lkml.org 
[lkml]   [2003]   [Aug]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
Date
From
Subject[PATCH] 2.4.22pre10+aa: XFS has it right, setxattr() takes "const void *"
It seems that the XFS developers have the right idea about setxattr(),
namely that it should take a "const void *" parameter for the attributes
it will set, rather than "void *".

This patch Makes It So. It is in some sense only cosmetic, since the
generated code is the same, but the usage of const is a Good Thing for
this kind of interface.

PS: I created the patch against 2.4.20pre10 plus many of the patches
in the 'aa' tree, so perhaps it should be taken as more of a suggested
idea rather than a literal patch.


Index: linux/fs/befs/linuxvfs.c
--- linux/fs/befs/linuxvfs.c.old 2003-06-13 10:51:37.000000000 -0400
+++ linux/fs/befs/linuxvfs.c 2003-08-04 12:34:02.000000000 -0400
@@ -59,5 +59,5 @@
static ssize_t befs_getxattr(struct dentry *dentry, const char *name,
void *buffer, size_t size);
-static int befs_setxattr(struct dentry *dentry, const char *name, void *value,
+static int befs_setxattr(struct dentry *dentry, const char *name, const void *value,
size_t size, int flags);
static int befs_removexattr(struct dentry *dentry, const char *name);
@@ -694,5 +694,5 @@
static int
befs_setxattr(struct dentry *dentry, const char *name,
- void *value, size_t size, int flags)
+ const void *value, size_t size, int flags)
{
return 0;
Index: linux/fs/jfs/jfs_xattr.h
--- linux/fs/jfs/jfs_xattr.h.old 2002-11-28 18:53:15.000000000 -0500
+++ linux/fs/jfs/jfs_xattr.h 2003-08-04 12:33:53.000000000 -0400
@@ -53,6 +53,6 @@
((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);
Index: linux/fs/jfs/xattr.c
--- linux/fs/jfs/xattr.c.old 2002-11-28 18:53:15.000000000 -0500
+++ linux/fs/jfs/xattr.c 2003-08-04 12:33:44.000000000 -0400
@@ -661,5 +661,5 @@
}

-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)
{
@@ -800,5 +800,5 @@
}

-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)
{
Index: linux/fs/xattr.c
--- linux/fs/xattr.c.old 2002-11-28 18:53:15.000000000 -0500
+++ linux/fs/xattr.c 2003-08-04 12:33:15.000000000 -0400
@@ -59,5 +59,5 @@
*/
static long
-setxattr(struct dentry *d, char *name, void *value, size_t size, int flags)
+setxattr(struct dentry *d, char *name, const void *value, size_t size, int flags)
{
int error;
@@ -97,5 +97,5 @@

asmlinkage long
-sys_setxattr(char *path, char *name, void *value, size_t size, int flags)
+sys_setxattr(char *path, char *name, const void *value, size_t size, int flags)
{
struct nameidata nd;
@@ -111,5 +111,5 @@

asmlinkage long
-sys_lsetxattr(char *path, char *name, void *value, size_t size, int flags)
+sys_lsetxattr(char *path, char *name, const void *value, size_t size, int flags)
{
struct nameidata nd;
@@ -125,5 +125,5 @@

asmlinkage long
-sys_fsetxattr(int fd, char *name, void *value, size_t size, int flags)
+sys_fsetxattr(int fd, char *name, const void *value, size_t size, int flags)
{
struct file *f;
Index: linux/include/linux/fs.h
--- linux/include/linux/fs.h.old 2003-08-04 12:18:32.000000000 -0400
+++ linux/include/linux/fs.h 2003-08-04 12:34:37.000000000 -0400
@@ -990,5 +990,5 @@
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);


--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
"I wanted to play hopscotch with the impenetrable mystery of existence,
but he stepped in a wormhole and had to go in early." // MST3K
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:47    [W:0.068 / U:0.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site