Esempio n. 1
0
File: acl.c Progetto: acton393/linux
static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, char *name)
{
	ssize_t size;
	void *value = NULL;
	struct posix_acl *acl = NULL;

	size = v9fs_fid_xattr_get(fid, name, NULL, 0);
	if (size > 0) {
		value = kzalloc(size, GFP_NOFS);
		if (!value)
			return ERR_PTR(-ENOMEM);
		size = v9fs_fid_xattr_get(fid, name, value, size);
		if (size > 0) {
			acl = posix_acl_from_xattr(&init_user_ns, value, size);
			if (IS_ERR(acl))
				goto err_out;
		}
	} else if (size == -ENODATA || size == 0 ||
		   size == -ENOSYS || size == -EOPNOTSUPP) {
		acl = NULL;
	} else
		acl = ERR_PTR(-EIO);

err_out:
	kfree(value);
	return acl;
}
Esempio n. 2
0
/*
 * v9fs_xattr_get()
 *
 * Copy an extended attribute into the buffer
 * provided, or compute the buffer size required.
 * Buffer is NULL to compute the size of the buffer required.
 *
 * Returns a negative error number on failure, or the number of bytes
 * used / required on success.
 */
ssize_t v9fs_xattr_get(struct dentry *dentry, const char *name,
                       void *buffer, size_t buffer_size)
{
    struct p9_fid *fid;

    P9_DPRINTK(P9_DEBUG_VFS, "%s: name = %s value_len = %zu\n",
               __func__, name, buffer_size);
    fid = v9fs_fid_lookup(dentry);
    if (IS_ERR(fid))
        return PTR_ERR(fid);

    return v9fs_fid_xattr_get(fid, name, buffer, buffer_size);
}