s3: libsmb: Add cli_smb2_chkpath() and use from cli_chkpath().
[sfrench/samba-autobuild/.git] / source3 / libsmb / cli_smb2_fnum.h
1 /*
2    Unix SMB/CIFS implementation.
3    smb2 wrapper client routines
4    Copyright (C) Jeremy Allison 2013
5
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef __SMB2CLI_FNUM_H__
21 #define __SMB2CLI_FNUM_H__
22
23 struct smbXcli_conn;
24 struct smbXcli_session;
25 struct cli_state;
26 struct file_info;
27
28 struct tevent_req *cli_smb2_create_fnum_send(TALLOC_CTX *mem_ctx,
29                                              struct tevent_context *ev,
30                                              struct cli_state *cli,
31                                              const char *fname,
32                                              uint32_t create_flags,
33                                              uint32_t desired_access,
34                                              uint32_t file_attributes,
35                                              uint32_t share_access,
36                                              uint32_t create_disposition,
37                                              uint32_t create_options);
38 NTSTATUS cli_smb2_create_fnum_recv(struct tevent_req *req, uint16_t *pfnum,
39                                    struct smb_create_returns *cr);
40 NTSTATUS cli_smb2_create_fnum(struct cli_state *cli,
41                         const char *fname,
42                         uint32_t create_flags,
43                         uint32_t desired_access,
44                         uint32_t file_attributes,
45                         uint32_t share_access,
46                         uint32_t create_disposition,
47                         uint32_t create_options,
48                         uint16_t *pfid,
49                         struct smb_create_returns *cr);
50
51 struct tevent_req *cli_smb2_close_fnum_send(TALLOC_CTX *mem_ctx,
52                                             struct tevent_context *ev,
53                                             struct cli_state *cli,
54                                             uint16_t fnum);
55 NTSTATUS cli_smb2_close_fnum_recv(struct tevent_req *req);
56 NTSTATUS cli_smb2_close_fnum(struct cli_state *cli, uint16_t fnum);
57 struct tevent_req *cli_smb2_delete_on_close_send(TALLOC_CTX *mem_ctx,
58                                         struct tevent_context *ev,
59                                         struct cli_state *cli,
60                                         uint16_t fnum,
61                                         bool flag);
62 NTSTATUS cli_smb2_delete_on_close_recv(struct tevent_req *req);
63 NTSTATUS cli_smb2_delete_on_close(struct cli_state *cli, uint16_t fnum, bool flag);
64 NTSTATUS cli_smb2_mkdir(struct cli_state *cli, const char *dirname);
65 NTSTATUS cli_smb2_rmdir(struct cli_state *cli, const char *dirname);
66 NTSTATUS cli_smb2_unlink(struct cli_state *cli,const char *fname);
67 NTSTATUS cli_smb2_list(struct cli_state *cli,
68                         const char *pathname,
69                         uint16_t attribute,
70                         NTSTATUS (*fn)(const char *,
71                                 struct file_info *,
72                                 const char *,
73                                 void *),
74                         void *state);
75 NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli,
76                         const char *name,
77                         SMB_STRUCT_STAT *sbuf,
78                         uint32_t *attributes);
79 NTSTATUS cli_smb2_qpathinfo_alt_name(struct cli_state *cli,
80                         const char *name,
81                         fstring alt_name);
82 NTSTATUS cli_smb2_chkpath(struct cli_state *cli,
83                         const char *name);
84 NTSTATUS cli_smb2_qfileinfo_basic(struct cli_state *cli,
85                         uint16_t fnum,
86                         uint16_t *mode,
87                         off_t *size,
88                         struct timespec *create_time,
89                         struct timespec *access_time,
90                         struct timespec *write_time,
91                         struct timespec *change_time,
92                         SMB_INO_T *ino);
93 NTSTATUS cli_smb2_getattrE(struct cli_state *cli,
94                         uint16_t fnum,
95                         uint16_t *attr,
96                         off_t *size,
97                         time_t *change_time,
98                         time_t *access_time,
99                         time_t *write_time);
100 NTSTATUS cli_smb2_getatr(struct cli_state *cli,
101                         const char *name,
102                         uint16_t *attr,
103                         off_t *size,
104                         time_t *write_time);
105 NTSTATUS cli_smb2_qpathinfo2(struct cli_state *cli,
106                         const char *fname,
107                         struct timespec *create_time,
108                         struct timespec *access_time,
109                         struct timespec *write_time,
110                         struct timespec *change_time,
111                         off_t *size,
112                         uint16_t *mode,
113                         SMB_INO_T *ino);
114 NTSTATUS cli_smb2_qpathinfo_streams(struct cli_state *cli,
115                         const char *name,
116                         TALLOC_CTX *mem_ctx,
117                         unsigned int *pnum_streams,
118                         struct stream_struct **pstreams);
119 NTSTATUS cli_smb2_setpathinfo(struct cli_state *cli,
120                         const char *name,
121                         uint8_t in_info_type,
122                         uint8_t in_file_info_class,
123                         const DATA_BLOB *p_in_data);
124 NTSTATUS cli_smb2_setatr(struct cli_state *cli,
125                         const char *fname,
126                         uint16_t attr,
127                         time_t mtime);
128 NTSTATUS cli_smb2_setattrE(struct cli_state *cli,
129                         uint16_t fnum,
130                         time_t change_time,
131                         time_t access_time,
132                         time_t write_time);
133 NTSTATUS cli_smb2_dskattr(struct cli_state *cli,
134                         const char *path,
135                         uint64_t *bsize,
136                         uint64_t *total,
137                         uint64_t *avail);
138 NTSTATUS cli_smb2_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr);
139 NTSTATUS cli_smb2_query_security_descriptor(struct cli_state *cli,
140                         uint16_t fnum,
141                         uint32_t sec_info,
142                         TALLOC_CTX *mem_ctx,
143                         struct security_descriptor **ppsd);
144 NTSTATUS cli_smb2_set_security_descriptor(struct cli_state *cli,
145                         uint16_t fnum,
146                         uint32_t sec_info,
147                         const struct security_descriptor *sd);
148 NTSTATUS cli_smb2_rename(struct cli_state *cli,
149                          const char *fname_src,
150                          const char *fname_dst,
151                          bool replace);
152 NTSTATUS cli_smb2_set_ea_fnum(struct cli_state *cli,
153                         uint16_t fnum,
154                         const char *ea_name,
155                         const char *ea_val,
156                         size_t ea_len);
157 NTSTATUS cli_smb2_get_ea_list_path(struct cli_state *cli,
158                         const char *name,
159                         TALLOC_CTX *ctx,
160                         size_t *pnum_eas,
161                         struct ea_struct **pea_list);
162 NTSTATUS cli_smb2_set_ea_path(struct cli_state *cli,
163                         const char *name,
164                         const char *ea_name,
165                         const char *ea_val,
166                         size_t ea_len);
167 NTSTATUS cli_smb2_get_user_quota(struct cli_state *cli,
168                                  int quota_fnum,
169                                  SMB_NTQUOTA_STRUCT *pqt);
170 NTSTATUS cli_smb2_list_user_quota_step(struct cli_state *cli,
171                                        TALLOC_CTX *mem_ctx,
172                                        int quota_fnum,
173                                        SMB_NTQUOTA_LIST **pqt_list,
174                                        bool first);
175 NTSTATUS cli_smb2_get_fs_quota_info(struct cli_state *cli,
176                                     int quota_fnum,
177                                     SMB_NTQUOTA_STRUCT *pqt);
178 NTSTATUS cli_smb2_set_user_quota(struct cli_state *cli,
179                                  int quota_fnum,
180                                  SMB_NTQUOTA_LIST *qtl);
181 NTSTATUS cli_smb2_set_fs_quota_info(struct cli_state *cli,
182                                     int quota_fnum,
183                                     SMB_NTQUOTA_STRUCT *pqt);
184 struct tevent_req *cli_smb2_read_send(TALLOC_CTX *mem_ctx,
185                                 struct tevent_context *ev,
186                                 struct cli_state *cli,
187                                 uint16_t fnum,
188                                 off_t offset,
189                                 size_t size);
190 NTSTATUS cli_smb2_read_recv(struct tevent_req *req,
191                                 ssize_t *received,
192                                 uint8_t **rcvbuf);
193 struct tevent_req *cli_smb2_write_send(TALLOC_CTX *mem_ctx,
194                                         struct tevent_context *ev,
195                                         struct cli_state *cli,
196                                         uint16_t fnum,
197                                         uint16_t mode,
198                                         const uint8_t *buf,
199                                         off_t offset,
200                                         size_t size);
201 NTSTATUS cli_smb2_write_recv(struct tevent_req *req,
202                              size_t *pwritten);
203 struct tevent_req *cli_smb2_writeall_send(TALLOC_CTX *mem_ctx,
204                         struct tevent_context *ev,
205                         struct cli_state *cli,
206                         uint16_t fnum,
207                         uint16_t mode,
208                         const uint8_t *buf,
209                         off_t offset,
210                         size_t size);
211 NTSTATUS cli_smb2_writeall_recv(struct tevent_req *req,
212                         size_t *pwritten);
213 struct tevent_req *cli_smb2_splice_send(TALLOC_CTX *mem_ctx,
214                         struct tevent_context *ev,
215                         struct cli_state *cli,
216                         uint16_t src_fnum, uint16_t dst_fnum,
217                         off_t size, off_t src_offset, off_t dst_offset,
218                         int (*splice_cb)(off_t n, void *priv), void *priv);
219 NTSTATUS cli_smb2_splice_recv(struct tevent_req *req, off_t *written);
220 NTSTATUS cli_smb2_shadow_copy_data(TALLOC_CTX *mem_ctx,
221                         struct cli_state *cli,
222                         uint16_t fnum,
223                         bool get_names,
224                         char ***pnames,
225                         int *pnum_names);
226 NTSTATUS cli_smb2_ftruncate(struct cli_state *cli,
227                         uint16_t fnum,
228                         uint64_t newsize);
229 NTSTATUS cli_smb2_notify(struct cli_state *cli, uint16_t fnum,
230                          uint32_t buffer_size, uint32_t completion_filter,
231                          bool recursive, TALLOC_CTX *mem_ctx,
232                          struct notify_change **pchanges,
233                          uint32_t *pnum_changes);
234 #endif /* __SMB2CLI_FNUM_H__ */