4 * Copyright (c) International Business Machines Corp., 2002,2008
5 * Author(s): Steve French (sfrench@us.ibm.com)
7 * This library is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published
9 * by the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
15 * the GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/nls.h>
29 *****************************************************************
31 *****************************************************************
34 extern struct smb_hdr
*cifs_buf_get(void);
35 extern void cifs_buf_release(void *);
36 extern struct smb_hdr
*cifs_small_buf_get(void);
37 extern void cifs_small_buf_release(void *);
38 extern int smb_send(struct socket
*, struct smb_hdr
*,
39 unsigned int /* length */ , struct sockaddr
*);
40 extern unsigned int _GetXid(void);
41 extern void _FreeXid(unsigned int);
42 #define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__FUNCTION__, xid,current->fsuid));
43 #define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__FUNCTION__,curr_xid,(int)rc));}
44 extern char *build_path_from_dentry(struct dentry
*);
45 extern char *build_wildcard_path_from_dentry(struct dentry
*direntry
);
46 /* extern void renew_parental_timestamps(struct dentry *direntry);*/
47 extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo
*,
48 struct smb_hdr
* /* input */ ,
49 struct smb_hdr
* /* out */ ,
50 int * /* bytes returned */ , const int long_op
);
51 extern int SendReceiveNoRsp(const unsigned int xid
, struct cifsSesInfo
*ses
,
52 struct smb_hdr
*in_buf
, int flags
);
53 extern int SendReceive2(const unsigned int /* xid */ , struct cifsSesInfo
*,
54 struct kvec
*, int /* nvec to send */,
55 int * /* type of buf returned */ , const int flags
);
56 <<<<<<< HEAD
:fs
/cifs
/cifsproto
.h
57 extern int SendReceiveBlockingLock(const unsigned int /* xid */ ,
58 struct cifsTconInfo
*,
59 struct smb_hdr
* /* input */ ,
60 struct smb_hdr
* /* out */ ,
61 int * /* bytes returned */);
63 extern int SendReceiveBlockingLock(const unsigned int xid
,
64 struct cifsTconInfo
*ptcon
,
65 struct smb_hdr
*in_buf
,
66 struct smb_hdr
*out_buf
,
68 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:fs
/cifs
/cifsproto
.h
69 extern int checkSMB(struct smb_hdr
*smb
, __u16 mid
, unsigned int length
);
70 extern int is_valid_oplock_break(struct smb_hdr
*smb
, struct TCP_Server_Info
*);
71 extern int is_size_safe_to_change(struct cifsInodeInfo
*, __u64 eof
);
72 extern struct cifsFileInfo
*find_writable_file(struct cifsInodeInfo
*);
73 #ifdef CONFIG_CIFS_EXPERIMENTAL
74 extern struct cifsFileInfo
*find_readable_file(struct cifsInodeInfo
*);
76 extern unsigned int smbCalcSize(struct smb_hdr
*ptr
);
77 extern unsigned int smbCalcSize_LE(struct smb_hdr
*ptr
);
78 extern int decode_negTokenInit(unsigned char *security_blob
, int length
,
79 enum securityEnum
*secType
);
80 extern int cifs_inet_pton(int, char *source
, void *dst
);
81 extern int map_smb_to_linux_error(struct smb_hdr
*smb
, int logErr
);
82 extern void header_assemble(struct smb_hdr
*, char /* command */ ,
83 const struct cifsTconInfo
*, int /* length of
84 fixed section (word count) in two byte units */);
85 extern int small_smb_init_no_tc(const int smb_cmd
, const int wct
,
86 struct cifsSesInfo
*ses
,
88 extern int CIFS_SessSetup(unsigned int xid
, struct cifsSesInfo
*ses
,
90 const struct nls_table
*nls_cp
);
91 extern __u16
GetNextMid(struct TCP_Server_Info
*server
);
92 extern struct oplock_q_entry
*AllocOplockQEntry(struct inode
*, u16
,
93 struct cifsTconInfo
*);
94 extern void DeleteOplockQEntry(struct oplock_q_entry
*);
95 <<<<<<< HEAD
:fs
/cifs
/cifsproto
.h
96 extern struct timespec
cifs_NTtimeToUnix(u64
/* utc nanoseconds since 1601 */ );
98 extern struct timespec
cifs_NTtimeToUnix(u64 utc_nanoseconds_since_1601
);
99 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:fs
/cifs
/cifsproto
.h
100 extern u64
cifs_UnixTimeToNT(struct timespec
);
101 extern __le64
cnvrtDosCifsTm(__u16 date
, __u16 time
);
102 extern struct timespec
cnvrtDosUnixTm(__u16 date
, __u16 time
);
104 extern int cifs_get_inode_info(struct inode
**pinode
,
105 const unsigned char *search_path
,
106 FILE_ALL_INFO
* pfile_info
,
107 struct super_block
*sb
, int xid
);
108 extern int cifs_get_inode_info_unix(struct inode
**pinode
,
109 const unsigned char *search_path
,
110 struct super_block
*sb
, int xid
);
111 extern void acl_to_uid_mode(struct inode
*inode
, const char *search_path
);
112 extern int mode_to_acl(struct inode
*inode
, const char *path
, __u64
);
114 extern int cifs_mount(struct super_block
*, struct cifs_sb_info
*, char *,
116 extern int cifs_umount(struct super_block
*, struct cifs_sb_info
*);
117 #ifdef CONFIG_CIFS_DFS_UPCALL
118 extern void dfs_shrink_umount_helper(struct vfsmount
*vfsmnt
);
119 <<<<<<< HEAD
:fs
/cifs
/cifsproto
.h
123 static inline void dfs_shrink_umount_helper(struct vfsmount
*vfsmnt
)
126 #endif /* DFS_UPCALL */
127 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:fs
/cifs
/cifsproto
.h
128 void cifs_proc_init(void);
129 void cifs_proc_clean(void);
131 extern int cifs_setup_session(unsigned int xid
, struct cifsSesInfo
*pSesInfo
,
132 struct nls_table
*nls_info
);
133 extern int CIFSSMBNegotiate(unsigned int xid
, struct cifsSesInfo
*ses
);
135 extern int CIFSTCon(unsigned int xid
, struct cifsSesInfo
*ses
,
136 const char *tree
, struct cifsTconInfo
*tcon
,
137 const struct nls_table
*);
139 extern int CIFSFindFirst(const int xid
, struct cifsTconInfo
*tcon
,
140 const char *searchName
, const struct nls_table
*nls_codepage
,
141 __u16
*searchHandle
, struct cifs_search_info
*psrch_inf
,
142 int map
, const char dirsep
);
144 extern int CIFSFindNext(const int xid
, struct cifsTconInfo
*tcon
,
145 __u16 searchHandle
, struct cifs_search_info
*psrch_inf
);
147 extern int CIFSFindClose(const int, struct cifsTconInfo
*tcon
,
148 const __u16 search_handle
);
150 extern int CIFSSMBQPathInfo(const int xid
, struct cifsTconInfo
*tcon
,
151 const unsigned char *searchName
,
152 FILE_ALL_INFO
* findData
,
153 int legacy
/* whether to use old info level */,
154 const struct nls_table
*nls_codepage
, int remap
);
155 extern int SMBQueryInformation(const int xid
, struct cifsTconInfo
*tcon
,
156 const unsigned char *searchName
,
157 FILE_ALL_INFO
*findData
,
158 const struct nls_table
*nls_codepage
, int remap
);
160 extern int CIFSSMBUnixQPathInfo(const int xid
,
161 struct cifsTconInfo
*tcon
,
162 const unsigned char *searchName
,
163 FILE_UNIX_BASIC_INFO
* pFindData
,
164 const struct nls_table
*nls_codepage
, int remap
);
166 extern int CIFSGetDFSRefer(const int xid
, struct cifsSesInfo
*ses
,
167 const unsigned char *searchName
,
168 unsigned char **targetUNCs
,
169 unsigned int *number_of_UNC_in_array
,
170 const struct nls_table
*nls_codepage
, int remap
);
172 extern int connect_to_dfs_path(int xid
, struct cifsSesInfo
*pSesInfo
,
173 const char *old_path
,
174 const struct nls_table
*nls_codepage
, int remap
);
175 extern int get_dfs_path(int xid
, struct cifsSesInfo
*pSesInfo
,
176 const char *old_path
,
177 const struct nls_table
*nls_codepage
,
178 unsigned int *pnum_referrals
,
179 struct dfs_info3_param
**preferrals
,
181 extern void reset_cifs_unix_caps(int xid
, struct cifsTconInfo
*tcon
,
182 struct super_block
*sb
, struct smb_vol
*vol
);
183 extern int CIFSSMBQFSInfo(const int xid
, struct cifsTconInfo
*tcon
,
184 struct kstatfs
*FSData
);
185 extern int SMBOldQFSInfo(const int xid
, struct cifsTconInfo
*tcon
,
186 struct kstatfs
*FSData
);
187 extern int CIFSSMBSetFSUnixInfo(const int xid
, struct cifsTconInfo
*tcon
,
190 extern int CIFSSMBQFSAttributeInfo(const int xid
,
191 struct cifsTconInfo
*tcon
);
192 extern int CIFSSMBQFSDeviceInfo(const int xid
, struct cifsTconInfo
*tcon
);
193 extern int CIFSSMBQFSUnixInfo(const int xid
, struct cifsTconInfo
*tcon
);
194 extern int CIFSSMBQFSPosixInfo(const int xid
, struct cifsTconInfo
*tcon
,
195 struct kstatfs
*FSData
);
197 extern int CIFSSMBSetTimes(const int xid
, struct cifsTconInfo
*tcon
,
198 <<<<<<< HEAD
:fs
/cifs
/cifsproto
.h
199 const char *fileName
, const FILE_BASIC_INFO
* data
,
201 const char *fileName
, const FILE_BASIC_INFO
*data
,
202 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:fs
/cifs
/cifsproto
.h
203 const struct nls_table
*nls_codepage
,
204 int remap_special_chars
);
205 extern int CIFSSMBSetFileTimes(const int xid
, struct cifsTconInfo
*tcon
,
206 <<<<<<< HEAD
:fs
/cifs
/cifsproto
.h
207 const FILE_BASIC_INFO
* data
, __u16 fid
);
209 const FILE_BASIC_INFO
*data
, __u16 fid
);
210 >>>>>>> 264e3e889d86e552b4191d69bb60f4f3b383135a
:fs
/cifs
/cifsproto
.h
212 extern int CIFSSMBSetAttrLegacy(int xid
, struct cifsTconInfo
*tcon
,
213 char *fileName
, __u16 dos_attributes
,
214 const struct nls_table
*nls_codepage
);
215 #endif /* possibly unneeded function */
216 extern int CIFSSMBSetEOF(const int xid
, struct cifsTconInfo
*tcon
,
217 const char *fileName
, __u64 size
,
218 int setAllocationSizeFlag
,
219 const struct nls_table
*nls_codepage
,
220 int remap_special_chars
);
221 extern int CIFSSMBSetFileSize(const int xid
, struct cifsTconInfo
*tcon
,
222 __u64 size
, __u16 fileHandle
, __u32 opener_pid
,
224 extern int CIFSSMBUnixSetPerms(const int xid
, struct cifsTconInfo
*pTcon
,
225 char *full_path
, __u64 mode
, __u64 uid
,
226 __u64 gid
, dev_t dev
,
227 const struct nls_table
*nls_codepage
,
228 int remap_special_chars
);
230 extern int CIFSSMBMkDir(const int xid
, struct cifsTconInfo
*tcon
,
232 const struct nls_table
*nls_codepage
,
233 int remap_special_chars
);
234 extern int CIFSSMBRmDir(const int xid
, struct cifsTconInfo
*tcon
,
235 const char *name
, const struct nls_table
*nls_codepage
,
236 int remap_special_chars
);
237 extern int CIFSPOSIXDelFile(const int xid
, struct cifsTconInfo
*tcon
,
238 const char *name
, __u16 type
,
239 const struct nls_table
*nls_codepage
,
240 int remap_special_chars
);
241 extern int CIFSSMBDelFile(const int xid
, struct cifsTconInfo
*tcon
,
243 const struct nls_table
*nls_codepage
,
244 int remap_special_chars
);
245 extern int CIFSSMBRename(const int xid
, struct cifsTconInfo
*tcon
,
246 const char *fromName
, const char *toName
,
247 const struct nls_table
*nls_codepage
,
248 int remap_special_chars
);
249 extern int CIFSSMBRenameOpenFile(const int xid
, struct cifsTconInfo
*pTcon
,
250 int netfid
, char *target_name
,
251 const struct nls_table
*nls_codepage
,
252 int remap_special_chars
);
253 extern int CIFSCreateHardLink(const int xid
,
254 struct cifsTconInfo
*tcon
,
255 const char *fromName
, const char *toName
,
256 const struct nls_table
*nls_codepage
,
257 int remap_special_chars
);
258 extern int CIFSUnixCreateHardLink(const int xid
,
259 struct cifsTconInfo
*tcon
,
260 const char *fromName
, const char *toName
,
261 const struct nls_table
*nls_codepage
,
262 int remap_special_chars
);
263 extern int CIFSUnixCreateSymLink(const int xid
,
264 struct cifsTconInfo
*tcon
,
265 const char *fromName
, const char *toName
,
266 const struct nls_table
*nls_codepage
);
267 extern int CIFSSMBUnixQuerySymLink(const int xid
,
268 struct cifsTconInfo
*tcon
,
269 const unsigned char *searchName
,
270 char *syminfo
, const int buflen
,
271 const struct nls_table
*nls_codepage
);
272 extern int CIFSSMBQueryReparseLinkInfo(const int xid
,
273 struct cifsTconInfo
*tcon
,
274 const unsigned char *searchName
,
275 char *symlinkinfo
, const int buflen
, __u16 fid
,
276 const struct nls_table
*nls_codepage
);
278 extern int CIFSSMBOpen(const int xid
, struct cifsTconInfo
*tcon
,
279 const char *fileName
, const int disposition
,
280 const int access_flags
, const int omode
,
281 __u16
*netfid
, int *pOplock
, FILE_ALL_INFO
*,
282 const struct nls_table
*nls_codepage
, int remap
);
283 extern int SMBLegacyOpen(const int xid
, struct cifsTconInfo
*tcon
,
284 const char *fileName
, const int disposition
,
285 const int access_flags
, const int omode
,
286 __u16
*netfid
, int *pOplock
, FILE_ALL_INFO
*,
287 const struct nls_table
*nls_codepage
, int remap
);
288 extern int CIFSPOSIXCreate(const int xid
, struct cifsTconInfo
*tcon
,
289 u32 posix_flags
, __u64 mode
, __u16
*netfid
,
290 FILE_UNIX_BASIC_INFO
*pRetData
,
291 __u32
*pOplock
, const char *name
,
292 const struct nls_table
*nls_codepage
, int remap
);
293 extern int CIFSSMBClose(const int xid
, struct cifsTconInfo
*tcon
,
294 const int smb_file_id
);
296 extern int CIFSSMBRead(const int xid
, struct cifsTconInfo
*tcon
,
297 const int netfid
, unsigned int count
,
298 const __u64 lseek
, unsigned int *nbytes
, char **buf
,
299 int *return_buf_type
);
300 extern int CIFSSMBWrite(const int xid
, struct cifsTconInfo
*tcon
,
301 const int netfid
, const unsigned int count
,
302 const __u64 lseek
, unsigned int *nbytes
,
303 const char *buf
, const char __user
*ubuf
,
305 extern int CIFSSMBWrite2(const int xid
, struct cifsTconInfo
*tcon
,
306 const int netfid
, const unsigned int count
,
307 const __u64 offset
, unsigned int *nbytes
,
308 struct kvec
*iov
, const int nvec
, const int long_op
);
309 extern int CIFSGetSrvInodeNumber(const int xid
, struct cifsTconInfo
*tcon
,
310 const unsigned char *searchName
, __u64
*inode_number
,
311 const struct nls_table
*nls_codepage
,
312 int remap_special_chars
);
313 extern int cifs_convertUCSpath(char *target
, const __le16
*source
, int maxlen
,
314 const struct nls_table
*codepage
);
315 extern int cifsConvertToUCS(__le16
*target
, const char *source
, int maxlen
,
316 const struct nls_table
*cp
, int mapChars
);
318 extern int CIFSSMBLock(const int xid
, struct cifsTconInfo
*tcon
,
319 const __u16 netfid
, const __u64 len
,
320 const __u64 offset
, const __u32 numUnlock
,
321 const __u32 numLock
, const __u8 lockType
,
323 extern int CIFSSMBPosixLock(const int xid
, struct cifsTconInfo
*tcon
,
324 const __u16 smb_file_id
, const int get_flag
,
325 const __u64 len
, struct file_lock
*,
326 const __u16 lock_type
, const int waitFlag
);
327 extern int CIFSSMBTDis(const int xid
, struct cifsTconInfo
*tcon
);
328 extern int CIFSSMBLogoff(const int xid
, struct cifsSesInfo
*ses
);
330 extern struct cifsSesInfo
*sesInfoAlloc(void);
331 extern void sesInfoFree(struct cifsSesInfo
*);
332 extern struct cifsTconInfo
*tconInfoAlloc(void);
333 extern void tconInfoFree(struct cifsTconInfo
*);
335 extern int cifs_sign_smb(struct smb_hdr
*, struct TCP_Server_Info
*, __u32
*);
336 extern int cifs_sign_smb2(struct kvec
*iov
, int n_vec
, struct TCP_Server_Info
*,
338 extern int cifs_verify_signature(struct smb_hdr
*,
339 const struct mac_key
*mac_key
,
340 __u32 expected_sequence_number
);
341 extern int cifs_calculate_mac_key(struct mac_key
*key
, const char *rn
,
343 extern int CalcNTLMv2_partial_mac_key(struct cifsSesInfo
*,
344 const struct nls_table
*);
345 extern void CalcNTLMv2_response(const struct cifsSesInfo
*, char *);
346 extern void setup_ntlmv2_rsp(struct cifsSesInfo
*, char *,
347 const struct nls_table
*);
348 #ifdef CONFIG_CIFS_WEAK_PW_HASH
349 extern void calc_lanman_hash(struct cifsSesInfo
*ses
, char *lnm_session_key
);
350 #endif /* CIFS_WEAK_PW_HASH */
351 extern int CIFSSMBCopy(int xid
,
352 struct cifsTconInfo
*source_tcon
,
353 const char *fromName
,
354 const __u16 target_tid
,
355 const char *toName
, const int flags
,
356 const struct nls_table
*nls_codepage
,
357 int remap_special_chars
);
358 extern int CIFSSMBNotify(const int xid
, struct cifsTconInfo
*tcon
,
359 const int notify_subdirs
, const __u16 netfid
,
360 __u32 filter
, struct file
*file
, int multishot
,
361 const struct nls_table
*nls_codepage
);
362 extern ssize_t
CIFSSMBQAllEAs(const int xid
, struct cifsTconInfo
*tcon
,
363 const unsigned char *searchName
, char *EAData
,
364 size_t bufsize
, const struct nls_table
*nls_codepage
,
365 int remap_special_chars
);
366 extern ssize_t
CIFSSMBQueryEA(const int xid
, struct cifsTconInfo
*tcon
,
367 const unsigned char *searchName
, const unsigned char *ea_name
,
368 unsigned char *ea_value
, size_t buf_size
,
369 const struct nls_table
*nls_codepage
, int remap_special_chars
);
370 extern int CIFSSMBSetEA(const int xid
, struct cifsTconInfo
*tcon
,
371 const char *fileName
, const char *ea_name
,
372 const void *ea_value
, const __u16 ea_value_len
,
373 const struct nls_table
*nls_codepage
, int remap_special_chars
);
374 extern int CIFSSMBGetCIFSACL(const int xid
, struct cifsTconInfo
*tcon
,
375 __u16 fid
, struct cifs_ntsd
**acl_inf
, __u32
*buflen
);
376 extern int CIFSSMBSetCIFSACL(const int, struct cifsTconInfo
*, __u16
,
377 struct cifs_ntsd
*, __u32
);
378 extern int CIFSSMBGetPosixACL(const int xid
, struct cifsTconInfo
*tcon
,
379 const unsigned char *searchName
,
380 char *acl_inf
, const int buflen
, const int acl_type
,
381 const struct nls_table
*nls_codepage
, int remap_special_chars
);
382 extern int CIFSSMBSetPosixACL(const int xid
, struct cifsTconInfo
*tcon
,
383 const unsigned char *fileName
,
384 const char *local_acl
, const int buflen
, const int acl_type
,
385 const struct nls_table
*nls_codepage
, int remap_special_chars
);
386 extern int CIFSGetExtAttr(const int xid
, struct cifsTconInfo
*tcon
,
387 const int netfid
, __u64
*pExtAttrBits
, __u64
*pMask
);
388 #endif /* _CIFSPROTO_H */