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) {
111 .desired_access = desired_access,
112 .disposition = create_disposition,
113 .create_options = cifs_create_options(cifs_sb, create_options),
119 rqst[num_rqst].rq_iov = &vars->open_iov[0];
120 rqst[num_rqst].rq_nvec = SMB2_CREATE_IOV_SIZE;
121 rc = SMB2_open_init(tcon, server,
122 &rqst[num_rqst], &oplock, &vars->oparms,
128 smb2_set_next_command(tcon, &rqst[num_rqst]);
135 case SMB2_OP_QUERY_INFO:
136 rqst[num_rqst].rq_iov = &vars->qi_iov[0];
137 rqst[num_rqst].rq_nvec = 1;
140 rc = SMB2_query_info_init(tcon, server,
142 cfile->fid.persistent_fid,
143 cfile->fid.volatile_fid,
144 FILE_ALL_INFORMATION,
146 sizeof(struct smb2_file_all_info) +
147 PATH_MAX * 2, 0, NULL);
149 rc = SMB2_query_info_init(tcon, server,
153 FILE_ALL_INFORMATION,
155 sizeof(struct smb2_file_all_info) +
156 PATH_MAX * 2, 0, NULL);
158 smb2_set_next_command(tcon, &rqst[num_rqst]);
159 smb2_set_related(&rqst[num_rqst]);
166 trace_smb3_query_info_compound_enter(xid, ses->Suid, tcon->tid,
169 case SMB2_OP_POSIX_QUERY_INFO:
170 rqst[num_rqst].rq_iov = &vars->qi_iov[0];
171 rqst[num_rqst].rq_nvec = 1;
174 rc = SMB2_query_info_init(tcon, server,
176 cfile->fid.persistent_fid,
177 cfile->fid.volatile_fid,
178 SMB_FIND_FILE_POSIX_INFO,
180 /* TBD: fix following to allow for longer SIDs */
181 sizeof(struct smb311_posix_qinfo *) + (PATH_MAX * 2) +
182 (sizeof(struct cifs_sid) * 2), 0, NULL);
184 rc = SMB2_query_info_init(tcon, server,
188 SMB_FIND_FILE_POSIX_INFO,
190 sizeof(struct smb311_posix_qinfo *) + (PATH_MAX * 2) +
191 (sizeof(struct cifs_sid) * 2), 0, NULL);
193 smb2_set_next_command(tcon, &rqst[num_rqst]);
194 smb2_set_related(&rqst[num_rqst]);
201 trace_smb3_posix_query_info_compound_enter(xid, ses->Suid, tcon->tid, full_path);
204 trace_smb3_delete_enter(xid, ses->Suid, tcon->tid, full_path);
208 * Directories are created through parameters in the
211 trace_smb3_mkdir_enter(xid, ses->Suid, tcon->tid, full_path);
214 rqst[num_rqst].rq_iov = &vars->si_iov[0];
215 rqst[num_rqst].rq_nvec = 1;
217 size[0] = 1; /* sizeof __u8 See MS-FSCC section 2.4.11 */
218 data[0] = &delete_pending[0];
220 rc = SMB2_set_info_init(tcon, server,
221 &rqst[num_rqst], COMPOUND_FID,
222 COMPOUND_FID, current->tgid,
223 FILE_DISPOSITION_INFORMATION,
224 SMB2_O_INFO_FILE, 0, data, size);
227 smb2_set_next_command(tcon, &rqst[num_rqst]);
228 smb2_set_related(&rqst[num_rqst++]);
229 trace_smb3_rmdir_enter(xid, ses->Suid, tcon->tid, full_path);
231 case SMB2_OP_SET_EOF:
232 rqst[num_rqst].rq_iov = &vars->si_iov[0];
233 rqst[num_rqst].rq_nvec = 1;
235 size[0] = 8; /* sizeof __le64 */
239 rc = SMB2_set_info_init(tcon, server,
241 cfile->fid.persistent_fid,
242 cfile->fid.volatile_fid,
244 FILE_END_OF_FILE_INFORMATION,
248 rc = SMB2_set_info_init(tcon, server,
253 FILE_END_OF_FILE_INFORMATION,
257 smb2_set_next_command(tcon, &rqst[num_rqst]);
258 smb2_set_related(&rqst[num_rqst]);
264 trace_smb3_set_eof_enter(xid, ses->Suid, tcon->tid, full_path);
266 case SMB2_OP_SET_INFO:
267 rqst[num_rqst].rq_iov = &vars->si_iov[0];
268 rqst[num_rqst].rq_nvec = 1;
271 size[0] = sizeof(FILE_BASIC_INFO);
275 rc = SMB2_set_info_init(tcon, server,
277 cfile->fid.persistent_fid,
278 cfile->fid.volatile_fid, current->tgid,
279 FILE_BASIC_INFORMATION,
280 SMB2_O_INFO_FILE, 0, data, size);
282 rc = SMB2_set_info_init(tcon, server,
285 COMPOUND_FID, current->tgid,
286 FILE_BASIC_INFORMATION,
287 SMB2_O_INFO_FILE, 0, data, size);
289 smb2_set_next_command(tcon, &rqst[num_rqst]);
290 smb2_set_related(&rqst[num_rqst]);
297 trace_smb3_set_info_compound_enter(xid, ses->Suid, tcon->tid,
301 rqst[num_rqst].rq_iov = &vars->si_iov[0];
302 rqst[num_rqst].rq_nvec = 2;
304 len = (2 * UniStrnlen((wchar_t *)ptr, PATH_MAX));
306 vars->rename_info.ReplaceIfExists = 1;
307 vars->rename_info.RootDirectory = 0;
308 vars->rename_info.FileNameLength = cpu_to_le32(len);
310 size[0] = sizeof(struct smb2_file_rename_info);
311 data[0] = &vars->rename_info;
313 size[1] = len + 2 /* null */;
314 data[1] = (__le16 *)ptr;
317 rc = SMB2_set_info_init(tcon, server,
319 cfile->fid.persistent_fid,
320 cfile->fid.volatile_fid,
321 current->tgid, FILE_RENAME_INFORMATION,
322 SMB2_O_INFO_FILE, 0, data, size);
324 rc = SMB2_set_info_init(tcon, server,
326 COMPOUND_FID, COMPOUND_FID,
327 current->tgid, FILE_RENAME_INFORMATION,
328 SMB2_O_INFO_FILE, 0, data, size);
330 smb2_set_next_command(tcon, &rqst[num_rqst]);
331 smb2_set_related(&rqst[num_rqst]);
337 trace_smb3_rename_enter(xid, ses->Suid, tcon->tid, full_path);
339 case SMB2_OP_HARDLINK:
340 rqst[num_rqst].rq_iov = &vars->si_iov[0];
341 rqst[num_rqst].rq_nvec = 2;
343 len = (2 * UniStrnlen((wchar_t *)ptr, PATH_MAX));
345 vars->link_info.ReplaceIfExists = 0;
346 vars->link_info.RootDirectory = 0;
347 vars->link_info.FileNameLength = cpu_to_le32(len);
349 size[0] = sizeof(struct smb2_file_link_info);
350 data[0] = &vars->link_info;
352 size[1] = len + 2 /* null */;
353 data[1] = (__le16 *)ptr;
355 rc = SMB2_set_info_init(tcon, server,
356 &rqst[num_rqst], COMPOUND_FID,
357 COMPOUND_FID, current->tgid,
358 FILE_LINK_INFORMATION,
359 SMB2_O_INFO_FILE, 0, data, size);
362 smb2_set_next_command(tcon, &rqst[num_rqst]);
363 smb2_set_related(&rqst[num_rqst++]);
364 trace_smb3_hardlink_enter(xid, ses->Suid, tcon->tid, full_path);
367 cifs_dbg(VFS, "Invalid command\n");
373 /* We already have a handle so we can skip the close */
377 flags |= CIFS_CP_CREATE_CLOSE_OP;
378 rqst[num_rqst].rq_iov = &vars->close_iov[0];
379 rqst[num_rqst].rq_nvec = 1;
380 rc = SMB2_close_init(tcon, server,
381 &rqst[num_rqst], COMPOUND_FID,
382 COMPOUND_FID, false);
383 smb2_set_related(&rqst[num_rqst]);
390 rc = compound_send_recv(xid, ses, server,
392 &rqst[1], &resp_buftype[1],
395 rc = compound_send_recv(xid, ses, server,
401 SMB2_open_free(&rqst[0]);
402 if (rc == -EREMCHG) {
403 pr_warn_once("server share %s deleted\n", tcon->tree_name);
404 tcon->need_reconnect = true;
408 case SMB2_OP_QUERY_INFO:
410 if (rc == 0 && cfile && cfile->symlink_target) {
411 idata->symlink_target = kstrdup(cfile->symlink_target, GFP_KERNEL);
412 if (!idata->symlink_target)
416 qi_rsp = (struct smb2_query_info_rsp *)
418 rc = smb2_validate_and_copy_iov(
419 le16_to_cpu(qi_rsp->OutputBufferOffset),
420 le32_to_cpu(qi_rsp->OutputBufferLength),
421 &rsp_iov[1], sizeof(idata->fi), (char *)&idata->fi);
424 SMB2_query_info_free(&rqst[1]);
426 SMB2_close_free(&rqst[2]);
428 trace_smb3_query_info_compound_err(xid, ses->Suid,
431 trace_smb3_query_info_compound_done(xid, ses->Suid,
434 case SMB2_OP_POSIX_QUERY_INFO:
436 if (rc == 0 && cfile && cfile->symlink_target) {
437 idata->symlink_target = kstrdup(cfile->symlink_target, GFP_KERNEL);
438 if (!idata->symlink_target)
442 qi_rsp = (struct smb2_query_info_rsp *)
444 rc = smb2_validate_and_copy_iov(
445 le16_to_cpu(qi_rsp->OutputBufferOffset),
446 le32_to_cpu(qi_rsp->OutputBufferLength),
447 &rsp_iov[1], sizeof(idata->posix_fi) /* add SIDs */,
448 (char *)&idata->posix_fi);
451 unsigned int length = le32_to_cpu(qi_rsp->OutputBufferLength);
453 if (length > sizeof(idata->posix_fi)) {
454 char *base = (char *)rsp_iov[1].iov_base +
455 le16_to_cpu(qi_rsp->OutputBufferOffset) +
456 sizeof(idata->posix_fi);
457 *extbuflen = length - sizeof(idata->posix_fi);
458 *extbuf = kmemdup(base, *extbuflen, GFP_KERNEL);
466 SMB2_query_info_free(&rqst[1]);
468 SMB2_close_free(&rqst[2]);
470 trace_smb3_posix_query_info_compound_err(xid, ses->Suid, tcon->tid, rc);
472 trace_smb3_posix_query_info_compound_done(xid, ses->Suid, tcon->tid);
476 trace_smb3_delete_err(xid, ses->Suid, tcon->tid, rc);
478 trace_smb3_delete_done(xid, ses->Suid, tcon->tid);
480 SMB2_close_free(&rqst[1]);
484 trace_smb3_mkdir_err(xid, ses->Suid, tcon->tid, rc);
486 trace_smb3_mkdir_done(xid, ses->Suid, tcon->tid);
488 SMB2_close_free(&rqst[1]);
490 case SMB2_OP_HARDLINK:
492 trace_smb3_hardlink_err(xid, ses->Suid, tcon->tid, rc);
494 trace_smb3_hardlink_done(xid, ses->Suid, tcon->tid);
495 free_set_inf_compound(rqst);
499 trace_smb3_rename_err(xid, ses->Suid, tcon->tid, rc);
501 trace_smb3_rename_done(xid, ses->Suid, tcon->tid);
502 free_set_inf_compound(rqst);
506 trace_smb3_rmdir_err(xid, ses->Suid, tcon->tid, rc);
508 trace_smb3_rmdir_done(xid, ses->Suid, tcon->tid);
509 free_set_inf_compound(rqst);
511 case SMB2_OP_SET_EOF:
513 trace_smb3_set_eof_err(xid, ses->Suid, tcon->tid, rc);
515 trace_smb3_set_eof_done(xid, ses->Suid, tcon->tid);
516 free_set_inf_compound(rqst);
518 case SMB2_OP_SET_INFO:
520 trace_smb3_set_info_compound_err(xid, ses->Suid,
523 trace_smb3_set_info_compound_done(xid, ses->Suid,
525 free_set_inf_compound(rqst);
530 cifsFileInfo_put(cfile);
532 if (rc && err_iov && err_buftype) {
533 memcpy(err_iov, rsp_iov, 3 * sizeof(*err_iov));
534 memcpy(err_buftype, resp_buftype, 3 * sizeof(*err_buftype));
536 free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base);
537 free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
538 free_rsp_buf(resp_buftype[2], rsp_iov[2].iov_base);
544 int smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
545 struct cifs_sb_info *cifs_sb, const char *full_path,
546 struct cifs_open_info_data *data, bool *adjust_tz, bool *reparse)
548 __u32 create_options = 0;
549 struct cifsFileInfo *cfile;
550 struct cached_fid *cfid = NULL;
551 struct kvec err_iov[3] = {};
552 int err_buftype[3] = {};
559 if (strcmp(full_path, ""))
562 rc = open_cached_dir(xid, tcon, full_path, cifs_sb, false, &cfid);
563 /* If it is a root and its handle is cached then use it */
565 if (cfid->file_all_info_is_valid) {
566 memcpy(&data->fi, &cfid->file_all_info, sizeof(data->fi));
568 rc = SMB2_query_info(xid, tcon, cfid->fid.persistent_fid,
569 cfid->fid.volatile_fid, &data->fi);
571 close_cached_dir(cfid);
575 cifs_get_readable_path(tcon, full_path, &cfile);
576 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, FILE_READ_ATTRIBUTES, FILE_OPEN,
577 create_options, ACL_NO_MODE, data, SMB2_OP_QUERY_INFO, cfile,
578 NULL, NULL, err_iov, err_buftype);
580 struct smb2_hdr *hdr = err_iov[0].iov_base;
582 if (unlikely(!hdr || err_buftype[0] == CIFS_NO_BUFFER))
584 if (rc == -EOPNOTSUPP && hdr->Command == SMB2_CREATE &&
585 hdr->Status == STATUS_STOPPED_ON_SYMLINK) {
586 rc = smb2_parse_symlink_response(cifs_sb, err_iov,
587 &data->symlink_target);
592 create_options |= OPEN_REPARSE_POINT;
594 /* Failed on a symbolic link - query a reparse point info */
595 cifs_get_readable_path(tcon, full_path, &cfile);
596 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
597 FILE_READ_ATTRIBUTES, FILE_OPEN,
598 create_options, ACL_NO_MODE, data,
599 SMB2_OP_QUERY_INFO, cfile, NULL, NULL,
602 } else if (rc != -EREMOTE && hdr->Status == STATUS_OBJECT_NAME_INVALID) {
603 rc2 = cifs_inval_name_dfs_link_error(xid, tcon, cifs_sb,
612 if (rc == -EREMOTE && IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) && cifs_sb &&
613 (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS))
618 free_rsp_buf(err_buftype[0], err_iov[0].iov_base);
619 free_rsp_buf(err_buftype[1], err_iov[1].iov_base);
620 free_rsp_buf(err_buftype[2], err_iov[2].iov_base);
625 int smb311_posix_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
626 struct cifs_sb_info *cifs_sb, const char *full_path,
627 struct cifs_open_info_data *data,
628 struct cifs_sid *owner,
629 struct cifs_sid *group,
630 bool *adjust_tz, bool *reparse)
633 __u32 create_options = 0;
634 struct cifsFileInfo *cfile;
635 struct kvec err_iov[3] = {};
636 int err_buftype[3] = {};
637 __u8 *sidsbuf = NULL;
638 __u8 *sidsbuf_end = NULL;
639 size_t sidsbuflen = 0;
640 size_t owner_len, group_len;
646 * BB TODO: Add support for using the cached root handle.
647 * Create SMB2_query_posix_info worker function to do non-compounded query
648 * when we already have an open file handle for this. For now this is fast enough
649 * (always using the compounded version).
652 cifs_get_readable_path(tcon, full_path, &cfile);
653 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, FILE_READ_ATTRIBUTES, FILE_OPEN,
654 create_options, ACL_NO_MODE, data, SMB2_OP_POSIX_QUERY_INFO, cfile,
655 &sidsbuf, &sidsbuflen, err_iov, err_buftype);
656 if (rc == -EOPNOTSUPP) {
657 /* BB TODO: When support for special files added to Samba re-verify this path */
658 if (err_iov[0].iov_base && err_buftype[0] != CIFS_NO_BUFFER &&
659 ((struct smb2_hdr *)err_iov[0].iov_base)->Command == SMB2_CREATE &&
660 ((struct smb2_hdr *)err_iov[0].iov_base)->Status == STATUS_STOPPED_ON_SYMLINK) {
661 rc = smb2_parse_symlink_response(cifs_sb, err_iov, &data->symlink_target);
666 create_options |= OPEN_REPARSE_POINT;
668 /* Failed on a symbolic link - query a reparse point info */
669 cifs_get_readable_path(tcon, full_path, &cfile);
670 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path, FILE_READ_ATTRIBUTES,
671 FILE_OPEN, create_options, ACL_NO_MODE, data,
672 SMB2_OP_POSIX_QUERY_INFO, cfile,
673 &sidsbuf, &sidsbuflen, NULL, NULL);
677 sidsbuf_end = sidsbuf + sidsbuflen;
679 owner_len = posix_info_sid_size(sidsbuf, sidsbuf_end);
680 if (owner_len == -1) {
684 memcpy(owner, sidsbuf, owner_len);
686 group_len = posix_info_sid_size(
687 sidsbuf + owner_len, sidsbuf_end);
688 if (group_len == -1) {
692 memcpy(group, sidsbuf + owner_len, group_len);
697 free_rsp_buf(err_buftype[0], err_iov[0].iov_base);
698 free_rsp_buf(err_buftype[1], err_iov[1].iov_base);
699 free_rsp_buf(err_buftype[2], err_iov[2].iov_base);
704 smb2_mkdir(const unsigned int xid, struct inode *parent_inode, umode_t mode,
705 struct cifs_tcon *tcon, const char *name,
706 struct cifs_sb_info *cifs_sb)
708 return smb2_compound_op(xid, tcon, cifs_sb, name,
709 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
710 CREATE_NOT_FILE, mode, NULL, SMB2_OP_MKDIR,
711 NULL, NULL, NULL, NULL, NULL);
715 smb2_mkdir_setinfo(struct inode *inode, const char *name,
716 struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
717 const unsigned int xid)
719 FILE_BASIC_INFO data;
720 struct cifsInodeInfo *cifs_i;
721 struct cifsFileInfo *cfile;
725 memset(&data, 0, sizeof(data));
726 cifs_i = CIFS_I(inode);
727 dosattrs = cifs_i->cifsAttrs | ATTR_READONLY;
728 data.Attributes = cpu_to_le32(dosattrs);
729 cifs_get_writable_path(tcon, name, FIND_WR_ANY, &cfile);
730 tmprc = smb2_compound_op(xid, tcon, cifs_sb, name,
731 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
732 CREATE_NOT_FILE, ACL_NO_MODE,
733 &data, SMB2_OP_SET_INFO, cfile, NULL, NULL, NULL, NULL);
735 cifs_i->cifsAttrs = dosattrs;
739 smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
740 struct cifs_sb_info *cifs_sb)
742 drop_cached_dir_by_name(xid, tcon, name, cifs_sb);
743 return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
744 CREATE_NOT_FILE, ACL_NO_MODE,
745 NULL, SMB2_OP_RMDIR, NULL, NULL, NULL, NULL, NULL);
749 smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
750 struct cifs_sb_info *cifs_sb)
752 return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
753 CREATE_DELETE_ON_CLOSE | OPEN_REPARSE_POINT,
754 ACL_NO_MODE, NULL, SMB2_OP_DELETE, NULL, NULL, NULL, NULL, NULL);
758 smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon,
759 const char *from_name, const char *to_name,
760 struct cifs_sb_info *cifs_sb, __u32 access, int command,
761 struct cifsFileInfo *cfile)
763 __le16 *smb2_to_name = NULL;
766 smb2_to_name = cifs_convert_path_to_utf16(to_name, cifs_sb);
767 if (smb2_to_name == NULL) {
769 goto smb2_rename_path;
771 rc = smb2_compound_op(xid, tcon, cifs_sb, from_name, access,
772 FILE_OPEN, 0, ACL_NO_MODE, smb2_to_name,
773 command, cfile, NULL, NULL, NULL, NULL);
780 smb2_rename_path(const unsigned int xid, struct cifs_tcon *tcon,
781 const char *from_name, const char *to_name,
782 struct cifs_sb_info *cifs_sb)
784 struct cifsFileInfo *cfile;
786 drop_cached_dir_by_name(xid, tcon, from_name, cifs_sb);
787 cifs_get_writable_path(tcon, from_name, FIND_WR_WITH_DELETE, &cfile);
789 return smb2_set_path_attr(xid, tcon, from_name, to_name,
790 cifs_sb, DELETE, SMB2_OP_RENAME, cfile);
794 smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
795 const char *from_name, const char *to_name,
796 struct cifs_sb_info *cifs_sb)
798 return smb2_set_path_attr(xid, tcon, from_name, to_name, cifs_sb,
799 FILE_READ_ATTRIBUTES, SMB2_OP_HARDLINK,
804 smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
805 const char *full_path, __u64 size,
806 struct cifs_sb_info *cifs_sb, bool set_alloc)
808 __le64 eof = cpu_to_le64(size);
809 struct cifsFileInfo *cfile;
811 cifs_get_writable_path(tcon, full_path, FIND_WR_ANY, &cfile);
812 return smb2_compound_op(xid, tcon, cifs_sb, full_path,
813 FILE_WRITE_DATA, FILE_OPEN, 0, ACL_NO_MODE,
814 &eof, SMB2_OP_SET_EOF, cfile, NULL, NULL, NULL, NULL);
818 smb2_set_file_info(struct inode *inode, const char *full_path,
819 FILE_BASIC_INFO *buf, const unsigned int xid)
821 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
822 struct tcon_link *tlink;
823 struct cifs_tcon *tcon;
824 struct cifsFileInfo *cfile;
827 if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) &&
828 (buf->LastWriteTime == 0) && (buf->ChangeTime == 0) &&
829 (buf->Attributes == 0))
830 return 0; /* would be a no op, no sense sending this */
832 tlink = cifs_sb_tlink(cifs_sb);
834 return PTR_ERR(tlink);
835 tcon = tlink_tcon(tlink);
837 cifs_get_writable_path(tcon, full_path, FIND_WR_ANY, &cfile);
838 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
839 FILE_WRITE_ATTRIBUTES, FILE_OPEN,
840 0, ACL_NO_MODE, buf, SMB2_OP_SET_INFO, cfile,
841 NULL, NULL, NULL, NULL);
842 cifs_put_tlink(tlink);