blob: 007bd35dc9414d79f5dee21d5feaffecc68f1cc0 [file] [log] [blame]
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +04001/*
2 * fs/cifs/smb2inode.c
3 *
4 * Copyright (C) International Business Machines Corp., 2002, 2011
5 * Etersoft, 2012
6 * Author(s): Pavel Shilovsky (pshilovsky@samba.org),
7 * Steve French (sfrench@us.ibm.com)
8 *
9 * This library is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published
11 * by the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23#include <linux/fs.h>
24#include <linux/stat.h>
25#include <linux/slab.h>
26#include <linux/pagemap.h>
27#include <asm/div64.h>
28#include "cifsfs.h"
29#include "cifspdu.h"
30#include "cifsglob.h"
31#include "cifsproto.h"
32#include "cifs_debug.h"
33#include "cifs_fs_sb.h"
34#include "cifs_unicode.h"
35#include "fscache.h"
36#include "smb2glob.h"
37#include "smb2pdu.h"
38#include "smb2proto.h"
39
40static int
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +100041smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
42 struct cifs_sb_info *cifs_sb, const char *full_path,
43 __u32 desired_access, __u32 create_disposition,
Ronnie Sahlbergc2e0fe32018-09-03 13:33:45 +100044 __u32 create_options, void *ptr, int command)
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +100045{
46 int rc;
47 __le16 *utf16_path = NULL;
48 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
49 struct cifs_open_parms oparms;
50 struct cifs_fid fid;
51 struct cifs_ses *ses = tcon->ses;
52 struct TCP_Server_Info *server = ses->server;
53 int num_rqst = 0;
54 struct smb_rqst rqst[3];
55 int resp_buftype[3];
56 struct kvec rsp_iov[3];
57 struct kvec open_iov[SMB2_CREATE_IOV_SIZE];
58 struct kvec qi_iov[1];
Ronnie Sahlbergc2e0fe32018-09-03 13:33:45 +100059 struct kvec si_iov[2]; /* 1 + potential padding. */
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +100060 struct kvec close_iov[1];
Ronnie Sahlbergc2e0fe32018-09-03 13:33:45 +100061 struct smb2_query_info_rsp *qi_rsp = NULL;
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +100062 int flags = 0;
Ronnie Sahlbergc2e0fe32018-09-03 13:33:45 +100063 __u8 delete_pending[8] = {1, 0, 0, 0, 0, 0, 0, 0};
64 unsigned int size[1];
65 void *data[1];
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +100066
67 if (smb3_encryption_required(tcon))
68 flags |= CIFS_TRANSFORM_REQ;
69
70 memset(rqst, 0, sizeof(rqst));
71 resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
72 memset(rsp_iov, 0, sizeof(rsp_iov));
73
74 /* Open */
75 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
76 if (!utf16_path)
77 return -ENOMEM;
78
79 oparms.tcon = tcon;
80 oparms.desired_access = desired_access;
81 oparms.disposition = create_disposition;
82 oparms.create_options = create_options;
83 oparms.fid = &fid;
84 oparms.reconnect = false;
85
86 memset(&open_iov, 0, sizeof(open_iov));
87 rqst[num_rqst].rq_iov = open_iov;
88 rqst[num_rqst].rq_nvec = SMB2_CREATE_IOV_SIZE;
89 rc = SMB2_open_init(tcon, &rqst[num_rqst], &oplock, &oparms,
90 utf16_path);
91 kfree(utf16_path);
92 if (rc)
93 goto finished;
94
95 smb2_set_next_command(server, &rqst[num_rqst++]);
96
97 /* Operation */
98 switch (command) {
99 case SMB2_OP_QUERY_INFO:
100 memset(&qi_iov, 0, sizeof(qi_iov));
101 rqst[num_rqst].rq_iov = qi_iov;
102 rqst[num_rqst].rq_nvec = 1;
103
104 rc = SMB2_query_info_init(tcon, &rqst[num_rqst], COMPOUND_FID,
105 COMPOUND_FID, FILE_ALL_INFORMATION,
106 SMB2_O_INFO_FILE, 0,
107 sizeof(struct smb2_file_all_info) +
108 PATH_MAX * 2);
109 smb2_set_next_command(server, &rqst[num_rqst]);
110 smb2_set_related(&rqst[num_rqst++]);
111 break;
Ronnie Sahlberg47dd9592018-09-03 13:33:43 +1000112 case SMB2_OP_DELETE:
113 break;
Ronnie Sahlbergf733e392018-09-03 13:33:42 +1000114 case SMB2_OP_MKDIR:
115 /*
116 * Directories are created through parameters in the
117 * SMB2_open() call.
118 */
119 break;
Ronnie Sahlbergc2e0fe32018-09-03 13:33:45 +1000120 case SMB2_OP_RMDIR:
121 memset(&si_iov, 0, sizeof(si_iov));
122 rqst[num_rqst].rq_iov = si_iov;
123 rqst[num_rqst].rq_nvec = 1;
124
125 size[0] = 8;
126 data[0] = &delete_pending[0];
127
128 rc = SMB2_set_info_init(tcon, &rqst[num_rqst], COMPOUND_FID,
129 COMPOUND_FID, current->tgid,
130 FILE_DISPOSITION_INFORMATION,
131 SMB2_O_INFO_FILE, 0, data, size);
132 smb2_set_next_command(server, &rqst[num_rqst]);
133 smb2_set_related(&rqst[num_rqst++]);
134 break;
Ronnie Sahlbergf7bfe042018-09-03 13:33:46 +1000135 case SMB2_OP_SET_EOF:
136 memset(&si_iov, 0, sizeof(si_iov));
137 rqst[num_rqst].rq_iov = si_iov;
138 rqst[num_rqst].rq_nvec = 1;
139
140 size[0] = 8; /* sizeof __le64 */
141 data[0] = ptr;
142
143 rc = SMB2_set_info_init(tcon, &rqst[num_rqst], COMPOUND_FID,
144 COMPOUND_FID, current->tgid,
145 FILE_END_OF_FILE_INFORMATION,
146 SMB2_O_INFO_FILE, 0, data, size);
147 smb2_set_next_command(server, &rqst[num_rqst]);
148 smb2_set_related(&rqst[num_rqst++]);
149 break;
Ronnie Sahlbergdcbf9102018-09-03 13:33:48 +1000150 case SMB2_OP_SET_INFO:
151 memset(&si_iov, 0, sizeof(si_iov));
152 rqst[num_rqst].rq_iov = si_iov;
153 rqst[num_rqst].rq_nvec = 1;
154
155 size[0] = sizeof(FILE_BASIC_INFO);
156 data[0] = ptr;
157
158 rc = SMB2_set_info_init(tcon, &rqst[num_rqst], COMPOUND_FID,
159 COMPOUND_FID, current->tgid,
160 FILE_BASIC_INFORMATION,
161 SMB2_O_INFO_FILE, 0, data, size);
162 smb2_set_next_command(server, &rqst[num_rqst]);
163 smb2_set_related(&rqst[num_rqst++]);
164 break;
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +1000165 default:
166 cifs_dbg(VFS, "Invalid command\n");
167 rc = -EINVAL;
168 }
169 if (rc)
170 goto finished;
171
172 /* Close */
173 memset(&close_iov, 0, sizeof(close_iov));
174 rqst[num_rqst].rq_iov = close_iov;
175 rqst[num_rqst].rq_nvec = 1;
176 rc = SMB2_close_init(tcon, &rqst[num_rqst], COMPOUND_FID,
177 COMPOUND_FID);
178 smb2_set_related(&rqst[num_rqst++]);
179 if (rc)
180 goto finished;
181
182 rc = compound_send_recv(xid, ses, flags, num_rqst, rqst,
183 resp_buftype, rsp_iov);
184
185 finished:
186 SMB2_open_free(&rqst[0]);
187 switch (command) {
188 case SMB2_OP_QUERY_INFO:
189 if (rc == 0) {
Ronnie Sahlbergc2e0fe32018-09-03 13:33:45 +1000190 qi_rsp = (struct smb2_query_info_rsp *)
191 rsp_iov[1].iov_base;
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +1000192 rc = smb2_validate_and_copy_iov(
Ronnie Sahlbergc2e0fe32018-09-03 13:33:45 +1000193 le16_to_cpu(qi_rsp->OutputBufferOffset),
194 le32_to_cpu(qi_rsp->OutputBufferLength),
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +1000195 &rsp_iov[1], sizeof(struct smb2_file_all_info),
Ronnie Sahlbergc2e0fe32018-09-03 13:33:45 +1000196 ptr);
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +1000197 }
198 if (rqst[1].rq_iov)
199 SMB2_query_info_free(&rqst[1]);
200 if (rqst[2].rq_iov)
201 SMB2_close_free(&rqst[2]);
202 break;
Ronnie Sahlberg47dd9592018-09-03 13:33:43 +1000203 case SMB2_OP_DELETE:
Ronnie Sahlbergf733e392018-09-03 13:33:42 +1000204 case SMB2_OP_MKDIR:
205 if (rqst[1].rq_iov)
206 SMB2_close_free(&rqst[1]);
207 break;
Ronnie Sahlbergc2e0fe32018-09-03 13:33:45 +1000208 case SMB2_OP_RMDIR:
Ronnie Sahlbergdcbf9102018-09-03 13:33:48 +1000209 case SMB2_OP_SET_EOF:
210 case SMB2_OP_SET_INFO:
Ronnie Sahlbergc2e0fe32018-09-03 13:33:45 +1000211 if (rqst[1].rq_iov)
212 SMB2_set_info_free(&rqst[1]);
213 if (rqst[2].rq_iov)
214 SMB2_close_free(&rqst[2]);
215 break;
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +1000216 }
217 free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base);
218 free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
219 free_rsp_buf(resp_buftype[2], rsp_iov[2].iov_base);
220 return rc;
221}
222
223static int
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400224smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon,
225 struct cifs_sb_info *cifs_sb, const char *full_path,
226 __u32 desired_access, __u32 create_disposition,
Pavel Shilovskyca819832013-07-05 12:21:26 +0400227 __u32 create_options, void *data, int command)
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400228{
229 int rc, tmprc = 0;
Steve French3d4ef9a2018-04-25 22:19:09 -0500230 __le16 *utf16_path = NULL;
Pavel Shilovsky2e44b282012-09-18 16:20:33 -0700231 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
Pavel Shilovsky064f6042013-07-09 18:20:30 +0400232 struct cifs_open_parms oparms;
233 struct cifs_fid fid;
Steve French3d4ef9a2018-04-25 22:19:09 -0500234 bool use_cached_root_handle = false;
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400235
Steve French3d4ef9a2018-04-25 22:19:09 -0500236 if ((strcmp(full_path, "") == 0) && (create_options == 0) &&
237 (desired_access == FILE_READ_ATTRIBUTES) &&
238 (create_disposition == FILE_OPEN) &&
239 (tcon->nohandlecache == false)) {
240 rc = open_shroot(xid, tcon, &fid);
241 if (rc == 0)
242 use_cached_root_handle = true;
243 }
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400244
Steve French3d4ef9a2018-04-25 22:19:09 -0500245 if (use_cached_root_handle == false) {
246 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
247 if (!utf16_path)
248 return -ENOMEM;
Pavel Shilovsky064f6042013-07-09 18:20:30 +0400249
Steve French3d4ef9a2018-04-25 22:19:09 -0500250 oparms.tcon = tcon;
251 oparms.desired_access = desired_access;
252 oparms.disposition = create_disposition;
253 oparms.create_options = create_options;
254 oparms.fid = &fid;
255 oparms.reconnect = false;
256
Ronnie Sahlberg9d874c32018-06-08 13:21:18 +1000257 rc = SMB2_open(xid, &oparms, utf16_path, &oplock, NULL, NULL,
258 NULL);
Steve French3d4ef9a2018-04-25 22:19:09 -0500259 if (rc) {
260 kfree(utf16_path);
261 return rc;
262 }
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400263 }
264
265 switch (command) {
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700266 case SMB2_OP_RENAME:
Pavel Shilovsky064f6042013-07-09 18:20:30 +0400267 tmprc = SMB2_rename(xid, tcon, fid.persistent_fid,
268 fid.volatile_fid, (__le16 *)data);
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700269 break;
Pavel Shilovsky568798c2012-09-18 16:20:31 -0700270 case SMB2_OP_HARDLINK:
Pavel Shilovsky064f6042013-07-09 18:20:30 +0400271 tmprc = SMB2_set_hardlink(xid, tcon, fid.persistent_fid,
272 fid.volatile_fid, (__le16 *)data);
Pavel Shilovsky568798c2012-09-18 16:20:31 -0700273 break;
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400274 default:
Joe Perchesf96637b2013-05-04 22:12:25 -0500275 cifs_dbg(VFS, "Invalid command\n");
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400276 break;
277 }
278
Ronnie Sahlberg9da6ec72018-07-31 08:48:22 +1000279 if (use_cached_root_handle)
280 close_shroot(&tcon->crfid);
281 else
Steve French3d4ef9a2018-04-25 22:19:09 -0500282 rc = SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid);
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400283 if (tmprc)
284 rc = tmprc;
285 kfree(utf16_path);
286 return rc;
287}
288
Pavel Shilovskyf0df7372012-09-18 16:20:26 -0700289void
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400290move_smb2_info_to_cifs(FILE_ALL_INFO *dst, struct smb2_file_all_info *src)
291{
292 memcpy(dst, src, (size_t)(&src->CurrentByteOffset) - (size_t)src);
293 dst->CurrentByteOffset = src->CurrentByteOffset;
294 dst->Mode = src->Mode;
295 dst->AlignmentRequirement = src->AlignmentRequirement;
296 dst->IndexNumber1 = 0; /* we don't use it */
297}
298
299int
300smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
301 struct cifs_sb_info *cifs_sb, const char *full_path,
Pavel Shilovskyeb85d94b2013-10-23 17:49:47 +0400302 FILE_ALL_INFO *data, bool *adjust_tz, bool *symlink)
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400303{
304 int rc;
305 struct smb2_file_all_info *smb2_data;
306
307 *adjust_tz = false;
Pavel Shilovskyeb85d94b2013-10-23 17:49:47 +0400308 *symlink = false;
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400309
Pavel Shilovsky1bbe4992014-08-22 13:32:11 +0400310 smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400311 GFP_KERNEL);
312 if (smb2_data == NULL)
313 return -ENOMEM;
314
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +1000315 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
316 FILE_READ_ATTRIBUTES, FILE_OPEN, 0,
317 smb2_data, SMB2_OP_QUERY_INFO);
Pavel Shilovskyeb85d94b2013-10-23 17:49:47 +0400318 if (rc == -EOPNOTSUPP) {
319 *symlink = true;
320 /* Failed on a symbolic link - query a reparse point info */
Ronnie Sahlbergc5a5f382018-09-03 13:33:41 +1000321 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
322 FILE_READ_ATTRIBUTES, FILE_OPEN,
323 OPEN_REPARSE_POINT, smb2_data,
324 SMB2_OP_QUERY_INFO);
Pavel Shilovskyeb85d94b2013-10-23 17:49:47 +0400325 }
Pavel Shilovskybe4cb9e2011-12-29 17:06:33 +0400326 if (rc)
327 goto out;
328
329 move_smb2_info_to_cifs(data, smb2_data);
330out:
331 kfree(smb2_data);
332 return rc;
333}
Pavel Shilovskya0e73182011-07-19 12:56:37 +0400334
335int
336smb2_mkdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
337 struct cifs_sb_info *cifs_sb)
338{
Ronnie Sahlbergf733e392018-09-03 13:33:42 +1000339 return smb2_compound_op(xid, tcon, cifs_sb, name,
340 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
341 CREATE_NOT_FILE, NULL, SMB2_OP_MKDIR);
Pavel Shilovskya0e73182011-07-19 12:56:37 +0400342}
343
344void
345smb2_mkdir_setinfo(struct inode *inode, const char *name,
346 struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
347 const unsigned int xid)
348{
349 FILE_BASIC_INFO data;
350 struct cifsInodeInfo *cifs_i;
351 u32 dosattrs;
352 int tmprc;
353
354 memset(&data, 0, sizeof(data));
355 cifs_i = CIFS_I(inode);
356 dosattrs = cifs_i->cifsAttrs | ATTR_READONLY;
357 data.Attributes = cpu_to_le32(dosattrs);
Ronnie Sahlbergdcbf9102018-09-03 13:33:48 +1000358 tmprc = smb2_compound_op(xid, tcon, cifs_sb, name,
359 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
360 CREATE_NOT_FILE, &data, SMB2_OP_SET_INFO);
Pavel Shilovskya0e73182011-07-19 12:56:37 +0400361 if (tmprc == 0)
362 cifs_i->cifsAttrs = dosattrs;
363}
Pavel Shilovsky1a500f02012-07-10 16:14:38 +0400364
365int
366smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
367 struct cifs_sb_info *cifs_sb)
368{
Ronnie Sahlbergc2e0fe32018-09-03 13:33:45 +1000369 return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
370 CREATE_NOT_FILE,
371 NULL, SMB2_OP_RMDIR);
Pavel Shilovsky1a500f02012-07-10 16:14:38 +0400372}
Pavel Shilovskycbe6f432012-09-18 16:20:25 -0700373
374int
375smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
376 struct cifs_sb_info *cifs_sb)
377{
Ronnie Sahlberg47dd9592018-09-03 13:33:43 +1000378 return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
379 CREATE_DELETE_ON_CLOSE | OPEN_REPARSE_POINT,
380 NULL, SMB2_OP_DELETE);
Pavel Shilovskycbe6f432012-09-18 16:20:25 -0700381}
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700382
Pavel Shilovsky568798c2012-09-18 16:20:31 -0700383static int
384smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon,
385 const char *from_name, const char *to_name,
386 struct cifs_sb_info *cifs_sb, __u32 access, int command)
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700387{
388 __le16 *smb2_to_name = NULL;
389 int rc;
390
391 smb2_to_name = cifs_convert_path_to_utf16(to_name, cifs_sb);
392 if (smb2_to_name == NULL) {
393 rc = -ENOMEM;
394 goto smb2_rename_path;
395 }
396
Pavel Shilovsky568798c2012-09-18 16:20:31 -0700397 rc = smb2_open_op_close(xid, tcon, cifs_sb, from_name, access,
Pavel Shilovskyca819832013-07-05 12:21:26 +0400398 FILE_OPEN, 0, smb2_to_name, command);
Pavel Shilovsky35143eb2012-09-18 16:20:31 -0700399smb2_rename_path:
400 kfree(smb2_to_name);
401 return rc;
402}
Pavel Shilovsky568798c2012-09-18 16:20:31 -0700403
404int
405smb2_rename_path(const unsigned int xid, struct cifs_tcon *tcon,
406 const char *from_name, const char *to_name,
407 struct cifs_sb_info *cifs_sb)
408{
409 return smb2_set_path_attr(xid, tcon, from_name, to_name, cifs_sb,
410 DELETE, SMB2_OP_RENAME);
411}
412
413int
414smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
415 const char *from_name, const char *to_name,
416 struct cifs_sb_info *cifs_sb)
417{
418 return smb2_set_path_attr(xid, tcon, from_name, to_name, cifs_sb,
419 FILE_READ_ATTRIBUTES, SMB2_OP_HARDLINK);
420}
Pavel Shilovskyc839ff22012-09-18 16:20:32 -0700421
422int
423smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
424 const char *full_path, __u64 size,
425 struct cifs_sb_info *cifs_sb, bool set_alloc)
426{
427 __le64 eof = cpu_to_le64(size);
Ronnie Sahlbergf7bfe042018-09-03 13:33:46 +1000428
429 return smb2_compound_op(xid, tcon, cifs_sb, full_path,
430 FILE_WRITE_DATA, FILE_OPEN, 0, &eof,
431 SMB2_OP_SET_EOF);
Pavel Shilovskyc839ff22012-09-18 16:20:32 -0700432}
Pavel Shilovsky1feeaac2012-09-18 16:20:32 -0700433
434int
435smb2_set_file_info(struct inode *inode, const char *full_path,
436 FILE_BASIC_INFO *buf, const unsigned int xid)
437{
438 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
439 struct tcon_link *tlink;
440 int rc;
441
Steve French18dd8e12016-09-26 14:23:08 -0500442 if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) &&
Steve Frenchfd09b7d2018-08-02 20:28:18 -0500443 (buf->LastWriteTime == 0) && (buf->ChangeTime == 0) &&
Steve French18dd8e12016-09-26 14:23:08 -0500444 (buf->Attributes == 0))
445 return 0; /* would be a no op, no sense sending this */
446
Pavel Shilovsky1feeaac2012-09-18 16:20:32 -0700447 tlink = cifs_sb_tlink(cifs_sb);
448 if (IS_ERR(tlink))
449 return PTR_ERR(tlink);
Steve French18dd8e12016-09-26 14:23:08 -0500450
Ronnie Sahlbergdcbf9102018-09-03 13:33:48 +1000451 rc = smb2_compound_op(xid, tlink_tcon(tlink), cifs_sb, full_path,
452 FILE_WRITE_ATTRIBUTES, FILE_OPEN, 0, buf,
453 SMB2_OP_SET_INFO);
Pavel Shilovsky1feeaac2012-09-18 16:20:32 -0700454 cifs_put_tlink(tlink);
455 return rc;
456}