lkml.org 
[lkml]   [2006]   [Sep]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Generic infrastructure for acls
Date
On Friday, 01 September 2006 23:44, Andrew Morton wrote:
> On Sat, 02 Sep 2006 00:14:22 +0200
>
> Andreas Gruenbacher <agruen@suse.de> wrote:
> > +generic_acl_list(struct inode *inode, struct generic_acl_operations
> > *ops, + int type, char *list, size_t list_size)
> > +{
> > + struct posix_acl *acl;
> > + const char *name;
> > + size_t size;
> > +
> > + acl = ops->getacl(inode, type);
> > + if (!acl)
> > + return 0;
> > + posix_acl_release(acl);
> > +
> > + switch(type) {
> > + case ACL_TYPE_ACCESS:
> > + name = POSIX_ACL_XATTR_ACCESS;
> > + break;
> > +
> > + case ACL_TYPE_DEFAULT:
> > + name = POSIX_ACL_XATTR_DEFAULT;
> > + break;
> > +
> > + default:
> > + return 0;
> > + }
> > + size = strlen(name) + 1;
> > + if (list && size <= list_size)
> > + memcpy(list, name, size);
> > + return size;
> > +}
>
> That's a clumsy-looking interface.

We could get rid of the switch by passing in the type and the name, but
otherwise that's pretty exactly what's needed, no matter if done in a
fs-dependent or independent way.

> How is the caller to know that *list got filled in? By checking the
generic_acl_list() return value against `list_size'?

The return value determines how many bytes have been used or would be needed
in the buffer -- generic_listxattr() in fs/xattr.c has this code:

> for_each_xattr_handler(handlers, handler) {
> size = handler->list(inode, buf, buffer_size, NULL, 0);
> if (size > buffer_size)
> return -ERANGE;
> buf += size;
> buffer_size -= size;
> }

Andreas

--
VGER BF report: H 0
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-09-02 00:31    [W:0.078 / U:25.728 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site