4 * Copyright (C) 1995, 1996 by Volker Lendecke
8 #ifndef _LINUX_NCP_FS_H
9 #define _LINUX_NCP_FS_H
13 #include <linux/types.h>
15 #include <linux/ncp_mount.h>
17 /* NLS charsets by ioctl */
18 #define NCP_IOCSNAME_LEN 20
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>
32 struct ncp_ioctl_request
{
33 unsigned int function
;
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! */
58 #define NCP_LOCK_LOG 0
61 #define NCP_LOCK_CLEAR 256
66 #define NCP_LOCK_DEFAULT_TIMEOUT 18
67 #define NCP_LOCK_MAX_TIMEOUT 180
71 struct ncp_setroot_ioctl
78 struct ncp_objectname_ioctl
80 #define NCP_AUTH_NONE 0x00
81 #define NCP_AUTH_BIND 0x31
82 #define NCP_AUTH_NDS 0x32
84 size_t object_name_len
;
85 void* object_name
; /* an userspace data, in most cases user name */
88 struct ncp_privatedata_ioctl
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)
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)
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
136 #include <linux/config.h>
138 #undef NCPFS_PARANOIA
143 #define DPRINTK(format, args...) printk(format , ## args)
145 #define DPRINTK(format, args...)
149 #define DDPRINTK(format, args...) printk(format , ## args)
151 #define DDPRINTK(format, args...)
154 /* The readdir cache size controls how many directory entries are
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)
167 __u32 dirEntNum
__attribute__((packed
));
168 __u32 DosDirNum
__attribute__((packed
));
169 __u32 volNumber
__attribute__((packed
));
170 #ifdef CONFIG_NCPFS_SMALLDOS
173 #ifdef CONFIG_NCPFS_STRONG
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
;
210 ncp_kmalloc(unsigned int size
, int priority
)
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;
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
)
274 if (*name
>= 'a' && *name
<= 'z') {
275 *name
-= ('a' - 'A');
281 static inline void str_lower(char *name
)
284 if (*name
>= 'A' && *name
<= 'Z') {
285 *name
+= ('a' - 'A');
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
);
301 #if defined(CONFIG_NCPFS_SMALLDOS) && defined(CONFIG_NCPFS_OS2_NS)
302 if ((ns
== NW_NS_OS2
) && (nscreator
== NW_NS_DOS
))
306 #ifdef CONFIG_NCPFS_OS2_NS
308 #endif /* CONFIG_NCPFS_OS2_NS */
309 #ifdef CONFIG_NCPFS_NFS_NS
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
;
326 #endif /* CONFIG_NCPFS_NFS_NS */
329 #endif /* __KERNEL__ */
331 #endif /* _LINUX_NCP_FS_H */