From 03cebaef615f9098d030ba776c124fa5f27d5c74 Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Wed, 31 Mar 2004 10:19:18 +0000 Subject: fix zero size case for getxattr and listxattr --- example/fusexmp.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) (limited to 'example/fusexmp.c') diff --git a/example/fusexmp.c b/example/fusexmp.c index 3c1b601..5d972a8 100644 --- a/example/fusexmp.c +++ b/example/fusexmp.c @@ -6,6 +6,8 @@ See the file COPYING. */ +#include + #ifdef linux /* For pread()/pwrite() */ #define _XOPEN_SOURCE 500 @@ -19,6 +21,9 @@ #include #include #include +#ifdef HAVE_SETXATTR +#include +#endif static int xmp_getattr(const char *path, struct stat *stbuf) { @@ -264,6 +269,43 @@ static int xmp_fsync(const char *path, int isdatasync) return 0; } +#ifdef HAVE_SETXATTR +/* xattr operations are optional and can safely be left unimplemented */ +static int xmp_setxattr(const char *path, const char *name, const char *value, + size_t size, int flags) +{ + int res = lsetxattr(path, name, value, size, flags); + if(res == -1) + return -errno; + return 0; +} + +static int xmp_getxattr(const char *path, const char *name, char *value, + size_t size) +{ + int res = lgetxattr(path, name, value, size); + if(res == -1) + return -errno; + return res; +} + +static int xmp_listxattr(const char *path, char *list, size_t size) +{ + int res = llistxattr(path, list, size); + if(res == -1) + return -errno; + return res; +} + +static int xmp_removexattr(const char *path, const char *name) +{ + int res = lremovexattr(path, name); + if(res == -1) + return -errno; + return 0; +} +#endif /* HAVE_SETXATTR */ + static struct fuse_operations xmp_oper = { .getattr = xmp_getattr, .readlink = xmp_readlink, @@ -284,7 +326,13 @@ static struct fuse_operations xmp_oper = { .write = xmp_write, .statfs = xmp_statfs, .release = xmp_release, - .fsync = xmp_fsync + .fsync = xmp_fsync, +#ifdef HAVE_SETXATTR + .setxattr = xmp_setxattr, + .getxattr = xmp_getxattr, + .listxattr = xmp_listxattr, + .removexattr= xmp_removexattr, +#endif }; int main(int argc, char *argv[]) -- cgit v1.2.3