1
2
3
4
5
6
7
8#ifndef _LINUX_NCP_FS_H
9#define _LINUX_NCP_FS_H
10
11#include <linux/fs.h>
12#include <linux/in.h>
13#include <linux/types.h>
14
15#include <linux/ipx.h>
16#include <linux/ncp_no.h>
17
18
19
20
21
22struct ncp_ioctl_request {
23 unsigned int function;
24 unsigned int size;
25 char *data;
26};
27
28struct ncp_fs_info {
29 int version;
30 struct sockaddr_ipx addr;
31 __kernel_uid_t mounted_uid;
32 int connection;
33 int buffer_size;
34
35
36 int volume_number;
37 __u32 directory_id;
38};
39
40struct ncp_fs_info_v2 {
41 int version;
42 unsigned long mounted_uid;
43 unsigned int connection;
44 unsigned int buffer_size;
45
46 unsigned int volume_number;
47 __u32 directory_id;
48
49 __u32 dummy1;
50 __u32 dummy2;
51 __u32 dummy3;
52};
53
54struct ncp_sign_init
55{
56 char sign_root[8];
57 char sign_last[16];
58};
59
60struct ncp_lock_ioctl
61{
62#define NCP_LOCK_LOG 0
63#define NCP_LOCK_SH 1
64#define NCP_LOCK_EX 2
65#define NCP_LOCK_CLEAR 256
66 int cmd;
67 int origin;
68 unsigned int offset;
69 unsigned int length;
70#define NCP_LOCK_DEFAULT_TIMEOUT 18
71#define NCP_LOCK_MAX_TIMEOUT 180
72 int timeout;
73};
74
75struct ncp_setroot_ioctl
76{
77 int volNumber;
78 int namespace;
79 __u32 dirEntNum;
80};
81
82struct ncp_objectname_ioctl
83{
84#define NCP_AUTH_NONE 0x00
85#define NCP_AUTH_BIND 0x31
86#define NCP_AUTH_NDS 0x32
87 int auth_type;
88 size_t object_name_len;
89 void* object_name;
90};
91
92struct ncp_privatedata_ioctl
93{
94 size_t len;
95 void* data;
96};
97
98
99#define NCP_IOCSNAME_LEN 20
100struct ncp_nls_ioctl
101{
102 unsigned char codepage[NCP_IOCSNAME_LEN+1];
103 unsigned char iocharset[NCP_IOCSNAME_LEN+1];
104};
105
106#define NCP_IOC_NCPREQUEST _IOR('n', 1, struct ncp_ioctl_request)
107#define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_old_uid_t)
108#define NCP_IOC_GETMOUNTUID2 _IOW('n', 2, unsigned long)
109
110#define NCP_IOC_CONN_LOGGED_IN _IO('n', 3)
111
112#define NCP_GET_FS_INFO_VERSION (1)
113#define NCP_IOC_GET_FS_INFO _IOWR('n', 4, struct ncp_fs_info)
114#define NCP_GET_FS_INFO_VERSION_V2 (2)
115#define NCP_IOC_GET_FS_INFO_V2 _IOWR('n', 4, struct ncp_fs_info_v2)
116
117#define NCP_IOC_SIGN_INIT _IOR('n', 5, struct ncp_sign_init)
118#define NCP_IOC_SIGN_WANTED _IOR('n', 6, int)
119#define NCP_IOC_SET_SIGN_WANTED _IOW('n', 6, int)
120
121#define NCP_IOC_LOCKUNLOCK _IOR('n', 7, struct ncp_lock_ioctl)
122
123#define NCP_IOC_GETROOT _IOW('n', 8, struct ncp_setroot_ioctl)
124#define NCP_IOC_SETROOT _IOR('n', 8, struct ncp_setroot_ioctl)
125
126#define NCP_IOC_GETOBJECTNAME _IOWR('n', 9, struct ncp_objectname_ioctl)
127#define NCP_IOC_SETOBJECTNAME _IOR('n', 9, struct ncp_objectname_ioctl)
128#define NCP_IOC_GETPRIVATEDATA _IOWR('n', 10, struct ncp_privatedata_ioctl)
129#define NCP_IOC_SETPRIVATEDATA _IOR('n', 10, struct ncp_privatedata_ioctl)
130
131#define NCP_IOC_GETCHARSETS _IOWR('n', 11, struct ncp_nls_ioctl)
132#define NCP_IOC_SETCHARSETS _IOR('n', 11, struct ncp_nls_ioctl)
133
134#define NCP_IOC_GETDENTRYTTL _IOW('n', 12, __u32)
135#define NCP_IOC_SETDENTRYTTL _IOR('n', 12, __u32)
136
137
138
139
140#define NCP_PACKET_SIZE 4070
141
142#define NCP_MAXPATHLEN 255
143#define NCP_MAXNAMELEN 14
144
145#ifdef __KERNEL__
146
147#include <linux/config.h>
148
149
150#undef PRINTK
151
152#define PRINTK(format, args...) printk(KERN_DEBUG format , ## args)
153
154#undef NCPFS_PARANOIA
155#ifdef NCPFS_PARANOIA
156#define PPRINTK(format, args...) PRINTK(format , ## args)
157#else
158#define PPRINTK(format, args...)
159#endif
160
161#ifndef DEBUG_NCP
162#define DEBUG_NCP 0
163#endif
164#if DEBUG_NCP > 0
165#define DPRINTK(format, args...) PRINTK(format , ## args)
166#else
167#define DPRINTK(format, args...)
168#endif
169#if DEBUG_NCP > 1
170#define DDPRINTK(format, args...) PRINTK(format , ## args)
171#else
172#define DDPRINTK(format, args...)
173#endif
174
175#define NCP_MAX_RPC_TIMEOUT (6*HZ)
176
177
178struct ncp_entry_info {
179 struct nw_info_struct i;
180 ino_t ino;
181 int opened;
182 int access;
183 __u32 server_file_handle __attribute__((packed));
184 __u8 open_create_action __attribute__((packed));
185 __u8 file_handle[6] __attribute__((packed));
186};
187
188
189#define NCP_SUPER_MAGIC 0x564c
190
191
192#define NCP_SBP(sb) (&((sb)->u.ncpfs_sb))
193
194#define NCP_SERVER(inode) NCP_SBP((inode)->i_sb)
195#define NCP_FINFO(inode) (&((inode)->u.ncpfs_i))
196
197#ifdef DEBUG_NCP_MALLOC
198
199#include <linux/slab.h>
200
201extern int ncp_malloced;
202extern int ncp_current_malloced;
203
204static inline void *
205 ncp_kmalloc(unsigned int size, int priority)
206{
207 ncp_malloced += 1;
208 ncp_current_malloced += 1;
209 return kmalloc(size, priority);
210}
211
212static inline void ncp_kfree_s(void *obj, int size)
213{
214 ncp_current_malloced -= 1;
215 kfree(obj);
216}
217
218#else
219
220#define ncp_kmalloc(s,p) kmalloc(s,p)
221#define ncp_kfree_s(o,s) kfree(o)
222
223#endif
224
225
226int ncp_notify_change(struct dentry *, struct iattr *);
227struct super_block *ncp_read_super(struct super_block *, void *, int);
228struct inode *ncp_iget(struct super_block *, struct ncp_entry_info *);
229void ncp_update_inode(struct inode *, struct ncp_entry_info *);
230void ncp_update_inode2(struct inode *, struct ncp_entry_info *);
231
232
233extern struct inode_operations ncp_dir_inode_operations;
234extern struct file_operations ncp_dir_operations;
235int ncp_conn_logged_in(struct super_block *);
236int ncp_date_dos2unix(__u16 time, __u16 date);
237void ncp_date_unix2dos(int unix_date, __u16 * time, __u16 * date);
238
239
240int ncp_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
241
242
243int ncp_request2(struct ncp_server *server, int function,
244 void* reply, int max_reply_size);
245static int inline ncp_request(struct ncp_server *server, int function) {
246 return ncp_request2(server, function, server->packet, server->packet_size);
247}
248int ncp_connect(struct ncp_server *server);
249int ncp_disconnect(struct ncp_server *server);
250void ncp_lock_server(struct ncp_server *server);
251void ncp_unlock_server(struct ncp_server *server);
252
253
254extern struct inode_operations ncp_file_inode_operations;
255extern struct file_operations ncp_file_operations;
256int ncp_make_open(struct inode *, int);
257
258
259int ncp_mmap(struct file *, struct vm_area_struct *);
260
261
262int ncp_make_closed(struct inode *);
263
264#define ncp_namespace(i) (NCP_SERVER(i)->name_space[NCP_FINFO(i)->volNumber])
265
266static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator)
267{
268#ifdef CONFIG_NCPFS_SMALLDOS
269 int ns = ncp_namespace(i);
270
271 if ((ns == NW_NS_DOS)
272#ifdef CONFIG_NCPFS_OS2_NS
273 || ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS))
274#endif
275 )
276 return 0;
277#endif
278 return 1;
279}
280
281#define ncp_preserve_case(i) (ncp_namespace(i) != NW_NS_DOS)
282
283static inline int ncp_case_sensitive(struct inode *i)
284{
285#ifdef CONFIG_NCPFS_NFS_NS
286 return ncp_namespace(i) == NW_NS_NFS;
287#else
288 return 0;
289#endif
290}
291
292#endif
293
294#endif
295