- Stephen Rothwell: APM updates
[davej-history.git] / include / linux / smb_fs.h
blob501ea4b964d6864900e1694af99e4acfdae5e5f4
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(o)
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 /* NT1 protocol capability bits */
78 #define SMB_CAP_RAW_MODE 0x0001
79 #define SMB_CAP_MPX_MODE 0x0002
80 #define SMB_CAP_UNICODE 0x0004
81 #define SMB_CAP_LARGE_FILES 0x0008
82 #define SMB_CAP_NT_SMBS 0x0010
83 #define SMB_CAP_RPC_REMOTE_APIS 0x0020
84 #define SMB_CAP_STATUS32 0x0040
85 #define SMB_CAP_LEVEL_II_OPLOCKS 0x0080
86 #define SMB_CAP_LOCK_AND_READ 0x0100
87 #define SMB_CAP_NT_FIND 0x0200
88 #define SMB_CAP_DFS 0x1000
89 #define SMB_CAP_LARGE_READX 0x4000
92 /* linux/fs/smbfs/mmap.c */
93 int smb_mmap(struct file *, struct vm_area_struct *);
95 /* linux/fs/smbfs/file.c */
96 extern struct inode_operations smb_file_inode_operations;
97 extern struct file_operations smb_file_operations;
98 extern struct address_space_operations smb_file_aops;
100 /* linux/fs/smbfs/dir.c */
101 extern struct inode_operations smb_dir_inode_operations;
102 extern struct file_operations smb_dir_operations;
103 void smb_renew_times(struct dentry *);
105 /* linux/fs/smbfs/ioctl.c */
106 int smb_ioctl (struct inode *, struct file *, unsigned int, unsigned long);
108 /* linux/fs/smbfs/inode.c */
109 struct super_block *smb_read_super(struct super_block *, void *, int);
110 void smb_get_inode_attr(struct inode *, struct smb_fattr *);
111 void smb_invalidate_inodes(struct smb_sb_info *);
112 int smb_revalidate_inode(struct dentry *);
113 int smb_notify_change(struct dentry *, struct iattr *);
114 unsigned long smb_invent_inos(unsigned long);
115 struct inode *smb_iget(struct super_block *, struct smb_fattr *);
117 /* linux/fs/smbfs/proc.c */
118 int smb_setcodepage(struct smb_sb_info *server, struct smb_nls_codepage *cp);
119 __u32 smb_len(unsigned char *);
120 __u8 *smb_encode_smb_length(__u8 *, __u32);
121 __u8 *smb_setup_header(struct smb_sb_info *, __u8, __u16, __u16);
122 int smb_get_rsize(struct smb_sb_info *);
123 int smb_get_wsize(struct smb_sb_info *);
124 int smb_newconn(struct smb_sb_info *, struct smb_conn_opt *);
125 int smb_errno(struct smb_sb_info *);
126 int smb_close(struct inode *);
127 int smb_close_fileid(struct dentry *, __u16);
128 int smb_open(struct dentry *, int);
129 int smb_proc_read(struct inode *, off_t, int, char *);
130 int smb_proc_write(struct inode *, off_t, int, const char *);
131 int smb_proc_create(struct dentry *, __u16, time_t, __u16 *);
132 int smb_proc_mv(struct dentry *, struct dentry *);
133 int smb_proc_mkdir(struct dentry *);
134 int smb_proc_rmdir(struct dentry *);
135 int smb_proc_unlink(struct dentry *);
136 int smb_proc_readdir(struct dentry *, int, void *);
137 int smb_proc_getattr(struct dentry *, struct smb_fattr *);
138 int smb_proc_setattr(struct dentry *, struct smb_fattr *);
139 int smb_proc_settime(struct dentry *, struct smb_fattr *);
140 int smb_proc_dskattr(struct super_block *, struct statfs *);
141 int smb_proc_reconnect(struct smb_sb_info *);
142 int smb_proc_connect(struct smb_sb_info *);
143 int smb_proc_disconnect(struct smb_sb_info *);
144 int smb_proc_trunc(struct smb_sb_info *, __u16, __u32);
145 void smb_init_root_dirent(struct smb_sb_info *, struct smb_fattr *);
147 static inline int
148 smb_is_open(struct inode *i)
150 return (i->u.smbfs_i.open == SMB_SERVER(i)->generation);
153 /* linux/fs/smbfs/sock.c */
154 int smb_round_length(int);
155 int smb_valid_socket(struct inode *);
156 void smb_close_socket(struct smb_sb_info *);
157 int smb_release(struct smb_sb_info *server);
158 int smb_connect(struct smb_sb_info *server);
159 int smb_request(struct smb_sb_info *server);
160 int smb_request_read_raw(struct smb_sb_info *, unsigned char *, int);
161 int smb_request_write_raw(struct smb_sb_info *, unsigned const char *, int);
162 int smb_catch_keepalive(struct smb_sb_info *server);
163 int smb_dont_catch_keepalive(struct smb_sb_info *server);
164 int smb_trans2_request(struct smb_sb_info *server, __u16 trans2_command,
165 int ldata, unsigned char *data,
166 int lparam, unsigned char *param,
167 int *lrdata, unsigned char **rdata,
168 int *lrparam, unsigned char **rparam);
170 /* fs/smbfs/cache.c */
173 * The cache index describes the pages mapped starting
174 * at offset PAGE_SIZE. We keep only a minimal amount
175 * of information here.
177 struct cache_index {
178 unsigned short num_entries;
179 unsigned short space;
180 struct cache_block * block;
183 #define NINDEX (PAGE_SIZE-64)/sizeof(struct cache_index)
185 * The cache head is mapped as the page at offset 0.
187 struct cache_head {
188 int valid;
189 int status; /* error code or 0 */
190 int entries; /* total entries */
191 int pages; /* number of data pages */
192 int idx; /* index of current data page */
193 struct cache_index index[NINDEX];
197 * An array of cache_entry structures holds information
198 * for each object in the cache_block.
200 struct cache_entry {
201 ino_t ino;
202 unsigned short namelen;
203 unsigned short offset;
207 * The cache blocks hold the actual data. The entry table grows up
208 * while the names grow down, and we have space until they meet.
210 struct cache_block {
211 union {
212 struct cache_entry table[1];
213 char names[PAGE_SIZE];
214 } cb_data;
218 * To return an entry, we can pass a reference to the
219 * name instead of having to copy it.
221 struct cache_dirent {
222 ino_t ino;
223 unsigned long pos;
224 int len;
225 char * name;
228 struct cache_head * smb_get_dircache(struct dentry *);
229 void smb_init_dircache(struct cache_head *);
230 void smb_free_dircache(struct cache_head *);
231 int smb_refill_dircache(struct cache_head *, struct dentry *);
232 void smb_add_to_cache(struct cache_head *, struct cache_dirent *, off_t);
233 int smb_find_in_cache(struct cache_head *, off_t, struct cache_dirent *);
234 void smb_invalid_dir_cache(struct inode *);
236 #endif /* __KERNEL__ */
238 #endif /* _LINUX_SMB_FS_H */