linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com, Mark Fasheh <mfasheh@suse.com>,
	reiserfs-devel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com,
	linux-mtd@lists.infradead.org, viro@zeniv.linux.org.uk,
	jfs-discussion@lists.sourceforge.net,
	linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
	linux-nfs@vger.kernel.org, linux-btrfs@vger.kernel.org,
	Joel Becker <jlbec@evilplan.org>
Subject: Re: [PATCH 04/18] fs: add generic xattr_acl handlers
Date: Mon, 2 Dec 2013 21:59:32 +0100	[thread overview]
Message-ID: <20131202205932.GE12253@quack.suse.cz> (raw)
In-Reply-To: <20131201120654.211328224@bombadil.infradead.org>

On Sun 01-12-13 03:59:07, Christoph Hellwig wrote:
> With the ->set_acl inode operation we can implement the Posix ACL
> xattr handlers in generic code instead of duplicating them all
> over the tree.
  Looks good. You can add:
Reviewed-by: Jan Kara <jack@suse.cz>

							Honza

> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xattr_acl.c                  |   95 +++++++++++++++++++++++++++++++++++++++
>  include/linux/posix_acl_xattr.h |    3 ++
>  2 files changed, 98 insertions(+)
> 
> diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
> index 9fbea87..932ec76 100644
> --- a/fs/xattr_acl.c
> +++ b/fs/xattr_acl.c
> @@ -10,6 +10,7 @@
>  #include <linux/posix_acl_xattr.h>
>  #include <linux/gfp.h>
>  #include <linux/user_namespace.h>
> +#include <linux/xattr.h>
>  
>  /*
>   * Fix up the uids and gids in posix acl extended attributes in place.
> @@ -178,3 +179,97 @@ posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl,
>  	return real_size;
>  }
>  EXPORT_SYMBOL (posix_acl_to_xattr);
> +
> +static int
> +posix_acl_xattr_get(struct dentry *dentry, const char *name,
> +		void *value, size_t size, int type)
> +{
> +	struct posix_acl *acl;
> +	int error;
> +
> +	if (!IS_POSIXACL(dentry->d_inode))
> +		return -EOPNOTSUPP;
> +
> +	acl = get_acl(dentry->d_inode, type);
> +	if (IS_ERR(acl))
> +		return PTR_ERR(acl);
> +	if (acl == NULL)
> +		return -ENODATA;
> +
> +	error = posix_acl_to_xattr(&init_user_ns, acl, value, size);
> +	posix_acl_release(acl);
> +
> +	return error;
> +}
> +
> +static int
> +posix_acl_xattr_set(struct dentry *dentry, const char *name,
> +		const void *value, size_t size, int flags, int type)
> +{
> +	struct inode *inode = dentry->d_inode;
> +	struct posix_acl *acl = NULL;
> +	int ret;
> +
> +	if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
> +		return value ? -EACCES : 0;
> +	if (!inode_owner_or_capable(inode))
> +		return -EPERM;
> +	if (!IS_POSIXACL(inode))
> +		return -EOPNOTSUPP;
> +
> +	if (value) {
> +		acl = posix_acl_from_xattr(&init_user_ns, value, size);
> +		if (IS_ERR(acl))
> +			return PTR_ERR(acl);
> +
> +		if (acl) {
> +			ret = posix_acl_valid(acl);
> +			if (ret)
> +				goto out;
> +		}
> +	}
> +
> +	ret = inode->i_op->set_acl(inode, acl, type);
> +out:
> +	posix_acl_release(acl);
> +	return ret;
> +}
> +
> +static size_t
> +posix_acl_xattr_list(struct dentry *dentry, char *list, size_t list_size,
> +		const char *name, size_t name_len, int type)
> +{
> +	const char *xname;
> +	size_t size;
> +
> +	if (!IS_POSIXACL(dentry->d_inode))
> +		return -EOPNOTSUPP;
> +
> +	if (type == ACL_TYPE_ACCESS)
> +		xname = POSIX_ACL_XATTR_ACCESS;
> +	else
> +		xname = POSIX_ACL_XATTR_DEFAULT;
> +
> +	size = strlen(xname) + 1;
> +	if (list && size <= list_size)
> +		memcpy(list, xname, size);
> +	return size;
> +}
> +
> +const struct xattr_handler posix_acl_access_xattr_handler = {
> +	.prefix = POSIX_ACL_XATTR_ACCESS,
> +	.flags = ACL_TYPE_ACCESS,
> +	.list = posix_acl_xattr_list,
> +	.get = posix_acl_xattr_get,
> +	.set = posix_acl_xattr_set,
> +};
> +EXPORT_SYMBOL_GPL(posix_acl_access_xattr_handler);
> +
> +const struct xattr_handler posix_acl_default_xattr_handler = {
> +	.prefix = POSIX_ACL_XATTR_DEFAULT,
> +	.flags = ACL_TYPE_DEFAULT,
> +	.list = posix_acl_xattr_list,
> +	.get = posix_acl_xattr_get,
> +	.set = posix_acl_xattr_set,
> +};
> +EXPORT_SYMBOL_GPL(posix_acl_default_xattr_handler);
> diff --git a/include/linux/posix_acl_xattr.h b/include/linux/posix_acl_xattr.h
> index ad93ad0..6f14ee2 100644
> --- a/include/linux/posix_acl_xattr.h
> +++ b/include/linux/posix_acl_xattr.h
> @@ -69,4 +69,7 @@ struct posix_acl *posix_acl_from_xattr(struct user_namespace *user_ns,
>  int posix_acl_to_xattr(struct user_namespace *user_ns,
>  		       const struct posix_acl *acl, void *buffer, size_t size);
>  
> +extern const struct xattr_handler posix_acl_access_xattr_handler;
> +extern const struct xattr_handler posix_acl_default_xattr_handler;
> +
>  #endif	/* _POSIX_ACL_XATTR_H */
> -- 
> 1.7.10.4
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2013-12-02 20:59 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-01 11:59 [PATCH 00/18] Consolidate Posix ACL implementation Christoph Hellwig
2013-12-01 11:59 ` [PATCH 01/18] reiserfs: prefix ACL symbols with reiserfs_ Christoph Hellwig
2013-12-02 20:15   ` Jan Kara
2013-12-01 11:59 ` [PATCH 02/18] fs: add get_acl helper Christoph Hellwig
2013-12-02 20:14   ` Jan Kara
2013-12-01 11:59 ` [PATCH 03/18] fs: add a set_acl inode operation Christoph Hellwig
2013-12-02 20:57   ` Jan Kara
2013-12-01 11:59 ` [PATCH 04/18] fs: add generic xattr_acl handlers Christoph Hellwig
2013-12-02 20:59   ` Jan Kara [this message]
2013-12-01 11:59 ` [PATCH 05/18] fs: make posix_acl_chmod more useful Christoph Hellwig
2013-12-02 21:09   ` Jan Kara
2013-12-01 11:59 ` [PATCH 06/18] fs: make posix_acl_create " Christoph Hellwig
2013-12-02 21:11   ` Jan Kara
2013-12-01 11:59 ` [PATCH 07/18] btrfs: use generic posix ACL infrastructure Christoph Hellwig
2013-12-01 11:59 ` [PATCH 08/18] ext2/3/4: " Christoph Hellwig
2013-12-02 22:13   ` Jan Kara
2013-12-02 22:18     ` [Jfs-discussion] " gary sheppard
2013-12-01 11:59 ` [PATCH 09/18] f2fs: " Christoph Hellwig
2013-12-06  1:37   ` Jaegeuk Kim
2013-12-08  9:14     ` Christoph Hellwig
2013-12-08 23:28       ` Jaegeuk Kim
2013-12-01 11:59 ` [PATCH 10/18] hfsplus: " Christoph Hellwig
2013-12-01 14:36   ` Vyacheslav Dubeyko
2013-12-01 11:59 ` [PATCH 11/18] jffs2: " Christoph Hellwig
2013-12-01 11:59 ` [PATCH 12/18] ocfs2: " Christoph Hellwig
2013-12-02 23:00   ` Jan Kara
2013-12-03 10:48     ` Christoph Hellwig
2013-12-01 11:59 ` [PATCH 13/18] reiserfs: " Christoph Hellwig
2013-12-02 22:17   ` Jan Kara
2013-12-01 11:59 ` [PATCH 14/18] xfs: " Christoph Hellwig
2013-12-02 23:34   ` Dave Chinner
2013-12-01 11:59 ` [PATCH 15/18] jfs: " Christoph Hellwig
2013-12-02 22:11   ` [Jfs-discussion] " Dave Kleikamp
2013-12-01 11:59 ` [PATCH 16/18] gfs2: " Christoph Hellwig
2013-12-04 12:12   ` [Cluster-devel] " Steven Whitehouse
2013-12-06 19:47     ` Christoph Hellwig
2013-12-01 11:59 ` [PATCH 17/18] nfs: use generic posix ACL infrastructure for v3 Posix ACLs Christoph Hellwig
2013-12-01 11:59 ` [PATCH 18/18] fs: remove generic_acl Christoph Hellwig
2013-12-05 17:57 ` [PATCH 00/18] Consolidate Posix ACL implementation Andreas Gruenbacher
2013-12-06 19:46   ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2013-12-11 10:42 [PATCH 00/18] Consolidate Posix ACL implementation V2 Christoph Hellwig
2013-12-11 10:42 ` [PATCH 04/18] fs: add generic xattr_acl handlers Christoph Hellwig
     [not found]   ` <20131211104527.044064384-PfSpb0PWhxZc2C7mugBRk2EX/6BAtgUQ@public.gmane.org>
2013-12-12 19:07     ` Andreas Gruenbacher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131202205932.GE12253@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=cluster-devel@redhat.com \
    --cc=hch@infradead.org \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=jlbec@evilplan.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=mfasheh@suse.com \
    --cc=reiserfs-devel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).