ncp_fs.h 6.7 KB

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