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 0x0001
104 #define SMB_CAP_MPX_MODE 0x0002
105 #define SMB_CAP_UNICODE 0x0004
106 #define SMB_CAP_LARGE_FILES 0x0008
107 #define SMB_CAP_NT_SMBS 0x0010
108 #define SMB_CAP_RPC_REMOTE_APIS 0x0020
109 #define SMB_CAP_STATUS32 0x0040
110 #define SMB_CAP_LEVEL_II_OPLOCKS 0x0080
111 #define SMB_CAP_LOCK_AND_READ 0x0100
112 #define SMB_CAP_NT_FIND 0x0200
113 #define SMB_CAP_DFS 0x1000
114 #define SMB_CAP_LARGE_READX 0x4000
118 * This is the time we allow an inode, dentry or dir cache to live. It is bad
119 * for performance to have shorter ttl on an inode than on the cache. It can
120 * cause refresh on each inode for a dir listing ... one-by-one
122 #define SMB_MAX_AGE(server) (((server)->mnt->ttl * HZ) / 1000)
125 smb_age_dentry(struct smb_sb_info *server, struct dentry *dentry)
127 dentry->d_time = jiffies - SMB_MAX_AGE(server);
130 struct smb_cache_head {
131 time_t mtime; /* unused */
132 unsigned long time; /* cache age */
133 unsigned long end; /* last valid fpos in cache */
137 #define SMB_DIRCACHE_SIZE ((int)(PAGE_CACHE_SIZE/sizeof(struct dentry *)))
138 union smb_dir_cache {
139 struct smb_cache_head head;
140 struct dentry *dentry[SMB_DIRCACHE_SIZE];
143 #define SMB_FIRSTCACHE_SIZE ((int)((SMB_DIRCACHE_SIZE * \
144 sizeof(struct dentry *) - sizeof(struct smb_cache_head)) / \
145 sizeof(struct dentry *)))
147 #define SMB_DIRCACHE_START (SMB_DIRCACHE_SIZE - SMB_FIRSTCACHE_SIZE)
149 struct smb_cache_control {
150 struct smb_cache_head head;
152 union smb_dir_cache *cache;
153 unsigned long fpos, ofs;
154 int filled, valid, idx;
158 smb_is_open(struct inode *i)
160 return (i->u.smbfs_i.open == server_from_inode(i)->generation);
164 #endif /* __KERNEL__ */
166 #endif /* _LINUX_SMB_FS_H */