bundle up Unix SET_PATH_INFO args into a struct and change name
We'd like to be able to use the unix SET_PATH_INFO_BASIC args to set file times as well, but that makes the argument list rather long. Bundle up the args for unix SET_PATH_INFO call into a struct. For now, we don't actually use the times fields anywhere. That will be done in a follow-on patch. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
9e96af8525
commit
4e1e7fb9e8
|
@ -262,7 +262,7 @@
|
||||||
*/
|
*/
|
||||||
#define CIFS_NO_HANDLE 0xFFFF
|
#define CIFS_NO_HANDLE 0xFFFF
|
||||||
|
|
||||||
#define NO_CHANGE_64 cpu_to_le64(0xFFFFFFFFFFFFFFFFULL)
|
#define NO_CHANGE_64 0xFFFFFFFFFFFFFFFFULL
|
||||||
#define NO_CHANGE_32 0xFFFFFFFFUL
|
#define NO_CHANGE_32 0xFFFFFFFFUL
|
||||||
|
|
||||||
/* IPC$ in ASCII */
|
/* IPC$ in ASCII */
|
||||||
|
|
|
@ -191,9 +191,20 @@ extern int CIFSSMBSetEOF(const int xid, struct cifsTconInfo *tcon,
|
||||||
extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon,
|
extern int CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon,
|
||||||
__u64 size, __u16 fileHandle, __u32 opener_pid,
|
__u64 size, __u16 fileHandle, __u32 opener_pid,
|
||||||
bool AllocSizeFlag);
|
bool AllocSizeFlag);
|
||||||
extern int CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *pTcon,
|
|
||||||
char *full_path, __u64 mode, __u64 uid,
|
struct cifs_unix_set_info_args {
|
||||||
__u64 gid, dev_t dev,
|
__u64 ctime;
|
||||||
|
__u64 atime;
|
||||||
|
__u64 mtime;
|
||||||
|
__u64 mode;
|
||||||
|
__u64 uid;
|
||||||
|
__u64 gid;
|
||||||
|
dev_t device;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern int CIFSSMBUnixSetInfo(const int xid, struct cifsTconInfo *pTcon,
|
||||||
|
char *fileName,
|
||||||
|
const struct cifs_unix_set_info_args *args,
|
||||||
const struct nls_table *nls_codepage,
|
const struct nls_table *nls_codepage,
|
||||||
int remap_special_chars);
|
int remap_special_chars);
|
||||||
|
|
||||||
|
|
|
@ -5013,10 +5013,9 @@ SetAttrLgcyRetry:
|
||||||
#endif /* temporarily unneeded SetAttr legacy function */
|
#endif /* temporarily unneeded SetAttr legacy function */
|
||||||
|
|
||||||
int
|
int
|
||||||
CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon,
|
CIFSSMBUnixSetInfo(const int xid, struct cifsTconInfo *tcon, char *fileName,
|
||||||
char *fileName, __u64 mode, __u64 uid, __u64 gid,
|
const struct cifs_unix_set_info_args *args,
|
||||||
dev_t device, const struct nls_table *nls_codepage,
|
const struct nls_table *nls_codepage, int remap)
|
||||||
int remap)
|
|
||||||
{
|
{
|
||||||
TRANSACTION2_SPI_REQ *pSMB = NULL;
|
TRANSACTION2_SPI_REQ *pSMB = NULL;
|
||||||
TRANSACTION2_SPI_RSP *pSMBr = NULL;
|
TRANSACTION2_SPI_RSP *pSMBr = NULL;
|
||||||
|
@ -5025,6 +5024,7 @@ CIFSSMBUnixSetPerms(const int xid, struct cifsTconInfo *tcon,
|
||||||
int bytes_returned = 0;
|
int bytes_returned = 0;
|
||||||
FILE_UNIX_BASIC_INFO *data_offset;
|
FILE_UNIX_BASIC_INFO *data_offset;
|
||||||
__u16 params, param_offset, offset, count, byte_count;
|
__u16 params, param_offset, offset, count, byte_count;
|
||||||
|
__u64 mode = args->mode;
|
||||||
|
|
||||||
cFYI(1, ("In SetUID/GID/Mode"));
|
cFYI(1, ("In SetUID/GID/Mode"));
|
||||||
setPermsRetry:
|
setPermsRetry:
|
||||||
|
@ -5080,16 +5080,16 @@ setPermsRetry:
|
||||||
set file size and do not want to truncate file size to zero
|
set file size and do not want to truncate file size to zero
|
||||||
accidently as happened on one Samba server beta by putting
|
accidently as happened on one Samba server beta by putting
|
||||||
zero instead of -1 here */
|
zero instead of -1 here */
|
||||||
data_offset->EndOfFile = NO_CHANGE_64;
|
data_offset->EndOfFile = cpu_to_le64(NO_CHANGE_64);
|
||||||
data_offset->NumOfBytes = NO_CHANGE_64;
|
data_offset->NumOfBytes = cpu_to_le64(NO_CHANGE_64);
|
||||||
data_offset->LastStatusChange = NO_CHANGE_64;
|
data_offset->LastStatusChange = cpu_to_le64(args->ctime);
|
||||||
data_offset->LastAccessTime = NO_CHANGE_64;
|
data_offset->LastAccessTime = cpu_to_le64(args->atime);
|
||||||
data_offset->LastModificationTime = NO_CHANGE_64;
|
data_offset->LastModificationTime = cpu_to_le64(args->mtime);
|
||||||
data_offset->Uid = cpu_to_le64(uid);
|
data_offset->Uid = cpu_to_le64(args->uid);
|
||||||
data_offset->Gid = cpu_to_le64(gid);
|
data_offset->Gid = cpu_to_le64(args->gid);
|
||||||
/* better to leave device as zero when it is */
|
/* better to leave device as zero when it is */
|
||||||
data_offset->DevMajor = cpu_to_le64(MAJOR(device));
|
data_offset->DevMajor = cpu_to_le64(MAJOR(args->device));
|
||||||
data_offset->DevMinor = cpu_to_le64(MINOR(device));
|
data_offset->DevMinor = cpu_to_le64(MINOR(args->device));
|
||||||
data_offset->Permissions = cpu_to_le64(mode);
|
data_offset->Permissions = cpu_to_le64(mode);
|
||||||
|
|
||||||
if (S_ISREG(mode))
|
if (S_ISREG(mode))
|
||||||
|
|
|
@ -226,23 +226,26 @@ cifs_create(struct inode *inode, struct dentry *direntry, int mode,
|
||||||
/* If Open reported that we actually created a file
|
/* If Open reported that we actually created a file
|
||||||
then we now have to set the mode if possible */
|
then we now have to set the mode if possible */
|
||||||
if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) {
|
if ((pTcon->unix_ext) && (oplock & CIFS_CREATE_ACTION)) {
|
||||||
|
struct cifs_unix_set_info_args args = {
|
||||||
|
.mode = mode,
|
||||||
|
.ctime = NO_CHANGE_64,
|
||||||
|
.atime = NO_CHANGE_64,
|
||||||
|
.mtime = NO_CHANGE_64,
|
||||||
|
.device = 0,
|
||||||
|
};
|
||||||
|
|
||||||
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
|
||||||
CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
|
args.uid = (__u64) current->fsuid;
|
||||||
(__u64)current->fsuid,
|
args.gid = (__u64) current->fsgid;
|
||||||
(__u64)current->fsgid,
|
|
||||||
0 /* dev */,
|
|
||||||
cifs_sb->local_nls,
|
|
||||||
cifs_sb->mnt_cifs_flags &
|
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
||||||
} else {
|
} else {
|
||||||
CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode,
|
args.uid = NO_CHANGE_64;
|
||||||
(__u64)-1,
|
args.gid = NO_CHANGE_64;
|
||||||
(__u64)-1,
|
|
||||||
0 /* dev */,
|
|
||||||
cifs_sb->local_nls,
|
|
||||||
cifs_sb->mnt_cifs_flags &
|
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args,
|
||||||
|
cifs_sb->local_nls,
|
||||||
|
cifs_sb->mnt_cifs_flags &
|
||||||
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
||||||
} else {
|
} else {
|
||||||
/* BB implement mode setting via Windows security
|
/* BB implement mode setting via Windows security
|
||||||
descriptors e.g. */
|
descriptors e.g. */
|
||||||
|
@ -357,21 +360,24 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, int mode,
|
||||||
if (full_path == NULL)
|
if (full_path == NULL)
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
else if (pTcon->unix_ext) {
|
else if (pTcon->unix_ext) {
|
||||||
mode &= ~current->fs->umask;
|
struct cifs_unix_set_info_args args = {
|
||||||
|
.mode = mode & ~current->fs->umask,
|
||||||
|
.ctime = NO_CHANGE_64,
|
||||||
|
.atime = NO_CHANGE_64,
|
||||||
|
.mtime = NO_CHANGE_64,
|
||||||
|
.device = device_number,
|
||||||
|
};
|
||||||
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
|
||||||
rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path,
|
args.uid = (__u64) current->fsuid;
|
||||||
mode, (__u64)current->fsuid,
|
args.gid = (__u64) current->fsgid;
|
||||||
(__u64)current->fsgid,
|
|
||||||
device_number, cifs_sb->local_nls,
|
|
||||||
cifs_sb->mnt_cifs_flags &
|
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
||||||
} else {
|
} else {
|
||||||
rc = CIFSSMBUnixSetPerms(xid, pTcon,
|
args.uid = NO_CHANGE_64;
|
||||||
full_path, mode, (__u64)-1, (__u64)-1,
|
args.gid = NO_CHANGE_64;
|
||||||
device_number, cifs_sb->local_nls,
|
|
||||||
cifs_sb->mnt_cifs_flags &
|
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
||||||
}
|
}
|
||||||
|
rc = CIFSSMBUnixSetInfo(xid, pTcon, full_path,
|
||||||
|
&args, cifs_sb->local_nls,
|
||||||
|
cifs_sb->mnt_cifs_flags &
|
||||||
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
||||||
|
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
rc = cifs_get_inode_info_unix(&newinode, full_path,
|
rc = cifs_get_inode_info_unix(&newinode, full_path,
|
||||||
|
|
|
@ -310,18 +310,19 @@ int cifs_open(struct inode *inode, struct file *file)
|
||||||
/* time to set mode which we can not set earlier due to
|
/* time to set mode which we can not set earlier due to
|
||||||
problems creating new read-only files */
|
problems creating new read-only files */
|
||||||
if (pTcon->unix_ext) {
|
if (pTcon->unix_ext) {
|
||||||
CIFSSMBUnixSetPerms(xid, pTcon, full_path,
|
struct cifs_unix_set_info_args args = {
|
||||||
inode->i_mode,
|
.mode = inode->i_mode,
|
||||||
(__u64)-1, (__u64)-1, 0 /* dev */,
|
.uid = NO_CHANGE_64,
|
||||||
|
.gid = NO_CHANGE_64,
|
||||||
|
.ctime = NO_CHANGE_64,
|
||||||
|
.atime = NO_CHANGE_64,
|
||||||
|
.mtime = NO_CHANGE_64,
|
||||||
|
.device = 0,
|
||||||
|
};
|
||||||
|
CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args,
|
||||||
cifs_sb->local_nls,
|
cifs_sb->local_nls,
|
||||||
cifs_sb->mnt_cifs_flags &
|
cifs_sb->mnt_cifs_flags &
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
||||||
} else {
|
|
||||||
/* BB implement via Windows security descriptors eg
|
|
||||||
CIFSSMBWinSetPerms(xid, pTcon, full_path, mode,
|
|
||||||
-1, -1, local_nls);
|
|
||||||
in the meantime could set r/o dos attribute when
|
|
||||||
perms are eg: mode & 0222 == 0 */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -986,23 +986,24 @@ mkdir_get_info:
|
||||||
direntry->d_inode->i_nlink = 2;
|
direntry->d_inode->i_nlink = 2;
|
||||||
mode &= ~current->fs->umask;
|
mode &= ~current->fs->umask;
|
||||||
if (pTcon->unix_ext) {
|
if (pTcon->unix_ext) {
|
||||||
|
struct cifs_unix_set_info_args args = {
|
||||||
|
.mode = mode,
|
||||||
|
.ctime = NO_CHANGE_64,
|
||||||
|
.atime = NO_CHANGE_64,
|
||||||
|
.mtime = NO_CHANGE_64,
|
||||||
|
.device = 0,
|
||||||
|
};
|
||||||
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) {
|
||||||
CIFSSMBUnixSetPerms(xid, pTcon, full_path,
|
args.uid = (__u64)current->fsuid;
|
||||||
mode,
|
args.gid = (__u64)current->fsgid;
|
||||||
(__u64)current->fsuid,
|
|
||||||
(__u64)current->fsgid,
|
|
||||||
0 /* dev_t */,
|
|
||||||
cifs_sb->local_nls,
|
|
||||||
cifs_sb->mnt_cifs_flags &
|
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
||||||
} else {
|
} else {
|
||||||
CIFSSMBUnixSetPerms(xid, pTcon, full_path,
|
args.uid = NO_CHANGE_64;
|
||||||
mode, (__u64)-1,
|
args.gid = NO_CHANGE_64;
|
||||||
(__u64)-1, 0 /* dev_t */,
|
|
||||||
cifs_sb->local_nls,
|
|
||||||
cifs_sb->mnt_cifs_flags &
|
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
||||||
}
|
}
|
||||||
|
CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args,
|
||||||
|
cifs_sb->local_nls,
|
||||||
|
cifs_sb->mnt_cifs_flags &
|
||||||
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
||||||
} else {
|
} else {
|
||||||
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) &&
|
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) &&
|
||||||
(mode & S_IWUGO) == 0) {
|
(mode & S_IWUGO) == 0) {
|
||||||
|
@ -1500,9 +1501,9 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
|
||||||
FILE_BASIC_INFO time_buf;
|
FILE_BASIC_INFO time_buf;
|
||||||
bool set_time = false;
|
bool set_time = false;
|
||||||
bool set_dosattr = false;
|
bool set_dosattr = false;
|
||||||
__u64 mode = 0xFFFFFFFFFFFFFFFFULL;
|
__u64 mode = NO_CHANGE_64;
|
||||||
__u64 uid = 0xFFFFFFFFFFFFFFFFULL;
|
__u64 uid = NO_CHANGE_64;
|
||||||
__u64 gid = 0xFFFFFFFFFFFFFFFFULL;
|
__u64 gid = NO_CHANGE_64;
|
||||||
struct cifsInodeInfo *cifsInode;
|
struct cifsInodeInfo *cifsInode;
|
||||||
struct inode *inode = direntry->d_inode;
|
struct inode *inode = direntry->d_inode;
|
||||||
|
|
||||||
|
@ -1586,12 +1587,21 @@ int cifs_setattr(struct dentry *direntry, struct iattr *attrs)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pTcon->unix_ext)
|
if ((pTcon->unix_ext)
|
||||||
&& (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID)))
|
&& (attrs->ia_valid & (ATTR_MODE | ATTR_GID | ATTR_UID))) {
|
||||||
rc = CIFSSMBUnixSetPerms(xid, pTcon, full_path, mode, uid, gid,
|
struct cifs_unix_set_info_args args = {
|
||||||
0 /* dev_t */, cifs_sb->local_nls,
|
.mode = mode,
|
||||||
cifs_sb->mnt_cifs_flags &
|
.uid = uid,
|
||||||
|
.gid = gid,
|
||||||
|
.ctime = NO_CHANGE_64,
|
||||||
|
.atime = NO_CHANGE_64,
|
||||||
|
.mtime = NO_CHANGE_64,
|
||||||
|
.device = 0,
|
||||||
|
};
|
||||||
|
rc = CIFSSMBUnixSetInfo(xid, pTcon, full_path, &args,
|
||||||
|
cifs_sb->local_nls,
|
||||||
|
cifs_sb->mnt_cifs_flags &
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
||||||
else if (attrs->ia_valid & ATTR_MODE) {
|
} else if (attrs->ia_valid & ATTR_MODE) {
|
||||||
rc = 0;
|
rc = 0;
|
||||||
#ifdef CONFIG_CIFS_EXPERIMENTAL
|
#ifdef CONFIG_CIFS_EXPERIMENTAL
|
||||||
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
|
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
|
||||||
|
|
Loading…
Reference in New Issue