Import 2.3.6
[davej-history.git] / include / linux / ncp_fs.h
blob9c5df53425d46f857f5e95425c54fa0bf8f4fd1f
1 /*
2 * ncp_fs.h
4 * Copyright (C) 1995, 1996 by Volker Lendecke
6 */
8 #ifndef _LINUX_NCP_FS_H
9 #define _LINUX_NCP_FS_H
11 #include <linux/fs.h>
12 #include <linux/in.h>
13 #include <linux/types.h>
15 #include <linux/ncp_mount.h>
17 /* NLS charsets by ioctl */
18 #define NCP_IOCSNAME_LEN 20
19 struct ncp_nls_ioctl
21 unsigned char codepage[NCP_IOCSNAME_LEN+1];
22 unsigned char iocharset[NCP_IOCSNAME_LEN+1];
25 #include <linux/ncp_fs_sb.h>
26 #include <linux/ncp_fs_i.h>
29 * ioctl commands
32 struct ncp_ioctl_request {
33 unsigned int function;
34 unsigned int size;
35 char *data;
38 struct ncp_fs_info {
39 int version;
40 struct sockaddr_ipx addr;
41 __kernel_uid_t mounted_uid;
42 int connection; /* Connection number the server assigned us */
43 int buffer_size; /* The negotiated buffer size, to be
44 used for read/write requests! */
46 int volume_number;
47 __u32 directory_id;
50 struct ncp_sign_init
52 char sign_root[8];
53 char sign_last[16];
56 struct ncp_lock_ioctl
58 #define NCP_LOCK_LOG 0
59 #define NCP_LOCK_SH 1
60 #define NCP_LOCK_EX 2
61 #define NCP_LOCK_CLEAR 256
62 int cmd;
63 int origin;
64 unsigned int offset;
65 unsigned int length;
66 #define NCP_LOCK_DEFAULT_TIMEOUT 18
67 #define NCP_LOCK_MAX_TIMEOUT 180
68 int timeout;
71 struct ncp_setroot_ioctl
73 int volNumber;
74 int namespace;
75 __u32 dirEntNum;
78 struct ncp_objectname_ioctl
80 #define NCP_AUTH_NONE 0x00
81 #define NCP_AUTH_BIND 0x31
82 #define NCP_AUTH_NDS 0x32
83 int auth_type;
84 size_t object_name_len;
85 void* object_name; /* an userspace data, in most cases user name */
88 struct ncp_privatedata_ioctl
90 size_t len;
91 void* data; /* ~1000 for NDS */
94 #define NCP_IOC_NCPREQUEST _IOR('n', 1, struct ncp_ioctl_request)
95 #define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_uid_t)
97 #if 1
98 #ifdef __KERNEL__
99 /* remove after ncpfs-2.0.13 gets released or at the beginning of kernel-2.1. codefreeze */
100 #define NCP_IOC_GETMOUNTUID_INT _IOW('n', 2, unsigned int)
101 #endif
102 #endif
104 #define NCP_IOC_CONN_LOGGED_IN _IO('n', 3)
106 #define NCP_GET_FS_INFO_VERSION (1)
107 #define NCP_IOC_GET_FS_INFO _IOWR('n', 4, struct ncp_fs_info)
109 #define NCP_IOC_SIGN_INIT _IOR('n', 5, struct ncp_sign_init)
110 #define NCP_IOC_SIGN_WANTED _IOR('n', 6, int)
111 #define NCP_IOC_SET_SIGN_WANTED _IOW('n', 6, int)
113 #define NCP_IOC_LOCKUNLOCK _IOR('n', 7, struct ncp_lock_ioctl)
115 #define NCP_IOC_GETROOT _IOW('n', 8, struct ncp_setroot_ioctl)
116 #define NCP_IOC_SETROOT _IOR('n', 8, struct ncp_setroot_ioctl)
118 #define NCP_IOC_GETOBJECTNAME _IOWR('n', 9, struct ncp_objectname_ioctl)
119 #define NCP_IOC_SETOBJECTNAME _IOR('n', 9, struct ncp_objectname_ioctl)
120 #define NCP_IOC_GETPRIVATEDATA _IOWR('n', 10, struct ncp_privatedata_ioctl)
121 #define NCP_IOC_SETPRIVATEDATA _IOR('n', 10, struct ncp_privatedata_ioctl)
123 #define NCP_IOC_GETCHARSETS _IOWR('n', 11, struct ncp_nls_ioctl)
124 #define NCP_IOC_SETCHARSETS _IOR('n', 11, struct ncp_nls_ioctl)
127 * The packet size to allocate. One page should be enough.
129 #define NCP_PACKET_SIZE 4070
131 #define NCP_MAXPATHLEN 255
132 #define NCP_MAXNAMELEN 14
134 #ifdef __KERNEL__
136 #include <linux/config.h>
138 #undef NCPFS_PARANOIA
139 #ifndef DEBUG_NCP
140 #define DEBUG_NCP 0
141 #endif
142 #if DEBUG_NCP > 0
143 #define DPRINTK(format, args...) printk(format , ## args)
144 #else
145 #define DPRINTK(format, args...)
146 #endif
148 #if DEBUG_NCP > 1
149 #define DDPRINTK(format, args...) printk(format , ## args)
150 #else
151 #define DDPRINTK(format, args...)
152 #endif
154 /* The readdir cache size controls how many directory entries are
155 * cached.
157 #define NCP_READDIR_CACHE_SIZE 64
159 #define NCP_MAX_RPC_TIMEOUT (6*HZ)
162 * This is the ncpfs part of the inode structure. This must contain
163 * all the information we need to work with an inode after creation.
164 * (Move to ncp_fs_i.h once it stabilizes, and add a union in fs.h)
166 struct ncpfs_i {
167 __u32 dirEntNum __attribute__((packed));
168 __u32 DosDirNum __attribute__((packed));
169 __u32 volNumber __attribute__((packed));
170 #ifdef CONFIG_NCPFS_SMALLDOS
171 __u32 origNS;
172 #endif
173 #ifdef CONFIG_NCPFS_STRONG
174 __u32 nwattr;
175 #endif
176 int opened;
177 int access;
178 __u32 server_file_handle __attribute__((packed));
179 __u8 open_create_action __attribute__((packed));
180 __u8 file_handle[6] __attribute__((packed));
184 * This is an extension of the nw_file_info structure with
185 * the additional information we need to create an inode.
187 struct ncpfs_inode_info {
188 ino_t ino; /* dummy inode number */
189 struct nw_file_info nw_info;
192 /* Guess, what 0x564c is :-) */
193 #define NCP_SUPER_MAGIC 0x564c
196 #define NCP_SBP(sb) ((struct ncp_server *)((sb)->u.generic_sbp))
198 #define NCP_SERVER(inode) NCP_SBP((inode)->i_sb)
199 /* We don't have an ncpfs union yet, so use smbfs ... */
200 #define NCP_FINFO(inode) ((struct ncpfs_i *)&((inode)->u.smbfs_i))
202 #ifdef DEBUG_NCP_MALLOC
204 #include <linux/malloc.h>
206 extern int ncp_malloced;
207 extern int ncp_current_malloced;
209 static inline void *
210 ncp_kmalloc(unsigned int size, int priority)
212 ncp_malloced += 1;
213 ncp_current_malloced += 1;
214 return kmalloc(size, priority);
217 static inline void ncp_kfree_s(void *obj, int size)
219 ncp_current_malloced -= 1;
220 kfree_s(obj, size);
223 #else /* DEBUG_NCP_MALLOC */
225 #define ncp_kmalloc(s,p) kmalloc(s,p)
226 #define ncp_kfree_s(o,s) kfree_s(o,s)
228 #endif /* DEBUG_NCP_MALLOC */
230 /* linux/fs/ncpfs/inode.c */
231 int ncp_notify_change(struct dentry *, struct iattr *attr);
232 struct super_block *ncp_read_super(struct super_block *, void *, int);
233 struct inode *ncp_iget(struct super_block *, struct ncpfs_inode_info *);
234 void ncp_update_inode(struct inode *, struct nw_file_info *);
235 void ncp_update_inode2(struct inode *, struct nw_file_info *);
236 extern int init_ncp_fs(void);
238 /* linux/fs/ncpfs/dir.c */
239 extern struct inode_operations ncp_dir_inode_operations;
240 int ncp_conn_logged_in(struct ncp_server *);
241 void ncp_init_dir_cache(void);
242 void ncp_invalid_dir_cache(struct inode *);
243 void ncp_free_dir_cache(void);
244 int ncp_date_dos2unix(__u16 time, __u16 date);
245 void ncp_date_unix2dos(int unix_date, __u16 * time, __u16 * date);
247 /* linux/fs/ncpfs/ioctl.c */
248 int ncp_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
250 /* linux/fs/ncpfs/sock.c */
251 int ncp_request2(struct ncp_server *server, int function,
252 void* reply, int max_reply_size);
253 static int inline ncp_request(struct ncp_server *server, int function) {
254 return ncp_request2(server, function, server->packet, server->packet_size);
256 int ncp_connect(struct ncp_server *server);
257 int ncp_disconnect(struct ncp_server *server);
258 void ncp_lock_server(struct ncp_server *server);
259 void ncp_unlock_server(struct ncp_server *server);
261 /* linux/fs/ncpfs/file.c */
262 extern struct inode_operations ncp_file_inode_operations;
263 int ncp_make_open(struct inode *, int);
265 /* linux/fs/ncpfs/mmap.c */
266 int ncp_mmap(struct file *, struct vm_area_struct *);
268 /* linux/fs/ncpfs/ncplib_kernel.c */
269 int ncp_make_closed(struct inode *);
271 static inline void str_upper(char *name)
273 while (*name) {
274 if (*name >= 'a' && *name <= 'z') {
275 *name -= ('a' - 'A');
277 name++;
281 static inline void str_lower(char *name)
283 while (*name) {
284 if (*name >= 'A' && *name <= 'Z') {
285 *name += ('a' - 'A');
287 name++;
291 static inline int ncp_namespace(struct inode *inode)
293 struct ncp_server *server = NCP_SERVER(inode);
294 return server->name_space[NCP_FINFO(inode)->volNumber];
297 static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator) {
298 #if defined(CONFIG_NCPFS_NFS_NS) || defined(CONFIG_NCPFS_OS2_NS)
299 int ns = ncp_namespace(i);
300 #endif
301 #if defined(CONFIG_NCPFS_SMALLDOS) && defined(CONFIG_NCPFS_OS2_NS)
302 if ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS))
303 return 0;
304 #endif
305 return
306 #ifdef CONFIG_NCPFS_OS2_NS
307 (ns == NW_NS_OS2) ||
308 #endif /* CONFIG_NCPFS_OS2_NS */
309 #ifdef CONFIG_NCPFS_NFS_NS
310 (ns == NW_NS_NFS) ||
311 #endif /* CONFIG_NCPFS_NFS_NS */
315 static inline int ncp_preserve_case(struct inode *i)
317 return ncp_preserve_entry_case(i, NW_NS_OS2);
320 static inline int ncp_case_sensitive(struct inode *i)
322 #ifdef CONFIG_NCPFS_NFS_NS
323 return ncp_namespace(i) == NW_NS_NFS;
324 #else
325 return 0;
326 #endif /* CONFIG_NCPFS_NFS_NS */
329 #endif /* __KERNEL__ */
331 #endif /* _LINUX_NCP_FS_H */