4 * Copyright (C) 1995 by Paal-Kr. Engstad and Volker Lendecke
5 * Copyright (C) 1997 by Volker Lendecke
9 #ifndef _LINUX_SMB_FS_H
10 #define _LINUX_SMB_FS_H
12 #include <linux/smb.h>
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)
26 #include <linux/pagemap.h>
27 #include <linux/vmalloc.h>
28 #include <linux/smb_mount.h>
29 #include <asm/unaligned.h>
32 /* macro names are short for word, double-word, long value (?) */
33 #define WVAL(buf,pos) \
34 (le16_to_cpu(get_unaligned((u16 *)((u8 *)(buf) + (pos)))))
35 #define DVAL(buf,pos) \
36 (le32_to_cpu(get_unaligned((u32 *)((u8 *)(buf) + (pos)))))
37 #define LVAL(buf,pos) \
38 (le64_to_cpu(get_unaligned((u64 *)((u8 *)(buf) + (pos)))))
39 #define WSET(buf,pos,val) \
40 put_unaligned(cpu_to_le16((u16)(val)), (u16 *)((u8 *)(buf) + (pos)))
41 #define DSET(buf,pos,val) \
42 put_unaligned(cpu_to_le32((u32)(val)), (u32 *)((u8 *)(buf) + (pos)))
43 #define LSET(buf,pos,val) \
44 put_unaligned(cpu_to_le64((u64)(val)), (u64 *)((u8 *)(buf) + (pos)))
46 /* where to find the base of the SMB packet proper */
47 #define smb_base(buf) ((u8 *)(((u8 *)(buf))+4))
49 #ifdef DEBUG_SMB_MALLOC
51 #include <linux/slab.h>
53 extern int smb_malloced;
54 extern int smb_current_vmalloced;
55 extern int smb_current_kmalloced;
58 smb_vmalloc(unsigned int size)
61 smb_current_vmalloced += 1;
68 smb_current_vmalloced -= 1;
73 smb_kmalloc(size_t size, int flags)
76 smb_current_kmalloced += 1;
77 return kmalloc(size, flags);
83 smb_current_kmalloced -= 1;
87 #else /* DEBUG_SMB_MALLOC */
89 #define smb_kmalloc(s,p) kmalloc(s,p)
90 #define smb_kfree(o) kfree(o)
91 #define smb_vmalloc(s) vmalloc(s)
92 #define smb_vfree(o) vfree(o)
94 #endif /* DEBUG_SMB_MALLOC */
97 * Flags for the in-memory inode
99 #define SMB_F_LOCALWRITE 0x02 /* file modified locally */
102 /* NT1 protocol capability bits */
103 #define SMB_CAP_RAW_MODE 0x00000001
104 #define SMB_CAP_MPX_MODE 0x00000002
105 #define SMB_CAP_UNICODE 0x00000004
106 #define SMB_CAP_LARGE_FILES 0x00000008
107 #define SMB_CAP_NT_SMBS 0x00000010
108 #define SMB_CAP_RPC_REMOTE_APIS 0x00000020
109 #define SMB_CAP_STATUS32 0x00000040
110 #define SMB_CAP_LEVEL_II_OPLOCKS 0x00000080
111 #define SMB_CAP_LOCK_AND_READ 0x00000100
112 #define SMB_CAP_NT_FIND 0x00000200
113 #define SMB_CAP_DFS 0x00001000
114 #define SMB_CAP_LARGE_READX 0x00004000
115 #define SMB_CAP_LARGE_WRITEX 0x00008000
116 #define SMB_CAP_UNIX 0x00800000 /* unofficial ... */
120 * This is the time we allow an inode, dentry or dir cache to live. It is bad
121 * for performance to have shorter ttl on an inode than on the cache. It can
122 * cause refresh on each inode for a dir listing ... one-by-one
124 #define SMB_MAX_AGE(server) (((server)->mnt->ttl * HZ) / 1000)
127 smb_age_dentry(struct smb_sb_info *server, struct dentry *dentry)
129 dentry->d_time = jiffies - SMB_MAX_AGE(server);
132 struct smb_cache_head {
133 time_t mtime; /* unused */
134 unsigned long time; /* cache age */
135 unsigned long end; /* last valid fpos in cache */
139 #define SMB_DIRCACHE_SIZE ((int)(PAGE_CACHE_SIZE/sizeof(struct dentry *)))
140 union smb_dir_cache {
141 struct smb_cache_head head;
142 struct dentry *dentry[SMB_DIRCACHE_SIZE];
145 #define SMB_FIRSTCACHE_SIZE ((int)((SMB_DIRCACHE_SIZE * \
146 sizeof(struct dentry *) - sizeof(struct smb_cache_head)) / \
147 sizeof(struct dentry *)))
149 #define SMB_DIRCACHE_START (SMB_DIRCACHE_SIZE - SMB_FIRSTCACHE_SIZE)
151 struct smb_cache_control {
152 struct smb_cache_head head;
154 union smb_dir_cache *cache;
155 unsigned long fpos, ofs;
156 int filled, valid, idx;
160 smb_is_open(struct inode *i)
162 return (i->u.smbfs_i.open == server_from_inode(i)->generation);
165 #define SMB_OPS_NUM_STATIC 5
167 int (*read)(struct inode *inode, loff_t offset, int count,
169 int (*write)(struct inode *inode, loff_t offset, int count, const
171 int (*readdir)(struct file *filp, void *dirent, filldir_t filldir,
172 struct smb_cache_control *ctl);
174 int (*getattr)(struct smb_sb_info *server, struct dentry *dir,
175 struct smb_fattr *fattr);
176 /* int (*setattr)(...); */ /* setattr is really icky! */
178 int (*truncate)(struct inode *inode, loff_t length);
181 /* --- --- --- end of "static" entries --- --- --- */
183 int (*convert)(unsigned char *output, int olen,
184 const unsigned char *input, int ilen,
185 struct nls_table *nls_from,
186 struct nls_table *nls_to);
189 #endif /* __KERNEL__ */
191 #endif /* _LINUX_SMB_FS_H */