~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/ncpfs/ncplib_kernel.h

Version: ~ [ linux-5.2-rc1 ] ~ [ linux-5.1.2 ] ~ [ linux-5.0.16 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.43 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.119 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.176 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.179 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.139 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.67 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  ncplib_kernel.h
  3  *
  4  *  Copyright (C) 1995, 1996 by Volker Lendecke
  5  *  Modified for big endian by J.F. Chadima and David S. Miller
  6  *  Modified 1997 Peter Waltenberg, Bill Hawes, David Woodhouse for 2.1 dcache
  7  *  Modified 1998, 1999 Wolfram Pienkoss for NLS
  8  *  Modified 1999 Wolfram Pienkoss for directory caching
  9  *
 10  */
 11 
 12 #ifndef _NCPLIB_H
 13 #define _NCPLIB_H
 14 
 15 
 16 #include <linux/fs.h>
 17 #include <linux/types.h>
 18 #include <linux/errno.h>
 19 #include <linux/slab.h>
 20 #include <linux/stat.h>
 21 #include <linux/fcntl.h>
 22 #include <linux/pagemap.h>
 23 
 24 #include <asm/uaccess.h>
 25 #include <asm/byteorder.h>
 26 #include <asm/unaligned.h>
 27 #include <asm/string.h>
 28 
 29 #ifdef CONFIG_NCPFS_NLS
 30 #include <linux/nls.h>
 31 #else
 32 #include <linux/ctype.h>
 33 #endif /* CONFIG_NCPFS_NLS */
 34 
 35 #define NCP_MIN_SYMLINK_SIZE    8
 36 #define NCP_MAX_SYMLINK_SIZE    512
 37 
 38 #define NCP_BLOCK_SHIFT         9
 39 #define NCP_BLOCK_SIZE          (1 << (NCP_BLOCK_SHIFT))
 40 
 41 int ncp_negotiate_buffersize(struct ncp_server *, int, int *);
 42 int ncp_negotiate_size_and_options(struct ncp_server *server, int size,
 43                           int options, int *ret_size, int *ret_options);
 44 
 45 int ncp_get_volume_info_with_number(struct ncp_server* server, int n,
 46                                     struct ncp_volume_info *target);
 47 
 48 int ncp_get_directory_info(struct ncp_server* server, __u8 dirhandle,
 49                            struct ncp_volume_info* target);
 50 
 51 int ncp_close_file(struct ncp_server *, const char *);
 52 static inline int ncp_read_bounce_size(__u32 size) {
 53         return sizeof(struct ncp_reply_header) + 2 + 2 + size + 8;
 54 };
 55 int ncp_read_bounce(struct ncp_server *, const char *, __u32, __u16, 
 56                 struct iov_iter *, int *, void *bounce, __u32 bouncelen);
 57 int ncp_read_kernel(struct ncp_server *, const char *, __u32, __u16, 
 58                 char *, int *);
 59 int ncp_write_kernel(struct ncp_server *, const char *, __u32, __u16,
 60                 const char *, int *);
 61 
 62 static inline void ncp_inode_close(struct inode *inode) {
 63         atomic_dec(&NCP_FINFO(inode)->opened);
 64 }
 65 
 66 void ncp_extract_file_info(const void* src, struct nw_info_struct* target);
 67 int ncp_obtain_info(struct ncp_server *server, struct inode *, const char *,
 68                 struct nw_info_struct *target);
 69 int ncp_obtain_nfs_info(struct ncp_server *server, struct nw_info_struct *target);
 70 int ncp_update_known_namespace(struct ncp_server *server, __u8 volume, int *ret_ns);
 71 int ncp_get_volume_root(struct ncp_server *server, const char *volname,
 72                         __u32 *volume, __le32 *dirent, __le32 *dosdirent);
 73 int ncp_lookup_volume(struct ncp_server *, const char *, struct nw_info_struct *);
 74 int ncp_modify_file_or_subdir_dos_info(struct ncp_server *, struct inode *,
 75          __le32, const struct nw_modify_dos_info *info);
 76 int ncp_modify_file_or_subdir_dos_info_path(struct ncp_server *, struct inode *,
 77          const char* path, __le32, const struct nw_modify_dos_info *info);
 78 int ncp_modify_nfs_info(struct ncp_server *, __u8 volnum, __le32 dirent,
 79                         __u32 mode, __u32 rdev);
 80 
 81 int ncp_del_file_or_subdir2(struct ncp_server *, struct dentry*);
 82 int ncp_del_file_or_subdir(struct ncp_server *, struct inode *, const char *);
 83 int ncp_open_create_file_or_subdir(struct ncp_server *, struct inode *, const char *,
 84                                 int, __le32, __le16, struct ncp_entry_info *);
 85 
 86 int ncp_initialize_search(struct ncp_server *, struct inode *,
 87                       struct nw_search_sequence *target);
 88 int ncp_search_for_fileset(struct ncp_server *server,
 89                            struct nw_search_sequence *seq,
 90                            int* more, int* cnt,
 91                            char* buffer, size_t bufsize,
 92                            char** rbuf, size_t* rsize);
 93 
 94 int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server,
 95                               struct inode *, const char *, struct inode *, const char *);
 96 
 97 
 98 int
 99 ncp_LogPhysicalRecord(struct ncp_server *server,
100                       const char *file_id, __u8 locktype,
101                       __u32 offset, __u32 length, __u16 timeout);
102 
103 #ifdef CONFIG_NCPFS_IOCTL_LOCKING
104 int
105 ncp_ClearPhysicalRecord(struct ncp_server *server,
106                         const char *file_id,
107                         __u32 offset, __u32 length);
108 #endif  /* CONFIG_NCPFS_IOCTL_LOCKING */
109 
110 int
111 ncp_mount_subdir(struct ncp_server *, __u8, __u8, __le32,
112                  __u32* volume, __le32* dirent, __le32* dosdirent);
113 int ncp_dirhandle_alloc(struct ncp_server *, __u8 vol, __le32 dirent, __u8 *dirhandle);
114 int ncp_dirhandle_free(struct ncp_server *, __u8 dirhandle);
115 
116 int ncp_create_new(struct inode *dir, struct dentry *dentry,
117                           umode_t mode, dev_t rdev, __le32 attributes);
118 
119 static inline int ncp_is_nfs_extras(struct ncp_server* server, unsigned int volnum) {
120 #ifdef CONFIG_NCPFS_NFS_NS
121         return (server->m.flags & NCP_MOUNT_NFS_EXTRAS) &&
122                (server->name_space[volnum] == NW_NS_NFS);
123 #else
124         return 0;
125 #endif
126 }
127 
128 #ifdef CONFIG_NCPFS_NLS
129 
130 int ncp__io2vol(struct ncp_server *, unsigned char *, unsigned int *,
131                                 const unsigned char *, unsigned int, int);
132 int ncp__vol2io(struct ncp_server *, unsigned char *, unsigned int *,
133                                 const unsigned char *, unsigned int, int);
134 
135 #define NCP_ESC                 ':'
136 #define NCP_IO_TABLE(sb)        (NCP_SBP(sb)->nls_io)
137 #define ncp_tolower(t, c)       nls_tolower(t, c)
138 #define ncp_toupper(t, c)       nls_toupper(t, c)
139 #define ncp_strnicmp(t, s1, s2, len) \
140         nls_strnicmp(t, s1, s2, len)
141 #define ncp_io2vol(S,m,i,n,k,U) ncp__io2vol(S,m,i,n,k,U)
142 #define ncp_vol2io(S,m,i,n,k,U) ncp__vol2io(S,m,i,n,k,U)
143 
144 #else
145 
146 int ncp__io2vol(unsigned char *, unsigned int *,
147                                 const unsigned char *, unsigned int, int);
148 int ncp__vol2io(unsigned char *, unsigned int *,
149                                 const unsigned char *, unsigned int, int);
150 
151 #define NCP_IO_TABLE(sb)        NULL
152 #define ncp_tolower(t, c)       tolower(c)
153 #define ncp_toupper(t, c)       toupper(c)
154 #define ncp_io2vol(S,m,i,n,k,U) ncp__io2vol(m,i,n,k,U)
155 #define ncp_vol2io(S,m,i,n,k,U) ncp__vol2io(m,i,n,k,U)
156 
157 
158 static inline int ncp_strnicmp(const struct nls_table *t,
159                 const unsigned char *s1, const unsigned char *s2, int len)
160 {
161         while (len--) {
162                 if (tolower(*s1++) != tolower(*s2++))
163                         return 1;
164         }
165 
166         return 0;
167 }
168 
169 #endif /* CONFIG_NCPFS_NLS */
170 
171 #define NCP_GET_AGE(dentry)     (jiffies - (dentry)->d_time)
172 #define NCP_MAX_AGE(server)     atomic_read(&(server)->dentry_ttl)
173 #define NCP_TEST_AGE(server,dentry)     (NCP_GET_AGE(dentry) < NCP_MAX_AGE(server))
174 
175 static inline void
176 ncp_age_dentry(struct ncp_server* server, struct dentry* dentry)
177 {
178         dentry->d_time = jiffies - NCP_MAX_AGE(server);
179 }
180 
181 static inline void
182 ncp_new_dentry(struct dentry* dentry)
183 {
184         dentry->d_time = jiffies;
185 }
186 
187 struct ncp_cache_head {
188         time_t          mtime;
189         unsigned long   time;   /* cache age */
190         unsigned long   end;    /* last valid fpos in cache */
191         int             eof;
192 };
193 
194 #define NCP_DIRCACHE_SIZE       ((int)(PAGE_SIZE/sizeof(struct dentry *)))
195 union ncp_dir_cache {
196         struct ncp_cache_head   head;
197         struct dentry           *dentry[NCP_DIRCACHE_SIZE];
198 };
199 
200 #define NCP_FIRSTCACHE_SIZE     ((int)((NCP_DIRCACHE_SIZE * \
201         sizeof(struct dentry *) - sizeof(struct ncp_cache_head)) / \
202         sizeof(struct dentry *)))
203 
204 #define NCP_DIRCACHE_START      (NCP_DIRCACHE_SIZE - NCP_FIRSTCACHE_SIZE)
205 
206 struct ncp_cache_control {
207         struct  ncp_cache_head          head;
208         struct  page                    *page;
209         union   ncp_dir_cache           *cache;
210         unsigned long                   fpos, ofs;
211         int                             filled, valid, idx;
212 };
213 
214 #endif /* _NCPLIB_H */
215 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp