diff options
author | Vikas Gorur <vikas@gluster.com> | 2009-03-16 04:03:55 -0700 |
---|---|---|
committer | Anand V. Avati <avati@amp.gluster.com> | 2009-03-17 17:15:07 +0530 |
commit | 3099d29e8e65554af31927c8f767b9b6103ca58e (patch) | |
tree | 0f9aef0dd519a591f3129871281ef248082f19d4 /libglusterfs/src/compat.c | |
parent | 7d61f9d69309ccb0f9aa787caacfef77bc4e32d2 (diff) |
Add system call abstraction layer
- syscall.c provides platform-independent system calls
- previous code for this from compat.c removed
- posix xlator uses new functions from syscall.c
- solaris_flistxattr added to compat.c
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'libglusterfs/src/compat.c')
-rw-r--r-- | libglusterfs/src/compat.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/libglusterfs/src/compat.c b/libglusterfs/src/compat.c index f0bd9119c7c..bad62b563d5 100644 --- a/libglusterfs/src/compat.c +++ b/libglusterfs/src/compat.c @@ -264,6 +264,61 @@ solaris_listxattr(const char *path, return len; } + +int +solaris_flistxattr(int fd, + char *list, + size_t size) +{ + int attrdirfd = -1; + ssize_t len = 0; + DIR *dirptr = NULL; + struct dirent *dent = NULL; + int newfd = -1; + + attrdirfd = openat (fd, ".", O_RDONLY, 0); + if (attrdirfd >= 0) { + newfd = dup(attrdirfd); + dirptr = fdopendir(newfd); + if (dirptr) { + while ((dent = readdir(dirptr))) { + size_t listlen = strlen(dent->d_name); + if (!strcmp(dent->d_name, ".") || !strcmp(dent->d_name, "..")) { + /* we don't want "." and ".." here */ + continue; + } + if (size == 0) { + /* return the current size of the list of extended attribute names*/ + len += listlen + 1; + } else { + /* check size and copy entrie + nul into list. */ + if ((len + listlen + 1) > size) { + errno = ERANGE; + len = -1; + break; + } else { + strncpy(list + len, dent->d_name, listlen); + len += listlen; + list[len] = '\0'; + ++len; + } + } + } + + if (closedir(dirptr) == -1) { + close (attrdirfd); + return -1; + } + } else { + close (attrdirfd); + return -1; + } + close (attrdirfd); + } + return len; +} + + int solaris_removexattr(const char *path, const char* key) |