Skip to content

Commit bb43545

Browse files
Stephen HemmingerAl Viro
authored andcommitted
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>
1 parent 18e9e51 commit bb43545

6 files changed

Lines changed: 15 additions & 15 deletions

File tree

‎fs/generic_acl.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,15 @@ generic_check_acl(struct inode *inode, int mask)
201201
return -EAGAIN;
202202
}
203203

204-
struct xattr_handler generic_acl_access_handler = {
204+
const struct xattr_handler generic_acl_access_handler = {
205205
.prefix = POSIX_ACL_XATTR_ACCESS,
206206
.flags = ACL_TYPE_ACCESS,
207207
.list = generic_acl_list,
208208
.get = generic_acl_get,
209209
.set = generic_acl_set,
210210
};
211211

212-
struct xattr_handler generic_acl_default_handler = {
212+
const struct xattr_handler generic_acl_default_handler = {
213213
.prefix = POSIX_ACL_XATTR_DEFAULT,
214214
.flags = ACL_TYPE_DEFAULT,
215215
.list = generic_acl_list,

‎fs/xattr.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,10 @@ strcmp_prefix(const char *a, const char *a_prefix)
590590
/*
591591
* Find the xattr_handler with the matching prefix.
592592
*/
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)
595595
{
596-
struct xattr_handler *handler;
596+
const struct xattr_handler *handler;
597597

598598
if (!*name)
599599
return NULL;
@@ -614,7 +614,7 @@ xattr_resolve_name(struct xattr_handler **handlers, const char **name)
614614
ssize_t
615615
generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size)
616616
{
617-
struct xattr_handler *handler;
617+
const struct xattr_handler *handler;
618618

619619
handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
620620
if (!handler)
@@ -629,7 +629,7 @@ generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t s
629629
ssize_t
630630
generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
631631
{
632-
struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr;
632+
const struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr;
633633
unsigned int size = 0;
634634

635635
if (!buffer) {
@@ -659,7 +659,7 @@ generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
659659
int
660660
generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags)
661661
{
662-
struct xattr_handler *handler;
662+
const struct xattr_handler *handler;
663663

664664
if (size == 0)
665665
value = ""; /* empty EA, do not remove */
@@ -676,7 +676,7 @@ generic_setxattr(struct dentry *dentry, const char *name, const void *value, siz
676676
int
677677
generic_removexattr(struct dentry *dentry, const char *name)
678678
{
679-
struct xattr_handler *handler;
679+
const struct xattr_handler *handler;
680680

681681
handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
682682
if (!handler)

‎include/linux/fs.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,7 @@ struct super_block {
13361336
#ifdef CONFIG_SECURITY
13371337
void *s_security;
13381338
#endif
1339-
struct xattr_handler **s_xattr;
1339+
const struct xattr_handler **s_xattr;
13401340

13411341
struct list_head s_inodes; /* all inodes */
13421342
struct hlist_head s_anon; /* anonymous dentries for (nfs) exporting */

‎include/linux/generic_acl.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
struct inode;
77

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;
1010

1111
int generic_acl_init(struct inode *, struct inode *);
1212
int generic_acl_chmod(struct inode *);

‎include/linux/xattr.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct inode;
3737
struct dentry;
3838

3939
struct xattr_handler {
40-
char *prefix;
40+
const char *prefix;
4141
int flags; /* fs private flags passed back to the handlers */
4242
size_t (*list)(struct dentry *dentry, char *list, size_t list_size,
4343
const char *name, size_t name_len, int handler_flags);

‎mm/shmem.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,14 +2071,14 @@ static int shmem_xattr_security_set(struct dentry *dentry, const char *name,
20712071
size, flags);
20722072
}
20732073

2074-
static struct xattr_handler shmem_xattr_security_handler = {
2074+
static const struct xattr_handler shmem_xattr_security_handler = {
20752075
.prefix = XATTR_SECURITY_PREFIX,
20762076
.list = shmem_xattr_security_list,
20772077
.get = shmem_xattr_security_get,
20782078
.set = shmem_xattr_security_set,
20792079
};
20802080

2081-
static struct xattr_handler *shmem_xattr_handlers[] = {
2081+
static const struct xattr_handler *shmem_xattr_handlers[] = {
20822082
&generic_acl_access_handler,
20832083
&generic_acl_default_handler,
20842084
&shmem_xattr_security_handler,

0 commit comments

Comments
 (0)