Import 2.3.25pre1
[davej-history.git] / include / linux / ncp_fs.h
blob1be68cfb5dc2477479dd11f88f1c12b13eae042e
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/ipx.h>
16 #include <linux/ncp_no.h>
19 * ioctl commands
22 struct ncp_ioctl_request {
23 unsigned int function;
24 unsigned int size;
25 char *data;
28 struct ncp_fs_info {
29 int version;
30 struct sockaddr_ipx addr;
31 __kernel_uid_t mounted_uid;
32 int connection; /* Connection number the server assigned us */
33 int buffer_size; /* The negotiated buffer size, to be
34 used for read/write requests! */
36 int volume_number;
37 __u32 directory_id;
40 struct ncp_sign_init
42 char sign_root[8];
43 char sign_last[16];
46 struct ncp_lock_ioctl
48 #define NCP_LOCK_LOG 0
49 #define NCP_LOCK_SH 1
50 #define NCP_LOCK_EX 2
51 #define NCP_LOCK_CLEAR 256
52 int cmd;
53 int origin;
54 unsigned int offset;
55 unsigned int length;
56 #define NCP_LOCK_DEFAULT_TIMEOUT 18
57 #define NCP_LOCK_MAX_TIMEOUT 180
58 int timeout;
61 struct ncp_setroot_ioctl
63 int volNumber;
64 int namespace;
65 __u32 dirEntNum;
68 struct ncp_objectname_ioctl
70 #define NCP_AUTH_NONE 0x00
71 #define NCP_AUTH_BIND 0x31
72 #define NCP_AUTH_NDS 0x32
73 int auth_type;
74 size_t object_name_len;
75 void* object_name; /* an userspace data, in most cases user name */
78 struct ncp_privatedata_ioctl
80 size_t len;
81 void* data; /* ~1000 for NDS */
84 /* NLS charsets by ioctl */
85 #define NCP_IOCSNAME_LEN 20
86 struct ncp_nls_ioctl
88 unsigned char codepage[NCP_IOCSNAME_LEN+1];
89 unsigned char iocharset[NCP_IOCSNAME_LEN+1];
92 #define NCP_IOC_NCPREQUEST _IOR('n', 1, struct ncp_ioctl_request)
93 #define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_uid_t)
95 #if 1
96 #ifdef __KERNEL__
97 /* remove after ncpfs-2.0.13 gets released or at the beginning of kernel-2.1. codefreeze */
98 #define NCP_IOC_GETMOUNTUID_INT _IOW('n', 2, unsigned int)
99 #endif
100 #endif
102 #define NCP_IOC_CONN_LOGGED_IN _IO('n', 3)
104 #define NCP_GET_FS_INFO_VERSION (1)
105 #define NCP_IOC_GET_FS_INFO _IOWR('n', 4, struct ncp_fs_info)
107 #define NCP_IOC_SIGN_INIT _IOR('n', 5, struct ncp_sign_init)
108 #define NCP_IOC_SIGN_WANTED _IOR('n', 6, int)
109 #define NCP_IOC_SET_SIGN_WANTED _IOW('n', 6, int)
111 #define NCP_IOC_LOCKUNLOCK _IOR('n', 7, struct ncp_lock_ioctl)
113 #define NCP_IOC_GETROOT _IOW('n', 8, struct ncp_setroot_ioctl)
114 #define NCP_IOC_SETROOT _IOR('n', 8, struct ncp_setroot_ioctl)
116 #define NCP_IOC_GETOBJECTNAME _IOWR('n', 9, struct ncp_objectname_ioctl)
117 #define NCP_IOC_SETOBJECTNAME _IOR('n', 9, struct ncp_objectname_ioctl)
118 #define NCP_IOC_GETPRIVATEDATA _IOWR('n', 10, struct ncp_privatedata_ioctl)
119 #define NCP_IOC_SETPRIVATEDATA _IOR('n', 10, struct ncp_privatedata_ioctl)
121 #define NCP_IOC_GETCHARSETS _IOWR('n', 11, struct ncp_nls_ioctl)
122 #define NCP_IOC_SETCHARSETS _IOR('n', 11, struct ncp_nls_ioctl)
124 #define NCP_IOC_GETDENTRYTTL _IOW('n', 12, __u32)
125 #define NCP_IOC_SETDENTRYTTL _IOR('n', 12, __u32)
128 * The packet size to allocate. One page should be enough.
130 #define NCP_PACKET_SIZE 4070
132 #define NCP_MAXPATHLEN 255
133 #define NCP_MAXNAMELEN 14
135 #ifdef __KERNEL__
137 #include <linux/config.h>
139 #undef NCPFS_PARANOIA
140 #ifndef DEBUG_NCP
141 #define DEBUG_NCP 0
142 #endif
143 #if DEBUG_NCP > 0
144 #define DPRINTK(format, args...) printk(format , ## args)
145 #else
146 #define DPRINTK(format, args...)
147 #endif
149 #if DEBUG_NCP > 1
150 #define DDPRINTK(format, args...) printk(format , ## args)
151 #else
152 #define DDPRINTK(format, args...)
153 #endif
155 #define NCP_MAX_RPC_TIMEOUT (6*HZ)
158 struct ncp_entry_info {
159 struct nw_info_struct i;
160 ino_t ino;
161 int opened;
162 int access;
163 __u32 server_file_handle __attribute__((packed));
164 __u8 open_create_action __attribute__((packed));
165 __u8 file_handle[6] __attribute__((packed));
168 /* Guess, what 0x564c is :-) */
169 #define NCP_SUPER_MAGIC 0x564c
172 #define NCP_SBP(sb) (&((sb)->u.ncpfs_sb))
174 #define NCP_SERVER(inode) NCP_SBP((inode)->i_sb)
175 #define NCP_FINFO(inode) (&((inode)->u.ncpfs_i))
177 #ifdef DEBUG_NCP_MALLOC
179 #include <linux/malloc.h>
181 extern int ncp_malloced;
182 extern int ncp_current_malloced;
184 static inline void *
185 ncp_kmalloc(unsigned int size, int priority)
187 ncp_malloced += 1;
188 ncp_current_malloced += 1;
189 return kmalloc(size, priority);
192 static inline void ncp_kfree_s(void *obj, int size)
194 ncp_current_malloced -= 1;
195 kfree_s(obj, size);
198 #else /* DEBUG_NCP_MALLOC */
200 #define ncp_kmalloc(s,p) kmalloc(s,p)
201 #define ncp_kfree_s(o,s) kfree_s(o,s)
203 #endif /* DEBUG_NCP_MALLOC */
205 /* linux/fs/ncpfs/inode.c */
206 int ncp_notify_change(struct dentry *, struct iattr *attr);
207 struct super_block *ncp_read_super(struct super_block *, void *, int);
208 struct inode *ncp_iget(struct super_block *, struct ncp_entry_info *);
209 void ncp_update_inode(struct inode *, struct ncp_entry_info *);
210 void ncp_update_inode2(struct inode *, struct ncp_entry_info *);
211 extern int init_ncp_fs(void);
213 /* linux/fs/ncpfs/dir.c */
214 extern struct inode_operations ncp_dir_inode_operations;
215 int ncp_conn_logged_in(struct super_block *);
216 int ncp_date_dos2unix(__u16 time, __u16 date);
217 void ncp_date_unix2dos(int unix_date, __u16 * time, __u16 * date);
219 /* linux/fs/ncpfs/ioctl.c */
220 int ncp_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
222 /* linux/fs/ncpfs/sock.c */
223 int ncp_request2(struct ncp_server *server, int function,
224 void* reply, int max_reply_size);
225 static int inline ncp_request(struct ncp_server *server, int function) {
226 return ncp_request2(server, function, server->packet, server->packet_size);
228 int ncp_connect(struct ncp_server *server);
229 int ncp_disconnect(struct ncp_server *server);
230 void ncp_lock_server(struct ncp_server *server);
231 void ncp_unlock_server(struct ncp_server *server);
233 /* linux/fs/ncpfs/file.c */
234 extern struct inode_operations ncp_file_inode_operations;
235 int ncp_make_open(struct inode *, int);
237 /* linux/fs/ncpfs/mmap.c */
238 int ncp_mmap(struct file *, struct vm_area_struct *);
240 /* linux/fs/ncpfs/ncplib_kernel.c */
241 int ncp_make_closed(struct inode *);
243 static inline void str_upper(char *name)
245 while (*name) {
246 if (*name >= 'a' && *name <= 'z') {
247 *name -= ('a' - 'A');
249 name++;
253 static inline void str_lower(char *name)
255 while (*name) {
256 if (*name >= 'A' && *name <= 'Z') {
257 *name += ('a' - 'A');
259 name++;
263 static inline int ncp_namespace(struct inode *inode)
265 struct ncp_server *server = NCP_SERVER(inode);
266 return server->name_space[NCP_FINFO(inode)->volNumber];
269 static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator) {
270 #if defined(CONFIG_NCPFS_NFS_NS) || defined(CONFIG_NCPFS_OS2_NS)
271 int ns = ncp_namespace(i);
272 #endif
273 #if defined(CONFIG_NCPFS_SMALLDOS) && defined(CONFIG_NCPFS_OS2_NS)
274 if ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS))
275 return 0;
276 #endif
277 return
278 #ifdef CONFIG_NCPFS_OS2_NS
279 (ns == NW_NS_OS2) ||
280 #endif /* CONFIG_NCPFS_OS2_NS */
281 #ifdef CONFIG_NCPFS_NFS_NS
282 (ns == NW_NS_NFS) ||
283 #endif /* CONFIG_NCPFS_NFS_NS */
287 static inline int ncp_preserve_case(struct inode *i)
289 return ncp_preserve_entry_case(i, NW_NS_OS2);
292 static inline int ncp_case_sensitive(struct inode *i)
294 #ifdef CONFIG_NCPFS_NFS_NS
295 return ncp_namespace(i) == NW_NS_NFS;
296 #else
297 return 0;
298 #endif /* CONFIG_NCPFS_NFS_NS */
301 #endif /* __KERNEL__ */
303 #endif /* _LINUX_NCP_FS_H */