^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * fs/cifs/smb2inode.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) International Business Machines Corp., 2002, 2011
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Etersoft, 2012
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Author(s): Pavel Shilovsky (pshilovsky@samba.org),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Steve French (sfrench@us.ibm.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This library is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * it under the terms of the GNU Lesser General Public License as published
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * by the Free Software Foundation; either version 2.1 of the License, or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * This library is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * the GNU Lesser General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * You should have received a copy of the GNU Lesser General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * along with this library; if not, write to the Free Software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/stat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <asm/div64.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #include "cifsfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #include "cifspdu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #include "cifsglob.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #include "cifsproto.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #include "cifs_debug.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #include "cifs_fs_sb.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #include "cifs_unicode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #include "fscache.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include "smb2glob.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #include "smb2pdu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #include "smb2proto.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) free_set_inf_compound(struct smb_rqst *rqst)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) if (rqst[1].rq_iov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) SMB2_set_info_free(&rqst[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) if (rqst[2].rq_iov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) SMB2_close_free(&rqst[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct cop_vars {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct cifs_open_parms oparms;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct kvec rsp_iov[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct smb_rqst rqst[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct kvec open_iov[SMB2_CREATE_IOV_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) struct kvec qi_iov[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct kvec si_iov[SMB2_SET_INFO_IOV_SIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct kvec close_iov[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct smb2_file_rename_info rename_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct smb2_file_link_info link_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct cifs_sb_info *cifs_sb, const char *full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) __u32 desired_access, __u32 create_disposition,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) __u32 create_options, umode_t mode, void *ptr, int command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct cifsFileInfo *cfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct cop_vars *vars = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct kvec *rsp_iov;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) struct smb_rqst *rqst;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) __le16 *utf16_path = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) __u8 oplock = SMB2_OPLOCK_LEVEL_NONE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct cifs_fid fid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct cifs_ses *ses = tcon->ses;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct TCP_Server_Info *server;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) int num_rqst = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) int resp_buftype[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) struct smb2_query_info_rsp *qi_rsp = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) int flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) __u8 delete_pending[8] = {1, 0, 0, 0, 0, 0, 0, 0};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) unsigned int size[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) void *data[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) vars = kzalloc(sizeof(*vars), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (vars == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) rqst = &vars->rqst[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) rsp_iov = &vars->rsp_iov[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) server = cifs_pick_channel(ses);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (smb3_encryption_required(tcon))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) flags |= CIFS_TRANSFORM_REQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /* We already have a handle so we can skip the open */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if (cfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) goto after_open;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /* Open */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (!utf16_path) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) vars->oparms.tcon = tcon;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) vars->oparms.desired_access = desired_access;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) vars->oparms.disposition = create_disposition;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) vars->oparms.create_options = cifs_create_options(cifs_sb, create_options);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) vars->oparms.fid = &fid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) vars->oparms.reconnect = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) vars->oparms.mode = mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) vars->oparms.cifs_sb = cifs_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) rqst[num_rqst].rq_iov = &vars->open_iov[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) rqst[num_rqst].rq_nvec = SMB2_CREATE_IOV_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) rc = SMB2_open_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) &rqst[num_rqst], &oplock, &vars->oparms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) utf16_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) kfree(utf16_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) smb2_set_next_command(tcon, &rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) after_open:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) num_rqst++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) rc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) /* Operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) switch (command) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) case SMB2_OP_QUERY_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) rqst[num_rqst].rq_iov = &vars->qi_iov[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) rqst[num_rqst].rq_nvec = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) if (cfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) rc = SMB2_query_info_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) &rqst[num_rqst],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) cfile->fid.persistent_fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) cfile->fid.volatile_fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) FILE_ALL_INFORMATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) SMB2_O_INFO_FILE, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) sizeof(struct smb2_file_all_info) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) PATH_MAX * 2, 0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) rc = SMB2_query_info_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) &rqst[num_rqst],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) COMPOUND_FID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) COMPOUND_FID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) FILE_ALL_INFORMATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) SMB2_O_INFO_FILE, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) sizeof(struct smb2_file_all_info) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) PATH_MAX * 2, 0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) smb2_set_next_command(tcon, &rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) smb2_set_related(&rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) num_rqst++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) trace_smb3_query_info_compound_enter(xid, ses->Suid, tcon->tid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) case SMB2_OP_POSIX_QUERY_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) rqst[num_rqst].rq_iov = &vars->qi_iov[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) rqst[num_rqst].rq_nvec = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if (cfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) rc = SMB2_query_info_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) &rqst[num_rqst],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) cfile->fid.persistent_fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) cfile->fid.volatile_fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) SMB_FIND_FILE_POSIX_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) SMB2_O_INFO_FILE, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) /* TBD: fix following to allow for longer SIDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) sizeof(struct smb311_posix_qinfo *) + (PATH_MAX * 2) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) (sizeof(struct cifs_sid) * 2), 0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) rc = SMB2_query_info_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) &rqst[num_rqst],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) COMPOUND_FID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) COMPOUND_FID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) SMB_FIND_FILE_POSIX_INFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) SMB2_O_INFO_FILE, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) sizeof(struct smb311_posix_qinfo *) + (PATH_MAX * 2) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) (sizeof(struct cifs_sid) * 2), 0, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) smb2_set_next_command(tcon, &rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) smb2_set_related(&rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) num_rqst++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) trace_smb3_posix_query_info_compound_enter(xid, ses->Suid, tcon->tid, full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) case SMB2_OP_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) trace_smb3_delete_enter(xid, ses->Suid, tcon->tid, full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) case SMB2_OP_MKDIR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) * Directories are created through parameters in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) * SMB2_open() call.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) trace_smb3_mkdir_enter(xid, ses->Suid, tcon->tid, full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) case SMB2_OP_RMDIR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) rqst[num_rqst].rq_iov = &vars->si_iov[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) rqst[num_rqst].rq_nvec = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) size[0] = 1; /* sizeof __u8 See MS-FSCC section 2.4.11 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) data[0] = &delete_pending[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) rc = SMB2_set_info_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) &rqst[num_rqst], COMPOUND_FID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) COMPOUND_FID, current->tgid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) FILE_DISPOSITION_INFORMATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) SMB2_O_INFO_FILE, 0, data, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) smb2_set_next_command(tcon, &rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) smb2_set_related(&rqst[num_rqst++]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) trace_smb3_rmdir_enter(xid, ses->Suid, tcon->tid, full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) case SMB2_OP_SET_EOF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) rqst[num_rqst].rq_iov = &vars->si_iov[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) rqst[num_rqst].rq_nvec = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) size[0] = 8; /* sizeof __le64 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) data[0] = ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) rc = SMB2_set_info_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) &rqst[num_rqst], COMPOUND_FID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) COMPOUND_FID, current->tgid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) FILE_END_OF_FILE_INFORMATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) SMB2_O_INFO_FILE, 0, data, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) smb2_set_next_command(tcon, &rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) smb2_set_related(&rqst[num_rqst++]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) trace_smb3_set_eof_enter(xid, ses->Suid, tcon->tid, full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) case SMB2_OP_SET_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) rqst[num_rqst].rq_iov = &vars->si_iov[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) rqst[num_rqst].rq_nvec = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) size[0] = sizeof(FILE_BASIC_INFO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) data[0] = ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) if (cfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) rc = SMB2_set_info_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) &rqst[num_rqst],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) cfile->fid.persistent_fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) cfile->fid.volatile_fid, current->tgid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) FILE_BASIC_INFORMATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) SMB2_O_INFO_FILE, 0, data, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) rc = SMB2_set_info_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) &rqst[num_rqst],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) COMPOUND_FID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) COMPOUND_FID, current->tgid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) FILE_BASIC_INFORMATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) SMB2_O_INFO_FILE, 0, data, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) smb2_set_next_command(tcon, &rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) smb2_set_related(&rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) num_rqst++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) trace_smb3_set_info_compound_enter(xid, ses->Suid, tcon->tid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) case SMB2_OP_RENAME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) rqst[num_rqst].rq_iov = &vars->si_iov[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) rqst[num_rqst].rq_nvec = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) len = (2 * UniStrnlen((wchar_t *)ptr, PATH_MAX));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) vars->rename_info.ReplaceIfExists = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) vars->rename_info.RootDirectory = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) vars->rename_info.FileNameLength = cpu_to_le32(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) size[0] = sizeof(struct smb2_file_rename_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) data[0] = &vars->rename_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) size[1] = len + 2 /* null */;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) data[1] = (__le16 *)ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) if (cfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) rc = SMB2_set_info_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) &rqst[num_rqst],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) cfile->fid.persistent_fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) cfile->fid.volatile_fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) current->tgid, FILE_RENAME_INFORMATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) SMB2_O_INFO_FILE, 0, data, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) rc = SMB2_set_info_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) &rqst[num_rqst],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) COMPOUND_FID, COMPOUND_FID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) current->tgid, FILE_RENAME_INFORMATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) SMB2_O_INFO_FILE, 0, data, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) if (!rc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) smb2_set_next_command(tcon, &rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) smb2_set_related(&rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) num_rqst++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) trace_smb3_rename_enter(xid, ses->Suid, tcon->tid, full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) case SMB2_OP_HARDLINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) rqst[num_rqst].rq_iov = &vars->si_iov[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) rqst[num_rqst].rq_nvec = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) len = (2 * UniStrnlen((wchar_t *)ptr, PATH_MAX));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) vars->link_info.ReplaceIfExists = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) vars->link_info.RootDirectory = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) vars->link_info.FileNameLength = cpu_to_le32(len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) size[0] = sizeof(struct smb2_file_link_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) data[0] = &vars->link_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) size[1] = len + 2 /* null */;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) data[1] = (__le16 *)ptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) rc = SMB2_set_info_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) &rqst[num_rqst], COMPOUND_FID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) COMPOUND_FID, current->tgid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) FILE_LINK_INFORMATION,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) SMB2_O_INFO_FILE, 0, data, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) smb2_set_next_command(tcon, &rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) smb2_set_related(&rqst[num_rqst++]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) trace_smb3_hardlink_enter(xid, ses->Suid, tcon->tid, full_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) cifs_dbg(VFS, "Invalid command\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) rc = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) /* We already have a handle so we can skip the close */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) if (cfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) goto after_close;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) /* Close */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) flags |= CIFS_CP_CREATE_CLOSE_OP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) rqst[num_rqst].rq_iov = &vars->close_iov[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) rqst[num_rqst].rq_nvec = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) rc = SMB2_close_init(tcon, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) &rqst[num_rqst], COMPOUND_FID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) COMPOUND_FID, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) smb2_set_related(&rqst[num_rqst]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) goto finished;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) after_close:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) num_rqst++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) if (cfile) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) cifsFileInfo_put(cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) cfile = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) rc = compound_send_recv(xid, ses, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) flags, num_rqst - 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) &rqst[1], &resp_buftype[1],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) &rsp_iov[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) rc = compound_send_recv(xid, ses, server,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) flags, num_rqst,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) rqst, resp_buftype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) rsp_iov);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) finished:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) if (cfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) cifsFileInfo_put(cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) SMB2_open_free(&rqst[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) if (rc == -EREMCHG) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) pr_warn_once("server share %s deleted\n", tcon->treeName);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) tcon->need_reconnect = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) switch (command) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) case SMB2_OP_QUERY_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) if (rc == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) qi_rsp = (struct smb2_query_info_rsp *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) rsp_iov[1].iov_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) rc = smb2_validate_and_copy_iov(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) le16_to_cpu(qi_rsp->OutputBufferOffset),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) le32_to_cpu(qi_rsp->OutputBufferLength),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) &rsp_iov[1], sizeof(struct smb2_file_all_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) if (rqst[1].rq_iov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) SMB2_query_info_free(&rqst[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) if (rqst[2].rq_iov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) SMB2_close_free(&rqst[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) trace_smb3_query_info_compound_err(xid, ses->Suid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) tcon->tid, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) trace_smb3_query_info_compound_done(xid, ses->Suid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) tcon->tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) case SMB2_OP_POSIX_QUERY_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) if (rc == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) qi_rsp = (struct smb2_query_info_rsp *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) rsp_iov[1].iov_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) rc = smb2_validate_and_copy_iov(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) le16_to_cpu(qi_rsp->OutputBufferOffset),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) le32_to_cpu(qi_rsp->OutputBufferLength),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) &rsp_iov[1], sizeof(struct smb311_posix_qinfo) /* add SIDs */, ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) if (rqst[1].rq_iov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) SMB2_query_info_free(&rqst[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) if (rqst[2].rq_iov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) SMB2_close_free(&rqst[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) trace_smb3_posix_query_info_compound_err(xid, ses->Suid, tcon->tid, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) trace_smb3_posix_query_info_compound_done(xid, ses->Suid, tcon->tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) case SMB2_OP_DELETE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) trace_smb3_delete_err(xid, ses->Suid, tcon->tid, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) trace_smb3_delete_done(xid, ses->Suid, tcon->tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) if (rqst[1].rq_iov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) SMB2_close_free(&rqst[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) case SMB2_OP_MKDIR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) trace_smb3_mkdir_err(xid, ses->Suid, tcon->tid, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) trace_smb3_mkdir_done(xid, ses->Suid, tcon->tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) if (rqst[1].rq_iov)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) SMB2_close_free(&rqst[1]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) case SMB2_OP_HARDLINK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) trace_smb3_hardlink_err(xid, ses->Suid, tcon->tid, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) trace_smb3_hardlink_done(xid, ses->Suid, tcon->tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) free_set_inf_compound(rqst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) case SMB2_OP_RENAME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) trace_smb3_rename_err(xid, ses->Suid, tcon->tid, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) trace_smb3_rename_done(xid, ses->Suid, tcon->tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) free_set_inf_compound(rqst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) case SMB2_OP_RMDIR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) trace_smb3_rmdir_err(xid, ses->Suid, tcon->tid, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) trace_smb3_rmdir_done(xid, ses->Suid, tcon->tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) free_set_inf_compound(rqst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) case SMB2_OP_SET_EOF:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) trace_smb3_set_eof_err(xid, ses->Suid, tcon->tid, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) trace_smb3_set_eof_done(xid, ses->Suid, tcon->tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) free_set_inf_compound(rqst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) case SMB2_OP_SET_INFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) trace_smb3_set_info_compound_err(xid, ses->Suid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) tcon->tid, rc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) trace_smb3_set_info_compound_done(xid, ses->Suid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) tcon->tid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) free_set_inf_compound(rqst);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) free_rsp_buf(resp_buftype[2], rsp_iov[2].iov_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) kfree(vars);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) move_smb2_info_to_cifs(FILE_ALL_INFO *dst, struct smb2_file_all_info *src)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) memcpy(dst, src, (size_t)(&src->CurrentByteOffset) - (size_t)src);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) dst->CurrentByteOffset = src->CurrentByteOffset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) dst->Mode = src->Mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) dst->AlignmentRequirement = src->AlignmentRequirement;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) dst->IndexNumber1 = 0; /* we don't use it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) struct cifs_sb_info *cifs_sb, const char *full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) FILE_ALL_INFO *data, bool *adjust_tz, bool *reparse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) struct smb2_file_all_info *smb2_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) __u32 create_options = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) bool no_cached_open = tcon->nohandlecache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) struct cifsFileInfo *cfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) struct cached_fid *cfid = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) *adjust_tz = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) *reparse = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) smb2_data = kzalloc(sizeof(struct smb2_file_all_info) + PATH_MAX * 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) if (smb2_data == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) /* If it is a root and its handle is cached then use it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) if (!strlen(full_path) && !no_cached_open) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) rc = open_shroot(xid, tcon, cifs_sb, &cfid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) if (tcon->crfid.file_all_info_is_valid) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) move_smb2_info_to_cifs(data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) &tcon->crfid.file_all_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) rc = SMB2_query_info(xid, tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) cfid->fid->persistent_fid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) cfid->fid->volatile_fid, smb2_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) move_smb2_info_to_cifs(data, smb2_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) close_shroot(cfid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) cifs_get_readable_path(tcon, full_path, &cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) FILE_READ_ATTRIBUTES, FILE_OPEN, create_options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) ACL_NO_MODE, smb2_data, SMB2_OP_QUERY_INFO, cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) if (rc == -EOPNOTSUPP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) *reparse = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) create_options |= OPEN_REPARSE_POINT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) /* Failed on a symbolic link - query a reparse point info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) FILE_READ_ATTRIBUTES, FILE_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) create_options, ACL_NO_MODE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) smb2_data, SMB2_OP_QUERY_INFO, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) move_smb2_info_to_cifs(data, smb2_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) kfree(smb2_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) smb311_posix_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) struct cifs_sb_info *cifs_sb, const char *full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) struct smb311_posix_qinfo *data, bool *adjust_tz, bool *reparse)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) __u32 create_options = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) struct cifsFileInfo *cfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) struct smb311_posix_qinfo *smb2_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) *adjust_tz = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) *reparse = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) /* BB TODO: Make struct larger when add support for parsing owner SIDs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) smb2_data = kzalloc(sizeof(struct smb311_posix_qinfo),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) if (smb2_data == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) * BB TODO: Add support for using the cached root handle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) * Create SMB2_query_posix_info worker function to do non-compounded query
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) * when we already have an open file handle for this. For now this is fast enough
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) * (always using the compounded version).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) cifs_get_readable_path(tcon, full_path, &cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) FILE_READ_ATTRIBUTES, FILE_OPEN, create_options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) ACL_NO_MODE, smb2_data, SMB2_OP_POSIX_QUERY_INFO, cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) if (rc == -EOPNOTSUPP) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) /* BB TODO: When support for special files added to Samba re-verify this path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) *reparse = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) create_options |= OPEN_REPARSE_POINT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) /* Failed on a symbolic link - query a reparse point info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) FILE_READ_ATTRIBUTES, FILE_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) create_options, ACL_NO_MODE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) smb2_data, SMB2_OP_POSIX_QUERY_INFO, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) if (rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) /* TODO: will need to allow for the 2 SIDs when add support for getting owner UID/GID */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) memcpy(data, smb2_data, sizeof(struct smb311_posix_qinfo));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) kfree(smb2_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) smb2_mkdir(const unsigned int xid, struct inode *parent_inode, umode_t mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) struct cifs_tcon *tcon, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) struct cifs_sb_info *cifs_sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) return smb2_compound_op(xid, tcon, cifs_sb, name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) FILE_WRITE_ATTRIBUTES, FILE_CREATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) CREATE_NOT_FILE, mode, NULL, SMB2_OP_MKDIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) smb2_mkdir_setinfo(struct inode *inode, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) struct cifs_sb_info *cifs_sb, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) const unsigned int xid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) FILE_BASIC_INFO data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) struct cifsInodeInfo *cifs_i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) struct cifsFileInfo *cfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) u32 dosattrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) int tmprc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) memset(&data, 0, sizeof(data));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) cifs_i = CIFS_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) dosattrs = cifs_i->cifsAttrs | ATTR_READONLY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) data.Attributes = cpu_to_le32(dosattrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) cifs_get_writable_path(tcon, name, FIND_WR_ANY, &cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) tmprc = smb2_compound_op(xid, tcon, cifs_sb, name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) FILE_WRITE_ATTRIBUTES, FILE_CREATE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) CREATE_NOT_FILE, ACL_NO_MODE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) &data, SMB2_OP_SET_INFO, cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) if (tmprc == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) cifs_i->cifsAttrs = dosattrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) struct cifs_sb_info *cifs_sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) CREATE_NOT_FILE, ACL_NO_MODE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) NULL, SMB2_OP_RMDIR, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) struct cifs_sb_info *cifs_sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) CREATE_DELETE_ON_CLOSE | OPEN_REPARSE_POINT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) ACL_NO_MODE, NULL, SMB2_OP_DELETE, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) const char *from_name, const char *to_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) struct cifs_sb_info *cifs_sb, __u32 access, int command,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) struct cifsFileInfo *cfile)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) __le16 *smb2_to_name = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) smb2_to_name = cifs_convert_path_to_utf16(to_name, cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) if (smb2_to_name == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) rc = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) goto smb2_rename_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) rc = smb2_compound_op(xid, tcon, cifs_sb, from_name, access,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) FILE_OPEN, 0, ACL_NO_MODE, smb2_to_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) command, cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) smb2_rename_path:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) kfree(smb2_to_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) smb2_rename_path(const unsigned int xid, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) const char *from_name, const char *to_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) struct cifs_sb_info *cifs_sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) struct cifsFileInfo *cfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) cifs_get_writable_path(tcon, from_name, FIND_WR_WITH_DELETE, &cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) return smb2_set_path_attr(xid, tcon, from_name, to_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) cifs_sb, DELETE, SMB2_OP_RENAME, cfile);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) const char *from_name, const char *to_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) struct cifs_sb_info *cifs_sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) return smb2_set_path_attr(xid, tcon, from_name, to_name, cifs_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) FILE_READ_ATTRIBUTES, SMB2_OP_HARDLINK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) const char *full_path, __u64 size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) struct cifs_sb_info *cifs_sb, bool set_alloc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) __le64 eof = cpu_to_le64(size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) return smb2_compound_op(xid, tcon, cifs_sb, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) FILE_WRITE_DATA, FILE_OPEN, 0, ACL_NO_MODE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) &eof, SMB2_OP_SET_EOF, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) smb2_set_file_info(struct inode *inode, const char *full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) FILE_BASIC_INFO *buf, const unsigned int xid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) struct tcon_link *tlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) if ((buf->CreationTime == 0) && (buf->LastAccessTime == 0) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) (buf->LastWriteTime == 0) && (buf->ChangeTime == 0) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) (buf->Attributes == 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) return 0; /* would be a no op, no sense sending this */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) tlink = cifs_sb_tlink(cifs_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) if (IS_ERR(tlink))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) return PTR_ERR(tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) rc = smb2_compound_op(xid, tlink_tcon(tlink), cifs_sb, full_path,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) FILE_WRITE_ATTRIBUTES, FILE_OPEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) 0, ACL_NO_MODE, buf, SMB2_OP_SET_INFO, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) cifs_put_tlink(tlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) }