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"));
} }
......
...@@ -75,6 +75,8 @@ struct smb_vol { ...@@ -75,6 +75,8 @@ struct smb_vol {
unsigned retry:1; unsigned retry:1;
unsigned intr:1; unsigned intr:1;
unsigned setuids:1; unsigned setuids:1;
unsigned override_uid:1;
unsigned override_gid:1;
unsigned noperm:1; unsigned noperm:1;
unsigned no_psx_acl:1; /* set if posix acl support should be disabled */ unsigned no_psx_acl:1; /* set if posix acl support should be disabled */
unsigned cifs_acl:1; unsigned cifs_acl:1;
...@@ -972,7 +974,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -972,7 +974,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
} }
if ((temp_len = strnlen(value, 300)) < 300) { if ((temp_len = strnlen(value, 300)) < 300) {
vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); vol->UNC = kmalloc(temp_len+1,GFP_KERNEL);
if(vol->UNC == NULL) if (vol->UNC == NULL)
return 1; return 1;
strcpy(vol->UNC,value); strcpy(vol->UNC,value);
if (strncmp(vol->UNC, "//", 2) == 0) { if (strncmp(vol->UNC, "//", 2) == 0) {
...@@ -1009,12 +1011,12 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -1009,12 +1011,12 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
return 1; /* needs_arg; */ return 1; /* needs_arg; */
} }
if ((temp_len = strnlen(value, 1024)) < 1024) { if ((temp_len = strnlen(value, 1024)) < 1024) {
if(value[0] != '/') if (value[0] != '/')
temp_len++; /* missing leading slash */ temp_len++; /* missing leading slash */
vol->prepath = kmalloc(temp_len+1,GFP_KERNEL); vol->prepath = kmalloc(temp_len+1,GFP_KERNEL);
if(vol->prepath == NULL) if (vol->prepath == NULL)
return 1; return 1;
if(value[0] != '/') { if (value[0] != '/') {
vol->prepath[0] = '/'; vol->prepath[0] = '/';
strcpy(vol->prepath+1,value); strcpy(vol->prepath+1,value);
} else } else
...@@ -1030,7 +1032,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -1030,7 +1032,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
return 1; /* needs_arg; */ return 1; /* needs_arg; */
} }
if (strnlen(value, 65) < 65) { if (strnlen(value, 65) < 65) {
if(strnicmp(value,"default",7)) if (strnicmp(value,"default",7))
vol->iocharset = value; vol->iocharset = value;
/* if iocharset not set load_nls_default used by caller */ /* if iocharset not set load_nls_default used by caller */
cFYI(1, ("iocharset set to %s",value)); cFYI(1, ("iocharset set to %s",value));
...@@ -1042,11 +1044,13 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -1042,11 +1044,13 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
if (value && *value) { if (value && *value) {
vol->linux_uid = vol->linux_uid =
simple_strtoul(value, &value, 0); simple_strtoul(value, &value, 0);
vol->override_uid = 1;
} }
} else if (strnicmp(data, "gid", 3) == 0) { } else if (strnicmp(data, "gid", 3) == 0) {
if (value && *value) { if (value && *value) {
vol->linux_gid = vol->linux_gid =
simple_strtoul(value, &value, 0); simple_strtoul(value, &value, 0);
vol->override_gid = 1;
} }
} else if (strnicmp(data, "file_mode", 4) == 0) { } else if (strnicmp(data, "file_mode", 4) == 0) {
if (value && *value) { if (value && *value) {
...@@ -1101,7 +1105,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -1101,7 +1105,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
} }
/* The string has 16th byte zero still from /* The string has 16th byte zero still from
set at top of the function */ set at top of the function */
if((i==15) && (value[i] != 0)) if ((i==15) && (value[i] != 0))
printk(KERN_WARNING "CIFS: netbiosname longer than 15 truncated.\n"); printk(KERN_WARNING "CIFS: netbiosname longer than 15 truncated.\n");
} }
} else if (strnicmp(data, "servern", 7) == 0) { } else if (strnicmp(data, "servern", 7) == 0) {
...@@ -1125,7 +1129,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -1125,7 +1129,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
} }
/* The string has 16th byte zero still from /* The string has 16th byte zero still from
set at top of the function */ set at top of the function */
if((i==15) && (value[i] != 0)) if ((i==15) && (value[i] != 0))
printk(KERN_WARNING "CIFS: server netbiosname longer than 15 truncated.\n"); printk(KERN_WARNING "CIFS: server netbiosname longer than 15 truncated.\n");
} }
} else if (strnicmp(data, "credentials", 4) == 0) { } else if (strnicmp(data, "credentials", 4) == 0) {
...@@ -1232,13 +1236,13 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) ...@@ -1232,13 +1236,13 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol)
printk(KERN_WARNING "CIFS: Unknown mount option %s\n",data); printk(KERN_WARNING "CIFS: Unknown mount option %s\n",data);
} }
if (vol->UNC == NULL) { if (vol->UNC == NULL) {
if(devname == NULL) { if (devname == NULL) {
printk(KERN_WARNING "CIFS: Missing UNC name for mount target\n"); printk(KERN_WARNING "CIFS: Missing UNC name for mount target\n");
return 1; return 1;
} }
if ((temp_len = strnlen(devname, 300)) < 300) { if ((temp_len = strnlen(devname, 300)) < 300) {
vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); vol->UNC = kmalloc(temp_len+1,GFP_KERNEL);
if(vol->UNC == NULL) if (vol->UNC == NULL)
return 1; return 1;
strcpy(vol->UNC,devname); strcpy(vol->UNC,devname);
if (strncmp(vol->UNC, "//", 2) == 0) { if (strncmp(vol->UNC, "//", 2) == 0) {
...@@ -1813,7 +1817,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1813,7 +1817,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
if (srvTcp) { if (srvTcp) {
cFYI(1, ("Existing tcp session with server found")); cFYI(1, ("Existing tcp session with server found"));
} else { /* create socket */ } else { /* create socket */
if(volume_info.port) if (volume_info.port)
sin_server.sin_port = htons(volume_info.port); sin_server.sin_port = htons(volume_info.port);
else else
sin_server.sin_port = 0; sin_server.sin_port = 0;
...@@ -1829,7 +1833,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1829,7 +1833,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
if (rc < 0) { if (rc < 0) {
cERROR(1, cERROR(1,
("Error connecting to IPv4 socket. Aborting operation")); ("Error connecting to IPv4 socket. Aborting operation"));
if(csocket != NULL) if (csocket != NULL)
sock_release(csocket); sock_release(csocket);
kfree(volume_info.UNC); kfree(volume_info.UNC);
kfree(volume_info.password); kfree(volume_info.password);
...@@ -1863,7 +1867,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1863,7 +1867,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
srvTcp->tcpStatus = CifsNew; srvTcp->tcpStatus = CifsNew;
init_MUTEX(&srvTcp->tcpSem); init_MUTEX(&srvTcp->tcpSem);
srvTcp->tsk = kthread_run((void *)(void *)cifs_demultiplex_thread, srvTcp, "cifsd"); srvTcp->tsk = kthread_run((void *)(void *)cifs_demultiplex_thread, srvTcp, "cifsd");
if( IS_ERR(srvTcp->tsk) ) { if ( IS_ERR(srvTcp->tsk) ) {
rc = PTR_ERR(srvTcp->tsk); rc = PTR_ERR(srvTcp->tsk);
cERROR(1,("error %d create cifsd thread", rc)); cERROR(1,("error %d create cifsd thread", rc));
srvTcp->tsk = NULL; srvTcp->tsk = NULL;
...@@ -1909,7 +1913,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1909,7 +1913,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
int len = strlen(volume_info.domainname); int len = strlen(volume_info.domainname);
pSesInfo->domainName = pSesInfo->domainName =
kmalloc(len + 1, GFP_KERNEL); kmalloc(len + 1, GFP_KERNEL);
if(pSesInfo->domainName) if (pSesInfo->domainName)
strcpy(pSesInfo->domainName, strcpy(pSesInfo->domainName,
volume_info.domainname); volume_info.domainname);
} }
...@@ -1919,7 +1923,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1919,7 +1923,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
/* BB FIXME need to pass vol->secFlgs BB */ /* BB FIXME need to pass vol->secFlgs BB */
rc = cifs_setup_session(xid,pSesInfo, cifs_sb->local_nls); rc = cifs_setup_session(xid,pSesInfo, cifs_sb->local_nls);
up(&pSesInfo->sesSem); up(&pSesInfo->sesSem);
if(!rc) if (!rc)
atomic_inc(&srvTcp->socketUseCount); atomic_inc(&srvTcp->socketUseCount);
} else } else
kfree(volume_info.password); kfree(volume_info.password);
...@@ -1927,7 +1931,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1927,7 +1931,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
/* search for existing tcon to this server share */ /* search for existing tcon to this server share */
if (!rc) { if (!rc) {
if(volume_info.rsize > CIFSMaxBufSize) { if (volume_info.rsize > CIFSMaxBufSize) {
cERROR(1,("rsize %d too large, using MaxBufSize", cERROR(1,("rsize %d too large, using MaxBufSize",
volume_info.rsize)); volume_info.rsize));
cifs_sb->rsize = CIFSMaxBufSize; cifs_sb->rsize = CIFSMaxBufSize;
...@@ -1936,11 +1940,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1936,11 +1940,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
else /* default */ else /* default */
cifs_sb->rsize = CIFSMaxBufSize; cifs_sb->rsize = CIFSMaxBufSize;
if(volume_info.wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) { if (volume_info.wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) {
cERROR(1,("wsize %d too large using 4096 instead", cERROR(1,("wsize %d too large using 4096 instead",
volume_info.wsize)); volume_info.wsize));
cifs_sb->wsize = 4096; cifs_sb->wsize = 4096;
} else if(volume_info.wsize) } else if (volume_info.wsize)
cifs_sb->wsize = volume_info.wsize; cifs_sb->wsize = volume_info.wsize;
else else
cifs_sb->wsize = cifs_sb->wsize =
...@@ -1953,14 +1957,14 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1953,14 +1957,14 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
conjunction with 52K kvec constraint on arch with 4K conjunction with 52K kvec constraint on arch with 4K
page size */ page size */
if(cifs_sb->rsize < 2048) { if (cifs_sb->rsize < 2048) {
cifs_sb->rsize = 2048; cifs_sb->rsize = 2048;
/* Windows ME may prefer this */ /* Windows ME may prefer this */
cFYI(1,("readsize set to minimum 2048")); cFYI(1,("readsize set to minimum 2048"));
} }
/* calculate prepath */ /* calculate prepath */
cifs_sb->prepath = volume_info.prepath; cifs_sb->prepath = volume_info.prepath;
if(cifs_sb->prepath) { if (cifs_sb->prepath) {
cifs_sb->prepathlen = strlen(cifs_sb->prepath); cifs_sb->prepathlen = strlen(cifs_sb->prepath);
cifs_sb->prepath[0] = CIFS_DIR_SEP(cifs_sb); cifs_sb->prepath[0] = CIFS_DIR_SEP(cifs_sb);
volume_info.prepath = NULL; volume_info.prepath = NULL;
...@@ -1973,24 +1977,27 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -1973,24 +1977,27 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
cFYI(1,("file mode: 0x%x dir mode: 0x%x", cFYI(1,("file mode: 0x%x dir mode: 0x%x",
cifs_sb->mnt_file_mode,cifs_sb->mnt_dir_mode)); cifs_sb->mnt_file_mode,cifs_sb->mnt_dir_mode));
if(volume_info.noperm) if (volume_info.noperm)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM;
if(volume_info.setuids) if (volume_info.setuids)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID;
if(volume_info.server_ino) if (volume_info.server_ino)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM;
if(volume_info.remap) if (volume_info.remap)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR;
if(volume_info.no_xattr) if (volume_info.no_xattr)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR;
if(volume_info.sfu_emul) if (volume_info.sfu_emul)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL;
if(volume_info.nobrl) if (volume_info.nobrl)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL;
if(volume_info.cifs_acl) if (volume_info.cifs_acl)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL;
if (volume_info.override_uid)
if(volume_info.direct_io) { cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID;
if (volume_info.override_gid)
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID;
if (volume_info.direct_io) {
cFYI(1,("mounting share using direct i/o")); cFYI(1,("mounting share using direct i/o"));
cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO; cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;
} }
...@@ -2043,7 +2050,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -2043,7 +2050,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
} }
} }
} }
if(pSesInfo) { if (pSesInfo) {
if (pSesInfo->capabilities & CAP_LARGE_FILES) { if (pSesInfo->capabilities & CAP_LARGE_FILES) {
sb->s_maxbytes = (u64) 1 << 63; sb->s_maxbytes = (u64) 1 << 63;
} else } else
...@@ -2057,11 +2064,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -2057,11 +2064,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
if (rc) { if (rc) {
/* if session setup failed, use count is zero but /* if session setup failed, use count is zero but
we still need to free cifsd thread */ we still need to free cifsd thread */
if(atomic_read(&srvTcp->socketUseCount) == 0) { if (atomic_read(&srvTcp->socketUseCount) == 0) {
spin_lock(&GlobalMid_Lock); spin_lock(&GlobalMid_Lock);
srvTcp->tcpStatus = CifsExiting; srvTcp->tcpStatus = CifsExiting;
spin_unlock(&GlobalMid_Lock); spin_unlock(&GlobalMid_Lock);
if(srvTcp->tsk) { if (srvTcp->tsk) {
send_sig(SIGKILL,srvTcp->tsk,1); send_sig(SIGKILL,srvTcp->tsk,1);
kthread_stop(srvTcp->tsk); kthread_stop(srvTcp->tsk);
} }
...@@ -2076,7 +2083,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, ...@@ -2076,7 +2083,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
int temp_rc; int temp_rc;
temp_rc = CIFSSMBLogoff(xid, pSesInfo); temp_rc = CIFSSMBLogoff(xid, pSesInfo);
/* if the socketUseCount is now zero */ /* if the socketUseCount is now zero */
if((temp_rc == -ESHUTDOWN) && if ((temp_rc == -ESHUTDOWN) &&
(pSesInfo->server) && (pSesInfo->server->tsk)) { (pSesInfo->server) && (pSesInfo->server->tsk)) {
send_sig(SIGKILL,pSesInfo->server->tsk,1); send_sig(SIGKILL,pSesInfo->server->tsk,1);
kthread_stop(pSesInfo->server->tsk); kthread_stop(pSesInfo->server->tsk);
...@@ -2140,7 +2147,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2140,7 +2147,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
__u16 count; __u16 count;
cFYI(1, ("In sesssetup")); cFYI(1, ("In sesssetup"));
if(ses == NULL) if (ses == NULL)
return -EINVAL; return -EINVAL;
user = ses->userName; user = ses->userName;
domain = ses->domainName; domain = ses->domainName;
...@@ -2195,7 +2202,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2195,7 +2202,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
*bcc_ptr = 0; *bcc_ptr = 0;
bcc_ptr++; bcc_ptr++;
} }
if(user == NULL) if (user == NULL)
bytes_returned = 0; /* skip null user */ bytes_returned = 0; /* skip null user */
else else
bytes_returned = bytes_returned =
...@@ -2229,7 +2236,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, ...@@ -2229,7 +2236,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses,
bcc_ptr += 2 * bytes_returned; bcc_ptr += 2 * bytes_returned;
bcc_ptr += 2; bcc_ptr += 2;
} else { } else {
if(user != NULL) { if (user != NULL) {
strncpy(bcc_ptr, user, 200); strncpy(bcc_ptr, user, 200);
bcc_ptr += strnlen(user, 200); bcc_ptr += strnlen(user, 200);
} }
......
...@@ -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 */
......
...@@ -37,19 +37,19 @@ static void dump_cifs_file_struct(struct file *file, char *label) ...@@ -37,19 +37,19 @@ static void dump_cifs_file_struct(struct file *file, char *label)
{ {
struct cifsFileInfo * cf; struct cifsFileInfo * cf;
if(file) { if (file) {
cf = file->private_data; cf = file->private_data;
if(cf == NULL) { if (cf == NULL) {
cFYI(1,("empty cifs private file data")); cFYI(1,("empty cifs private file data"));
return; return;
} }
if(cf->invalidHandle) { if (cf->invalidHandle) {
cFYI(1,("invalid handle")); cFYI(1,("invalid handle"));
} }
if(cf->srch_inf.endOfSearch) { if (cf->srch_inf.endOfSearch) {
cFYI(1,("end of search")); cFYI(1,("end of search"));
} }
if(cf->srch_inf.emptyDir) { if (cf->srch_inf.emptyDir) {
cFYI(1,("empty dir")); cFYI(1,("empty dir"));
} }
...@@ -77,17 +77,17 @@ static int construct_dentry(struct qstr *qstring, struct file *file, ...@@ -77,17 +77,17 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
cFYI(0, ("existing dentry with inode 0x%p", tmp_dentry->d_inode)); cFYI(0, ("existing dentry with inode 0x%p", tmp_dentry->d_inode));
*ptmp_inode = tmp_dentry->d_inode; *ptmp_inode = tmp_dentry->d_inode;
/* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/ /* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/
if(*ptmp_inode == NULL) { if (*ptmp_inode == NULL) {
*ptmp_inode = new_inode(file->f_path.dentry->d_sb); *ptmp_inode = new_inode(file->f_path.dentry->d_sb);
if(*ptmp_inode == NULL) if (*ptmp_inode == NULL)
return rc; return rc;
rc = 1; rc = 1;
} }
if(file->f_path.dentry->d_sb->s_flags & MS_NOATIME) if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME)
(*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME; (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME;
} else { } else {
tmp_dentry = d_alloc(file->f_path.dentry, qstring); tmp_dentry = d_alloc(file->f_path.dentry, qstring);
if(tmp_dentry == NULL) { if (tmp_dentry == NULL) {
cERROR(1,("Failed allocating dentry")); cERROR(1,("Failed allocating dentry"));
*ptmp_inode = NULL; *ptmp_inode = NULL;
return rc; return rc;
...@@ -98,9 +98,9 @@ static int construct_dentry(struct qstr *qstring, struct file *file, ...@@ -98,9 +98,9 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
tmp_dentry->d_op = &cifs_ci_dentry_ops; tmp_dentry->d_op = &cifs_ci_dentry_ops;
else else
tmp_dentry->d_op = &cifs_dentry_ops; tmp_dentry->d_op = &cifs_dentry_ops;
if(*ptmp_inode == NULL) if (*ptmp_inode == NULL)
return rc; return rc;
if(file->f_path.dentry->d_sb->s_flags & MS_NOATIME) if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME)
(*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME; (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME;
rc = 2; rc = 2;
} }
...@@ -112,7 +112,7 @@ static int construct_dentry(struct qstr *qstring, struct file *file, ...@@ -112,7 +112,7 @@ static int construct_dentry(struct qstr *qstring, struct file *file,
static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode) static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode)
{ {
if((tcon) && (tcon->ses) && (tcon->ses->server)) { if ((tcon) && (tcon->ses) && (tcon->ses->server)) {
inode->i_ctime.tv_sec += tcon->ses->server->timeAdj; inode->i_ctime.tv_sec += tcon->ses->server->timeAdj;
inode->i_mtime.tv_sec += tcon->ses->server->timeAdj; inode->i_mtime.tv_sec += tcon->ses->server->timeAdj;
inode->i_atime.tv_sec += tcon->ses->server->timeAdj; inode->i_atime.tv_sec += tcon->ses->server->timeAdj;
...@@ -137,7 +137,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, ...@@ -137,7 +137,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
local_mtime = tmp_inode->i_mtime; local_mtime = tmp_inode->i_mtime;
local_size = tmp_inode->i_size; local_size = tmp_inode->i_size;
if(new_buf_type) { if (new_buf_type) {
FILE_DIRECTORY_INFO *pfindData = (FILE_DIRECTORY_INFO *)buf; FILE_DIRECTORY_INFO *pfindData = (FILE_DIRECTORY_INFO *)buf;
attr = le32_to_cpu(pfindData->ExtFileAttributes); attr = le32_to_cpu(pfindData->ExtFileAttributes);
...@@ -193,7 +193,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, ...@@ -193,7 +193,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
if (attr & ATTR_DIRECTORY) { if (attr & ATTR_DIRECTORY) {
*pobject_type = DT_DIR; *pobject_type = DT_DIR;
/* override default perms since we do not lock dirs */ /* override default perms since we do not lock dirs */
if(atomic_read(&cifsInfo->inUse) == 0) { if (atomic_read(&cifsInfo->inUse) == 0) {
tmp_inode->i_mode = cifs_sb->mnt_dir_mode; tmp_inode->i_mode = cifs_sb->mnt_dir_mode;
} }
tmp_inode->i_mode |= S_IFDIR; tmp_inode->i_mode |= S_IFDIR;
...@@ -250,25 +250,25 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, ...@@ -250,25 +250,25 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type,
if (S_ISREG(tmp_inode->i_mode)) { if (S_ISREG(tmp_inode->i_mode)) {
cFYI(1, ("File inode")); cFYI(1, ("File inode"));
tmp_inode->i_op = &cifs_file_inode_ops; tmp_inode->i_op = &cifs_file_inode_ops;
if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; tmp_inode->i_fop = &cifs_file_direct_nobrl_ops;
else else
tmp_inode->i_fop = &cifs_file_direct_ops; tmp_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)
tmp_inode->i_fop = &cifs_file_nobrl_ops; tmp_inode->i_fop = &cifs_file_nobrl_ops;
else else
tmp_inode->i_fop = &cifs_file_ops; tmp_inode->i_fop = &cifs_file_ops;
if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
(cifs_sb->tcon->ses->server->maxBuf < (cifs_sb->tcon->ses->server->maxBuf <
PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
else else
tmp_inode->i_data.a_ops = &cifs_addr_ops; tmp_inode->i_data.a_ops = &cifs_addr_ops;
if(isNewInode) if (isNewInode)
return; /* No sense invalidating pages for new inode return; /* No sense invalidating pages for new inode
since have not started caching readahead file since have not started caching readahead file
data yet */ data yet */
...@@ -357,8 +357,14 @@ static void unix_fill_in_inode(struct inode *tmp_inode, ...@@ -357,8 +357,14 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
cFYI(1,("unknown inode type %d",type)); cFYI(1,("unknown inode type %d",type));
} }
tmp_inode->i_uid = le64_to_cpu(pfindData->Uid); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
tmp_inode->i_gid = le64_to_cpu(pfindData->Gid); tmp_inode->i_uid = cifs_sb->mnt_uid;
else
tmp_inode->i_uid = le64_to_cpu(pfindData->Uid);
if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
tmp_inode->i_gid = cifs_sb->mnt_gid;
else
tmp_inode->i_gid = le64_to_cpu(pfindData->Gid);
tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks); tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks);
spin_lock(&tmp_inode->i_lock); spin_lock(&tmp_inode->i_lock);
...@@ -377,25 +383,24 @@ static void unix_fill_in_inode(struct inode *tmp_inode, ...@@ -377,25 +383,24 @@ static void unix_fill_in_inode(struct inode *tmp_inode,
cFYI(1, ("File inode")); cFYI(1, ("File inode"));
tmp_inode->i_op = &cifs_file_inode_ops; tmp_inode->i_op = &cifs_file_inode_ops;
if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) {
if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; tmp_inode->i_fop = &cifs_file_direct_nobrl_ops;
else else
tmp_inode->i_fop = &cifs_file_direct_ops; tmp_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)
tmp_inode->i_fop = &cifs_file_nobrl_ops; tmp_inode->i_fop = &cifs_file_nobrl_ops;
else else
tmp_inode->i_fop = &cifs_file_ops; tmp_inode->i_fop = &cifs_file_ops;
if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) &&
(cifs_sb->tcon->ses->server->maxBuf < (cifs_sb->tcon->ses->server->maxBuf <
PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE))
tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
else else
tmp_inode->i_data.a_ops = &cifs_addr_ops; tmp_inode->i_data.a_ops = &cifs_addr_ops;
if(isNewInode) if (isNewInode)
return; /* No sense invalidating pages for new inode since we return; /* No sense invalidating pages for new inode since we
have not started caching readahead file data yet */ have not started caching readahead file data yet */
...@@ -430,28 +435,28 @@ static int initiate_cifs_search(const int xid, struct file *file) ...@@ -430,28 +435,28 @@ static int initiate_cifs_search(const int xid, struct file *file)
struct cifs_sb_info *cifs_sb; struct cifs_sb_info *cifs_sb;
struct cifsTconInfo *pTcon; struct cifsTconInfo *pTcon;
if(file->private_data == NULL) { if (file->private_data == NULL) {
file->private_data = file->private_data =
kzalloc(sizeof(struct cifsFileInfo),GFP_KERNEL); kzalloc(sizeof(struct cifsFileInfo),GFP_KERNEL);
} }
if(file->private_data == NULL) if (file->private_data == NULL)
return -ENOMEM; return -ENOMEM;
cifsFile = file->private_data; cifsFile = file->private_data;
cifsFile->invalidHandle = TRUE; cifsFile->invalidHandle = TRUE;
cifsFile->srch_inf.endOfSearch = FALSE; cifsFile->srch_inf.endOfSearch = FALSE;
cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); cifs_sb = CIFS_SB(file->f_path.dentry->d_sb);
if(cifs_sb == NULL) if (cifs_sb == NULL)
return -EINVAL; return -EINVAL;
pTcon = cifs_sb->tcon; pTcon = cifs_sb->tcon;
if(pTcon == NULL) if (pTcon == NULL)
return -EINVAL; return -EINVAL;
full_path = build_path_from_dentry(file->f_path.dentry); full_path = build_path_from_dentry(file->f_path.dentry);
if(full_path == NULL) { if (full_path == NULL) {
return -ENOMEM; return -ENOMEM;
} }
...@@ -474,9 +479,9 @@ ffirst_retry: ...@@ -474,9 +479,9 @@ ffirst_retry:
&cifsFile->netfid, &cifsFile->srch_inf, &cifsFile->netfid, &cifsFile->srch_inf,
cifs_sb->mnt_cifs_flags & cifs_sb->mnt_cifs_flags &
CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb)); CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb));
if(rc == 0) if (rc == 0)
cifsFile->invalidHandle = FALSE; cifsFile->invalidHandle = FALSE;
if((rc == -EOPNOTSUPP) && if ((rc == -EOPNOTSUPP) &&
(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
goto ffirst_retry; goto ffirst_retry;
...@@ -492,7 +497,7 @@ static int cifs_unicode_bytelen(char *str) ...@@ -492,7 +497,7 @@ static int cifs_unicode_bytelen(char *str)
__le16 * ustr = (__le16 *)str; __le16 * ustr = (__le16 *)str;
for(len=0;len <= PATH_MAX;len++) { for(len=0;len <= PATH_MAX;len++) {
if(ustr[len] == 0) if (ustr[len] == 0)
return len << 1; return len << 1;
} }
cFYI(1,("Unicode string longer than PATH_MAX found")); cFYI(1,("Unicode string longer than PATH_MAX found"));
...@@ -504,7 +509,7 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level) ...@@ -504,7 +509,7 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
char * new_entry; char * new_entry;
FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry; FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry;
if(level == SMB_FIND_FILE_INFO_STANDARD) { if (level == SMB_FIND_FILE_INFO_STANDARD) {
FIND_FILE_STANDARD_INFO * pfData; FIND_FILE_STANDARD_INFO * pfData;
pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo; pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo;
...@@ -514,12 +519,12 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level) ...@@ -514,12 +519,12 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level)
new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset); new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset);
cFYI(1,("new entry %p old entry %p",new_entry,old_entry)); cFYI(1,("new entry %p old entry %p",new_entry,old_entry));
/* validate that new_entry is not past end of SMB */ /* validate that new_entry is not past end of SMB */
if(new_entry >= end_of_smb) { if (new_entry >= end_of_smb) {
cERROR(1, cERROR(1,
("search entry %p began after end of SMB %p old entry %p", ("search entry %p began after end of SMB %p old entry %p",
new_entry, end_of_smb, old_entry)); new_entry, end_of_smb, old_entry));
return NULL; return NULL;
} else if(((level == SMB_FIND_FILE_INFO_STANDARD) && } else if (((level == SMB_FIND_FILE_INFO_STANDARD) &&
(new_entry + sizeof(FIND_FILE_STANDARD_INFO) > end_of_smb)) || (new_entry + sizeof(FIND_FILE_STANDARD_INFO) > end_of_smb)) ||
((level != SMB_FIND_FILE_INFO_STANDARD) && ((level != SMB_FIND_FILE_INFO_STANDARD) &&
(new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb))) { (new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb))) {
...@@ -540,39 +545,39 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile) ...@@ -540,39 +545,39 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
char * filename = NULL; char * filename = NULL;
int len = 0; int len = 0;
if(cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) { if (cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) {
FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry;
filename = &pFindData->FileName[0]; filename = &pFindData->FileName[0];
if(cfile->srch_inf.unicode) { if (cfile->srch_inf.unicode) {
len = cifs_unicode_bytelen(filename); len = cifs_unicode_bytelen(filename);
} else { } else {
/* BB should we make this strnlen of PATH_MAX? */ /* BB should we make this strnlen of PATH_MAX? */
len = strnlen(filename, 5); len = strnlen(filename, 5);
} }
} else if(cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) { } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) {
FILE_DIRECTORY_INFO * pFindData = FILE_DIRECTORY_INFO * pFindData =
(FILE_DIRECTORY_INFO *)current_entry; (FILE_DIRECTORY_INFO *)current_entry;
filename = &pFindData->FileName[0]; filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength); len = le32_to_cpu(pFindData->FileNameLength);
} else if(cfile->srch_inf.info_level == } else if (cfile->srch_inf.info_level ==
SMB_FIND_FILE_FULL_DIRECTORY_INFO) { SMB_FIND_FILE_FULL_DIRECTORY_INFO) {
FILE_FULL_DIRECTORY_INFO * pFindData = FILE_FULL_DIRECTORY_INFO * pFindData =
(FILE_FULL_DIRECTORY_INFO *)current_entry; (FILE_FULL_DIRECTORY_INFO *)current_entry;
filename = &pFindData->FileName[0]; filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength); len = le32_to_cpu(pFindData->FileNameLength);
} else if(cfile->srch_inf.info_level == } else if (cfile->srch_inf.info_level ==
SMB_FIND_FILE_ID_FULL_DIR_INFO) { SMB_FIND_FILE_ID_FULL_DIR_INFO) {
SEARCH_ID_FULL_DIR_INFO * pFindData = SEARCH_ID_FULL_DIR_INFO * pFindData =
(SEARCH_ID_FULL_DIR_INFO *)current_entry; (SEARCH_ID_FULL_DIR_INFO *)current_entry;
filename = &pFindData->FileName[0]; filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength); len = le32_to_cpu(pFindData->FileNameLength);
} else if(cfile->srch_inf.info_level == } else if (cfile->srch_inf.info_level ==
SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { SMB_FIND_FILE_BOTH_DIRECTORY_INFO) {
FILE_BOTH_DIRECTORY_INFO * pFindData = FILE_BOTH_DIRECTORY_INFO * pFindData =
(FILE_BOTH_DIRECTORY_INFO *)current_entry; (FILE_BOTH_DIRECTORY_INFO *)current_entry;
filename = &pFindData->FileName[0]; filename = &pFindData->FileName[0];
len = le32_to_cpu(pFindData->FileNameLength); len = le32_to_cpu(pFindData->FileNameLength);
} else if(cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) { } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) {
FIND_FILE_STANDARD_INFO * pFindData = FIND_FILE_STANDARD_INFO * pFindData =
(FIND_FILE_STANDARD_INFO *)current_entry; (FIND_FILE_STANDARD_INFO *)current_entry;
filename = &pFindData->FileName[0]; filename = &pFindData->FileName[0];
...@@ -581,25 +586,25 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile) ...@@ -581,25 +586,25 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile)
cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level)); cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level));
} }
if(filename) { if (filename) {
if(cfile->srch_inf.unicode) { if (cfile->srch_inf.unicode) {
__le16 *ufilename = (__le16 *)filename; __le16 *ufilename = (__le16 *)filename;
if(len == 2) { if (len == 2) {
/* check for . */ /* check for . */
if(ufilename[0] == UNICODE_DOT) if (ufilename[0] == UNICODE_DOT)
rc = 1; rc = 1;
} else if(len == 4) { } else if (len == 4) {
/* check for .. */ /* check for .. */
if((ufilename[0] == UNICODE_DOT) if ((ufilename[0] == UNICODE_DOT)
&&(ufilename[1] == UNICODE_DOT)) &&(ufilename[1] == UNICODE_DOT))
rc = 2; rc = 2;
} }
} else /* ASCII */ { } else /* ASCII */ {
if(len == 1) { if (len == 1) {
if(filename[0] == '.') if (filename[0] == '.')
rc = 1; rc = 1;
} else if(len == 2) { } else if (len == 2) {
if((filename[0] == '.') && (filename[1] == '.')) if((filename[0] == '.') && (filename[1] == '.'))
rc = 2; rc = 2;
} }
} }
...@@ -638,7 +643,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, ...@@ -638,7 +643,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
struct cifsFileInfo * cifsFile = file->private_data; struct cifsFileInfo * cifsFile = file->private_data;
/* check if index in the buffer */ /* check if index in the buffer */
if((cifsFile == NULL) || (ppCurrentEntry == NULL) || if ((cifsFile == NULL) || (ppCurrentEntry == NULL) ||
(num_to_ret == NULL)) (num_to_ret == NULL))
return -ENOENT; return -ENOENT;
...@@ -656,7 +661,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, ...@@ -656,7 +661,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
#ifdef CONFIG_CIFS_DEBUG2 #ifdef CONFIG_CIFS_DEBUG2
dump_cifs_file_struct(file, "In fce "); dump_cifs_file_struct(file, "In fce ");
#endif #endif
if(((index_to_find < cifsFile->srch_inf.index_of_last_entry) && if (((index_to_find < cifsFile->srch_inf.index_of_last_entry) &&
is_dir_changed(file)) || is_dir_changed(file)) ||
(index_to_find < first_entry_in_buffer)) { (index_to_find < first_entry_in_buffer)) {
/* close and restart search */ /* close and restart search */
...@@ -665,9 +670,9 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, ...@@ -665,9 +670,9 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
CIFSFindClose(xid, pTcon, cifsFile->netfid); CIFSFindClose(xid, pTcon, cifsFile->netfid);
kfree(cifsFile->search_resume_name); kfree(cifsFile->search_resume_name);
cifsFile->search_resume_name = NULL; cifsFile->search_resume_name = NULL;
if(cifsFile->srch_inf.ntwrk_buf_start) { if (cifsFile->srch_inf.ntwrk_buf_start) {
cFYI(1,("freeing SMB ff cache buf on search rewind")); cFYI(1,("freeing SMB ff cache buf on search rewind"));
if(cifsFile->srch_inf.smallBuf) if (cifsFile->srch_inf.smallBuf)
cifs_small_buf_release(cifsFile->srch_inf. cifs_small_buf_release(cifsFile->srch_inf.
ntwrk_buf_start); ntwrk_buf_start);
else else
...@@ -675,7 +680,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, ...@@ -675,7 +680,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
ntwrk_buf_start); ntwrk_buf_start);
} }
rc = initiate_cifs_search(xid,file); rc = initiate_cifs_search(xid,file);
if(rc) { if (rc) {
cFYI(1,("error %d reinitiating a search on rewind",rc)); cFYI(1,("error %d reinitiating a search on rewind",rc));
return rc; return rc;
} }
...@@ -686,10 +691,10 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, ...@@ -686,10 +691,10 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon,
cFYI(1,("calling findnext2")); cFYI(1,("calling findnext2"));
rc = CIFSFindNext(xid,pTcon,cifsFile->netfid, rc = CIFSFindNext(xid,pTcon,cifsFile->netfid,
&cifsFile->srch_inf); &cifsFile->srch_inf);
if(rc) if (rc)
return -ENOENT; return -ENOENT;
} }
if(index_to_find < cifsFile->srch_inf.index_of_last_entry) { if (index_to_find < cifsFile->srch_inf.index_of_last_entry) {
/* we found the buffer that contains the entry */ /* we found the buffer that contains the entry */
/* scan and find it */ /* scan and find it */
int i; int i;
......
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