diff options
author | Steve French <sfrench@us.ibm.com> | 2007-04-30 16:13:06 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2007-04-30 16:13:06 -0400 |
commit | 4523cc3044d1bc7fcf3d7fee75d62bc76b8e1abb (patch) | |
tree | 31c2b6c0a81f14ec812d09586eb8ef5a586743cb /fs/cifs | |
parent | 984acfe1cfb613257a15f30b3cf60ae7e4ed8f06 (diff) |
[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: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/CHANGES | 6 | ||||
-rw-r--r-- | fs/cifs/README | 23 | ||||
-rw-r--r-- | fs/cifs/TODO | 2 | ||||
-rw-r--r-- | fs/cifs/cifs_fs_sb.h | 14 | ||||
-rw-r--r-- | fs/cifs/cifsfs.c | 76 | ||||
-rw-r--r-- | fs/cifs/connect.c | 79 | ||||
-rw-r--r-- | fs/cifs/inode.c | 55 | ||||
-rw-r--r-- | fs/cifs/readdir.c | 129 |
8 files changed, 213 insertions, 171 deletions
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES index 301631cac7f8..62dcf6325861 100644 --- a/fs/cifs/CHANGES +++ b/fs/cifs/CHANGES | |||
@@ -2,7 +2,11 @@ Version 1.49 | |||
2 | ------------ | 2 | ------------ |
3 | IPv6 support. Enable ipv6 addresses to be passed on mount (put the ipv6 | 3 | IPv6 support. Enable ipv6 addresses to be passed on mount (put the ipv6 |
4 | address after the "ip=" mount option, at least until mount.cifs is fixed to | 4 | address after the "ip=" mount option, at least until mount.cifs is fixed to |
5 | handle DNS host to ipv6 name translation). | 5 | handle DNS host to ipv6 name translation). Accept override of uid or gid |
6 | on mount even when Unix Extensions are negotiated (it used to be ignored | ||
7 | when Unix Extensions were ignored). This allows users to override the | ||
8 | default uid and gid for files when they are certain that the uids or | ||
9 | gids on the server do not match those of the client. | ||
6 | 10 | ||
7 | Version 1.48 | 11 | Version 1.48 |
8 | ------------ | 12 | ------------ |
diff --git a/fs/cifs/README b/fs/cifs/README index 080c5eba112b..93fe3594274f 100644 --- a/fs/cifs/README +++ b/fs/cifs/README | |||
@@ -257,13 +257,19 @@ A partial list of the supported mount options follows: | |||
257 | mount. | 257 | mount. |
258 | domain Set the SMB/CIFS workgroup name prepended to the | 258 | domain Set the SMB/CIFS workgroup name prepended to the |
259 | username during CIFS session establishment | 259 | username during CIFS session establishment |
260 | uid If CIFS Unix extensions are not supported by the server | 260 | uid Set the default uid for inodes. For mounts to servers |
261 | this overrides the default uid for inodes. For mounts to | 261 | which do support the CIFS Unix extensions, such as a |
262 | servers which do support the CIFS Unix extensions, such | 262 | properly configured Samba server, the server provides |
263 | as a properly configured Samba server, the server provides | 263 | the uid, gid and mode so this parameter should not be |
264 | the uid, gid and mode. For servers which do not support | 264 | specified unless the server and clients uid and gid |
265 | the Unix extensions, the default uid (and gid) returned on | 265 | numbering differ. If the server and client are in the |
266 | lookup of existing files is the uid (gid) of the person | 266 | same domain (e.g. running winbind or nss_ldap) and |
267 | the server supports the Unix Extensions then the uid | ||
268 | and gid can be retrieved from the server (and uid | ||
269 | and gid would not have to be specifed on the mount. | ||
270 | For servers which do not support the CIFS Unix | ||
271 | extensions, the default uid (and gid) returned on lookup | ||
272 | of existing files will be the uid (gid) of the person | ||
267 | who executed the mount (root, except when mount.cifs | 273 | who executed the mount (root, except when mount.cifs |
268 | is configured setuid for user mounts) unless the "uid=" | 274 | is configured setuid for user mounts) unless the "uid=" |
269 | (gid) mount option is specified. For the uid (gid) of newly | 275 | (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 | the client. Note that the mount.cifs helper must be | 287 | the client. Note that the mount.cifs helper must be |
282 | at version 1.10 or higher to support specifying the uid | 288 | at version 1.10 or higher to support specifying the uid |
283 | (or gid) in non-numberic form. | 289 | (or gid) in non-numberic form. |
284 | gid If CIFS Unix extensions are not supported by the server | 290 | gid Set the default gid for inodes (similar to above). |
285 | this overrides the default gid for inodes. | ||
286 | file_mode If CIFS Unix extensions are not supported by the server | 291 | file_mode If CIFS Unix extensions are not supported by the server |
287 | this overrides the default mode for file inodes. | 292 | this overrides the default mode for file inodes. |
288 | dir_mode If CIFS Unix extensions are not supported by the server | 293 | dir_mode If CIFS Unix extensions are not supported by the server |
diff --git a/fs/cifs/TODO b/fs/cifs/TODO index b70a69bf7cf6..78b620e332bd 100644 --- a/fs/cifs/TODO +++ b/fs/cifs/TODO | |||
@@ -80,7 +80,7 @@ need to add ability to set time to server (utimes command) | |||
80 | 80 | ||
81 | u) DOS attrs - returned as pseudo-xattr in Samba format (check VFAT and NTFS for this too) | 81 | u) DOS attrs - returned as pseudo-xattr in Samba format (check VFAT and NTFS for this too) |
82 | 82 | ||
83 | v) mount check for unmatched uids - and uid override | 83 | v) mount check for unmatched uids |
84 | 84 | ||
85 | w) Add mount option for Linux extension disable per mount, and partial | 85 | w) Add mount option for Linux extension disable per mount, and partial |
86 | disable per mount (uid off, symlink/fifo/mknod on but what about posix acls?) | 86 | disable per mount (uid off, symlink/fifo/mknod on but what about posix acls?) |
diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h index fd1e52ebcee6..4cc2012e9322 100644 --- a/fs/cifs/cifs_fs_sb.h +++ b/fs/cifs/cifs_fs_sb.h | |||
@@ -22,12 +22,14 @@ | |||
22 | #define CIFS_MOUNT_SET_UID 2 /* set current->euid in create etc. */ | 22 | #define CIFS_MOUNT_SET_UID 2 /* set current->euid in create etc. */ |
23 | #define CIFS_MOUNT_SERVER_INUM 4 /* inode numbers from uniqueid from server */ | 23 | #define CIFS_MOUNT_SERVER_INUM 4 /* inode numbers from uniqueid from server */ |
24 | #define CIFS_MOUNT_DIRECT_IO 8 /* do not write nor read through page cache */ | 24 | #define CIFS_MOUNT_DIRECT_IO 8 /* do not write nor read through page cache */ |
25 | #define CIFS_MOUNT_NO_XATTR 0x10 /* if set - disable xattr support */ | 25 | #define CIFS_MOUNT_NO_XATTR 0x10 /* if set - disable xattr support */ |
26 | #define CIFS_MOUNT_MAP_SPECIAL_CHR 0x20 /* remap illegal chars in filenames */ | 26 | #define CIFS_MOUNT_MAP_SPECIAL_CHR 0x20 /* remap illegal chars in filenames */ |
27 | #define CIFS_MOUNT_POSIX_PATHS 0x40 /* Negotiate posix pathnames if possible. */ | 27 | #define CIFS_MOUNT_POSIX_PATHS 0x40 /* Negotiate posix pathnames if possible*/ |
28 | #define CIFS_MOUNT_UNX_EMUL 0x80 /* Network compat with SFUnix emulation */ | 28 | #define CIFS_MOUNT_UNX_EMUL 0x80 /* Network compat with SFUnix emulation */ |
29 | #define CIFS_MOUNT_NO_BRL 0x100 /* No sending byte range locks to srv */ | 29 | #define CIFS_MOUNT_NO_BRL 0x100 /* No sending byte range locks to srv */ |
30 | #define CIFS_MOUNT_CIFS_ACL 0x200 /* send ACL requests to non-POSIX srv */ | 30 | #define CIFS_MOUNT_CIFS_ACL 0x200 /* send ACL requests to non-POSIX srv */ |
31 | #define CIFS_MOUNT_OVERR_UID 0x400 /* override uid returned from server */ | ||
32 | #define CIFS_MOUNT_OVERR_GID 0x800 /* override gid returned from server */ | ||
31 | 33 | ||
32 | struct cifs_sb_info { | 34 | struct cifs_sb_info { |
33 | struct cifsTconInfo *tcon; /* primary mount */ | 35 | struct cifsTconInfo *tcon; /* primary mount */ |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index dd03e680f8f8..5036dae09cd7 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -100,7 +100,7 @@ cifs_read_super(struct super_block *sb, void *data, | |||
100 | sb->s_flags |= MS_NODIRATIME | MS_NOATIME; | 100 | sb->s_flags |= MS_NODIRATIME | MS_NOATIME; |
101 | sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info),GFP_KERNEL); | 101 | sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info),GFP_KERNEL); |
102 | cifs_sb = CIFS_SB(sb); | 102 | cifs_sb = CIFS_SB(sb); |
103 | if(cifs_sb == NULL) | 103 | if (cifs_sb == NULL) |
104 | return -ENOMEM; | 104 | return -ENOMEM; |
105 | 105 | ||
106 | rc = cifs_mount(sb, cifs_sb, data, devname); | 106 | rc = cifs_mount(sb, cifs_sb, data, devname); |
@@ -115,10 +115,10 @@ cifs_read_super(struct super_block *sb, void *data, | |||
115 | sb->s_magic = CIFS_MAGIC_NUMBER; | 115 | sb->s_magic = CIFS_MAGIC_NUMBER; |
116 | sb->s_op = &cifs_super_ops; | 116 | sb->s_op = &cifs_super_ops; |
117 | #ifdef CONFIG_CIFS_EXPERIMENTAL | 117 | #ifdef CONFIG_CIFS_EXPERIMENTAL |
118 | if(experimEnabled != 0) | 118 | if (experimEnabled != 0) |
119 | sb->s_export_op = &cifs_export_ops; | 119 | sb->s_export_op = &cifs_export_ops; |
120 | #endif /* EXPERIMENTAL */ | 120 | #endif /* EXPERIMENTAL */ |
121 | /* if(cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512) | 121 | /* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512) |
122 | sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */ | 122 | sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */ |
123 | #ifdef CONFIG_CIFS_QUOTA | 123 | #ifdef CONFIG_CIFS_QUOTA |
124 | sb->s_qcop = &cifs_quotactl_ops; | 124 | sb->s_qcop = &cifs_quotactl_ops; |
@@ -147,8 +147,8 @@ out_no_root: | |||
147 | iput(inode); | 147 | iput(inode); |
148 | 148 | ||
149 | out_mount_failed: | 149 | out_mount_failed: |
150 | if(cifs_sb) { | 150 | if (cifs_sb) { |
151 | if(cifs_sb->local_nls) | 151 | if (cifs_sb->local_nls) |
152 | unload_nls(cifs_sb->local_nls); | 152 | unload_nls(cifs_sb->local_nls); |
153 | kfree(cifs_sb); | 153 | kfree(cifs_sb); |
154 | } | 154 | } |
@@ -163,7 +163,7 @@ cifs_put_super(struct super_block *sb) | |||
163 | 163 | ||
164 | cFYI(1, ("In cifs_put_super")); | 164 | cFYI(1, ("In cifs_put_super")); |
165 | cifs_sb = CIFS_SB(sb); | 165 | cifs_sb = CIFS_SB(sb); |
166 | if(cifs_sb == NULL) { | 166 | if (cifs_sb == NULL) { |
167 | cFYI(1,("Empty cifs superblock info passed to unmount")); | 167 | cFYI(1,("Empty cifs superblock info passed to unmount")); |
168 | return; | 168 | return; |
169 | } | 169 | } |
@@ -208,14 +208,14 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
208 | 208 | ||
209 | /* Only need to call the old QFSInfo if failed | 209 | /* Only need to call the old QFSInfo if failed |
210 | on newer one */ | 210 | on newer one */ |
211 | if(rc) | 211 | if (rc) |
212 | if(pTcon->ses->capabilities & CAP_NT_SMBS) | 212 | if (pTcon->ses->capabilities & CAP_NT_SMBS) |
213 | rc = CIFSSMBQFSInfo(xid, pTcon, buf); /* not supported by OS2 */ | 213 | rc = CIFSSMBQFSInfo(xid, pTcon, buf); /* not supported by OS2 */ |
214 | 214 | ||
215 | /* Some old Windows servers also do not support level 103, retry with | 215 | /* Some old Windows servers also do not support level 103, retry with |
216 | older level one if old server failed the previous call or we | 216 | older level one if old server failed the previous call or we |
217 | bypassed it because we detected that this was an older LANMAN sess */ | 217 | bypassed it because we detected that this was an older LANMAN sess */ |
218 | if(rc) | 218 | if (rc) |
219 | rc = SMBOldQFSInfo(xid, pTcon, buf); | 219 | rc = SMBOldQFSInfo(xid, pTcon, buf); |
220 | /* | 220 | /* |
221 | int f_type; | 221 | int f_type; |
@@ -301,11 +301,19 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m) | |||
301 | if (cifs_sb->tcon->ses->userName) | 301 | if (cifs_sb->tcon->ses->userName) |
302 | seq_printf(s, ",username=%s", | 302 | seq_printf(s, ",username=%s", |
303 | cifs_sb->tcon->ses->userName); | 303 | cifs_sb->tcon->ses->userName); |
304 | if(cifs_sb->tcon->ses->domainName) | 304 | if (cifs_sb->tcon->ses->domainName) |
305 | seq_printf(s, ",domain=%s", | 305 | seq_printf(s, ",domain=%s", |
306 | cifs_sb->tcon->ses->domainName); | 306 | cifs_sb->tcon->ses->domainName); |
307 | } | 307 | } |
308 | } | 308 | } |
309 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) | ||
310 | seq_printf(s, ",posixpaths"); | ||
311 | if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) || | ||
312 | !(cifs_sb->tcon->ses->capabilities & CAP_UNIX)) | ||
313 | seq_printf(s, ",uid=%d", cifs_sb->mnt_uid); | ||
314 | if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) || | ||
315 | !(cifs_sb->tcon->ses->capabilities & CAP_UNIX)) | ||
316 | seq_printf(s, ",gid=%d", cifs_sb->mnt_gid); | ||
309 | seq_printf(s, ",rsize=%d",cifs_sb->rsize); | 317 | seq_printf(s, ",rsize=%d",cifs_sb->rsize); |
310 | seq_printf(s, ",wsize=%d",cifs_sb->wsize); | 318 | seq_printf(s, ",wsize=%d",cifs_sb->wsize); |
311 | } | 319 | } |
@@ -321,14 +329,14 @@ int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid, | |||
321 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); | 329 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); |
322 | struct cifsTconInfo *pTcon; | 330 | struct cifsTconInfo *pTcon; |
323 | 331 | ||
324 | if(cifs_sb) | 332 | if (cifs_sb) |
325 | pTcon = cifs_sb->tcon; | 333 | pTcon = cifs_sb->tcon; |
326 | else | 334 | else |
327 | return -EIO; | 335 | return -EIO; |
328 | 336 | ||
329 | 337 | ||
330 | xid = GetXid(); | 338 | xid = GetXid(); |
331 | if(pTcon) { | 339 | if (pTcon) { |
332 | cFYI(1,("set type: 0x%x id: %d",quota_type,qid)); | 340 | cFYI(1,("set type: 0x%x id: %d",quota_type,qid)); |
333 | } else { | 341 | } else { |
334 | return -EIO; | 342 | return -EIO; |
@@ -346,13 +354,13 @@ int cifs_xquota_get(struct super_block * sb, int quota_type, qid_t qid, | |||
346 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); | 354 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); |
347 | struct cifsTconInfo *pTcon; | 355 | struct cifsTconInfo *pTcon; |
348 | 356 | ||
349 | if(cifs_sb) | 357 | if (cifs_sb) |
350 | pTcon = cifs_sb->tcon; | 358 | pTcon = cifs_sb->tcon; |
351 | else | 359 | else |
352 | return -EIO; | 360 | return -EIO; |
353 | 361 | ||
354 | xid = GetXid(); | 362 | xid = GetXid(); |
355 | if(pTcon) { | 363 | if (pTcon) { |
356 | cFYI(1,("set type: 0x%x id: %d",quota_type,qid)); | 364 | cFYI(1,("set type: 0x%x id: %d",quota_type,qid)); |
357 | } else { | 365 | } else { |
358 | rc = -EIO; | 366 | rc = -EIO; |
@@ -369,13 +377,13 @@ int cifs_xstate_set(struct super_block * sb, unsigned int flags, int operation) | |||
369 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); | 377 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); |
370 | struct cifsTconInfo *pTcon; | 378 | struct cifsTconInfo *pTcon; |
371 | 379 | ||
372 | if(cifs_sb) | 380 | if (cifs_sb) |
373 | pTcon = cifs_sb->tcon; | 381 | pTcon = cifs_sb->tcon; |
374 | else | 382 | else |
375 | return -EIO; | 383 | return -EIO; |
376 | 384 | ||
377 | xid = GetXid(); | 385 | xid = GetXid(); |
378 | if(pTcon) { | 386 | if (pTcon) { |
379 | cFYI(1,("flags: 0x%x operation: 0x%x",flags,operation)); | 387 | cFYI(1,("flags: 0x%x operation: 0x%x",flags,operation)); |
380 | } else { | 388 | } else { |
381 | rc = -EIO; | 389 | rc = -EIO; |
@@ -392,13 +400,13 @@ int cifs_xstate_get(struct super_block * sb, struct fs_quota_stat *qstats) | |||
392 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); | 400 | struct cifs_sb_info *cifs_sb = CIFS_SB(sb); |
393 | struct cifsTconInfo *pTcon; | 401 | struct cifsTconInfo *pTcon; |
394 | 402 | ||
395 | if(cifs_sb) { | 403 | if (cifs_sb) { |
396 | pTcon = cifs_sb->tcon; | 404 | pTcon = cifs_sb->tcon; |
397 | } else { | 405 | } else { |
398 | return -EIO; | 406 | return -EIO; |
399 | } | 407 | } |
400 | xid = GetXid(); | 408 | xid = GetXid(); |
401 | if(pTcon) { | 409 | if (pTcon) { |
402 | cFYI(1,("pqstats %p",qstats)); | 410 | cFYI(1,("pqstats %p",qstats)); |
403 | } else { | 411 | } else { |
404 | rc = -EIO; | 412 | rc = -EIO; |
@@ -424,11 +432,11 @@ static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags) | |||
424 | if (!(flags & MNT_FORCE)) | 432 | if (!(flags & MNT_FORCE)) |
425 | return; | 433 | return; |
426 | cifs_sb = CIFS_SB(vfsmnt->mnt_sb); | 434 | cifs_sb = CIFS_SB(vfsmnt->mnt_sb); |
427 | if(cifs_sb == NULL) | 435 | if (cifs_sb == NULL) |
428 | return; | 436 | return; |
429 | 437 | ||
430 | tcon = cifs_sb->tcon; | 438 | tcon = cifs_sb->tcon; |
431 | if(tcon == NULL) | 439 | if (tcon == NULL) |
432 | return; | 440 | return; |
433 | down(&tcon->tconSem); | 441 | down(&tcon->tconSem); |
434 | if (atomic_read(&tcon->useCount) == 1) | 442 | if (atomic_read(&tcon->useCount) == 1) |
@@ -437,7 +445,7 @@ static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags) | |||
437 | 445 | ||
438 | /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */ | 446 | /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */ |
439 | /* cancel_notify_requests(tcon); */ | 447 | /* cancel_notify_requests(tcon); */ |
440 | if(tcon->ses && tcon->ses->server) | 448 | if (tcon->ses && tcon->ses->server) |
441 | { | 449 | { |
442 | cFYI(1,("wake up tasks now - umount begin not complete")); | 450 | cFYI(1,("wake up tasks now - umount begin not complete")); |
443 | wake_up_all(&tcon->ses->server->request_q); | 451 | wake_up_all(&tcon->ses->server->request_q); |
@@ -723,7 +731,7 @@ cifs_destroy_inodecache(void) | |||
723 | static int | 731 | static int |
724 | cifs_init_request_bufs(void) | 732 | cifs_init_request_bufs(void) |
725 | { | 733 | { |
726 | if(CIFSMaxBufSize < 8192) { | 734 | if (CIFSMaxBufSize < 8192) { |
727 | /* Buffer size can not be smaller than 2 * PATH_MAX since maximum | 735 | /* Buffer size can not be smaller than 2 * PATH_MAX since maximum |
728 | Unicode path name has to fit in any SMB/CIFS path based frames */ | 736 | Unicode path name has to fit in any SMB/CIFS path based frames */ |
729 | CIFSMaxBufSize = 8192; | 737 | CIFSMaxBufSize = 8192; |
@@ -740,7 +748,7 @@ cifs_init_request_bufs(void) | |||
740 | if (cifs_req_cachep == NULL) | 748 | if (cifs_req_cachep == NULL) |
741 | return -ENOMEM; | 749 | return -ENOMEM; |
742 | 750 | ||
743 | if(cifs_min_rcv < 1) | 751 | if (cifs_min_rcv < 1) |
744 | cifs_min_rcv = 1; | 752 | cifs_min_rcv = 1; |
745 | else if (cifs_min_rcv > 64) { | 753 | else if (cifs_min_rcv > 64) { |
746 | cifs_min_rcv = 64; | 754 | cifs_min_rcv = 64; |
@@ -750,7 +758,7 @@ cifs_init_request_bufs(void) | |||
750 | cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv, | 758 | cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv, |
751 | cifs_req_cachep); | 759 | cifs_req_cachep); |
752 | 760 | ||
753 | if(cifs_req_poolp == NULL) { | 761 | if (cifs_req_poolp == NULL) { |
754 | kmem_cache_destroy(cifs_req_cachep); | 762 | kmem_cache_destroy(cifs_req_cachep); |
755 | return -ENOMEM; | 763 | return -ENOMEM; |
756 | } | 764 | } |
@@ -771,7 +779,7 @@ cifs_init_request_bufs(void) | |||
771 | return -ENOMEM; | 779 | return -ENOMEM; |
772 | } | 780 | } |
773 | 781 | ||
774 | if(cifs_min_small < 2) | 782 | if (cifs_min_small < 2) |
775 | cifs_min_small = 2; | 783 | cifs_min_small = 2; |
776 | else if (cifs_min_small > 256) { | 784 | else if (cifs_min_small > 256) { |
777 | cifs_min_small = 256; | 785 | cifs_min_small = 256; |
@@ -781,7 +789,7 @@ cifs_init_request_bufs(void) | |||
781 | cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small, | 789 | cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small, |
782 | cifs_sm_req_cachep); | 790 | cifs_sm_req_cachep); |
783 | 791 | ||
784 | if(cifs_sm_req_poolp == NULL) { | 792 | if (cifs_sm_req_poolp == NULL) { |
785 | mempool_destroy(cifs_req_poolp); | 793 | mempool_destroy(cifs_req_poolp); |
786 | kmem_cache_destroy(cifs_req_cachep); | 794 | kmem_cache_destroy(cifs_req_cachep); |
787 | kmem_cache_destroy(cifs_sm_req_cachep); | 795 | kmem_cache_destroy(cifs_sm_req_cachep); |
@@ -811,7 +819,7 @@ cifs_init_mids(void) | |||
811 | 819 | ||
812 | /* 3 is a reasonable minimum number of simultaneous operations */ | 820 | /* 3 is a reasonable minimum number of simultaneous operations */ |
813 | cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep); | 821 | cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep); |
814 | if(cifs_mid_poolp == NULL) { | 822 | if (cifs_mid_poolp == NULL) { |
815 | kmem_cache_destroy(cifs_mid_cachep); | 823 | kmem_cache_destroy(cifs_mid_cachep); |
816 | return -ENOMEM; | 824 | return -ENOMEM; |
817 | } | 825 | } |
@@ -849,14 +857,14 @@ static int cifs_oplock_thread(void * dummyarg) | |||
849 | continue; | 857 | continue; |
850 | 858 | ||
851 | spin_lock(&GlobalMid_Lock); | 859 | spin_lock(&GlobalMid_Lock); |
852 | if(list_empty(&GlobalOplock_Q)) { | 860 | if (list_empty(&GlobalOplock_Q)) { |
853 | spin_unlock(&GlobalMid_Lock); | 861 | spin_unlock(&GlobalMid_Lock); |
854 | set_current_state(TASK_INTERRUPTIBLE); | 862 | set_current_state(TASK_INTERRUPTIBLE); |
855 | schedule_timeout(39*HZ); | 863 | schedule_timeout(39*HZ); |
856 | } else { | 864 | } else { |
857 | oplock_item = list_entry(GlobalOplock_Q.next, | 865 | oplock_item = list_entry(GlobalOplock_Q.next, |
858 | struct oplock_q_entry, qhead); | 866 | struct oplock_q_entry, qhead); |
859 | if(oplock_item) { | 867 | if (oplock_item) { |
860 | cFYI(1,("found oplock item to write out")); | 868 | cFYI(1,("found oplock item to write out")); |
861 | pTcon = oplock_item->tcon; | 869 | pTcon = oplock_item->tcon; |
862 | inode = oplock_item->pinode; | 870 | inode = oplock_item->pinode; |
@@ -870,7 +878,7 @@ static int cifs_oplock_thread(void * dummyarg) | |||
870 | /* mutex_lock(&inode->i_mutex);*/ | 878 | /* mutex_lock(&inode->i_mutex);*/ |
871 | if (S_ISREG(inode->i_mode)) { | 879 | if (S_ISREG(inode->i_mode)) { |
872 | rc = filemap_fdatawrite(inode->i_mapping); | 880 | rc = filemap_fdatawrite(inode->i_mapping); |
873 | if(CIFS_I(inode)->clientCanCacheRead == 0) { | 881 | if (CIFS_I(inode)->clientCanCacheRead == 0) { |
874 | filemap_fdatawait(inode->i_mapping); | 882 | filemap_fdatawait(inode->i_mapping); |
875 | invalidate_remote_inode(inode); | 883 | invalidate_remote_inode(inode); |
876 | } | 884 | } |
@@ -887,7 +895,7 @@ static int cifs_oplock_thread(void * dummyarg) | |||
887 | not bother sending an oplock release if session | 895 | not bother sending an oplock release if session |
888 | to server still is disconnected since oplock | 896 | to server still is disconnected since oplock |
889 | already released by the server in that case */ | 897 | already released by the server in that case */ |
890 | if(pTcon->tidStatus != CifsNeedReconnect) { | 898 | if (pTcon->tidStatus != CifsNeedReconnect) { |
891 | rc = CIFSSMBLock(0, pTcon, netfid, | 899 | rc = CIFSSMBLock(0, pTcon, netfid, |
892 | 0 /* len */ , 0 /* offset */, 0, | 900 | 0 /* len */ , 0 /* offset */, 0, |
893 | 0, LOCKING_ANDX_OPLOCK_RELEASE, | 901 | 0, LOCKING_ANDX_OPLOCK_RELEASE, |
@@ -921,7 +929,7 @@ static int cifs_dnotify_thread(void * dummyarg) | |||
921 | list_for_each(tmp, &GlobalSMBSessionList) { | 929 | list_for_each(tmp, &GlobalSMBSessionList) { |
922 | ses = list_entry(tmp, struct cifsSesInfo, | 930 | ses = list_entry(tmp, struct cifsSesInfo, |
923 | cifsSessionList); | 931 | cifsSessionList); |
924 | if(ses && ses->server && | 932 | if (ses && ses->server && |
925 | atomic_read(&ses->server->inFlight)) | 933 | atomic_read(&ses->server->inFlight)) |
926 | wake_up_all(&ses->server->response_q); | 934 | wake_up_all(&ses->server->response_q); |
927 | } | 935 | } |
@@ -970,10 +978,10 @@ init_cifs(void) | |||
970 | rwlock_init(&GlobalSMBSeslock); | 978 | rwlock_init(&GlobalSMBSeslock); |
971 | spin_lock_init(&GlobalMid_Lock); | 979 | spin_lock_init(&GlobalMid_Lock); |
972 | 980 | ||
973 | if(cifs_max_pending < 2) { | 981 | if (cifs_max_pending < 2) { |
974 | cifs_max_pending = 2; | 982 | cifs_max_pending = 2; |
975 | cFYI(1,("cifs_max_pending set to min of 2")); | 983 | cFYI(1,("cifs_max_pending set to min of 2")); |
976 | } else if(cifs_max_pending > 256) { | 984 | } else if (cifs_max_pending > 256) { |
977 | cifs_max_pending = 256; | 985 | cifs_max_pending = 256; |
978 | cFYI(1,("cifs_max_pending set to max of 256")); | 986 | cFYI(1,("cifs_max_pending set to max of 256")); |
979 | } | 987 | } |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index c1af15995689..1f4bc7181701 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -75,6 +75,8 @@ struct smb_vol { | |||
75 | unsigned retry:1; | 75 | unsigned retry:1; |
76 | unsigned intr:1; | 76 | unsigned intr:1; |
77 | unsigned setuids:1; | 77 | unsigned setuids:1; |
78 | unsigned override_uid:1; | ||
79 | unsigned override_gid:1; | ||
78 | unsigned noperm:1; | 80 | unsigned noperm:1; |
79 | unsigned no_psx_acl:1; /* set if posix acl support should be disabled */ | 81 | unsigned no_psx_acl:1; /* set if posix acl support should be disabled */ |
80 | unsigned cifs_acl:1; | 82 | unsigned cifs_acl:1; |
@@ -972,7 +974,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
972 | } | 974 | } |
973 | if ((temp_len = strnlen(value, 300)) < 300) { | 975 | if ((temp_len = strnlen(value, 300)) < 300) { |
974 | vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); | 976 | vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); |
975 | if(vol->UNC == NULL) | 977 | if (vol->UNC == NULL) |
976 | return 1; | 978 | return 1; |
977 | strcpy(vol->UNC,value); | 979 | strcpy(vol->UNC,value); |
978 | if (strncmp(vol->UNC, "//", 2) == 0) { | 980 | if (strncmp(vol->UNC, "//", 2) == 0) { |
@@ -1009,12 +1011,12 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1009 | return 1; /* needs_arg; */ | 1011 | return 1; /* needs_arg; */ |
1010 | } | 1012 | } |
1011 | if ((temp_len = strnlen(value, 1024)) < 1024) { | 1013 | if ((temp_len = strnlen(value, 1024)) < 1024) { |
1012 | if(value[0] != '/') | 1014 | if (value[0] != '/') |
1013 | temp_len++; /* missing leading slash */ | 1015 | temp_len++; /* missing leading slash */ |
1014 | vol->prepath = kmalloc(temp_len+1,GFP_KERNEL); | 1016 | vol->prepath = kmalloc(temp_len+1,GFP_KERNEL); |
1015 | if(vol->prepath == NULL) | 1017 | if (vol->prepath == NULL) |
1016 | return 1; | 1018 | return 1; |
1017 | if(value[0] != '/') { | 1019 | if (value[0] != '/') { |
1018 | vol->prepath[0] = '/'; | 1020 | vol->prepath[0] = '/'; |
1019 | strcpy(vol->prepath+1,value); | 1021 | strcpy(vol->prepath+1,value); |
1020 | } else | 1022 | } else |
@@ -1030,7 +1032,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1030 | return 1; /* needs_arg; */ | 1032 | return 1; /* needs_arg; */ |
1031 | } | 1033 | } |
1032 | if (strnlen(value, 65) < 65) { | 1034 | if (strnlen(value, 65) < 65) { |
1033 | if(strnicmp(value,"default",7)) | 1035 | if (strnicmp(value,"default",7)) |
1034 | vol->iocharset = value; | 1036 | vol->iocharset = value; |
1035 | /* if iocharset not set load_nls_default used by caller */ | 1037 | /* if iocharset not set load_nls_default used by caller */ |
1036 | cFYI(1, ("iocharset set to %s",value)); | 1038 | 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 | if (value && *value) { | 1044 | if (value && *value) { |
1043 | vol->linux_uid = | 1045 | vol->linux_uid = |
1044 | simple_strtoul(value, &value, 0); | 1046 | simple_strtoul(value, &value, 0); |
1047 | vol->override_uid = 1; | ||
1045 | } | 1048 | } |
1046 | } else if (strnicmp(data, "gid", 3) == 0) { | 1049 | } else if (strnicmp(data, "gid", 3) == 0) { |
1047 | if (value && *value) { | 1050 | if (value && *value) { |
1048 | vol->linux_gid = | 1051 | vol->linux_gid = |
1049 | simple_strtoul(value, &value, 0); | 1052 | simple_strtoul(value, &value, 0); |
1053 | vol->override_gid = 1; | ||
1050 | } | 1054 | } |
1051 | } else if (strnicmp(data, "file_mode", 4) == 0) { | 1055 | } else if (strnicmp(data, "file_mode", 4) == 0) { |
1052 | if (value && *value) { | 1056 | if (value && *value) { |
@@ -1101,7 +1105,7 @@ cifs_parse_mount_options(char *options, const char *devname,struct smb_vol *vol) | |||
1101 | } | 1105 | } |
1102 | /* The string has 16th byte zero still from | 1106 | /* The string has 16th byte zero still from |
1103 | set at top of the function */ | 1107 | set at top of the function */ |
1104 | if((i==15) && (value[i] != 0)) | 1108 | if ((i==15) && (value[i] != 0)) |
1105 | printk(KERN_WARNING "CIFS: netbiosname longer than 15 truncated.\n"); | 1109 | printk(KERN_WARNING "CIFS: netbiosname longer than 15 truncated.\n"); |
1106 | } | 1110 | } |
1107 | } else if (strnicmp(data, "servern", 7) == 0) { | 1111 | } 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 | } | 1129 | } |
1126 | /* The string has 16th byte zero still from | 1130 | /* The string has 16th byte zero still from |
1127 | set at top of the function */ | 1131 | set at top of the function */ |
1128 | if((i==15) && (value[i] != 0)) | 1132 | if ((i==15) && (value[i] != 0)) |
1129 | printk(KERN_WARNING "CIFS: server netbiosname longer than 15 truncated.\n"); | 1133 | printk(KERN_WARNING "CIFS: server netbiosname longer than 15 truncated.\n"); |
1130 | } | 1134 | } |
1131 | } else if (strnicmp(data, "credentials", 4) == 0) { | 1135 | } 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 | printk(KERN_WARNING "CIFS: Unknown mount option %s\n",data); | 1236 | printk(KERN_WARNING "CIFS: Unknown mount option %s\n",data); |
1233 | } | 1237 | } |
1234 | if (vol->UNC == NULL) { | 1238 | if (vol->UNC == NULL) { |
1235 | if(devname == NULL) { | 1239 | if (devname == NULL) { |
1236 | printk(KERN_WARNING "CIFS: Missing UNC name for mount target\n"); | 1240 | printk(KERN_WARNING "CIFS: Missing UNC name for mount target\n"); |
1237 | return 1; | 1241 | return 1; |
1238 | } | 1242 | } |
1239 | if ((temp_len = strnlen(devname, 300)) < 300) { | 1243 | if ((temp_len = strnlen(devname, 300)) < 300) { |
1240 | vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); | 1244 | vol->UNC = kmalloc(temp_len+1,GFP_KERNEL); |
1241 | if(vol->UNC == NULL) | 1245 | if (vol->UNC == NULL) |
1242 | return 1; | 1246 | return 1; |
1243 | strcpy(vol->UNC,devname); | 1247 | strcpy(vol->UNC,devname); |
1244 | if (strncmp(vol->UNC, "//", 2) == 0) { | 1248 | if (strncmp(vol->UNC, "//", 2) == 0) { |
@@ -1813,7 +1817,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1813 | if (srvTcp) { | 1817 | if (srvTcp) { |
1814 | cFYI(1, ("Existing tcp session with server found")); | 1818 | cFYI(1, ("Existing tcp session with server found")); |
1815 | } else { /* create socket */ | 1819 | } else { /* create socket */ |
1816 | if(volume_info.port) | 1820 | if (volume_info.port) |
1817 | sin_server.sin_port = htons(volume_info.port); | 1821 | sin_server.sin_port = htons(volume_info.port); |
1818 | else | 1822 | else |
1819 | sin_server.sin_port = 0; | 1823 | sin_server.sin_port = 0; |
@@ -1829,7 +1833,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1829 | if (rc < 0) { | 1833 | if (rc < 0) { |
1830 | cERROR(1, | 1834 | cERROR(1, |
1831 | ("Error connecting to IPv4 socket. Aborting operation")); | 1835 | ("Error connecting to IPv4 socket. Aborting operation")); |
1832 | if(csocket != NULL) | 1836 | if (csocket != NULL) |
1833 | sock_release(csocket); | 1837 | sock_release(csocket); |
1834 | kfree(volume_info.UNC); | 1838 | kfree(volume_info.UNC); |
1835 | kfree(volume_info.password); | 1839 | kfree(volume_info.password); |
@@ -1863,7 +1867,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1863 | srvTcp->tcpStatus = CifsNew; | 1867 | srvTcp->tcpStatus = CifsNew; |
1864 | init_MUTEX(&srvTcp->tcpSem); | 1868 | init_MUTEX(&srvTcp->tcpSem); |
1865 | srvTcp->tsk = kthread_run((void *)(void *)cifs_demultiplex_thread, srvTcp, "cifsd"); | 1869 | srvTcp->tsk = kthread_run((void *)(void *)cifs_demultiplex_thread, srvTcp, "cifsd"); |
1866 | if( IS_ERR(srvTcp->tsk) ) { | 1870 | if ( IS_ERR(srvTcp->tsk) ) { |
1867 | rc = PTR_ERR(srvTcp->tsk); | 1871 | rc = PTR_ERR(srvTcp->tsk); |
1868 | cERROR(1,("error %d create cifsd thread", rc)); | 1872 | cERROR(1,("error %d create cifsd thread", rc)); |
1869 | srvTcp->tsk = NULL; | 1873 | srvTcp->tsk = NULL; |
@@ -1909,7 +1913,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1909 | int len = strlen(volume_info.domainname); | 1913 | int len = strlen(volume_info.domainname); |
1910 | pSesInfo->domainName = | 1914 | pSesInfo->domainName = |
1911 | kmalloc(len + 1, GFP_KERNEL); | 1915 | kmalloc(len + 1, GFP_KERNEL); |
1912 | if(pSesInfo->domainName) | 1916 | if (pSesInfo->domainName) |
1913 | strcpy(pSesInfo->domainName, | 1917 | strcpy(pSesInfo->domainName, |
1914 | volume_info.domainname); | 1918 | volume_info.domainname); |
1915 | } | 1919 | } |
@@ -1919,7 +1923,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1919 | /* BB FIXME need to pass vol->secFlgs BB */ | 1923 | /* BB FIXME need to pass vol->secFlgs BB */ |
1920 | rc = cifs_setup_session(xid,pSesInfo, cifs_sb->local_nls); | 1924 | rc = cifs_setup_session(xid,pSesInfo, cifs_sb->local_nls); |
1921 | up(&pSesInfo->sesSem); | 1925 | up(&pSesInfo->sesSem); |
1922 | if(!rc) | 1926 | if (!rc) |
1923 | atomic_inc(&srvTcp->socketUseCount); | 1927 | atomic_inc(&srvTcp->socketUseCount); |
1924 | } else | 1928 | } else |
1925 | kfree(volume_info.password); | 1929 | kfree(volume_info.password); |
@@ -1927,7 +1931,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1927 | 1931 | ||
1928 | /* search for existing tcon to this server share */ | 1932 | /* search for existing tcon to this server share */ |
1929 | if (!rc) { | 1933 | if (!rc) { |
1930 | if(volume_info.rsize > CIFSMaxBufSize) { | 1934 | if (volume_info.rsize > CIFSMaxBufSize) { |
1931 | cERROR(1,("rsize %d too large, using MaxBufSize", | 1935 | cERROR(1,("rsize %d too large, using MaxBufSize", |
1932 | volume_info.rsize)); | 1936 | volume_info.rsize)); |
1933 | cifs_sb->rsize = CIFSMaxBufSize; | 1937 | cifs_sb->rsize = CIFSMaxBufSize; |
@@ -1936,11 +1940,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1936 | else /* default */ | 1940 | else /* default */ |
1937 | cifs_sb->rsize = CIFSMaxBufSize; | 1941 | cifs_sb->rsize = CIFSMaxBufSize; |
1938 | 1942 | ||
1939 | if(volume_info.wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) { | 1943 | if (volume_info.wsize > PAGEVEC_SIZE * PAGE_CACHE_SIZE) { |
1940 | cERROR(1,("wsize %d too large using 4096 instead", | 1944 | cERROR(1,("wsize %d too large using 4096 instead", |
1941 | volume_info.wsize)); | 1945 | volume_info.wsize)); |
1942 | cifs_sb->wsize = 4096; | 1946 | cifs_sb->wsize = 4096; |
1943 | } else if(volume_info.wsize) | 1947 | } else if (volume_info.wsize) |
1944 | cifs_sb->wsize = volume_info.wsize; | 1948 | cifs_sb->wsize = volume_info.wsize; |
1945 | else | 1949 | else |
1946 | cifs_sb->wsize = | 1950 | cifs_sb->wsize = |
@@ -1953,14 +1957,14 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1953 | conjunction with 52K kvec constraint on arch with 4K | 1957 | conjunction with 52K kvec constraint on arch with 4K |
1954 | page size */ | 1958 | page size */ |
1955 | 1959 | ||
1956 | if(cifs_sb->rsize < 2048) { | 1960 | if (cifs_sb->rsize < 2048) { |
1957 | cifs_sb->rsize = 2048; | 1961 | cifs_sb->rsize = 2048; |
1958 | /* Windows ME may prefer this */ | 1962 | /* Windows ME may prefer this */ |
1959 | cFYI(1,("readsize set to minimum 2048")); | 1963 | cFYI(1,("readsize set to minimum 2048")); |
1960 | } | 1964 | } |
1961 | /* calculate prepath */ | 1965 | /* calculate prepath */ |
1962 | cifs_sb->prepath = volume_info.prepath; | 1966 | cifs_sb->prepath = volume_info.prepath; |
1963 | if(cifs_sb->prepath) { | 1967 | if (cifs_sb->prepath) { |
1964 | cifs_sb->prepathlen = strlen(cifs_sb->prepath); | 1968 | cifs_sb->prepathlen = strlen(cifs_sb->prepath); |
1965 | cifs_sb->prepath[0] = CIFS_DIR_SEP(cifs_sb); | 1969 | cifs_sb->prepath[0] = CIFS_DIR_SEP(cifs_sb); |
1966 | volume_info.prepath = NULL; | 1970 | volume_info.prepath = NULL; |
@@ -1973,24 +1977,27 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
1973 | cFYI(1,("file mode: 0x%x dir mode: 0x%x", | 1977 | cFYI(1,("file mode: 0x%x dir mode: 0x%x", |
1974 | cifs_sb->mnt_file_mode,cifs_sb->mnt_dir_mode)); | 1978 | cifs_sb->mnt_file_mode,cifs_sb->mnt_dir_mode)); |
1975 | 1979 | ||
1976 | if(volume_info.noperm) | 1980 | if (volume_info.noperm) |
1977 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; | 1981 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; |
1978 | if(volume_info.setuids) | 1982 | if (volume_info.setuids) |
1979 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID; | 1983 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID; |
1980 | if(volume_info.server_ino) | 1984 | if (volume_info.server_ino) |
1981 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM; | 1985 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM; |
1982 | if(volume_info.remap) | 1986 | if (volume_info.remap) |
1983 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR; | 1987 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR; |
1984 | if(volume_info.no_xattr) | 1988 | if (volume_info.no_xattr) |
1985 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR; | 1989 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR; |
1986 | if(volume_info.sfu_emul) | 1990 | if (volume_info.sfu_emul) |
1987 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL; | 1991 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL; |
1988 | if(volume_info.nobrl) | 1992 | if (volume_info.nobrl) |
1989 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL; | 1993 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL; |
1990 | if(volume_info.cifs_acl) | 1994 | if (volume_info.cifs_acl) |
1991 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL; | 1995 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL; |
1992 | 1996 | if (volume_info.override_uid) | |
1993 | if(volume_info.direct_io) { | 1997 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID; |
1998 | if (volume_info.override_gid) | ||
1999 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID; | ||
2000 | if (volume_info.direct_io) { | ||
1994 | cFYI(1,("mounting share using direct i/o")); | 2001 | cFYI(1,("mounting share using direct i/o")); |
1995 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO; | 2002 | cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO; |
1996 | } | 2003 | } |
@@ -2043,7 +2050,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2043 | } | 2050 | } |
2044 | } | 2051 | } |
2045 | } | 2052 | } |
2046 | if(pSesInfo) { | 2053 | if (pSesInfo) { |
2047 | if (pSesInfo->capabilities & CAP_LARGE_FILES) { | 2054 | if (pSesInfo->capabilities & CAP_LARGE_FILES) { |
2048 | sb->s_maxbytes = (u64) 1 << 63; | 2055 | sb->s_maxbytes = (u64) 1 << 63; |
2049 | } else | 2056 | } else |
@@ -2057,11 +2064,11 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2057 | if (rc) { | 2064 | if (rc) { |
2058 | /* if session setup failed, use count is zero but | 2065 | /* if session setup failed, use count is zero but |
2059 | we still need to free cifsd thread */ | 2066 | we still need to free cifsd thread */ |
2060 | if(atomic_read(&srvTcp->socketUseCount) == 0) { | 2067 | if (atomic_read(&srvTcp->socketUseCount) == 0) { |
2061 | spin_lock(&GlobalMid_Lock); | 2068 | spin_lock(&GlobalMid_Lock); |
2062 | srvTcp->tcpStatus = CifsExiting; | 2069 | srvTcp->tcpStatus = CifsExiting; |
2063 | spin_unlock(&GlobalMid_Lock); | 2070 | spin_unlock(&GlobalMid_Lock); |
2064 | if(srvTcp->tsk) { | 2071 | if (srvTcp->tsk) { |
2065 | send_sig(SIGKILL,srvTcp->tsk,1); | 2072 | send_sig(SIGKILL,srvTcp->tsk,1); |
2066 | kthread_stop(srvTcp->tsk); | 2073 | kthread_stop(srvTcp->tsk); |
2067 | } | 2074 | } |
@@ -2076,7 +2083,7 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb, | |||
2076 | int temp_rc; | 2083 | int temp_rc; |
2077 | temp_rc = CIFSSMBLogoff(xid, pSesInfo); | 2084 | temp_rc = CIFSSMBLogoff(xid, pSesInfo); |
2078 | /* if the socketUseCount is now zero */ | 2085 | /* if the socketUseCount is now zero */ |
2079 | if((temp_rc == -ESHUTDOWN) && | 2086 | if ((temp_rc == -ESHUTDOWN) && |
2080 | (pSesInfo->server) && (pSesInfo->server->tsk)) { | 2087 | (pSesInfo->server) && (pSesInfo->server->tsk)) { |
2081 | send_sig(SIGKILL,pSesInfo->server->tsk,1); | 2088 | send_sig(SIGKILL,pSesInfo->server->tsk,1); |
2082 | kthread_stop(pSesInfo->server->tsk); | 2089 | kthread_stop(pSesInfo->server->tsk); |
@@ -2140,7 +2147,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2140 | __u16 count; | 2147 | __u16 count; |
2141 | 2148 | ||
2142 | cFYI(1, ("In sesssetup")); | 2149 | cFYI(1, ("In sesssetup")); |
2143 | if(ses == NULL) | 2150 | if (ses == NULL) |
2144 | return -EINVAL; | 2151 | return -EINVAL; |
2145 | user = ses->userName; | 2152 | user = ses->userName; |
2146 | domain = ses->domainName; | 2153 | domain = ses->domainName; |
@@ -2195,7 +2202,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2195 | *bcc_ptr = 0; | 2202 | *bcc_ptr = 0; |
2196 | bcc_ptr++; | 2203 | bcc_ptr++; |
2197 | } | 2204 | } |
2198 | if(user == NULL) | 2205 | if (user == NULL) |
2199 | bytes_returned = 0; /* skip null user */ | 2206 | bytes_returned = 0; /* skip null user */ |
2200 | else | 2207 | else |
2201 | bytes_returned = | 2208 | bytes_returned = |
@@ -2229,7 +2236,7 @@ CIFSSessSetup(unsigned int xid, struct cifsSesInfo *ses, | |||
2229 | bcc_ptr += 2 * bytes_returned; | 2236 | bcc_ptr += 2 * bytes_returned; |
2230 | bcc_ptr += 2; | 2237 | bcc_ptr += 2; |
2231 | } else { | 2238 | } else { |
2232 | if(user != NULL) { | 2239 | if (user != NULL) { |
2233 | strncpy(bcc_ptr, user, 200); | 2240 | strncpy(bcc_ptr, user, 200); |
2234 | bcc_ptr += strnlen(user, 200); | 2241 | bcc_ptr += strnlen(user, 200); |
2235 | } | 2242 | } |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index f74f37cee119..3e87dad3367c 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -90,7 +90,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
90 | (*pinode)->i_ino = | 90 | (*pinode)->i_ino = |
91 | (unsigned long)findData.UniqueId; | 91 | (unsigned long)findData.UniqueId; |
92 | } /* note ino incremented to unique num in new_inode */ | 92 | } /* note ino incremented to unique num in new_inode */ |
93 | if(sb->s_flags & MS_NOATIME) | 93 | if (sb->s_flags & MS_NOATIME) |
94 | (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; | 94 | (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; |
95 | 95 | ||
96 | insert_inode_hash(*pinode); | 96 | insert_inode_hash(*pinode); |
@@ -139,8 +139,17 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
139 | inode->i_mode |= S_IFREG; | 139 | inode->i_mode |= S_IFREG; |
140 | cFYI(1,("unknown type %d",type)); | 140 | cFYI(1,("unknown type %d",type)); |
141 | } | 141 | } |
142 | inode->i_uid = le64_to_cpu(findData.Uid); | 142 | |
143 | inode->i_gid = le64_to_cpu(findData.Gid); | 143 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) |
144 | inode->i_uid = cifs_sb->mnt_uid; | ||
145 | else | ||
146 | inode->i_uid = le64_to_cpu(findData.Uid); | ||
147 | |||
148 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) | ||
149 | inode->i_gid = cifs_sb->mnt_gid; | ||
150 | else | ||
151 | inode->i_gid = le64_to_cpu(findData.Gid); | ||
152 | |||
144 | inode->i_nlink = le64_to_cpu(findData.Nlinks); | 153 | inode->i_nlink = le64_to_cpu(findData.Nlinks); |
145 | 154 | ||
146 | spin_lock(&inode->i_lock); | 155 | spin_lock(&inode->i_lock); |
@@ -178,13 +187,13 @@ int cifs_get_inode_info_unix(struct inode **pinode, | |||
178 | &cifs_file_direct_nobrl_ops; | 187 | &cifs_file_direct_nobrl_ops; |
179 | else | 188 | else |
180 | inode->i_fop = &cifs_file_direct_ops; | 189 | inode->i_fop = &cifs_file_direct_ops; |
181 | } else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 190 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
182 | inode->i_fop = &cifs_file_nobrl_ops; | 191 | inode->i_fop = &cifs_file_nobrl_ops; |
183 | else /* not direct, send byte range locks */ | 192 | else /* not direct, send byte range locks */ |
184 | inode->i_fop = &cifs_file_ops; | 193 | inode->i_fop = &cifs_file_ops; |
185 | 194 | ||
186 | /* check if server can support readpages */ | 195 | /* check if server can support readpages */ |
187 | if(pTcon->ses->server->maxBuf < | 196 | if (pTcon->ses->server->maxBuf < |
188 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) | 197 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) |
189 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | 198 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
190 | else | 199 | else |
@@ -220,7 +229,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
220 | 229 | ||
221 | pbuf = buf; | 230 | pbuf = buf; |
222 | 231 | ||
223 | if(size == 0) { | 232 | if (size == 0) { |
224 | inode->i_mode |= S_IFIFO; | 233 | inode->i_mode |= S_IFIFO; |
225 | return 0; | 234 | return 0; |
226 | } else if (size < 8) { | 235 | } else if (size < 8) { |
@@ -239,11 +248,11 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
239 | netfid, | 248 | netfid, |
240 | 24 /* length */, 0 /* offset */, | 249 | 24 /* length */, 0 /* offset */, |
241 | &bytes_read, &pbuf, &buf_type); | 250 | &bytes_read, &pbuf, &buf_type); |
242 | if((rc == 0) && (bytes_read >= 8)) { | 251 | if ((rc == 0) && (bytes_read >= 8)) { |
243 | if(memcmp("IntxBLK", pbuf, 8) == 0) { | 252 | if (memcmp("IntxBLK", pbuf, 8) == 0) { |
244 | cFYI(1,("Block device")); | 253 | cFYI(1,("Block device")); |
245 | inode->i_mode |= S_IFBLK; | 254 | inode->i_mode |= S_IFBLK; |
246 | if(bytes_read == 24) { | 255 | if (bytes_read == 24) { |
247 | /* we have enough to decode dev num */ | 256 | /* we have enough to decode dev num */ |
248 | __u64 mjr; /* major */ | 257 | __u64 mjr; /* major */ |
249 | __u64 mnr; /* minor */ | 258 | __u64 mnr; /* minor */ |
@@ -251,10 +260,10 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
251 | mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); | 260 | mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); |
252 | inode->i_rdev = MKDEV(mjr, mnr); | 261 | inode->i_rdev = MKDEV(mjr, mnr); |
253 | } | 262 | } |
254 | } else if(memcmp("IntxCHR", pbuf, 8) == 0) { | 263 | } else if (memcmp("IntxCHR", pbuf, 8) == 0) { |
255 | cFYI(1,("Char device")); | 264 | cFYI(1,("Char device")); |
256 | inode->i_mode |= S_IFCHR; | 265 | inode->i_mode |= S_IFCHR; |
257 | if(bytes_read == 24) { | 266 | if (bytes_read == 24) { |
258 | /* we have enough to decode dev num */ | 267 | /* we have enough to decode dev num */ |
259 | __u64 mjr; /* major */ | 268 | __u64 mjr; /* major */ |
260 | __u64 mnr; /* minor */ | 269 | __u64 mnr; /* minor */ |
@@ -262,7 +271,7 @@ static int decode_sfu_inode(struct inode * inode, __u64 size, | |||
262 | mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); | 271 | mnr = le64_to_cpu(*(__le64 *)(pbuf+16)); |
263 | inode->i_rdev = MKDEV(mjr, mnr); | 272 | inode->i_rdev = MKDEV(mjr, mnr); |
264 | } | 273 | } |
265 | } else if(memcmp("IntxLNK", pbuf, 7) == 0) { | 274 | } else if (memcmp("IntxLNK", pbuf, 7) == 0) { |
266 | cFYI(1,("Symlink")); | 275 | cFYI(1,("Symlink")); |
267 | inode->i_mode |= S_IFLNK; | 276 | inode->i_mode |= S_IFLNK; |
268 | } else { | 277 | } else { |
@@ -293,7 +302,7 @@ static int get_sfu_uid_mode(struct inode * inode, | |||
293 | rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS", | 302 | rc = CIFSSMBQueryEA(xid, cifs_sb->tcon, path, "SETFILEBITS", |
294 | ea_value, 4 /* size of buf */, cifs_sb->local_nls, | 303 | ea_value, 4 /* size of buf */, cifs_sb->local_nls, |
295 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 304 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
296 | if(rc < 0) | 305 | if (rc < 0) |
297 | return (int)rc; | 306 | return (int)rc; |
298 | else if (rc > 3) { | 307 | else if (rc > 3) { |
299 | mode = le32_to_cpu(*((__le32 *)ea_value)); | 308 | mode = le32_to_cpu(*((__le32 *)ea_value)); |
@@ -348,7 +357,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
348 | /* BB optimize code so we do not make the above call | 357 | /* BB optimize code so we do not make the above call |
349 | when server claims no NT SMB support and the above call | 358 | when server claims no NT SMB support and the above call |
350 | failed at least once - set flag in tcon or mount */ | 359 | failed at least once - set flag in tcon or mount */ |
351 | if((rc == -EOPNOTSUPP) || (rc == -EINVAL)) { | 360 | if ((rc == -EOPNOTSUPP) || (rc == -EINVAL)) { |
352 | rc = SMBQueryInformation(xid, pTcon, search_path, | 361 | rc = SMBQueryInformation(xid, pTcon, search_path, |
353 | pfindData, cifs_sb->local_nls, | 362 | pfindData, cifs_sb->local_nls, |
354 | cifs_sb->mnt_cifs_flags & | 363 | cifs_sb->mnt_cifs_flags & |
@@ -425,7 +434,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
425 | } else /* do we need cast or hash to ino? */ | 434 | } else /* do we need cast or hash to ino? */ |
426 | (*pinode)->i_ino = inode_num; | 435 | (*pinode)->i_ino = inode_num; |
427 | } /* else ino incremented to unique num in new_inode*/ | 436 | } /* else ino incremented to unique num in new_inode*/ |
428 | if(sb->s_flags & MS_NOATIME) | 437 | if (sb->s_flags & MS_NOATIME) |
429 | (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; | 438 | (*pinode)->i_flags |= S_NOATIME | S_NOCMTIME; |
430 | insert_inode_hash(*pinode); | 439 | insert_inode_hash(*pinode); |
431 | } | 440 | } |
@@ -442,7 +451,7 @@ int cifs_get_inode_info(struct inode **pinode, | |||
442 | (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/ | 451 | (pTcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE) & 0xFFFFFE00;*/ |
443 | 452 | ||
444 | /* Linux can not store file creation time so ignore it */ | 453 | /* Linux can not store file creation time so ignore it */ |
445 | if(pfindData->LastAccessTime) | 454 | if (pfindData->LastAccessTime) |
446 | inode->i_atime = cifs_NTtimeToUnix | 455 | inode->i_atime = cifs_NTtimeToUnix |
447 | (le64_to_cpu(pfindData->LastAccessTime)); | 456 | (le64_to_cpu(pfindData->LastAccessTime)); |
448 | else /* do not need to use current_fs_time - time not stored */ | 457 | 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 | inode->i_ctime = | 461 | inode->i_ctime = |
453 | cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); | 462 | cifs_NTtimeToUnix(le64_to_cpu(pfindData->ChangeTime)); |
454 | cFYI(0, ("Attributes came in as 0x%x", attr)); | 463 | cFYI(0, ("Attributes came in as 0x%x", attr)); |
455 | if(adjustTZ && (pTcon->ses) && (pTcon->ses->server)) { | 464 | if (adjustTZ && (pTcon->ses) && (pTcon->ses->server)) { |
456 | inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj; | 465 | inode->i_ctime.tv_sec += pTcon->ses->server->timeAdj; |
457 | inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj; | 466 | inode->i_mtime.tv_sec += pTcon->ses->server->timeAdj; |
458 | } | 467 | } |
@@ -521,8 +530,10 @@ int cifs_get_inode_info(struct inode **pinode, | |||
521 | 530 | ||
522 | /* BB fill in uid and gid here? with help from winbind? | 531 | /* BB fill in uid and gid here? with help from winbind? |
523 | or retrieve from NTFS stream extended attribute */ | 532 | or retrieve from NTFS stream extended attribute */ |
524 | if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { | 533 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { |
525 | /* fill in uid, gid, mode from server ACL */ | 534 | /* fill in uid, gid, mode from server ACL */ |
535 | /* BB FIXME this should also take into account the | ||
536 | * default uid specified on mount if present */ | ||
526 | get_sfu_uid_mode(inode, search_path, cifs_sb, xid); | 537 | get_sfu_uid_mode(inode, search_path, cifs_sb, xid); |
527 | } else if (atomic_read(&cifsInfo->inUse) == 0) { | 538 | } else if (atomic_read(&cifsInfo->inUse) == 0) { |
528 | inode->i_uid = cifs_sb->mnt_uid; | 539 | inode->i_uid = cifs_sb->mnt_uid; |
@@ -541,12 +552,12 @@ int cifs_get_inode_info(struct inode **pinode, | |||
541 | &cifs_file_direct_nobrl_ops; | 552 | &cifs_file_direct_nobrl_ops; |
542 | else | 553 | else |
543 | inode->i_fop = &cifs_file_direct_ops; | 554 | inode->i_fop = &cifs_file_direct_ops; |
544 | } else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 555 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
545 | inode->i_fop = &cifs_file_nobrl_ops; | 556 | inode->i_fop = &cifs_file_nobrl_ops; |
546 | else /* not direct, send byte range locks */ | 557 | else /* not direct, send byte range locks */ |
547 | inode->i_fop = &cifs_file_ops; | 558 | inode->i_fop = &cifs_file_ops; |
548 | 559 | ||
549 | if(pTcon->ses->server->maxBuf < | 560 | if (pTcon->ses->server->maxBuf < |
550 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) | 561 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE) |
551 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | 562 | inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
552 | else | 563 | else |
@@ -597,7 +608,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
597 | 608 | ||
598 | xid = GetXid(); | 609 | xid = GetXid(); |
599 | 610 | ||
600 | if(inode) | 611 | if (inode) |
601 | cifs_sb = CIFS_SB(inode->i_sb); | 612 | cifs_sb = CIFS_SB(inode->i_sb); |
602 | else | 613 | else |
603 | cifs_sb = CIFS_SB(direntry->d_sb); | 614 | cifs_sb = CIFS_SB(direntry->d_sb); |
@@ -723,7 +734,7 @@ int cifs_unlink(struct inode *inode, struct dentry *direntry) | |||
723 | when needed */ | 734 | when needed */ |
724 | direntry->d_inode->i_ctime = current_fs_time(inode->i_sb); | 735 | direntry->d_inode->i_ctime = current_fs_time(inode->i_sb); |
725 | } | 736 | } |
726 | if(inode) { | 737 | if (inode) { |
727 | inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb); | 738 | inode->i_ctime = inode->i_mtime = current_fs_time(inode->i_sb); |
728 | cifsInode = CIFS_I(inode); | 739 | cifsInode = CIFS_I(inode); |
729 | cifsInode->time = 0; /* force revalidate of dir as well */ | 740 | cifsInode->time = 0; /* force revalidate of dir as well */ |
diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index b80b0fc1c4c4..b5364f90d551 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c | |||
@@ -37,19 +37,19 @@ static void dump_cifs_file_struct(struct file *file, char *label) | |||
37 | { | 37 | { |
38 | struct cifsFileInfo * cf; | 38 | struct cifsFileInfo * cf; |
39 | 39 | ||
40 | if(file) { | 40 | if (file) { |
41 | cf = file->private_data; | 41 | cf = file->private_data; |
42 | if(cf == NULL) { | 42 | if (cf == NULL) { |
43 | cFYI(1,("empty cifs private file data")); | 43 | cFYI(1,("empty cifs private file data")); |
44 | return; | 44 | return; |
45 | } | 45 | } |
46 | if(cf->invalidHandle) { | 46 | if (cf->invalidHandle) { |
47 | cFYI(1,("invalid handle")); | 47 | cFYI(1,("invalid handle")); |
48 | } | 48 | } |
49 | if(cf->srch_inf.endOfSearch) { | 49 | if (cf->srch_inf.endOfSearch) { |
50 | cFYI(1,("end of search")); | 50 | cFYI(1,("end of search")); |
51 | } | 51 | } |
52 | if(cf->srch_inf.emptyDir) { | 52 | if (cf->srch_inf.emptyDir) { |
53 | cFYI(1,("empty dir")); | 53 | cFYI(1,("empty dir")); |
54 | } | 54 | } |
55 | 55 | ||
@@ -77,17 +77,17 @@ static int construct_dentry(struct qstr *qstring, struct file *file, | |||
77 | cFYI(0, ("existing dentry with inode 0x%p", tmp_dentry->d_inode)); | 77 | cFYI(0, ("existing dentry with inode 0x%p", tmp_dentry->d_inode)); |
78 | *ptmp_inode = tmp_dentry->d_inode; | 78 | *ptmp_inode = tmp_dentry->d_inode; |
79 | /* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/ | 79 | /* BB overwrite old name? i.e. tmp_dentry->d_name and tmp_dentry->d_name.len??*/ |
80 | if(*ptmp_inode == NULL) { | 80 | if (*ptmp_inode == NULL) { |
81 | *ptmp_inode = new_inode(file->f_path.dentry->d_sb); | 81 | *ptmp_inode = new_inode(file->f_path.dentry->d_sb); |
82 | if(*ptmp_inode == NULL) | 82 | if (*ptmp_inode == NULL) |
83 | return rc; | 83 | return rc; |
84 | rc = 1; | 84 | rc = 1; |
85 | } | 85 | } |
86 | if(file->f_path.dentry->d_sb->s_flags & MS_NOATIME) | 86 | if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME) |
87 | (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME; | 87 | (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME; |
88 | } else { | 88 | } else { |
89 | tmp_dentry = d_alloc(file->f_path.dentry, qstring); | 89 | tmp_dentry = d_alloc(file->f_path.dentry, qstring); |
90 | if(tmp_dentry == NULL) { | 90 | if (tmp_dentry == NULL) { |
91 | cERROR(1,("Failed allocating dentry")); | 91 | cERROR(1,("Failed allocating dentry")); |
92 | *ptmp_inode = NULL; | 92 | *ptmp_inode = NULL; |
93 | return rc; | 93 | return rc; |
@@ -98,9 +98,9 @@ static int construct_dentry(struct qstr *qstring, struct file *file, | |||
98 | tmp_dentry->d_op = &cifs_ci_dentry_ops; | 98 | tmp_dentry->d_op = &cifs_ci_dentry_ops; |
99 | else | 99 | else |
100 | tmp_dentry->d_op = &cifs_dentry_ops; | 100 | tmp_dentry->d_op = &cifs_dentry_ops; |
101 | if(*ptmp_inode == NULL) | 101 | if (*ptmp_inode == NULL) |
102 | return rc; | 102 | return rc; |
103 | if(file->f_path.dentry->d_sb->s_flags & MS_NOATIME) | 103 | if (file->f_path.dentry->d_sb->s_flags & MS_NOATIME) |
104 | (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME; | 104 | (*ptmp_inode)->i_flags |= S_NOATIME | S_NOCMTIME; |
105 | rc = 2; | 105 | rc = 2; |
106 | } | 106 | } |
@@ -112,7 +112,7 @@ static int construct_dentry(struct qstr *qstring, struct file *file, | |||
112 | 112 | ||
113 | static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode) | 113 | static void AdjustForTZ(struct cifsTconInfo * tcon, struct inode * inode) |
114 | { | 114 | { |
115 | if((tcon) && (tcon->ses) && (tcon->ses->server)) { | 115 | if ((tcon) && (tcon->ses) && (tcon->ses->server)) { |
116 | inode->i_ctime.tv_sec += tcon->ses->server->timeAdj; | 116 | inode->i_ctime.tv_sec += tcon->ses->server->timeAdj; |
117 | inode->i_mtime.tv_sec += tcon->ses->server->timeAdj; | 117 | inode->i_mtime.tv_sec += tcon->ses->server->timeAdj; |
118 | inode->i_atime.tv_sec += tcon->ses->server->timeAdj; | 118 | 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 | local_mtime = tmp_inode->i_mtime; | 137 | local_mtime = tmp_inode->i_mtime; |
138 | local_size = tmp_inode->i_size; | 138 | local_size = tmp_inode->i_size; |
139 | 139 | ||
140 | if(new_buf_type) { | 140 | if (new_buf_type) { |
141 | FILE_DIRECTORY_INFO *pfindData = (FILE_DIRECTORY_INFO *)buf; | 141 | FILE_DIRECTORY_INFO *pfindData = (FILE_DIRECTORY_INFO *)buf; |
142 | 142 | ||
143 | attr = le32_to_cpu(pfindData->ExtFileAttributes); | 143 | attr = le32_to_cpu(pfindData->ExtFileAttributes); |
@@ -193,7 +193,7 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, | |||
193 | if (attr & ATTR_DIRECTORY) { | 193 | if (attr & ATTR_DIRECTORY) { |
194 | *pobject_type = DT_DIR; | 194 | *pobject_type = DT_DIR; |
195 | /* override default perms since we do not lock dirs */ | 195 | /* override default perms since we do not lock dirs */ |
196 | if(atomic_read(&cifsInfo->inUse) == 0) { | 196 | if (atomic_read(&cifsInfo->inUse) == 0) { |
197 | tmp_inode->i_mode = cifs_sb->mnt_dir_mode; | 197 | tmp_inode->i_mode = cifs_sb->mnt_dir_mode; |
198 | } | 198 | } |
199 | tmp_inode->i_mode |= S_IFDIR; | 199 | tmp_inode->i_mode |= S_IFDIR; |
@@ -250,25 +250,25 @@ static void fill_in_inode(struct inode *tmp_inode, int new_buf_type, | |||
250 | if (S_ISREG(tmp_inode->i_mode)) { | 250 | if (S_ISREG(tmp_inode->i_mode)) { |
251 | cFYI(1, ("File inode")); | 251 | cFYI(1, ("File inode")); |
252 | tmp_inode->i_op = &cifs_file_inode_ops; | 252 | tmp_inode->i_op = &cifs_file_inode_ops; |
253 | if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { | 253 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { |
254 | if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 254 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
255 | tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; | 255 | tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; |
256 | else | 256 | else |
257 | tmp_inode->i_fop = &cifs_file_direct_ops; | 257 | tmp_inode->i_fop = &cifs_file_direct_ops; |
258 | 258 | ||
259 | } else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 259 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
260 | tmp_inode->i_fop = &cifs_file_nobrl_ops; | 260 | tmp_inode->i_fop = &cifs_file_nobrl_ops; |
261 | else | 261 | else |
262 | tmp_inode->i_fop = &cifs_file_ops; | 262 | tmp_inode->i_fop = &cifs_file_ops; |
263 | 263 | ||
264 | if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && | 264 | if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) && |
265 | (cifs_sb->tcon->ses->server->maxBuf < | 265 | (cifs_sb->tcon->ses->server->maxBuf < |
266 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) | 266 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) |
267 | tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | 267 | tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
268 | else | 268 | else |
269 | tmp_inode->i_data.a_ops = &cifs_addr_ops; | 269 | tmp_inode->i_data.a_ops = &cifs_addr_ops; |
270 | 270 | ||
271 | if(isNewInode) | 271 | if (isNewInode) |
272 | return; /* No sense invalidating pages for new inode | 272 | return; /* No sense invalidating pages for new inode |
273 | since have not started caching readahead file | 273 | since have not started caching readahead file |
274 | data yet */ | 274 | data yet */ |
@@ -357,8 +357,14 @@ static void unix_fill_in_inode(struct inode *tmp_inode, | |||
357 | cFYI(1,("unknown inode type %d",type)); | 357 | cFYI(1,("unknown inode type %d",type)); |
358 | } | 358 | } |
359 | 359 | ||
360 | tmp_inode->i_uid = le64_to_cpu(pfindData->Uid); | 360 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) |
361 | tmp_inode->i_gid = le64_to_cpu(pfindData->Gid); | 361 | tmp_inode->i_uid = cifs_sb->mnt_uid; |
362 | else | ||
363 | tmp_inode->i_uid = le64_to_cpu(pfindData->Uid); | ||
364 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) | ||
365 | tmp_inode->i_gid = cifs_sb->mnt_gid; | ||
366 | else | ||
367 | tmp_inode->i_gid = le64_to_cpu(pfindData->Gid); | ||
362 | tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks); | 368 | tmp_inode->i_nlink = le64_to_cpu(pfindData->Nlinks); |
363 | 369 | ||
364 | spin_lock(&tmp_inode->i_lock); | 370 | spin_lock(&tmp_inode->i_lock); |
@@ -377,25 +383,24 @@ static void unix_fill_in_inode(struct inode *tmp_inode, | |||
377 | cFYI(1, ("File inode")); | 383 | cFYI(1, ("File inode")); |
378 | tmp_inode->i_op = &cifs_file_inode_ops; | 384 | tmp_inode->i_op = &cifs_file_inode_ops; |
379 | 385 | ||
380 | if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { | 386 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { |
381 | if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | 387 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) |
382 | tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; | 388 | tmp_inode->i_fop = &cifs_file_direct_nobrl_ops; |
383 | else | 389 | else |
384 | tmp_inode->i_fop = &cifs_file_direct_ops; | 390 | tmp_inode->i_fop = &cifs_file_direct_ops; |
385 | 391 | } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | |
386 | } else if(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) | ||
387 | tmp_inode->i_fop = &cifs_file_nobrl_ops; | 392 | tmp_inode->i_fop = &cifs_file_nobrl_ops; |
388 | else | 393 | else |
389 | tmp_inode->i_fop = &cifs_file_ops; | 394 | tmp_inode->i_fop = &cifs_file_ops; |
390 | 395 | ||
391 | if((cifs_sb->tcon) && (cifs_sb->tcon->ses) && | 396 | if ((cifs_sb->tcon) && (cifs_sb->tcon->ses) && |
392 | (cifs_sb->tcon->ses->server->maxBuf < | 397 | (cifs_sb->tcon->ses->server->maxBuf < |
393 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) | 398 | PAGE_CACHE_SIZE + MAX_CIFS_HDR_SIZE)) |
394 | tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; | 399 | tmp_inode->i_data.a_ops = &cifs_addr_ops_smallbuf; |
395 | else | 400 | else |
396 | tmp_inode->i_data.a_ops = &cifs_addr_ops; | 401 | tmp_inode->i_data.a_ops = &cifs_addr_ops; |
397 | 402 | ||
398 | if(isNewInode) | 403 | if (isNewInode) |
399 | return; /* No sense invalidating pages for new inode since we | 404 | return; /* No sense invalidating pages for new inode since we |
400 | have not started caching readahead file data yet */ | 405 | have not started caching readahead file data yet */ |
401 | 406 | ||
@@ -430,28 +435,28 @@ static int initiate_cifs_search(const int xid, struct file *file) | |||
430 | struct cifs_sb_info *cifs_sb; | 435 | struct cifs_sb_info *cifs_sb; |
431 | struct cifsTconInfo *pTcon; | 436 | struct cifsTconInfo *pTcon; |
432 | 437 | ||
433 | if(file->private_data == NULL) { | 438 | if (file->private_data == NULL) { |
434 | file->private_data = | 439 | file->private_data = |
435 | kzalloc(sizeof(struct cifsFileInfo),GFP_KERNEL); | 440 | kzalloc(sizeof(struct cifsFileInfo),GFP_KERNEL); |
436 | } | 441 | } |
437 | 442 | ||
438 | if(file->private_data == NULL) | 443 | if (file->private_data == NULL) |
439 | return -ENOMEM; | 444 | return -ENOMEM; |
440 | cifsFile = file->private_data; | 445 | cifsFile = file->private_data; |
441 | cifsFile->invalidHandle = TRUE; | 446 | cifsFile->invalidHandle = TRUE; |
442 | cifsFile->srch_inf.endOfSearch = FALSE; | 447 | cifsFile->srch_inf.endOfSearch = FALSE; |
443 | 448 | ||
444 | cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); | 449 | cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); |
445 | if(cifs_sb == NULL) | 450 | if (cifs_sb == NULL) |
446 | return -EINVAL; | 451 | return -EINVAL; |
447 | 452 | ||
448 | pTcon = cifs_sb->tcon; | 453 | pTcon = cifs_sb->tcon; |
449 | if(pTcon == NULL) | 454 | if (pTcon == NULL) |
450 | return -EINVAL; | 455 | return -EINVAL; |
451 | 456 | ||
452 | full_path = build_path_from_dentry(file->f_path.dentry); | 457 | full_path = build_path_from_dentry(file->f_path.dentry); |
453 | 458 | ||
454 | if(full_path == NULL) { | 459 | if (full_path == NULL) { |
455 | return -ENOMEM; | 460 | return -ENOMEM; |
456 | } | 461 | } |
457 | 462 | ||
@@ -474,9 +479,9 @@ ffirst_retry: | |||
474 | &cifsFile->netfid, &cifsFile->srch_inf, | 479 | &cifsFile->netfid, &cifsFile->srch_inf, |
475 | cifs_sb->mnt_cifs_flags & | 480 | cifs_sb->mnt_cifs_flags & |
476 | CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb)); | 481 | CIFS_MOUNT_MAP_SPECIAL_CHR, CIFS_DIR_SEP(cifs_sb)); |
477 | if(rc == 0) | 482 | if (rc == 0) |
478 | cifsFile->invalidHandle = FALSE; | 483 | cifsFile->invalidHandle = FALSE; |
479 | if((rc == -EOPNOTSUPP) && | 484 | if ((rc == -EOPNOTSUPP) && |
480 | (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { | 485 | (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { |
481 | cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; | 486 | cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; |
482 | goto ffirst_retry; | 487 | goto ffirst_retry; |
@@ -492,7 +497,7 @@ static int cifs_unicode_bytelen(char *str) | |||
492 | __le16 * ustr = (__le16 *)str; | 497 | __le16 * ustr = (__le16 *)str; |
493 | 498 | ||
494 | for(len=0;len <= PATH_MAX;len++) { | 499 | for(len=0;len <= PATH_MAX;len++) { |
495 | if(ustr[len] == 0) | 500 | if (ustr[len] == 0) |
496 | return len << 1; | 501 | return len << 1; |
497 | } | 502 | } |
498 | cFYI(1,("Unicode string longer than PATH_MAX found")); | 503 | 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 | char * new_entry; | 509 | char * new_entry; |
505 | FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry; | 510 | FILE_DIRECTORY_INFO * pDirInfo = (FILE_DIRECTORY_INFO *)old_entry; |
506 | 511 | ||
507 | if(level == SMB_FIND_FILE_INFO_STANDARD) { | 512 | if (level == SMB_FIND_FILE_INFO_STANDARD) { |
508 | FIND_FILE_STANDARD_INFO * pfData; | 513 | FIND_FILE_STANDARD_INFO * pfData; |
509 | pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo; | 514 | pfData = (FIND_FILE_STANDARD_INFO *)pDirInfo; |
510 | 515 | ||
@@ -514,12 +519,12 @@ static char *nxt_dir_entry(char *old_entry, char *end_of_smb, int level) | |||
514 | new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset); | 519 | new_entry = old_entry + le32_to_cpu(pDirInfo->NextEntryOffset); |
515 | cFYI(1,("new entry %p old entry %p",new_entry,old_entry)); | 520 | cFYI(1,("new entry %p old entry %p",new_entry,old_entry)); |
516 | /* validate that new_entry is not past end of SMB */ | 521 | /* validate that new_entry is not past end of SMB */ |
517 | if(new_entry >= end_of_smb) { | 522 | if (new_entry >= end_of_smb) { |
518 | cERROR(1, | 523 | cERROR(1, |
519 | ("search entry %p began after end of SMB %p old entry %p", | 524 | ("search entry %p began after end of SMB %p old entry %p", |
520 | new_entry, end_of_smb, old_entry)); | 525 | new_entry, end_of_smb, old_entry)); |
521 | return NULL; | 526 | return NULL; |
522 | } else if(((level == SMB_FIND_FILE_INFO_STANDARD) && | 527 | } else if (((level == SMB_FIND_FILE_INFO_STANDARD) && |
523 | (new_entry + sizeof(FIND_FILE_STANDARD_INFO) > end_of_smb)) || | 528 | (new_entry + sizeof(FIND_FILE_STANDARD_INFO) > end_of_smb)) || |
524 | ((level != SMB_FIND_FILE_INFO_STANDARD) && | 529 | ((level != SMB_FIND_FILE_INFO_STANDARD) && |
525 | (new_entry + sizeof(FILE_DIRECTORY_INFO) > end_of_smb))) { | 530 | (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 | char * filename = NULL; | 545 | char * filename = NULL; |
541 | int len = 0; | 546 | int len = 0; |
542 | 547 | ||
543 | if(cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) { | 548 | if (cfile->srch_inf.info_level == SMB_FIND_FILE_UNIX) { |
544 | FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; | 549 | FILE_UNIX_INFO * pFindData = (FILE_UNIX_INFO *)current_entry; |
545 | filename = &pFindData->FileName[0]; | 550 | filename = &pFindData->FileName[0]; |
546 | if(cfile->srch_inf.unicode) { | 551 | if (cfile->srch_inf.unicode) { |
547 | len = cifs_unicode_bytelen(filename); | 552 | len = cifs_unicode_bytelen(filename); |
548 | } else { | 553 | } else { |
549 | /* BB should we make this strnlen of PATH_MAX? */ | 554 | /* BB should we make this strnlen of PATH_MAX? */ |
550 | len = strnlen(filename, 5); | 555 | len = strnlen(filename, 5); |
551 | } | 556 | } |
552 | } else if(cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) { | 557 | } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_DIRECTORY_INFO) { |
553 | FILE_DIRECTORY_INFO * pFindData = | 558 | FILE_DIRECTORY_INFO * pFindData = |
554 | (FILE_DIRECTORY_INFO *)current_entry; | 559 | (FILE_DIRECTORY_INFO *)current_entry; |
555 | filename = &pFindData->FileName[0]; | 560 | filename = &pFindData->FileName[0]; |
556 | len = le32_to_cpu(pFindData->FileNameLength); | 561 | len = le32_to_cpu(pFindData->FileNameLength); |
557 | } else if(cfile->srch_inf.info_level == | 562 | } else if (cfile->srch_inf.info_level == |
558 | SMB_FIND_FILE_FULL_DIRECTORY_INFO) { | 563 | SMB_FIND_FILE_FULL_DIRECTORY_INFO) { |
559 | FILE_FULL_DIRECTORY_INFO * pFindData = | 564 | FILE_FULL_DIRECTORY_INFO * pFindData = |
560 | (FILE_FULL_DIRECTORY_INFO *)current_entry; | 565 | (FILE_FULL_DIRECTORY_INFO *)current_entry; |
561 | filename = &pFindData->FileName[0]; | 566 | filename = &pFindData->FileName[0]; |
562 | len = le32_to_cpu(pFindData->FileNameLength); | 567 | len = le32_to_cpu(pFindData->FileNameLength); |
563 | } else if(cfile->srch_inf.info_level == | 568 | } else if (cfile->srch_inf.info_level == |
564 | SMB_FIND_FILE_ID_FULL_DIR_INFO) { | 569 | SMB_FIND_FILE_ID_FULL_DIR_INFO) { |
565 | SEARCH_ID_FULL_DIR_INFO * pFindData = | 570 | SEARCH_ID_FULL_DIR_INFO * pFindData = |
566 | (SEARCH_ID_FULL_DIR_INFO *)current_entry; | 571 | (SEARCH_ID_FULL_DIR_INFO *)current_entry; |
567 | filename = &pFindData->FileName[0]; | 572 | filename = &pFindData->FileName[0]; |
568 | len = le32_to_cpu(pFindData->FileNameLength); | 573 | len = le32_to_cpu(pFindData->FileNameLength); |
569 | } else if(cfile->srch_inf.info_level == | 574 | } else if (cfile->srch_inf.info_level == |
570 | SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { | 575 | SMB_FIND_FILE_BOTH_DIRECTORY_INFO) { |
571 | FILE_BOTH_DIRECTORY_INFO * pFindData = | 576 | FILE_BOTH_DIRECTORY_INFO * pFindData = |
572 | (FILE_BOTH_DIRECTORY_INFO *)current_entry; | 577 | (FILE_BOTH_DIRECTORY_INFO *)current_entry; |
573 | filename = &pFindData->FileName[0]; | 578 | filename = &pFindData->FileName[0]; |
574 | len = le32_to_cpu(pFindData->FileNameLength); | 579 | len = le32_to_cpu(pFindData->FileNameLength); |
575 | } else if(cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) { | 580 | } else if (cfile->srch_inf.info_level == SMB_FIND_FILE_INFO_STANDARD) { |
576 | FIND_FILE_STANDARD_INFO * pFindData = | 581 | FIND_FILE_STANDARD_INFO * pFindData = |
577 | (FIND_FILE_STANDARD_INFO *)current_entry; | 582 | (FIND_FILE_STANDARD_INFO *)current_entry; |
578 | filename = &pFindData->FileName[0]; | 583 | filename = &pFindData->FileName[0]; |
@@ -581,25 +586,25 @@ static int cifs_entry_is_dot(char *current_entry, struct cifsFileInfo *cfile) | |||
581 | cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level)); | 586 | cFYI(1,("Unknown findfirst level %d",cfile->srch_inf.info_level)); |
582 | } | 587 | } |
583 | 588 | ||
584 | if(filename) { | 589 | if (filename) { |
585 | if(cfile->srch_inf.unicode) { | 590 | if (cfile->srch_inf.unicode) { |
586 | __le16 *ufilename = (__le16 *)filename; | 591 | __le16 *ufilename = (__le16 *)filename; |
587 | if(len == 2) { | 592 | if (len == 2) { |
588 | /* check for . */ | 593 | /* check for . */ |
589 | if(ufilename[0] == UNICODE_DOT) | 594 | if (ufilename[0] == UNICODE_DOT) |
590 | rc = 1; | 595 | rc = 1; |
591 | } else if(len == 4) { | 596 | } else if (len == 4) { |
592 | /* check for .. */ | 597 | /* check for .. */ |
593 | if((ufilename[0] == UNICODE_DOT) | 598 | if ((ufilename[0] == UNICODE_DOT) |
594 | &&(ufilename[1] == UNICODE_DOT)) | 599 | &&(ufilename[1] == UNICODE_DOT)) |
595 | rc = 2; | 600 | rc = 2; |
596 | } | 601 | } |
597 | } else /* ASCII */ { | 602 | } else /* ASCII */ { |
598 | if(len == 1) { | 603 | if (len == 1) { |
599 | if(filename[0] == '.') | 604 | if (filename[0] == '.') |
600 | rc = 1; | 605 | rc = 1; |
601 | } else if(len == 2) { | 606 | } else if (len == 2) { |
602 | if((filename[0] == '.') && (filename[1] == '.')) | 607 | if((filename[0] == '.') && (filename[1] == '.')) |
603 | rc = 2; | 608 | rc = 2; |
604 | } | 609 | } |
605 | } | 610 | } |
@@ -638,7 +643,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, | |||
638 | struct cifsFileInfo * cifsFile = file->private_data; | 643 | struct cifsFileInfo * cifsFile = file->private_data; |
639 | /* check if index in the buffer */ | 644 | /* check if index in the buffer */ |
640 | 645 | ||
641 | if((cifsFile == NULL) || (ppCurrentEntry == NULL) || | 646 | if ((cifsFile == NULL) || (ppCurrentEntry == NULL) || |
642 | (num_to_ret == NULL)) | 647 | (num_to_ret == NULL)) |
643 | return -ENOENT; | 648 | return -ENOENT; |
644 | 649 | ||
@@ -656,7 +661,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, | |||
656 | #ifdef CONFIG_CIFS_DEBUG2 | 661 | #ifdef CONFIG_CIFS_DEBUG2 |
657 | dump_cifs_file_struct(file, "In fce "); | 662 | dump_cifs_file_struct(file, "In fce "); |
658 | #endif | 663 | #endif |
659 | if(((index_to_find < cifsFile->srch_inf.index_of_last_entry) && | 664 | if (((index_to_find < cifsFile->srch_inf.index_of_last_entry) && |
660 | is_dir_changed(file)) || | 665 | is_dir_changed(file)) || |
661 | (index_to_find < first_entry_in_buffer)) { | 666 | (index_to_find < first_entry_in_buffer)) { |
662 | /* close and restart search */ | 667 | /* close and restart search */ |
@@ -665,9 +670,9 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, | |||
665 | CIFSFindClose(xid, pTcon, cifsFile->netfid); | 670 | CIFSFindClose(xid, pTcon, cifsFile->netfid); |
666 | kfree(cifsFile->search_resume_name); | 671 | kfree(cifsFile->search_resume_name); |
667 | cifsFile->search_resume_name = NULL; | 672 | cifsFile->search_resume_name = NULL; |
668 | if(cifsFile->srch_inf.ntwrk_buf_start) { | 673 | if (cifsFile->srch_inf.ntwrk_buf_start) { |
669 | cFYI(1,("freeing SMB ff cache buf on search rewind")); | 674 | cFYI(1,("freeing SMB ff cache buf on search rewind")); |
670 | if(cifsFile->srch_inf.smallBuf) | 675 | if (cifsFile->srch_inf.smallBuf) |
671 | cifs_small_buf_release(cifsFile->srch_inf. | 676 | cifs_small_buf_release(cifsFile->srch_inf. |
672 | ntwrk_buf_start); | 677 | ntwrk_buf_start); |
673 | else | 678 | else |
@@ -675,7 +680,7 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, | |||
675 | ntwrk_buf_start); | 680 | ntwrk_buf_start); |
676 | } | 681 | } |
677 | rc = initiate_cifs_search(xid,file); | 682 | rc = initiate_cifs_search(xid,file); |
678 | if(rc) { | 683 | if (rc) { |
679 | cFYI(1,("error %d reinitiating a search on rewind",rc)); | 684 | cFYI(1,("error %d reinitiating a search on rewind",rc)); |
680 | return rc; | 685 | return rc; |
681 | } | 686 | } |
@@ -686,10 +691,10 @@ static int find_cifs_entry(const int xid, struct cifsTconInfo *pTcon, | |||
686 | cFYI(1,("calling findnext2")); | 691 | cFYI(1,("calling findnext2")); |
687 | rc = CIFSFindNext(xid,pTcon,cifsFile->netfid, | 692 | rc = CIFSFindNext(xid,pTcon,cifsFile->netfid, |
688 | &cifsFile->srch_inf); | 693 | &cifsFile->srch_inf); |
689 | if(rc) | 694 | if (rc) |
690 | return -ENOENT; | 695 | return -ENOENT; |
691 | } | 696 | } |
692 | if(index_to_find < cifsFile->srch_inf.index_of_last_entry) { | 697 | if (index_to_find < cifsFile->srch_inf.index_of_last_entry) { |
693 | /* we found the buffer that contains the entry */ | 698 | /* we found the buffer that contains the entry */ |
694 | /* scan and find it */ | 699 | /* scan and find it */ |
695 | int i; | 700 | int i; |