Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: LGPL-2.1 */
0002 /*
0003  *
0004  *   Copyright (c) International Business Machines  Corp., 2002,2008
0005  *   Author(s): Steve French (sfrench@us.ibm.com)
0006  *
0007  */
0008 #ifndef _CIFSPROTO_H
0009 #define _CIFSPROTO_H
0010 #include <linux/nls.h>
0011 #include "trace.h"
0012 #ifdef CONFIG_CIFS_DFS_UPCALL
0013 #include "dfs_cache.h"
0014 #endif
0015 
0016 struct statfs;
0017 struct smb_rqst;
0018 struct smb3_fs_context;
0019 
0020 /*
0021  *****************************************************************
0022  * All Prototypes
0023  *****************************************************************
0024  */
0025 
0026 extern struct smb_hdr *cifs_buf_get(void);
0027 extern void cifs_buf_release(void *);
0028 extern struct smb_hdr *cifs_small_buf_get(void);
0029 extern void cifs_small_buf_release(void *);
0030 extern void free_rsp_buf(int, void *);
0031 extern int smb_send(struct TCP_Server_Info *, struct smb_hdr *,
0032             unsigned int /* length */);
0033 extern unsigned int _get_xid(void);
0034 extern void _free_xid(unsigned int);
0035 #define get_xid()                           \
0036 ({                                  \
0037     unsigned int __xid = _get_xid();                \
0038     cifs_dbg(FYI, "VFS: in %s as Xid: %u with uid: %d\n",       \
0039          __func__, __xid,                   \
0040          from_kuid(&init_user_ns, current_fsuid()));        \
0041     trace_smb3_enter(__xid, __func__);              \
0042     __xid;                              \
0043 })
0044 
0045 #define free_xid(curr_xid)                      \
0046 do {                                    \
0047     _free_xid(curr_xid);                        \
0048     cifs_dbg(FYI, "VFS: leaving %s (xid = %u) rc = %d\n",       \
0049          __func__, curr_xid, (int)rc);              \
0050     if (rc)                             \
0051         trace_smb3_exit_err(curr_xid, __func__, (int)rc);   \
0052     else                                \
0053         trace_smb3_exit_done(curr_xid, __func__);       \
0054 } while (0)
0055 extern int init_cifs_idmap(void);
0056 extern void exit_cifs_idmap(void);
0057 extern int init_cifs_spnego(void);
0058 extern void exit_cifs_spnego(void);
0059 extern const char *build_path_from_dentry(struct dentry *, void *);
0060 extern char *build_path_from_dentry_optional_prefix(struct dentry *direntry,
0061                             void *page, bool prefix);
0062 static inline void *alloc_dentry_path(void)
0063 {
0064     return __getname();
0065 }
0066 
0067 static inline void free_dentry_path(void *page)
0068 {
0069     if (page)
0070         __putname(page);
0071 }
0072 
0073 extern char *cifs_build_path_to_root(struct smb3_fs_context *ctx,
0074                      struct cifs_sb_info *cifs_sb,
0075                      struct cifs_tcon *tcon,
0076                      int add_treename);
0077 extern char *build_wildcard_path_from_dentry(struct dentry *direntry);
0078 extern char *cifs_compose_mount_options(const char *sb_mountdata,
0079         const char *fullpath, const struct dfs_info3_param *ref,
0080         char **devname);
0081 extern void delete_mid(struct mid_q_entry *mid);
0082 extern void release_mid(struct mid_q_entry *mid);
0083 extern void cifs_wake_up_task(struct mid_q_entry *mid);
0084 extern int cifs_handle_standard(struct TCP_Server_Info *server,
0085                 struct mid_q_entry *mid);
0086 extern int smb3_parse_devname(const char *devname, struct smb3_fs_context *ctx);
0087 extern int smb3_parse_opt(const char *options, const char *key, char **val);
0088 extern bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs);
0089 extern int cifs_discard_remaining_data(struct TCP_Server_Info *server);
0090 extern int cifs_call_async(struct TCP_Server_Info *server,
0091             struct smb_rqst *rqst,
0092             mid_receive_t *receive, mid_callback_t *callback,
0093             mid_handle_t *handle, void *cbdata, const int flags,
0094             const struct cifs_credits *exist_credits);
0095 extern struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses);
0096 extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
0097               struct TCP_Server_Info *server,
0098               struct smb_rqst *rqst, int *resp_buf_type,
0099               const int flags, struct kvec *resp_iov);
0100 extern int compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
0101                   struct TCP_Server_Info *server,
0102                   const int flags, const int num_rqst,
0103                   struct smb_rqst *rqst, int *resp_buf_type,
0104                   struct kvec *resp_iov);
0105 extern int SendReceive(const unsigned int /* xid */ , struct cifs_ses *,
0106             struct smb_hdr * /* input */ ,
0107             struct smb_hdr * /* out */ ,
0108             int * /* bytes returned */ , const int);
0109 extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
0110                 char *in_buf, int flags);
0111 extern struct mid_q_entry *cifs_setup_request(struct cifs_ses *,
0112                 struct TCP_Server_Info *,
0113                 struct smb_rqst *);
0114 extern struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *,
0115                         struct smb_rqst *);
0116 extern int cifs_check_receive(struct mid_q_entry *mid,
0117             struct TCP_Server_Info *server, bool log_error);
0118 extern int cifs_wait_mtu_credits(struct TCP_Server_Info *server,
0119                  unsigned int size, unsigned int *num,
0120                  struct cifs_credits *credits);
0121 extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *,
0122             struct kvec *, int /* nvec to send */,
0123             int * /* type of buf returned */, const int flags,
0124             struct kvec * /* resp vec */);
0125 extern int SendReceiveBlockingLock(const unsigned int xid,
0126             struct cifs_tcon *ptcon,
0127             struct smb_hdr *in_buf ,
0128             struct smb_hdr *out_buf,
0129             int *bytes_returned);
0130 void
0131 cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server,
0132                       bool all_channels);
0133 void
0134 cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server,
0135                       bool mark_smb_session);
0136 extern int cifs_reconnect(struct TCP_Server_Info *server,
0137               bool mark_smb_session);
0138 extern int checkSMB(char *buf, unsigned int len, struct TCP_Server_Info *srvr);
0139 extern bool is_valid_oplock_break(char *, struct TCP_Server_Info *);
0140 extern bool backup_cred(struct cifs_sb_info *);
0141 extern bool is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof);
0142 extern void cifs_update_eof(struct cifsInodeInfo *cifsi, loff_t offset,
0143                 unsigned int bytes_written);
0144 extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *, int);
0145 extern int cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
0146                   int flags,
0147                   struct cifsFileInfo **ret_file);
0148 extern int cifs_get_writable_path(struct cifs_tcon *tcon, const char *name,
0149                   int flags,
0150                   struct cifsFileInfo **ret_file);
0151 extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *, bool);
0152 extern int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name,
0153                   struct cifsFileInfo **ret_file);
0154 extern unsigned int smbCalcSize(void *buf);
0155 extern int decode_negTokenInit(unsigned char *security_blob, int length,
0156             struct TCP_Server_Info *server);
0157 extern int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
0158 extern void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
0159 extern int map_smb_to_linux_error(char *buf, bool logErr);
0160 extern int map_and_check_smb_error(struct mid_q_entry *mid, bool logErr);
0161 extern void header_assemble(struct smb_hdr *, char /* command */ ,
0162                 const struct cifs_tcon *, int /* length of
0163                 fixed section (word count) in two byte units */);
0164 extern int small_smb_init_no_tc(const int smb_cmd, const int wct,
0165                 struct cifs_ses *ses,
0166                 void **request_buf);
0167 extern enum securityEnum select_sectype(struct TCP_Server_Info *server,
0168                 enum securityEnum requested);
0169 extern int CIFS_SessSetup(const unsigned int xid, struct cifs_ses *ses,
0170               struct TCP_Server_Info *server,
0171               const struct nls_table *nls_cp);
0172 extern struct timespec64 cifs_NTtimeToUnix(__le64 utc_nanoseconds_since_1601);
0173 extern u64 cifs_UnixTimeToNT(struct timespec64);
0174 extern struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time,
0175                       int offset);
0176 extern void cifs_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock);
0177 extern int cifs_get_writer(struct cifsInodeInfo *cinode);
0178 extern void cifs_put_writer(struct cifsInodeInfo *cinode);
0179 extern void cifs_done_oplock_break(struct cifsInodeInfo *cinode);
0180 extern int cifs_unlock_range(struct cifsFileInfo *cfile,
0181                  struct file_lock *flock, const unsigned int xid);
0182 extern int cifs_push_mandatory_locks(struct cifsFileInfo *cfile);
0183 
0184 extern void cifs_down_write(struct rw_semaphore *sem);
0185 extern struct cifsFileInfo *cifs_new_fileinfo(struct cifs_fid *fid,
0186                           struct file *file,
0187                           struct tcon_link *tlink,
0188                           __u32 oplock);
0189 extern int cifs_posix_open(const char *full_path, struct inode **inode,
0190                struct super_block *sb, int mode,
0191                unsigned int f_flags, __u32 *oplock, __u16 *netfid,
0192                unsigned int xid);
0193 void cifs_fill_uniqueid(struct super_block *sb, struct cifs_fattr *fattr);
0194 extern void cifs_unix_basic_to_fattr(struct cifs_fattr *fattr,
0195                      FILE_UNIX_BASIC_INFO *info,
0196                      struct cifs_sb_info *cifs_sb);
0197 extern void cifs_dir_info_to_fattr(struct cifs_fattr *, FILE_DIRECTORY_INFO *,
0198                     struct cifs_sb_info *);
0199 extern int cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr);
0200 extern struct inode *cifs_iget(struct super_block *sb,
0201                    struct cifs_fattr *fattr);
0202 
0203 extern int cifs_get_inode_info(struct inode **inode, const char *full_path,
0204                    FILE_ALL_INFO *data, struct super_block *sb,
0205                    int xid, const struct cifs_fid *fid);
0206 extern int smb311_posix_get_inode_info(struct inode **pinode, const char *search_path,
0207             struct super_block *sb, unsigned int xid);
0208 extern int cifs_get_inode_info_unix(struct inode **pinode,
0209             const unsigned char *search_path,
0210             struct super_block *sb, unsigned int xid);
0211 extern int cifs_set_file_info(struct inode *inode, struct iattr *attrs,
0212                   unsigned int xid, const char *full_path, __u32 dosattr);
0213 extern int cifs_rename_pending_delete(const char *full_path,
0214                       struct dentry *dentry,
0215                       const unsigned int xid);
0216 extern int sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid,
0217                 struct cifs_fattr *fattr, uint sidtype);
0218 extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
0219                   struct cifs_fattr *fattr, struct inode *inode,
0220                   bool get_mode_from_special_sid,
0221                   const char *path, const struct cifs_fid *pfid);
0222 extern int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
0223                     kuid_t uid, kgid_t gid);
0224 extern struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *, struct inode *,
0225                       const char *, u32 *, u32);
0226 extern struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *,
0227                 const struct cifs_fid *, u32 *, u32);
0228 extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *,
0229                 const char *, int);
0230 extern unsigned int setup_authusers_ACE(struct cifs_ace *pace);
0231 extern unsigned int setup_special_mode_ACE(struct cifs_ace *pace, __u64 nmode);
0232 extern unsigned int setup_special_user_owner_ACE(struct cifs_ace *pace);
0233 
0234 extern void dequeue_mid(struct mid_q_entry *mid, bool malformed);
0235 extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf,
0236                      unsigned int to_read);
0237 extern ssize_t cifs_discard_from_socket(struct TCP_Server_Info *server,
0238                     size_t to_read);
0239 extern int cifs_read_page_from_socket(struct TCP_Server_Info *server,
0240                     struct page *page,
0241                     unsigned int page_offset,
0242                     unsigned int to_read);
0243 extern int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb);
0244 extern int cifs_match_super(struct super_block *, void *);
0245 extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
0246 extern void cifs_umount(struct cifs_sb_info *);
0247 extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
0248 extern void cifs_reopen_persistent_handles(struct cifs_tcon *tcon);
0249 
0250 extern bool cifs_find_lock_conflict(struct cifsFileInfo *cfile, __u64 offset,
0251                     __u64 length, __u8 type, __u16 flags,
0252                     struct cifsLockInfo **conf_lock,
0253                     int rw_check);
0254 extern void cifs_add_pending_open(struct cifs_fid *fid,
0255                   struct tcon_link *tlink,
0256                   struct cifs_pending_open *open);
0257 extern void cifs_add_pending_open_locked(struct cifs_fid *fid,
0258                      struct tcon_link *tlink,
0259                      struct cifs_pending_open *open);
0260 extern void cifs_del_pending_open(struct cifs_pending_open *open);
0261 
0262 extern bool cifs_is_deferred_close(struct cifsFileInfo *cfile,
0263                 struct cifs_deferred_close **dclose);
0264 
0265 extern void cifs_add_deferred_close(struct cifsFileInfo *cfile,
0266                 struct cifs_deferred_close *dclose);
0267 
0268 extern void cifs_del_deferred_close(struct cifsFileInfo *cfile);
0269 
0270 extern void cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode);
0271 
0272 extern void cifs_close_all_deferred_files(struct cifs_tcon *cifs_tcon);
0273 
0274 extern void cifs_close_deferred_file_under_dentry(struct cifs_tcon *cifs_tcon,
0275                 const char *path);
0276 extern struct TCP_Server_Info *
0277 cifs_get_tcp_session(struct smb3_fs_context *ctx,
0278              struct TCP_Server_Info *primary_server);
0279 extern void cifs_put_tcp_session(struct TCP_Server_Info *server,
0280                  int from_reconnect);
0281 extern void cifs_put_tcon(struct cifs_tcon *tcon);
0282 
0283 #if IS_ENABLED(CONFIG_CIFS_DFS_UPCALL)
0284 extern void cifs_dfs_release_automount_timer(void);
0285 #else /* ! IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) */
0286 #define cifs_dfs_release_automount_timer()  do { } while (0)
0287 #endif /* ! IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) */
0288 
0289 void cifs_proc_init(void);
0290 void cifs_proc_clean(void);
0291 
0292 extern void cifs_move_llist(struct list_head *source, struct list_head *dest);
0293 extern void cifs_free_llist(struct list_head *llist);
0294 extern void cifs_del_lock_waiters(struct cifsLockInfo *lock);
0295 
0296 extern int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon,
0297                  const struct nls_table *nlsc);
0298 
0299 extern int cifs_negotiate_protocol(const unsigned int xid,
0300                    struct cifs_ses *ses,
0301                    struct TCP_Server_Info *server);
0302 extern int cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
0303                   struct TCP_Server_Info *server,
0304                   struct nls_table *nls_info);
0305 extern int cifs_enable_signing(struct TCP_Server_Info *server, bool mnt_sign_required);
0306 extern int CIFSSMBNegotiate(const unsigned int xid,
0307                 struct cifs_ses *ses,
0308                 struct TCP_Server_Info *server);
0309 
0310 extern int CIFSTCon(const unsigned int xid, struct cifs_ses *ses,
0311             const char *tree, struct cifs_tcon *tcon,
0312             const struct nls_table *);
0313 
0314 extern int CIFSFindFirst(const unsigned int xid, struct cifs_tcon *tcon,
0315         const char *searchName, struct cifs_sb_info *cifs_sb,
0316         __u16 *searchHandle, __u16 search_flags,
0317         struct cifs_search_info *psrch_inf,
0318         bool msearch);
0319 
0320 extern int CIFSFindNext(const unsigned int xid, struct cifs_tcon *tcon,
0321         __u16 searchHandle, __u16 search_flags,
0322         struct cifs_search_info *psrch_inf);
0323 
0324 extern int CIFSFindClose(const unsigned int xid, struct cifs_tcon *tcon,
0325             const __u16 search_handle);
0326 
0327 extern int CIFSSMBQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
0328             u16 netfid, FILE_ALL_INFO *pFindData);
0329 extern int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
0330                 const char *search_Name, FILE_ALL_INFO *data,
0331                 int legacy /* whether to use old info level */,
0332                 const struct nls_table *nls_codepage, int remap);
0333 extern int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon,
0334                    const char *search_name, FILE_ALL_INFO *data,
0335                    const struct nls_table *nls_codepage, int remap);
0336 
0337 extern int CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
0338             u16 netfid, FILE_UNIX_BASIC_INFO *pFindData);
0339 extern int CIFSSMBUnixQPathInfo(const unsigned int xid,
0340             struct cifs_tcon *tcon,
0341             const unsigned char *searchName,
0342             FILE_UNIX_BASIC_INFO *pFindData,
0343             const struct nls_table *nls_codepage, int remap);
0344 
0345 extern int CIFSGetDFSRefer(const unsigned int xid, struct cifs_ses *ses,
0346                const char *search_name,
0347                struct dfs_info3_param **target_nodes,
0348                unsigned int *num_of_nodes,
0349                const struct nls_table *nls_codepage, int remap);
0350 
0351 extern int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
0352                    unsigned int *num_of_nodes,
0353                    struct dfs_info3_param **target_nodes,
0354                    const struct nls_table *nls_codepage, int remap,
0355                    const char *searchName, bool is_unicode);
0356 extern void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
0357                  struct cifs_sb_info *cifs_sb,
0358                  struct smb3_fs_context *ctx);
0359 extern int CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
0360             struct kstatfs *FSData);
0361 extern int SMBOldQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
0362             struct kstatfs *FSData);
0363 extern int CIFSSMBSetFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon,
0364             __u64 cap);
0365 
0366 extern int CIFSSMBQFSAttributeInfo(const unsigned int xid,
0367             struct cifs_tcon *tcon);
0368 extern int CIFSSMBQFSDeviceInfo(const unsigned int xid, struct cifs_tcon *tcon);
0369 extern int CIFSSMBQFSUnixInfo(const unsigned int xid, struct cifs_tcon *tcon);
0370 extern int CIFSSMBQFSPosixInfo(const unsigned int xid, struct cifs_tcon *tcon,
0371             struct kstatfs *FSData);
0372 
0373 extern int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
0374             const char *fileName, const FILE_BASIC_INFO *data,
0375             const struct nls_table *nls_codepage,
0376             struct cifs_sb_info *cifs_sb);
0377 extern int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
0378             const FILE_BASIC_INFO *data, __u16 fid,
0379             __u32 pid_of_opener);
0380 extern int CIFSSMBSetFileDisposition(const unsigned int xid,
0381                      struct cifs_tcon *tcon,
0382                      bool delete_file, __u16 fid,
0383                      __u32 pid_of_opener);
0384 extern int CIFSSMBSetEOF(const unsigned int xid, struct cifs_tcon *tcon,
0385              const char *file_name, __u64 size,
0386              struct cifs_sb_info *cifs_sb, bool set_allocation);
0387 extern int CIFSSMBSetFileSize(const unsigned int xid, struct cifs_tcon *tcon,
0388                   struct cifsFileInfo *cfile, __u64 size,
0389                   bool set_allocation);
0390 
0391 struct cifs_unix_set_info_args {
0392     __u64   ctime;
0393     __u64   atime;
0394     __u64   mtime;
0395     __u64   mode;
0396     kuid_t  uid;
0397     kgid_t  gid;
0398     dev_t   device;
0399 };
0400 
0401 extern int CIFSSMBUnixSetFileInfo(const unsigned int xid,
0402                   struct cifs_tcon *tcon,
0403                   const struct cifs_unix_set_info_args *args,
0404                   u16 fid, u32 pid_of_opener);
0405 
0406 extern int CIFSSMBUnixSetPathInfo(const unsigned int xid,
0407                   struct cifs_tcon *tcon, const char *file_name,
0408                   const struct cifs_unix_set_info_args *args,
0409                   const struct nls_table *nls_codepage,
0410                   int remap);
0411 
0412 extern int CIFSSMBMkDir(const unsigned int xid, struct inode *inode,
0413             umode_t mode, struct cifs_tcon *tcon,
0414             const char *name, struct cifs_sb_info *cifs_sb);
0415 extern int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
0416             const char *name, struct cifs_sb_info *cifs_sb);
0417 extern int CIFSPOSIXDelFile(const unsigned int xid, struct cifs_tcon *tcon,
0418             const char *name, __u16 type,
0419             const struct nls_table *nls_codepage,
0420             int remap_special_chars);
0421 extern int CIFSSMBDelFile(const unsigned int xid, struct cifs_tcon *tcon,
0422               const char *name, struct cifs_sb_info *cifs_sb);
0423 extern int CIFSSMBRename(const unsigned int xid, struct cifs_tcon *tcon,
0424              const char *from_name, const char *to_name,
0425              struct cifs_sb_info *cifs_sb);
0426 extern int CIFSSMBRenameOpenFile(const unsigned int xid, struct cifs_tcon *tcon,
0427                  int netfid, const char *target_name,
0428                  const struct nls_table *nls_codepage,
0429                  int remap_special_chars);
0430 extern int CIFSCreateHardLink(const unsigned int xid, struct cifs_tcon *tcon,
0431                   const char *from_name, const char *to_name,
0432                   struct cifs_sb_info *cifs_sb);
0433 extern int CIFSUnixCreateHardLink(const unsigned int xid,
0434             struct cifs_tcon *tcon,
0435             const char *fromName, const char *toName,
0436             const struct nls_table *nls_codepage,
0437             int remap_special_chars);
0438 extern int CIFSUnixCreateSymLink(const unsigned int xid,
0439             struct cifs_tcon *tcon,
0440             const char *fromName, const char *toName,
0441             const struct nls_table *nls_codepage, int remap);
0442 extern int CIFSSMBUnixQuerySymLink(const unsigned int xid,
0443             struct cifs_tcon *tcon,
0444             const unsigned char *searchName, char **syminfo,
0445             const struct nls_table *nls_codepage, int remap);
0446 extern int CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon,
0447                    __u16 fid, char **symlinkinfo,
0448                    const struct nls_table *nls_codepage);
0449 extern int CIFSSMB_set_compression(const unsigned int xid,
0450                    struct cifs_tcon *tcon, __u16 fid);
0451 extern int CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms,
0452              int *oplock, FILE_ALL_INFO *buf);
0453 extern int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon,
0454             const char *fileName, const int disposition,
0455             const int access_flags, const int omode,
0456             __u16 *netfid, int *pOplock, FILE_ALL_INFO *,
0457             const struct nls_table *nls_codepage, int remap);
0458 extern int CIFSPOSIXCreate(const unsigned int xid, struct cifs_tcon *tcon,
0459             u32 posix_flags, __u64 mode, __u16 *netfid,
0460             FILE_UNIX_BASIC_INFO *pRetData,
0461             __u32 *pOplock, const char *name,
0462             const struct nls_table *nls_codepage, int remap);
0463 extern int CIFSSMBClose(const unsigned int xid, struct cifs_tcon *tcon,
0464             const int smb_file_id);
0465 
0466 extern int CIFSSMBFlush(const unsigned int xid, struct cifs_tcon *tcon,
0467             const int smb_file_id);
0468 
0469 extern int CIFSSMBRead(const unsigned int xid, struct cifs_io_parms *io_parms,
0470             unsigned int *nbytes, char **buf,
0471             int *return_buf_type);
0472 extern int CIFSSMBWrite(const unsigned int xid, struct cifs_io_parms *io_parms,
0473             unsigned int *nbytes, const char *buf);
0474 extern int CIFSSMBWrite2(const unsigned int xid, struct cifs_io_parms *io_parms,
0475             unsigned int *nbytes, struct kvec *iov, const int nvec);
0476 extern int CIFSGetSrvInodeNumber(const unsigned int xid, struct cifs_tcon *tcon,
0477                  const char *search_name, __u64 *inode_number,
0478                  const struct nls_table *nls_codepage,
0479                  int remap);
0480 
0481 extern int cifs_lockv(const unsigned int xid, struct cifs_tcon *tcon,
0482               const __u16 netfid, const __u8 lock_type,
0483               const __u32 num_unlock, const __u32 num_lock,
0484               LOCKING_ANDX_RANGE *buf);
0485 extern int CIFSSMBLock(const unsigned int xid, struct cifs_tcon *tcon,
0486             const __u16 netfid, const __u32 netpid, const __u64 len,
0487             const __u64 offset, const __u32 numUnlock,
0488             const __u32 numLock, const __u8 lockType,
0489             const bool waitFlag, const __u8 oplock_level);
0490 extern int CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon,
0491             const __u16 smb_file_id, const __u32 netpid,
0492             const loff_t start_offset, const __u64 len,
0493             struct file_lock *, const __u16 lock_type,
0494             const bool waitFlag);
0495 extern int CIFSSMBTDis(const unsigned int xid, struct cifs_tcon *tcon);
0496 extern int CIFSSMBEcho(struct TCP_Server_Info *server);
0497 extern int CIFSSMBLogoff(const unsigned int xid, struct cifs_ses *ses);
0498 
0499 extern struct cifs_ses *sesInfoAlloc(void);
0500 extern void sesInfoFree(struct cifs_ses *);
0501 extern struct cifs_tcon *tconInfoAlloc(void);
0502 extern void tconInfoFree(struct cifs_tcon *);
0503 
0504 extern int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server,
0505            __u32 *pexpected_response_sequence_number);
0506 extern int cifs_sign_smbv(struct kvec *iov, int n_vec, struct TCP_Server_Info *,
0507               __u32 *);
0508 extern int cifs_sign_smb(struct smb_hdr *, struct TCP_Server_Info *, __u32 *);
0509 extern int cifs_verify_signature(struct smb_rqst *rqst,
0510                  struct TCP_Server_Info *server,
0511                 __u32 expected_sequence_number);
0512 extern int setup_ntlmv2_rsp(struct cifs_ses *, const struct nls_table *);
0513 extern void cifs_crypto_secmech_release(struct TCP_Server_Info *server);
0514 extern int calc_seckey(struct cifs_ses *);
0515 extern int generate_smb30signingkey(struct cifs_ses *ses,
0516                     struct TCP_Server_Info *server);
0517 extern int generate_smb311signingkey(struct cifs_ses *ses,
0518                      struct TCP_Server_Info *server);
0519 
0520 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY
0521 extern int CIFSSMBCopy(unsigned int xid,
0522             struct cifs_tcon *source_tcon,
0523             const char *fromName,
0524             const __u16 target_tid,
0525             const char *toName, const int flags,
0526             const struct nls_table *nls_codepage,
0527             int remap_special_chars);
0528 extern ssize_t CIFSSMBQAllEAs(const unsigned int xid, struct cifs_tcon *tcon,
0529             const unsigned char *searchName,
0530             const unsigned char *ea_name, char *EAData,
0531             size_t bufsize, struct cifs_sb_info *cifs_sb);
0532 extern int CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
0533         const char *fileName, const char *ea_name,
0534         const void *ea_value, const __u16 ea_value_len,
0535         const struct nls_table *nls_codepage,
0536         struct cifs_sb_info *cifs_sb);
0537 extern int CIFSSMBGetCIFSACL(const unsigned int xid, struct cifs_tcon *tcon,
0538             __u16 fid, struct cifs_ntsd **acl_inf, __u32 *buflen);
0539 extern int CIFSSMBSetCIFSACL(const unsigned int, struct cifs_tcon *, __u16,
0540             struct cifs_ntsd *, __u32, int);
0541 extern int CIFSSMBGetPosixACL(const unsigned int xid, struct cifs_tcon *tcon,
0542         const unsigned char *searchName,
0543         char *acl_inf, const int buflen, const int acl_type,
0544         const struct nls_table *nls_codepage, int remap_special_chars);
0545 extern int CIFSSMBSetPosixACL(const unsigned int xid, struct cifs_tcon *tcon,
0546         const unsigned char *fileName,
0547         const char *local_acl, const int buflen, const int acl_type,
0548         const struct nls_table *nls_codepage, int remap_special_chars);
0549 extern int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon,
0550             const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
0551 #endif /* CIFS_ALLOW_INSECURE_LEGACY */
0552 extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb);
0553 extern bool couldbe_mf_symlink(const struct cifs_fattr *fattr);
0554 extern int check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
0555                   struct cifs_sb_info *cifs_sb,
0556                   struct cifs_fattr *fattr,
0557                   const unsigned char *path);
0558 extern int E_md4hash(const unsigned char *passwd, unsigned char *p16,
0559             const struct nls_table *codepage);
0560 
0561 extern int
0562 cifs_setup_volume_info(struct smb3_fs_context *ctx, const char *mntopts, const char *devname);
0563 
0564 extern struct TCP_Server_Info *
0565 cifs_find_tcp_session(struct smb3_fs_context *ctx);
0566 
0567 extern void cifs_put_smb_ses(struct cifs_ses *ses);
0568 
0569 extern struct cifs_ses *
0570 cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx);
0571 
0572 void cifs_readdata_release(struct kref *refcount);
0573 int cifs_async_readv(struct cifs_readdata *rdata);
0574 int cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid);
0575 
0576 int cifs_async_writev(struct cifs_writedata *wdata,
0577               void (*release)(struct kref *kref));
0578 void cifs_writev_complete(struct work_struct *work);
0579 struct cifs_writedata *cifs_writedata_alloc(unsigned int nr_pages,
0580                         work_func_t complete);
0581 struct cifs_writedata *cifs_writedata_direct_alloc(struct page **pages,
0582                         work_func_t complete);
0583 void cifs_writedata_release(struct kref *refcount);
0584 int cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
0585               struct cifs_sb_info *cifs_sb,
0586               const unsigned char *path, char *pbuf,
0587               unsigned int *pbytes_read);
0588 int cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
0589                struct cifs_sb_info *cifs_sb,
0590                const unsigned char *path, char *pbuf,
0591                unsigned int *pbytes_written);
0592 int __cifs_calc_signature(struct smb_rqst *rqst,
0593             struct TCP_Server_Info *server, char *signature,
0594             struct shash_desc *shash);
0595 enum securityEnum cifs_select_sectype(struct TCP_Server_Info *,
0596                     enum securityEnum);
0597 struct cifs_aio_ctx *cifs_aio_ctx_alloc(void);
0598 void cifs_aio_ctx_release(struct kref *refcount);
0599 int setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw);
0600 
0601 int cifs_alloc_hash(const char *name, struct crypto_shash **shash,
0602             struct sdesc **sdesc);
0603 void cifs_free_hash(struct crypto_shash **shash, struct sdesc **sdesc);
0604 
0605 extern void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page,
0606                 unsigned int *len, unsigned int *offset);
0607 struct cifs_chan *
0608 cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server);
0609 int cifs_try_adding_channels(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses);
0610 bool is_server_using_iface(struct TCP_Server_Info *server,
0611                struct cifs_server_iface *iface);
0612 bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface);
0613 void cifs_ses_mark_for_reconnect(struct cifs_ses *ses);
0614 
0615 unsigned int
0616 cifs_ses_get_chan_index(struct cifs_ses *ses,
0617             struct TCP_Server_Info *server);
0618 void
0619 cifs_chan_set_in_reconnect(struct cifs_ses *ses,
0620                  struct TCP_Server_Info *server);
0621 void
0622 cifs_chan_clear_in_reconnect(struct cifs_ses *ses,
0623                    struct TCP_Server_Info *server);
0624 bool
0625 cifs_chan_in_reconnect(struct cifs_ses *ses,
0626               struct TCP_Server_Info *server);
0627 void
0628 cifs_chan_set_need_reconnect(struct cifs_ses *ses,
0629                  struct TCP_Server_Info *server);
0630 void
0631 cifs_chan_clear_need_reconnect(struct cifs_ses *ses,
0632                    struct TCP_Server_Info *server);
0633 bool
0634 cifs_chan_needs_reconnect(struct cifs_ses *ses,
0635               struct TCP_Server_Info *server);
0636 bool
0637 cifs_chan_is_iface_active(struct cifs_ses *ses,
0638               struct TCP_Server_Info *server);
0639 int
0640 cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server);
0641 int
0642 SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon);
0643 
0644 void extract_unc_hostname(const char *unc, const char **h, size_t *len);
0645 int copy_path_name(char *dst, const char *src);
0646 int smb2_parse_query_directory(struct cifs_tcon *tcon, struct kvec *rsp_iov,
0647                    int resp_buftype,
0648                    struct cifs_search_info *srch_inf);
0649 
0650 struct super_block *cifs_get_tcp_super(struct TCP_Server_Info *server);
0651 void cifs_put_tcp_super(struct super_block *sb);
0652 int cifs_update_super_prepath(struct cifs_sb_info *cifs_sb, char *prefix);
0653 char *extract_hostname(const char *unc);
0654 char *extract_sharename(const char *unc);
0655 
0656 #ifdef CONFIG_CIFS_DFS_UPCALL
0657 static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses,
0658                    const char *old_path,
0659                    const struct nls_table *nls_codepage,
0660                    struct dfs_info3_param *referral, int remap)
0661 {
0662     return dfs_cache_find(xid, ses, nls_codepage, remap, old_path,
0663                   referral, NULL);
0664 }
0665 
0666 int match_target_ip(struct TCP_Server_Info *server,
0667             const char *share, size_t share_len,
0668             bool *result);
0669 
0670 int cifs_dfs_query_info_nonascii_quirk(const unsigned int xid,
0671                        struct cifs_tcon *tcon,
0672                        struct cifs_sb_info *cifs_sb,
0673                        const char *dfs_link_path);
0674 #endif
0675 
0676 static inline int cifs_create_options(struct cifs_sb_info *cifs_sb, int options)
0677 {
0678     if (cifs_sb && (backup_cred(cifs_sb)))
0679         return options | CREATE_OPEN_BACKUP_INTENT;
0680     else
0681         return options;
0682 }
0683 
0684 struct super_block *cifs_get_tcon_super(struct cifs_tcon *tcon);
0685 void cifs_put_tcon_super(struct super_block *sb);
0686 
0687 #endif          /* _CIFSPROTO_H */