forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/fs/cifs/cifsproto.h
....@@ -22,6 +22,9 @@
2222 #define _CIFSPROTO_H
2323 #include <linux/nls.h>
2424 #include "trace.h"
25
+#ifdef CONFIG_CIFS_DFS_UPCALL
26
+#include "dfs_cache.h"
27
+#endif
2528
2629 struct statfs;
2730 struct smb_vol;
....@@ -42,25 +45,25 @@
4245 unsigned int /* length */);
4346 extern unsigned int _get_xid(void);
4447 extern void _free_xid(unsigned int);
45
-#define get_xid() \
46
-({ \
48
+#define get_xid() \
49
+({ \
4750 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", \
4952 __func__, __xid, \
5053 from_kuid(&init_user_ns, current_fsuid())); \
51
- trace_smb3_enter(__xid, __func__); \
52
- __xid; \
54
+ trace_smb3_enter(__xid, __func__); \
55
+ __xid; \
5356 })
5457
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) \
6164 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__); \
6467 } while (0)
6568 extern int init_cifs_idmap(void);
6669 extern void exit_cifs_idmap(void);
....@@ -86,15 +89,20 @@
8689 extern void cifs_wake_up_task(struct mid_q_entry *mid);
8790 extern int cifs_handle_standard(struct TCP_Server_Info *server,
8891 struct mid_q_entry *mid);
92
+extern bool cifs_match_ipaddr(struct sockaddr *srcaddr, struct sockaddr *rhs);
8993 extern int cifs_discard_remaining_data(struct TCP_Server_Info *server);
9094 extern int cifs_call_async(struct TCP_Server_Info *server,
9195 struct smb_rqst *rqst,
9296 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);
94100 extern int cifs_send_recv(const unsigned int xid, struct cifs_ses *ses,
101
+ struct TCP_Server_Info *server,
95102 struct smb_rqst *rqst, int *resp_buf_type,
96103 const int flags, struct kvec *resp_iov);
97104 extern int compound_send_recv(const unsigned int xid, struct cifs_ses *ses,
105
+ struct TCP_Server_Info *server,
98106 const int flags, const int num_rqst,
99107 struct smb_rqst *rqst, int *resp_buf_type,
100108 struct kvec *resp_iov);
....@@ -105,6 +113,7 @@
105113 extern int SendReceiveNoRsp(const unsigned int xid, struct cifs_ses *ses,
106114 char *in_buf, int flags);
107115 extern struct mid_q_entry *cifs_setup_request(struct cifs_ses *,
116
+ struct TCP_Server_Info *,
108117 struct smb_rqst *);
109118 extern struct mid_q_entry *cifs_setup_async_request(struct TCP_Server_Info *,
110119 struct smb_rqst *);
....@@ -112,7 +121,7 @@
112121 struct TCP_Server_Info *server, bool log_error);
113122 extern int cifs_wait_mtu_credits(struct TCP_Server_Info *server,
114123 unsigned int size, unsigned int *num,
115
- unsigned int *credits);
124
+ struct cifs_credits *credits);
116125 extern int SendReceive2(const unsigned int /* xid */ , struct cifs_ses *,
117126 struct kvec *, int /* nvec to send */,
118127 int * /* type of buf returned */, const int flags,
....@@ -129,14 +138,23 @@
129138 extern bool is_size_safe_to_change(struct cifsInodeInfo *, __u64 eof);
130139 extern void cifs_update_eof(struct cifsInodeInfo *cifsi, loff_t offset,
131140 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);
133148 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);
134151 extern unsigned int smbCalcSize(void *buf, struct TCP_Server_Info *server);
135152 extern int decode_negTokenInit(unsigned char *security_blob, int length,
136153 struct TCP_Server_Info *server);
137154 extern int cifs_convert_address(struct sockaddr *dst, const char *src, int len);
138155 extern void cifs_set_port(struct sockaddr *addr, const unsigned short int port);
139156 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);
140158 extern void header_assemble(struct smb_hdr *, char /* command */ ,
141159 const struct cifs_tcon *, int /* length of
142160 fixed section (word count) in two byte units */);
....@@ -181,6 +199,8 @@
181199 extern int cifs_get_inode_info(struct inode **inode, const char *full_path,
182200 FILE_ALL_INFO *data, struct super_block *sb,
183201 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);
184204 extern int cifs_get_inode_info_unix(struct inode **pinode,
185205 const unsigned char *search_path,
186206 struct super_block *sb, unsigned int xid);
....@@ -189,8 +209,11 @@
189209 extern int cifs_rename_pending_delete(const char *full_path,
190210 struct dentry *dentry,
191211 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);
192214 extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
193215 struct cifs_fattr *fattr, struct inode *inode,
216
+ bool get_mode_from_special_sid,
194217 const char *path, const struct cifs_fid *pfid);
195218 extern int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64,
196219 kuid_t, kgid_t);
....@@ -200,10 +223,15 @@
200223 const struct cifs_fid *, u32 *);
201224 extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *,
202225 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);
203229
204230 extern void dequeue_mid(struct mid_q_entry *mid, bool malformed);
205231 extern int cifs_read_from_socket(struct TCP_Server_Info *server, char *buf,
206232 unsigned int to_read);
233
+extern ssize_t cifs_discard_from_socket(struct TCP_Server_Info *server,
234
+ size_t to_read);
207235 extern int cifs_read_page_from_socket(struct TCP_Server_Info *server,
208236 struct page *page,
209237 unsigned int page_offset,
....@@ -214,13 +242,13 @@
214242 extern void cifs_cleanup_volume_info(struct smb_vol *pvolume_info);
215243 extern struct smb_vol *cifs_get_volume_info(char *mount_data,
216244 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);
218246 extern void cifs_umount(struct cifs_sb_info *);
219247 extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
220248 extern void cifs_reopen_persistent_handles(struct cifs_tcon *tcon);
221249
222250 extern bool cifs_find_lock_conflict(struct cifsFileInfo *cfile, __u64 offset,
223
- __u64 length, __u8 type,
251
+ __u64 length, __u8 type, __u16 flags,
224252 struct cifsLockInfo **conf_lock,
225253 int rw_check);
226254 extern void cifs_add_pending_open(struct cifs_fid *fid,
....@@ -230,6 +258,7 @@
230258 struct tcon_link *tlink,
231259 struct cifs_pending_open *open);
232260 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);
233262 extern void cifs_put_tcp_session(struct TCP_Server_Info *server,
234263 int from_reconnect);
235264 extern void cifs_put_tcon(struct cifs_tcon *tcon);
....@@ -246,6 +275,9 @@
246275 extern void cifs_move_llist(struct list_head *source, struct list_head *dest);
247276 extern void cifs_free_llist(struct list_head *llist);
248277 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);
249281
250282 extern int cifs_negotiate_protocol(const unsigned int xid,
251283 struct cifs_ses *ses);
....@@ -295,11 +327,6 @@
295327 unsigned int *num_of_nodes,
296328 const struct nls_table *nls_codepage, int remap);
297329
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);
303330 extern int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
304331 unsigned int *num_of_nodes,
305332 struct dfs_info3_param **target_nodes,
....@@ -325,7 +352,7 @@
325352 extern int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
326353 const char *fileName, const FILE_BASIC_INFO *data,
327354 const struct nls_table *nls_codepage,
328
- int remap_special_chars);
355
+ struct cifs_sb_info *cifs_sb);
329356 extern int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
330357 const FILE_BASIC_INFO *data, __u16 fid,
331358 __u32 pid_of_opener);
....@@ -366,7 +393,8 @@
366393 const struct nls_table *nls_codepage,
367394 int remap);
368395
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,
370398 const char *name, struct cifs_sb_info *cifs_sb);
371399 extern int CIFSSMBRmDir(const unsigned int xid, struct cifs_tcon *tcon,
372400 const char *name, struct cifs_sb_info *cifs_sb);
....@@ -526,6 +554,20 @@
526554 extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8,
527555 unsigned char *p24);
528556
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
+
529571 void cifs_readdata_release(struct kref *refcount);
530572 int cifs_async_readv(struct cifs_readdata *rdata);
531573 int cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid);
....@@ -560,7 +602,48 @@
560602 struct sdesc **sdesc);
561603 void cifs_free_hash(struct crypto_shash **shash, struct sdesc **sdesc);
562604
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
+}
565648
566649 #endif /* _CIFSPROTO_H */