All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH 01/10] fs: xattr_handler table should be const
Date: Thu, 13 May 2010 17:53:14 -0700	[thread overview]
Message-ID: <20100514005408.574230076@vyatta.com> (raw)
In-Reply-To: 20100514005313.884038885@vyatta.com

[-- Attachment #1: xattr-handler-const.patch --]
[-- Type: text/plain, Size: 5174 bytes --]

The entries in xattr handler table should be immutable (ie const)
like other operation tables.

Later patches convert common filesystems. Uncoverted filesystems
will still work, but will generate a compiler warning.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>


---
 fs/generic_acl.c            |    4 ++--
 fs/xattr.c                  |   14 +++++++-------
 include/linux/fs.h          |    2 +-
 include/linux/generic_acl.h |    4 ++--
 include/linux/xattr.h       |    2 +-
 mm/shmem.c                  |    4 ++--
 6 files changed, 15 insertions(+), 15 deletions(-)

--- a/include/linux/xattr.h	2010-05-13 16:34:05.403477486 -0700
+++ b/include/linux/xattr.h	2010-05-13 16:34:14.452532499 -0700
@@ -37,7 +37,7 @@ struct inode;
 struct dentry;
 
 struct xattr_handler {
-	char *prefix;
+	const char *prefix;
 	int flags;	/* fs private flags passed back to the handlers */
 	size_t (*list)(struct dentry *dentry, char *list, size_t list_size,
 		       const char *name, size_t name_len, int handler_flags);
--- a/include/linux/fs.h	2010-05-13 16:44:51.284126558 -0700
+++ b/include/linux/fs.h	2010-05-13 16:45:08.952534280 -0700
@@ -1339,7 +1339,7 @@ struct super_block {
 #ifdef CONFIG_SECURITY
 	void                    *s_security;
 #endif
-	struct xattr_handler	**s_xattr;
+	const struct xattr_handler **s_xattr;
 
 	struct list_head	s_inodes;	/* all inodes */
 	struct hlist_head	s_anon;		/* anonymous dentries for (nfs) exporting */
--- a/fs/generic_acl.c	2010-05-13 16:54:53.934439088 -0700
+++ b/fs/generic_acl.c	2010-05-13 16:55:13.842844638 -0700
@@ -201,7 +201,7 @@ generic_check_acl(struct inode *inode, i
 	return -EAGAIN;
 }
 
-struct xattr_handler generic_acl_access_handler = {
+const struct xattr_handler generic_acl_access_handler = {
 	.prefix = POSIX_ACL_XATTR_ACCESS,
 	.flags	= ACL_TYPE_ACCESS,
 	.list	= generic_acl_list,
@@ -209,7 +209,7 @@ struct xattr_handler generic_acl_access_
 	.set	= generic_acl_set,
 };
 
-struct xattr_handler generic_acl_default_handler = {
+const struct xattr_handler generic_acl_default_handler = {
 	.prefix = POSIX_ACL_XATTR_DEFAULT,
 	.flags	= ACL_TYPE_DEFAULT,
 	.list	= generic_acl_list,
--- a/include/linux/generic_acl.h	2010-05-13 16:55:34.073187417 -0700
+++ b/include/linux/generic_acl.h	2010-05-13 16:55:41.652531852 -0700
@@ -5,8 +5,8 @@
 
 struct inode;
 
-extern struct xattr_handler generic_acl_access_handler;
-extern struct xattr_handler generic_acl_default_handler;
+extern const struct xattr_handler generic_acl_access_handler;
+extern const struct xattr_handler generic_acl_default_handler;
 
 int generic_acl_init(struct inode *, struct inode *);
 int generic_acl_chmod(struct inode *);
--- a/mm/shmem.c	2010-05-13 16:56:02.543789782 -0700
+++ b/mm/shmem.c	2010-05-13 16:56:23.162842856 -0700
@@ -2071,14 +2071,14 @@ static int shmem_xattr_security_set(stru
 					  size, flags);
 }
 
-static struct xattr_handler shmem_xattr_security_handler = {
+static const struct xattr_handler shmem_xattr_security_handler = {
 	.prefix = XATTR_SECURITY_PREFIX,
 	.list   = shmem_xattr_security_list,
 	.get    = shmem_xattr_security_get,
 	.set    = shmem_xattr_security_set,
 };
 
-static struct xattr_handler *shmem_xattr_handlers[] = {
+static const struct xattr_handler *shmem_xattr_handlers[] = {
 	&generic_acl_access_handler,
 	&generic_acl_default_handler,
 	&shmem_xattr_security_handler,
--- a/fs/xattr.c	2010-05-13 17:05:50.124699014 -0700
+++ b/fs/xattr.c	2010-05-13 17:09:58.074182182 -0700
@@ -590,10 +590,10 @@ strcmp_prefix(const char *a, const char 
 /*
  * Find the xattr_handler with the matching prefix.
  */
-static struct xattr_handler *
-xattr_resolve_name(struct xattr_handler **handlers, const char **name)
+static const struct xattr_handler *
+xattr_resolve_name(const struct xattr_handler **handlers, const char **name)
 {
-	struct xattr_handler *handler;
+	const struct xattr_handler *handler;
 
 	if (!*name)
 		return NULL;
@@ -614,7 +614,7 @@ xattr_resolve_name(struct xattr_handler 
 ssize_t
 generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size)
 {
-	struct xattr_handler *handler;
+	const struct xattr_handler *handler;
 
 	handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
 	if (!handler)
@@ -629,7 +629,7 @@ generic_getxattr(struct dentry *dentry, 
 ssize_t
 generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
-	struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr;
+	const struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr;
 	unsigned int size = 0;
 
 	if (!buffer) {
@@ -659,7 +659,7 @@ generic_listxattr(struct dentry *dentry,
 int
 generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
 {
-	struct xattr_handler *handler;
+	const struct xattr_handler *handler;
 
 	if (size == 0)
 		value = "";  /* empty EA, do not remove */
@@ -676,7 +676,7 @@ generic_setxattr(struct dentry *dentry, 
 int
 generic_removexattr(struct dentry *dentry, const char *name)
 {
-	struct xattr_handler *handler;
+	const struct xattr_handler *handler;
 
 	handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
 	if (!handler)



  reply	other threads:[~2010-05-14  2:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-14  0:53 [PATCH 00/10] Make xattr_handler constant patches Stephen Hemminger
2010-05-14  0:53 ` Stephen Hemminger [this message]
2010-05-14  0:53 ` [PATCH 02/10] btrfs: constify xattr_handler Stephen Hemminger
2010-05-14  0:53 ` [PATCH 03/10] ext2: " Stephen Hemminger
2010-05-14  0:53 ` [PATCH 04/10] Subject ext3: constify xattr handlers Stephen Hemminger
2010-05-14  0:53 ` [PATCH 05/10] ext4: constify xattr_handler Stephen Hemminger
2010-05-14  0:53 ` [PATCH 06/10] reiserfs: " Stephen Hemminger
2010-05-14  0:53 ` [PATCH 07/10] xfs: " Stephen Hemminger
2010-05-14  0:53 ` [PATCH 08/10] jffs2: " Stephen Hemminger
2010-05-14  0:53 ` [PATCH 09/10] ocfs: " Stephen Hemminger
2010-05-14  0:53 ` [PATCH 10/10] gfs: " Stephen Hemminger

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=20100514005408.574230076@vyatta.com \
    --to=shemminger@vyatta.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.