From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shirish Pargaonkar Subject: Re: [linux-cifs-client] [PATCH 04/10] cifs: clean up set_cifs_acl interfaces Date: Thu, 28 May 2009 10:23:41 -0500 Message-ID: <4a4634330905280823l348e5ff2mc8064fa0f774d619@mail.gmail.com> References: <1243456447-11176-1-git-send-email-jlayton@redhat.com> <1243456447-11176-5-git-send-email-jlayton@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-cifs-client@lists.samba.org, linux-fsdevel@vger.kernel.org To: Jeff Layton Return-path: Received: from yx-out-2324.google.com ([74.125.44.29]:17312 "EHLO yx-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758501AbZE1PXk convert rfc822-to-8bit (ORCPT ); Thu, 28 May 2009 11:23:40 -0400 Received: by yx-out-2324.google.com with SMTP id 3so3059843yxj.1 for ; Thu, 28 May 2009 08:23:41 -0700 (PDT) In-Reply-To: <1243456447-11176-5-git-send-email-jlayton@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, May 27, 2009 at 3:34 PM, Jeff Layton wrote= : > From: Christoph Hellwig > > Signed-off-by: Christoph Hellwig > Signed-off-by: Jeff Layton > --- > =A0fs/cifs/cifsacl.c | =A0 78 ++++++++++++++++++++++++++++-----------= -------------- > =A01 files changed, 41 insertions(+), 37 deletions(-) > > diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c > index 7f8e6c4..1403b5d 100644 > --- a/fs/cifs/cifsacl.c > +++ b/fs/cifs/cifsacl.c > @@ -612,57 +612,61 @@ static struct cifs_ntsd *get_cifs_acl(struct ci= fs_sb_info *cifs_sb, > =A0 =A0 =A0 =A0return pntsd; > =A0} > > -/* Set an ACL on the server */ > -static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct = inode *inode, const char *path) > +static int set_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb, __u16 f= id, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct cifs_ntsd *pnntsd, u32 acllen) > =A0{ > - =A0 =A0 =A0 struct cifsFileInfo *open_file; > - =A0 =A0 =A0 bool unlock_file =3D false; > - =A0 =A0 =A0 int xid; > - =A0 =A0 =A0 int rc =3D -EIO; > - =A0 =A0 =A0 __u16 fid; > - =A0 =A0 =A0 struct super_block *sb; > - =A0 =A0 =A0 struct cifs_sb_info *cifs_sb; > + =A0 =A0 =A0 int xid, rc; > > - =A0 =A0 =A0 cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inod= e->i_mode)); > + =A0 =A0 =A0 xid =3D GetXid(); > + =A0 =A0 =A0 rc =3D CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnnts= d, acllen); > + =A0 =A0 =A0 FreeXid(xid); > > - =A0 =A0 =A0 if (!inode) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return rc; > + =A0 =A0 =A0 cFYI(DBG2, ("SetCIFSACL rc =3D %d", rc)); > + =A0 =A0 =A0 return rc; > +} > > - =A0 =A0 =A0 sb =3D inode->i_sb; > - =A0 =A0 =A0 if (sb =3D=3D NULL) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 return rc; > +static int set_cifs_acl_by_path(struct cifs_sb_info *cifs_sb, const = char *path, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct cifs_ntsd *pnntsd, u32 acllen) > +{ > + =A0 =A0 =A0 int oplock =3D 0; > + =A0 =A0 =A0 int xid, rc; > + =A0 =A0 =A0 __u16 fid; > > - =A0 =A0 =A0 cifs_sb =3D CIFS_SB(sb); > =A0 =A0 =A0 =A0xid =3D GetXid(); > > - =A0 =A0 =A0 open_file =3D find_readable_file(CIFS_I(inode)); > - =A0 =A0 =A0 if (open_file) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 unlock_file =3D true; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 fid =3D open_file->netfid; > - =A0 =A0 =A0 } else { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 int oplock =3D 0; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* open file */ > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 rc =3D CIFSSMBOpen(xid, cifs_sb->tcon, = path, FILE_OPEN, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 WRITE_D= AC, 0, &fid, &oplock, NULL, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cifs_sb= ->local_nls, cifs_sb->mnt_cifs_flags & > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 CIFS_MOUNT_MAP_SPECIAL_CHR); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (rc !=3D 0) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 cERROR(1, ("Unable to o= pen file to set ACL")); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FreeXid(xid); > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return rc; > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 } > + =A0 =A0 =A0 rc =3D CIFSSMBOpen(xid, cifs_sb->tcon, path, FILE_OPEN,= WRITE_DAC, 0, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0&fid, &oplock, NULL,= cifs_sb->local_nls, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0cifs_sb->mnt_cifs_fl= ags & CIFS_MOUNT_MAP_SPECIAL_CHR); > + =A0 =A0 =A0 if (rc) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 cERROR(1, ("Unable to open file to set = ACL")); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto out; > =A0 =A0 =A0 =A0} > > =A0 =A0 =A0 =A0rc =3D CIFSSMBSetCIFSACL(xid, cifs_sb->tcon, fid, pnnt= sd, acllen); > =A0 =A0 =A0 =A0cFYI(DBG2, ("SetCIFSACL rc =3D %d", rc)); > - =A0 =A0 =A0 if (unlock_file) > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 atomic_dec(&open_file->wrtPending); > - =A0 =A0 =A0 else > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 CIFSSMBClose(xid, cifs_sb->tcon, fid); > > + =A0 =A0 =A0 CIFSSMBClose(xid, cifs_sb->tcon, fid); > + out: > =A0 =A0 =A0 =A0FreeXid(xid); > + =A0 =A0 =A0 return rc; > +} > > +/* Set an ACL on the server */ > +static int set_cifs_acl(struct cifs_ntsd *pnntsd, __u32 acllen, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 struct = inode *inode, const char *path) > +{ > + =A0 =A0 =A0 struct cifs_sb_info *cifs_sb =3D CIFS_SB(inode->i_sb); > + =A0 =A0 =A0 struct cifsFileInfo *open_file; > + =A0 =A0 =A0 int rc; > + > + =A0 =A0 =A0 cFYI(DBG2, ("set ACL for %s from mode 0x%x", path, inod= e->i_mode)); > + > + =A0 =A0 =A0 open_file =3D find_readable_file(CIFS_I(inode)); > + =A0 =A0 =A0 if (!open_file) > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 return set_cifs_acl_by_path(cifs_sb, pa= th, pnntsd, acllen); > + > + =A0 =A0 =A0 rc =3D set_cifs_acl_by_fid(cifs_sb, open_file->netfid, = pnntsd, acllen); > + =A0 =A0 =A0 atomic_dec(&open_file->wrtPending); > =A0 =A0 =A0 =A0return rc; > =A0} > > -- > 1.6.2.2 > > _______________________________________________ > linux-cifs-client mailing list > linux-cifs-client@lists.samba.org > https://lists.samba.org/mailman/listinfo/linux-cifs-client > Looks good -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html