Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: xattr_handler table should be const

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>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

authored by

Stephen Hemminger and committed by
Al Viro
bb435453 18e9e510

+15 -15
+2 -2
fs/generic_acl.c
··· 201 201 return -EAGAIN; 202 202 } 203 203 204 - struct xattr_handler generic_acl_access_handler = { 204 + const struct xattr_handler generic_acl_access_handler = { 205 205 .prefix = POSIX_ACL_XATTR_ACCESS, 206 206 .flags = ACL_TYPE_ACCESS, 207 207 .list = generic_acl_list, ··· 209 209 .set = generic_acl_set, 210 210 }; 211 211 212 - struct xattr_handler generic_acl_default_handler = { 212 + const struct xattr_handler generic_acl_default_handler = { 213 213 .prefix = POSIX_ACL_XATTR_DEFAULT, 214 214 .flags = ACL_TYPE_DEFAULT, 215 215 .list = generic_acl_list,
+7 -7
fs/xattr.c
··· 590 590 /* 591 591 * Find the xattr_handler with the matching prefix. 592 592 */ 593 - static struct xattr_handler * 594 - xattr_resolve_name(struct xattr_handler **handlers, const char **name) 593 + static const struct xattr_handler * 594 + xattr_resolve_name(const struct xattr_handler **handlers, const char **name) 595 595 { 596 - struct xattr_handler *handler; 596 + const struct xattr_handler *handler; 597 597 598 598 if (!*name) 599 599 return NULL; ··· 614 614 ssize_t 615 615 generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) 616 616 { 617 - struct xattr_handler *handler; 617 + const struct xattr_handler *handler; 618 618 619 619 handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); 620 620 if (!handler) ··· 629 629 ssize_t 630 630 generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) 631 631 { 632 - struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; 632 + const struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; 633 633 unsigned int size = 0; 634 634 635 635 if (!buffer) { ··· 659 659 int 660 660 generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) 661 661 { 662 - struct xattr_handler *handler; 662 + const struct xattr_handler *handler; 663 663 664 664 if (size == 0) 665 665 value = ""; /* empty EA, do not remove */ ··· 676 676 int 677 677 generic_removexattr(struct dentry *dentry, const char *name) 678 678 { 679 - struct xattr_handler *handler; 679 + const struct xattr_handler *handler; 680 680 681 681 handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); 682 682 if (!handler)
+1 -1
include/linux/fs.h
··· 1336 1336 #ifdef CONFIG_SECURITY 1337 1337 void *s_security; 1338 1338 #endif 1339 - struct xattr_handler **s_xattr; 1339 + const struct xattr_handler **s_xattr; 1340 1340 1341 1341 struct list_head s_inodes; /* all inodes */ 1342 1342 struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */
+2 -2
include/linux/generic_acl.h
··· 5 5 6 6 struct inode; 7 7 8 - extern struct xattr_handler generic_acl_access_handler; 9 - extern struct xattr_handler generic_acl_default_handler; 8 + extern const struct xattr_handler generic_acl_access_handler; 9 + extern const struct xattr_handler generic_acl_default_handler; 10 10 11 11 int generic_acl_init(struct inode *, struct inode *); 12 12 int generic_acl_chmod(struct inode *);
+1 -1
include/linux/xattr.h
··· 37 37 struct dentry; 38 38 39 39 struct xattr_handler { 40 - char *prefix; 40 + const char *prefix; 41 41 int flags; /* fs private flags passed back to the handlers */ 42 42 size_t (*list)(struct dentry *dentry, char *list, size_t list_size, 43 43 const char *name, size_t name_len, int handler_flags);
+2 -2
mm/shmem.c
··· 2071 2071 size, flags); 2072 2072 } 2073 2073 2074 - static struct xattr_handler shmem_xattr_security_handler = { 2074 + static const struct xattr_handler shmem_xattr_security_handler = { 2075 2075 .prefix = XATTR_SECURITY_PREFIX, 2076 2076 .list = shmem_xattr_security_list, 2077 2077 .get = shmem_xattr_security_get, 2078 2078 .set = shmem_xattr_security_set, 2079 2079 }; 2080 2080 2081 - static struct xattr_handler *shmem_xattr_handlers[] = { 2081 + static const struct xattr_handler *shmem_xattr_handlers[] = { 2082 2082 &generic_acl_access_handler, 2083 2083 &generic_acl_default_handler, 2084 2084 &shmem_xattr_security_handler,