1 // SPDX-License-Identifier: LGPL-2.1
4 * Copyright (C) International Business Machines Corp., 2002, 2011
6 * Author(s): Pavel Shilovsky (pshilovsky@samba.org),
7 * Steve French (sfrench@us.ibm.com)
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]);
40 struct cifs_open_parms oparms;
41 struct kvec rsp_iov[3];
42 struct smb_rqst rqst[3];
43 struct kvec open_iov[SMB2_CREATE_IOV_SIZE];
44 struct kvec qi_iov[1];
45 struct kvec si_iov[SMB2_SET_INFO_IOV_SIZE];
46 struct kvec close_iov[1];
47 struct smb2_file_rename_info rename_info;
48 struct smb2_file_link_info link_info;
52 * note: If cfile is passed, the reference to it is dropped here.
53 * So make sure that you do not reuse cfile after return from this func.
55 * If passing @err_iov and @err_buftype, ensure to make them both large enough (>= 3) to hold all
56 * error responses. Caller is also responsible for freeing them up.
58 static int smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
59 struct cifs_sb_info *cifs_sb, const char *full_path,
60 __u32 desired_access, __u32 create_disposition, __u32 create_options,
61 umode_t mode, void *ptr, int command, struct cifsFileInfo *cfile,
62 __u8 **extbuf, size_t *extbuflen,
63 struct kvec *err_iov, int *err_buftype)
65 struct cop_vars *vars = NULL;
67 struct smb_rqst *rqst;
69 __le16 *utf16_path = NULL;
70 __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
72 struct cifs_ses *ses = tcon->ses;
73 struct TCP_Server_Info *server;
76 struct smb2_query_info_rsp *qi_rsp = NULL;
77 struct cifs_open_info_data *idata;
79 __u8 delete_pending[8] = {1, 0, 0, 0, 0, 0, 0, 0};
84 vars = kzalloc(sizeof(*vars), GFP_ATOMIC);
87 rqst = &vars->rqst[0];
88 rsp_iov = &vars->rsp_iov[0];
90 server = cifs_pick_channel(ses);
92 if (smb3_encryption_required(tcon))
93 flags |= CIFS_TRANSFORM_REQ;
95 resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
97 /* We already have a handle so we can skip the open */
102 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
108 vars->oparms = (struct cifs_open_parms) {
110 .desired_access = desired_access,
111 .disposition = create_disposition,
112 .create_options = cifs_create_options(cifs_sb, create_options),
118 rqst[num_rqst].rq_iov = &vars->open_iov[0];
119 rqst[num_rqst].rq_nvec = SMB2_CREATE_IOV_SIZE;
120 rc = SMB2_open_init(tcon, server,
121 &rqst[num_rqst], &oplock, &vars->oparms,
127 smb2_set_next_command(tcon, &rqst[num_rqst]);
134 case SMB2_OP_QUERY_INFO:
135 rqst[num_rqst].rq_iov = &vars->qi_iov[0];
136 rqst[num_rqst].rq_nvec = 1;
139 rc = SMB2_query_info_init(tcon, server,
141 cfile->fid.persistent_fid,
142 cfile->fid.volatile_fid,
143 FILE_ALL_INFORMATION,
145 sizeof(struct smb2_file_all_info) +
146 PATH_MAX * 2, 0, NULL);
148 rc = SMB2_query_info_init(tcon, server,
152 FILE_ALL_INFORMATION,
154 sizeof(struct smb2_file_all_info) +
155 PATH_MAX * 2, 0, NULL);
157 smb2_set_next_command(tcon, &rqst[num_rqst]);
158 smb2_set_related(&rqst[num_rqst]);
165 trace_smb3_query_info_compound_enter(xid, ses->Suid, tcon->tid,
168 case SMB2_OP_POSIX_QUERY_INFO:
169 rqst[num_rqst].rq_iov = &vars->qi_iov[0];
170 rqst[num_rqst].rq_nvec = 1;
173 rc = SMB2_query_info_init(tcon, server,
175 cfile->fid.persistent_fid,
176 cfile->fid.volatile_fid,
177 SMB_FIND_FILE_POSIX_INFO,
179 /* TBD: fix following to allow for longer SIDs */
180 sizeof(struct smb311_posix_qinfo *) + (PATH_MAX * 2) +
181 (sizeof(struct cifs_sid) * 2), 0, NULL);
183 rc = SMB2_query_info_init(tcon, server,
187 SMB_FIND_FILE_POSIX_INFO,
189 sizeof(struct smb311_posix_qinfo *) + (PATH_MAX * 2) +
190 (sizeof(struct cifs_sid) * 2), 0, NULL);
192 smb2_set_next_command(tcon, &rqst[num_rqst]);
193 smb2_set_related(&rqst[num_rqst]);
200 trace_smb3_posix_query_info_compound_enter(xid, ses->Suid, tcon->tid, full_path);
203 trace_smb3_delete_enter(xid, ses->Suid, tcon->tid, full_path);
207 * Directories are created through parameters in the
210 trace_smb3_mkdir_enter(xid, ses->Suid, tcon->tid, full_path);
213 rqst[num_rqst].rq_iov = &vars->si_iov[0];
214 rqst[num_rqst].rq_nvec = 1;
216 size[0] = 1; /* sizeof __u8 See MS-FSCC section 2.4.11 */
217 data[0] = &delete_pending[0];
219 rc = SMB2_set_info_init(tcon, server,
220 &rqst[num_rqst], COMPOUND_FID,
221 COMPOUND_FID, current->tgid,
222 FILE_DISPOSITION_INFORMATION,
223 SMB2_O_INFO_FILE, 0, data, size);
226 smb2_set_next_command(tcon, &rqst[num_rqst]);
227 smb2_set_related(&rqst[num_rqst++]);
228 trace_smb3_rmdir_enter(xid, ses->Suid, tcon->tid, full_path);
230 case SMB2_OP_SET_EOF:
231 rqst[num_rqst].rq_iov = &vars->si_iov[0];
232 rqst[num_rqst].rq_nvec = 1;
234 size[0] = 8; /* sizeof __le64 */
238 rc = SMB2_set_info_init(tcon, server,
240 cfile->fid.persistent_fid,
241 cfile->fid.volatile_fid,
243 FILE_END_OF_FILE_INFORMATION,
247 rc = SMB2_set_info_init(tcon, server,
252 FILE_END_OF_FILE_INFORMATION,
256 smb2_set_next_command(tcon, &rqst[num_rqst]);
257 smb2_set_related(&rqst[num_rqst]);
263 trace_smb3_set_eof_enter(xid, ses->Suid, tcon->tid, full_path);
265 case SMB2_OP_SET_INFO:
266 rqst[num_rqst].rq_iov = &vars->si_iov[0];
267 rqst[num_rqst].rq_nvec = 1;
270 size[0] = sizeof(FILE_BASIC_INFO);
274 rc = SMB2_set_info_init(tcon, server,
276 cfile->fid.persistent_fid,
277 cfile->fid.volatile_fid, current->tgid,
278 FILE_BASIC_INFORMATION,
279 SMB2_O_INFO_FILE, 0, data, size);
281 rc = SMB2_set_info_init(tcon, server,
284 COMPOUND_FID, current->tgid,
285 FILE_BASIC_INFORMATION,
286 SMB2_O_INFO_FILE, 0, data, size);
288 smb2_set_next_command(tcon, &rqst[num_rqst]);
289 smb2_set_related(&rqst[num_rqst]);
296 trace_smb3_set_info_compound_enter(xid, ses->Suid, tcon->tid,
300 rqst[num_rqst].rq_iov = &vars->si_iov[0];
301 rqst[num_rqst].rq_nvec = 2;
303 len = (2 * UniStrnlen((wchar_t *)ptr, PATH_MAX));
305 vars->rename_info.ReplaceIfExists = 1;
306 vars->rename_info.RootDirectory = 0;
307 vars->rename_info.FileNameLength = cpu_to_le32(len);
309 size[0] = sizeof(struct smb2_file_rename_info);
310 data[0] = &vars->rename_info;
312 size[1] = len + 2 /* null */;
313 data[1] = (__le16 *)ptr;
316 rc = SMB2_set_info_init(tcon, server,
318 cfile->fid.persistent_fid,
319 cfile->fid.volatile_fid,
320 current->tgid, FILE_RENAME_INFORMATION,
321 SMB2_O_INFO_FILE, 0, data, size);
323 rc = SMB2_set_info_init(tcon, server,
325 COMPOUND_FID, COMPOUND_FID,
326 current->tgid, FILE_RENAME_INFORMATION,
327 SMB2_O_INFO_FILE, 0, data, size);
329 smb2_set_next_command(tcon, &rqst[num_rqst]);
330 smb2_set_related(&rqst[num_rqst]);
336 trace_smb3_rename_enter(xid, ses->Suid, tcon->tid, full_path);
338 case SMB2_OP_HARDLINK:
339 rqst[num_rqst].rq_iov = &vars->si_iov[0];
340 rqst[num_rqst].rq_nvec = 2;
342 len = (2 * UniStrnlen((wchar_t *)ptr, PATH_MAX));
344 vars->link_info.ReplaceIfExists = 0;
345 vars->link_info.RootDirectory = 0;
346 vars->link_info.FileNameLength = cpu_to_le32(len);
348 size[0] = sizeof(struct smb2_file_link_info);
349 data[0] = &vars->link_info;
351 size[1] = len + 2 /* null */;
352 data[1] = (__le16 *)ptr;
354 rc = SMB2_set_info_init(tcon, server,
355 &rqst[num_rqst], COMPOUND_FID,
356 COMPOUND_FID, current->tgid,
357 FILE_LINK_INFORMATION,
358 SMB2_O_INFO_FILE, 0, data, size);
361 smb2_set_next_command(tcon, &rqst[num_rqst]);
362 smb2_set_related(&rqst[num_rqst++]);
363 trace_smb3_hardlink_enter(xid, ses->Suid, tcon->tid, full_path);
366 cifs_dbg(VFS, "Invalid command\n");
372 /* We already have a handle so we can skip the close */
376 flags |= CIFS_CP_CREATE_CLOSE_OP;
377 rqst[num_rqst].rq_iov = &vars->close_iov[0];
378 rqst[num_rqst].rq_nvec = 1;
379 rc = SMB2_close_init(tcon, server,
380 &rqst[num_rqst], COMPOUND_FID,
381 COMPOUND_FID, false);
382 smb2_set_related(&rqst[num_rqst]);
389 rc = compound_send_recv(xid, ses, server,
391 &rqst[1], &resp_buftype[1],
394 rc = compound_send_recv(xid, ses, server,
401 cifsFileInfo_put(cfile);
403 SMB2_open_free(&rqst[0]);
404 if (rc == -EREMCHG) {
405 pr_warn_once("server share %s deleted\n", tcon->tree_name);
406 tcon->need_reconnect = true;
410 case SMB2_OP_QUERY_INFO:
412 if (rc == 0 && cfile && cfile->symlink_target) {
413 idata->symlink_target = kstrdup(cfile->symlink_target, GFP_KERNEL);
414 if (!idata->symlink_target)
418 qi_rsp = (struct smb2_query_info_rsp *)
420 rc = smb2_validate_and_copy_iov(
421 le16_to_cpu(qi_rsp->OutputBufferOffset),
422 le32_to_cpu(qi_rsp->OutputBufferLength),
423 &rsp_iov[1], sizeof(idata->fi), (char *)&idata->fi);
426 SMB2_query_info_free(&rqst[1]);
428 SMB2_close_free(&rqst[2]);
430 trace_smb3_query_info_compound_err(xid, ses->Suid,
433 trace_smb3_query_info_compound_done(xid, ses->Suid,
436 case SMB2_OP_POSIX_QUERY_INFO:
438 if (rc == 0 && cfile && cfile->symlink_target) {
439 idata->symlink_target = kstrdup(cfile->symlink_target, GFP_KERNEL);
440 if (!idata->symlink_target)
444 qi_rsp = (struct smb2_query_info_rsp *)
446 rc = smb2_validate_and_copy_iov(
447 le16_to_cpu(qi_rsp->OutputBufferOffset),
448 le32_to_cpu(qi_rsp->OutputBufferLength),
449 &rsp_iov[1], sizeof(idata->posix_fi) /* add SIDs */,
450 (char *)&idata->posix_fi);
453 unsigned int length = le32_to_cpu(qi_rsp->OutputBufferLength);
455 if (length > sizeof(idata->posix_fi)) {
456 char *base = (char *)rsp_iov[1].iov_base +
457 le16_to_cpu(qi_rsp->OutputBufferOffset) +
458 sizeof(idata->posix_fi);
459 *extbuflen = length - sizeof(idata->posix_fi);
460 *extbuf = kmemdup(base, *extbuflen, GFP_KERNEL);
468 SMB2_query_info_free(&rqst[1]);
470 SMB2_close_free(&rqst[2]);
472 trace_smb3_posix_query_info_compound_err(xid, ses->Suid, tcon->tid, rc);
474 trace_smb3_posix_query_info_compound_done(xid, ses->Suid, tcon->tid);
478 trace_smb3_delete_err(xid, ses->Suid, tcon->tid, rc);
480 trace_smb3_delete_done(xid, ses->Suid, tcon->tid);
482 SMB2_close_free(&rqst[1]);
486 trace_smb3_mkdir_err(xid, ses->Suid, tcon->tid, rc);
488 trace_smb3_mkdir_done(xid, ses->Suid, tcon->tid);
490 SMB2_close_free(&rqst[1]);
492 case SMB2_OP_HARDLINK:
494 trace_smb3_hardlink_err(xid, ses->Suid, tcon->tid, rc);
496 trace_smb3_hardlink_done(xid, ses->Suid, tcon->tid);
497 free_set_inf_compound(rqst);
501 trace_smb3_rename_err(xid, ses->Suid, tcon->tid, rc);
503 trace_smb3_rename_done(xid, ses->Suid, tcon->tid);
504 free_set_inf_compound(rqst);
508 trace_smb3_rmdir_err(xid, ses->Suid, tcon->tid, rc);
510 trace_smb3_rmdir_done(xid, ses->Suid, tcon->tid);
511 free_set_inf_compound(rqst);
513 case SMB2_OP_SET_EOF:
515 trace_smb3_set_eof_err(xid, ses->Suid, tcon->tid, rc);
517 trace_smb3_set_eof_done(xid, ses->Suid, tcon->tid);
518 free_set_inf_compound(rqst);
520 case SMB2_OP_SET_INFO:
522 trace_smb3_set_info_compound_err(xid, ses->Suid,
525 trace_smb3_set_info_compound_done(xid, ses->Suid,
527 free_set_inf_compound(rqst);
531 if (rc && err_iov && err_buftype) {
532 memcpy(err_iov, rsp_iov, 3 * sizeof(*err_iov));
533 memcpy(err_buftype, resp_buftype, 3 * sizeof(*err_buftype));
535 free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base);
536 free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
537 free_rsp_buf(resp_buftype[2], rsp_iov[2].iov_base);
543 int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
544 struct cifs_sb_info *cifs_sb, const char *full_path,
545 struct cifs_open_info_data *data, bool *adjust_tz, bool *reparse)
547 __u32 create_options = 0;
548 struct cifsFileInfo *cfile;
549 struct cached_fid *cfid = NULL;
550 struct kvec err_iov[3] = {};
551 int err_buftype[3] = {};
558 if (strcmp(full_path, ""))
561 rc = open_cached_dir(xid, tcon, full_path, cifs_sb, false, &cfid);
562 /* If it is a root and its handle is cached then use it */
564 if (cfid->file_all_info_is_valid) {
565 memcpy(&data->fi, &cfid->file_all_info, sizeof(data->fi));
567 rc = SMB2_query_info(xid, tcon, cfid->fid.persistent_fid,
568 cfid->fid.volatile_fid, &data->fi);
570 close_cached_dir(cfid);
574 cifs_get_readable_path(tcon, full_path, &cfile);
575 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, FILE_READ_ATTRIBUTES, FILE_OPEN,
576 create_options, ACL_NO_MODE, data, SMB2_OP_QUERY_INFO, cfile,
577 NULL, NULL, err_iov, err_buftype);
579 struct smb2_hdr *hdr = err_iov[0].iov_base;
581 if (unlikely(!hdr || err_buftype[0] == CIFS_NO_BUFFER))
583 if (rc == -EOPNOTSUPP && hdr->Command == SMB2_CREATE &&
584 hdr->Status == STATUS_STOPPED_ON_SYMLINK) {
585 rc = smb2_parse_symlink_response(cifs_sb, err_iov,
586 &data->symlink_target);
591 create_options |= OPEN_REPARSE_POINT;
593 /* Failed on a symbolic link - query a reparse point info */
594 cifs_get_readable_path(tcon, full_path, &cfile);
595 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
596 FILE_READ_ATTRIBUTES, FILE_OPEN,
597 create_options, ACL_NO_MODE, data,
598 SMB2_OP_QUERY_INFO, cfile, NULL, NULL,
601 } else if (rc != -EREMOTE && hdr->Status == STATUS_OBJECT_NAME_INVALID) {
602 rc2 = cifs_inval_name_dfs_link_error(xid, tcon, cifs_sb,
611 if (rc == -EREMOTE && IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) && cifs_sb &&
612 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS))
617 free_rsp_buf(err_buftype[0], err_iov[0].iov_base);
618 free_rsp_buf(err_buftype[1], err_iov[1].iov_base);
619 free_rsp_buf(err_buftype[2], err_iov[2].iov_base);
624 int smb311_posix_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
625 struct cifs_sb_info *cifs_sb, const char *full_path,
626 struct cifs_open_info_data *data,
627 struct cifs_sid *owner,
628 struct cifs_sid *group,
629 bool *adjust_tz, bool *reparse)
632 __u32 create_options = 0;
633 struct cifsFileInfo *cfile;
634 struct kvec err_iov[3] = {};
635 int err_buftype[3] = {};
636 __u8 *sidsbuf = NULL;
637 __u8 *sidsbuf_end = NULL;
638 size_t sidsbuflen = 0;
639 size_t owner_len, group_len;
645 * BB TODO: Add support for using the cached root handle.
646 * Create SMB2_query_posix_info worker function to do non-compounded query
647 * when we already have an open file handle for this. For now this is fast enough
648 * (always using the compounded version).
651 cifs_get_readable_path(tcon, full_path, &cfile);
652 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, FILE_READ_ATTRIBUTES, FILE_OPEN,
653 create_options, ACL_NO_MODE, data, SMB2_OP_POSIX_QUERY_INFO, cfile,
654 &sidsbuf, &sidsbuflen, err_iov, err_buftype);
655 if (rc == -EOPNOTSUPP) {
656 /* BB TODO: When support for special files added to Samba re-verify this path */
657 if (err_iov[0].iov_base && err_buftype[0] != CIFS_NO_BUFFER &&
658 ((struct smb2_hdr *)err_iov[0].iov_base)->Command == SMB2_CREATE &&
659 ((struct smb2_hdr *)err_iov[0].iov_base)->Status == STATUS_STOPPED_ON_SYMLINK) {
660 rc = smb2_parse_symlink_response(cifs_sb, err_iov, &data->symlink_target);
665 create_options |= OPEN_REPARSE_POINT;
667 /* Failed on a symbolic link - query a reparse point info */
668 cifs_get_readable_path(tcon, full_path, &cfile);
669 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, FILE_READ_ATTRIBUTES,
670 FILE_OPEN, create_options, ACL_NO_MODE, data,
671 SMB2_OP_POSIX_QUERY_INFO, cfile,
672 &sidsbuf, &sidsbuflen, NULL, NULL);
676 sidsbuf_end = sidsbuf + sidsbuflen;
678 owner_len = posix_info_sid_size(sidsbuf, sidsbuf_end);
679 if (owner_len == -1) {
683 memcpy(owner, sidsbuf, owner_len);
685 group_len = posix_info_sid_size(
686 sidsbuf + owner_len, sidsbuf_end);
687 if (group_len == -1) {
691 memcpy(group, sidsbuf + owner_len, group_len);
696 free_rsp_buf(err_buftype[0], err_iov[0].iov_base);
697 free_rsp_buf(err_buftype[1], err_iov[1].iov_base);
698 free_rsp_buf(err_buftype[2], err_iov[2].iov_base);
703 smb2_mkdir(const unsigned int xid, struct inode *parent_inode, umode_t mode,
704 struct cifs_tcon *tcon, const char *name,
705 struct cifs_sb_info *cifs_sb)
707 return smb2_compound_op(xid, tcon, cifs_sb, name,
708 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
709 CREATE_NOT_FILE, mode, NULL, SMB2_OP_MKDIR,
710 NULL, NULL, NULL, NULL, NULL);
714 smb2_mkdir_setinfo(struct inode *inode, const char *name,
715 struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
716 const unsigned int xid)
718 FILE_BASIC_INFO data;
719 struct cifsInodeInfo *cifs_i;
720 struct cifsFileInfo *cfile;
724 memset(&data, 0, sizeof(data));
725 cifs_i = CIFS_I(inode);
726 dosattrs = cifs_i->cifsAttrs | ATTR_READONLY;
727 data.Attributes = cpu_to_le32(dosattrs);
728 cifs_get_writable_path(tcon, name, FIND_WR_ANY, &cfile);
729 tmprc = smb2_compound_op(xid, tcon, cifs_sb, name,
730 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
731 CREATE_NOT_FILE, ACL_NO_MODE,
732 &data, SMB2_OP_SET_INFO, cfile, NULL, NULL, NULL, NULL);
734 cifs_i->cifsAttrs = dosattrs;
738 smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
739 struct cifs_sb_info *cifs_sb)
741 drop_cached_dir_by_name(xid, tcon, name, cifs_sb);
742 return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
743 CREATE_NOT_FILE, ACL_NO_MODE,
744 NULL, SMB2_OP_RMDIR, NULL, NULL, NULL, NULL, NULL);
748 smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
749 struct cifs_sb_info *cifs_sb)
751 return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
752 CREATE_DELETE_ON_CLOSE | OPEN_REPARSE_POINT,
753 ACL_NO_MODE, NULL, SMB2_OP_DELETE, NULL, NULL, NULL, NULL, NULL);
757 smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon,
758 const char *from_name, const char *to_name,
759 struct cifs_sb_info *cifs_sb, __u32 access, int command,
760 struct cifsFileInfo *cfile)
762 __le16 *smb2_to_name = NULL;
765 smb2_to_name = cifs_convert_path_to_utf16(to_name, cifs_sb);
766 if (smb2_to_name == NULL) {
768 goto smb2_rename_path;
770 rc = smb2_compound_op(xid, tcon, cifs_sb, from_name, access,
771 FILE_OPEN, 0, ACL_NO_MODE, smb2_to_name,
772 command, cfile, NULL, NULL, NULL, NULL);
779 smb2_rename_path(const unsigned int xid, struct cifs_tcon *tcon,
780 const char *from_name, const char *to_name,
781 struct cifs_sb_info *cifs_sb)
783 struct cifsFileInfo *cfile;
785 drop_cached_dir_by_name(xid, tcon, from_name, cifs_sb);
786 cifs_get_writable_path(tcon, from_name, FIND_WR_WITH_DELETE, &cfile);
788 return smb2_set_path_attr(xid, tcon, from_name, to_name,
789 cifs_sb, DELETE, SMB2_OP_RENAME, cfile);
793 smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
794 const char *from_name, const char *to_name,
795 struct cifs_sb_info *cifs_sb)
797 return smb2_set_path_attr(xid, tcon, from_name, to_name, cifs_sb,
798 FILE_READ_ATTRIBUTES, SMB2_OP_HARDLINK,
803 smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
804 const char *full_path, __u64 size,
805 struct cifs_sb_info *cifs_sb, bool set_alloc)
807 __le64 eof = cpu_to_le64(size);
808 struct cifsFileInfo *cfile;
810 cifs_get_writable_path(tcon, full_path, FIND_WR_ANY, &cfile);
811 return smb2_compound_op(xid, tcon, cifs_sb, full_path,
812 FILE_WRITE_DATA, FILE_OPEN, 0, ACL_NO_MODE,
813 &eof, SMB2_OP_SET_EOF, cfile, NULL, NULL, NULL, NULL);
817 smb2_set_file_info(struct inode *inode, const char *full_path,
818 FILE_BASIC_INFO *buf, const unsigned int xid)
820 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
821 struct tcon_link *tlink;
822 struct cifs_tcon *tcon;
823 struct cifsFileInfo *cfile;
826 if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) &&
827 (buf->LastWriteTime == 0) && (buf->ChangeTime == 0) &&
828 (buf->Attributes == 0))
829 return 0; /* would be a no op, no sense sending this */
831 tlink = cifs_sb_tlink(cifs_sb);
833 return PTR_ERR(tlink);
834 tcon = tlink_tcon(tlink);
836 cifs_get_writable_path(tcon, full_path, FIND_WR_ANY, &cfile);
837 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
838 FILE_WRITE_ATTRIBUTES, FILE_OPEN,
839 0, ACL_NO_MODE, buf, SMB2_OP_SET_INFO, cfile,
840 NULL, NULL, NULL, NULL);
841 cifs_put_tlink(tlink);