]> git.ipfire.org Git - thirdparty/linux.git/blame - fs/cifs/cifsproto.h
cifs: fix dfs domain referrals
[thirdparty/linux.git] / fs / cifs / cifsproto.h
CommitLineData
1da177e4
LT
1/*
2 * fs/cifs/cifsproto.h
3 *
366781c1 4 * Copyright (c) International Business Machines Corp., 2002,2008
1da177e4
LT
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
d38d8c74 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1da177e4
LT
20 */
21#ifndef _CIFSPROTO_H
22#define _CIFSPROTO_H
23#include <linux/nls.h>
d683bcd3 24#include "trace.h"
1c780228
PA
25#ifdef CONFIG_CIFS_DFS_UPCALL
26#include "dfs_cache.h"
27#endif
1da177e4
LT
28
29struct statfs;
bf5ea0e2 30struct smb_rqst;
3fa1c6d1 31struct smb3_fs_context;
1da177e4
LT
32
33/*
34 *****************************************************************
35 * All Prototypes
36 *****************************************************************
37 */
38
39extern struct smb_hdr *cifs_buf_get(void);
40extern void cifs_buf_release(void *);
41extern struct smb_hdr *cifs_small_buf_get(void);
42extern void cifs_small_buf_release(void *);
6d81ed1e 43extern void free_rsp_buf(int, void *);
0496e02d
JL
44extern int smb_send(struct TCP_Server_Info *, struct smb_hdr *,
45 unsigned int /* length */);
6d5786a3
PS
46extern unsigned int _get_xid(void);
47extern void _free_xid(unsigned int);
a0a3036b
JP
48#define get_xid() \
49({ \
6d5786a3 50 unsigned int __xid = _get_xid(); \
a0a3036b 51 cifs_dbg(FYI, "VFS: in %s as Xid: %u with uid: %d\n", \
f96637be
JP
52 __func__, __xid, \
53 from_kuid(&init_user_ns, current_fsuid())); \
a0a3036b
JP
54 trace_smb3_enter(__xid, __func__); \
55 __xid; \
b6b38f70
JP
56})
57
a0a3036b
JP
58#define free_xid(curr_xid) \
59do { \
60 _free_xid(curr_xid); \
61 cifs_dbg(FYI, "VFS: leaving %s (xid = %u) rc = %d\n", \
62 __func__, curr_xid, (int)rc); \
63 if (rc) \
d683bcd3 64 trace_smb3_exit_err(curr_xid, __func__, (int)rc); \
a0a3036b
JP
65 else \
66 trace_smb3_exit_done(curr_xid, __func__); \
b6b38f70 67} while (0)
4d79dba0
SP
68extern int init_cifs_idmap(void);
69extern void exit_cifs_idmap(void);
b74cb9a8
SP
70extern int init_cifs_spnego(void);
71extern void exit_cifs_spnego(void);
7f57356b 72extern char *build_path_from_dentry(struct dentry *);
268a635d
AA
73extern char *build_path_from_dentry_optional_prefix(struct dentry *direntry,
74 bool prefix);
3fa1c6d1 75extern char *cifs_build_path_to_root(struct smb3_fs_context *ctx,
6d3ea7e4 76 struct cifs_sb_info *cifs_sb,
374402a2
SP
77 struct cifs_tcon *tcon,
78 int add_treename);
1da177e4 79extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
c6c00919 80extern char *cifs_compose_mount_options(const char *sb_mountdata,
0d4873f9
RS
81 const char *fullpath, const struct dfs_info3_param *ref,
82 char **devname);
99ee4dbd 83/* extern void renew_parental_timestamps(struct dentry *direntry);*/
a6827c18
JL
84extern struct mid_q_entry *AllocMidQEntry(const struct smb_hdr *smb_buffer,
85 struct TCP_Server_Info *server);
766fdbb5 86extern void DeleteMidQEntry(struct mid_q_entry *midEntry);
3c1bf7e4 87extern void cifs_delete_mid(struct mid_q_entry *mid);
696e420b 88extern void cifs_mid_q_entry_release(struct mid_q_entry *midEntry);
2dc7e1c0 89extern void cifs_wake_up_task(struct mid_q_entry *mid);
4326ed2f
PS
90extern int cifs_handle_standard(struct TCP_Server_Info *server,
91 struct mid_q_entry *mid);
66e7b09c 92extern int smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx);
0d4873f9 93extern int smb3_parse_opt(const char *options, const char *key, char **val);
e4af35fa 94extern bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs);
350be257 95extern int cifs_discard_remaining_data(struct TCP_Server_Info *server);
fec344e3
JL
96extern int cifs_call_async(struct TCP_Server_Info *server,
97 struct smb_rqst *rqst,
98 mid_receive_t *receive, mid_callback_t *callback,
3349c3a7
PS
99 mid_handle_t *handle, void *cbdata, const int flags,
100 const struct cifs_credits *exist_credits);
5f68ea4a 101extern struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses);
b8f57ee8 102extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
352d96f3 103 struct TCP_Server_Info *server,
b8f57ee8
PS
104 struct smb_rqst *rqst, int *resp_buf_type,
105 const int flags, struct kvec *resp_iov);
e0bba0b8 106extern int compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
352d96f3 107 struct TCP_Server_Info *server,
e0bba0b8
RS
108 const int flags, const int num_rqst,
109 struct smb_rqst *rqst, int *resp_buf_type,
110 struct kvec *resp_iov);
96daf2b0 111extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *,
1da177e4
LT
112 struct smb_hdr * /* input */ ,
113 struct smb_hdr * /* out */ ,
a891f0f8 114 int * /* bytes returned */ , const int);
96daf2b0 115extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
792af7b0 116 char *in_buf, int flags);
fec344e3 117extern struct mid_q_entry *cifs_setup_request(struct cifs_ses *,
f780bd3f 118 struct TCP_Server_Info *,
fec344e3
JL
119 struct smb_rqst *);
120extern struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *,
121 struct smb_rqst *);
2c8f981d
JL
122extern int cifs_check_receive(struct mid_q_entry *mid,
123 struct TCP_Server_Info *server, bool log_error);
cb7e9eab
PS
124extern int cifs_wait_mtu_credits(struct TCP_Server_Info *server,
125 unsigned int size, unsigned int *num,
335b7b62 126 struct cifs_credits *credits);
96daf2b0 127extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *,
d38d8c74 128 struct kvec *, int /* nvec to send */,
da502f7d
PS
129 int * /* type of buf returned */, const int flags,
130 struct kvec * /* resp vec */);
ad7a2926 131extern int SendReceiveBlockingLock(const unsigned int xid,
96daf2b0 132 struct cifs_tcon *ptcon,
ad7a2926
SF
133 struct smb_hdr *in_buf ,
134 struct smb_hdr *out_buf,
135 int *bytes_returned);
28ea5290 136extern int cifs_reconnect(struct TCP_Server_Info *server);
373512ec 137extern int checkSMB(char *buf, unsigned int len, struct TCP_Server_Info *srvr);
d4e4854f 138extern bool is_valid_oplock_break(char *, struct TCP_Server_Info *);
3d3ea8e6 139extern bool backup_cred(struct cifs_sb_info *);
4b18f2a9 140extern bool is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof);
72432ffc
PS
141extern void cifs_update_eof(struct cifsInodeInfo *cifsi, loff_t offset,
142 unsigned int bytes_written);
86f740f2 143extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *, int);
fe768d51 144extern int cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
86f740f2 145 int flags,
fe768d51 146 struct cifsFileInfo **ret_file);
8de9e86c 147extern int cifs_get_writable_path(struct cifs_tcon *tcon, const char *name,
86f740f2 148 int flags,
8de9e86c 149 struct cifsFileInfo **ret_file);
6508d904 150extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *, bool);
496902dc
RS
151extern int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name,
152 struct cifsFileInfo **ret_file);
9ec672bd 153extern unsigned int smbCalcSize(void *buf, struct TCP_Server_Info *server);
1da177e4 154extern int decode_negTokenInit(unsigned char *security_blob, int length,
26efa0ba 155 struct TCP_Server_Info *server);
67b7626a 156extern int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
b979aaa1 157extern void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
5ffef7bf 158extern int map_smb_to_linux_error(char *buf, bool logErr);
a3713ec3 159extern int map_and_check_smb_error(struct mid_q_entry *mid, bool logErr);
1da177e4 160extern void header_assemble(struct smb_hdr *, char /* command */ ,
96daf2b0 161 const struct cifs_tcon *, int /* length of
1982c344 162 fixed section (word count) in two byte units */);
5815449d 163extern int small_smb_init_no_tc(const int smb_cmd, const int wct,
96daf2b0 164 struct cifs_ses *ses,
50c2f753 165 void **request_buf);
3f618223
JL
166extern enum securityEnum select_sectype(struct TCP_Server_Info *server,
167 enum securityEnum requested);
58c45c58
PS
168extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
169 const struct nls_table *nls_cp);
95390201
AB
170extern struct timespec64 cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
171extern u64 cifs_UnixTimeToNT(struct timespec64);
172extern struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
c4a2c08d 173 int offset);
c6723628 174extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
c11f1df5
SP
175extern int cifs_get_writer(struct cifsInodeInfo *cinode);
176extern void cifs_put_writer(struct cifsInodeInfo *cinode);
177extern void cifs_done_oplock_break(struct cifsInodeInfo *cinode);
d39a4f71
PS
178extern int cifs_unlock_range(struct cifsFileInfo *cfile,
179 struct file_lock *flock, const unsigned int xid);
180extern int cifs_push_mandatory_locks(struct cifsFileInfo *cfile);
1bd5bbcb 181
d46b0da7 182extern void cifs_down_write(struct rw_semaphore *sem);
fb1214e4
PS
183extern struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid,
184 struct file *file,
185 struct tcon_link *tlink,
186 __u32 oplock);
6d5786a3
PS
187extern int cifs_posix_open(char *full_path, struct inode **inode,
188 struct super_block *sb, int mode,
189 unsigned int f_flags, __u32 *oplock, __u16 *netfid,
190 unsigned int xid);
4065c802 191void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr);
cc0bad75
JL
192extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr,
193 FILE_UNIX_BASIC_INFO *info,
194 struct cifs_sb_info *cifs_sb);
c052e2b4
SP
195extern void cifs_dir_info_to_fattr(struct cifs_fattr *, FILE_DIRECTORY_INFO *,
196 struct cifs_sb_info *);
cc0bad75 197extern void cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr);
cc0bad75
JL
198extern struct inode *cifs_iget(struct super_block *sb,
199 struct cifs_fattr *fattr);
200
1208ef1f
PS
201extern int cifs_get_inode_info(struct inode **inode, const char *full_path,
202 FILE_ALL_INFO *data, struct super_block *sb,
42eacf9e 203 int xid, const struct cifs_fid *fid);
6a5f6592
SF
204extern int smb311_posix_get_inode_info(struct inode **pinode, const char *search_path,
205 struct super_block *sb, unsigned int xid);
1da177e4
LT
206extern int cifs_get_inode_info_unix(struct inode **pinode,
207 const unsigned char *search_path,
6d5786a3 208 struct super_block *sb, unsigned int xid);
ed6875e0
PS
209extern int cifs_set_file_info(struct inode *inode, struct iattr *attrs,
210 unsigned int xid, char *full_path, __u32 dosattr);
211extern int cifs_rename_pending_delete(const char *full_path,
212 struct dentry *dentry,
213 const unsigned int xid);
9934430e
SF
214extern int sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
215 struct cifs_fattr *fattr, uint sidtype);
987b21d7 216extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
0b8f18e3 217 struct cifs_fattr *fattr, struct inode *inode,
e2f8fbfb 218 bool get_mode_from_special_sid,
42eacf9e 219 const char *path, const struct cifs_fid *pfid);
0f22053e
SP
220extern int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
221 kuid_t uid, kgid_t gid);
fbeba8bb 222extern struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *, struct inode *,
3970acf7 223 const char *, u32 *, u32);
42eacf9e 224extern struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *,
3970acf7 225 const struct cifs_fid *, u32 *, u32);
b73b9a4b 226extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *,
a5ff3769 227 const char *, int);
643fbcee 228extern unsigned int setup_authusers_ACE(struct cifs_ace *pace);
fdef665b 229extern unsigned int setup_special_mode_ACE(struct cifs_ace *pace, __u64 nmode);
975221ec 230extern unsigned int setup_special_user_owner_ACE(struct cifs_ace *pace);
953f8681 231
e28bc5b1
JL
232extern void dequeue_mid(struct mid_q_entry *mid, bool malformed);
233extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf,
71335664
AV
234 unsigned int to_read);
235extern int cifs_read_page_from_socket(struct TCP_Server_Info *server,
1dbe3466
LL
236 struct page *page,
237 unsigned int page_offset,
238 unsigned int to_read);
51acd208 239extern int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb);
724d9f1c 240extern int cifs_match_super(struct super_block *, void *);
3fa1c6d1 241extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
2a9b9951 242extern void cifs_umount(struct cifs_sb_info *);
aa24d1e9 243extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
52ace1ef
SF
244extern void cifs_reopen_persistent_handles(struct cifs_tcon *tcon);
245
579f9053 246extern bool cifs_find_lock_conflict(struct cifsFileInfo *cfile, __u64 offset,
9645759c 247 __u64 length, __u8 type, __u16 flags,
579f9053 248 struct cifsLockInfo **conf_lock,
081c0414 249 int rw_check);
233839b1
PS
250extern void cifs_add_pending_open(struct cifs_fid *fid,
251 struct tcon_link *tlink,
252 struct cifs_pending_open *open);
253extern void cifs_add_pending_open_locked(struct cifs_fid *fid,
254 struct tcon_link *tlink,
255 struct cifs_pending_open *open);
256extern void cifs_del_pending_open(struct cifs_pending_open *open);
3fa1c6d1 257extern struct TCP_Server_Info *cifs_get_tcp_session(struct smb3_fs_context *ctx);
53e0e11e
PS
258extern void cifs_put_tcp_session(struct TCP_Server_Info *server,
259 int from_reconnect);
260extern void cifs_put_tcon(struct cifs_tcon *tcon);
815465c4
JL
261
262#if IS_ENABLED(CONFIG_CIFS_DFS_UPCALL)
78d31a3a 263extern void cifs_dfs_release_automount_timer(void);
815465c4
JL
264#else /* ! IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) */
265#define cifs_dfs_release_automount_timer() do { } while (0)
266#endif /* ! IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) */
267
1da177e4
LT
268void cifs_proc_init(void);
269void cifs_proc_clean(void);
270
f7ba7fe6
PS
271extern void cifs_move_llist(struct list_head *source, struct list_head *dest);
272extern void cifs_free_llist(struct list_head *llist);
273extern void cifs_del_lock_waiters(struct cifsLockInfo *lock);
274
565674d6
SM
275extern int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon,
276 const struct nls_table *nlsc);
277
286170aa
PS
278extern int cifs_negotiate_protocol(const unsigned int xid,
279 struct cifs_ses *ses);
58c45c58
PS
280extern int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
281 struct nls_table *nls_info);
38d77c50 282extern int cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required);
286170aa 283extern int CIFSSMBNegotiate(const unsigned int xid, struct cifs_ses *ses);
1da177e4 284
2e6e02ab
PS
285extern int CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
286 const char *tree, struct cifs_tcon *tcon,
287 const struct nls_table *);
1da177e4 288
6d5786a3 289extern int CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
c052e2b4 290 const char *searchName, struct cifs_sb_info *cifs_sb,
2608bee7
SP
291 __u16 *searchHandle, __u16 search_flags,
292 struct cifs_search_info *psrch_inf,
c052e2b4 293 bool msearch);
1da177e4 294
6d5786a3 295extern int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon,
2608bee7
SP
296 __u16 searchHandle, __u16 search_flags,
297 struct cifs_search_info *psrch_inf);
1da177e4 298
6d5786a3 299extern int CIFSFindClose(const unsigned int xid, struct cifs_tcon *tcon,
1da177e4
LT
300 const __u16 search_handle);
301
6d5786a3 302extern int CIFSSMBQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
bcd5357f 303 u16 netfid, FILE_ALL_INFO *pFindData);
6d5786a3 304extern int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
68889f26
PS
305 const char *search_Name, FILE_ALL_INFO *data,
306 int legacy /* whether to use old info level */,
307 const struct nls_table *nls_codepage, int remap);
6d5786a3 308extern int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
68889f26
PS
309 const char *search_name, FILE_ALL_INFO *data,
310 const struct nls_table *nls_codepage, int remap);
1da177e4 311
6d5786a3 312extern int CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
c8634fd3 313 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData);
6d5786a3 314extern int CIFSSMBUnixQPathInfo(const unsigned int xid,
96daf2b0 315 struct cifs_tcon *tcon,
1da177e4 316 const unsigned char *searchName,
582d21e5 317 FILE_UNIX_BASIC_INFO *pFindData,
737b758c 318 const struct nls_table *nls_codepage, int remap);
1da177e4 319
6d5786a3 320extern int CIFSGetDFSRefer(const unsigned int xid, struct cifs_ses *ses,
b669f33c
PS
321 const char *search_name,
322 struct dfs_info3_param **target_nodes,
323 unsigned int *num_of_nodes,
324 const struct nls_table *nls_codepage, int remap);
1da177e4 325
4ecce920
AA
326extern int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
327 unsigned int *num_of_nodes,
328 struct dfs_info3_param **target_nodes,
329 const struct nls_table *nls_codepage, int remap,
330 const char *searchName, bool is_unicode);
6d5786a3 331extern void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
2c6292ae 332 struct cifs_sb_info *cifs_sb,
3fa1c6d1 333 struct smb3_fs_context *ctx);
6d5786a3 334extern int CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
737b758c 335 struct kstatfs *FSData);
6d5786a3 336extern int SMBOldQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
20962438 337 struct kstatfs *FSData);
6d5786a3 338extern int CIFSSMBSetFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon,
ac67055e
JA
339 __u64 cap);
340
6d5786a3 341extern int CIFSSMBQFSAttributeInfo(const unsigned int xid,
96daf2b0 342 struct cifs_tcon *tcon);
6d5786a3
PS
343extern int CIFSSMBQFSDeviceInfo(const unsigned int xid, struct cifs_tcon *tcon);
344extern int CIFSSMBQFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon);
345extern int CIFSSMBQFSPosixInfo(const unsigned int xid, struct cifs_tcon *tcon,
737b758c 346 struct kstatfs *FSData);
1da177e4 347
6d5786a3 348extern int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
ad7a2926 349 const char *fileName, const FILE_BASIC_INFO *data,
737b758c 350 const struct nls_table *nls_codepage,
8e408fc9 351 struct cifs_sb_info *cifs_sb);
6d5786a3 352extern int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
2dd2dfa0
JL
353 const FILE_BASIC_INFO *data, __u16 fid,
354 __u32 pid_of_opener);
6d5786a3
PS
355extern int CIFSSMBSetFileDisposition(const unsigned int xid,
356 struct cifs_tcon *tcon,
357 bool delete_file, __u16 fid,
358 __u32 pid_of_opener);
1da177e4 359#if 0
6d5786a3 360extern int CIFSSMBSetAttrLegacy(unsigned int xid, struct cifs_tcon *tcon,
1da177e4
LT
361 char *fileName, __u16 dos_attributes,
362 const struct nls_table *nls_codepage);
363#endif /* possibly unneeded function */
6d5786a3 364extern int CIFSSMBSetEOF(const unsigned int xid, struct cifs_tcon *tcon,
d1433418
PS
365 const char *file_name, __u64 size,
366 struct cifs_sb_info *cifs_sb, bool set_allocation);
6d5786a3 367extern int CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon,
d1433418
PS
368 struct cifsFileInfo *cfile, __u64 size,
369 bool set_allocation);
4e1e7fb9
JL
370
371struct cifs_unix_set_info_args {
372 __u64 ctime;
373 __u64 atime;
374 __u64 mtime;
375 __u64 mode;
49418b2c
EB
376 kuid_t uid;
377 kgid_t gid;
4e1e7fb9
JL
378 dev_t device;
379};
380
6d5786a3
PS
381extern int CIFSSMBUnixSetFileInfo(const unsigned int xid,
382 struct cifs_tcon *tcon,
3bbeeb3c
JL
383 const struct cifs_unix_set_info_args *args,
384 u16 fid, u32 pid_of_opener);
385
6d5786a3 386extern int CIFSSMBUnixSetPathInfo(const unsigned int xid,
ff691e96 387 struct cifs_tcon *tcon, const char *file_name,
6d5786a3
PS
388 const struct cifs_unix_set_info_args *args,
389 const struct nls_table *nls_codepage,
ff691e96 390 int remap);
1da177e4 391
c3ca78e2
SF
392extern int CIFSSMBMkDir(const unsigned int xid, struct inode *inode,
393 umode_t mode, struct cifs_tcon *tcon,
f436720e 394 const char *name, struct cifs_sb_info *cifs_sb);
6d5786a3 395extern int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
f958ca5d 396 const char *name, struct cifs_sb_info *cifs_sb);
6d5786a3 397extern int CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon,
2d785a50
SF
398 const char *name, __u16 type,
399 const struct nls_table *nls_codepage,
400 int remap_special_chars);
6d5786a3 401extern int CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon,
ed6875e0 402 const char *name, struct cifs_sb_info *cifs_sb);
6d5786a3 403extern int CIFSSMBRename(const unsigned int xid, struct cifs_tcon *tcon,
8ceb9843
PS
404 const char *from_name, const char *to_name,
405 struct cifs_sb_info *cifs_sb);
6d5786a3
PS
406extern int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *tcon,
407 int netfid, const char *target_name,
408 const struct nls_table *nls_codepage,
409 int remap_special_chars);
d6e906f1
SF
410extern int CIFSCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
411 const char *from_name, const char *to_name,
412 struct cifs_sb_info *cifs_sb);
6d5786a3 413extern int CIFSUnixCreateHardLink(const unsigned int xid,
96daf2b0 414 struct cifs_tcon *tcon,
1da177e4 415 const char *fromName, const char *toName,
d38d8c74 416 const struct nls_table *nls_codepage,
737b758c 417 int remap_special_chars);
6d5786a3 418extern int CIFSUnixCreateSymLink(const unsigned int xid,
96daf2b0 419 struct cifs_tcon *tcon,
1da177e4 420 const char *fromName, const char *toName,
bc8ebdc4 421 const struct nls_table *nls_codepage, int remap);
6d5786a3 422extern int CIFSSMBUnixQuerySymLink(const unsigned int xid,
96daf2b0 423 struct cifs_tcon *tcon,
460b9696 424 const unsigned char *searchName, char **syminfo,
bc8ebdc4 425 const struct nls_table *nls_codepage, int remap);
d244bf2d
PS
426extern int CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
427 __u16 fid, char **symlinkinfo,
428 const struct nls_table *nls_codepage);
c7f508a9
SF
429extern int CIFSSMB_set_compression(const unsigned int xid,
430 struct cifs_tcon *tcon, __u16 fid);
d81b8a40
PS
431extern int CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms,
432 int *oplock, FILE_ALL_INFO *buf);
6d5786a3 433extern int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon,
a9d02ad4
SF
434 const char *fileName, const int disposition,
435 const int access_flags, const int omode,
8840dee9 436 __u16 *netfid, int *pOplock, FILE_ALL_INFO *,
a9d02ad4 437 const struct nls_table *nls_codepage, int remap);
6d5786a3 438extern int CIFSPOSIXCreate(const unsigned int xid, struct cifs_tcon *tcon,
8840dee9 439 u32 posix_flags, __u64 mode, __u16 *netfid,
2dd29d31
SF
440 FILE_UNIX_BASIC_INFO *pRetData,
441 __u32 *pOplock, const char *name,
d38d8c74 442 const struct nls_table *nls_codepage, int remap);
6d5786a3 443extern int CIFSSMBClose(const unsigned int xid, struct cifs_tcon *tcon,
1da177e4
LT
444 const int smb_file_id);
445
6d5786a3 446extern int CIFSSMBFlush(const unsigned int xid, struct cifs_tcon *tcon,
b298f223
SF
447 const int smb_file_id);
448
6d5786a3 449extern int CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms,
d4ffff1f 450 unsigned int *nbytes, char **buf,
d38d8c74 451 int *return_buf_type);
6d5786a3 452extern int CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
dbbab325 453 unsigned int *nbytes, const char *buf);
6d5786a3 454extern int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
ba9ad725 455 unsigned int *nbytes, struct kvec *iov, const int nvec);
6d5786a3 456extern int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon,
1208ef1f
PS
457 const char *search_name, __u64 *inode_number,
458 const struct nls_table *nls_codepage,
459 int remap);
1da177e4 460
6d5786a3
PS
461extern int cifs_lockv(const unsigned int xid, struct cifs_tcon *tcon,
462 const __u16 netfid, const __u8 lock_type,
463 const __u32 num_unlock, const __u32 num_lock,
464 LOCKING_ANDX_RANGE *buf);
465extern int CIFSSMBLock(const unsigned int xid, struct cifs_tcon *tcon,
03776f45 466 const __u16 netfid, const __u32 netpid, const __u64 len,
1da177e4
LT
467 const __u64 offset, const __u32 numUnlock,
468 const __u32 numLock, const __u8 lockType,
12fed00d 469 const bool waitFlag, const __u8 oplock_level);
6d5786a3 470extern int CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon,
4f6bcec9 471 const __u16 smb_file_id, const __u32 netpid,
c5fd363d
JL
472 const loff_t start_offset, const __u64 len,
473 struct file_lock *, const __u16 lock_type,
474 const bool waitFlag);
2e6e02ab 475extern int CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon);
766fdbb5 476extern int CIFSSMBEcho(struct TCP_Server_Info *server);
58c45c58 477extern int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses);
1da177e4 478
96daf2b0
SF
479extern struct cifs_ses *sesInfoAlloc(void);
480extern void sesInfoFree(struct cifs_ses *);
481extern struct cifs_tcon *tconInfoAlloc(void);
482extern void tconInfoFree(struct cifs_tcon *);
1da177e4 483
bf5ea0e2
JL
484extern int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
485 __u32 *pexpected_response_sequence_number);
762a4206 486extern int cifs_sign_smbv(struct kvec *iov, int n_vec, struct TCP_Server_Info *,
84afc29b 487 __u32 *);
bf5ea0e2
JL
488extern int cifs_sign_smb(struct smb_hdr *, struct TCP_Server_Info *, __u32 *);
489extern int cifs_verify_signature(struct smb_rqst *rqst,
21e73393 490 struct TCP_Server_Info *server,
b609f06a 491 __u32 expected_sequence_number);
9ef5992e
SP
492extern int SMBNTencrypt(unsigned char *, unsigned char *, unsigned char *,
493 const struct nls_table *);
494extern int setup_ntlm_response(struct cifs_ses *, const struct nls_table *);
96daf2b0 495extern int setup_ntlmv2_rsp(struct cifs_ses *, const struct nls_table *);
026e93dc 496extern void cifs_crypto_secmech_release(struct TCP_Server_Info *server);
96daf2b0 497extern int calc_seckey(struct cifs_ses *);
373512ec
SF
498extern int generate_smb30signingkey(struct cifs_ses *);
499extern int generate_smb311signingkey(struct cifs_ses *);
d2b91521 500
7c7b25bc 501#ifdef CONFIG_CIFS_WEAK_PW_HASH
43988d76 502extern int calc_lanman_hash(const char *password, const char *cryptkey,
4e53a3fb 503 bool encrypt, char *lnm_session_key);
7c7b25bc 504#endif /* CIFS_WEAK_PW_HASH */
0eff0e26 505#ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */
6d5786a3 506extern int CIFSSMBNotify(const unsigned int xid, struct cifs_tcon *tcon,
0eff0e26
SF
507 const int notify_subdirs, const __u16 netfid,
508 __u32 filter, struct file *file, int multishot,
509 const struct nls_table *nls_codepage);
510#endif /* was needed for dnotify, and will be needed for inotify when VFS fix */
6d5786a3 511extern int CIFSSMBCopy(unsigned int xid,
96daf2b0 512 struct cifs_tcon *source_tcon,
1da177e4
LT
513 const char *fromName,
514 const __u16 target_tid,
515 const char *toName, const int flags,
50c2f753 516 const struct nls_table *nls_codepage,
737b758c 517 int remap_special_chars);
6d5786a3 518extern ssize_t CIFSSMBQAllEAs(const unsigned int xid, struct cifs_tcon *tcon,
31c0519f
JL
519 const unsigned char *searchName,
520 const unsigned char *ea_name, char *EAData,
67b4c889 521 size_t bufsize, struct cifs_sb_info *cifs_sb);
6d5786a3 522extern int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
d38d8c74
SF
523 const char *fileName, const char *ea_name,
524 const void *ea_value, const __u16 ea_value_len,
5517554e
RS
525 const struct nls_table *nls_codepage,
526 struct cifs_sb_info *cifs_sb);
6d5786a3 527extern int CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon,
630f3f0c 528 __u16 fid, struct cifs_ntsd **acl_inf, __u32 *buflen);
6d5786a3 529extern int CIFSSMBSetCIFSACL(const unsigned int, struct cifs_tcon *, __u16,
a5ff3769 530 struct cifs_ntsd *, __u32, int);
6d5786a3 531extern int CIFSSMBGetPosixACL(const unsigned int xid, struct cifs_tcon *tcon,
1da177e4 532 const unsigned char *searchName,
d38d8c74 533 char *acl_inf, const int buflen, const int acl_type,
737b758c 534 const struct nls_table *nls_codepage, int remap_special_chars);
6d5786a3 535extern int CIFSSMBSetPosixACL(const unsigned int xid, struct cifs_tcon *tcon,
1da177e4
LT
536 const unsigned char *fileName,
537 const char *local_acl, const int buflen, const int acl_type,
737b758c 538 const struct nls_table *nls_codepage, int remap_special_chars);
6d5786a3 539extern int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon,
8840dee9 540 const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
ec06aedd 541extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb);
cb084b1a
SP
542extern bool couldbe_mf_symlink(const struct cifs_fattr *fattr);
543extern int check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
750b8de6
SP
544 struct cifs_sb_info *cifs_sb,
545 struct cifs_fattr *fattr,
546 const unsigned char *path);
ee2c9258 547extern int mdfour(unsigned char *, unsigned char *, int);
9ef5992e
SP
548extern int E_md4hash(const unsigned char *passwd, unsigned char *p16,
549 const struct nls_table *codepage);
43988d76 550extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8,
ee2c9258 551 unsigned char *p24);
5072010c
PAS
552
553extern int
0d4873f9 554cifs_setup_volume_info(struct smb3_fs_context *ctx, const char *mntopts, const char *devname);
c28c89fc 555
54be1f6c 556extern struct TCP_Server_Info *
3fa1c6d1 557cifs_find_tcp_session(struct smb3_fs_context *ctx);
54be1f6c 558
5072010c
PAS
559extern void cifs_put_smb_ses(struct cifs_ses *ses);
560
561extern struct cifs_ses *
3fa1c6d1 562cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx);
5072010c 563
6993f74a 564void cifs_readdata_release(struct kref *refcount);
e28bc5b1 565int cifs_async_readv(struct cifs_readdata *rdata);
09a4707e 566int cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid);
e28bc5b1 567
4a5c80d7
SF
568int cifs_async_writev(struct cifs_writedata *wdata,
569 void (*release)(struct kref *kref));
c2e87640
JL
570void cifs_writev_complete(struct work_struct *work);
571struct cifs_writedata *cifs_writedata_alloc(unsigned int nr_pages,
572 work_func_t complete);
8e7360f6
LL
573struct cifs_writedata *cifs_writedata_direct_alloc(struct page **pages,
574 work_func_t complete);
c28c89fc 575void cifs_writedata_release(struct kref *refcount);
b5be1a1c
SP
576int cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
577 struct cifs_sb_info *cifs_sb,
578 const unsigned char *path, char *pbuf,
579 unsigned int *pbytes_read);
cbb0aba6
SP
580int cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
581 struct cifs_sb_info *cifs_sb,
582 const unsigned char *path, char *pbuf,
583 unsigned int *pbytes_written);
c713c877 584int __cifs_calc_signature(struct smb_rqst *rqst,
16c568ef
AV
585 struct TCP_Server_Info *server, char *signature,
586 struct shash_desc *shash);
ef65aaed
SP
587enum securityEnum cifs_select_sectype(struct TCP_Server_Info *,
588 enum securityEnum);
ccf7f408
PS
589struct cifs_aio_ctx *cifs_aio_ctx_alloc(void);
590void cifs_aio_ctx_release(struct kref *refcount);
591int setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw);
a93864d9 592void smb2_cached_lease_break(struct work_struct *work);
82fb82be
AA
593
594int cifs_alloc_hash(const char *name, struct crypto_shash **shash,
595 struct sdesc **sdesc);
596void cifs_free_hash(struct crypto_shash **shash, struct sdesc **sdesc);
597
7b7f2bdf
LL
598extern void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page,
599 unsigned int *len, unsigned int *offset);
2f589679
AA
600struct cifs_chan *
601cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server);
387ec58f 602int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses);
d70e9fa5
AA
603bool is_server_using_iface(struct TCP_Server_Info *server,
604 struct cifs_server_iface *iface);
605bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface);
7b7f2bdf 606
a3a53b76 607void extract_unc_hostname(const char *unc, const char **h, size_t *len);
340625e6 608int copy_path_name(char *dst, const char *src);
37478608
RS
609int smb2_parse_query_directory(struct cifs_tcon *tcon, struct kvec *rsp_iov,
610 int resp_buftype,
611 struct cifs_search_info *srch_inf);
a3a53b76 612
bacd704a
PAS
613struct super_block *cifs_get_tcp_super(struct TCP_Server_Info *server);
614void cifs_put_tcp_super(struct super_block *sb);
7548e1da 615int update_super_prepath(struct cifs_tcon *tcon, char *prefix);
a87e6725 616char *extract_hostname(const char *unc);
e73a42e0 617char *extract_sharename(const char *unc);
bacd704a 618
1c780228
PA
619#ifdef CONFIG_CIFS_DFS_UPCALL
620static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,
621 const char *old_path,
622 const struct nls_table *nls_codepage,
623 struct dfs_info3_param *referral, int remap)
624{
625 return dfs_cache_find(xid, ses, nls_codepage, remap, old_path,
626 referral, NULL);
627}
e4af35fa
PA
628
629int match_target_ip(struct TCP_Server_Info *server,
630 const char *share, size_t share_len,
631 bool *result);
1c780228
PA
632#endif
633
0f060936
AG
634static inline int cifs_create_options(struct cifs_sb_info *cifs_sb, int options)
635{
87f93d82 636 if (cifs_sb && (backup_cred(cifs_sb)))
0f060936
AG
637 return options | CREATE_OPEN_BACKUP_INTENT;
638 else
639 return options;
640}
641
1da177e4 642#endif /* _CIFSPROTO_H */