xfs
[Top] [All Lists]

RE: accessing the ACL of a file inside XFS kernel.

To: "Tim Shimmin" <tes@xxxxxxx>
Subject: RE: accessing the ACL of a file inside XFS kernel.
From: "Eric Chen" <echen@xxxxxxxxxxx>
Date: Fri, 9 May 2003 11:06:28 -0700
Cc: <linux-xfs@xxxxxxxxxxx>
Importance: Normal
In-reply-to: <20030509185934.A39490@boing.melbourne.sgi.com>
Sender: linux-xfs-bounce@xxxxxxxxxxx
>>How about using:
>>  _ACL_GET_ACCESS(pv,pa) for the XFS access ACL
>>(which ends up calling xfs_acl_vtoacl()).
>>This function will get the xfs_acl given the vnode.
>
>what is the argument 'pa' that is passed into the function _ACL_GET_ACCESS?
>
>so I can have
>
>xfs_acl_t *acl = _ACL_GET_ACCESS(pv, pa);
>
>where vnode_t *pv = LINVFS_GET_VP(dir);
>

nevermind, I think I figured out the syntax. You call _ACL_GET_ACCESS with
pv and pa, where pv is the pointer to the vnode_t and pa is the pointer to
the xfs_acl_t. Is this right?

so if you call _ACL_GET_ACCESS(pv, pa);
will the acl be then stored in 'pa'? I am getting a weird result, because
when I printk pa->acl_cnt, I always get -1.

Here's some of the code:

STATIC int
linvfs_unlink(
        struct inode    *dir,
        struct dentry   *dentry)
{
        int                     error = 0;
        struct inode    *inode;
        vnode_t         *dvp;   /* directory containing name to remove */

        // I added this
        int             i;
        vnode_t *vp;
        xfs_acl_t       *acl;
        // end of I added this

        inode = dentry->d_inode;

        dvp = LINVFS_GET_VP(dir);

        // I added this
        vp = LINVFS_GET_VP(inode);
        _ACL_GET_ACCESS(vp, acl);

        printk("acl_cnt: %d\n", acl->acl_cnt);
        for (i=0;i<acl->acl_cnt;i++) {
                printk("perm[%d]: %x\n", i, acl->acl_entry[i].ae_perm);
        }
        // end of I added this

        ..... resume the rest of the code
}

so if I create a file by doing 'touch file', I get a file with the
permission bits: -rw-r--r--
and in the ACL, there are 3 entries for user, group, and other.
acl->acl_cnt should then be 3 right?? and
acl->acl_entry[0].ae_perm should be 6, and
acl->acl_entry[1].ae_perm should be 4, and
acl->acl_entry[2].ae_perm should be 4.

however, when I remove a file, I get 'acl->acl_cnt = -1'

this is a different result from what I expected.. but I don't know where the
problem might be.

I tried doing a printk in the function xfs_acl_vtoacl() and I get a
different result there also.

Here is the code for that function:

int
xfs_acl_vtoacl(
        vnode_t *vp,
        xfs_acl_t       *access_acl,
        xfs_acl_t       *default_acl)
{
        vattr_t va;
        int             error = 0;

        if (access_acl) {
                /*
                 * Get the Access ACL and the mode.  If either cannot
                 * be obtained for some reason, invalidate the access ACL.
                 */
                xfs_acl_get_attr(vp, access_acl, _ACL_TYPE_ACCESS, 0, &error);

                //I added this line
                printk("aclcount : access_acl->acl_cnt=%d\n", 
access_acl->acl_cnt);

        ...resume rest of code
}

This is weird because I would expect the acl_cnts to be the same.

When I remove the file, it will first print out 'aclcount :
access_acl->acl_cnt=1' then 'acl_cnt: -1'.

Any ideas on why this might be happening? and how I can get the correct acl?

Thanks,
~Eric

*please reply to me because I am not subscribed to the list.*


<Prev in Thread] Current Thread [Next in Thread>