aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/smb1ops.c
diff options
context:
space:
mode:
authorPavel Shilovsky <piastry@etersoft.ru>2014-01-16 06:53:36 -0500
committerSteve French <smfrench@gmail.com>2014-01-20 10:52:13 -0500
commitd81b8a40e2ece0a9ab57b1fe1798e291e75bf8fc (patch)
treea3fd90c8172375499b2ad8f5f21ba633a3e522b3 /fs/cifs/smb1ops.c
parent0360d605a236355f9501d21175e405536e2acd48 (diff)
CIFS: Cleanup cifs open codepath
Rename CIFSSMBOpen to CIFS_open and make it take cifs_open_parms structure as a parm. Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru> Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs/smb1ops.c')
-rw-r--r--fs/cifs/smb1ops.c71
1 files changed, 43 insertions, 28 deletions
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index abd2cc9515c9..9ac5bfc9cc56 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -560,17 +560,24 @@ cifs_query_path_info(const unsigned int xid, struct cifs_tcon *tcon,
560 if (!rc && (le32_to_cpu(data->Attributes) & ATTR_REPARSE)) { 560 if (!rc && (le32_to_cpu(data->Attributes) & ATTR_REPARSE)) {
561 int tmprc; 561 int tmprc;
562 int oplock = 0; 562 int oplock = 0;
563 __u16 netfid; 563 struct cifs_fid fid;
564 struct cifs_open_parms oparms;
565
566 oparms.tcon = tcon;
567 oparms.cifs_sb = cifs_sb;
568 oparms.desired_access = FILE_READ_ATTRIBUTES;
569 oparms.create_options = 0;
570 oparms.disposition = FILE_OPEN;
571 oparms.path = full_path;
572 oparms.fid = &fid;
573 oparms.reconnect = false;
564 574
565 /* Need to check if this is a symbolic link or not */ 575 /* Need to check if this is a symbolic link or not */
566 tmprc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, 576 tmprc = CIFS_open(xid, &oparms, &oplock, NULL);
567 FILE_READ_ATTRIBUTES, 0, &netfid, &oplock,
568 NULL, cifs_sb->local_nls,
569 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
570 if (tmprc == -EOPNOTSUPP) 577 if (tmprc == -EOPNOTSUPP)
571 *symlink = true; 578 *symlink = true;
572 else 579 else
573 CIFSSMBClose(xid, tcon, netfid); 580 CIFSSMBClose(xid, tcon, fid.netfid);
574 } 581 }
575 582
576 return rc; 583 return rc;
@@ -705,12 +712,7 @@ cifs_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
705 oparms->cifs_sb->local_nls, 712 oparms->cifs_sb->local_nls,
706 oparms->cifs_sb->mnt_cifs_flags 713 oparms->cifs_sb->mnt_cifs_flags
707 & CIFS_MOUNT_MAP_SPECIAL_CHR); 714 & CIFS_MOUNT_MAP_SPECIAL_CHR);
708 return CIFSSMBOpen(xid, oparms->tcon, oparms->path, 715 return CIFS_open(xid, oparms, oplock, buf);
709 oparms->disposition, oparms->desired_access,
710 oparms->create_options, &oparms->fid->netfid, oplock,
711 buf, oparms->cifs_sb->local_nls,
712 oparms->cifs_sb->mnt_cifs_flags &
713 CIFS_MOUNT_MAP_SPECIAL_CHR);
714} 716}
715 717
716static void 718static void
@@ -761,8 +763,9 @@ smb_set_file_info(struct inode *inode, const char *full_path,
761{ 763{
762 int oplock = 0; 764 int oplock = 0;
763 int rc; 765 int rc;
764 __u16 netfid;
765 __u32 netpid; 766 __u32 netpid;
767 struct cifs_fid fid;
768 struct cifs_open_parms oparms;
766 struct cifsFileInfo *open_file; 769 struct cifsFileInfo *open_file;
767 struct cifsInodeInfo *cinode = CIFS_I(inode); 770 struct cifsInodeInfo *cinode = CIFS_I(inode);
768 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 771 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
@@ -772,7 +775,7 @@ smb_set_file_info(struct inode *inode, const char *full_path,
772 /* if the file is already open for write, just use that fileid */ 775 /* if the file is already open for write, just use that fileid */
773 open_file = find_writable_file(cinode, true); 776 open_file = find_writable_file(cinode, true);
774 if (open_file) { 777 if (open_file) {
775 netfid = open_file->fid.netfid; 778 fid.netfid = open_file->fid.netfid;
776 netpid = open_file->pid; 779 netpid = open_file->pid;
777 tcon = tlink_tcon(open_file->tlink); 780 tcon = tlink_tcon(open_file->tlink);
778 goto set_via_filehandle; 781 goto set_via_filehandle;
@@ -796,12 +799,17 @@ smb_set_file_info(struct inode *inode, const char *full_path,
796 goto out; 799 goto out;
797 } 800 }
798 801
799 cifs_dbg(FYI, "calling SetFileInfo since SetPathInfo for times not supported by this server\n"); 802 oparms.tcon = tcon;
800 rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, 803 oparms.cifs_sb = cifs_sb;
801 SYNCHRONIZE | FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR, 804 oparms.desired_access = SYNCHRONIZE | FILE_WRITE_ATTRIBUTES;
802 &netfid, &oplock, NULL, cifs_sb->local_nls, 805 oparms.create_options = CREATE_NOT_DIR;
803 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 806 oparms.disposition = FILE_OPEN;
807 oparms.path = full_path;
808 oparms.fid = &fid;
809 oparms.reconnect = false;
804 810
811 cifs_dbg(FYI, "calling SetFileInfo since SetPathInfo for times not supported by this server\n");
812 rc = CIFS_open(xid, &oparms, &oplock, NULL);
805 if (rc != 0) { 813 if (rc != 0) {
806 if (rc == -EIO) 814 if (rc == -EIO)
807 rc = -EINVAL; 815 rc = -EINVAL;
@@ -811,12 +819,12 @@ smb_set_file_info(struct inode *inode, const char *full_path,
811 netpid = current->tgid; 819 netpid = current->tgid;
812 820
813set_via_filehandle: 821set_via_filehandle:
814 rc = CIFSSMBSetFileInfo(xid, tcon, buf, netfid, netpid); 822 rc = CIFSSMBSetFileInfo(xid, tcon, buf, fid.netfid, netpid);
815 if (!rc) 823 if (!rc)
816 cinode->cifsAttrs = le32_to_cpu(buf->Attributes); 824 cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
817 825
818 if (open_file == NULL) 826 if (open_file == NULL)
819 CIFSSMBClose(xid, tcon, netfid); 827 CIFSSMBClose(xid, tcon, fid.netfid);
820 else 828 else
821 cifsFileInfo_put(open_file); 829 cifsFileInfo_put(open_file);
822out: 830out:
@@ -941,7 +949,8 @@ cifs_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
941{ 949{
942 int rc; 950 int rc;
943 int oplock = 0; 951 int oplock = 0;
944 __u16 netfid; 952 struct cifs_fid fid;
953 struct cifs_open_parms oparms;
945 954
946 cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path); 955 cifs_dbg(FYI, "%s: path: %s\n", __func__, full_path);
947 956
@@ -957,21 +966,27 @@ cifs_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
957 goto out; 966 goto out;
958 } 967 }
959 968
960 rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, 969 oparms.tcon = tcon;
961 FILE_READ_ATTRIBUTES, OPEN_REPARSE_POINT, &netfid, 970 oparms.cifs_sb = cifs_sb;
962 &oplock, NULL, cifs_sb->local_nls, 971 oparms.desired_access = FILE_READ_ATTRIBUTES;
963 cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 972 oparms.create_options = OPEN_REPARSE_POINT;
973 oparms.disposition = FILE_OPEN;
974 oparms.path = full_path;
975 oparms.fid = &fid;
976 oparms.reconnect = false;
977
978 rc = CIFS_open(xid, &oparms, &oplock, NULL);
964 if (rc) 979 if (rc)
965 goto out; 980 goto out;
966 981
967 rc = CIFSSMBQuerySymLink(xid, tcon, netfid, target_path, 982 rc = CIFSSMBQuerySymLink(xid, tcon, fid.netfid, target_path,
968 cifs_sb->local_nls); 983 cifs_sb->local_nls);
969 if (rc) 984 if (rc)
970 goto out_close; 985 goto out_close;
971 986
972 convert_delimiter(*target_path, '/'); 987 convert_delimiter(*target_path, '/');
973out_close: 988out_close:
974 CIFSSMBClose(xid, tcon, netfid); 989 CIFSSMBClose(xid, tcon, fid.netfid);
975out: 990out:
976 if (!rc) 991 if (!rc)
977 cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path); 992 cifs_dbg(FYI, "%s: target path: %s\n", __func__, *target_path);