Commit 4523cc30 authored by Steve French's avatar Steve French

[CIFS] UID/GID override on CIFS mounts to Samba

When CIFS Unix Extensions are negotiated we get the Unix uid and gid
owners of the file from the server (on the Unix Query Path Info
levels), but if the server's uids don't match the client uid's users
were having to disable the Unix Extensions (which turned off features
they still wanted).   The changeset patch allows users to override uid
and/or gid for file/directory owner with a default uid and/or gid
specified at mount (as is often done when mounting from Linux cifs
client to Windows server).  This changeset also displays the uid
and gid used by default in /proc/mounts (if applicable).

Also cleans up code by adding some of the missing spaces after
"if" keywords per-kernel style guidelines (as suggested by Randy Dunlap
when he reviewed the patch).
Signed-off-by: default avatarSteve French <sfrench@us.ibm.com>
parent 984acfe1
...@@ -2,7 +2,11 @@ Version 1.49 ...@@ -2,7 +2,11 @@ Version 1.49
------------ ------------
IPv6 support. Enable ipv6 addresses to be passed on mount (put the ipv6 IPv6 support. Enable ipv6 addresses to be passed on mount (put the ipv6
address after the "ip=" mount option, at least until mount.cifs is fixed to address after the "ip=" mount option, at least until mount.cifs is fixed to
handle DNS host to ipv6 name translation). handle DNS host to ipv6 name translation). Accept override of uid or gid
on mount even when Unix Extensions are negotiated (it used to be ignored
when Unix Extensions were ignored). This allows users to override the
default uid and gid for files when they are certain that the uids or
gids on the server do not match those of the client.
Version 1.48 Version 1.48
------------ ------------
......
...@@ -257,13 +257,19 @@ A partial list of the supported mount options follows: ...@@ -257,13 +257,19 @@ A partial list of the supported mount options follows:
mount. mount.
domain Set the SMB/CIFS workgroup name prepended to the domain Set the SMB/CIFS workgroup name prepended to the
username during CIFS session establishment username during CIFS session establishment
uid If CIFS Unix extensions are not supported by the server uid Set the default uid for inodes. For mounts to servers
this overrides the default uid for inodes. For mounts to which do support the CIFS Unix extensions, such as a
servers which do support the CIFS Unix extensions, such properly configured Samba server, the server provides
as a properly configured Samba server, the server provides the uid, gid and mode so this parameter should not be
the uid, gid and mode. For servers which do not support specified unless the server and clients uid and gid
the Unix extensions, the default uid (and gid) returned on numbering differ. If the server and client are in the
lookup of existing files is the uid (gid) of the person same domain (e.g. running winbind or nss_ldap) and
the server supports the Unix Extensions then the uid
and gid can be retrieved from the server (and uid
and gid would not have to be specifed on the mount.
For servers which do not support the CIFS Unix
extensions, the default uid (and gid) returned on lookup
of existing files will be the uid (gid) of the person
who executed the mount (root, except when mount.cifs who executed the mount (root, except when mount.cifs
is configured setuid for user mounts) unless the "uid=" is configured setuid for user mounts) unless the "uid="
(gid) mount option is specified. For the uid (gid) of newly (gid) mount option is specified. For the uid (gid) of newly
...@@ -281,8 +287,7 @@ A partial list of the supported mount options follows: ...@@ -281,8 +287,7 @@ A partial list of the supported mount options follows:
the client. Note that the mount.cifs helper must be the client. Note that the mount.cifs helper must be
at version 1.10 or higher to support specifying the uid at version 1.10 or higher to support specifying the uid
(or gid) in non-numberic form. (or gid) in non-numberic form.
gid If CIFS Unix extensions are not supported by the server gid Set the default gid for inodes (similar to above).
this overrides the default gid for inodes.
file_mode If CIFS Unix extensions are not supported by the server file_mode If CIFS Unix extensions are not supported by the server
this overrides the default mode for file inodes. this overrides the default mode for file inodes.
dir_mode If CIFS Unix extensions are not supported by the server dir_mode If CIFS Unix extensions are not supported by the server
......
...@@ -80,7 +80,7 @@ need to add ability to set time to server (utimes command) ...@@ -80,7 +80,7 @@ need to add ability to set time to server (utimes command)
u) DOS attrs - returned as pseudo-xattr in Samba format (check VFAT and NTFS for this too) u) DOS attrs - returned as pseudo-xattr in Samba format (check VFAT and NTFS for this too)
v) mount check for unmatched uids - and uid override v) mount check for unmatched uids
w) Add mount option for Linux extension disable per mount, and partial w) Add mount option for Linux extension disable per mount, and partial
disable per mount (uid off, symlink/fifo/mknod on but what about posix acls?) disable per mount (uid off, symlink/fifo/mknod on but what about posix acls?)
......
...@@ -22,12 +22,14 @@ ...@@ -22,12 +22,14 @@
#define CIFS_MOUNT_SET_UID 2 /* set current->euid in create etc. */ #define CIFS_MOUNT_SET_UID 2 /* set current->euid in create etc. */
#define CIFS_MOUNT_SERVER_INUM 4 /* inode numbers from uniqueid from server */ #define CIFS_MOUNT_SERVER_INUM 4 /* inode numbers from uniqueid from server */
#define CIFS_MOUNT_DIRECT_IO 8 /* do not write nor read through page cache */ #define CIFS_MOUNT_DIRECT_IO 8 /* do not write nor read through page cache */
#define CIFS_MOUNT_NO_XATTR 0x10 /* if set - disable xattr support */ #define CIFS_MOUNT_NO_XATTR 0x10 /* if set - disable xattr support */
#define CIFS_MOUNT_MAP_SPECIAL_CHR 0x20 /* remap illegal chars in filenames */ #define CIFS_MOUNT_MAP_SPECIAL_CHR 0x20 /* remap illegal chars in filenames */
#define CIFS_MOUNT_POSIX_PATHS 0x40 /* Negotiate posix pathnames if possible. */ #define CIFS_MOUNT_POSIX_PATHS 0x40 /* Negotiate posix pathnames if possible*/
#define CIFS_MOUNT_UNX_EMUL 0x80 /* Network compat with SFUnix emulation */ #define CIFS_MOUNT_UNX_EMUL 0x80 /* Network compat with SFUnix emulation */
#define CIFS_MOUNT_NO_BRL 0x100 /* No sending byte range locks to srv */ #define CIFS_MOUNT_NO_BRL 0x100 /* No sending byte range locks to srv */
#define CIFS_MOUNT_CIFS_ACL 0x200 /* send ACL requests to non-POSIX srv */ #define CIFS_MOUNT_CIFS_ACL 0x200 /* send ACL requests to non-POSIX srv */
#define CIFS_MOUNT_OVERR_UID 0x400 /* override uid returned from server */
#define CIFS_MOUNT_OVERR_GID 0x800 /* override gid returned from server */
struct cifs_sb_info { struct cifs_sb_info {
struct cifsTconInfo *tcon; /* primary mount */ struct cifsTconInfo *tcon; /* primary mount */
......
...@@ -100,7 +100,7 @@ cifs_read_super(struct super_block *sb, void *data, ...@@ -100,7 +100,7 @@ cifs_read_super(struct super_block *sb, void *data,
sb->s_flags |= MS_NODIRATIME | MS_NOATIME; sb->s_flags |= MS_NODIRATIME | MS_NOATIME;
sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info),GFP_KERNEL); sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info),GFP_KERNEL);
cifs_sb = CIFS_SB(sb); cifs_sb = CIFS_SB(sb);
if(cifs_sb == NULL) if (cifs_sb == NULL)
return -ENOMEM; return -ENOMEM;
rc = cifs_mount(sb, cifs_sb, data, devname); rc = cifs_mount(sb, cifs_sb, data, devname);
...@@ -115,10 +115,10 @@ cifs_read_super(struct super_block *sb, void *data, ...@@ -115,10 +115,10 @@ cifs_read_super(struct super_block *sb, void *data,
sb->s_magic = CIFS_MAGIC_NUMBER; sb->s_magic = CIFS_MAGIC_NUMBER;
sb->s_op = &cifs_super_ops; sb->s_op = &cifs_super_ops;
#ifdef CONFIG_CIFS_EXPERIMENTAL #ifdef CONFIG_CIFS_EXPERIMENTAL
if(experimEnabled != 0) if (experimEnabled != 0)
sb->s_export_op = &cifs_export_ops; sb->s_export_op = &cifs_export_ops;
#endif /* EXPERIMENTAL */ #endif /* EXPERIMENTAL */
/* if(cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512) /* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */ sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
#ifdef CONFIG_CIFS_QUOTA #ifdef CONFIG_CIFS_QUOTA
sb->s_qcop = &cifs_quotactl_ops; sb->s_qcop = &cifs_quotactl_ops;
...@@ -147,8 +147,8 @@ out_no_root: ...@@ -147,8 +147,8 @@ out_no_root:
iput(inode); iput(inode);
out_mount_failed: out_mount_failed:
if(cifs_sb) { if (cifs_sb) {
if(cifs_sb->local_nls) if (cifs_sb->local_nls)
unload_nls(cifs_sb->local_nls); unload_nls(cifs_sb->local_nls);
kfree(cifs_sb); kfree(cifs_sb);
} }
...@@ -163,7 +163,7 @@ cifs_put_super(struct super_block *sb) ...@@ -163,7 +163,7 @@ cifs_put_super(struct super_block *sb)
cFYI(1, ("In cifs_put_super")); cFYI(1, ("In cifs_put_super"));
cifs_sb = CIFS_SB(sb); cifs_sb = CIFS_SB(sb);
if(cifs_sb == NULL) { if (cifs_sb == NULL) {
cFYI(1,("Empty cifs superblock info passed to unmount")); cFYI(1,("Empty cifs superblock info passed to unmount"));
return; return;
} }
...@@ -208,14 +208,14 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf) ...@@ -208,14 +208,14 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
/* Only need to call the old QFSInfo if failed /* Only need to call the old QFSInfo if failed
on newer one */ on newer one */
if(rc) if (rc)
if(pTcon->ses->capabilities & CAP_NT_SMBS) if (pTcon->ses->capabilities & CAP_NT_SMBS)
rc = CIFSSMBQFSInfo(xid, pTcon, buf); /* not supported by OS2 */ rc = CIFSSMBQFSInfo(xid, pTcon, buf); /* not supported by OS2 */
/* Some old Windows servers also do not support level 103, retry with /* Some old Windows servers also do not support level 103, retry with
older level one if old server failed the previous call or we older level one if old server failed the previous call or we
bypassed it because we detected that this was an older LANMAN sess */ bypassed it because we detected that this was an older LANMAN sess */
if(rc) if (rc)
rc = SMBOldQFSInfo(xid, pTcon, buf); rc = SMBOldQFSInfo(xid, pTcon, buf);
/* /*
int f_type; int f_type;
...@@ -301,11 +301,19 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m) ...@@ -301,11 +301,19 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
if (cifs_sb->tcon->ses->userName) if (cifs_sb->tcon->ses->userName)
seq_printf(s, ",username=%s", seq_printf(s, ",username=%s",
cifs_sb->tcon->ses->userName); cifs_sb->tcon->ses->userName);
if(cifs_sb->tcon->ses->domainName) if (cifs_sb->tcon->ses->domainName)
seq_printf(s, ",domain=%s", seq_printf(s, ",domain=%s",
cifs_sb->tcon->ses->domainName); cifs_sb->tcon->ses->domainName);
} }
} }
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
seq_printf(s, ",posixpaths");
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) ||
!(cifs_sb->tcon->ses->capabilities & CAP_UNIX))
seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) ||
!(cifs_sb->tcon->ses->capabilities & CAP_UNIX))
seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
seq_printf(s, ",rsize=%d",cifs_sb->rsize); seq_printf(s, ",rsize=%d",cifs_sb->rsize);
seq_printf(s, ",wsize=%d",cifs_sb->wsize); seq_printf(s, ",wsize=%d",cifs_sb->wsize);
} }
...@@ -321,14 +329,14 @@ int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid, ...@@ -321,14 +329,14 @@ int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid,
struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
if(cifs_sb) if (cifs_sb)
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
else else
return -EIO; return -EIO;
xid = GetXid(); xid = GetXid();
if(pTcon) { if (pTcon) {
cFYI(1,("set type: 0x%x id: %d",quota_type,qid)); cFYI(1,("set type: 0x%x id: %d",quota_type,qid));
} else { } else {
return -EIO; return -EIO;
...@@ -346,13 +354,13 @@ int cifs_xquota_get(struct super_block * sb, int quota_type, qid_t qid, ...@@ -346,13 +354,13 @@ int cifs_xquota_get(struct super_block * sb, int quota_type, qid_t qid,
struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
if(cifs_sb) if (cifs_sb)
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
else else
return -EIO; return -EIO;
xid = GetXid(); xid = GetXid();
if(pTcon) { if (pTcon) {
cFYI(1,("set type: 0x%x id: %d",quota_type,qid)); cFYI(1,("set type: 0x%x id: %d",quota_type,qid));
} else { } else {
rc = -EIO; rc = -EIO;
...@@ -369,13 +377,13 @@ int cifs_xstate_set(struct super_block * sb, unsigned int flags, int operation) ...@@ -369,13 +377,13 @@ int cifs_xstate_set(struct super_block * sb, unsigned int flags, int operation)
struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
if(cifs_sb) if (cifs_sb)
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
else else
return -EIO; return -EIO;
xid = GetXid(); xid = GetXid();
if(pTcon) { if (pTcon) {
cFYI(1,("flags: 0x%x operation: 0x%x",flags,operation)); cFYI(1,("flags: 0x%x operation: 0x%x",flags,operation));
} else { } else {
rc = -EIO; rc = -EIO;
...@@ -392,13 +400,13 @@ int cifs_xstate_get(struct super_block * sb, struct fs_quota_stat *qstats) ...@@ -392,13 +400,13 @@ int cifs_xstate_get(struct super_block * sb, struct fs_quota_stat *qstats)
struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
if(cifs_sb) { if (cifs_sb) {
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
} else { } else {
return -EIO; return -EIO;
} }
xid = GetXid(); xid = GetXid();
if(pTcon) { if (pTcon) {
cFYI(1,("pqstats %p",qstats)); cFYI(1,("pqstats %p",qstats));
} else { } else {
rc = -EIO; rc = -EIO;
...@@ -424,11 +432,11 @@ static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags) ...@@ -424,11 +432,11 @@ static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags)
if (!(flags & MNT_FORCE)) if (!(flags & MNT_FORCE))
return; return;
cifs_sb = CIFS_SB(vfsmnt->mnt_sb); cifs_sb = CIFS_SB(vfsmnt->mnt_sb);
if(cifs_sb == NULL) if (cifs_sb == NULL)
return; return;
tcon = cifs_sb->tcon; tcon = cifs_sb->tcon;
if(tcon == NULL) if (tcon == NULL)
return; return;
down(&tcon->tconSem); down(&tcon->tconSem);
if (atomic_read(&tcon->useCount) == 1) if (atomic_read(&tcon->useCount) == 1)
...@@ -437,7 +445,7 @@ static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags) ...@@ -437,7 +445,7 @@ static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags)
/* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */ /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
/* cancel_notify_requests(tcon); */ /* cancel_notify_requests(tcon); */
if(tcon->ses && tcon->ses->server) if (tcon->ses && tcon->ses->server)
{ {
cFYI(1,("wake up tasks now - umount begin not complete")); cFYI(1,("wake up tasks now - umount begin not complete"));
wake_up_all(&tcon->ses->server->request_q); wake_up_all(&tcon->ses->server->request_q);
...@@ -723,7 +731,7 @@ cifs_destroy_inodecache(void) ...@@ -723,7 +731,7 @@ cifs_destroy_inodecache(void)
static int static int
cifs_init_request_bufs(void) cifs_init_request_bufs(void)
{ {
if(CIFSMaxBufSize < 8192) { if (CIFSMaxBufSize < 8192) {
/* Buffer size can not be smaller than 2 * PATH_MAX since maximum /* Buffer size can not be smaller than 2 * PATH_MAX since maximum
Unicode path name has to fit in any SMB/CIFS path based frames */ Unicode path name has to fit in any SMB/CIFS path based frames */
CIFSMaxBufSize = 8192; CIFSMaxBufSize = 8192;
...@@ -740,7 +748,7 @@ cifs_init_request_bufs(void) ...@@ -740,7 +748,7 @@ cifs_init_request_bufs(void)
if (cifs_req_cachep == NULL) if (cifs_req_cachep == NULL)
return -ENOMEM; return -ENOMEM;
if(cifs_min_rcv < 1) if (cifs_min_rcv < 1)
cifs_min_rcv = 1; cifs_min_rcv = 1;
else if (cifs_min_rcv > 64) { else if (cifs_min_rcv > 64) {
cifs_min_rcv = 64; cifs_min_rcv = 64;
...@@ -750,7 +758,7 @@ cifs_init_request_bufs(void) ...@@ -750,7 +758,7 @@ cifs_init_request_bufs(void)
cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv, cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
cifs_req_cachep); cifs_req_cachep);
if(cifs_req_poolp == NULL) { if (cifs_req_poolp == NULL) {
kmem_cache_destroy(cifs_req_cachep); kmem_cache_destroy(cifs_req_cachep);
return -ENOMEM; return -ENOMEM;
} }
...@@ -771,7 +779,7 @@ cifs_init_request_bufs(void) ...@@ -771,7 +779,7 @@ cifs_init_request_bufs(void)
return -ENOMEM; return -ENOMEM;
} }
if(cifs_min_small < 2) if (cifs_min_small < 2)
cifs_min_small = 2; cifs_min_small = 2;
else if (cifs_min_small > 256) { else if (cifs_min_small > 256) {
cifs_min_small = 256; cifs_min_small = 256;
...@@ -781,7 +789,7 @@ cifs_init_request_bufs(void) ...@@ -781,7 +789,7 @@ cifs_init_request_bufs(void)
cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small, cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
cifs_sm_req_cachep); cifs_sm_req_cachep);
if(cifs_sm_req_poolp == NULL) { if (cifs_sm_req_poolp == NULL) {
mempool_destroy(cifs_req_poolp); mempool_destroy(cifs_req_poolp);
kmem_cache_destroy(cifs_req_cachep); kmem_cache_destroy(cifs_req_cachep);
kmem_cache_destroy(cifs_sm_req_cachep); kmem_cache_destroy(cifs_sm_req_cachep);
...@@ -811,7 +819,7 @@ cifs_init_mids(void) ...@@ -811,7 +819,7 @@ cifs_init_mids(void)
/* 3 is a reasonable minimum number of simultaneous operations */ /* 3 is a reasonable minimum number of simultaneous operations */
cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep); cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
if(cifs_mid_poolp == NULL) { if (cifs_mid_poolp == NULL) {
kmem_cache_destroy(cifs_mid_cachep); kmem_cache_destroy(cifs_mid_cachep);
return -ENOMEM; return -ENOMEM;
} }
...@@ -849,14 +857,14 @@ static int cifs_oplock_thread(void * dummyarg) ...@@ -849,14 +857,14 @@ static int cifs_oplock_thread(void * dummyarg)
continue; continue;
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
if(list_empty(&GlobalOplock_Q)) { if (list_empty(&GlobalOplock_Q)) {
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
set_current_state(TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout(39*HZ); schedule_timeout(39*HZ);
} else { } else {
oplock_item = list_entry(GlobalOplock_Q.next, oplock_item = list_entry(GlobalOplock_Q.next,
struct oplock_q_entry, qhead); struct oplock_q_entry, qhead);
if(oplock_item) { if (oplock_item) {
cFYI(1,("found oplock item to write out")); cFYI(1,("found oplock item to write out"));
pTcon = oplock_item->tcon; pTcon = oplock_item->tcon;
inode = oplock_item->pinode; inode = oplock_item->pinode;
...@@ -870,7 +878,7 @@ static int cifs_oplock_thread(void * dummyarg) ...@@ -870,7 +878,7 @@ static int cifs_oplock_thread(void * dummyarg)
/* mutex_lock(&inode->i_mutex);*/ /* mutex_lock(&inode->i_mutex);*/
if (S_ISREG(inode->i_mode)) { if (S_ISREG(inode->i_mode)) {
rc = filemap_fdatawrite(inode->i_mapping); rc = filemap_fdatawrite(inode->i_mapping);
if(CIFS_I(inode)->clientCanCacheRead == 0) { if (CIFS_I(inode)->clientCanCacheRead == 0) {
filemap_fdatawait(inode->i_mapping); filemap_fdatawait(inode->i_mapping);
invalidate_remote_inode(inode); invalidate_remote_inode(inode);
} }
...@@ -887,7 +895,7 @@ static int cifs_oplock_thread(void * dummyarg) ...@@ -887,7 +895,7 @@ static int cifs_oplock_thread(void * dummyarg)
not bother sending an oplock release if session not bother sending an oplock release if session
to server still is disconnected since oplock to server still is disconnected since oplock
already released by the server in that case */ already released by the server in that case */
if(pTcon->tidStatus != CifsNeedReconnect) { if (pTcon->tidStatus != CifsNeedReconnect) {
rc = CIFSSMBLock(0, pTcon, netfid, rc = CIFSSMBLock(0, pTcon, netfid,
0 /* len */ , 0 /* offset */, 0, 0 /* len */ , 0 /* offset */, 0,
0, LOCKING_ANDX_OPLOCK_RELEASE, 0, LOCKING_ANDX_OPLOCK_RELEASE,
...@@ -921,7 +929,7 @@ static int cifs_dnotify_thread(void * dummyarg) ...@@ -921,7 +929,7 @@ static int cifs_dnotify_thread(void * dummyarg)
list_for_each(tmp, &GlobalSMBSessionList) { list_for_each(tmp, &GlobalSMBSessionList) {
ses = list_entry(tmp, struct cifsSesInfo, ses = list_entry(tmp, struct cifsSesInfo,
cifsSessionList); cifsSessionList);
if(ses && ses->server && if (ses && ses->server &&
atomic_read(&ses->server->inFlight)) atomic_read(&ses->server->inFlight))
wake_up_all(&ses->server->response_q); wake_up_all(&ses->server->response_q);
} }
...@@ -970,10 +978,10 @@ init_cifs(void) ...@@ -970,10 +978,10 @@ init_cifs(void)
rwlock_init(&GlobalSMBSeslock); rwlock_init(&GlobalSMBSeslock);
spin_lock_init(&GlobalMid_Lock); spin_lock_init(&GlobalMid_Lock);
if(cifs_max_pending < 2) { if (cifs_max_pending < 2) {
cifs_max_pending = 2; cifs_max_pending = 2;
cFYI(1,("cifs_max_pending set to min of 2")); cFYI(1,("cifs_max_pending set to min of 2"));
} else if(cifs_max_pending > 256) { } else if (cifs_max_pending > 256) {
cifs_max_pending = 256; cifs_max_pending = 256;
cFYI(1,("cifs_max_pending set to max of 256")); cFYI(1,("cifs_max_pending set to max of 256"));
} }
......
This diff is collapsed.
...@@ -90,7 +90,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -90,7 +90,7 @@ int cifs_get_inode_info_unix(struct inode **pinode,
(*pinode)->i_ino = (*pinode)->i_ino =
(unsigned long)findData.UniqueId; (unsigned long)findData.UniqueId;
} /* note ino incremented to unique num in new_inode */ } /* note ino incremented to unique num in new_inode */
if(sb->s_flags & MS_NOATIME) if (sb->s_flags & MS_NOATIME)
(*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME;
insert_inode_hash(*pinode); insert_inode_hash(*pinode);
...@@ -139,8 +139,17 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -139,8 +139,17 @@ int cifs_get_inode_info_unix(struct inode **pinode,
inode->i_mode |= S_IFREG; inode->i_mode |= S_IFREG;
cFYI(1,("unknown type %d",type)); cFYI(1,("unknown type %d",type));
} }
inode->i_uid = le64_to_cpu(findData.Uid);
inode->i_gid = le64_to_cpu(findData.Gid); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
inode->i_uid = cifs_sb->mnt_uid;
else
inode->i_uid = le64_to_cpu(findData.Uid);
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
inode->i_gid = cifs_sb->mnt_gid;
else
inode->i_gid = le64_to_cpu(findData.Gid);
inode->i_nlink = le64_to_cpu(findData.Nlinks); inode->i_nlink = le64_to_cpu(findData.Nlinks);
spin_lock(&inode->i_lock); spin_lock(&inode->i_lock);
...@@ -178,13 +187,13 @@ int cifs_get_inode_info_unix(struct inode **pinode, ...@@ -178,13 +187,13 @@ int cifs_get_inode_info_unix(struct inode **pinode,
&cifs_file_direct_nobrl_ops; &cifs_file_direct_nobrl_ops;
else else
inode->i_fop = &cifs_file_direct_ops; inode->i_fop = &cifs_file_direct_ops;
} else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
inode->i_fop = &cifs_file_nobrl_ops; inode->i_fop = &cifs_file_nobrl_ops;
else /* not direct, send byte range locks */ else /* not direct, send byte range locks */
inode->i_fop = &cifs_file_ops; inode->i_fop = &cifs_file_ops;
/* check if server can support readpages */ /* check if server can support readpages */
if(pTcon->ses->server->maxBuf < if (pTcon->ses->server->maxBuf <
PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
inode->i_data.a_ops = &cifs_addr_ops_smallbuf; inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
else else
...@@ -220,7 +229,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, ...@@ -220,7 +229,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size,
pbuf = buf; pbuf = buf;
if(size == 0) { if (size == 0) {
inode->i_mode |= S_IFIFO; inode->i_mode |= S_IFIFO;
return 0; return 0;
} else if (size < 8) { } else if (size < 8) {
...@@ -239,11 +248,11 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, ...@@ -239,11 +248,11 @@ static int decode_sfu_inode(struct inode * inode, __u64 size,
netfid, netfid,
24 /* length */, 0 /* offset */, 24 /* length */, 0 /* offset */,
&bytes_read, &pbuf, &buf_type); &bytes_read, &pbuf, &buf_type);
if((rc == 0) && (bytes_read >= 8)) { if ((rc == 0) && (bytes_read >= 8)) {
if(memcmp("IntxBLK", pbuf, 8) == 0) { if (memcmp("IntxBLK", pbuf, 8) == 0) {
cFYI(1,("Block device")); cFYI(1,("Block device"));
inode->i_mode |= S_IFBLK; inode->i_mode |= S_IFBLK;
if(bytes_read == 24) { if (bytes_read == 24) {
/* we have enough to decode dev num */ /* we have enough to decode dev num */
__u64 mjr; /* major */ __u64 mjr; /* major */
__u64 mnr; /* minor */ __u64 mnr; /* minor */
...@@ -251,10 +260,10 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, ...@@ -251,10 +260,10 @@ static int decode_sfu_inode(struct inode * inode, __u64 size,
mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); mnr = le64_to_cpu(*(__le64 *)(pbuf+16));
inode->i_rdev = MKDEV(mjr, mnr); inode->i_rdev = MKDEV(mjr, mnr);
} }
} else if(memcmp("IntxCHR", pbuf, 8) == 0) { } else if (memcmp("IntxCHR", pbuf, 8) == 0) {
cFYI(1,("Char device")); cFYI(1,("Char device"));
inode->i_mode |= S_IFCHR; inode->i_mode |= S_IFCHR;
if(bytes_read == 24) { if (bytes_read == 24) {
/* we have enough to decode dev num */ /* we have enough to decode dev num */
__u64 mjr; /* major */ __u64 mjr; /* major */
__u64 mnr; /* minor */ __u64 mnr; /* minor */
...@@ -262,7 +271,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, ...@@ -262,7 +271,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size,
mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); mnr = le64_to_cpu(*(__le64 *)(pbuf+16));
inode->i_rdev = MKDEV(mjr, mnr); inode->i_rdev = MKDEV(mjr, mnr);
} }
} else if(memcmp("IntxLNK", pbuf, 7) == 0) { } else if (memcmp("IntxLNK", pbuf, 7) == 0) {
cFYI(1,("Symlink")); cFYI(1,("Symlink"));
inode->i_mode |= S_IFLNK; inode->i_mode |= S_IFLNK;
} else { } else {
...@@ -293,7 +302,7 @@ static int get_sfu_uid_mode(struct inode * inode, ...@@ -293,7 +302,7 @@ static int get_sfu_uid_mode(struct inode * inode,
rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS", rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS",
ea_value, 4 /* size of buf */, cifs_sb->local_nls, ea_value, 4 /* size of buf */, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
if(rc < 0) if (rc < 0)
return (int)rc; return (int)rc;
else if (rc > 3) { else if (rc > 3) {
mode = le32_to_cpu(*((__le32 *)ea_value)); mode = le32_to_cpu(*((__le32 *)ea_value));
...@@ -348,7 +357,7 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -348,7 +357,7 @@ int cifs_get_inode_info(struct inode **pinode,
/* BB optimize code so we do not make the above call /* BB optimize code so we do not make the above call
when server claims no NT SMB support and the above call when server claims no NT SMB support and the above call
failed at least once - set flag in tcon or mount */ failed at least once - set flag in tcon or mount */
if((rc == -EOPNOTSUPP) || (rc == -EINVAL)) { if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) {
rc = SMBQueryInformation(xid, pTcon, search_path, rc = SMBQueryInformation(xid, pTcon, search_path,
pfindData, cifs_sb->local_nls, pfindData, cifs_sb->local_nls,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
...@@ -425,7 +434,7 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -425,7 +434,7 @@ int cifs_get_inode_info(struct inode **pinode,
} else /* do we need cast or hash to ino? */ } else /* do we need cast or hash to ino? */
(*pinode)->i_ino = inode_num; (*pinode)->i_ino = inode_num;
} /* else ino incremented to unique num in new_inode*/ } /* else ino incremented to unique num in new_inode*/
if(sb->s_flags & MS_NOATIME) if (sb->s_flags & MS_NOATIME)
(*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME;
insert_inode_hash(*pinode); insert_inode_hash(*pinode);
} }
...@@ -442,7 +451,7 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -442,7 +451,7 @@ int cifs_get_inode_info(struct inode **pinode,
(pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/ (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/
/* Linux can not store file creation time so ignore it */ /* Linux can not store file creation time so ignore it */
if(pfindData->LastAccessTime) if (pfindData->LastAccessTime)
inode->i_atime = cifs_NTtimeToUnix inode->i_atime = cifs_NTtimeToUnix
(le64_to_cpu(pfindData->LastAccessTime)); (le64_to_cpu(pfindData->LastAccessTime));
else /* do not need to use current_fs_time - time not stored */ else /* do not need to use current_fs_time - time not stored */
...@@ -452,7 +461,7 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -452,7 +461,7 @@ int cifs_get_inode_info(struct inode **pinode,
inode->i_ctime = inode->i_ctime =
cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime));
cFYI(0, ("Attributes came in as 0x%x", attr)); cFYI(0, ("Attributes came in as 0x%x", attr));
if(adjustTZ && (pTcon->ses) && (pTcon->ses->server)) { if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) {
inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj; inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj;
inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj; inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj;
} }
...@@ -521,8 +530,10 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -521,8 +530,10 @@ int cifs_get_inode_info(struct inode **pinode,
/* BB fill in uid and gid here? with help from winbind? /* BB fill in uid and gid here? with help from winbind?
or retrieve from NTFS stream extended attribute */ or retrieve from NTFS stream extended attribute */
if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) {
/* fill in uid, gid, mode from server ACL */ /* fill in uid, gid, mode from server ACL */
/* BB FIXME this should also take into account the
* default uid specified on mount if present */
get_sfu_uid_mode(inode, search_path, cifs_sb, xid); get_sfu_uid_mode(inode, search_path, cifs_sb, xid);
} else if (atomic_read(&cifsInfo->inUse) == 0) { } else if (atomic_read(&cifsInfo->inUse) == 0) {
inode->i_uid = cifs_sb->mnt_uid; inode->i_uid = cifs_sb->mnt_uid;
...@@ -541,12 +552,12 @@ int cifs_get_inode_info(struct inode **pinode, ...@@ -541,12 +552,12 @@ int cifs_get_inode_info(struct inode **pinode,
&cifs_file_direct_nobrl_ops; &cifs_file_direct_nobrl_ops;
else else
inode->i_fop = &cifs_file_direct_ops; inode->i_fop = &cifs_file_direct_ops;
} else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
inode->i_fop = &cifs_file_nobrl_ops; inode->i_fop = &cifs_file_nobrl_ops;
else /* not direct, send byte range locks */ else /* not direct, send byte range locks */
inode->i_fop = &cifs_file_ops; inode->i_fop = &cifs_file_ops;
if(pTcon->ses->server->maxBuf < if (pTcon->ses->server->maxBuf <
PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)
inode->i_data.a_ops = &cifs_addr_ops_smallbuf; inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
else else
...@@ -597,7 +608,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) ...@@ -597,7 +608,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
xid = GetXid(); xid = GetXid();
if(inode) if (inode)
cifs_sb = CIFS_SB(inode->i_sb); cifs_sb = CIFS_SB(inode->i_sb);
else else
cifs_sb = CIFS_SB(direntry->d_sb); cifs_sb = CIFS_SB(direntry->d_sb);
...@@ -723,7 +734,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) ...@@ -723,7 +734,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry)
when needed */ when needed */
direntry->d_inode->i_ctime = current_fs_time(inode->i_sb); direntry->d_inode->i_ctime = current_fs_time(inode->i_sb);
} }
if(inode) { if (inode) {
inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb); inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb);
cifsInode = CIFS_I(inode); cifsInode = CIFS_I(inode);
cifsInode->time = 0; /* force revalidate of dir as well */ cifsInode->time = 0; /* force revalidate of dir as well */
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment