| .. | .. |
|---|
| 22 | 22 | #define _CIFSPROTO_H |
|---|
| 23 | 23 | #include <linux/nls.h> |
|---|
| 24 | 24 | #include "trace.h" |
|---|
| 25 | +#ifdef CONFIG_CIFS_DFS_UPCALL |
|---|
| 26 | +#include "dfs_cache.h" |
|---|
| 27 | +#endif |
|---|
| 25 | 28 | |
|---|
| 26 | 29 | struct statfs; |
|---|
| 27 | 30 | struct smb_vol; |
|---|
| .. | .. |
|---|
| 42 | 45 | unsigned int /* length */); |
|---|
| 43 | 46 | extern unsigned int _get_xid(void); |
|---|
| 44 | 47 | extern void _free_xid(unsigned int); |
|---|
| 45 | | -#define get_xid() \ |
|---|
| 46 | | -({ \ |
|---|
| 48 | +#define get_xid() \ |
|---|
| 49 | +({ \ |
|---|
| 47 | 50 | unsigned int __xid = _get_xid(); \ |
|---|
| 48 | | - cifs_dbg(FYI, "CIFS VFS: in %s as Xid: %u with uid: %d\n", \ |
|---|
| 51 | + cifs_dbg(FYI, "VFS: in %s as Xid: %u with uid: %d\n", \ |
|---|
| 49 | 52 | __func__, __xid, \ |
|---|
| 50 | 53 | from_kuid(&init_user_ns, current_fsuid())); \ |
|---|
| 51 | | - trace_smb3_enter(__xid, __func__); \ |
|---|
| 52 | | - __xid; \ |
|---|
| 54 | + trace_smb3_enter(__xid, __func__); \ |
|---|
| 55 | + __xid; \ |
|---|
| 53 | 56 | }) |
|---|
| 54 | 57 | |
|---|
| 55 | | -#define free_xid(curr_xid) \ |
|---|
| 56 | | -do { \ |
|---|
| 57 | | - _free_xid(curr_xid); \ |
|---|
| 58 | | - cifs_dbg(FYI, "CIFS VFS: leaving %s (xid = %u) rc = %d\n", \ |
|---|
| 59 | | - __func__, curr_xid, (int)rc); \ |
|---|
| 60 | | - if (rc) \ |
|---|
| 58 | +#define free_xid(curr_xid) \ |
|---|
| 59 | +do { \ |
|---|
| 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) \ |
|---|
| 61 | 64 | trace_smb3_exit_err(curr_xid, __func__, (int)rc); \ |
|---|
| 62 | | - else \ |
|---|
| 63 | | - trace_smb3_exit_done(curr_xid, __func__); \ |
|---|
| 65 | + else \ |
|---|
| 66 | + trace_smb3_exit_done(curr_xid, __func__); \ |
|---|
| 64 | 67 | } while (0) |
|---|
| 65 | 68 | extern int init_cifs_idmap(void); |
|---|
| 66 | 69 | extern void exit_cifs_idmap(void); |
|---|
| .. | .. |
|---|
| 86 | 89 | extern void cifs_wake_up_task(struct mid_q_entry *mid); |
|---|
| 87 | 90 | extern int cifs_handle_standard(struct TCP_Server_Info *server, |
|---|
| 88 | 91 | struct mid_q_entry *mid); |
|---|
| 92 | +extern bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs); |
|---|
| 89 | 93 | extern int cifs_discard_remaining_data(struct TCP_Server_Info *server); |
|---|
| 90 | 94 | extern int cifs_call_async(struct TCP_Server_Info *server, |
|---|
| 91 | 95 | struct smb_rqst *rqst, |
|---|
| 92 | 96 | mid_receive_t *receive, mid_callback_t *callback, |
|---|
| 93 | | - mid_handle_t *handle, void *cbdata, const int flags); |
|---|
| 97 | + mid_handle_t *handle, void *cbdata, const int flags, |
|---|
| 98 | + const struct cifs_credits *exist_credits); |
|---|
| 99 | +extern struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses); |
|---|
| 94 | 100 | extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses, |
|---|
| 101 | + struct TCP_Server_Info *server, |
|---|
| 95 | 102 | struct smb_rqst *rqst, int *resp_buf_type, |
|---|
| 96 | 103 | const int flags, struct kvec *resp_iov); |
|---|
| 97 | 104 | extern int compound_send_recv(const unsigned int xid, struct cifs_ses *ses, |
|---|
| 105 | + struct TCP_Server_Info *server, |
|---|
| 98 | 106 | const int flags, const int num_rqst, |
|---|
| 99 | 107 | struct smb_rqst *rqst, int *resp_buf_type, |
|---|
| 100 | 108 | struct kvec *resp_iov); |
|---|
| .. | .. |
|---|
| 105 | 113 | extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses, |
|---|
| 106 | 114 | char *in_buf, int flags); |
|---|
| 107 | 115 | extern struct mid_q_entry *cifs_setup_request(struct cifs_ses *, |
|---|
| 116 | + struct TCP_Server_Info *, |
|---|
| 108 | 117 | struct smb_rqst *); |
|---|
| 109 | 118 | extern struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *, |
|---|
| 110 | 119 | struct smb_rqst *); |
|---|
| .. | .. |
|---|
| 112 | 121 | struct TCP_Server_Info *server, bool log_error); |
|---|
| 113 | 122 | extern int cifs_wait_mtu_credits(struct TCP_Server_Info *server, |
|---|
| 114 | 123 | unsigned int size, unsigned int *num, |
|---|
| 115 | | - unsigned int *credits); |
|---|
| 124 | + struct cifs_credits *credits); |
|---|
| 116 | 125 | extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *, |
|---|
| 117 | 126 | struct kvec *, int /* nvec to send */, |
|---|
| 118 | 127 | int * /* type of buf returned */, const int flags, |
|---|
| .. | .. |
|---|
| 129 | 138 | extern bool is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof); |
|---|
| 130 | 139 | extern void cifs_update_eof(struct cifsInodeInfo *cifsi, loff_t offset, |
|---|
| 131 | 140 | unsigned int bytes_written); |
|---|
| 132 | | -extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *, bool); |
|---|
| 141 | +extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *, int); |
|---|
| 142 | +extern int cifs_get_writable_file(struct cifsInodeInfo *cifs_inode, |
|---|
| 143 | + int flags, |
|---|
| 144 | + struct cifsFileInfo **ret_file); |
|---|
| 145 | +extern int cifs_get_writable_path(struct cifs_tcon *tcon, const char *name, |
|---|
| 146 | + int flags, |
|---|
| 147 | + struct cifsFileInfo **ret_file); |
|---|
| 133 | 148 | extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *, bool); |
|---|
| 149 | +extern int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name, |
|---|
| 150 | + struct cifsFileInfo **ret_file); |
|---|
| 134 | 151 | extern unsigned int smbCalcSize(void *buf, struct TCP_Server_Info *server); |
|---|
| 135 | 152 | extern int decode_negTokenInit(unsigned char *security_blob, int length, |
|---|
| 136 | 153 | struct TCP_Server_Info *server); |
|---|
| 137 | 154 | extern int cifs_convert_address(struct sockaddr *dst, const char *src, int len); |
|---|
| 138 | 155 | extern void cifs_set_port(struct sockaddr *addr, const unsigned short int port); |
|---|
| 139 | 156 | extern int map_smb_to_linux_error(char *buf, bool logErr); |
|---|
| 157 | +extern int map_and_check_smb_error(struct mid_q_entry *mid, bool logErr); |
|---|
| 140 | 158 | extern void header_assemble(struct smb_hdr *, char /* command */ , |
|---|
| 141 | 159 | const struct cifs_tcon *, int /* length of |
|---|
| 142 | 160 | fixed section (word count) in two byte units */); |
|---|
| .. | .. |
|---|
| 181 | 199 | extern int cifs_get_inode_info(struct inode **inode, const char *full_path, |
|---|
| 182 | 200 | FILE_ALL_INFO *data, struct super_block *sb, |
|---|
| 183 | 201 | int xid, const struct cifs_fid *fid); |
|---|
| 202 | +extern int smb311_posix_get_inode_info(struct inode **pinode, const char *search_path, |
|---|
| 203 | + struct super_block *sb, unsigned int xid); |
|---|
| 184 | 204 | extern int cifs_get_inode_info_unix(struct inode **pinode, |
|---|
| 185 | 205 | const unsigned char *search_path, |
|---|
| 186 | 206 | struct super_block *sb, unsigned int xid); |
|---|
| .. | .. |
|---|
| 189 | 209 | extern int cifs_rename_pending_delete(const char *full_path, |
|---|
| 190 | 210 | struct dentry *dentry, |
|---|
| 191 | 211 | const unsigned int xid); |
|---|
| 212 | +extern int sid_to_id(struct cifs_sb_info *cifs_sb, struct cifs_sid *psid, |
|---|
| 213 | + struct cifs_fattr *fattr, uint sidtype); |
|---|
| 192 | 214 | extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, |
|---|
| 193 | 215 | struct cifs_fattr *fattr, struct inode *inode, |
|---|
| 216 | + bool get_mode_from_special_sid, |
|---|
| 194 | 217 | const char *path, const struct cifs_fid *pfid); |
|---|
| 195 | 218 | extern int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64, |
|---|
| 196 | 219 | kuid_t, kgid_t); |
|---|
| .. | .. |
|---|
| 200 | 223 | const struct cifs_fid *, u32 *); |
|---|
| 201 | 224 | extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *, |
|---|
| 202 | 225 | const char *, int); |
|---|
| 226 | +extern unsigned int setup_authusers_ACE(struct cifs_ace *pace); |
|---|
| 227 | +extern unsigned int setup_special_mode_ACE(struct cifs_ace *pace, __u64 nmode); |
|---|
| 228 | +extern unsigned int setup_special_user_owner_ACE(struct cifs_ace *pace); |
|---|
| 203 | 229 | |
|---|
| 204 | 230 | extern void dequeue_mid(struct mid_q_entry *mid, bool malformed); |
|---|
| 205 | 231 | extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf, |
|---|
| 206 | 232 | unsigned int to_read); |
|---|
| 233 | +extern ssize_t cifs_discard_from_socket(struct TCP_Server_Info *server, |
|---|
| 234 | + size_t to_read); |
|---|
| 207 | 235 | extern int cifs_read_page_from_socket(struct TCP_Server_Info *server, |
|---|
| 208 | 236 | struct page *page, |
|---|
| 209 | 237 | unsigned int page_offset, |
|---|
| .. | .. |
|---|
| 214 | 242 | extern void cifs_cleanup_volume_info(struct smb_vol *pvolume_info); |
|---|
| 215 | 243 | extern struct smb_vol *cifs_get_volume_info(char *mount_data, |
|---|
| 216 | 244 | const char *devname, bool is_smb3); |
|---|
| 217 | | -extern int cifs_mount(struct cifs_sb_info *, struct smb_vol *); |
|---|
| 245 | +extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *vol); |
|---|
| 218 | 246 | extern void cifs_umount(struct cifs_sb_info *); |
|---|
| 219 | 247 | extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon); |
|---|
| 220 | 248 | extern void cifs_reopen_persistent_handles(struct cifs_tcon *tcon); |
|---|
| 221 | 249 | |
|---|
| 222 | 250 | extern bool cifs_find_lock_conflict(struct cifsFileInfo *cfile, __u64 offset, |
|---|
| 223 | | - __u64 length, __u8 type, |
|---|
| 251 | + __u64 length, __u8 type, __u16 flags, |
|---|
| 224 | 252 | struct cifsLockInfo **conf_lock, |
|---|
| 225 | 253 | int rw_check); |
|---|
| 226 | 254 | extern void cifs_add_pending_open(struct cifs_fid *fid, |
|---|
| .. | .. |
|---|
| 230 | 258 | struct tcon_link *tlink, |
|---|
| 231 | 259 | struct cifs_pending_open *open); |
|---|
| 232 | 260 | extern void cifs_del_pending_open(struct cifs_pending_open *open); |
|---|
| 261 | +extern struct TCP_Server_Info *cifs_get_tcp_session(struct smb_vol *vol); |
|---|
| 233 | 262 | extern void cifs_put_tcp_session(struct TCP_Server_Info *server, |
|---|
| 234 | 263 | int from_reconnect); |
|---|
| 235 | 264 | extern void cifs_put_tcon(struct cifs_tcon *tcon); |
|---|
| .. | .. |
|---|
| 246 | 275 | extern void cifs_move_llist(struct list_head *source, struct list_head *dest); |
|---|
| 247 | 276 | extern void cifs_free_llist(struct list_head *llist); |
|---|
| 248 | 277 | extern void cifs_del_lock_waiters(struct cifsLockInfo *lock); |
|---|
| 278 | + |
|---|
| 279 | +extern int cifs_tree_connect(const unsigned int xid, struct cifs_tcon *tcon, |
|---|
| 280 | + const struct nls_table *nlsc); |
|---|
| 249 | 281 | |
|---|
| 250 | 282 | extern int cifs_negotiate_protocol(const unsigned int xid, |
|---|
| 251 | 283 | struct cifs_ses *ses); |
|---|
| .. | .. |
|---|
| 295 | 327 | unsigned int *num_of_nodes, |
|---|
| 296 | 328 | const struct nls_table *nls_codepage, int remap); |
|---|
| 297 | 329 | |
|---|
| 298 | | -extern int get_dfs_path(const unsigned int xid, struct cifs_ses *ses, |
|---|
| 299 | | - const char *old_path, |
|---|
| 300 | | - const struct nls_table *nls_codepage, |
|---|
| 301 | | - unsigned int *num_referrals, |
|---|
| 302 | | - struct dfs_info3_param **referrals, int remap); |
|---|
| 303 | 330 | extern int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size, |
|---|
| 304 | 331 | unsigned int *num_of_nodes, |
|---|
| 305 | 332 | struct dfs_info3_param **target_nodes, |
|---|
| .. | .. |
|---|
| 325 | 352 | extern int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon, |
|---|
| 326 | 353 | const char *fileName, const FILE_BASIC_INFO *data, |
|---|
| 327 | 354 | const struct nls_table *nls_codepage, |
|---|
| 328 | | - int remap_special_chars); |
|---|
| 355 | + struct cifs_sb_info *cifs_sb); |
|---|
| 329 | 356 | extern int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon, |
|---|
| 330 | 357 | const FILE_BASIC_INFO *data, __u16 fid, |
|---|
| 331 | 358 | __u32 pid_of_opener); |
|---|
| .. | .. |
|---|
| 366 | 393 | const struct nls_table *nls_codepage, |
|---|
| 367 | 394 | int remap); |
|---|
| 368 | 395 | |
|---|
| 369 | | -extern int CIFSSMBMkDir(const unsigned int xid, struct cifs_tcon *tcon, |
|---|
| 396 | +extern int CIFSSMBMkDir(const unsigned int xid, struct inode *inode, |
|---|
| 397 | + umode_t mode, struct cifs_tcon *tcon, |
|---|
| 370 | 398 | const char *name, struct cifs_sb_info *cifs_sb); |
|---|
| 371 | 399 | extern int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon, |
|---|
| 372 | 400 | const char *name, struct cifs_sb_info *cifs_sb); |
|---|
| .. | .. |
|---|
| 526 | 554 | extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8, |
|---|
| 527 | 555 | unsigned char *p24); |
|---|
| 528 | 556 | |
|---|
| 557 | +extern int |
|---|
| 558 | +cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data, |
|---|
| 559 | + const char *devname, bool is_smb3); |
|---|
| 560 | +extern void |
|---|
| 561 | +cifs_cleanup_volume_info_contents(struct smb_vol *volume_info); |
|---|
| 562 | + |
|---|
| 563 | +extern struct TCP_Server_Info * |
|---|
| 564 | +cifs_find_tcp_session(struct smb_vol *vol); |
|---|
| 565 | + |
|---|
| 566 | +extern void cifs_put_smb_ses(struct cifs_ses *ses); |
|---|
| 567 | + |
|---|
| 568 | +extern struct cifs_ses * |
|---|
| 569 | +cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info); |
|---|
| 570 | + |
|---|
| 529 | 571 | void cifs_readdata_release(struct kref *refcount); |
|---|
| 530 | 572 | int cifs_async_readv(struct cifs_readdata *rdata); |
|---|
| 531 | 573 | int cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid); |
|---|
| .. | .. |
|---|
| 560 | 602 | struct sdesc **sdesc); |
|---|
| 561 | 603 | void cifs_free_hash(struct crypto_shash **shash, struct sdesc **sdesc); |
|---|
| 562 | 604 | |
|---|
| 563 | | -extern void rqst_page_get_length(struct smb_rqst *rqst, unsigned int page, |
|---|
| 564 | | - unsigned int *len, unsigned int *offset); |
|---|
| 605 | +void rqst_page_get_length(const struct smb_rqst *rqst, unsigned int page, |
|---|
| 606 | + unsigned int *len, unsigned int *offset); |
|---|
| 607 | +struct cifs_chan * |
|---|
| 608 | +cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server); |
|---|
| 609 | +int cifs_try_adding_channels(struct cifs_ses *ses); |
|---|
| 610 | +int cifs_ses_add_channel(struct cifs_ses *ses, |
|---|
| 611 | + struct cifs_server_iface *iface); |
|---|
| 612 | +bool is_server_using_iface(struct TCP_Server_Info *server, |
|---|
| 613 | + struct cifs_server_iface *iface); |
|---|
| 614 | +bool is_ses_using_iface(struct cifs_ses *ses, struct cifs_server_iface *iface); |
|---|
| 615 | + |
|---|
| 616 | +void extract_unc_hostname(const char *unc, const char **h, size_t *len); |
|---|
| 617 | +int copy_path_name(char *dst, const char *src); |
|---|
| 618 | +int smb2_parse_query_directory(struct cifs_tcon *tcon, struct kvec *rsp_iov, |
|---|
| 619 | + int resp_buftype, |
|---|
| 620 | + struct cifs_search_info *srch_inf); |
|---|
| 621 | + |
|---|
| 622 | +struct super_block *cifs_get_tcp_super(struct TCP_Server_Info *server); |
|---|
| 623 | +void cifs_put_tcp_super(struct super_block *sb); |
|---|
| 624 | +int update_super_prepath(struct cifs_tcon *tcon, char *prefix); |
|---|
| 625 | + |
|---|
| 626 | +#ifdef CONFIG_CIFS_DFS_UPCALL |
|---|
| 627 | +static inline int get_dfs_path(const unsigned int xid, struct cifs_ses *ses, |
|---|
| 628 | + const char *old_path, |
|---|
| 629 | + const struct nls_table *nls_codepage, |
|---|
| 630 | + struct dfs_info3_param *referral, int remap) |
|---|
| 631 | +{ |
|---|
| 632 | + return dfs_cache_find(xid, ses, nls_codepage, remap, old_path, |
|---|
| 633 | + referral, NULL); |
|---|
| 634 | +} |
|---|
| 635 | + |
|---|
| 636 | +int match_target_ip(struct TCP_Server_Info *server, |
|---|
| 637 | + const char *share, size_t share_len, |
|---|
| 638 | + bool *result); |
|---|
| 639 | +#endif |
|---|
| 640 | + |
|---|
| 641 | +static inline int cifs_create_options(struct cifs_sb_info *cifs_sb, int options) |
|---|
| 642 | +{ |
|---|
| 643 | + if (cifs_sb && (backup_cred(cifs_sb))) |
|---|
| 644 | + return options | CREATE_OPEN_BACKUP_INTENT; |
|---|
| 645 | + else |
|---|
| 646 | + return options; |
|---|
| 647 | +} |
|---|
| 565 | 648 | |
|---|
| 566 | 649 | #endif /* _CIFSPROTO_H */ |
|---|