cifs: clean up set_cifs_acl interfaces
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Shirish Pargaonkar <shirishp@us.ibm.com> Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
This commit is contained in:
parent
1bf4072da6
commit
b96d31a62f
1 changed files with 43 additions and 39 deletions
|
@ -612,57 +612,61 @@ static struct cifs_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
|
||||||
return pntsd;
|
return pntsd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set an ACL on the server */
|
static int set_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, __u16 fid,
|
||||||
static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
|
struct cifs_ntsd *pnntsd, u32 acllen)
|
||||||
struct inode *inode, const char *path)
|
|
||||||
{
|
{
|
||||||
struct cifsFileInfo *open_file;
|
int xid, rc;
|
||||||
bool unlock_file = false;
|
|
||||||
int xid;
|
xid = GetXid();
|
||||||
int rc = -EIO;
|
rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen);
|
||||||
|
FreeXid(xid);
|
||||||
|
|
||||||
|
cFYI(DBG2, ("SetCIFSACL rc = %d", rc));
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int set_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, const char *path,
|
||||||
|
struct cifs_ntsd *pnntsd, u32 acllen)
|
||||||
|
{
|
||||||
|
int oplock = 0;
|
||||||
|
int xid, rc;
|
||||||
__u16 fid;
|
__u16 fid;
|
||||||
struct super_block *sb;
|
|
||||||
struct cifs_sb_info *cifs_sb;
|
|
||||||
|
|
||||||
cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode));
|
|
||||||
|
|
||||||
if (!inode)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
sb = inode->i_sb;
|
|
||||||
if (sb == NULL)
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
cifs_sb = CIFS_SB(sb);
|
|
||||||
xid = GetXid();
|
xid = GetXid();
|
||||||
|
|
||||||
open_file = find_readable_file(CIFS_I(inode));
|
rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN, WRITE_DAC, 0,
|
||||||
if (open_file) {
|
&fid, &oplock, NULL, cifs_sb->local_nls,
|
||||||
unlock_file = true;
|
cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR);
|
||||||
fid = open_file->netfid;
|
if (rc) {
|
||||||
} else {
|
|
||||||
int oplock = 0;
|
|
||||||
/* open file */
|
|
||||||
rc = CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,
|
|
||||||
WRITE_DAC, 0, &fid, &oplock, NULL,
|
|
||||||
cifs_sb->local_nls, cifs_sb->mnt_cifs_flags &
|
|
||||||
CIFS_MOUNT_MAP_SPECIAL_CHR);
|
|
||||||
if (rc != 0) {
|
|
||||||
cERROR(1, ("Unable to open file to set ACL"));
|
cERROR(1, ("Unable to open file to set ACL"));
|
||||||
FreeXid(xid);
|
goto out;
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen);
|
rc = CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnntsd, acllen);
|
||||||
cFYI(DBG2, ("SetCIFSACL rc = %d", rc));
|
cFYI(DBG2, ("SetCIFSACL rc = %d", rc));
|
||||||
if (unlock_file)
|
|
||||||
atomic_dec(&open_file->wrtPending);
|
|
||||||
else
|
|
||||||
CIFSSMBClose(xid, cifs_sb->tcon, fid);
|
CIFSSMBClose(xid, cifs_sb->tcon, fid);
|
||||||
|
out:
|
||||||
FreeXid(xid);
|
FreeXid(xid);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set an ACL on the server */
|
||||||
|
static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen,
|
||||||
|
struct inode *inode, const char *path)
|
||||||
|
{
|
||||||
|
struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
|
||||||
|
struct cifsFileInfo *open_file;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inode->i_mode));
|
||||||
|
|
||||||
|
open_file = find_readable_file(CIFS_I(inode));
|
||||||
|
if (!open_file)
|
||||||
|
return set_cifs_acl_by_path(cifs_sb, path, pnntsd, acllen);
|
||||||
|
|
||||||
|
rc = set_cifs_acl_by_fid(cifs_sb, open_file->netfid, pnntsd, acllen);
|
||||||
|
atomic_dec(&open_file->wrtPending);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue