aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/file.c
diff options
context:
space:
mode:
authorPavel Shilovsky <pshilovsky@samba.org>2012-07-13 05:58:14 -0400
committerSteve French <smfrench@gmail.com>2012-07-24 15:12:03 -0400
commit29e20f9c65fae245d6fd4fce31cc5d01cde3d93f (patch)
tree3e8410588672f7f0947c4c9bffd2455f855d0b02 /fs/cifs/file.c
parentd60622eb5a23904facf4a4efac60f5bfa810d7d4 (diff)
CIFS: Make CAP_* checks protocol independent
Since both CIFS and SMB2 use ses->capabilities (server->capabilities) field but flags are different we should make such checks protocol independent. Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Pavel Shilovsky <pshilovsky@samba.org> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/file.c')
-rw-r--r--fs/cifs/file.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 93b3b1358409..07e9d41cade7 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -385,9 +385,8 @@ int cifs_open(struct inode *inode, struct file *file)
385 oplock = 0; 385 oplock = 0;
386 386
387 if (!tcon->broken_posix_open && tcon->unix_ext && 387 if (!tcon->broken_posix_open && tcon->unix_ext &&
388 (tcon->ses->capabilities & CAP_UNIX) && 388 cap_unix(tcon->ses) && (CIFS_UNIX_POSIX_PATH_OPS_CAP &
389 (CIFS_UNIX_POSIX_PATH_OPS_CAP & 389 le64_to_cpu(tcon->fsUnixInfo.Capability))) {
390 le64_to_cpu(tcon->fsUnixInfo.Capability))) {
391 /* can not refresh inode info since size could be stale */ 390 /* can not refresh inode info since size could be stale */
392 rc = cifs_posix_open(full_path, &inode, inode->i_sb, 391 rc = cifs_posix_open(full_path, &inode, inode->i_sb,
393 cifs_sb->mnt_file_mode /* ignored */, 392 cifs_sb->mnt_file_mode /* ignored */,
@@ -509,10 +508,9 @@ static int cifs_reopen_file(struct cifsFileInfo *pCifsFile, bool can_flush)
509 else 508 else
510 oplock = 0; 509 oplock = 0;
511 510
512 if (tcon->unix_ext && (tcon->ses->capabilities & CAP_UNIX) && 511 if (tcon->unix_ext && cap_unix(tcon->ses) &&
513 (CIFS_UNIX_POSIX_PATH_OPS_CAP & 512 (CIFS_UNIX_POSIX_PATH_OPS_CAP &
514 le64_to_cpu(tcon->fsUnixInfo.Capability))) { 513 le64_to_cpu(tcon->fsUnixInfo.Capability))) {
515
516 /* 514 /*
517 * O_CREAT, O_EXCL and O_TRUNC already had their effect on the 515 * O_CREAT, O_EXCL and O_TRUNC already had their effect on the
518 * original open. Must mask them off for a reopen. 516 * original open. Must mask them off for a reopen.
@@ -1071,7 +1069,7 @@ cifs_push_locks(struct cifsFileInfo *cfile)
1071 struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb); 1069 struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb);
1072 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); 1070 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink);
1073 1071
1074 if ((tcon->ses->capabilities & CAP_UNIX) && 1072 if (cap_unix(tcon->ses) &&
1075 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && 1073 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
1076 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) 1074 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
1077 return cifs_push_posix_locks(cfile); 1075 return cifs_push_posix_locks(cfile);
@@ -1419,7 +1417,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock)
1419 netfid = cfile->netfid; 1417 netfid = cfile->netfid;
1420 cinode = CIFS_I(file->f_path.dentry->d_inode); 1418 cinode = CIFS_I(file->f_path.dentry->d_inode);
1421 1419
1422 if ((tcon->ses->capabilities & CAP_UNIX) && 1420 if (cap_unix(tcon->ses) &&
1423 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && 1421 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
1424 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) 1422 ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
1425 posix_lck = true; 1423 posix_lck = true;
@@ -2745,7 +2743,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
2745 unsigned int current_read_size; 2743 unsigned int current_read_size;
2746 unsigned int rsize; 2744 unsigned int rsize;
2747 struct cifs_sb_info *cifs_sb; 2745 struct cifs_sb_info *cifs_sb;
2748 struct cifs_tcon *pTcon; 2746 struct cifs_tcon *tcon;
2749 unsigned int xid; 2747 unsigned int xid;
2750 char *current_offset; 2748 char *current_offset;
2751 struct cifsFileInfo *open_file; 2749 struct cifsFileInfo *open_file;
@@ -2765,7 +2763,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
2765 return rc; 2763 return rc;
2766 } 2764 }
2767 open_file = file->private_data; 2765 open_file = file->private_data;
2768 pTcon = tlink_tcon(open_file->tlink); 2766 tcon = tlink_tcon(open_file->tlink);
2769 2767
2770 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 2768 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
2771 pid = open_file->pid; 2769 pid = open_file->pid;
@@ -2779,11 +2777,12 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
2779 read_size > total_read; 2777 read_size > total_read;
2780 total_read += bytes_read, current_offset += bytes_read) { 2778 total_read += bytes_read, current_offset += bytes_read) {
2781 current_read_size = min_t(uint, read_size - total_read, rsize); 2779 current_read_size = min_t(uint, read_size - total_read, rsize);
2782 2780 /*
2783 /* For windows me and 9x we do not want to request more 2781 * For windows me and 9x we do not want to request more than it
2784 than it negotiated since it will refuse the read then */ 2782 * negotiated since it will refuse the read then.
2785 if ((pTcon->ses) && 2783 */
2786 !(pTcon->ses->capabilities & CAP_LARGE_FILES)) { 2784 if ((tcon->ses) && !(tcon->ses->capabilities &
2785 tcon->ses->server->vals->cap_large_files)) {
2787 current_read_size = min_t(uint, current_read_size, 2786 current_read_size = min_t(uint, current_read_size,
2788 CIFSMaxBufSize); 2787 CIFSMaxBufSize);
2789 } 2788 }
@@ -2796,7 +2795,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
2796 } 2795 }
2797 io_parms.netfid = open_file->netfid; 2796 io_parms.netfid = open_file->netfid;
2798 io_parms.pid = pid; 2797 io_parms.pid = pid;
2799 io_parms.tcon = pTcon; 2798 io_parms.tcon = tcon;
2800 io_parms.offset = *poffset; 2799 io_parms.offset = *poffset;
2801 io_parms.length = current_read_size; 2800 io_parms.length = current_read_size;
2802 rc = CIFSSMBRead(xid, &io_parms, &bytes_read, 2801 rc = CIFSSMBRead(xid, &io_parms, &bytes_read,
@@ -2810,7 +2809,7 @@ static ssize_t cifs_read(struct file *file, char *read_data, size_t read_size,
2810 return rc; 2809 return rc;
2811 } 2810 }
2812 } else { 2811 } else {
2813 cifs_stats_bytes_read(pTcon, total_read); 2812 cifs_stats_bytes_read(tcon, total_read);
2814 *poffset += bytes_read; 2813 *poffset += bytes_read;
2815 } 2814 }
2816 } 2815 }