Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.19 886 lines 36 kB view raw
1/* SPDX-License-Identifier: LGPL-2.1 */ 2/* 3 * 4 * Copyright (c) International Business Machines Corp., 2002,2008 5 * Author(s): Steve French (sfrench@us.ibm.com) 6 * 7 */ 8#ifndef _CIFSPROTO_H 9#define _CIFSPROTO_H 10#include <linux/nls.h> 11#include <linux/ctype.h> 12#include "cifsglob.h" 13#include "trace.h" 14#ifdef CONFIG_CIFS_DFS_UPCALL 15#include "dfs_cache.h" 16#endif 17 18struct statfs; 19struct smb_rqst; 20struct smb3_fs_context; 21 22/* 23 ***************************************************************** 24 * All Prototypes 25 ***************************************************************** 26 */ 27 28extern struct smb_hdr *cifs_buf_get(void); 29extern void cifs_buf_release(void *); 30extern struct smb_hdr *cifs_small_buf_get(void); 31extern void cifs_small_buf_release(void *); 32extern void free_rsp_buf(int, void *); 33extern int smb_send_kvec(struct TCP_Server_Info *server, 34 struct msghdr *msg, 35 size_t *sent); 36extern unsigned int _get_xid(void); 37extern void _free_xid(unsigned int); 38#define get_xid() \ 39({ \ 40 unsigned int __xid = _get_xid(); \ 41 cifs_dbg(FYI, "VFS: in %s as Xid: %u with uid: %d\n", \ 42 __func__, __xid, \ 43 from_kuid(&init_user_ns, current_fsuid())); \ 44 trace_smb3_enter(__xid, __func__); \ 45 __xid; \ 46}) 47 48#define free_xid(curr_xid) \ 49do { \ 50 _free_xid(curr_xid); \ 51 cifs_dbg(FYI, "VFS: leaving %s (xid = %u) rc = %d\n", \ 52 __func__, curr_xid, (int)rc); \ 53 if (rc) \ 54 trace_smb3_exit_err(curr_xid, __func__, (int)rc); \ 55 else \ 56 trace_smb3_exit_done(curr_xid, __func__); \ 57} while (0) 58extern int init_cifs_idmap(void); 59extern void exit_cifs_idmap(void); 60extern int init_cifs_spnego(void); 61extern void exit_cifs_spnego(void); 62extern const char *build_path_from_dentry(struct dentry *, void *); 63char *__build_path_from_dentry_optional_prefix(struct dentry *direntry, void *page, 64 const char *tree, int tree_len, 65 bool prefix); 66extern char *build_path_from_dentry_optional_prefix(struct dentry *direntry, 67 void *page, bool prefix); 68static inline void *alloc_dentry_path(void) 69{ 70 return __getname(); 71} 72 73static inline void free_dentry_path(void *page) 74{ 75 if (page) 76 __putname(page); 77} 78 79extern char *cifs_build_path_to_root(struct smb3_fs_context *ctx, 80 struct cifs_sb_info *cifs_sb, 81 struct cifs_tcon *tcon, 82 int add_treename); 83char *cifs_build_devname(char *nodename, const char *prepath); 84void delete_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid); 85void __release_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid); 86void cifs_wake_up_task(struct TCP_Server_Info *server, struct mid_q_entry *mid); 87extern int cifs_handle_standard(struct TCP_Server_Info *server, 88 struct mid_q_entry *mid); 89extern char *smb3_fs_context_fullpath(const struct smb3_fs_context *ctx, 90 char dirsep); 91extern int smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx); 92extern int smb3_parse_opt(const char *options, const char *key, char **val); 93extern int cifs_ipaddr_cmp(struct sockaddr *srcaddr, struct sockaddr *rhs); 94extern bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs); 95extern int cifs_discard_remaining_data(struct TCP_Server_Info *server); 96extern int cifs_call_async(struct TCP_Server_Info *server, 97 struct smb_rqst *rqst, 98 mid_receive_t receive, mid_callback_t callback, 99 mid_handle_t handle, void *cbdata, const int flags, 100 const struct cifs_credits *exist_credits); 101extern struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses); 102extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, 103 struct TCP_Server_Info *server, 104 struct smb_rqst *rqst, int *resp_buf_type, 105 const int flags, struct kvec *resp_iov); 106extern int compound_send_recv(const unsigned int xid, struct cifs_ses *ses, 107 struct TCP_Server_Info *server, 108 const int flags, const int num_rqst, 109 struct smb_rqst *rqst, int *resp_buf_type, 110 struct kvec *resp_iov); 111int SendReceive(const unsigned int xid, struct cifs_ses *ses, 112 struct smb_hdr *in_buf, unsigned int in_len, 113 struct smb_hdr *out_buf, int *pbytes_returned, const int flags); 114int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses, 115 char *in_buf, unsigned int in_len, int flags); 116int cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server); 117struct mid_q_entry *cifs_setup_request(struct cifs_ses *ses, struct TCP_Server_Info *ignored, 118 struct smb_rqst *rqst); 119struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *server, 120 struct smb_rqst *rqst); 121int __smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, 122 struct smb_rqst *rqst); 123extern int cifs_check_receive(struct mid_q_entry *mid, 124 struct TCP_Server_Info *server, bool log_error); 125int wait_for_free_request(struct TCP_Server_Info *server, const int flags, 126 unsigned int *instance); 127extern int cifs_wait_mtu_credits(struct TCP_Server_Info *server, 128 size_t size, size_t *num, 129 struct cifs_credits *credits); 130 131static inline int 132send_cancel(struct cifs_ses *ses, struct TCP_Server_Info *server, 133 struct smb_rqst *rqst, struct mid_q_entry *mid, 134 unsigned int xid) 135{ 136 return server->ops->send_cancel ? 137 server->ops->send_cancel(ses, server, rqst, mid, xid) : 0; 138} 139 140int wait_for_response(struct TCP_Server_Info *server, struct mid_q_entry *midQ); 141extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *, 142 struct kvec *, int /* nvec to send */, 143 int * /* type of buf returned */, const int flags, 144 struct kvec * /* resp vec */); 145 146void smb2_query_server_interfaces(struct work_struct *work); 147void 148cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server, 149 bool all_channels); 150void 151cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server, 152 bool mark_smb_session); 153extern int cifs_reconnect(struct TCP_Server_Info *server, 154 bool mark_smb_session); 155int checkSMB(char *buf, unsigned int pdu_len, unsigned int len, 156 struct TCP_Server_Info *srvr); 157extern bool is_valid_oplock_break(char *, struct TCP_Server_Info *); 158extern bool backup_cred(struct cifs_sb_info *); 159extern bool is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 eof, 160 bool from_readdir); 161void cifs_write_subrequest_terminated(struct cifs_io_subrequest *wdata, ssize_t result); 162extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *, int); 163extern int cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, 164 int flags, 165 struct cifsFileInfo **ret_file); 166extern int cifs_get_writable_path(struct cifs_tcon *tcon, const char *name, 167 int flags, 168 struct cifsFileInfo **ret_file); 169extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *, bool); 170extern int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name, 171 struct cifsFileInfo **ret_file); 172extern int cifs_get_hardlink_path(struct cifs_tcon *tcon, struct inode *inode, 173 struct file *file); 174extern unsigned int smbCalcSize(void *buf); 175extern int decode_negTokenInit(unsigned char *security_blob, int length, 176 struct TCP_Server_Info *server); 177extern int cifs_convert_address(struct sockaddr *dst, const char *src, int len); 178extern void cifs_set_port(struct sockaddr *addr, const unsigned short int port); 179extern int map_smb_to_linux_error(char *buf, bool logErr); 180extern int map_and_check_smb_error(struct TCP_Server_Info *server, 181 struct mid_q_entry *mid, bool logErr); 182unsigned int header_assemble(struct smb_hdr *buffer, char smb_command, 183 const struct cifs_tcon *treeCon, int word_count 184 /* length of fixed section word count in two byte units */); 185extern int small_smb_init_no_tc(const int smb_cmd, const int wct, 186 struct cifs_ses *ses, 187 void **request_buf); 188extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses, 189 struct TCP_Server_Info *server, 190 const struct nls_table *nls_cp); 191extern struct timespec64 cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601); 192extern u64 cifs_UnixTimeToNT(struct timespec64); 193extern struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, 194 int offset); 195extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock); 196extern int cifs_get_writer(struct cifsInodeInfo *cinode); 197extern void cifs_put_writer(struct cifsInodeInfo *cinode); 198extern void cifs_done_oplock_break(struct cifsInodeInfo *cinode); 199extern int cifs_unlock_range(struct cifsFileInfo *cfile, 200 struct file_lock *flock, const unsigned int xid); 201extern int cifs_push_mandatory_locks(struct cifsFileInfo *cfile); 202 203extern void cifs_down_write(struct rw_semaphore *sem); 204struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid, struct file *file, 205 struct tcon_link *tlink, __u32 oplock, 206 const char *symlink_target); 207extern int cifs_posix_open(const char *full_path, struct inode **inode, 208 struct super_block *sb, int mode, 209 unsigned int f_flags, __u32 *oplock, __u16 *netfid, 210 unsigned int xid); 211void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr); 212extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, 213 FILE_UNIX_BASIC_INFO *info, 214 struct cifs_sb_info *cifs_sb); 215extern void cifs_dir_info_to_fattr(struct cifs_fattr *, FILE_DIRECTORY_INFO *, 216 struct cifs_sb_info *); 217extern int cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr, 218 bool from_readdir); 219extern struct inode *cifs_iget(struct super_block *sb, 220 struct cifs_fattr *fattr); 221 222int cifs_get_inode_info(struct inode **inode, const char *full_path, 223 struct cifs_open_info_data *data, struct super_block *sb, int xid, 224 const struct cifs_fid *fid); 225extern int smb311_posix_get_inode_info(struct inode **inode, 226 const char *full_path, 227 struct cifs_open_info_data *data, 228 struct super_block *sb, 229 const unsigned int xid); 230extern int cifs_get_inode_info_unix(struct inode **pinode, 231 const unsigned char *search_path, 232 struct super_block *sb, unsigned int xid); 233extern int cifs_set_file_info(struct inode *inode, struct iattr *attrs, 234 unsigned int xid, const char *full_path, __u32 dosattr); 235extern int cifs_rename_pending_delete(const char *full_path, 236 struct dentry *dentry, 237 const unsigned int xid); 238extern int sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid, 239 struct cifs_fattr *fattr, uint sidtype); 240extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, 241 struct cifs_fattr *fattr, struct inode *inode, 242 bool get_mode_from_special_sid, 243 const char *path, const struct cifs_fid *pfid); 244extern int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode, 245 kuid_t uid, kgid_t gid); 246extern struct smb_ntsd *get_cifs_acl(struct cifs_sb_info *cifssmb, struct inode *ino, 247 const char *path, u32 *plen, u32 info); 248extern struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifssb, 249 const struct cifs_fid *pfid, u32 *plen, u32 info); 250extern struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap, 251 struct dentry *dentry, int type); 252extern int cifs_set_acl(struct mnt_idmap *idmap, 253 struct dentry *dentry, struct posix_acl *acl, int type); 254extern int set_cifs_acl(struct smb_ntsd *pntsd, __u32 len, struct inode *ino, 255 const char *path, int flag); 256extern unsigned int setup_authusers_ACE(struct smb_ace *pace); 257extern unsigned int setup_special_mode_ACE(struct smb_ace *pace, 258 bool posix, 259 __u64 nmode); 260extern unsigned int setup_special_user_owner_ACE(struct smb_ace *pace); 261 262void dequeue_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid, bool malformed); 263extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, 264 unsigned int to_read); 265extern ssize_t cifs_discard_from_socket(struct TCP_Server_Info *server, 266 size_t to_read); 267int cifs_read_iter_from_socket(struct TCP_Server_Info *server, 268 struct iov_iter *iter, 269 unsigned int to_read); 270extern int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb); 271void cifs_mount_put_conns(struct cifs_mount_ctx *mnt_ctx); 272int cifs_mount_get_session(struct cifs_mount_ctx *mnt_ctx); 273int cifs_is_path_remote(struct cifs_mount_ctx *mnt_ctx); 274int cifs_mount_get_tcon(struct cifs_mount_ctx *mnt_ctx); 275extern int cifs_match_super(struct super_block *, void *); 276extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx); 277extern void cifs_umount(struct cifs_sb_info *); 278extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon); 279extern void cifs_reopen_persistent_handles(struct cifs_tcon *tcon); 280 281extern bool cifs_find_lock_conflict(struct cifsFileInfo *cfile, __u64 offset, 282 __u64 length, __u8 type, __u16 flags, 283 struct cifsLockInfo **conf_lock, 284 int rw_check); 285extern void cifs_add_pending_open(struct cifs_fid *fid, 286 struct tcon_link *tlink, 287 struct cifs_pending_open *open); 288extern void cifs_add_pending_open_locked(struct cifs_fid *fid, 289 struct tcon_link *tlink, 290 struct cifs_pending_open *open); 291extern void cifs_del_pending_open(struct cifs_pending_open *open); 292 293extern bool cifs_is_deferred_close(struct cifsFileInfo *cfile, 294 struct cifs_deferred_close **dclose); 295 296extern void cifs_add_deferred_close(struct cifsFileInfo *cfile, 297 struct cifs_deferred_close *dclose); 298 299extern void cifs_del_deferred_close(struct cifsFileInfo *cfile); 300 301extern void cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode); 302 303extern void cifs_close_all_deferred_files(struct cifs_tcon *cifs_tcon); 304 305void cifs_close_deferred_file_under_dentry(struct cifs_tcon *cifs_tcon, 306 struct dentry *dentry); 307 308extern void cifs_mark_open_handles_for_deleted_file(struct inode *inode, 309 const char *path); 310 311extern struct TCP_Server_Info * 312cifs_get_tcp_session(struct smb3_fs_context *ctx, 313 struct TCP_Server_Info *primary_server); 314extern void cifs_put_tcp_session(struct TCP_Server_Info *server, 315 int from_reconnect); 316extern void cifs_put_tcon(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace); 317 318extern void cifs_release_automount_timer(void); 319 320void cifs_proc_init(void); 321void cifs_proc_clean(void); 322 323extern void cifs_move_llist(struct list_head *source, struct list_head *dest); 324extern void cifs_free_llist(struct list_head *llist); 325extern void cifs_del_lock_waiters(struct cifsLockInfo *lock); 326 327int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon); 328 329extern int cifs_negotiate_protocol(const unsigned int xid, 330 struct cifs_ses *ses, 331 struct TCP_Server_Info *server); 332extern int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, 333 struct TCP_Server_Info *server, 334 struct nls_table *nls_info); 335extern int cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required); 336extern int CIFSSMBNegotiate(const unsigned int xid, 337 struct cifs_ses *ses, 338 struct TCP_Server_Info *server); 339 340extern int CIFSTCon(const unsigned int xid, struct cifs_ses *ses, 341 const char *tree, struct cifs_tcon *tcon, 342 const struct nls_table *); 343 344extern int CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon, 345 const char *searchName, struct cifs_sb_info *cifs_sb, 346 __u16 *searchHandle, __u16 search_flags, 347 struct cifs_search_info *psrch_inf, 348 bool msearch); 349 350extern int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon, 351 __u16 searchHandle, __u16 search_flags, 352 struct cifs_search_info *psrch_inf); 353 354extern int CIFSFindClose(const unsigned int xid, struct cifs_tcon *tcon, 355 const __u16 search_handle); 356 357extern int CIFSSMBQFileInfo(const unsigned int xid, struct cifs_tcon *tcon, 358 u16 netfid, FILE_ALL_INFO *pFindData); 359extern int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon, 360 const char *search_Name, FILE_ALL_INFO *data, 361 int legacy /* whether to use old info level */, 362 const struct nls_table *nls_codepage, int remap); 363extern int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon, 364 const char *search_name, FILE_ALL_INFO *data, 365 const struct nls_table *nls_codepage, int remap); 366 367extern int CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon, 368 u16 netfid, FILE_UNIX_BASIC_INFO *pFindData); 369extern int CIFSSMBUnixQPathInfo(const unsigned int xid, 370 struct cifs_tcon *tcon, 371 const unsigned char *searchName, 372 FILE_UNIX_BASIC_INFO *pFindData, 373 const struct nls_table *nls_codepage, int remap); 374 375extern int CIFSGetDFSRefer(const unsigned int xid, struct cifs_ses *ses, 376 const char *search_name, 377 struct dfs_info3_param **target_nodes, 378 unsigned int *num_of_nodes, 379 const struct nls_table *nls_codepage, int remap); 380 381extern int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size, 382 unsigned int *num_of_nodes, 383 struct dfs_info3_param **target_nodes, 384 const struct nls_table *nls_codepage, int remap, 385 const char *searchName, bool is_unicode); 386extern void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon, 387 struct cifs_sb_info *cifs_sb, 388 struct smb3_fs_context *ctx); 389extern int CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon, 390 struct kstatfs *FSData); 391extern int SMBOldQFSInfo(const unsigned int xid, struct cifs_tcon *tcon, 392 struct kstatfs *FSData); 393extern int CIFSSMBSetFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon, 394 __u64 cap); 395 396extern int CIFSSMBQFSAttributeInfo(const unsigned int xid, 397 struct cifs_tcon *tcon); 398extern int CIFSSMBQFSDeviceInfo(const unsigned int xid, struct cifs_tcon *tcon); 399extern int CIFSSMBQFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon); 400extern int CIFSSMBQFSPosixInfo(const unsigned int xid, struct cifs_tcon *tcon, 401 struct kstatfs *FSData); 402 403extern int SMBSetInformation(const unsigned int xid, struct cifs_tcon *tcon, 404 const char *fileName, __le32 attributes, __le64 write_time, 405 const struct nls_table *nls_codepage, 406 struct cifs_sb_info *cifs_sb); 407extern int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon, 408 const char *fileName, const FILE_BASIC_INFO *data, 409 const struct nls_table *nls_codepage, 410 struct cifs_sb_info *cifs_sb); 411extern int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon, 412 const FILE_BASIC_INFO *data, __u16 fid, 413 __u32 pid_of_opener); 414extern int CIFSSMBSetFileDisposition(const unsigned int xid, 415 struct cifs_tcon *tcon, 416 bool delete_file, __u16 fid, 417 __u32 pid_of_opener); 418extern int CIFSSMBSetEOF(const unsigned int xid, struct cifs_tcon *tcon, 419 const char *file_name, __u64 size, 420 struct cifs_sb_info *cifs_sb, bool set_allocation, 421 struct dentry *dentry); 422extern int CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon, 423 struct cifsFileInfo *cfile, __u64 size, 424 bool set_allocation); 425 426struct cifs_unix_set_info_args { 427 __u64 ctime; 428 __u64 atime; 429 __u64 mtime; 430 __u64 mode; 431 kuid_t uid; 432 kgid_t gid; 433 dev_t device; 434}; 435 436extern int CIFSSMBUnixSetFileInfo(const unsigned int xid, 437 struct cifs_tcon *tcon, 438 const struct cifs_unix_set_info_args *args, 439 u16 fid, u32 pid_of_opener); 440 441extern int CIFSSMBUnixSetPathInfo(const unsigned int xid, 442 struct cifs_tcon *tcon, const char *file_name, 443 const struct cifs_unix_set_info_args *args, 444 const struct nls_table *nls_codepage, 445 int remap); 446 447extern int CIFSSMBMkDir(const unsigned int xid, struct inode *inode, 448 umode_t mode, struct cifs_tcon *tcon, 449 const char *name, struct cifs_sb_info *cifs_sb); 450extern int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon, 451 const char *name, struct cifs_sb_info *cifs_sb); 452extern int CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon, 453 const char *name, __u16 type, 454 const struct nls_table *nls_codepage, 455 int remap_special_chars); 456extern int CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon, 457 const char *name, struct cifs_sb_info *cifs_sb, 458 struct dentry *dentry); 459int CIFSSMBRename(const unsigned int xid, struct cifs_tcon *tcon, 460 struct dentry *source_dentry, 461 const char *from_name, const char *to_name, 462 struct cifs_sb_info *cifs_sb); 463extern int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *tcon, 464 int netfid, const char *target_name, 465 const struct nls_table *nls_codepage, 466 int remap_special_chars); 467int CIFSCreateHardLink(const unsigned int xid, 468 struct cifs_tcon *tcon, 469 struct dentry *source_dentry, 470 const char *from_name, const char *to_name, 471 struct cifs_sb_info *cifs_sb); 472extern int CIFSUnixCreateHardLink(const unsigned int xid, 473 struct cifs_tcon *tcon, 474 const char *fromName, const char *toName, 475 const struct nls_table *nls_codepage, 476 int remap_special_chars); 477extern int CIFSUnixCreateSymLink(const unsigned int xid, 478 struct cifs_tcon *tcon, 479 const char *fromName, const char *toName, 480 const struct nls_table *nls_codepage, int remap); 481extern int CIFSSMBUnixQuerySymLink(const unsigned int xid, 482 struct cifs_tcon *tcon, 483 const unsigned char *searchName, char **syminfo, 484 const struct nls_table *nls_codepage, int remap); 485extern int cifs_query_reparse_point(const unsigned int xid, 486 struct cifs_tcon *tcon, 487 struct cifs_sb_info *cifs_sb, 488 const char *full_path, 489 u32 *tag, struct kvec *rsp, 490 int *rsp_buftype); 491extern struct inode *cifs_create_reparse_inode(struct cifs_open_info_data *data, 492 struct super_block *sb, 493 const unsigned int xid, 494 struct cifs_tcon *tcon, 495 const char *full_path, 496 bool directory, 497 struct kvec *reparse_iov, 498 struct kvec *xattr_iov); 499extern int CIFSSMB_set_compression(const unsigned int xid, 500 struct cifs_tcon *tcon, __u16 fid); 501extern int CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, 502 int *oplock, FILE_ALL_INFO *buf); 503extern int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon, 504 const char *fileName, const int disposition, 505 const int access_flags, const int omode, 506 __u16 *netfid, int *pOplock, FILE_ALL_INFO *, 507 const struct nls_table *nls_codepage, int remap); 508extern int CIFSPOSIXCreate(const unsigned int xid, struct cifs_tcon *tcon, 509 u32 posix_flags, __u64 mode, __u16 *netfid, 510 FILE_UNIX_BASIC_INFO *pRetData, 511 __u32 *pOplock, const char *name, 512 const struct nls_table *nls_codepage, int remap); 513extern int CIFSSMBClose(const unsigned int xid, struct cifs_tcon *tcon, 514 const int smb_file_id); 515 516extern int CIFSSMBFlush(const unsigned int xid, struct cifs_tcon *tcon, 517 const int smb_file_id); 518 519extern int CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms, 520 unsigned int *nbytes, char **buf, 521 int *return_buf_type); 522extern int CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms, 523 unsigned int *nbytes, const char *buf); 524extern int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms, 525 unsigned int *nbytes, struct kvec *iov, const int nvec); 526extern int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon, 527 const char *search_name, __u64 *inode_number, 528 const struct nls_table *nls_codepage, 529 int remap); 530 531extern int cifs_lockv(const unsigned int xid, struct cifs_tcon *tcon, 532 const __u16 netfid, const __u8 lock_type, 533 const __u32 num_unlock, const __u32 num_lock, 534 LOCKING_ANDX_RANGE *buf); 535extern int CIFSSMBLock(const unsigned int xid, struct cifs_tcon *tcon, 536 const __u16 netfid, const __u32 netpid, const __u64 len, 537 const __u64 offset, const __u32 numUnlock, 538 const __u32 numLock, const __u8 lockType, 539 const bool waitFlag, const __u8 oplock_level); 540extern int CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon, 541 const __u16 smb_file_id, const __u32 netpid, 542 const loff_t start_offset, const __u64 len, 543 struct file_lock *, const __u16 lock_type, 544 const bool waitFlag); 545extern int CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon); 546extern int CIFSSMBEcho(struct TCP_Server_Info *server); 547extern int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses); 548 549extern struct cifs_ses *sesInfoAlloc(void); 550extern void sesInfoFree(struct cifs_ses *); 551extern struct cifs_tcon *tcon_info_alloc(bool dir_leases_enabled, 552 enum smb3_tcon_ref_trace trace); 553extern void tconInfoFree(struct cifs_tcon *tcon, enum smb3_tcon_ref_trace trace); 554 555extern int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server, 556 __u32 *pexpected_response_sequence_number); 557int cifs_verify_signature(struct smb_rqst *rqst, 558 struct TCP_Server_Info *server, 559 __u32 expected_sequence_number); 560extern int setup_ntlmv2_rsp(struct cifs_ses *, const struct nls_table *); 561extern void cifs_crypto_secmech_release(struct TCP_Server_Info *server); 562extern int calc_seckey(struct cifs_ses *); 563extern int generate_smb30signingkey(struct cifs_ses *ses, 564 struct TCP_Server_Info *server); 565extern int generate_smb311signingkey(struct cifs_ses *ses, 566 struct TCP_Server_Info *server); 567 568#ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY 569extern ssize_t CIFSSMBQAllEAs(const unsigned int xid, struct cifs_tcon *tcon, 570 const unsigned char *searchName, 571 const unsigned char *ea_name, char *EAData, 572 size_t bufsize, struct cifs_sb_info *cifs_sb); 573extern int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon, 574 const char *fileName, const char *ea_name, 575 const void *ea_value, const __u16 ea_value_len, 576 const struct nls_table *nls_codepage, 577 struct cifs_sb_info *cifs_sb); 578extern int CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon, 579 __u16 fid, struct smb_ntsd **acl_inf, __u32 *buflen, __u32 info); 580extern int CIFSSMBSetCIFSACL(const unsigned int, struct cifs_tcon *, __u16, 581 struct smb_ntsd *pntsd, __u32 len, int aclflag); 582extern int cifs_do_get_acl(const unsigned int xid, struct cifs_tcon *tcon, 583 const unsigned char *searchName, 584 struct posix_acl **acl, const int acl_type, 585 const struct nls_table *nls_codepage, int remap); 586extern int cifs_do_set_acl(const unsigned int xid, struct cifs_tcon *tcon, 587 const unsigned char *fileName, 588 const struct posix_acl *acl, const int acl_type, 589 const struct nls_table *nls_codepage, int remap); 590extern int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon, 591 const int netfid, __u64 *pExtAttrBits, __u64 *pMask); 592#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ 593extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb); 594extern bool couldbe_mf_symlink(const struct cifs_fattr *fattr); 595extern int check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, 596 struct cifs_sb_info *cifs_sb, 597 struct cifs_fattr *fattr, 598 const unsigned char *path); 599extern int E_md4hash(const unsigned char *passwd, unsigned char *p16, 600 const struct nls_table *codepage); 601 602extern struct TCP_Server_Info * 603cifs_find_tcp_session(struct smb3_fs_context *ctx); 604 605struct cifs_tcon *cifs_setup_ipc(struct cifs_ses *ses, bool seal); 606 607void __cifs_put_smb_ses(struct cifs_ses *ses); 608 609extern struct cifs_ses * 610cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx); 611 612int cifs_async_readv(struct cifs_io_subrequest *rdata); 613int cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid); 614 615void cifs_async_writev(struct cifs_io_subrequest *wdata); 616int cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, 617 struct cifs_sb_info *cifs_sb, 618 const unsigned char *path, char *pbuf, 619 unsigned int *pbytes_read); 620int cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, 621 struct cifs_sb_info *cifs_sb, 622 const unsigned char *path, char *pbuf, 623 unsigned int *pbytes_written); 624int __cifs_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server, 625 char *signature, struct cifs_calc_sig_ctx *ctx); 626enum securityEnum cifs_select_sectype(struct TCP_Server_Info *, 627 enum securityEnum); 628 629int cifs_alloc_hash(const char *name, struct shash_desc **sdesc); 630void cifs_free_hash(struct shash_desc **sdesc); 631 632int cifs_try_adding_channels(struct cifs_ses *ses); 633int smb3_update_ses_channels(struct cifs_ses *ses, struct TCP_Server_Info *server, 634 bool from_reconnect, bool disable_mchan); 635bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface); 636 637int 638cifs_ses_get_chan_index(struct cifs_ses *ses, 639 struct TCP_Server_Info *server); 640void 641cifs_chan_set_in_reconnect(struct cifs_ses *ses, 642 struct TCP_Server_Info *server); 643void 644cifs_chan_clear_in_reconnect(struct cifs_ses *ses, 645 struct TCP_Server_Info *server); 646void 647cifs_chan_set_need_reconnect(struct cifs_ses *ses, 648 struct TCP_Server_Info *server); 649void 650cifs_chan_clear_need_reconnect(struct cifs_ses *ses, 651 struct TCP_Server_Info *server); 652bool 653cifs_chan_needs_reconnect(struct cifs_ses *ses, 654 struct TCP_Server_Info *server); 655bool 656cifs_chan_is_iface_active(struct cifs_ses *ses, 657 struct TCP_Server_Info *server); 658void 659cifs_decrease_secondary_channels(struct cifs_ses *ses, bool disable_mchan); 660void 661cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server); 662int 663SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon, bool in_mount); 664 665void extract_unc_hostname(const char *unc, const char **h, size_t *len); 666int copy_path_name(char *dst, const char *src); 667int smb2_parse_query_directory(struct cifs_tcon *tcon, struct kvec *rsp_iov, 668 int resp_buftype, 669 struct cifs_search_info *srch_inf); 670 671struct super_block *cifs_get_dfs_tcon_super(struct cifs_tcon *tcon); 672void cifs_put_tcp_super(struct super_block *sb); 673int cifs_update_super_prepath(struct cifs_sb_info *cifs_sb, char *prefix); 674char *extract_hostname(const char *unc); 675char *extract_sharename(const char *unc); 676int parse_reparse_point(struct reparse_data_buffer *buf, 677 u32 plen, struct cifs_sb_info *cifs_sb, 678 const char *full_path, 679 struct cifs_open_info_data *data); 680int __cifs_sfu_make_node(unsigned int xid, struct inode *inode, 681 struct dentry *dentry, struct cifs_tcon *tcon, 682 const char *full_path, umode_t mode, dev_t dev, 683 const char *symname); 684int cifs_sfu_make_node(unsigned int xid, struct inode *inode, 685 struct dentry *dentry, struct cifs_tcon *tcon, 686 const char *full_path, umode_t mode, dev_t dev); 687umode_t wire_mode_to_posix(u32 wire, bool is_dir); 688 689#ifdef CONFIG_CIFS_DFS_UPCALL 690static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses, 691 const char *old_path, 692 const struct nls_table *nls_codepage, 693 struct dfs_info3_param *referral, int remap) 694{ 695 return dfs_cache_find(xid, ses, nls_codepage, remap, old_path, 696 referral, NULL); 697} 698 699int match_target_ip(struct TCP_Server_Info *server, 700 const char *host, size_t hostlen, 701 bool *result); 702int cifs_inval_name_dfs_link_error(const unsigned int xid, 703 struct cifs_tcon *tcon, 704 struct cifs_sb_info *cifs_sb, 705 const char *full_path, 706 bool *islink); 707#else 708static inline int cifs_inval_name_dfs_link_error(const unsigned int xid, 709 struct cifs_tcon *tcon, 710 struct cifs_sb_info *cifs_sb, 711 const char *full_path, 712 bool *islink) 713{ 714 *islink = false; 715 return 0; 716} 717#endif 718 719static inline int cifs_create_options(struct cifs_sb_info *cifs_sb, int options) 720{ 721 if (cifs_sb && (backup_cred(cifs_sb))) 722 return options | CREATE_OPEN_BACKUP_INTENT; 723 else 724 return options; 725} 726 727int cifs_wait_for_server_reconnect(struct TCP_Server_Info *server, bool retry); 728 729static inline void cifs_put_smb_ses(struct cifs_ses *ses) 730{ 731 __cifs_put_smb_ses(ses); 732} 733 734/* Get an active reference of @ses and its children. 735 * 736 * NOTE: make sure to call this function when incrementing reference count of 737 * @ses to ensure that any DFS root session attached to it (@ses->dfs_root_ses) 738 * will also get its reference count incremented. 739 * 740 * cifs_put_smb_ses() will put all references, so call it when you're done. 741 */ 742static inline void cifs_smb_ses_inc_refcount(struct cifs_ses *ses) 743{ 744 lockdep_assert_held(&cifs_tcp_ses_lock); 745 ses->ses_count++; 746} 747 748static inline bool dfs_src_pathname_equal(const char *s1, const char *s2) 749{ 750 if (strlen(s1) != strlen(s2)) 751 return false; 752 for (; *s1; s1++, s2++) { 753 if (*s1 == '/' || *s1 == '\\') { 754 if (*s2 != '/' && *s2 != '\\') 755 return false; 756 } else if (tolower(*s1) != tolower(*s2)) 757 return false; 758 } 759 return true; 760} 761 762static inline void smb_get_mid(struct mid_q_entry *mid) 763{ 764 refcount_inc(&mid->refcount); 765} 766 767static inline void release_mid(struct TCP_Server_Info *server, struct mid_q_entry *mid) 768{ 769 if (refcount_dec_and_test(&mid->refcount)) 770 __release_mid(server, mid); 771} 772 773static inline void cifs_free_open_info(struct cifs_open_info_data *data) 774{ 775 kfree(data->symlink_target); 776 free_rsp_buf(data->reparse.io.buftype, data->reparse.io.iov.iov_base); 777 memset(data, 0, sizeof(*data)); 778} 779 780static inline int smb_EIO(enum smb_eio_trace trace) 781{ 782 trace_smb3_eio(trace, 0, 0); 783 return -EIO; 784} 785 786static inline int smb_EIO1(enum smb_eio_trace trace, unsigned long info) 787{ 788 trace_smb3_eio(trace, info, 0); 789 return -EIO; 790} 791 792static inline int smb_EIO2(enum smb_eio_trace trace, unsigned long info, unsigned long info2) 793{ 794 trace_smb3_eio(trace, info, info2); 795 return -EIO; 796} 797 798static inline int cifs_get_num_sgs(const struct smb_rqst *rqst, 799 int num_rqst, 800 const u8 *sig) 801{ 802 unsigned int len, skip; 803 unsigned int nents = 0; 804 unsigned long addr; 805 size_t data_size; 806 int i, j; 807 808 /* 809 * The first rqst has a transform header where the first 20 bytes are 810 * not part of the encrypted blob. 811 */ 812 skip = 20; 813 814 /* Assumes the first rqst has a transform header as the first iov. 815 * I.e. 816 * rqst[0].rq_iov[0] is transform header 817 * rqst[0].rq_iov[1+] data to be encrypted/decrypted 818 * rqst[1+].rq_iov[0+] data to be encrypted/decrypted 819 */ 820 for (i = 0; i < num_rqst; i++) { 821 data_size = iov_iter_count(&rqst[i].rq_iter); 822 823 /* We really don't want a mixture of pinned and unpinned pages 824 * in the sglist. It's hard to keep track of which is what. 825 * Instead, we convert to a BVEC-type iterator higher up. 826 */ 827 if (data_size && 828 WARN_ON_ONCE(user_backed_iter(&rqst[i].rq_iter))) 829 return smb_EIO(smb_eio_trace_user_iter); 830 831 /* We also don't want to have any extra refs or pins to clean 832 * up in the sglist. 833 */ 834 if (data_size && 835 WARN_ON_ONCE(iov_iter_extract_will_pin(&rqst[i].rq_iter))) 836 return smb_EIO(smb_eio_trace_extract_will_pin); 837 838 for (j = 0; j < rqst[i].rq_nvec; j++) { 839 struct kvec *iov = &rqst[i].rq_iov[j]; 840 841 addr = (unsigned long)iov->iov_base + skip; 842 if (is_vmalloc_or_module_addr((void *)addr)) { 843 len = iov->iov_len - skip; 844 nents += DIV_ROUND_UP(offset_in_page(addr) + len, 845 PAGE_SIZE); 846 } else { 847 nents++; 848 } 849 skip = 0; 850 } 851 if (data_size) 852 nents += iov_iter_npages(&rqst[i].rq_iter, INT_MAX); 853 } 854 nents += DIV_ROUND_UP(offset_in_page(sig) + SMB2_SIGNATURE_SIZE, PAGE_SIZE); 855 return nents; 856} 857 858/* We can not use the normal sg_set_buf() as we will sometimes pass a 859 * stack object as buf. 860 */ 861static inline void cifs_sg_set_buf(struct sg_table *sgtable, 862 const void *buf, 863 unsigned int buflen) 864{ 865 unsigned long addr = (unsigned long)buf; 866 unsigned int off = offset_in_page(addr); 867 868 addr &= PAGE_MASK; 869 if (is_vmalloc_or_module_addr((void *)addr)) { 870 do { 871 unsigned int len = min_t(unsigned int, buflen, PAGE_SIZE - off); 872 873 sg_set_page(&sgtable->sgl[sgtable->nents++], 874 vmalloc_to_page((void *)addr), len, off); 875 876 off = 0; 877 addr += PAGE_SIZE; 878 buflen -= len; 879 } while (buflen); 880 } else { 881 sg_set_page(&sgtable->sgl[sgtable->nents++], 882 virt_to_page((void *)addr), buflen, off); 883 } 884} 885 886#endif /* _CIFSPROTO_H */