Lines 169-175
Link Here
|
169 |
|
169 |
|
170 |
if (fattr->cf_flags & CIFS_FATTR_DFS_REFERRAL) |
170 |
if (fattr->cf_flags & CIFS_FATTR_DFS_REFERRAL) |
171 |
inode->i_flags |= S_AUTOMOUNT; |
171 |
inode->i_flags |= S_AUTOMOUNT; |
172 |
cifs_set_ops(inode); |
172 |
if (inode->i_state & I_NEW) |
|
|
173 |
cifs_set_ops(inode); |
173 |
} |
174 |
} |
174 |
|
175 |
|
175 |
void |
176 |
void |
Lines 244-258
Link Here
|
244 |
break; |
245 |
break; |
245 |
} |
246 |
} |
246 |
|
247 |
|
247 |
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) |
248 |
fattr->cf_uid = cifs_sb->mnt_uid; |
248 |
fattr->cf_uid = cifs_sb->mnt_uid; |
249 |
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)) { |
249 |
else |
250 |
u64 id = le64_to_cpu(info->Uid); |
250 |
fattr->cf_uid = le64_to_cpu(info->Uid); |
251 |
if (id < ((uid_t)-1)) { |
251 |
|
252 |
kuid_t uid = make_kuid(&init_user_ns, id); |
252 |
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) |
253 |
if (uid_valid(uid)) |
253 |
fattr->cf_gid = cifs_sb->mnt_gid; |
254 |
fattr->cf_uid = uid; |
254 |
else |
255 |
} |
255 |
fattr->cf_gid = le64_to_cpu(info->Gid); |
256 |
} |
|
|
257 |
|
258 |
fattr->cf_gid = cifs_sb->mnt_gid; |
259 |
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)) { |
260 |
u64 id = le64_to_cpu(info->Gid); |
261 |
if (id < ((gid_t)-1)) { |
262 |
kgid_t gid = make_kgid(&init_user_ns, id); |
263 |
if (gid_valid(gid)) |
264 |
fattr->cf_gid = gid; |
265 |
} |
266 |
} |
256 |
|
267 |
|
257 |
fattr->cf_nlink = le64_to_cpu(info->Nlinks); |
268 |
fattr->cf_nlink = le64_to_cpu(info->Nlinks); |
258 |
} |
269 |
} |
Lines 289-295
Link Here
|
289 |
unsigned int xid; |
300 |
unsigned int xid; |
290 |
FILE_UNIX_BASIC_INFO find_data; |
301 |
FILE_UNIX_BASIC_INFO find_data; |
291 |
struct cifs_fattr fattr; |
302 |
struct cifs_fattr fattr; |
292 |
struct inode *inode = filp->f_path.dentry->d_inode; |
303 |
struct inode *inode = file_inode(filp); |
293 |
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
304 |
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
294 |
struct cifsFileInfo *cfile = filp->private_data; |
305 |
struct cifsFileInfo *cfile = filp->private_data; |
295 |
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); |
306 |
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); |
Lines 558-564
Link Here
|
558 |
unsigned int xid; |
569 |
unsigned int xid; |
559 |
FILE_ALL_INFO find_data; |
570 |
FILE_ALL_INFO find_data; |
560 |
struct cifs_fattr fattr; |
571 |
struct cifs_fattr fattr; |
561 |
struct inode *inode = filp->f_path.dentry->d_inode; |
572 |
struct inode *inode = file_inode(filp); |
562 |
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
573 |
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
563 |
struct cifsFileInfo *cfile = filp->private_data; |
574 |
struct cifsFileInfo *cfile = filp->private_data; |
564 |
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); |
575 |
struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); |
Lines 806-815
Link Here
|
806 |
inode_has_hashed_dentries(struct inode *inode) |
817 |
inode_has_hashed_dentries(struct inode *inode) |
807 |
{ |
818 |
{ |
808 |
struct dentry *dentry; |
819 |
struct dentry *dentry; |
809 |
struct hlist_node *p; |
|
|
810 |
|
820 |
|
811 |
spin_lock(&inode->i_lock); |
821 |
spin_lock(&inode->i_lock); |
812 |
hlist_for_each_entry(dentry, p, &inode->i_dentry, d_alias) { |
822 |
hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) { |
813 |
if (!d_unhashed(dentry) || IS_ROOT(dentry)) { |
823 |
if (!d_unhashed(dentry) || IS_ROOT(dentry)) { |
814 |
spin_unlock(&inode->i_lock); |
824 |
spin_unlock(&inode->i_lock); |
815 |
return true; |
825 |
return true; |
Lines 986-991
Link Here
|
986 |
return PTR_ERR(tlink); |
996 |
return PTR_ERR(tlink); |
987 |
tcon = tlink_tcon(tlink); |
997 |
tcon = tlink_tcon(tlink); |
988 |
|
998 |
|
|
|
999 |
/* |
1000 |
* We cannot rename the file if the server doesn't support |
1001 |
* CAP_INFOLEVEL_PASSTHRU |
1002 |
*/ |
1003 |
if (!(tcon->ses->capabilities & CAP_INFOLEVEL_PASSTHRU)) { |
1004 |
rc = -EBUSY; |
1005 |
goto out; |
1006 |
} |
1007 |
|
989 |
rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, |
1008 |
rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, |
990 |
DELETE|FILE_WRITE_ATTRIBUTES, FILE_SHARE_ALL, CREATE_NOT_DIR, |
1009 |
DELETE|FILE_WRITE_ATTRIBUTES, FILE_SHARE_ALL, CREATE_NOT_DIR, |
991 |
&netfid, &oplock, NULL, cifs_sb->local_nls, |
1010 |
&netfid, &oplock, NULL, cifs_sb->local_nls, |
Lines 1014-1020
Link Here
|
1014 |
current->tgid); |
1033 |
current->tgid); |
1015 |
/* although we would like to mark the file hidden |
1034 |
/* although we would like to mark the file hidden |
1016 |
if that fails we will still try to rename it */ |
1035 |
if that fails we will still try to rename it */ |
1017 |
if (rc != 0) |
1036 |
if (!rc) |
1018 |
cifsInode->cifsAttrs = dosattr; |
1037 |
cifsInode->cifsAttrs = dosattr; |
1019 |
else |
1038 |
else |
1020 |
dosattr = origattr; /* since not able to change them */ |
1039 |
dosattr = origattr; /* since not able to change them */ |
Lines 1025-1031
Link Here
|
1025 |
cifs_sb->mnt_cifs_flags & |
1044 |
cifs_sb->mnt_cifs_flags & |
1026 |
CIFS_MOUNT_MAP_SPECIAL_CHR); |
1045 |
CIFS_MOUNT_MAP_SPECIAL_CHR); |
1027 |
if (rc != 0) { |
1046 |
if (rc != 0) { |
1028 |
rc = -ETXTBSY; |
1047 |
rc = -EBUSY; |
1029 |
goto undo_setattr; |
1048 |
goto undo_setattr; |
1030 |
} |
1049 |
} |
1031 |
|
1050 |
|
Lines 1044-1050
Link Here
|
1044 |
if (rc == -ENOENT) |
1063 |
if (rc == -ENOENT) |
1045 |
rc = 0; |
1064 |
rc = 0; |
1046 |
else if (rc != 0) { |
1065 |
else if (rc != 0) { |
1047 |
rc = -ETXTBSY; |
1066 |
rc = -EBUSY; |
1048 |
goto undo_rename; |
1067 |
goto undo_rename; |
1049 |
} |
1068 |
} |
1050 |
cifsInode->delete_pending = true; |
1069 |
cifsInode->delete_pending = true; |
Lines 1151-1165
Link Here
|
1151 |
cifs_drop_nlink(inode); |
1170 |
cifs_drop_nlink(inode); |
1152 |
} else if (rc == -ENOENT) { |
1171 |
} else if (rc == -ENOENT) { |
1153 |
d_drop(dentry); |
1172 |
d_drop(dentry); |
1154 |
} else if (rc == -ETXTBSY) { |
1173 |
} else if (rc == -EBUSY) { |
1155 |
if (server->ops->rename_pending_delete) { |
1174 |
if (server->ops->rename_pending_delete) { |
1156 |
rc = server->ops->rename_pending_delete(full_path, |
1175 |
rc = server->ops->rename_pending_delete(full_path, |
1157 |
dentry, xid); |
1176 |
dentry, xid); |
1158 |
if (rc == 0) |
1177 |
if (rc == 0) |
1159 |
cifs_drop_nlink(inode); |
1178 |
cifs_drop_nlink(inode); |
1160 |
} |
1179 |
} |
1161 |
if (rc == -ETXTBSY) |
|
|
1162 |
rc = -EBUSY; |
1163 |
} else if ((rc == -EACCES) && (dosattr == 0) && inode) { |
1180 |
} else if ((rc == -EACCES) && (dosattr == 0) && inode) { |
1164 |
attrs = kzalloc(sizeof(*attrs), GFP_KERNEL); |
1181 |
attrs = kzalloc(sizeof(*attrs), GFP_KERNEL); |
1165 |
if (attrs == NULL) { |
1182 |
if (attrs == NULL) { |
Lines 1245-1258
Link Here
|
1245 |
.device = 0, |
1262 |
.device = 0, |
1246 |
}; |
1263 |
}; |
1247 |
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { |
1264 |
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { |
1248 |
args.uid = (__u64)current_fsuid(); |
1265 |
args.uid = current_fsuid(); |
1249 |
if (parent->i_mode & S_ISGID) |
1266 |
if (parent->i_mode & S_ISGID) |
1250 |
args.gid = (__u64)parent->i_gid; |
1267 |
args.gid = parent->i_gid; |
1251 |
else |
1268 |
else |
1252 |
args.gid = (__u64)current_fsgid(); |
1269 |
args.gid = current_fsgid(); |
1253 |
} else { |
1270 |
} else { |
1254 |
args.uid = NO_CHANGE_64; |
1271 |
args.uid = INVALID_UID; /* no change */ |
1255 |
args.gid = NO_CHANGE_64; |
1272 |
args.gid = INVALID_GID; /* no change */ |
1256 |
} |
1273 |
} |
1257 |
CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args, |
1274 |
CIFSSMBUnixSetPathInfo(xid, tcon, full_path, &args, |
1258 |
cifs_sb->local_nls, |
1275 |
cifs_sb->local_nls, |
Lines 1500-1506
Link Here
|
1500 |
* source. Note that cross directory moves do not work with |
1517 |
* source. Note that cross directory moves do not work with |
1501 |
* rename by filehandle to various Windows servers. |
1518 |
* rename by filehandle to various Windows servers. |
1502 |
*/ |
1519 |
*/ |
1503 |
if (rc == 0 || rc != -ETXTBSY) |
1520 |
if (rc == 0 || rc != -EBUSY) |
1504 |
goto do_rename_exit; |
1521 |
goto do_rename_exit; |
1505 |
|
1522 |
|
1506 |
/* open-file renames don't work across directories */ |
1523 |
/* open-file renames don't work across directories */ |
Lines 1678-1684
Link Here
|
1678 |
int cifs_revalidate_file_attr(struct file *filp) |
1695 |
int cifs_revalidate_file_attr(struct file *filp) |
1679 |
{ |
1696 |
{ |
1680 |
int rc = 0; |
1697 |
int rc = 0; |
1681 |
struct inode *inode = filp->f_path.dentry->d_inode; |
1698 |
struct inode *inode = file_inode(filp); |
1682 |
struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data; |
1699 |
struct cifsFileInfo *cfile = (struct cifsFileInfo *) filp->private_data; |
1683 |
|
1700 |
|
1684 |
if (!cifs_inode_needs_reval(inode)) |
1701 |
if (!cifs_inode_needs_reval(inode)) |
Lines 1735-1741
Link Here
|
1735 |
int cifs_revalidate_file(struct file *filp) |
1752 |
int cifs_revalidate_file(struct file *filp) |
1736 |
{ |
1753 |
{ |
1737 |
int rc; |
1754 |
int rc; |
1738 |
struct inode *inode = filp->f_path.dentry->d_inode; |
1755 |
struct inode *inode = file_inode(filp); |
1739 |
|
1756 |
|
1740 |
rc = cifs_revalidate_file_attr(filp); |
1757 |
rc = cifs_revalidate_file_attr(filp); |
1741 |
if (rc) |
1758 |
if (rc) |
Lines 2013-2024
Link Here
|
2013 |
if (attrs->ia_valid & ATTR_UID) |
2030 |
if (attrs->ia_valid & ATTR_UID) |
2014 |
args->uid = attrs->ia_uid; |
2031 |
args->uid = attrs->ia_uid; |
2015 |
else |
2032 |
else |
2016 |
args->uid = NO_CHANGE_64; |
2033 |
args->uid = INVALID_UID; /* no change */ |
2017 |
|
2034 |
|
2018 |
if (attrs->ia_valid & ATTR_GID) |
2035 |
if (attrs->ia_valid & ATTR_GID) |
2019 |
args->gid = attrs->ia_gid; |
2036 |
args->gid = attrs->ia_gid; |
2020 |
else |
2037 |
else |
2021 |
args->gid = NO_CHANGE_64; |
2038 |
args->gid = INVALID_GID; /* no change */ |
2022 |
|
2039 |
|
2023 |
if (attrs->ia_valid & ATTR_ATIME) |
2040 |
if (attrs->ia_valid & ATTR_ATIME) |
2024 |
args->atime = cifs_UnixTimeToNT(attrs->ia_atime); |
2041 |
args->atime = cifs_UnixTimeToNT(attrs->ia_atime); |
Lines 2086-2093
Link Here
|
2086 |
cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) |
2103 |
cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) |
2087 |
{ |
2104 |
{ |
2088 |
unsigned int xid; |
2105 |
unsigned int xid; |
2089 |
uid_t uid = NO_CHANGE_32; |
2106 |
kuid_t uid = INVALID_UID; |
2090 |
gid_t gid = NO_CHANGE_32; |
2107 |
kgid_t gid = INVALID_GID; |
2091 |
struct inode *inode = direntry->d_inode; |
2108 |
struct inode *inode = direntry->d_inode; |
2092 |
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
2109 |
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
2093 |
struct cifsInodeInfo *cifsInode = CIFS_I(inode); |
2110 |
struct cifsInodeInfo *cifsInode = CIFS_I(inode); |
Lines 2146-2152
Link Here
|
2146 |
|
2163 |
|
2147 |
#ifdef CONFIG_CIFS_ACL |
2164 |
#ifdef CONFIG_CIFS_ACL |
2148 |
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { |
2165 |
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { |
2149 |
if (uid != NO_CHANGE_32 || gid != NO_CHANGE_32) { |
2166 |
if (uid_valid(uid) || gid_valid(gid)) { |
2150 |
rc = id_mode_to_cifs_acl(inode, full_path, NO_CHANGE_64, |
2167 |
rc = id_mode_to_cifs_acl(inode, full_path, NO_CHANGE_64, |
2151 |
uid, gid); |
2168 |
uid, gid); |
2152 |
if (rc) { |
2169 |
if (rc) { |
Lines 2170-2176
Link Here
|
2170 |
#ifdef CONFIG_CIFS_ACL |
2187 |
#ifdef CONFIG_CIFS_ACL |
2171 |
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { |
2188 |
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { |
2172 |
rc = id_mode_to_cifs_acl(inode, full_path, mode, |
2189 |
rc = id_mode_to_cifs_acl(inode, full_path, mode, |
2173 |
NO_CHANGE_32, NO_CHANGE_32); |
2190 |
INVALID_UID, INVALID_GID); |
2174 |
if (rc) { |
2191 |
if (rc) { |
2175 |
cFYI(1, "%s: Setting ACL failed with error: %d", |
2192 |
cFYI(1, "%s: Setting ACL failed with error: %d", |
2176 |
__func__, rc); |
2193 |
__func__, rc); |