1 // SPDX-License-Identifier: LGPL-2.1
4 * Copyright (C) International Business Machines Corp., 2002, 2011
11 #include <linux/stat.h>
12 #include <linux/slab.h>
13 #include <linux/pagemap.h>
14 #include <asm/div64.h>
18 #include "cifsproto.h"
19 #include "cifs_debug.h"
20 #include "cifs_fs_sb.h"
21 #include "cifs_unicode.h"
25 #include "smb2proto.h"
26 #include "cached_dir.h"
27 #include "smb2status.h"
30 free_set_inf_compound(struct smb_rqst *rqst)
33 SMB2_set_info_free(&rqst[1]);
35 SMB2_close_free(&rqst[2]);
39 * note: If cfile is passed, the reference to it is dropped here.
40 * So make sure that you do not reuse cfile after return from this func.
42 * If passing @out_iov and @out_buftype, ensure to make them both large enough
43 * (>= 3) to hold all compounded responses. Caller is also responsible for
44 * freeing them up with free_rsp_buf().
46 static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
47 struct cifs_sb_info *cifs_sb, const char *full_path,
48 __u32 desired_access, __u32 create_disposition, __u32 create_options,
49 umode_t mode, void *ptr, int command, struct cifsFileInfo *cfile,
50 __u8 **extbuf, size_t *extbuflen,
51 struct kvec *out_iov, int *out_buftype)
53 struct smb2_compound_vars *vars = NULL;
55 struct smb_rqst *rqst;
57 __le16 *utf16_path = NULL;
58 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
60 struct cifs_ses *ses = tcon->ses;
61 struct TCP_Server_Info *server;
64 struct smb2_query_info_rsp *qi_rsp = NULL;
65 struct cifs_open_info_data *idata;
67 __u8 delete_pending[8] = {1, 0, 0, 0, 0, 0, 0, 0};
72 vars = kzalloc(sizeof(*vars), GFP_ATOMIC);
75 rqst = &vars->rqst[0];
76 rsp_iov = &vars->rsp_iov[0];
78 server = cifs_pick_channel(ses);
80 if (smb3_encryption_required(tcon))
81 flags |= CIFS_TRANSFORM_REQ;
83 resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
85 /* We already have a handle so we can skip the open */
90 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
96 vars->oparms = (struct cifs_open_parms) {
99 .desired_access = desired_access,
100 .disposition = create_disposition,
101 .create_options = cifs_create_options(cifs_sb, create_options),
107 rqst[num_rqst].rq_iov = &vars->open_iov[0];
108 rqst[num_rqst].rq_nvec = SMB2_CREATE_IOV_SIZE;
109 rc = SMB2_open_init(tcon, server,
110 &rqst[num_rqst], &oplock, &vars->oparms,
116 smb2_set_next_command(tcon, &rqst[num_rqst]);
123 case SMB2_OP_QUERY_INFO:
124 rqst[num_rqst].rq_iov = &vars->qi_iov;
125 rqst[num_rqst].rq_nvec = 1;
128 rc = SMB2_query_info_init(tcon, server,
130 cfile->fid.persistent_fid,
131 cfile->fid.volatile_fid,
132 FILE_ALL_INFORMATION,
134 sizeof(struct smb2_file_all_info) +
135 PATH_MAX * 2, 0, NULL);
137 rc = SMB2_query_info_init(tcon, server,
141 FILE_ALL_INFORMATION,
143 sizeof(struct smb2_file_all_info) +
144 PATH_MAX * 2, 0, NULL);
146 smb2_set_next_command(tcon, &rqst[num_rqst]);
147 smb2_set_related(&rqst[num_rqst]);
154 trace_smb3_query_info_compound_enter(xid, ses->Suid, tcon->tid,
157 case SMB2_OP_POSIX_QUERY_INFO:
158 rqst[num_rqst].rq_iov = &vars->qi_iov;
159 rqst[num_rqst].rq_nvec = 1;
162 rc = SMB2_query_info_init(tcon, server,
164 cfile->fid.persistent_fid,
165 cfile->fid.volatile_fid,
166 SMB_FIND_FILE_POSIX_INFO,
168 /* TBD: fix following to allow for longer SIDs */
169 sizeof(struct smb311_posix_qinfo *) + (PATH_MAX * 2) +
170 (sizeof(struct cifs_sid) * 2), 0, NULL);
172 rc = SMB2_query_info_init(tcon, server,
176 SMB_FIND_FILE_POSIX_INFO,
178 sizeof(struct smb311_posix_qinfo *) + (PATH_MAX * 2) +
179 (sizeof(struct cifs_sid) * 2), 0, NULL);
181 smb2_set_next_command(tcon, &rqst[num_rqst]);
182 smb2_set_related(&rqst[num_rqst]);
189 trace_smb3_posix_query_info_compound_enter(xid, ses->Suid, tcon->tid, full_path);
192 trace_smb3_delete_enter(xid, ses->Suid, tcon->tid, full_path);
196 * Directories are created through parameters in the
199 trace_smb3_mkdir_enter(xid, ses->Suid, tcon->tid, full_path);
202 rqst[num_rqst].rq_iov = &vars->si_iov[0];
203 rqst[num_rqst].rq_nvec = 1;
205 size[0] = 1; /* sizeof __u8 See MS-FSCC section 2.4.11 */
206 data[0] = &delete_pending[0];
208 rc = SMB2_set_info_init(tcon, server,
209 &rqst[num_rqst], COMPOUND_FID,
210 COMPOUND_FID, current->tgid,
211 FILE_DISPOSITION_INFORMATION,
212 SMB2_O_INFO_FILE, 0, data, size);
215 smb2_set_next_command(tcon, &rqst[num_rqst]);
216 smb2_set_related(&rqst[num_rqst++]);
217 trace_smb3_rmdir_enter(xid, ses->Suid, tcon->tid, full_path);
219 case SMB2_OP_SET_EOF:
220 rqst[num_rqst].rq_iov = &vars->si_iov[0];
221 rqst[num_rqst].rq_nvec = 1;
223 size[0] = 8; /* sizeof __le64 */
227 rc = SMB2_set_info_init(tcon, server,
229 cfile->fid.persistent_fid,
230 cfile->fid.volatile_fid,
232 FILE_END_OF_FILE_INFORMATION,
236 rc = SMB2_set_info_init(tcon, server,
241 FILE_END_OF_FILE_INFORMATION,
245 smb2_set_next_command(tcon, &rqst[num_rqst]);
246 smb2_set_related(&rqst[num_rqst]);
252 trace_smb3_set_eof_enter(xid, ses->Suid, tcon->tid, full_path);
254 case SMB2_OP_SET_INFO:
255 rqst[num_rqst].rq_iov = &vars->si_iov[0];
256 rqst[num_rqst].rq_nvec = 1;
259 size[0] = sizeof(FILE_BASIC_INFO);
263 rc = SMB2_set_info_init(tcon, server,
265 cfile->fid.persistent_fid,
266 cfile->fid.volatile_fid, current->tgid,
267 FILE_BASIC_INFORMATION,
268 SMB2_O_INFO_FILE, 0, data, size);
270 rc = SMB2_set_info_init(tcon, server,
273 COMPOUND_FID, current->tgid,
274 FILE_BASIC_INFORMATION,
275 SMB2_O_INFO_FILE, 0, data, size);
277 smb2_set_next_command(tcon, &rqst[num_rqst]);
278 smb2_set_related(&rqst[num_rqst]);
285 trace_smb3_set_info_compound_enter(xid, ses->Suid, tcon->tid,
289 rqst[num_rqst].rq_iov = &vars->si_iov[0];
290 rqst[num_rqst].rq_nvec = 2;
292 len = (2 * UniStrnlen((wchar_t *)ptr, PATH_MAX));
294 vars->rename_info.ReplaceIfExists = 1;
295 vars->rename_info.RootDirectory = 0;
296 vars->rename_info.FileNameLength = cpu_to_le32(len);
298 size[0] = sizeof(struct smb2_file_rename_info);
299 data[0] = &vars->rename_info;
301 size[1] = len + 2 /* null */;
302 data[1] = (__le16 *)ptr;
305 rc = SMB2_set_info_init(tcon, server,
307 cfile->fid.persistent_fid,
308 cfile->fid.volatile_fid,
309 current->tgid, FILE_RENAME_INFORMATION,
310 SMB2_O_INFO_FILE, 0, data, size);
312 rc = SMB2_set_info_init(tcon, server,
314 COMPOUND_FID, COMPOUND_FID,
315 current->tgid, FILE_RENAME_INFORMATION,
316 SMB2_O_INFO_FILE, 0, data, size);
318 smb2_set_next_command(tcon, &rqst[num_rqst]);
319 smb2_set_related(&rqst[num_rqst]);
325 trace_smb3_rename_enter(xid, ses->Suid, tcon->tid, full_path);
327 case SMB2_OP_HARDLINK:
328 rqst[num_rqst].rq_iov = &vars->si_iov[0];
329 rqst[num_rqst].rq_nvec = 2;
331 len = (2 * UniStrnlen((wchar_t *)ptr, PATH_MAX));
333 vars->link_info.ReplaceIfExists = 0;
334 vars->link_info.RootDirectory = 0;
335 vars->link_info.FileNameLength = cpu_to_le32(len);
337 size[0] = sizeof(struct smb2_file_link_info);
338 data[0] = &vars->link_info;
340 size[1] = len + 2 /* null */;
341 data[1] = (__le16 *)ptr;
343 rc = SMB2_set_info_init(tcon, server,
344 &rqst[num_rqst], COMPOUND_FID,
345 COMPOUND_FID, current->tgid,
346 FILE_LINK_INFORMATION,
347 SMB2_O_INFO_FILE, 0, data, size);
350 smb2_set_next_command(tcon, &rqst[num_rqst]);
351 smb2_set_related(&rqst[num_rqst++]);
352 trace_smb3_hardlink_enter(xid, ses->Suid, tcon->tid, full_path);
355 cifs_dbg(VFS, "Invalid command\n");
361 /* We already have a handle so we can skip the close */
365 flags |= CIFS_CP_CREATE_CLOSE_OP;
366 rqst[num_rqst].rq_iov = &vars->close_iov;
367 rqst[num_rqst].rq_nvec = 1;
368 rc = SMB2_close_init(tcon, server,
369 &rqst[num_rqst], COMPOUND_FID,
370 COMPOUND_FID, false);
371 smb2_set_related(&rqst[num_rqst]);
378 rc = compound_send_recv(xid, ses, server,
380 &rqst[1], &resp_buftype[1],
383 rc = compound_send_recv(xid, ses, server,
389 SMB2_open_free(&rqst[0]);
390 if (rc == -EREMCHG) {
391 pr_warn_once("server share %s deleted\n", tcon->tree_name);
392 tcon->need_reconnect = true;
396 case SMB2_OP_QUERY_INFO:
398 if (rc == 0 && cfile && cfile->symlink_target) {
399 idata->symlink_target = kstrdup(cfile->symlink_target, GFP_KERNEL);
400 if (!idata->symlink_target)
404 qi_rsp = (struct smb2_query_info_rsp *)
406 rc = smb2_validate_and_copy_iov(
407 le16_to_cpu(qi_rsp->OutputBufferOffset),
408 le32_to_cpu(qi_rsp->OutputBufferLength),
409 &rsp_iov[1], sizeof(idata->fi), (char *)&idata->fi);
412 SMB2_query_info_free(&rqst[1]);
414 SMB2_close_free(&rqst[2]);
416 trace_smb3_query_info_compound_err(xid, ses->Suid,
419 trace_smb3_query_info_compound_done(xid, ses->Suid,
422 case SMB2_OP_POSIX_QUERY_INFO:
424 if (rc == 0 && cfile && cfile->symlink_target) {
425 idata->symlink_target = kstrdup(cfile->symlink_target, GFP_KERNEL);
426 if (!idata->symlink_target)
430 qi_rsp = (struct smb2_query_info_rsp *)
432 rc = smb2_validate_and_copy_iov(
433 le16_to_cpu(qi_rsp->OutputBufferOffset),
434 le32_to_cpu(qi_rsp->OutputBufferLength),
435 &rsp_iov[1], sizeof(idata->posix_fi) /* add SIDs */,
436 (char *)&idata->posix_fi);
439 unsigned int length = le32_to_cpu(qi_rsp->OutputBufferLength);
441 if (length > sizeof(idata->posix_fi)) {
442 char *base = (char *)rsp_iov[1].iov_base +
443 le16_to_cpu(qi_rsp->OutputBufferOffset) +
444 sizeof(idata->posix_fi);
445 *extbuflen = length - sizeof(idata->posix_fi);
446 *extbuf = kmemdup(base, *extbuflen, GFP_KERNEL);
454 SMB2_query_info_free(&rqst[1]);
456 SMB2_close_free(&rqst[2]);
458 trace_smb3_posix_query_info_compound_err(xid, ses->Suid, tcon->tid, rc);
460 trace_smb3_posix_query_info_compound_done(xid, ses->Suid, tcon->tid);
464 trace_smb3_delete_err(xid, ses->Suid, tcon->tid, rc);
466 trace_smb3_delete_done(xid, ses->Suid, tcon->tid);
468 SMB2_close_free(&rqst[1]);
472 trace_smb3_mkdir_err(xid, ses->Suid, tcon->tid, rc);
474 trace_smb3_mkdir_done(xid, ses->Suid, tcon->tid);
476 SMB2_close_free(&rqst[1]);
478 case SMB2_OP_HARDLINK:
480 trace_smb3_hardlink_err(xid, ses->Suid, tcon->tid, rc);
482 trace_smb3_hardlink_done(xid, ses->Suid, tcon->tid);
483 free_set_inf_compound(rqst);
487 trace_smb3_rename_err(xid, ses->Suid, tcon->tid, rc);
489 trace_smb3_rename_done(xid, ses->Suid, tcon->tid);
490 free_set_inf_compound(rqst);
494 trace_smb3_rmdir_err(xid, ses->Suid, tcon->tid, rc);
496 trace_smb3_rmdir_done(xid, ses->Suid, tcon->tid);
497 free_set_inf_compound(rqst);
499 case SMB2_OP_SET_EOF:
501 trace_smb3_set_eof_err(xid, ses->Suid, tcon->tid, rc);
503 trace_smb3_set_eof_done(xid, ses->Suid, tcon->tid);
504 free_set_inf_compound(rqst);
506 case SMB2_OP_SET_INFO:
508 trace_smb3_set_info_compound_err(xid, ses->Suid,
511 trace_smb3_set_info_compound_done(xid, ses->Suid,
513 free_set_inf_compound(rqst);
518 cifsFileInfo_put(cfile);
520 if (out_iov && out_buftype) {
521 memcpy(out_iov, rsp_iov, 3 * sizeof(*out_iov));
522 memcpy(out_buftype, resp_buftype, 3 * sizeof(*out_buftype));
524 free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base);
525 free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
526 free_rsp_buf(resp_buftype[2], rsp_iov[2].iov_base);
532 static int parse_create_response(struct cifs_open_info_data *data,
533 struct cifs_sb_info *cifs_sb,
534 const struct kvec *iov)
536 struct smb2_create_rsp *rsp = iov->iov_base;
537 bool reparse_point = false;
541 switch (rsp->hdr.Status) {
542 case STATUS_STOPPED_ON_SYMLINK:
543 rc = smb2_parse_symlink_response(cifs_sb, iov,
544 &data->symlink_target);
547 tag = IO_REPARSE_TAG_SYMLINK;
548 reparse_point = true;
551 reparse_point = !!(rsp->Flags & SMB2_CREATE_FLAG_REPARSEPOINT);
554 data->reparse_point = reparse_point;
555 data->reparse_tag = tag;
559 int smb2_query_path_info(const unsigned int xid,
560 struct cifs_tcon *tcon,
561 struct cifs_sb_info *cifs_sb,
562 const char *full_path,
563 struct cifs_open_info_data *data)
565 __u32 create_options = 0;
566 struct cifsFileInfo *cfile;
567 struct cached_fid *cfid = NULL;
568 struct smb2_hdr *hdr;
569 struct kvec out_iov[3] = {};
570 int out_buftype[3] = {};
574 data->adjust_tz = false;
575 data->reparse_point = false;
577 if (strcmp(full_path, ""))
580 rc = open_cached_dir(xid, tcon, full_path, cifs_sb, false, &cfid);
581 /* If it is a root and its handle is cached then use it */
583 if (cfid->file_all_info_is_valid) {
584 memcpy(&data->fi, &cfid->file_all_info, sizeof(data->fi));
586 rc = SMB2_query_info(xid, tcon, cfid->fid.persistent_fid,
587 cfid->fid.volatile_fid, &data->fi);
589 close_cached_dir(cfid);
593 cifs_get_readable_path(tcon, full_path, &cfile);
594 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, FILE_READ_ATTRIBUTES, FILE_OPEN,
595 create_options, ACL_NO_MODE, data, SMB2_OP_QUERY_INFO, cfile,
596 NULL, NULL, out_iov, out_buftype);
597 hdr = out_iov[0].iov_base;
599 * If first iov is unset, then SMB session was dropped or we've got a
600 * cached open file (@cfile).
602 if (!hdr || out_buftype[0] == CIFS_NO_BUFFER)
608 rc = parse_create_response(data, cifs_sb, &out_iov[0]);
609 if (rc || !data->reparse_point)
612 create_options |= OPEN_REPARSE_POINT;
613 /* Failed on a symbolic link - query a reparse point info */
614 cifs_get_readable_path(tcon, full_path, &cfile);
615 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
616 FILE_READ_ATTRIBUTES, FILE_OPEN,
617 create_options, ACL_NO_MODE, data,
618 SMB2_OP_QUERY_INFO, cfile, NULL, NULL,
624 if (hdr->Status != STATUS_OBJECT_NAME_INVALID)
626 rc2 = cifs_inval_name_dfs_link_error(xid, tcon, cifs_sb,
637 free_rsp_buf(out_buftype[0], out_iov[0].iov_base);
638 free_rsp_buf(out_buftype[1], out_iov[1].iov_base);
639 free_rsp_buf(out_buftype[2], out_iov[2].iov_base);
643 int smb311_posix_query_path_info(const unsigned int xid,
644 struct cifs_tcon *tcon,
645 struct cifs_sb_info *cifs_sb,
646 const char *full_path,
647 struct cifs_open_info_data *data,
648 struct cifs_sid *owner,
649 struct cifs_sid *group)
652 __u32 create_options = 0;
653 struct cifsFileInfo *cfile;
654 struct kvec out_iov[3] = {};
655 int out_buftype[3] = {};
656 __u8 *sidsbuf = NULL;
657 __u8 *sidsbuf_end = NULL;
658 size_t sidsbuflen = 0;
659 size_t owner_len, group_len;
661 data->adjust_tz = false;
662 data->reparse_point = false;
665 * BB TODO: Add support for using the cached root handle.
666 * Create SMB2_query_posix_info worker function to do non-compounded query
667 * when we already have an open file handle for this. For now this is fast enough
668 * (always using the compounded version).
671 cifs_get_readable_path(tcon, full_path, &cfile);
672 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, FILE_READ_ATTRIBUTES, FILE_OPEN,
673 create_options, ACL_NO_MODE, data, SMB2_OP_POSIX_QUERY_INFO, cfile,
674 &sidsbuf, &sidsbuflen, out_iov, out_buftype);
676 * If first iov is unset, then SMB session was dropped or we've got a
677 * cached open file (@cfile).
679 if (!out_iov[0].iov_base || out_buftype[0] == CIFS_NO_BUFFER)
685 /* BB TODO: When support for special files added to Samba re-verify this path */
686 rc = parse_create_response(data, cifs_sb, &out_iov[0]);
687 if (rc || !data->reparse_point)
690 create_options |= OPEN_REPARSE_POINT;
691 /* Failed on a symbolic link - query a reparse point info */
692 cifs_get_readable_path(tcon, full_path, &cfile);
693 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, FILE_READ_ATTRIBUTES,
694 FILE_OPEN, create_options, ACL_NO_MODE, data,
695 SMB2_OP_POSIX_QUERY_INFO, cfile,
696 &sidsbuf, &sidsbuflen, NULL, NULL);
702 sidsbuf_end = sidsbuf + sidsbuflen;
704 owner_len = posix_info_sid_size(sidsbuf, sidsbuf_end);
705 if (owner_len == -1) {
709 memcpy(owner, sidsbuf, owner_len);
711 group_len = posix_info_sid_size(
712 sidsbuf + owner_len, sidsbuf_end);
713 if (group_len == -1) {
717 memcpy(group, sidsbuf + owner_len, group_len);
721 free_rsp_buf(out_buftype[0], out_iov[0].iov_base);
722 free_rsp_buf(out_buftype[1], out_iov[1].iov_base);
723 free_rsp_buf(out_buftype[2], out_iov[2].iov_base);
728 smb2_mkdir(const unsigned int xid, struct inode *parent_inode, umode_t mode,
729 struct cifs_tcon *tcon, const char *name,
730 struct cifs_sb_info *cifs_sb)
732 return smb2_compound_op(xid, tcon, cifs_sb, name,
733 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
734 CREATE_NOT_FILE, mode, NULL, SMB2_OP_MKDIR,
735 NULL, NULL, NULL, NULL, NULL);
739 smb2_mkdir_setinfo(struct inode *inode, const char *name,
740 struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
741 const unsigned int xid)
743 FILE_BASIC_INFO data;
744 struct cifsInodeInfo *cifs_i;
745 struct cifsFileInfo *cfile;
749 memset(&data, 0, sizeof(data));
750 cifs_i = CIFS_I(inode);
751 dosattrs = cifs_i->cifsAttrs | ATTR_READONLY;
752 data.Attributes = cpu_to_le32(dosattrs);
753 cifs_get_writable_path(tcon, name, FIND_WR_ANY, &cfile);
754 tmprc = smb2_compound_op(xid, tcon, cifs_sb, name,
755 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
756 CREATE_NOT_FILE, ACL_NO_MODE,
757 &data, SMB2_OP_SET_INFO, cfile, NULL, NULL, NULL, NULL);
759 cifs_i->cifsAttrs = dosattrs;
763 smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
764 struct cifs_sb_info *cifs_sb)
766 drop_cached_dir_by_name(xid, tcon, name, cifs_sb);
767 return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
768 CREATE_NOT_FILE, ACL_NO_MODE,
769 NULL, SMB2_OP_RMDIR, NULL, NULL, NULL, NULL, NULL);
773 smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
774 struct cifs_sb_info *cifs_sb)
776 return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
777 CREATE_DELETE_ON_CLOSE | OPEN_REPARSE_POINT,
778 ACL_NO_MODE, NULL, SMB2_OP_DELETE, NULL, NULL, NULL, NULL, NULL);
782 smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon,
783 const char *from_name, const char *to_name,
784 struct cifs_sb_info *cifs_sb, __u32 access, int command,
785 struct cifsFileInfo *cfile)
787 __le16 *smb2_to_name = NULL;
790 smb2_to_name = cifs_convert_path_to_utf16(to_name, cifs_sb);
791 if (smb2_to_name == NULL) {
793 goto smb2_rename_path;
795 rc = smb2_compound_op(xid, tcon, cifs_sb, from_name, access,
796 FILE_OPEN, 0, ACL_NO_MODE, smb2_to_name,
797 command, cfile, NULL, NULL, NULL, NULL);
804 smb2_rename_path(const unsigned int xid, struct cifs_tcon *tcon,
805 const char *from_name, const char *to_name,
806 struct cifs_sb_info *cifs_sb)
808 struct cifsFileInfo *cfile;
810 drop_cached_dir_by_name(xid, tcon, from_name, cifs_sb);
811 cifs_get_writable_path(tcon, from_name, FIND_WR_WITH_DELETE, &cfile);
813 return smb2_set_path_attr(xid, tcon, from_name, to_name,
814 cifs_sb, DELETE, SMB2_OP_RENAME, cfile);
818 smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
819 const char *from_name, const char *to_name,
820 struct cifs_sb_info *cifs_sb)
822 return smb2_set_path_attr(xid, tcon, from_name, to_name, cifs_sb,
823 FILE_READ_ATTRIBUTES, SMB2_OP_HARDLINK,
828 smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
829 const char *full_path, __u64 size,
830 struct cifs_sb_info *cifs_sb, bool set_alloc)
832 __le64 eof = cpu_to_le64(size);
833 struct cifsFileInfo *cfile;
835 cifs_get_writable_path(tcon, full_path, FIND_WR_ANY, &cfile);
836 return smb2_compound_op(xid, tcon, cifs_sb, full_path,
837 FILE_WRITE_DATA, FILE_OPEN, 0, ACL_NO_MODE,
838 &eof, SMB2_OP_SET_EOF, cfile, NULL, NULL, NULL, NULL);
842 smb2_set_file_info(struct inode *inode, const char *full_path,
843 FILE_BASIC_INFO *buf, const unsigned int xid)
845 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
846 struct tcon_link *tlink;
847 struct cifs_tcon *tcon;
848 struct cifsFileInfo *cfile;
851 if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) &&
852 (buf->LastWriteTime == 0) && (buf->ChangeTime == 0) &&
853 (buf->Attributes == 0))
854 return 0; /* would be a no op, no sense sending this */
856 tlink = cifs_sb_tlink(cifs_sb);
858 return PTR_ERR(tlink);
859 tcon = tlink_tcon(tlink);
861 cifs_get_writable_path(tcon, full_path, FIND_WR_ANY, &cfile);
862 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
863 FILE_WRITE_ATTRIBUTES, FILE_OPEN,
864 0, ACL_NO_MODE, buf, SMB2_OP_SET_INFO, cfile,
865 NULL, NULL, NULL, NULL);
866 cifs_put_tlink(tlink);