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