Import 2.3.48
[davej-history.git] / include / linux / smb_fs.h
blobd11573ca59fb2cc775cb2a77c825d1a95af33e98
1 /*
2 * smb_fs.h
4 * Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
7 */
9 #ifndef _LINUX_SMB_FS_H
10 #define _LINUX_SMB_FS_H
12 #include <linux/smb.h>
15 * ioctl commands
17 #define SMB_IOC_GETMOUNTUID _IOR('u', 1, __kernel_old_uid_t)
18 #define SMB_IOC_NEWCONN _IOW('u', 2, struct smb_conn_opt)
20 /* __kernel_uid_t can never change, so we have to use __kernel_uid32_t */
21 #define SMB_IOC_GETMOUNTUID32 _IOR('u', 3, __kernel_uid32_t)
23 #ifdef __KERNEL__
25 #include <asm/unaligned.h>
27 #define WVAL(buf,pos) \
28 (le16_to_cpu(get_unaligned((__u16 *)((__u8 *)(buf) + (pos)))))
29 #define DVAL(buf,pos) \
30 (le32_to_cpu(get_unaligned((__u32 *)((__u8 *)(buf) + (pos)))))
31 #define WSET(buf,pos,val) \
32 put_unaligned(cpu_to_le16((__u16)(val)), (__u16 *)((__u8 *)(buf) + (pos)))
33 #define DSET(buf,pos,val) \
34 put_unaligned(cpu_to_le32((__u32)(val)), (__u32 *)((__u8 *)(buf) + (pos)))
36 /* where to find the base of the SMB packet proper */
37 #define smb_base(buf) ((__u8 *)(((__u8 *)(buf))+4))
39 #include <linux/vmalloc.h>
41 #ifdef DEBUG_SMB_MALLOC
43 extern int smb_malloced;
44 extern int smb_current_vmalloced;
46 static inline void *
47 smb_vmalloc(unsigned int size)
49 smb_malloced += 1;
50 smb_current_vmalloced += 1;
51 return vmalloc(size);
54 static inline void
55 smb_vfree(void *obj)
57 smb_current_vmalloced -= 1;
58 vfree(obj);
61 #else /* DEBUG_SMB_MALLOC */
63 #define smb_kmalloc(s,p) kmalloc(s,p)
64 #define smb_kfree_s(o,s) kfree_s(o,s)
65 #define smb_vmalloc(s) vmalloc(s)
66 #define smb_vfree(o) vfree(o)
68 #endif /* DEBUG_SMB_MALLOC */
71 * Flags for the in-memory inode
73 #define SMB_F_CACHEVALID 0x01 /* directory cache valid */
74 #define SMB_F_LOCALWRITE 0x02 /* file modified locally */
77 * Bug fix flags
79 #define SMB_FIX_WIN95 0x0001 /* Win 95 server */
80 #define SMB_FIX_OLDATTR 0x0002 /* Use core getattr (Win 95 speedup) */
81 #define SMB_FIX_DIRATTR 0x0004 /* Use find_first for getattr */
84 /* NT1 protocol capability bits */
85 #define SMB_CAP_RAW_MODE 0x0001
86 #define SMB_CAP_MPX_MODE 0x0002
87 #define SMB_CAP_UNICODE 0x0004
88 #define SMB_CAP_LARGE_FILES 0x0008
89 #define SMB_CAP_NT_SMBS 0x0010
90 #define SMB_CAP_RPC_REMOTE_APIS 0x0020
91 #define SMB_CAP_STATUS32 0x0040
92 #define SMB_CAP_LEVEL_II_OPLOCKS 0x0080
93 #define SMB_CAP_LOCK_AND_READ 0x0100
94 #define SMB_CAP_NT_FIND 0x0200
95 #define SMB_CAP_DFS 0x1000
96 #define SMB_CAP_LARGE_READX 0x4000
99 /* linux/fs/smbfs/mmap.c */
100 int smb_mmap(struct file *, struct vm_area_struct *);
102 /* linux/fs/smbfs/file.c */
103 extern struct inode_operations smb_file_inode_operations;
104 extern struct file_operations smb_file_operations;
105 extern struct address_space_operations smb_file_aops;
107 /* linux/fs/smbfs/dir.c */
108 extern struct inode_operations smb_dir_inode_operations;
109 extern struct file_operations smb_dir_operations;
110 void smb_renew_times(struct dentry *);
112 /* linux/fs/smbfs/ioctl.c */
113 int smb_ioctl (struct inode *, struct file *, unsigned int, unsigned long);
115 /* linux/fs/smbfs/inode.c */
116 struct super_block *smb_read_super(struct super_block *, void *, int);
117 void smb_get_inode_attr(struct inode *, struct smb_fattr *);
118 void smb_invalidate_inodes(struct smb_sb_info *);
119 int smb_revalidate_inode(struct dentry *);
120 int smb_notify_change(struct dentry *, struct iattr *);
121 unsigned long smb_invent_inos(unsigned long);
122 struct inode *smb_iget(struct super_block *, struct smb_fattr *);
123 extern int init_smb_fs(void);
125 /* linux/fs/smbfs/proc.c */
126 __u32 smb_len(unsigned char *);
127 __u8 *smb_encode_smb_length(__u8 *, __u32);
128 __u8 *smb_setup_header(struct smb_sb_info *, __u8, __u16, __u16);
129 int smb_get_rsize(struct smb_sb_info *);
130 int smb_get_wsize(struct smb_sb_info *);
131 int smb_newconn(struct smb_sb_info *, struct smb_conn_opt *);
132 int smb_errno(struct smb_sb_info *);
133 int smb_close(struct inode *);
134 void smb_close_dentry(struct dentry *);
135 int smb_close_fileid(struct dentry *, __u16);
136 int smb_open(struct dentry *, int);
137 int smb_proc_read(struct dentry *, off_t, int, char *);
138 int smb_proc_write(struct dentry *, off_t, int, const char *);
139 int smb_proc_create(struct dentry *, __u16, time_t, __u16 *);
140 int smb_proc_mv(struct dentry *, struct dentry *);
141 int smb_proc_mkdir(struct dentry *);
142 int smb_proc_rmdir(struct dentry *);
143 int smb_proc_unlink(struct dentry *);
144 int smb_proc_readdir(struct dentry *, int, void *);
145 int smb_proc_getattr(struct dentry *, struct smb_fattr *);
146 int smb_proc_setattr(struct dentry *, struct smb_fattr *);
147 int smb_proc_settime(struct dentry *, struct smb_fattr *);
148 int smb_proc_dskattr(struct super_block *, struct statfs *);
149 int smb_proc_reconnect(struct smb_sb_info *);
150 int smb_proc_connect(struct smb_sb_info *);
151 int smb_proc_disconnect(struct smb_sb_info *);
152 int smb_proc_trunc(struct smb_sb_info *, __u16, __u32);
153 void smb_init_root_dirent(struct smb_sb_info *, struct smb_fattr *);
155 static inline int
156 smb_is_open(struct inode *i)
158 return (i->u.smbfs_i.open == SMB_SERVER(i)->generation);
161 /* linux/fs/smbfs/sock.c */
162 int smb_round_length(int);
163 int smb_valid_socket(struct inode *);
164 void smb_close_socket(struct smb_sb_info *);
165 int smb_release(struct smb_sb_info *server);
166 int smb_connect(struct smb_sb_info *server);
167 int smb_request(struct smb_sb_info *server);
168 int smb_request_read_raw(struct smb_sb_info *, unsigned char *, int);
169 int smb_request_write_raw(struct smb_sb_info *, unsigned const char *, int);
170 int smb_catch_keepalive(struct smb_sb_info *server);
171 int smb_dont_catch_keepalive(struct smb_sb_info *server);
172 int smb_trans2_request(struct smb_sb_info *server, __u16 trans2_command,
173 int ldata, unsigned char *data,
174 int lparam, unsigned char *param,
175 int *lrdata, unsigned char **rdata,
176 int *lrparam, unsigned char **rparam);
178 /* fs/smbfs/cache.c */
181 * The cache index describes the pages mapped starting
182 * at offset PAGE_SIZE. We keep only a minimal amount
183 * of information here.
185 struct cache_index {
186 unsigned short num_entries;
187 unsigned short space;
188 struct cache_block * block;
191 #define NINDEX (PAGE_SIZE-64)/sizeof(struct cache_index)
193 * The cache head is mapped as the page at offset 0.
195 struct cache_head {
196 int valid;
197 int status; /* error code or 0 */
198 int entries; /* total entries */
199 int pages; /* number of data pages */
200 int idx; /* index of current data page */
201 struct cache_index index[NINDEX];
205 * An array of cache_entry structures holds information
206 * for each object in the cache_block.
208 struct cache_entry {
209 ino_t ino;
210 unsigned short namelen;
211 unsigned short offset;
215 * The cache blocks hold the actual data. The entry table grows up
216 * while the names grow down, and we have space until they meet.
218 struct cache_block {
219 union {
220 struct cache_entry table[1];
221 char names[PAGE_SIZE];
222 } cb_data;
226 * To return an entry, we can pass a reference to the
227 * name instead of having to copy it.
229 struct cache_dirent {
230 ino_t ino;
231 unsigned long pos;
232 int len;
233 char * name;
236 struct cache_head * smb_get_dircache(struct dentry *);
237 void smb_init_dircache(struct cache_head *);
238 void smb_free_dircache(struct cache_head *);
239 int smb_refill_dircache(struct cache_head *, struct dentry *);
240 void smb_add_to_cache(struct cache_head *, struct cache_dirent *, off_t);
241 int smb_find_in_cache(struct cache_head *, off_t, struct cache_dirent *);
242 void smb_invalid_dir_cache(struct inode *);
244 #endif /* __KERNEL__ */
246 #endif /* _LINUX_SMB_FS_H */