Skip to contentSkip to conversation

Make inode_ops->setxattr value parameter const (2.4.x + 2.5.x)

PATCH In review Andreas Gruenbacher 2 participants 2 messages Nov 20, 2002

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make inode_ops->setxattr value parameter const (2.4.x + 2.5.x)

Hello,

the setxattr inode operation is defined like this in 2.4 and 2.5:

	int (*setxattr) (struct dentry *dentry, const char *name,
			 void *value, size_t size, int flags);

the original type of the value parameter was `const void *'; the const obviously has been lost at some point. The definition should be:

	int (*setxattr) (struct dentry *dentry, const char *name,
			 const void *value, size_t size, int flags);

Please apply the attached patches.

Thanks,
Andreas.

------------------------------------------------------------------
Andreas Gruenbacher SuSE Linux AG
mailto:[email protected] Deutschherrnstr. 15-19
http://www.suse.de/ D-90429 Nuernberg, Germany

Make inode_ops->setxattr value parameter const

Add `const' to the value parameter definition of the setxattr inode operation and fix the resulting warnings in fs/jfs/xattr.c: File systems are not supposed to modify the value.

Also fixes the non-const usage in jfs, ext2, and ext3.

fs/ext2/xattr.c +1 -1
@@ -230,7 +230,7 @@
  */
 int
 ext2_setxattr(struct dentry *dentry, const char *name,
-	      void *value, size_t size, int flags)
+	      const void *value, size_t size, int flags)
 {
 	struct ext2_xattr_handler *handler;
 	struct inode *inode = dentry->d_inode;
fs/ext2/xattr.h +1 -1
@@ -67,7 +67,7 @@
 extern int ext2_xattr_register(int, struct ext2_xattr_handler *);
 extern void ext2_xattr_unregister(int, struct ext2_xattr_handler *);
 
-extern int ext2_setxattr(struct dentry *, const char *, void *, size_t, int);
+extern int ext2_setxattr(struct dentry *, const char *, const void *, size_t, int);
 extern ssize_t ext2_getxattr(struct dentry *, const char *, void *, size_t);
 extern ssize_t ext2_listxattr(struct dentry *, char *, size_t);
 extern int ext2_removexattr(struct dentry *, const char *);
fs/ext3/xattr.c +1 -1
@@ -223,7 +223,7 @@
  */
 int
 ext3_setxattr(struct dentry *dentry, const char *name,
-	      void *value, size_t size, int flags)
+	      const void *value, size_t size, int flags)
 {
 	struct ext3_xattr_handler *handler;
 	struct inode *inode = dentry->d_inode;
fs/ext3/xattr.h +1 -1
@@ -66,7 +66,7 @@
 extern int ext3_xattr_register(int, struct ext3_xattr_handler *);
 extern void ext3_xattr_unregister(int, struct ext3_xattr_handler *);
 
-extern int ext3_setxattr(struct dentry *, const char *, void *, size_t, int);
+extern int ext3_setxattr(struct dentry *, const char *, const void *, size_t, int);
 extern ssize_t ext3_getxattr(struct dentry *, const char *, void *, size_t);
 extern ssize_t ext3_listxattr(struct dentry *, char *, size_t);
 extern int ext3_removexattr(struct dentry *, const char *);
fs/jfs/jfs_xattr.h +3 -3
@@ -52,9 +52,9 @@
 #define	END_EALIST(ealist) \
 	((struct jfs_ea *) (((char *) (ealist)) + EALIST_SIZE(ealist)))
 
-extern int __jfs_setxattr(struct inode *, const char *, void *, size_t,
-			int);
-extern int jfs_setxattr(struct dentry *, const char *, void *, size_t,
+extern int __jfs_setxattr(struct inode *, const char *, const void *, size_t,
+			  int);
+extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t,
 			int);
 extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t);
 extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t);
fs/jfs/xattr.c +3 -3
@@ -706,7 +706,7 @@
 }
 
 static int can_set_xattr(struct inode *inode, const char *name,
-			 void *value, size_t value_len)
+			 const void *value, size_t value_len)
 {
 	if (IS_RDONLY(inode))
 		return -EROFS;
@@ -735,7 +735,7 @@
 #endif
 }
 
-int __jfs_setxattr(struct inode *inode, const char *name, void *value,
+int __jfs_setxattr(struct inode *inode, const char *name, const void *value,
 		   size_t value_len, int flags)
 {
 	struct jfs_ea_list *ealist;
@@ -874,7 +874,7 @@
 	return rc;
 }
 
-int jfs_setxattr(struct dentry *dentry, const char *name, void *value,
+int jfs_setxattr(struct dentry *dentry, const char *name, const void *value,
 		 size_t value_len, int flags)
 {
 	if (value == NULL) {	/* empty EA, do not remove */
include/linux/fs.h +1 -1
@@ -782,7 +782,7 @@
 	int (*permission) (struct inode *, int);
 	int (*setattr) (struct dentry *, struct iattr *);
 	int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
-	int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
+	int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
 	ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
 	ssize_t (*listxattr) (struct dentry *, char *, size_t);
 	int (*removexattr) (struct dentry *, const char *);

Make inode_ops->setxattr value parameter const

Add `const' to the value parameter definition of the setxattr inode operation and fix the resulting warnings in fs/jfs/xattr.c: File systems are not supposed to modify the value.

Also fixes the non-const usage in jfs.

include/linux/fs.h renamed from include/linux/fs.h~xattr-const +1 -1
@@ -866,7 +866,7 @@
 	int (*revalidate) (struct dentry *);
 	int (*setattr) (struct dentry *, struct iattr *);
 	int (*getattr) (struct dentry *, struct iattr *);
-	int (*setxattr) (struct dentry *, const char *, void *, size_t, int);
+	int (*setxattr) (struct dentry *, const char *, const void *, size_t, int);
 	ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t);
 	ssize_t (*listxattr) (struct dentry *, char *, size_t);
 	int (*removexattr) (struct dentry *, const char *);
fs/jfs/xattr.c renamed from fs/jfs/xattr.c~xattr-const +3 -3
@@ -641,7 +641,7 @@
 }
 
 static int can_set_xattr(struct inode *inode, const char *name,
-			 void *value, size_t value_len)
+			 const void *value, size_t value_len)
 {
 	if (IS_RDONLY(inode))
 		return -EROFS;
@@ -660,7 +660,7 @@
 	return permission(inode, MAY_WRITE);
 }
 
-int __jfs_setxattr(struct inode *inode, const char *name, void *value,
+int __jfs_setxattr(struct inode *inode, const char *name, const void *value,
 		   size_t value_len, int flags)
 {
 	struct jfs_ea_list *ealist;
@@ -799,7 +799,7 @@
 	return rc;
 }
 
-int jfs_setxattr(struct dentry *dentry, const char *name, void *value,
+int jfs_setxattr(struct dentry *dentry, const char *name, const void *value,
 		 size_t value_len, int flags)
 {
 	if (value == NULL) {	/* empty EA, do not remove */
fs/jfs/jfs_xattr.h renamed from fs/jfs/jfs_xattr.h~xattr-const +4 -2
@@ -52,8 +52,10 @@
 #define	END_EALIST(ealist) \
 	((struct jfs_ea *) (((char *) (ealist)) + EALIST_SIZE(ealist)))
 
-extern int __jfs_setxattr(struct inode *, const char *, void *, size_t, int);
-extern int jfs_setxattr(struct dentry *, const char *, void *, size_t, int);
+extern int __jfs_setxattr(struct inode *, const char *, const void *, size_t,
+			  int);
+extern int jfs_setxattr(struct dentry *, const char *, const void *, size_t,
+			int);
 extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t);
 extern ssize_t jfs_getxattr(struct dentry *, const char *, void *, size_t);
 extern ssize_t jfs_listxattr(struct dentry *, char *, size_t);

_

#1 lore raw
Quoted 1 line · Andreas Gruenbacher

Please apply the attached patches.

Andreas,
Please send the patches separately to Linus and Marcelo. I know Linus doesn't like patches as attachements, especially when mail contains two different patches, only one of which he can apply. (Think about saving the email to a file and running patch against it.)

Otherwise, the patches look good to me.

Thanks,
Shaggy

Signature · 2 lines
David Kleikamp
IBM Linux Technology Center