Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ncp_fs.h |
| 3 | * |
| 4 | * Copyright (C) 1995, 1996 by Volker Lendecke |
| 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> |
Jeff Garzik | e18fa70 | 2006-09-24 11:13:19 -0400 | [diff] [blame] | 14 | #include <linux/magic.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/ipx.h> |
| 17 | #include <linux/ncp_no.h> |
| 18 | |
| 19 | /* |
| 20 | * ioctl commands |
| 21 | */ |
| 22 | |
| 23 | struct ncp_ioctl_request { |
| 24 | unsigned int function; |
| 25 | unsigned int size; |
| 26 | char __user *data; |
| 27 | }; |
| 28 | |
| 29 | struct ncp_fs_info { |
| 30 | int version; |
| 31 | struct sockaddr_ipx addr; |
| 32 | __kernel_uid_t mounted_uid; |
| 33 | int connection; /* Connection number the server assigned us */ |
| 34 | int buffer_size; /* The negotiated buffer size, to be |
| 35 | used for read/write requests! */ |
| 36 | |
| 37 | int volume_number; |
| 38 | __le32 directory_id; |
| 39 | }; |
| 40 | |
| 41 | struct ncp_fs_info_v2 { |
| 42 | int version; |
| 43 | unsigned long mounted_uid; |
| 44 | unsigned int connection; |
| 45 | unsigned int buffer_size; |
| 46 | |
| 47 | unsigned int volume_number; |
| 48 | __le32 directory_id; |
| 49 | |
| 50 | __u32 dummy1; |
| 51 | __u32 dummy2; |
| 52 | __u32 dummy3; |
| 53 | }; |
| 54 | |
| 55 | struct ncp_sign_init |
| 56 | { |
| 57 | char sign_root[8]; |
| 58 | char sign_last[16]; |
| 59 | }; |
| 60 | |
| 61 | struct ncp_lock_ioctl |
| 62 | { |
| 63 | #define NCP_LOCK_LOG 0 |
| 64 | #define NCP_LOCK_SH 1 |
| 65 | #define NCP_LOCK_EX 2 |
| 66 | #define NCP_LOCK_CLEAR 256 |
| 67 | int cmd; |
| 68 | int origin; |
| 69 | unsigned int offset; |
| 70 | unsigned int length; |
| 71 | #define NCP_LOCK_DEFAULT_TIMEOUT 18 |
| 72 | #define NCP_LOCK_MAX_TIMEOUT 180 |
| 73 | int timeout; |
| 74 | }; |
| 75 | |
| 76 | struct ncp_setroot_ioctl |
| 77 | { |
| 78 | int volNumber; |
| 79 | int namespace; |
| 80 | __le32 dirEntNum; |
| 81 | }; |
| 82 | |
| 83 | struct ncp_objectname_ioctl |
| 84 | { |
| 85 | #define NCP_AUTH_NONE 0x00 |
| 86 | #define NCP_AUTH_BIND 0x31 |
| 87 | #define NCP_AUTH_NDS 0x32 |
| 88 | int auth_type; |
| 89 | size_t object_name_len; |
| 90 | void __user * object_name; /* an userspace data, in most cases user name */ |
| 91 | }; |
| 92 | |
| 93 | struct ncp_privatedata_ioctl |
| 94 | { |
| 95 | size_t len; |
| 96 | void __user * data; /* ~1000 for NDS */ |
| 97 | }; |
| 98 | |
| 99 | /* NLS charsets by ioctl */ |
| 100 | #define NCP_IOCSNAME_LEN 20 |
| 101 | struct ncp_nls_ioctl |
| 102 | { |
| 103 | unsigned char codepage[NCP_IOCSNAME_LEN+1]; |
| 104 | unsigned char iocharset[NCP_IOCSNAME_LEN+1]; |
| 105 | }; |
| 106 | |
| 107 | #define NCP_IOC_NCPREQUEST _IOR('n', 1, struct ncp_ioctl_request) |
| 108 | #define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_old_uid_t) |
| 109 | #define NCP_IOC_GETMOUNTUID2 _IOW('n', 2, unsigned long) |
| 110 | |
| 111 | #define NCP_IOC_CONN_LOGGED_IN _IO('n', 3) |
| 112 | |
| 113 | #define NCP_GET_FS_INFO_VERSION (1) |
| 114 | #define NCP_IOC_GET_FS_INFO _IOWR('n', 4, struct ncp_fs_info) |
| 115 | #define NCP_GET_FS_INFO_VERSION_V2 (2) |
| 116 | #define NCP_IOC_GET_FS_INFO_V2 _IOWR('n', 4, struct ncp_fs_info_v2) |
| 117 | |
| 118 | #define NCP_IOC_SIGN_INIT _IOR('n', 5, struct ncp_sign_init) |
| 119 | #define NCP_IOC_SIGN_WANTED _IOR('n', 6, int) |
| 120 | #define NCP_IOC_SET_SIGN_WANTED _IOW('n', 6, int) |
| 121 | |
| 122 | #define NCP_IOC_LOCKUNLOCK _IOR('n', 7, struct ncp_lock_ioctl) |
| 123 | |
| 124 | #define NCP_IOC_GETROOT _IOW('n', 8, struct ncp_setroot_ioctl) |
| 125 | #define NCP_IOC_SETROOT _IOR('n', 8, struct ncp_setroot_ioctl) |
| 126 | |
| 127 | #define NCP_IOC_GETOBJECTNAME _IOWR('n', 9, struct ncp_objectname_ioctl) |
| 128 | #define NCP_IOC_SETOBJECTNAME _IOR('n', 9, struct ncp_objectname_ioctl) |
| 129 | #define NCP_IOC_GETPRIVATEDATA _IOWR('n', 10, struct ncp_privatedata_ioctl) |
| 130 | #define NCP_IOC_SETPRIVATEDATA _IOR('n', 10, struct ncp_privatedata_ioctl) |
| 131 | |
| 132 | #define NCP_IOC_GETCHARSETS _IOWR('n', 11, struct ncp_nls_ioctl) |
| 133 | #define NCP_IOC_SETCHARSETS _IOR('n', 11, struct ncp_nls_ioctl) |
| 134 | |
| 135 | #define NCP_IOC_GETDENTRYTTL _IOW('n', 12, __u32) |
| 136 | #define NCP_IOC_SETDENTRYTTL _IOR('n', 12, __u32) |
| 137 | |
| 138 | /* |
| 139 | * The packet size to allocate. One page should be enough. |
| 140 | */ |
| 141 | #define NCP_PACKET_SIZE 4070 |
| 142 | |
| 143 | #define NCP_MAXPATHLEN 255 |
| 144 | #define NCP_MAXNAMELEN 14 |
| 145 | |
| 146 | #ifdef __KERNEL__ |
| 147 | |
David Woodhouse | 58908d0 | 2006-04-25 14:26:26 +0100 | [diff] [blame] | 148 | #include <linux/ncp_fs_i.h> |
| 149 | #include <linux/ncp_fs_sb.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | |
| 151 | /* undef because public define in umsdos_fs.h (ncp_fs.h isn't public) */ |
| 152 | #undef PRINTK |
| 153 | /* define because it is easy to change PRINTK to {*}PRINTK */ |
| 154 | #define PRINTK(format, args...) printk(KERN_DEBUG format , ## args) |
| 155 | |
| 156 | #undef NCPFS_PARANOIA |
| 157 | #ifdef NCPFS_PARANOIA |
| 158 | #define PPRINTK(format, args...) PRINTK(format , ## args) |
| 159 | #else |
| 160 | #define PPRINTK(format, args...) |
| 161 | #endif |
| 162 | |
| 163 | #ifndef DEBUG_NCP |
| 164 | #define DEBUG_NCP 0 |
| 165 | #endif |
| 166 | #if DEBUG_NCP > 0 |
| 167 | #define DPRINTK(format, args...) PRINTK(format , ## args) |
| 168 | #else |
| 169 | #define DPRINTK(format, args...) |
| 170 | #endif |
| 171 | #if DEBUG_NCP > 1 |
| 172 | #define DDPRINTK(format, args...) PRINTK(format , ## args) |
| 173 | #else |
| 174 | #define DDPRINTK(format, args...) |
| 175 | #endif |
| 176 | |
| 177 | #define NCP_MAX_RPC_TIMEOUT (6*HZ) |
| 178 | |
| 179 | |
| 180 | struct ncp_entry_info { |
| 181 | struct nw_info_struct i; |
| 182 | ino_t ino; |
| 183 | int opened; |
| 184 | int access; |
| 185 | unsigned int volume; |
| 186 | __u8 file_handle[6]; |
| 187 | }; |
| 188 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | static inline struct ncp_server *NCP_SBP(struct super_block *sb) |
| 190 | { |
| 191 | return sb->s_fs_info; |
| 192 | } |
| 193 | |
| 194 | #define NCP_SERVER(inode) NCP_SBP((inode)->i_sb) |
| 195 | static inline struct ncp_inode_info *NCP_FINFO(struct inode *inode) |
| 196 | { |
| 197 | return container_of(inode, struct ncp_inode_info, vfs_inode); |
| 198 | } |
| 199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | /* linux/fs/ncpfs/inode.c */ |
| 201 | int ncp_notify_change(struct dentry *, struct iattr *); |
| 202 | struct inode *ncp_iget(struct super_block *, struct ncp_entry_info *); |
| 203 | void ncp_update_inode(struct inode *, struct ncp_entry_info *); |
| 204 | void ncp_update_inode2(struct inode *, struct ncp_entry_info *); |
| 205 | |
| 206 | /* linux/fs/ncpfs/dir.c */ |
| 207 | extern struct inode_operations ncp_dir_inode_operations; |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 208 | extern const struct file_operations ncp_dir_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | int ncp_conn_logged_in(struct super_block *); |
| 210 | int ncp_date_dos2unix(__le16 time, __le16 date); |
| 211 | void ncp_date_unix2dos(int unix_date, __le16 * time, __le16 * date); |
| 212 | |
| 213 | /* linux/fs/ncpfs/ioctl.c */ |
| 214 | int ncp_ioctl(struct inode *, struct file *, unsigned int, unsigned long); |
Petr Vandrovec | 54f67f6 | 2006-09-30 23:27:55 -0700 | [diff] [blame] | 215 | long ncp_compat_ioctl(struct file *, unsigned int, unsigned long); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | |
| 217 | /* linux/fs/ncpfs/sock.c */ |
| 218 | int ncp_request2(struct ncp_server *server, int function, |
| 219 | void* reply, int max_reply_size); |
| 220 | static inline int ncp_request(struct ncp_server *server, int function) { |
| 221 | return ncp_request2(server, function, server->packet, server->packet_size); |
| 222 | } |
| 223 | int ncp_connect(struct ncp_server *server); |
| 224 | int ncp_disconnect(struct ncp_server *server); |
| 225 | void ncp_lock_server(struct ncp_server *server); |
| 226 | void ncp_unlock_server(struct ncp_server *server); |
| 227 | |
| 228 | /* linux/fs/ncpfs/file.c */ |
| 229 | extern struct inode_operations ncp_file_inode_operations; |
Arjan van de Ven | 4b6f5d2 | 2006-03-28 01:56:42 -0800 | [diff] [blame] | 230 | extern const struct file_operations ncp_file_operations; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | int ncp_make_open(struct inode *, int); |
| 232 | |
| 233 | /* linux/fs/ncpfs/mmap.c */ |
| 234 | int ncp_mmap(struct file *, struct vm_area_struct *); |
| 235 | |
| 236 | /* linux/fs/ncpfs/ncplib_kernel.c */ |
| 237 | int ncp_make_closed(struct inode *); |
| 238 | |
| 239 | #define ncp_namespace(i) (NCP_SERVER(i)->name_space[NCP_FINFO(i)->volNumber]) |
| 240 | |
| 241 | static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator) |
| 242 | { |
| 243 | #ifdef CONFIG_NCPFS_SMALLDOS |
| 244 | int ns = ncp_namespace(i); |
| 245 | |
| 246 | if ((ns == NW_NS_DOS) |
| 247 | #ifdef CONFIG_NCPFS_OS2_NS |
| 248 | || ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS)) |
| 249 | #endif /* CONFIG_NCPFS_OS2_NS */ |
| 250 | ) |
| 251 | return 0; |
| 252 | #endif /* CONFIG_NCPFS_SMALLDOS */ |
| 253 | return 1; |
| 254 | } |
| 255 | |
| 256 | #define ncp_preserve_case(i) (ncp_namespace(i) != NW_NS_DOS) |
| 257 | |
| 258 | static inline int ncp_case_sensitive(struct inode *i) |
| 259 | { |
| 260 | #ifdef CONFIG_NCPFS_NFS_NS |
| 261 | return ncp_namespace(i) == NW_NS_NFS; |
| 262 | #else |
| 263 | return 0; |
| 264 | #endif /* CONFIG_NCPFS_NFS_NS */ |
| 265 | } |
| 266 | |
| 267 | #endif /* __KERNEL__ */ |
| 268 | |
| 269 | #endif /* _LINUX_NCP_FS_H */ |