diff options
author | Pavel Shilovsky <piastry@etersoft.ru> | 2014-01-16 06:53:36 -0500 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2014-01-20 10:52:13 -0500 |
commit | d81b8a40e2ece0a9ab57b1fe1798e291e75bf8fc (patch) | |
tree | a3fd90c8172375499b2ad8f5f21ba633a3e522b3 /fs/cifs | |
parent | 0360d605a236355f9501d21175e405536e2acd48 (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')
-rw-r--r-- | fs/cifs/cifsacl.c | 40 | ||||
-rw-r--r-- | fs/cifs/cifsproto.h | 7 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 16 | ||||
-rw-r--r-- | fs/cifs/dir.c | 21 | ||||
-rw-r--r-- | fs/cifs/file.c | 2 | ||||
-rw-r--r-- | fs/cifs/inode.c | 73 | ||||
-rw-r--r-- | fs/cifs/link.c | 44 | ||||
-rw-r--r-- | fs/cifs/smb1ops.c | 71 |
8 files changed, 174 insertions, 100 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 51f5e0ee7237..8f9b4f710d4a 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
@@ -895,9 +895,10 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, | |||
895 | int oplock = 0; | 895 | int oplock = 0; |
896 | unsigned int xid; | 896 | unsigned int xid; |
897 | int rc, create_options = 0; | 897 | int rc, create_options = 0; |
898 | __u16 fid; | ||
899 | struct cifs_tcon *tcon; | 898 | struct cifs_tcon *tcon; |
900 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); | 899 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); |
900 | struct cifs_fid fid; | ||
901 | struct cifs_open_parms oparms; | ||
901 | 902 | ||
902 | if (IS_ERR(tlink)) | 903 | if (IS_ERR(tlink)) |
903 | return ERR_CAST(tlink); | 904 | return ERR_CAST(tlink); |
@@ -908,12 +909,19 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, | |||
908 | if (backup_cred(cifs_sb)) | 909 | if (backup_cred(cifs_sb)) |
909 | create_options |= CREATE_OPEN_BACKUP_INTENT; | 910 | create_options |= CREATE_OPEN_BACKUP_INTENT; |
910 | 911 | ||
911 | rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, | 912 | oparms.tcon = tcon; |
912 | create_options, &fid, &oplock, NULL, cifs_sb->local_nls, | 913 | oparms.cifs_sb = cifs_sb; |
913 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 914 | oparms.desired_access = READ_CONTROL; |
915 | oparms.create_options = create_options; | ||
916 | oparms.disposition = FILE_OPEN; | ||
917 | oparms.path = path; | ||
918 | oparms.fid = &fid; | ||
919 | oparms.reconnect = false; | ||
920 | |||
921 | rc = CIFS_open(xid, &oparms, &oplock, NULL); | ||
914 | if (!rc) { | 922 | if (!rc) { |
915 | rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen); | 923 | rc = CIFSSMBGetCIFSACL(xid, tcon, fid.netfid, &pntsd, pacllen); |
916 | CIFSSMBClose(xid, tcon, fid); | 924 | CIFSSMBClose(xid, tcon, fid.netfid); |
917 | } | 925 | } |
918 | 926 | ||
919 | cifs_put_tlink(tlink); | 927 | cifs_put_tlink(tlink); |
@@ -950,10 +958,11 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
950 | int oplock = 0; | 958 | int oplock = 0; |
951 | unsigned int xid; | 959 | unsigned int xid; |
952 | int rc, access_flags, create_options = 0; | 960 | int rc, access_flags, create_options = 0; |
953 | __u16 fid; | ||
954 | struct cifs_tcon *tcon; | 961 | struct cifs_tcon *tcon; |
955 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); | 962 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
956 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); | 963 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); |
964 | struct cifs_fid fid; | ||
965 | struct cifs_open_parms oparms; | ||
957 | 966 | ||
958 | if (IS_ERR(tlink)) | 967 | if (IS_ERR(tlink)) |
959 | return PTR_ERR(tlink); | 968 | return PTR_ERR(tlink); |
@@ -969,18 +978,25 @@ int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
969 | else | 978 | else |
970 | access_flags = WRITE_DAC; | 979 | access_flags = WRITE_DAC; |
971 | 980 | ||
972 | rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, access_flags, | 981 | oparms.tcon = tcon; |
973 | create_options, &fid, &oplock, NULL, cifs_sb->local_nls, | 982 | oparms.cifs_sb = cifs_sb; |
974 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 983 | oparms.desired_access = access_flags; |
984 | oparms.create_options = create_options; | ||
985 | oparms.disposition = FILE_OPEN; | ||
986 | oparms.path = path; | ||
987 | oparms.fid = &fid; | ||
988 | oparms.reconnect = false; | ||
989 | |||
990 | rc = CIFS_open(xid, &oparms, &oplock, NULL); | ||
975 | if (rc) { | 991 | if (rc) { |
976 | cifs_dbg(VFS, "Unable to open file to set ACL\n"); | 992 | cifs_dbg(VFS, "Unable to open file to set ACL\n"); |
977 | goto out; | 993 | goto out; |
978 | } | 994 | } |
979 | 995 | ||
980 | rc = CIFSSMBSetCIFSACL(xid, tcon, fid, pnntsd, acllen, aclflag); | 996 | rc = CIFSSMBSetCIFSACL(xid, tcon, fid.netfid, pnntsd, acllen, aclflag); |
981 | cifs_dbg(NOISY, "SetCIFSACL rc = %d\n", rc); | 997 | cifs_dbg(NOISY, "SetCIFSACL rc = %d\n", rc); |
982 | 998 | ||
983 | CIFSSMBClose(xid, tcon, fid); | 999 | CIFSSMBClose(xid, tcon, fid.netfid); |
984 | out: | 1000 | out: |
985 | free_xid(xid); | 1001 | free_xid(xid); |
986 | cifs_put_tlink(tlink); | 1002 | cifs_put_tlink(tlink); |
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 582ae61f45b6..79e6e9a93a8c 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -362,11 +362,8 @@ extern int CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon, | |||
362 | const struct nls_table *nls_codepage); | 362 | const struct nls_table *nls_codepage); |
363 | extern int CIFSSMB_set_compression(const unsigned int xid, | 363 | extern int CIFSSMB_set_compression(const unsigned int xid, |
364 | struct cifs_tcon *tcon, __u16 fid); | 364 | struct cifs_tcon *tcon, __u16 fid); |
365 | extern int CIFSSMBOpen(const unsigned int xid, struct cifs_tcon *tcon, | 365 | extern int CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, |
366 | const char *path, const int disposition, | 366 | int *oplock, FILE_ALL_INFO *buf); |
367 | const int desired_access, const int create_options, | ||
368 | __u16 *netfid, int *oplock, FILE_ALL_INFO *buf, | ||
369 | const struct nls_table *nls, int remap); | ||
370 | extern int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon, | 367 | extern int SMBLegacyOpen(const unsigned int xid, struct cifs_tcon *tcon, |
371 | const char *fileName, const int disposition, | 368 | const char *fileName, const int disposition, |
372 | const int access_flags, const int omode, | 369 | const int access_flags, const int omode, |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 8e1ebc2dc0db..4d881c35eeca 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -1273,10 +1273,8 @@ OldOpenRetry: | |||
1273 | } | 1273 | } |
1274 | 1274 | ||
1275 | int | 1275 | int |
1276 | CIFSSMBOpen(const unsigned int xid, struct cifs_tcon *tcon, | 1276 | CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, int *oplock, |
1277 | const char *path, const int disposition, const int desired_access, | 1277 | FILE_ALL_INFO *buf) |
1278 | const int create_options, __u16 *netfid, int *oplock, | ||
1279 | FILE_ALL_INFO *buf, const struct nls_table *nls, int remap) | ||
1280 | { | 1278 | { |
1281 | int rc = -EACCES; | 1279 | int rc = -EACCES; |
1282 | OPEN_REQ *req = NULL; | 1280 | OPEN_REQ *req = NULL; |
@@ -1284,6 +1282,14 @@ CIFSSMBOpen(const unsigned int xid, struct cifs_tcon *tcon, | |||
1284 | int bytes_returned; | 1282 | int bytes_returned; |
1285 | int name_len; | 1283 | int name_len; |
1286 | __u16 count; | 1284 | __u16 count; |
1285 | struct cifs_sb_info *cifs_sb = oparms->cifs_sb; | ||
1286 | struct cifs_tcon *tcon = oparms->tcon; | ||
1287 | int remap = cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR; | ||
1288 | const struct nls_table *nls = cifs_sb->local_nls; | ||
1289 | int create_options = oparms->create_options; | ||
1290 | int desired_access = oparms->desired_access; | ||
1291 | int disposition = oparms->disposition; | ||
1292 | const char *path = oparms->path; | ||
1287 | 1293 | ||
1288 | openRetry: | 1294 | openRetry: |
1289 | rc = smb_init(SMB_COM_NT_CREATE_ANDX, 24, tcon, (void **)&req, | 1295 | rc = smb_init(SMB_COM_NT_CREATE_ANDX, 24, tcon, (void **)&req, |
@@ -1367,7 +1373,7 @@ openRetry: | |||
1367 | /* 1 byte no need to le_to_cpu */ | 1373 | /* 1 byte no need to le_to_cpu */ |
1368 | *oplock = rsp->OplockLevel; | 1374 | *oplock = rsp->OplockLevel; |
1369 | /* cifs fid stays in le */ | 1375 | /* cifs fid stays in le */ |
1370 | *netfid = rsp->Fid; | 1376 | oparms->fid->netfid = rsp->Fid; |
1371 | 1377 | ||
1372 | /* Let caller know file was created so we can set the mode. */ | 1378 | /* Let caller know file was created so we can set the mode. */ |
1373 | /* Do we care about the CreateAction in any other cases? */ | 1379 | /* Do we care about the CreateAction in any other cases? */ |
diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 0850325c3b44..d3a6796caa5a 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c | |||
@@ -570,7 +570,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, | |||
570 | char *full_path = NULL; | 570 | char *full_path = NULL; |
571 | struct inode *newinode = NULL; | 571 | struct inode *newinode = NULL; |
572 | int oplock = 0; | 572 | int oplock = 0; |
573 | u16 netfid; | 573 | struct cifs_fid fid; |
574 | struct cifs_open_parms oparms; | ||
574 | FILE_ALL_INFO *buf = NULL; | 575 | FILE_ALL_INFO *buf = NULL; |
575 | unsigned int bytes_written; | 576 | unsigned int bytes_written; |
576 | struct win_dev *pdev; | 577 | struct win_dev *pdev; |
@@ -640,10 +641,16 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, | |||
640 | if (backup_cred(cifs_sb)) | 641 | if (backup_cred(cifs_sb)) |
641 | create_options |= CREATE_OPEN_BACKUP_INTENT; | 642 | create_options |= CREATE_OPEN_BACKUP_INTENT; |
642 | 643 | ||
643 | rc = CIFSSMBOpen(xid, tcon, full_path, FILE_CREATE, | 644 | oparms.tcon = tcon; |
644 | GENERIC_WRITE, create_options, | 645 | oparms.cifs_sb = cifs_sb; |
645 | &netfid, &oplock, buf, cifs_sb->local_nls, | 646 | oparms.desired_access = GENERIC_WRITE; |
646 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 647 | oparms.create_options = create_options; |
648 | oparms.disposition = FILE_CREATE; | ||
649 | oparms.path = full_path; | ||
650 | oparms.fid = &fid; | ||
651 | oparms.reconnect = false; | ||
652 | |||
653 | rc = CIFS_open(xid, &oparms, &oplock, buf); | ||
647 | if (rc) | 654 | if (rc) |
648 | goto mknod_out; | 655 | goto mknod_out; |
649 | 656 | ||
@@ -653,7 +660,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, | |||
653 | */ | 660 | */ |
654 | 661 | ||
655 | pdev = (struct win_dev *)buf; | 662 | pdev = (struct win_dev *)buf; |
656 | io_parms.netfid = netfid; | 663 | io_parms.netfid = fid.netfid; |
657 | io_parms.pid = current->tgid; | 664 | io_parms.pid = current->tgid; |
658 | io_parms.tcon = tcon; | 665 | io_parms.tcon = tcon; |
659 | io_parms.offset = 0; | 666 | io_parms.offset = 0; |
@@ -671,7 +678,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, | |||
671 | rc = CIFSSMBWrite(xid, &io_parms, &bytes_written, (char *)pdev, | 678 | rc = CIFSSMBWrite(xid, &io_parms, &bytes_written, (char *)pdev, |
672 | NULL, 0); | 679 | NULL, 0); |
673 | } /* else if (S_ISFIFO) */ | 680 | } /* else if (S_ISFIFO) */ |
674 | CIFSSMBClose(xid, tcon, netfid); | 681 | CIFSSMBClose(xid, tcon, fid.netfid); |
675 | d_drop(direntry); | 682 | d_drop(direntry); |
676 | 683 | ||
677 | /* FIXME: add code here to set EAs */ | 684 | /* FIXME: add code here to set EAs */ |
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 5a5a87240fe2..853d6d1cc822 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
@@ -678,7 +678,7 @@ cifs_reopen_file(struct cifsFileInfo *cfile, bool can_flush) | |||
678 | 678 | ||
679 | /* | 679 | /* |
680 | * Can not refresh inode by passing in file_info buf to be returned by | 680 | * Can not refresh inode by passing in file_info buf to be returned by |
681 | * CIFSSMBOpen and then calling get_inode_info with returned buf since | 681 | * ops->open and then calling get_inode_info with returned buf since |
682 | * file might have write behind data that needs to be flushed and server | 682 | * file might have write behind data that needs to be flushed and server |
683 | * version of file size can be stale. If we knew for sure that inode was | 683 | * version of file size can be stale. If we knew for sure that inode was |
684 | * not dirty locally we could do this. | 684 | * not dirty locally we could do this. |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 5793b5a557e9..9cb9679d7357 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -409,9 +409,10 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, | |||
409 | { | 409 | { |
410 | int rc; | 410 | int rc; |
411 | int oplock = 0; | 411 | int oplock = 0; |
412 | __u16 netfid; | ||
413 | struct tcon_link *tlink; | 412 | struct tcon_link *tlink; |
414 | struct cifs_tcon *tcon; | 413 | struct cifs_tcon *tcon; |
414 | struct cifs_fid fid; | ||
415 | struct cifs_open_parms oparms; | ||
415 | struct cifs_io_parms io_parms; | 416 | struct cifs_io_parms io_parms; |
416 | char buf[24]; | 417 | char buf[24]; |
417 | unsigned int bytes_read; | 418 | unsigned int bytes_read; |
@@ -437,18 +438,23 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, | |||
437 | return PTR_ERR(tlink); | 438 | return PTR_ERR(tlink); |
438 | tcon = tlink_tcon(tlink); | 439 | tcon = tlink_tcon(tlink); |
439 | 440 | ||
440 | rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, GENERIC_READ, | 441 | oparms.tcon = tcon; |
441 | CREATE_NOT_DIR, &netfid, &oplock, NULL, | 442 | oparms.cifs_sb = cifs_sb; |
442 | cifs_sb->local_nls, | 443 | oparms.desired_access = GENERIC_READ; |
443 | cifs_sb->mnt_cifs_flags & | 444 | oparms.create_options = CREATE_NOT_DIR; |
444 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 445 | oparms.disposition = FILE_OPEN; |
446 | oparms.path = path; | ||
447 | oparms.fid = &fid; | ||
448 | oparms.reconnect = false; | ||
449 | |||
450 | rc = CIFS_open(xid, &oparms, &oplock, NULL); | ||
445 | if (rc) { | 451 | if (rc) { |
446 | cifs_put_tlink(tlink); | 452 | cifs_put_tlink(tlink); |
447 | return rc; | 453 | return rc; |
448 | } | 454 | } |
449 | 455 | ||
450 | /* Read header */ | 456 | /* Read header */ |
451 | io_parms.netfid = netfid; | 457 | io_parms.netfid = fid.netfid; |
452 | io_parms.pid = current->tgid; | 458 | io_parms.pid = current->tgid; |
453 | io_parms.tcon = tcon; | 459 | io_parms.tcon = tcon; |
454 | io_parms.offset = 0; | 460 | io_parms.offset = 0; |
@@ -494,7 +500,7 @@ cifs_sfu_type(struct cifs_fattr *fattr, const char *path, | |||
494 | fattr->cf_dtype = DT_REG; | 500 | fattr->cf_dtype = DT_REG; |
495 | rc = -EOPNOTSUPP; /* or some unknown SFU type */ | 501 | rc = -EOPNOTSUPP; /* or some unknown SFU type */ |
496 | } | 502 | } |
497 | CIFSSMBClose(xid, tcon, netfid); | 503 | CIFSSMBClose(xid, tcon, fid.netfid); |
498 | cifs_put_tlink(tlink); | 504 | cifs_put_tlink(tlink); |
499 | return rc; | 505 | return rc; |
500 | } | 506 | } |
@@ -1035,7 +1041,8 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, | |||
1035 | { | 1041 | { |
1036 | int oplock = 0; | 1042 | int oplock = 0; |
1037 | int rc; | 1043 | int rc; |
1038 | __u16 netfid; | 1044 | struct cifs_fid fid; |
1045 | struct cifs_open_parms oparms; | ||
1039 | struct inode *inode = dentry->d_inode; | 1046 | struct inode *inode = dentry->d_inode; |
1040 | struct cifsInodeInfo *cifsInode = CIFS_I(inode); | 1047 | struct cifsInodeInfo *cifsInode = CIFS_I(inode); |
1041 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); | 1048 | struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); |
@@ -1058,10 +1065,16 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, | |||
1058 | goto out; | 1065 | goto out; |
1059 | } | 1066 | } |
1060 | 1067 | ||
1061 | rc = CIFSSMBOpen(xid, tcon, full_path, FILE_OPEN, | 1068 | oparms.tcon = tcon; |
1062 | DELETE|FILE_WRITE_ATTRIBUTES, CREATE_NOT_DIR, | 1069 | oparms.cifs_sb = cifs_sb; |
1063 | &netfid, &oplock, NULL, cifs_sb->local_nls, | 1070 | oparms.desired_access = DELETE | FILE_WRITE_ATTRIBUTES; |
1064 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 1071 | oparms.create_options = CREATE_NOT_DIR; |
1072 | oparms.disposition = FILE_OPEN; | ||
1073 | oparms.path = full_path; | ||
1074 | oparms.fid = &fid; | ||
1075 | oparms.reconnect = false; | ||
1076 | |||
1077 | rc = CIFS_open(xid, &oparms, &oplock, NULL); | ||
1065 | if (rc != 0) | 1078 | if (rc != 0) |
1066 | goto out; | 1079 | goto out; |
1067 | 1080 | ||
@@ -1082,7 +1095,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, | |||
1082 | goto out_close; | 1095 | goto out_close; |
1083 | } | 1096 | } |
1084 | info_buf->Attributes = cpu_to_le32(dosattr); | 1097 | info_buf->Attributes = cpu_to_le32(dosattr); |
1085 | rc = CIFSSMBSetFileInfo(xid, tcon, info_buf, netfid, | 1098 | rc = CIFSSMBSetFileInfo(xid, tcon, info_buf, fid.netfid, |
1086 | current->tgid); | 1099 | current->tgid); |
1087 | /* although we would like to mark the file hidden | 1100 | /* although we would like to mark the file hidden |
1088 | if that fails we will still try to rename it */ | 1101 | if that fails we will still try to rename it */ |
@@ -1093,7 +1106,8 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, | |||
1093 | } | 1106 | } |
1094 | 1107 | ||
1095 | /* rename the file */ | 1108 | /* rename the file */ |
1096 | rc = CIFSSMBRenameOpenFile(xid, tcon, netfid, NULL, cifs_sb->local_nls, | 1109 | rc = CIFSSMBRenameOpenFile(xid, tcon, fid.netfid, NULL, |
1110 | cifs_sb->local_nls, | ||
1097 | cifs_sb->mnt_cifs_flags & | 1111 | cifs_sb->mnt_cifs_flags & |
1098 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1112 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1099 | if (rc != 0) { | 1113 | if (rc != 0) { |
@@ -1103,7 +1117,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, | |||
1103 | 1117 | ||
1104 | /* try to set DELETE_ON_CLOSE */ | 1118 | /* try to set DELETE_ON_CLOSE */ |
1105 | if (!cifsInode->delete_pending) { | 1119 | if (!cifsInode->delete_pending) { |
1106 | rc = CIFSSMBSetFileDisposition(xid, tcon, true, netfid, | 1120 | rc = CIFSSMBSetFileDisposition(xid, tcon, true, fid.netfid, |
1107 | current->tgid); | 1121 | current->tgid); |
1108 | /* | 1122 | /* |
1109 | * some samba versions return -ENOENT when we try to set the | 1123 | * some samba versions return -ENOENT when we try to set the |
@@ -1123,7 +1137,7 @@ cifs_rename_pending_delete(const char *full_path, struct dentry *dentry, | |||
1123 | } | 1137 | } |
1124 | 1138 | ||
1125 | out_close: | 1139 | out_close: |
1126 | CIFSSMBClose(xid, tcon, netfid); | 1140 | CIFSSMBClose(xid, tcon, fid.netfid); |
1127 | out: | 1141 | out: |
1128 | kfree(info_buf); | 1142 | kfree(info_buf); |
1129 | cifs_put_tlink(tlink); | 1143 | cifs_put_tlink(tlink); |
@@ -1135,13 +1149,13 @@ out: | |||
1135 | * them anyway. | 1149 | * them anyway. |
1136 | */ | 1150 | */ |
1137 | undo_rename: | 1151 | undo_rename: |
1138 | CIFSSMBRenameOpenFile(xid, tcon, netfid, dentry->d_name.name, | 1152 | CIFSSMBRenameOpenFile(xid, tcon, fid.netfid, dentry->d_name.name, |
1139 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & | 1153 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & |
1140 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1154 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1141 | undo_setattr: | 1155 | undo_setattr: |
1142 | if (dosattr != origattr) { | 1156 | if (dosattr != origattr) { |
1143 | info_buf->Attributes = cpu_to_le32(origattr); | 1157 | info_buf->Attributes = cpu_to_le32(origattr); |
1144 | if (!CIFSSMBSetFileInfo(xid, tcon, info_buf, netfid, | 1158 | if (!CIFSSMBSetFileInfo(xid, tcon, info_buf, fid.netfid, |
1145 | current->tgid)) | 1159 | current->tgid)) |
1146 | cifsInode->cifsAttrs = origattr; | 1160 | cifsInode->cifsAttrs = origattr; |
1147 | } | 1161 | } |
@@ -1552,7 +1566,8 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry, | |||
1552 | struct tcon_link *tlink; | 1566 | struct tcon_link *tlink; |
1553 | struct cifs_tcon *tcon; | 1567 | struct cifs_tcon *tcon; |
1554 | struct TCP_Server_Info *server; | 1568 | struct TCP_Server_Info *server; |
1555 | __u16 srcfid; | 1569 | struct cifs_fid fid; |
1570 | struct cifs_open_parms oparms; | ||
1556 | int oplock, rc; | 1571 | int oplock, rc; |
1557 | 1572 | ||
1558 | tlink = cifs_sb_tlink(cifs_sb); | 1573 | tlink = cifs_sb_tlink(cifs_sb); |
@@ -1579,17 +1594,23 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry, | |||
1579 | if (to_dentry->d_parent != from_dentry->d_parent) | 1594 | if (to_dentry->d_parent != from_dentry->d_parent) |
1580 | goto do_rename_exit; | 1595 | goto do_rename_exit; |
1581 | 1596 | ||
1597 | oparms.tcon = tcon; | ||
1598 | oparms.cifs_sb = cifs_sb; | ||
1582 | /* open the file to be renamed -- we need DELETE perms */ | 1599 | /* open the file to be renamed -- we need DELETE perms */ |
1583 | rc = CIFSSMBOpen(xid, tcon, from_path, FILE_OPEN, DELETE, | 1600 | oparms.desired_access = DELETE; |
1584 | CREATE_NOT_DIR, &srcfid, &oplock, NULL, | 1601 | oparms.create_options = CREATE_NOT_DIR; |
1585 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & | 1602 | oparms.disposition = FILE_OPEN; |
1586 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1603 | oparms.path = from_path; |
1604 | oparms.fid = &fid; | ||
1605 | oparms.reconnect = false; | ||
1606 | |||
1607 | rc = CIFS_open(xid, &oparms, &oplock, NULL); | ||
1587 | if (rc == 0) { | 1608 | if (rc == 0) { |
1588 | rc = CIFSSMBRenameOpenFile(xid, tcon, srcfid, | 1609 | rc = CIFSSMBRenameOpenFile(xid, tcon, fid.netfid, |
1589 | (const char *) to_dentry->d_name.name, | 1610 | (const char *) to_dentry->d_name.name, |
1590 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & | 1611 | cifs_sb->local_nls, cifs_sb->mnt_cifs_flags & |
1591 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 1612 | CIFS_MOUNT_MAP_SPECIAL_CHR); |
1592 | CIFSSMBClose(xid, tcon, srcfid); | 1613 | CIFSSMBClose(xid, tcon, fid.netfid); |
1593 | } | 1614 | } |
1594 | do_rename_exit: | 1615 | do_rename_exit: |
1595 | cifs_put_tlink(tlink); | 1616 | cifs_put_tlink(tlink); |
diff --git a/fs/cifs/link.c b/fs/cifs/link.c index 38b9bf4f5a6b..52f41f9f7def 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c | |||
@@ -320,16 +320,22 @@ cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, | |||
320 | { | 320 | { |
321 | int rc; | 321 | int rc; |
322 | int oplock = 0; | 322 | int oplock = 0; |
323 | __u16 netfid = 0; | 323 | struct cifs_fid fid; |
324 | struct cifs_open_parms oparms; | ||
324 | struct cifs_io_parms io_parms; | 325 | struct cifs_io_parms io_parms; |
325 | int buf_type = CIFS_NO_BUFFER; | 326 | int buf_type = CIFS_NO_BUFFER; |
326 | FILE_ALL_INFO file_info; | 327 | FILE_ALL_INFO file_info; |
327 | 328 | ||
328 | rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, GENERIC_READ, | 329 | oparms.tcon = tcon; |
329 | CREATE_NOT_DIR, &netfid, &oplock, &file_info, | 330 | oparms.cifs_sb = cifs_sb; |
330 | cifs_sb->local_nls, | 331 | oparms.desired_access = GENERIC_READ; |
331 | cifs_sb->mnt_cifs_flags & | 332 | oparms.create_options = CREATE_NOT_DIR; |
332 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 333 | oparms.disposition = FILE_OPEN; |
334 | oparms.path = path; | ||
335 | oparms.fid = &fid; | ||
336 | oparms.reconnect = false; | ||
337 | |||
338 | rc = CIFS_open(xid, &oparms, &oplock, &file_info); | ||
333 | if (rc) | 339 | if (rc) |
334 | return rc; | 340 | return rc; |
335 | 341 | ||
@@ -337,7 +343,7 @@ cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, | |||
337 | /* it's not a symlink */ | 343 | /* it's not a symlink */ |
338 | goto out; | 344 | goto out; |
339 | 345 | ||
340 | io_parms.netfid = netfid; | 346 | io_parms.netfid = fid.netfid; |
341 | io_parms.pid = current->tgid; | 347 | io_parms.pid = current->tgid; |
342 | io_parms.tcon = tcon; | 348 | io_parms.tcon = tcon; |
343 | io_parms.offset = 0; | 349 | io_parms.offset = 0; |
@@ -345,7 +351,7 @@ cifs_query_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, | |||
345 | 351 | ||
346 | rc = CIFSSMBRead(xid, &io_parms, pbytes_read, &pbuf, &buf_type); | 352 | rc = CIFSSMBRead(xid, &io_parms, pbytes_read, &pbuf, &buf_type); |
347 | out: | 353 | out: |
348 | CIFSSMBClose(xid, tcon, netfid); | 354 | CIFSSMBClose(xid, tcon, fid.netfid); |
349 | return rc; | 355 | return rc; |
350 | } | 356 | } |
351 | 357 | ||
@@ -356,29 +362,35 @@ cifs_create_mf_symlink(unsigned int xid, struct cifs_tcon *tcon, | |||
356 | { | 362 | { |
357 | int rc; | 363 | int rc; |
358 | int oplock = 0; | 364 | int oplock = 0; |
359 | __u16 netfid = 0; | 365 | struct cifs_fid fid; |
366 | struct cifs_open_parms oparms; | ||
360 | struct cifs_io_parms io_parms; | 367 | struct cifs_io_parms io_parms; |
361 | int create_options = CREATE_NOT_DIR; | 368 | int create_options = CREATE_NOT_DIR; |
362 | 369 | ||
363 | if (backup_cred(cifs_sb)) | 370 | if (backup_cred(cifs_sb)) |
364 | create_options |= CREATE_OPEN_BACKUP_INTENT; | 371 | create_options |= CREATE_OPEN_BACKUP_INTENT; |
365 | 372 | ||
366 | rc = CIFSSMBOpen(xid, tcon, path, FILE_CREATE, GENERIC_WRITE, | 373 | oparms.tcon = tcon; |
367 | create_options, &netfid, &oplock, NULL, | 374 | oparms.cifs_sb = cifs_sb; |
368 | cifs_sb->local_nls, | 375 | oparms.desired_access = GENERIC_WRITE; |
369 | cifs_sb->mnt_cifs_flags & | 376 | oparms.create_options = create_options; |
370 | CIFS_MOUNT_MAP_SPECIAL_CHR); | 377 | oparms.disposition = FILE_OPEN; |
378 | oparms.path = path; | ||
379 | oparms.fid = &fid; | ||
380 | oparms.reconnect = false; | ||
381 | |||
382 | rc = CIFS_open(xid, &oparms, &oplock, NULL); | ||
371 | if (rc) | 383 | if (rc) |
372 | return rc; | 384 | return rc; |
373 | 385 | ||
374 | io_parms.netfid = netfid; | 386 | io_parms.netfid = fid.netfid; |
375 | io_parms.pid = current->tgid; | 387 | io_parms.pid = current->tgid; |
376 | io_parms.tcon = tcon; | 388 | io_parms.tcon = tcon; |
377 | io_parms.offset = 0; | 389 | io_parms.offset = 0; |
378 | io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE; | 390 | io_parms.length = CIFS_MF_SYMLINK_FILE_SIZE; |
379 | 391 | ||
380 | rc = CIFSSMBWrite(xid, &io_parms, pbytes_written, pbuf, NULL, 0); | 392 | rc = CIFSSMBWrite(xid, &io_parms, pbytes_written, pbuf, NULL, 0); |
381 | CIFSSMBClose(xid, tcon, netfid); | 393 | CIFSSMBClose(xid, tcon, fid.netfid); |
382 | return rc; | 394 | return rc; |
383 | } | 395 | } |
384 | 396 | ||
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 | ||
716 | static void | 718 | static 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 | ||
813 | set_via_filehandle: | 821 | set_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); |
822 | out: | 830 | out: |
@@ -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, '/'); |
973 | out_close: | 988 | out_close: |
974 | CIFSSMBClose(xid, tcon, netfid); | 989 | CIFSSMBClose(xid, tcon, fid.netfid); |
975 | out: | 990 | out: |
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); |