diff options
author | Shirish Pargaonkar <shirishpargaonkar@gmail.com> | 2010-11-10 08:50:35 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2010-11-10 22:54:36 -0500 |
commit | 987b21d7d91d0335e164a41a312174851c58f333 (patch) | |
tree | 2e73097480e5482ef0fdc50db19c162e6fea78cf /fs/cifs | |
parent | a7851ce73b9fdef53f251420e6883cf4f3766534 (diff) |
cifs: Percolate error up to the caller during get/set acls [try #4]
Modify get/set_cifs_acl* calls to reutrn error code and percolate the
error code up to the caller.
Signed-off-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifsacl.c | 44 | ||||
-rw-r--r-- | fs/cifs/cifsproto.h | 2 |
2 files changed, 27 insertions, 19 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index c9b4792ae825..91992abc2149 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
@@ -560,7 +560,7 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, | |||
560 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); | 560 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); |
561 | 561 | ||
562 | if (IS_ERR(tlink)) | 562 | if (IS_ERR(tlink)) |
563 | return NULL; | 563 | return ERR_CAST(tlink); |
564 | 564 | ||
565 | xid = GetXid(); | 565 | xid = GetXid(); |
566 | rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), fid, &pntsd, pacllen); | 566 | rc = CIFSSMBGetCIFSACL(xid, tlink_tcon(tlink), fid, &pntsd, pacllen); |
@@ -568,7 +568,9 @@ static struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, | |||
568 | 568 | ||
569 | cifs_put_tlink(tlink); | 569 | cifs_put_tlink(tlink); |
570 | 570 | ||
571 | cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen); | 571 | cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen); |
572 | if (rc) | ||
573 | return ERR_PTR(rc); | ||
572 | return pntsd; | 574 | return pntsd; |
573 | } | 575 | } |
574 | 576 | ||
@@ -583,7 +585,7 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, | |||
583 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); | 585 | struct tcon_link *tlink = cifs_sb_tlink(cifs_sb); |
584 | 586 | ||
585 | if (IS_ERR(tlink)) | 587 | if (IS_ERR(tlink)) |
586 | return NULL; | 588 | return ERR_CAST(tlink); |
587 | 589 | ||
588 | tcon = tlink_tcon(tlink); | 590 | tcon = tlink_tcon(tlink); |
589 | xid = GetXid(); | 591 | xid = GetXid(); |
@@ -591,18 +593,17 @@ static struct cifs_ntsd *get_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, | |||
591 | rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0, | 593 | rc = CIFSSMBOpen(xid, tcon, path, FILE_OPEN, READ_CONTROL, 0, |
592 | &fid, &oplock, NULL, cifs_sb->local_nls, | 594 | &fid, &oplock, NULL, cifs_sb->local_nls, |
593 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); | 595 | cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); |
594 | if (rc) { | 596 | if (!rc) { |
595 | cERROR(1, "Unable to open file to get ACL"); | 597 | rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen); |
596 | goto out; | 598 | CIFSSMBClose(xid, tcon, fid); |
597 | } | 599 | } |
598 | 600 | ||
599 | rc = CIFSSMBGetCIFSACL(xid, tcon, fid, &pntsd, pacllen); | ||
600 | cFYI(1, "GetCIFSACL rc = %d ACL len %d", rc, *pacllen); | ||
601 | |||
602 | CIFSSMBClose(xid, tcon, fid); | ||
603 | out: | ||
604 | cifs_put_tlink(tlink); | 601 | cifs_put_tlink(tlink); |
605 | FreeXid(xid); | 602 | FreeXid(xid); |
603 | |||
604 | cFYI(1, "%s: rc = %d ACL len %d", __func__, rc, *pacllen); | ||
605 | if (rc) | ||
606 | return ERR_PTR(rc); | ||
606 | return pntsd; | 607 | return pntsd; |
607 | } | 608 | } |
608 | 609 | ||
@@ -695,7 +696,7 @@ static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, | |||
695 | } | 696 | } |
696 | 697 | ||
697 | /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ | 698 | /* Translate the CIFS ACL (simlar to NTFS ACL) for a file into mode bits */ |
698 | void | 699 | int |
699 | cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, | 700 | cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, |
700 | struct inode *inode, const char *path, const __u16 *pfid) | 701 | struct inode *inode, const char *path, const __u16 *pfid) |
701 | { | 702 | { |
@@ -711,13 +712,17 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, | |||
711 | pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen); | 712 | pntsd = get_cifs_acl(cifs_sb, inode, path, &acllen); |
712 | 713 | ||
713 | /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ | 714 | /* if we can retrieve the ACL, now parse Access Control Entries, ACEs */ |
714 | if (pntsd) | 715 | if (IS_ERR(pntsd)) { |
716 | rc = PTR_ERR(pntsd); | ||
717 | cERROR(1, "%s: error %d getting sec desc", __func__, rc); | ||
718 | } else { | ||
715 | rc = parse_sec_desc(pntsd, acllen, fattr); | 719 | rc = parse_sec_desc(pntsd, acllen, fattr); |
716 | if (rc) | 720 | kfree(pntsd); |
717 | cFYI(1, "parse sec desc failed rc = %d", rc); | 721 | if (rc) |
722 | cERROR(1, "parse sec desc failed rc = %d", rc); | ||
723 | } | ||
718 | 724 | ||
719 | kfree(pntsd); | 725 | return rc; |
720 | return; | ||
721 | } | 726 | } |
722 | 727 | ||
723 | /* Convert mode bits to an ACL so we can update the ACL on the server */ | 728 | /* Convert mode bits to an ACL so we can update the ACL on the server */ |
@@ -736,7 +741,10 @@ int mode_to_acl(struct inode *inode, const char *path, __u64 nmode) | |||
736 | /* Add three ACEs for owner, group, everyone getting rid of | 741 | /* Add three ACEs for owner, group, everyone getting rid of |
737 | other ACEs as chmod disables ACEs and set the security descriptor */ | 742 | other ACEs as chmod disables ACEs and set the security descriptor */ |
738 | 743 | ||
739 | if (pntsd) { | 744 | if (IS_ERR(pntsd)) { |
745 | rc = PTR_ERR(pntsd); | ||
746 | cERROR(1, "%s: error %d getting sec desc", __func__, rc); | ||
747 | } else { | ||
740 | /* allocate memory for the smb header, | 748 | /* allocate memory for the smb header, |
741 | set security descriptor request security descriptor | 749 | set security descriptor request security descriptor |
742 | parameters, and secuirty descriptor itself */ | 750 | parameters, and secuirty descriptor itself */ |
diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 7ed69b6b5fe6..6ed59af4520d 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h | |||
@@ -130,7 +130,7 @@ extern int cifs_get_file_info_unix(struct file *filp); | |||
130 | extern int cifs_get_inode_info_unix(struct inode **pinode, | 130 | extern int cifs_get_inode_info_unix(struct inode **pinode, |
131 | const unsigned char *search_path, | 131 | const unsigned char *search_path, |
132 | struct super_block *sb, int xid); | 132 | struct super_block *sb, int xid); |
133 | extern void cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, | 133 | extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, |
134 | struct cifs_fattr *fattr, struct inode *inode, | 134 | struct cifs_fattr *fattr, struct inode *inode, |
135 | const char *path, const __u16 *pfid); | 135 | const char *path, const __u16 *pfid); |
136 | extern int mode_to_acl(struct inode *inode, const char *path, __u64); | 136 | extern int mode_to_acl(struct inode *inode, const char *path, __u64); |