patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / fs / cifs / cifsproto.h
1 /*
2  *   fs/cifs/cifsproto.h
3  *
4  *   Copyright (c) International Business Machines  Corp., 2002
5  *   Author(s): Steve French (sfrench@us.ibm.com)
6  *
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.
11  *
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.
16  *
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 
20  */
21 #ifndef _CIFSPROTO_H
22 #define _CIFSPROTO_H
23 #include <linux/nls.h>
24
25 struct statfs;
26
27 /*
28  *****************************************************************
29  * All Prototypes
30  *****************************************************************
31  */
32
33 extern struct smb_hdr *cifs_buf_get(void);
34 extern void cifs_buf_release(void *);
35 extern int smb_send(struct socket *, struct smb_hdr *,
36                         unsigned int /* length */ , struct sockaddr *);
37 extern unsigned int _GetXid(void);
38 extern void _FreeXid(unsigned int);
39 #define GetXid() (int)_GetXid(); cFYI(1,("CIFS VFS: in %s as Xid: %d with uid: %d",__FUNCTION__, xid,current->fsuid));
40 #define FreeXid(curr_xid) {_FreeXid(curr_xid); cFYI(1,("CIFS VFS: leaving %s (xid = %d) rc = %d",__FUNCTION__,curr_xid,rc));}
41 extern char *build_path_from_dentry(struct dentry *);
42 extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
43 extern void renew_parental_timestamps(struct dentry *direntry);
44 extern int SendReceive(const unsigned int /* xid */ , struct cifsSesInfo *,
45                         struct smb_hdr * /* input */ ,
46                         struct smb_hdr * /* out */ ,
47                         int * /* bytes returned */ , const int long_op);
48 extern int checkSMBhdr(struct smb_hdr *smb, __u16 mid);
49 extern int checkSMB(struct smb_hdr *smb, __u16 mid, int length);
50 extern int is_valid_oplock_break(struct smb_hdr *smb);
51 extern unsigned int smbCalcSize(struct smb_hdr *ptr);
52 extern int decode_negTokenInit(unsigned char *security_blob, int length,
53                         enum securityEnum *secType);
54 extern int map_smb_to_linux_error(struct smb_hdr *smb);
55 extern void header_assemble(struct smb_hdr *, char /* command */ ,
56                         const struct cifsTconInfo *, int
57                         /* length of fixed section (word count) in two byte units  */
58                         );
59 struct oplock_q_entry * AllocOplockQEntry(struct inode *, u16, struct cifsTconInfo *);
60 void DeleteOplockQEntry(struct oplock_q_entry *);
61 extern struct timespec cifs_NTtimeToUnix(u64 /* utc nanoseconds since 1601 */ );
62 extern u64 cifs_UnixTimeToNT(struct timespec);
63 extern int cifs_get_inode_info(struct inode **pinode,
64                         const unsigned char *search_path, 
65                         FILE_ALL_INFO * pfile_info,
66                         struct super_block *sb);
67 extern int cifs_get_inode_info_unix(struct inode **pinode,
68                         const unsigned char *search_path,
69                         struct super_block *sb);
70
71 extern int cifs_setup_session(unsigned int xid, struct cifsSesInfo *pSesInfo, 
72                         struct nls_table * nls_info);
73 extern int CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses);
74
75 extern int CIFSTCon(unsigned int xid, struct cifsSesInfo *ses,
76                         const char *tree, struct cifsTconInfo *tcon,
77                         const struct nls_table *);
78
79 extern int CIFSFindFirst(const int xid, struct cifsTconInfo *tcon,
80                         const char *searchName,
81                         FILE_DIRECTORY_INFO * findData,
82                         T2_FFIRST_RSP_PARMS * findParms,
83                         const struct nls_table *nls_codepage,
84                         int *pUnicodeFlag,
85                         int *pUnixFlag /* if Unix extensions used */ );
86 extern int CIFSFindNext(const int xid, struct cifsTconInfo *tcon,
87                         FILE_DIRECTORY_INFO * findData,
88                         T2_FNEXT_RSP_PARMS * findParms,
89                         const __u16 searchHandle, char * resume_name,
90                         int name_length, __u32 resume_key,
91                         int *UnicodeFlag, int *pUnixFlag);
92
93 extern int CIFSFindClose(const int, struct cifsTconInfo *tcon,
94                         const __u16 search_handle);
95
96 extern int CIFSSMBQPathInfo(const int xid, struct cifsTconInfo *tcon,
97                         const unsigned char *searchName,
98                         FILE_ALL_INFO * findData,
99                         const struct nls_table *nls_codepage);
100
101 extern int CIFSSMBUnixQPathInfo(const int xid,
102                         struct cifsTconInfo *tcon,
103                         const unsigned char *searchName,
104                         FILE_UNIX_BASIC_INFO * pFindData,
105                         const struct nls_table *nls_codepage);
106
107 extern int CIFSGetDFSRefer(const int xid, struct cifsSesInfo *ses,
108                         const unsigned char *searchName,
109                         unsigned char **targetUNCs,
110                         unsigned int *number_of_UNC_in_array,
111                         const struct nls_table *nls_codepage);
112
113 extern int connect_to_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
114                         const char *old_path,
115                         const struct nls_table *nls_codepage);
116 extern int get_dfs_path(int xid, struct cifsSesInfo *pSesInfo,
117                         const char *old_path, const struct nls_table *nls_codepage, 
118                         unsigned int *pnum_referrals, unsigned char ** preferrals);
119 extern int CIFSSMBQFSInfo(const int xid, struct cifsTconInfo *tcon,
120                         struct kstatfs *FSData,
121                         const struct nls_table *nls_codepage);
122 extern int CIFSSMBQFSAttributeInfo(const int xid,
123                         struct cifsTconInfo *tcon,
124                         const struct nls_table *nls_codepage);
125 extern int CIFSSMBQFSDeviceInfo(const int xid, struct cifsTconInfo *tcon,
126                         const struct nls_table *nls_codepage);
127 extern int CIFSSMBQFSUnixInfo(const int xid, struct cifsTconInfo *tcon,
128                         const struct nls_table *nls_codepage);
129
130 extern int CIFSSMBSetTimes(const int xid, struct cifsTconInfo *tcon,
131                         char *fileName, FILE_BASIC_INFO * data,
132                         const struct nls_table *nls_codepage);
133 extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon,
134                         char *fileName, __u64 size,int setAllocationSizeFlag,
135                         const struct nls_table *nls_codepage);
136 extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon,
137                          __u64 size, __u16 fileHandle,__u32 opener_pid, int AllocSizeFlag);
138 extern int CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *pTcon,
139                         char *full_path, __u64 mode, __u64 uid,
140                         __u64 gid, dev_t dev, const struct nls_table *nls_codepage);
141
142 extern int CIFSSMBMkDir(const int xid, struct cifsTconInfo *tcon,
143                         const char *newName,
144                         const struct nls_table *nls_codepage);
145 extern int CIFSSMBRmDir(const int xid, struct cifsTconInfo *tcon,
146                         const char *name, const struct nls_table *nls_codepage);
147
148 extern int CIFSSMBDelFile(const int xid, struct cifsTconInfo *tcon,
149                         const char *name,
150                         const struct nls_table *nls_codepage);
151 extern int CIFSSMBRename(const int xid, struct cifsTconInfo *tcon,
152                         const char *fromName, const char *toName,
153                         const struct nls_table *nls_codepage);
154 extern int CIFSSMBRenameOpenFile(const int xid,struct cifsTconInfo *pTcon,
155                         int netfid, char * target_name, const struct nls_table *nls_codepage);
156 extern int CIFSCreateHardLink(const int xid,
157                         struct cifsTconInfo *tcon,
158                         const char *fromName, const char *toName,
159                         const struct nls_table *nls_codepage);
160 extern int CIFSUnixCreateHardLink(const int xid,
161                         struct cifsTconInfo *tcon,
162                         const char *fromName, const char *toName,
163                         const struct nls_table *nls_codepage);
164 extern int CIFSUnixCreateSymLink(const int xid,
165                         struct cifsTconInfo *tcon,
166                         const char *fromName, const char *toName,
167                         const struct nls_table *nls_codepage);
168 extern int CIFSSMBUnixQuerySymLink(const int xid,
169                         struct cifsTconInfo *tcon,
170                         const unsigned char *searchName,
171                         char *syminfo, const int buflen,
172                         const struct nls_table *nls_codepage);
173 extern int CIFSSMBQueryReparseLinkInfo(const int xid, 
174                         struct cifsTconInfo *tcon,
175                         const unsigned char *searchName,
176                         char *symlinkinfo, const int buflen, __u16 fid,
177                         const struct nls_table *nls_codepage);
178
179 extern int CIFSSMBOpen(const int xid, struct cifsTconInfo *tcon,
180                         const char *fileName, const int disposition,
181                         const int access_flags, const int omode,
182                         __u16 * netfid, int *pOplock, FILE_ALL_INFO *,
183                         const struct nls_table *nls_codepage);
184 extern int CIFSSMBClose(const int xid, struct cifsTconInfo *tcon,
185                         const int smb_file_id);
186
187 extern int CIFSSMBRead(const int xid, struct cifsTconInfo *tcon,
188                         const int netfid, unsigned int count,
189                         const __u64 lseek, unsigned int *nbytes, char **buf);
190 extern int CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon,
191                         const int netfid, const unsigned int count,
192                         const __u64 lseek, unsigned int *nbytes,
193                         const char *buf, const int long_op);
194 extern int CIFSSMBLock(const int xid, struct cifsTconInfo *tcon,
195                         const __u16 netfid, const __u64 len,
196                         const __u64 offset, const __u32 numUnlock,
197                         const __u32 numLock, const __u8 lockType,
198                         const int waitFlag);
199
200 extern int CIFSSMBTDis(const int xid, struct cifsTconInfo *tcon);
201 extern int CIFSSMBLogoff(const int xid, struct cifsSesInfo *ses);
202
203 extern struct cifsSesInfo *sesInfoAlloc(void);
204 extern void sesInfoFree(struct cifsSesInfo *);
205 extern struct cifsTconInfo *tconInfoAlloc(void);
206 extern void tconInfoFree(struct cifsTconInfo *);
207
208 extern int cifs_reconnect(struct TCP_Server_Info *server);
209
210 extern int cifs_sign_smb(struct smb_hdr *, struct cifsSesInfo *,__u32 *);
211 extern int cifs_verify_signature(const struct smb_hdr *, const char * mac_key,
212         __u32 expected_sequence_number);
213 extern int cifs_calculate_mac_key(char * key,const char * rn,const char * pass);
214 extern void CalcNTLMv2_partial_mac_key(struct cifsSesInfo *, struct nls_table *);
215 extern void CalcNTLMv2_response(const struct cifsSesInfo *,char * );
216
217 extern int CIFSBuildServerList(int xid, char *serverBufferList,
218                         int recordlength, int *entries,
219                         int *totalEntries, int *topoChangedFlag);
220 extern int CIFSSMBQueryShares(int xid, struct cifsTconInfo *tcon,
221                         struct shareInfo *shareList, int bufferLen,
222                         int *entries, int *totalEntries);
223 extern int CIFSSMBQueryAlias(int xid, struct cifsTconInfo *tcon,
224                         struct aliasInfo *aliasList, int bufferLen,
225                         int *entries, int *totalEntries);
226 extern int CIFSSMBAliasInfo(int xid, struct cifsTconInfo *tcon,
227                         char *aliasName, char *serverName,
228                         char *shareName, char *comment);
229 extern int CIFSSMBGetShareInfo(int xid, struct cifsTconInfo *tcon,
230                         char *share, char *comment);
231 extern int CIFSSMBGetUserPerms(int xid, struct cifsTconInfo *tcon,
232                         char *userName, char *searchName, int *perms);
233 extern int CIFSSMBSync(int xid, struct cifsTconInfo *tcon, int netfid, int pid);
234
235 extern int CIFSSMBSeek(int xid,
236                         struct cifsTconInfo *tcon,
237                         int netfid,
238                         int pid,
239                         int whence, unsigned long offset, long long *newoffset);
240
241 extern int CIFSSMBCopy(int xid,
242                         struct cifsTconInfo *source_tcon,
243                         const char *fromName,
244                         const __u16 target_tid,
245                         const char *toName, const int flags,
246                         const struct nls_table *nls_codepage);
247 extern int CIFSSMBNotify(const int xid, struct cifsTconInfo *tcon, 
248                         const int notify_subdirs,const __u16 netfid,__u32 filter,
249                         const struct nls_table *nls_codepage);
250 extern int CIFSSMBQAllEAs(const int xid, struct cifsTconInfo *tcon,
251                  const unsigned char *searchName,
252                  char * EAData, size_t size,
253                  const struct nls_table *nls_codepage);
254 #endif                  /* _CIFSPROTO_H */