You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(23) |
Sep
(3) |
Oct
(28) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
|
Mar
|
Apr
(12) |
May
(11) |
Jun
(4) |
Jul
(5) |
Aug
(4) |
Sep
|
Oct
|
Nov
(7) |
Dec
(6) |
2008 |
Jan
(8) |
Feb
(5) |
Mar
|
Apr
(5) |
May
(1) |
Jun
(1) |
Jul
(4) |
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
(7) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Richard D. <ric...@us...> - 2006-10-02 20:30:12
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv27138 Modified Files: extattr_macosx.c Log Message: Add prototype Mac OS X support for *listxattr Index: extattr_macosx.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_macosx.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** extattr_macosx.c 2 Oct 2006 20:05:22 -0000 1.2 --- extattr_macosx.c 2 Oct 2006 20:30:09 -0000 1.3 *************** *** 167,172 **** struct hv *flags) { ! /* FIXME */ ! return listxattr(path, buf, buflen, 0 /* XXX: flags? */); } --- 167,183 ---- struct hv *flags) { ! int ok = 1; ! int ret = -1; ! ! if (!File_ExtAttr_valid_default_namespace(flags)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! ret = listxattr(path, buf, buflen, 0 /* XXX: flags? */); ! ! return ok ? ret : -1; } *************** *** 177,182 **** struct hv *flags) { ! /* FIXME */ ! return flistxattr(fd, buf, buflen, 0 /* XXX: flags? */); } --- 188,204 ---- struct hv *flags) { ! int ok = 1; ! int ret = -1; ! ! if (!File_ExtAttr_valid_default_namespace(flags)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! ret = flistxattr(fd, buf, buflen, 0 /* XXX: flags? */); ! ! return ok ? ret : -1; } |
From: Richard D. <ric...@us...> - 2006-10-02 20:27:16
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv25949 Modified Files: extattr_linux.c Log Message: Linux *listxattr with namespace awareness Index: extattr_linux.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_linux.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** extattr_linux.c 2 Oct 2006 20:05:22 -0000 1.6 --- extattr_linux.c 2 Oct 2006 20:27:13 -0000 1.7 *************** *** 74,92 **** { char *res = NULL; ! char *ns; size_t reslen; ! ns = flags2namespace(flags); ! if (ns) { ! reslen = strlen(ns) + strlen(attrname) + 2; /* ns + "." + attrname + nul */ res = malloc(reslen); } if (res) ! snprintf(res, reslen, "%s.%s", ns, attrname); ! if (ns) ! free(ns); return res; --- 74,92 ---- { char *res = NULL; ! char *pNS; size_t reslen; ! pNS = flags2namespace(flags); ! if (pNS) { ! reslen = strlen(pNS) + strlen(attrname) + 2; /* pNS + "." + attrname + nul */ res = malloc(reslen); } if (res) ! snprintf(res, reslen, "%s.%s", pNS, attrname); ! if (pNS) ! free(pNS); return res; *************** *** 261,305 **** } - ssize_t - linux_listxattr (const char *path, - char *buf, - const size_t buflen, - struct hv *flags) - { - #if 0 - /* XXX: We need some kind of hash returned here: { namespace => attrname } */ - int ret; - char *q; - - /* XXX: Other flags? */ - q = qualify_attrname(attrname, flags); - if (q) - { - ret = listxattr(path, buf, buflen); - free(q); - } - else - { - ret = -1; - errno = ENOMEM; - } - - return ret; - #else - return listxattr(path, buf, buflen); - #endif - } - - ssize_t - linux_flistxattr (const int fd, - char *buf, - const size_t buflen, - struct hv *flags) - { - return flistxattr(fd, buf, buflen); - } - static ssize_t ! attrlist2nslist (char *sbuf, const size_t slen, char *buf, const size_t buflen) { ssize_t sbuiltlen = 0; --- 261,268 ---- } static ssize_t ! attrlist2list (char *sbuf, const size_t slen, ! char *buf, const size_t buflen, ! const int iWantNames, const char *pWantNS) { ssize_t sbuiltlen = 0; *************** *** 309,328 **** for (spos = 0; (spos < slen); ) { ! char *pns, *pval; /* Get the namespace. */ ! pns = &sbuf[spos]; ! pval = strchr(pns, '.'); ! if (!pval) break; /* Point spos at the next attribute. */ ! spos += strlen(pval) + 1; ! /* Check we haven't already seen this namespace. */ ! *pval = '\0'; ! ++pval; ! if (memstr(sbuf, pns, sbuiltlen) != NULL) ! continue; /* --- 272,308 ---- for (spos = 0; (spos < slen); ) { ! char *pNS, *pname, *psrc; /* Get the namespace. */ ! pNS = &sbuf[spos]; ! pname = strchr(pNS, '.'); ! if (!pname) break; /* Point spos at the next attribute. */ ! spos += strlen(pNS) + 1; ! *pname = '\0'; ! ++pname; ! ! if (iWantNames) ! { ! psrc = pname; ! ! /* Name list wanted. Check this is in the right namespace. */ ! if (strcmp(pNS, pWantNS) != 0) ! continue; ! } ! else ! { ! psrc = pNS; ! ! /* ! * Namespace list wanted. Check we haven't already seen ! * this namespace. ! */ ! if (memstr(sbuf, pNS, sbuiltlen) != NULL) ! continue; ! } /* *************** *** 331,336 **** * We shift the namespaces from the list to the start of the buffer. */ ! memmove(&sbuf[sbuiltlen], pns, strlen(pns) + 1 /* nul */); ! sbuiltlen += strlen(pns) + 1; } --- 311,316 ---- * We shift the namespaces from the list to the start of the buffer. */ ! memmove(&sbuf[sbuiltlen], psrc, strlen(psrc) + 1 /* nul */); ! sbuiltlen += strlen(psrc) + 1; } *************** *** 354,358 **** --- 334,450 ---- } + /* XXX: More common code below */ /* XXX: Just return a Perl list? */ + + ssize_t + linux_listxattr (const char *path, + char *buf, + const size_t buflen, + struct hv *flags) + { + char *pNS; + ssize_t ret = 0; + + pNS = flags2namespace(flags); + if (!pNS) + { + ret = -1; + errno = ENOMEM; + } + + /* + * Get a buffer of nul-delimited "namespace.attribute"s, + * then extract the attributes into buf. + */ + if (ret == 0) + { + ssize_t slen; + + slen = listxattr(path, buf, 0); + if (slen >= 0) + { + char *sbuf; + + sbuf = malloc(slen); + if (sbuf) + slen = listxattr(path, sbuf, slen); + else + ret = -1; + + if (slen) + ret = attrlist2list(sbuf, slen, buf, buflen, 1, pNS); + else + ret = slen; + + if (sbuf) + free(sbuf); + } + else + { + ret = slen; + } + } + + if (pNS) + free(pNS); + + return ret; + } + + ssize_t + linux_flistxattr (const int fd, + char *buf, + const size_t buflen, + struct hv *flags) + { + char *pNS; + ssize_t ret = 0; + + pNS = flags2namespace(flags); + if (!pNS) + { + ret = -1; + errno = ENOMEM; + } + + /* + * Get a buffer of nul-delimited "namespace.attribute"s, + * then extract the attributes into buf. + */ + if (ret == 0) + { + ssize_t slen; + + slen = flistxattr(fd, buf, 0); + if (slen >= 0) + { + char *sbuf; + + sbuf = malloc(slen); + if (sbuf) + slen = flistxattr(fd, sbuf, slen); + else + ret = -1; + + if (slen) + ret = attrlist2list(sbuf, slen, buf, buflen, 1, pNS); + else + ret = slen; + + if (sbuf) + free(sbuf); + } + else + { + ret = slen; + } + } + + if (pNS) + free(pNS); + + return ret; + } + ssize_t linux_listxattrns (const char *path, *************** *** 380,384 **** if (slen) ! ret = attrlist2nslist(sbuf, slen, buf, buflen); else ret = slen; --- 472,476 ---- if (slen) ! ret = attrlist2list(sbuf, slen, buf, buflen, 0, NULL); else ret = slen; *************** *** 420,424 **** if (slen) ! ret = attrlist2nslist(sbuf, slen, buf, buflen); else ret = slen; --- 512,516 ---- if (slen) ! ret = attrlist2list(sbuf, slen, buf, buflen, 0, NULL); else ret = slen; |
From: Richard D. <ric...@us...> - 2006-10-02 20:05:27
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv17403 Modified Files: extattr_bsd.c extattr_linux.c extattr_macosx.c extattr_macosx.h extattr_solaris.c flags.c flags.h Log Message: Add prototype Mac OS X support for listxattrns; factor out common code for ns for Solaris & Mac OS X Index: extattr_linux.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_linux.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** extattr_linux.c 1 Oct 2006 11:18:54 -0000 1.5 --- extattr_linux.c 2 Oct 2006 20:05:22 -0000 1.6 *************** *** 44,48 **** flags2namespace (struct hv *flags) { ! static const char NAMESPACE_DEFAULT[] = "user"; const size_t NAMESPACE_KEYLEN = strlen(NAMESPACE_KEY); SV **psv_ns; --- 44,48 ---- flags2namespace (struct hv *flags) { ! const char *NAMESPACE_DEFAULT = NAMESPACE_USER; const size_t NAMESPACE_KEYLEN = strlen(NAMESPACE_KEY); SV **psv_ns; Index: extattr_macosx.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_macosx.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** extattr_macosx.c 1 Oct 2006 08:18:49 -0000 1.1 --- extattr_macosx.c 2 Oct 2006 20:05:22 -0000 1.2 *************** *** 181,183 **** --- 181,211 ---- } + ssize_t + macosx_listxattrns (const char *path, + char *buf, + const size_t buflen, + struct hv *flags) + { + ssize_t ret = listxattr(path, NULL, 0, 0 /* XXX: flags? */); + + if (ret > 0) + ret = File_ExtAttr_default_listxattrns(buf, buflen); + + return ret; + } + + ssize_t + macosx_flistxattrns (const int fd, + char *buf, + const size_t buflen, + struct hv *flags) + { + ssize_t ret = flistxattr(fd, NULL, 0, 0 /* XXX: flags? */); + + if (ret > 0) + ret = File_ExtAttr_default_listxattrns(buf, buflen); + + return ret; + } + #endif /* EXTATTR_MACOSX */ Index: extattr_solaris.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_solaris.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** extattr_solaris.c 2 Oct 2006 19:53:06 -0000 1.6 --- extattr_solaris.c 2 Oct 2006 20:05:22 -0000 1.7 *************** *** 202,236 **** } - /* - * Solaris doesn't support namespacing attributes. So if there are - * any attributes, return the namespace "user". - */ - static - ssize_t listxattrns (const int attrdirfd, char *buf, const size_t buflen) - { - ssize_t ret = hasattrclose(attrdirfd); - if (ret > 0) - { - static const char NAMESPACE_USER[] = "user"; - - if (buflen >= sizeof(NAMESPACE_USER)) - { - memcpy(buf, NAMESPACE_USER, sizeof(NAMESPACE_USER)); - ret = sizeof(NAMESPACE_USER); - } - else if (buflen == 0) - { - ret = sizeof(NAMESPACE_USER); - } - else - { - ret = -1; - errno = ERANGE; - } - } - - return ret; - } - int solaris_setxattr (const char *path, --- 202,205 ---- *************** *** 435,440 **** struct hv *flags) { ! int attrdirfd = attropen(path, ".", O_RDONLY); ! return listxattrns(attrdirfd, buf, buflen); } --- 404,416 ---- struct hv *flags) { ! int attrdirfd; ! ssize_t ret; ! ! attrdirfd = attropen(path, ".", O_RDONLY); ! ret = hasattrclose(attrdirfd); ! if (ret > 0) ! ret = File_ExtAttr_default_listxattrns(buf, buflen); ! ! return ret; } *************** *** 444,449 **** struct hv *flags) { ! int attrdirfd = openat(fd, ".", O_RDONLY|O_XATTR); ! return listxattrns(attrdirfd, buf, buflen); } --- 420,432 ---- struct hv *flags) { ! int attrdirfd; ! ssize_t ret; ! ! attrdirfd = openat(fd, ".", O_RDONLY|O_XATTR); ! ret = hasattrclose(attrdirfd); ! if (ret > 0) ! ret = File_ExtAttr_default_listxattrns(buf, buflen); ! ! return ret; } Index: extattr_macosx.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_macosx.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** extattr_macosx.h 1 Oct 2006 08:18:49 -0000 1.2 --- extattr_macosx.h 2 Oct 2006 20:05:22 -0000 1.3 *************** *** 49,51 **** --- 49,61 ---- struct hv *flags); + ssize_t macosx_listxattrns (const char *path, + char *buf, + const size_t buflen, + struct hv *flags); + + ssize_t macosx_flistxattrns (const int fd, + char *buf, + const size_t buflen, + struct hv *flags); + #endif /* EXTATTR_MACOSX_H */ Index: flags.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/flags.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** flags.c 1 Oct 2006 08:02:49 -0000 1.2 --- flags.c 2 Oct 2006 20:05:22 -0000 1.3 *************** *** 59,63 **** if (len) ! ok = (memcmp("user", s, len) == 0); else ok = 0; --- 59,63 ---- if (len) ! ok = (memcmp(NAMESPACE_USER, s, len) == 0); else ok = 0; *************** *** 67,68 **** --- 67,96 ---- return ok; } + + /* + * Mac OS X and Solaris doesn't support namespacing attributes. + * So if there are any attributes, call this function, + * to return the namespace "user". + */ + ssize_t + File_ExtAttr_default_listxattrns (char *buf, const size_t buflen) + { + ssize_t ret = 0; + + if (buflen >= sizeof(NAMESPACE_USER)) + { + memcpy(buf, NAMESPACE_USER, sizeof(NAMESPACE_USER)); + ret = sizeof(NAMESPACE_USER); + } + else if (buflen == 0) + { + ret = sizeof(NAMESPACE_USER); + } + else + { + ret = -1; + errno = ERANGE; + } + + return ret; + } Index: extattr_bsd.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_bsd.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** extattr_bsd.c 30 Sep 2006 22:10:12 -0000 1.3 --- extattr_bsd.c 2 Oct 2006 20:05:22 -0000 1.4 *************** *** 11,17 **** #include "flags.h" - static const char NAMESPACE_USER[] = "user"; - static const char NAMESPACE_SYSTEM[] = "system"; - static int valid_namespace (struct hv *flags, int *pattrnamespace) --- 11,14 ---- Index: flags.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/flags.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** flags.h 1 Oct 2006 08:02:49 -0000 1.3 --- flags.h 2 Oct 2006 20:05:22 -0000 1.4 *************** *** 2,5 **** --- 2,7 ---- #define EXTATTR_FLAGS_H + #include <stddef.h> + struct hv; *************** *** 12,15 **** --- 14,20 ---- static const char NAMESPACE_KEY[] = "namespace"; + static const char NAMESPACE_USER[] = "user"; + static const char NAMESPACE_SYSTEM[] = "system"; + static const char CREATE_KEY[] = "create"; static const char REPLACE_KEY[] = "replace"; *************** *** 17,20 **** --- 22,26 ---- File_ExtAttr_setflags_t File_ExtAttr_flags2setflags (struct hv *flags); int File_ExtAttr_valid_default_namespace (struct hv *flags); + ssize_t File_ExtAttr_default_listxattrns (char *buf, const size_t buflen); #endif /* EXTATTR_FLAGS_H */ |
From: Richard D. <ric...@us...> - 2006-10-02 19:53:12
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv12304 Modified Files: extattr_solaris.c extattr_solaris.h Log Message: Solaris support for listfattrns Index: extattr_solaris.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_solaris.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** extattr_solaris.h 28 Aug 2006 11:45:40 -0000 1.3 --- extattr_solaris.h 2 Oct 2006 19:53:06 -0000 1.4 *************** *** 58,60 **** --- 58,70 ---- struct hv *flags); + ssize_t solaris_listxattrns (const char *path, + char *buf, + const size_t buflen, + struct hv *flags); + + ssize_t solaris_flistxattrns (const int fd, + char *buf, + const size_t buflen, + struct hv *flags); + #endif /* EXTATTR_SOLARIS_H */ Index: extattr_solaris.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_solaris.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** extattr_solaris.c 1 Oct 2006 08:02:49 -0000 1.5 --- extattr_solaris.c 2 Oct 2006 19:53:06 -0000 1.6 *************** *** 153,156 **** --- 153,158 ---- if ((attrdirfd >= 0) && (close(attrdirfd) == -1) && !saved_errno) saved_errno = errno; + if (dirp && (closedir(dirp) == -1) && !saved_errno) + saved_errno = errno; if (saved_errno) errno = saved_errno; *************** *** 159,162 **** --- 161,236 ---- } + static int + hasattrclose (const int attrdirfd) + { + int saved_errno = 0; + int ret = 0; /* Not by default */ + DIR *dirp; + + if (attrdirfd == -1) + ret = -1; + + if (ret >= 0) + dirp = fdopendir(attrdirfd); + + if (ret >= 0) + { + struct dirent *de; + + while ((de = readdir(dirp))) + { + /* Ignore "." and ".." entries */ + if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) + continue; + + /* Found a file */ + ret = 1; + break; + } + } + + if (ret == -1) + saved_errno = errno; + if ((attrdirfd >= 0) && (close(attrdirfd) == -1) && !saved_errno) + saved_errno = errno; + if (dirp && (closedir(dirp) == -1) && !saved_errno) + saved_errno = errno; + if (saved_errno) + errno = saved_errno; + + return ret; + } + + /* + * Solaris doesn't support namespacing attributes. So if there are + * any attributes, return the namespace "user". + */ + static + ssize_t listxattrns (const int attrdirfd, char *buf, const size_t buflen) + { + ssize_t ret = hasattrclose(attrdirfd); + if (ret > 0) + { + static const char NAMESPACE_USER[] = "user"; + + if (buflen >= sizeof(NAMESPACE_USER)) + { + memcpy(buf, NAMESPACE_USER, sizeof(NAMESPACE_USER)); + ret = sizeof(NAMESPACE_USER); + } + else if (buflen == 0) + { + ret = sizeof(NAMESPACE_USER); + } + else + { + ret = -1; + errno = ERANGE; + } + } + + return ret; + } + int solaris_setxattr (const char *path, *************** *** 356,358 **** --- 430,450 ---- } + ssize_t solaris_listxattrns (const char *path, + char *buf, + const size_t buflen, + struct hv *flags) + { + int attrdirfd = attropen(path, ".", O_RDONLY); + return listxattrns(attrdirfd, buf, buflen); + } + + ssize_t solaris_flistxattrns (const int fd, + char *buf, + const size_t buflen, + struct hv *flags) + { + int attrdirfd = openat(fd, ".", O_RDONLY|O_XATTR); + return listxattrns(attrdirfd, buf, buflen); + } + #endif /* EXTATTR_SOLARIS */ |
From: Richard D. <ric...@us...> - 2006-10-02 19:53:09
|
Update of /cvsroot/file-extattr/File-ExtAttr/t In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv12304/t Added Files: 31nsmultiple.t Log Message: Solaris support for listfattrns --- NEW FILE: 31nsmultiple.t --- #!perl -T -w # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Linux-xattr.t' ########################## # change 'tests => 2' to 'tests => last_test_to_print'; use strict; use Test::More tests => 26; use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr listfattrns); use IO::File; my $TESTDIR = ($ENV{ATTR_TEST_DIR} || '.'); my ($fh, $filename) = tempfile( DIR => $TESTDIR ); close $fh || die "can't close $filename $!"; #todo: try wierd characters in here? # try unicode? my $key = "alskdfjadf2340zsdflksjdfa09eralsdkfjaldkjsldkfj"; my $val = "ZZZadlf03948alsdjfaslfjaoweir12l34kealfkjalskdfas90d8fajdlfkj./.,f"; my $key2 = $key.'2'; my $key3 = $key.'3'; my @ns; ########################## # Filename-based tests # ########################## print "# using $filename\n"; #for (1..30000) { #checking memory leaks #will die if xattr stuff doesn't work at all setfattr($filename, "$key", $val, { namespace => 'user' }) || die "setfattr failed on filename $filename: $!"; #set it is (setfattr($filename, "$key", $val, { namespace => 'user' }), 1); #read it back is (getfattr($filename, "$key", { namespace => 'user' }), $val); #set another is (setfattr($filename, "$key2", $val, { namespace => 'user' }), 1); #read it back is (getfattr($filename, "$key2", { namespace => 'user' }), $val); #set yet another is (setfattr($filename, "$key3", $val, { namespace => 'user' }), 1); #read it back is (getfattr($filename, "$key3", { namespace => 'user' }), $val); #check user namespace exists now @ns = listfattrns($filename); is (grep(/^user$/, @ns), 1); #delete them ok (delfattr($filename, "$key", { namespace => 'user' })); ok (delfattr($filename, "$key2", { namespace => 'user' })); ok (delfattr($filename, "$key3", { namespace => 'user' })); #check that they're gone is (getfattr($filename, "$key", { namespace => 'user' }), undef); is (getfattr($filename, "$key2", { namespace => 'user' }), undef); is (getfattr($filename, "$key3", { namespace => 'user' }), undef); #check user namespace doesn't exist now @ns = listfattrns($filename); is (grep(/^user$/, @ns), 0); #} #print STDERR "done\n"; #<STDIN>; ########################## # IO::Handle-based tests # ########################## $fh = new IO::File("<$filename") || die "Unable to open $filename"; print "# using file descriptor ".$fh->fileno()."\n"; #for (1..30000) { #checking memory leaks #will die if xattr stuff doesn't work at all setfattr($fh, "$key", $val, { namespace => 'user' }) || die "setfattr failed on file descriptor ".$fh->fileno().": $!"; #set it is (setfattr($fh, "$key", $val, { namespace => 'user' }), 1); #read it back is (getfattr($fh, "$key", { namespace => 'user' }), $val); #set another is (setfattr($fh, "$key2", $val, { namespace => 'user' }), 1); #read it back is (getfattr($fh, "$key2", { namespace => 'user' }), $val); #set yet another is (setfattr($fh, "$key3", $val, { namespace => 'user' }), 1); #read it back is (getfattr($fh, "$key3", { namespace => 'user' }), $val); #check user namespace exists now @ns = listfattrns($fh); is (grep(/^user$/, @ns), 1); #delete them ok (delfattr($fh, "$key", { namespace => 'user' })); ok (delfattr($fh, "$key2", { namespace => 'user' })); ok (delfattr($fh, "$key3", { namespace => 'user' })); #check that it's gone is (getfattr($fh, "$key", { namespace => 'user' }), undef); #check user namespace doesn't exist now @ns = listfattrns($fh); is (grep(/^user$/, @ns), 0); #} #print STDERR "done\n"; #<STDIN>; END {unlink $filename if $filename}; |
From: Richard D. <ric...@us...> - 2006-10-01 11:18:56
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv9280 Modified Files: ExtAttr.xs extattr_linux.c extattr_linux.h portable.h Log Message: First cut of namespace list function for Linux Index: portable.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/portable.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** portable.h 1 Oct 2006 08:18:49 -0000 1.11 --- portable.h 1 Oct 2006 11:18:54 -0000 1.12 *************** *** 166,168 **** --- 166,202 ---- } + static inline int + portable_listxattrns(const char *path, + char *buf, + const size_t slen, + struct hv *flags) + { + #ifdef EXTATTR_MACOSX + return macosx_listxattrns(path, buf, slen, flags); + #elif defined(EXTATTR_BSD) + return bsd_listxattrns(path, buf, slen, flags); + #elif defined(EXTATTR_SOLARIS) + return solaris_listxattrns(path, buf, slen, flags); + #else + return linux_listxattrns(path, buf, slen, flags); + #endif + } + + static inline int + portable_flistxattrns(const int fd, + char *buf, + const size_t slen, + struct hv *flags) + { + #ifdef EXTATTR_MACOSX + return macosx_flistxattrns(fd, buf, slen, flags); + #elif defined(EXTATTR_BSD) + return bsd_flistxattrns(fd, buf, slen, flags); + #elif defined(EXTATTR_SOLARIS) + return solaris_flistxattrns(fd, buf, slen, flags); + #else + return linux_flistxattrns(fd, buf, slen, flags); + #endif + } + #endif /* EXTATTR_PORTABLE_H */ Index: extattr_linux.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_linux.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** extattr_linux.h 19 Aug 2006 14:06:22 -0000 1.2 --- extattr_linux.h 1 Oct 2006 11:18:54 -0000 1.3 *************** *** 50,52 **** --- 50,62 ---- struct hv *flags); + ssize_t linux_listxattrns (const char *path, + char *buf, + const size_t buflen, + struct hv *flags); + + ssize_t linux_flistxattrns (const int fd, + char *buf, + const size_t buflen, + struct hv *flags); + #endif /* EXTATTR_LINUX_H */ Index: ExtAttr.xs =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/ExtAttr.xs,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ExtAttr.xs 19 Aug 2006 18:34:42 -0000 1.19 --- ExtAttr.xs 1 Oct 2006 11:18:54 -0000 1.20 *************** *** 227,228 **** --- 227,290 ---- free(namebuf); + + void + _listfattrns (path, fd, flags = 0) + const char *path + int fd + HV * flags + PREINIT: + ssize_t size, ret; + char *namebuf = NULL; + char *nameptr; + + PPCODE: + if(fd == -1) + size = portable_listxattrns(path, NULL, 0, flags); + else + size = portable_flistxattrns(fd, NULL, 0, flags); + + if (size == -1) + { + XSRETURN_UNDEF; + } else if (size == 0) + { + XSRETURN_EMPTY; + } + + namebuf = malloc(size); + + if (fd == -1) + ret = portable_listxattrns(path, namebuf, size, flags); + else + ret = portable_flistxattrns(fd, namebuf, size, flags); + + // There could be a race condition here, if someone adds a new + // attribute between the two listxattr calls. However it just means we + // might return ERANGE. + + if (ret == -1) + { + free(namebuf); + XSRETURN_UNDEF; + } else if (ret == 0) + { + free(namebuf); + XSRETURN_EMPTY; + } + + nameptr = namebuf; + + while(nameptr < namebuf + ret) + { + char *endptr = nameptr; + while(*endptr++ != '\0'); + + // endptr will now point one past the end.. + + XPUSHs(sv_2mortal(newSVpvn(nameptr, endptr - nameptr - 1))); + + // nameptr could now point past the end of namebuf + nameptr = endptr; + } + + free(namebuf); Index: extattr_linux.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_linux.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** extattr_linux.c 1 Oct 2006 08:21:52 -0000 1.4 --- extattr_linux.c 1 Oct 2006 11:18:54 -0000 1.5 *************** *** 9,17 **** #include "flags.h" ! static const char NAMESPACE_DEFAULT[] = "user"; static char * flags2namespace (struct hv *flags) { const size_t NAMESPACE_KEYLEN = strlen(NAMESPACE_KEY); SV **psv_ns; --- 9,48 ---- #include "flags.h" ! static void * ! memstr (void *buf, const char *str, const size_t buflen) ! { ! void *p = buf; ! size_t len = buflen; ! const size_t slen = strlen(str); ! ! /* Ignore empty strings and buffers. */ ! if ((slen == 0) || (buflen == 0)) ! p = NULL; ! ! while (p && (len >= slen)) ! { ! /* ! * Find the first character of the string, then see if the rest ! * matches. ! */ ! p = memchr(p, str[0], len); ! if (!p) ! break; ! ! if (memcmp(p, str, slen) == 0) ! break; ! ! /* Next! */ ! ++p; ! --len; ! } ! ! return p; ! } static char * flags2namespace (struct hv *flags) { + static const char NAMESPACE_DEFAULT[] = "user"; const size_t NAMESPACE_KEYLEN = strlen(NAMESPACE_KEY); SV **psv_ns; *************** *** 269,271 **** --- 300,437 ---- } + static ssize_t + attrlist2nslist (char *sbuf, const size_t slen, char *buf, const size_t buflen) + { + ssize_t sbuiltlen = 0; + ssize_t spos = 0; + int ret = -1; + + for (spos = 0; (spos < slen); ) + { + char *pns, *pval; + + /* Get the namespace. */ + pns = &sbuf[spos]; + pval = strchr(pns, '.'); + if (!pval) + break; + + /* Point spos at the next attribute. */ + spos += strlen(pval) + 1; + + /* Check we haven't already seen this namespace. */ + *pval = '\0'; + ++pval; + if (memstr(sbuf, pns, sbuiltlen) != NULL) + continue; + + /* + * We build the results in sbuf. So sbuf will contain the list + * returned by listxattr and the list of namespaces. + * We shift the namespaces from the list to the start of the buffer. + */ + memmove(&sbuf[sbuiltlen], pns, strlen(pns) + 1 /* nul */); + sbuiltlen += strlen(pns) + 1; + } + + if (buflen == 0) + { + /* Return what space is required. */ + ret = sbuiltlen; + } + else if (sbuiltlen <= buflen) + { + memcpy(buf, sbuf, sbuiltlen); + ret = sbuiltlen; + } + else + { + errno = ERANGE; + ret = -1; + } + + return ret; + } + + /* XXX: Just return a Perl list? */ + ssize_t + linux_listxattrns (const char *path, + char *buf, + const size_t buflen, + struct hv *flags) + { + ssize_t slen; + ssize_t ret; + + /* + * Get a buffer of nul-delimited "namespace.attribute"s, + * then extract the namespaces into buf. + */ + slen = listxattr(path, buf, 0); + if (slen >= 0) + { + char *sbuf; + + sbuf = malloc(slen); + if (sbuf) + slen = listxattr(path, sbuf, slen); + else + ret = -1; + + if (slen) + ret = attrlist2nslist(sbuf, slen, buf, buflen); + else + ret = slen; + + if (sbuf) + free(sbuf); + } + else + { + ret = slen; + } + + return ret; + } + + ssize_t + linux_flistxattrns (const int fd, + char *buf, + const size_t buflen, + struct hv *flags) + { + ssize_t slen; + ssize_t ret; + + /* + * Get a buffer of nul-delimited "namespace.attribute"s, + * then extract the namespaces into buf. + */ + slen = flistxattr(fd, buf, 0); + if (slen >= 0) + { + char *sbuf; + + sbuf = malloc(slen); + if (sbuf) + slen = flistxattr(fd, sbuf, slen); + else + ret = -1; + + if (slen) + ret = attrlist2nslist(sbuf, slen, buf, buflen); + else + ret = slen; + + if (sbuf) + free(sbuf); + } + else + { + ret = slen; + } + + return ret; + } + #endif /* EXTATTR_LINUX */ |
From: Richard D. <ric...@us...> - 2006-10-01 11:18:56
|
Update of /cvsroot/file-extattr/File-ExtAttr/t In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv9280/t Modified Files: 30nsbasic.t Log Message: First cut of namespace list function for Linux Index: 30nsbasic.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/30nsbasic.t,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** 30nsbasic.t 19 Aug 2006 14:06:25 -0000 1.1 --- 30nsbasic.t 1 Oct 2006 11:18:54 -0000 1.2 *************** *** 1,3 **** ! #!perl -T # Before `make install' is performed this script should be runnable with --- 1,3 ---- ! #!perl -T -w # Before `make install' is performed this script should be runnable with *************** *** 9,15 **** use strict; ! use Test::More tests => 8; use File::Temp qw(tempfile); ! use File::ExtAttr qw(setfattr getfattr delfattr); use IO::File; --- 9,15 ---- use strict; ! use Test::More tests => 12; use File::Temp qw(tempfile); ! use File::ExtAttr qw(setfattr getfattr delfattr listfattrns); use IO::File; *************** *** 24,27 **** --- 24,29 ---- my $val = "ZZZadlf03948alsdjfaslfjaoweir12l34kealfkjalskdfas90d8fajdlfkj./.,f"; + my @ns; + ########################## # Filename-based tests # *************** *** 39,42 **** --- 41,48 ---- is (setfattr($filename, "$key", $val, { namespace => 'user' }), 1); + #check user namespace exists now + @ns = listfattrns($filename); + is (grep(/^user$/, @ns), 1); + #read it back is (getfattr($filename, "$key", { namespace => 'user' }), $val); *************** *** 47,50 **** --- 53,60 ---- #check that it's gone is (getfattr($filename, "$key", { namespace => 'user' }), undef); + + #check user namespace doesn't exist now + @ns = listfattrns($filename); + is (grep(/^user$/, @ns), 0); #} #print STDERR "done\n"; *************** *** 68,71 **** --- 78,85 ---- is (setfattr($fh, "$key", $val, { namespace => 'user' }), 1); + #check user namespace exists now + @ns = listfattrns($fh); + is (grep(/^user$/, @ns), 1); + #read it back is (getfattr($fh, "$key", { namespace => 'user' }), $val); *************** *** 76,79 **** --- 90,97 ---- #check that it's gone is (getfattr($fh, "$key", { namespace => 'user' }), undef); + + #check user namespace doesn't exist now + @ns = listfattrns($fh); + is (grep(/^user$/, @ns), 0); #} #print STDERR "done\n"; |
From: Richard D. <ric...@us...> - 2006-10-01 11:18:56
|
Update of /cvsroot/file-extattr/File-ExtAttr/lib/File In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv9280/lib/File Modified Files: ExtAttr.pm Log Message: First cut of namespace list function for Linux Index: ExtAttr.pm =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/lib/File/ExtAttr.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ExtAttr.pm 30 Sep 2006 22:10:12 -0000 1.16 --- ExtAttr.pm 1 Oct 2006 11:18:54 -0000 1.17 *************** *** 125,129 **** # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. ! our %EXPORT_TAGS = ( 'all' => [ qw( getfattr setfattr delfattr listfattr ) ] ); --- 125,134 ---- # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. ! our %EXPORT_TAGS = ( 'all' => [ qw( ! getfattr ! setfattr ! delfattr ! listfattr ! listfattrns ) ] ); *************** *** 262,266 **** --- 267,291 ---- # Filename : _listfattr($file, -1, @_); + } + + =item listfattrns([$filename | $filehandle], [\%flags]) + + Return a list containing the namespaces of attributes on the file named + C<$filename> or referenced by the open filehandle C<$filehandle> + (which should be an IO::Handle). + Returns undef on failure and $! will be set. + + =cut + + sub listfattrns + { + my $file = shift; + + return _is_fh($file) + # File handle + ? _listfattrns(undef, $file->fileno(), @_) + # Filename + : _listfattrns($file, -1, @_); } |
From: Richard D. <ric...@us...> - 2006-10-01 11:17:58
|
Update of /cvsroot/file-extattr/File-ExtAttr/t In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv8875/t Modified Files: 00load.t 01distribution.t 02load-all.t 03pod-coverage.t 11basic.t 13long.t 14optional.t 15create.t 16replace.t 17createreplace.t 20tie-basic.t Log Message: Run tests with warnings on Index: 03pod-coverage.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/03pod-coverage.t,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** 03pod-coverage.t 1 Jan 2006 19:06:39 -0000 1.1 --- 03pod-coverage.t 1 Oct 2006 11:17:56 -0000 1.2 *************** *** 1,3 **** ! #!perl -T use strict; --- 1,3 ---- ! #!perl -T -w use strict; Index: 15create.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/15create.t,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** 15create.t 19 Aug 2006 18:27:18 -0000 1.1 --- 15create.t 1 Oct 2006 11:17:56 -0000 1.2 *************** *** 1,3 **** ! #!perl -T # Before `make install' is performed this script should be runnable with --- 1,3 ---- ! #!perl -T -w # Before `make install' is performed this script should be runnable with Index: 02load-all.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/02load-all.t,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** 02load-all.t 6 Mar 2006 20:53:47 -0000 1.2 --- 02load-all.t 1 Oct 2006 11:17:56 -0000 1.3 *************** *** 1,3 **** ! #!perl -T use strict; --- 1,3 ---- ! #!perl -T -w use strict; Index: 13long.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/13long.t,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** 13long.t 19 Aug 2006 14:06:25 -0000 1.3 --- 13long.t 1 Oct 2006 11:17:56 -0000 1.4 *************** *** 1,3 **** ! #!perl -T # Before `make install' is performed this script should be runnable with --- 1,3 ---- ! #!perl -T -w # Before `make install' is performed this script should be runnable with Index: 20tie-basic.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/20tie-basic.t,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** 20tie-basic.t 19 Aug 2006 14:06:25 -0000 1.4 --- 20tie-basic.t 1 Oct 2006 11:17:56 -0000 1.5 *************** *** 1,3 **** ! #!perl -T use strict; --- 1,3 ---- ! #!perl -T -w use strict; Index: 01distribution.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/01distribution.t,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** 01distribution.t 20 Nov 2005 18:50:36 -0000 1.1 --- 01distribution.t 1 Oct 2006 11:17:56 -0000 1.2 *************** *** 1,3 **** ! #!/usr/bin/perl -w use strict; --- 1,3 ---- ! #!perl -w use strict; Index: 11basic.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/11basic.t,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** 11basic.t 19 Aug 2006 14:06:25 -0000 1.3 --- 11basic.t 1 Oct 2006 11:17:56 -0000 1.4 *************** *** 1,3 **** ! #!perl -T # Before `make install' is performed this script should be runnable with --- 1,3 ---- ! #!perl -T -w # Before `make install' is performed this script should be runnable with Index: 00load.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/00load.t,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** 00load.t 9 Dec 2005 23:28:47 -0000 1.3 --- 00load.t 1 Oct 2006 11:17:56 -0000 1.4 *************** *** 1,3 **** ! #!perl -T use strict; --- 1,3 ---- ! #!perl -T -w use strict; Index: 16replace.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/16replace.t,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** 16replace.t 19 Aug 2006 18:27:18 -0000 1.1 --- 16replace.t 1 Oct 2006 11:17:56 -0000 1.2 *************** *** 1,3 **** ! #!perl -T # Before `make install' is performed this script should be runnable with --- 1,3 ---- ! #!perl -T -w # Before `make install' is performed this script should be runnable with Index: 14optional.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/14optional.t,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** 14optional.t 19 Aug 2006 14:06:25 -0000 1.2 --- 14optional.t 1 Oct 2006 11:17:56 -0000 1.3 *************** *** 1,3 **** ! #!perl -T # Before `make install' is performed this script should be runnable with --- 1,3 ---- ! #!perl -T -w # Before `make install' is performed this script should be runnable with Index: 17createreplace.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/17createreplace.t,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** 17createreplace.t 19 Aug 2006 18:27:18 -0000 1.1 --- 17createreplace.t 1 Oct 2006 11:17:56 -0000 1.2 *************** *** 1,3 **** ! #!perl -T # Before `make install' is performed this script should be runnable with --- 1,3 ---- ! #!perl -T -w # Before `make install' is performed this script should be runnable with |
From: Richard D. <ric...@us...> - 2006-10-01 11:17:24
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv8852 Modified Files: TODO Log Message: Done something Index: TODO =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/TODO,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TODO 1 Oct 2006 08:19:08 -0000 1.13 --- TODO 1 Oct 2006 11:17:17 -0000 1.14 *************** *** 24,30 **** there's no point supporting 3.0? - File::ExtAttr::XATTR_REPLACE/XATTR_CREATE is non-portable; find some - non-racy of doing this on *BSD & Solaris. - "user." prefix vs. other platforms. This needs sorting out, perhaps as an optional parameter on each *xattr function? Defaults to "user." --- 24,27 ---- |
From: Richard D. <ric...@us...> - 2006-10-01 08:25:12
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv5620 Modified Files: extattr_linux.c Log Message: Use common flags2setflags code on Linux Index: extattr_linux.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_linux.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** extattr_linux.c 28 Aug 2006 11:45:39 -0000 1.3 --- extattr_linux.c 1 Oct 2006 08:21:52 -0000 1.4 *************** *** 11,35 **** static const char NAMESPACE_DEFAULT[] = "user"; - static int - flags2setflags (struct hv *flags) - { - const size_t CREATE_KEYLEN = strlen(CREATE_KEY); - const size_t REPLACE_KEYLEN = strlen(REPLACE_KEY); - SV **psv_ns; - int ret = 0; - - /* - * ASSUMPTION: Perl layer must ensure that create & replace - * aren't used at the same time. - */ - if (flags && (psv_ns = hv_fetch(flags, CREATE_KEY, CREATE_KEYLEN, 0))) - ret = SvIV(*psv_ns) ? XATTR_CREATE : 0; - - if (flags && (psv_ns = hv_fetch(flags, REPLACE_KEY, REPLACE_KEYLEN, 0))) - ret = SvIV(*psv_ns) ? XATTR_REPLACE : 0; - - return ret; - } - static char * flags2namespace (struct hv *flags) --- 11,14 ---- *************** *** 92,103 **** int ret; char *q; ! int setflags; ! setflags = flags2setflags(flags); ! q = qualify_attrname(attrname, flags); if (q) { ! ret = setxattr(path, q, attrvalue, slen, setflags); free(q); } --- 71,89 ---- int ret; char *q; ! File_ExtAttr_setflags_t setflags; ! int xflags = 0; ! setflags = File_ExtAttr_flags2setflags(flags); ! switch (setflags) ! { ! case SET_CREATEIFNEEDED: break; ! case SET_CREATE: xflags |= XATTR_CREATE; break; ! case SET_REPLACE: xflags |= XATTR_REPLACE; break; ! } + q = qualify_attrname(attrname, flags); if (q) { ! ret = setxattr(path, q, attrvalue, slen, xflags); free(q); } *************** *** 120,131 **** int ret; char *q; ! int setflags; ! setflags = flags2setflags(flags); ! q = qualify_attrname(attrname, flags); if (q) { ! ret = fsetxattr(fd, q, attrvalue, slen, setflags); free(q); } --- 106,124 ---- int ret; char *q; ! File_ExtAttr_setflags_t setflags; ! int xflags = 0; ! setflags = File_ExtAttr_flags2setflags(flags); ! switch (setflags) ! { ! case SET_CREATEIFNEEDED: break; ! case SET_CREATE: xflags |= XATTR_CREATE; break; ! case SET_REPLACE: xflags |= XATTR_REPLACE; break; ! } + q = qualify_attrname(attrname, flags); if (q) { ! ret = fsetxattr(fd, q, attrvalue, slen, xflags); free(q); } |
From: Richard D. <ric...@us...> - 2006-10-01 08:24:46
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv4447 Modified Files: extattr_macosx.h portable.h Changes Added Files: extattr_macosx.c Log Message: Namespace & flag checking for Mac OS X Index: portable.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/portable.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** portable.h 30 Sep 2006 22:10:12 -0000 1.10 --- portable.h 1 Oct 2006 08:18:49 -0000 1.11 *************** *** 16,20 **** { #ifdef EXTATTR_MACOSX ! return setxattr(path, attrname, attrvalue, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) return bsd_setxattr(path, attrname, attrvalue, slen, flags); --- 16,20 ---- { #ifdef EXTATTR_MACOSX ! return macosx_setxattr(path, attrname, attrvalue, slen, flags); #elif defined(EXTATTR_BSD) return bsd_setxattr(path, attrname, attrvalue, slen, flags); *************** *** 34,38 **** { #ifdef EXTATTR_MACOSX ! return fsetxattr(fd, attrname, attrvalue, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) return bsd_fsetxattr(fd, attrname, attrvalue, slen, flags); --- 34,38 ---- { #ifdef EXTATTR_MACOSX ! return macosx_fsetxattr(fd, attrname, attrvalue, slen, flags); #elif defined(EXTATTR_BSD) return bsd_fsetxattr(fd, attrname, attrvalue, slen, flags); *************** *** 52,56 **** { #ifdef EXTATTR_MACOSX ! return getxattr(path, attrname, attrvalue, slen, 0, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) return bsd_getxattr(path, attrname, attrvalue, slen, flags); --- 52,56 ---- { #ifdef EXTATTR_MACOSX ! return macosx_getxattr(path, attrname, attrvalue, slen, flags); #elif defined(EXTATTR_BSD) return bsd_getxattr(path, attrname, attrvalue, slen, flags); *************** *** 70,74 **** { #ifdef EXTATTR_MACOSX ! return fgetxattr(fd, attrname, attrvalue, slen, 0, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) return bsd_fgetxattr(fd, attrname, attrvalue, slen, flags); --- 70,74 ---- { #ifdef EXTATTR_MACOSX ! return macosx_fgetxattr(fd, attrname, attrvalue, slen, flags); #elif defined(EXTATTR_BSD) return bsd_fgetxattr(fd, attrname, attrvalue, slen, flags); *************** *** 108,112 **** { #ifdef EXTATTR_MACOSX ! return removexattr(path, name, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) return bsd_removexattr(path, name, flags); --- 108,112 ---- { #ifdef EXTATTR_MACOSX ! return macosx_removexattr(path, name, flags); #elif defined(EXTATTR_BSD) return bsd_removexattr(path, name, flags); *************** *** 122,126 **** { #ifdef EXTATTR_MACOSX ! return fremovexattr(fd, name, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) return bsd_fremovexattr(fd, name, flags); --- 122,126 ---- { #ifdef EXTATTR_MACOSX ! return macosx_fremovexattr(fd, name, flags); #elif defined(EXTATTR_BSD) return bsd_fremovexattr(fd, name, flags); *************** *** 139,143 **** { #ifdef EXTATTR_MACOSX ! return listxattr(path, buf, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) return bsd_listxattr(path, buf, slen, flags); --- 139,143 ---- { #ifdef EXTATTR_MACOSX ! return macosx_listxattr(path, buf, slen, flags); #elif defined(EXTATTR_BSD) return bsd_listxattr(path, buf, slen, flags); *************** *** 156,160 **** { #ifdef EXTATTR_MACOSX ! return flistxattr(fd, buf, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) return bsd_flistxattr(fd, buf, slen, flags); --- 156,160 ---- { #ifdef EXTATTR_MACOSX ! return macosx_flistxattr(fd, buf, slen, flags); #elif defined(EXTATTR_BSD) return bsd_flistxattr(fd, buf, slen, flags); Index: extattr_macosx.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_macosx.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** extattr_macosx.h 14 Aug 2006 21:10:54 -0000 1.1 --- extattr_macosx.h 1 Oct 2006 08:18:49 -0000 1.2 *************** *** 5,7 **** --- 5,51 ---- #include <sys/xattr.h> + struct hv; + + int macosx_setxattr (const char *path, + const char *attrname, + const char *attrvalue, + const size_t slen, + struct hv *flags); + + int macosx_fsetxattr (const int fd, + const char *attrname, + const char *attrvalue, + const size_t slen, + struct hv *flags); + + int macosx_getxattr (const char *path, + const char *attrname, + void *attrvalue, + const size_t slen, + struct hv *flags); + + int macosx_fgetxattr (const int fd, + const char *attrname, + void *attrvalue, + const size_t slen, + struct hv *flags); + + int macosx_removexattr (const char *path, + const char *attrname, + struct hv *flags); + + int macosx_fremovexattr (const int fd, + const char *attrname, + struct hv *flags); + + ssize_t macosx_listxattr (const char *path, + char *buf, + const size_t buflen, + struct hv *flags); + + ssize_t macosx_flistxattr (const int fd, + char *buf, + const size_t buflen, + struct hv *flags); + #endif /* EXTATTR_MACOSX_H */ Index: Changes =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/Changes,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Changes 28 Aug 2006 11:45:39 -0000 1.18 --- Changes 1 Oct 2006 08:18:49 -0000 1.19 *************** *** 7,10 **** --- 7,11 ---- are now passed via a hash. This breaks API compatibility. There should be no further API changes. + NOTE: This has not been tested on Mac OS X. 0.05 2006-05-27 --- NEW FILE: extattr_macosx.c --- #include "extattr_os.h" #ifdef EXTATTR_MACOSX #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "flags.h" int macosx_setxattr (const char *path, const char *attrname, const char *attrvalue, const size_t slen, struct hv *flags) { int ok = 1; File_ExtAttr_setflags_t setflags = 0; int xflags = 0; int ret = -1; setflags = File_ExtAttr_flags2setflags(flags); switch (setflags) { case SET_CREATEIFNEEDED: break; case SET_CREATE: xflags |= XATTR_CREATE; break; case SET_REPLACE: xflags |= XATTR_REPLACE; break; } if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; ok = 0; } if (ok) ret = setxattr(path, attrname, attrvalue, slen, xflags); return ok ? ret : -1; } int macosx_fsetxattr (const int fd, const char *attrname, const char *attrvalue, const size_t slen, struct hv *flags) { int ok = 1; File_ExtAttr_setflags_t setflags; int xflags = 0; int ret = -1; setflags = File_ExtAttr_flags2setflags(flags); switch (setflags) { case SET_CREATEIFNEEDED: break; case SET_CREATE: xflags |= XATTR_CREATE; break; case SET_REPLACE: xflags |= XATTR_REPLACE; break; } if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; ok = 0; } if (ok) ret = fsetxattr(fd, attrname, attrvalue, slen, xflags); return ok ? ret : -1; } int macosx_getxattr (const char *path, const char *attrname, void *attrvalue, const size_t slen, struct hv *flags) { int ok = 1; int xflags = 0; int ret = -1; if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; ok = 0; } if (ok) ret = getxattr(path, attrname, attrvalue, slen, 0, xflags); return ok ? ret : - 1; } int macosx_fgetxattr (const int fd, const char *attrname, void *attrvalue, const size_t slen, struct hv *flags) { int ok = 1; int xflags = 0; int ret = -1; if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; ok = 0; } if (ok) ret = fgetxattr(fd, attrname, attrvalue, slen, 0, xflags); return ok ? ret : -1; } int macosx_removexattr (const char *path, const char *attrname, struct hv *flags) { int ok = 1; int xflags = 0; int ret = -1; if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; ok = 0; } if (ok) ret = removexattr(path, attrname, xflags); return ok ? ret : -1; } int macosx_fremovexattr (const int fd, const char *attrname, struct hv *flags) { int ok = 1; int xflags = 0; int ret = -1; if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; ok = 0; } if (ok) ret = fremovexattr(fd, attrname, xflags); return ok ? ret : -1; } ssize_t macosx_listxattr (const char *path, char *buf, const size_t buflen, struct hv *flags) { /* FIXME */ return listxattr(path, buf, buflen, 0 /* XXX: flags? */); } ssize_t macosx_flistxattr (const int fd, char *buf, const size_t buflen, struct hv *flags) { /* FIXME */ return flistxattr(fd, buf, buflen, 0 /* XXX: flags? */); } #endif /* EXTATTR_MACOSX */ |
From: Richard D. <ric...@us...> - 2006-10-01 08:24:46
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv4823 Modified Files: TODO Log Message: YATT Index: TODO =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/TODO,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TODO 30 Sep 2006 22:10:12 -0000 1.12 --- TODO 1 Oct 2006 08:19:08 -0000 1.13 *************** *** 8,12 **** buffer size, reuse buffer? throw exceptions rather than warnings on getxattr() failure ! symbolic link handling Check it can be used with Perl 5.6.x Factor out common code from the tests --- 8,12 ---- buffer size, reuse buffer? throw exceptions rather than warnings on getxattr() failure ! symbolic link handling (O_NOFOLLOW on Mac OS X) Check it can be used with Perl 5.6.x Factor out common code from the tests |
From: Richard D. <ric...@us...> - 2006-10-01 08:02:56
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv30650 Modified Files: flags.c flags.h extattr_solaris.c Log Message: Move valid_namespace into common code for use on Mac OS X Index: flags.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/flags.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** flags.h 30 Sep 2006 22:10:12 -0000 1.2 --- flags.h 1 Oct 2006 08:02:49 -0000 1.3 *************** *** 16,19 **** --- 16,20 ---- File_ExtAttr_setflags_t File_ExtAttr_flags2setflags (struct hv *flags); + int File_ExtAttr_valid_default_namespace (struct hv *flags); #endif /* EXTATTR_FLAGS_H */ Index: extattr_solaris.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_solaris.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** extattr_solaris.c 30 Sep 2006 22:10:12 -0000 1.4 --- extattr_solaris.c 1 Oct 2006 08:02:49 -0000 1.5 *************** *** 18,53 **** static int - valid_namespace (struct hv *flags) - { - const size_t NAMESPACE_KEYLEN = strlen(NAMESPACE_KEY); - SV **psv_ns; - char *ns = NULL; - int ok = 1; /* Default is valid */ - - if (flags && (psv_ns = hv_fetch(flags, NAMESPACE_KEY, NAMESPACE_KEYLEN, 0))) - { - /* - * Undefined => default. Otherwise treat "user" as if it were valid, - * for compatibility with the default on Linux and *BSD. - * An empty namespace (i.e.: zero-length) is not the same as the default. - */ - if (SvOK(*psv_ns)) - { - char *s; - STRLEN len = 0; - - s = SvPV(*psv_ns, len); - - if (len) - ok = (memcmp("user", s, len) == 0); - else - ok = 0; - } - } - - return ok; - } - - static int writexattr (const int attrfd, const char *attrvalue, --- 18,21 ---- *************** *** 213,217 **** } ! if (!valid_namespace(flags)) { errno = ENOATTR; --- 181,185 ---- } ! if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; *************** *** 259,263 **** } ! if (!valid_namespace(flags)) { errno = ENOATTR; --- 227,231 ---- } ! if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; *************** *** 294,298 **** int ok = 1; ! if (!valid_namespace(flags)) { errno = ENOATTR; --- 262,266 ---- int ok = 1; ! if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; *************** *** 316,320 **** int ok = 1; ! if (!valid_namespace(flags)) { errno = ENOATTR; --- 284,288 ---- int ok = 1; ! if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; *************** *** 336,340 **** int ok = 1; ! if (!valid_namespace(flags)) { errno = ENOATTR; --- 304,308 ---- int ok = 1; ! if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; *************** *** 356,360 **** int ok = 1; ! if (!valid_namespace(flags)) { errno = ENOATTR; --- 324,328 ---- int ok = 1; ! if (!File_ExtAttr_valid_default_namespace(flags)) { errno = ENOATTR; Index: flags.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/flags.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** flags.c 30 Sep 2006 22:10:12 -0000 1.1 --- flags.c 1 Oct 2006 08:02:49 -0000 1.2 *************** *** 7,10 **** --- 7,14 ---- #include "flags.h" + /* + * Convert the 'create' and/or 'replace' attributes into a value, + * so they can be mapped to O_CREATE/O_EXCL values by the caller. + */ File_ExtAttr_setflags_t File_ExtAttr_flags2setflags (struct hv *flags) *************** *** 27,28 **** --- 31,68 ---- return ret; } + + /* + * For platforms that don't support namespacing attributes + * (Mac OS X, Solaris), provide some smart default behaviour + * for the 'namespace' attribute for cross-platform compatibility. + */ + int + File_ExtAttr_valid_default_namespace (struct hv *flags) + { + const size_t NAMESPACE_KEYLEN = strlen(NAMESPACE_KEY); + SV **psv_ns; + int ok = 1; /* Default is valid */ + + if (flags && (psv_ns = hv_fetch(flags, NAMESPACE_KEY, NAMESPACE_KEYLEN, 0))) + { + /* + * Undefined => default. Otherwise treat "user" as if it were valid, + * for compatibility with the default on Linux and *BSD. + * An empty namespace (i.e.: zero-length) is not the same as the default. + */ + if (SvOK(*psv_ns)) + { + char *s; + STRLEN len = 0; + + s = SvPV(*psv_ns, len); + + if (len) + ok = (memcmp("user", s, len) == 0); + else + ok = 0; + } + } + + return ok; + } |
From: Richard D. <ric...@us...> - 2006-09-30 22:10:16
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv1641 Modified Files: TODO extattr_bsd.c extattr_bsd.h extattr_solaris.c flags.h portable.h Added Files: flags.c Log Message: Initial BSD support for attribute flag Index: extattr_solaris.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_solaris.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** extattr_solaris.c 28 Aug 2006 11:45:40 -0000 1.3 --- extattr_solaris.c 30 Sep 2006 22:10:12 -0000 1.4 *************** *** 17,47 **** static const mode_t ATTRMODE = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP; - typedef enum { - SET_CREATEIFNEEDED = 0, - SET_CREATE, - SET_REPLACE - } setflags_t; - - static setflags_t - flags2setflags (struct hv *flags) - { - const size_t CREATE_KEYLEN = strlen(CREATE_KEY); - const size_t REPLACE_KEYLEN = strlen(REPLACE_KEY); - SV **psv_ns; - setflags_t ret = SET_CREATEIFNEEDED; - - /* - * ASSUMPTION: Perl layer must ensure that create & replace - * aren't used at the same time. - */ - if (flags && (psv_ns = hv_fetch(flags, CREATE_KEY, CREATE_KEYLEN, 0))) - ret = SvIV(*psv_ns) ? SET_CREATE : SET_CREATEIFNEEDED; - - if (flags && (psv_ns = hv_fetch(flags, REPLACE_KEY, REPLACE_KEYLEN, 0))) - ret = SvIV(*psv_ns) ? SET_REPLACE : SET_CREATEIFNEEDED; - - return ret; - } - static int valid_namespace (struct hv *flags) --- 17,20 ---- *************** *** 228,236 **** int saved_errno = 0; int ok = 1; ! setflags_t setflags; int openflags = O_RDWR; int attrfd = -1; ! setflags = flags2setflags(flags); switch (setflags) { --- 201,209 ---- int saved_errno = 0; int ok = 1; ! File_ExtAttr_setflags_t setflags; int openflags = O_RDWR; int attrfd = -1; ! setflags = File_ExtAttr_flags2setflags(flags); switch (setflags) { *************** *** 275,282 **** int ok = 1; int openflags = O_RDWR | O_XATTR; ! setflags_t setflags; int attrfd = -1; ! setflags = flags2setflags(flags); switch (setflags) { --- 248,255 ---- int ok = 1; int openflags = O_RDWR | O_XATTR; ! File_ExtAttr_setflags_t setflags; int attrfd = -1; ! setflags = File_ExtAttr_flags2setflags(flags); switch (setflags) { --- NEW FILE: flags.c --- #include <stddef.h> #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "flags.h" File_ExtAttr_setflags_t File_ExtAttr_flags2setflags (struct hv *flags) { const size_t CREATE_KEYLEN = strlen(CREATE_KEY); const size_t REPLACE_KEYLEN = strlen(REPLACE_KEY); SV **psv_ns; File_ExtAttr_setflags_t ret = SET_CREATEIFNEEDED; /* * ASSUMPTION: Perl layer must ensure that create & replace * aren't used at the same time. */ if (flags && (psv_ns = hv_fetch(flags, CREATE_KEY, CREATE_KEYLEN, 0))) ret = SvIV(*psv_ns) ? SET_CREATE : SET_CREATEIFNEEDED; if (flags && (psv_ns = hv_fetch(flags, REPLACE_KEY, REPLACE_KEYLEN, 0))) ret = SvIV(*psv_ns) ? SET_REPLACE : SET_CREATEIFNEEDED; return ret; } Index: extattr_bsd.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_bsd.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** extattr_bsd.c 15 Aug 2006 09:14:20 -0000 1.2 --- extattr_bsd.c 30 Sep 2006 22:10:12 -0000 1.3 *************** *** 5,9 **** #include <errno.h> ! #include "extattr_bsd.h" /* Helper to convert number of bytes written into success/failure code. */ --- 5,59 ---- #include <errno.h> ! #include "EXTERN.h" ! #include "perl.h" ! #include "XSUB.h" ! ! #include "flags.h" ! ! static const char NAMESPACE_USER[] = "user"; ! static const char NAMESPACE_SYSTEM[] = "system"; ! ! static int ! valid_namespace (struct hv *flags, int *pattrnamespace) ! { ! const size_t NAMESPACE_KEYLEN = strlen(NAMESPACE_KEY); ! SV **psv_ns; ! char *ns = NULL; ! int ok = 1; /* Default is valid */ ! int attrnamespace = EXTATTR_NAMESPACE_USER; ! ! if (flags && (psv_ns = hv_fetch(flags, NAMESPACE_KEY, NAMESPACE_KEYLEN, 0))) ! { ! /* ! * Undefined => default. Otherwise "user" and "system" are valid. ! */ ! if (SvOK(*psv_ns)) ! { ! char *s; ! STRLEN len = 0; ! ! s = SvPV(*psv_ns, len); ! ! if (len) ! { ! if (memcmp(NAMESPACE_USER, s, len) == 0) ! attrnamespace = EXTATTR_NAMESPACE_USER; ! else if (memcmp(NAMESPACE_SYSTEM, s, len) == 0) ! attrnamespace = EXTATTR_NAMESPACE_SYSTEM; ! else ! ok = 0; ! } ! else ! { ! ok = 0; ! } ! } ! } ! ! if (ok) ! *pattrnamespace = attrnamespace; ! ! return ok; ! } /* Helper to convert number of bytes written into success/failure code. */ *************** *** 33,41 **** const char *attrname, const char *attrvalue, ! const size_t slen) { ! /* XXX: Namespace? */ ! int ret = extattr_set_file(path, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); ! return bsd_extattr_set_succeeded(slen, ret); } --- 83,135 ---- const char *attrname, const char *attrvalue, ! const size_t slen, ! struct hv *flags) { ! int attrnamespace = -1; ! int ok = 1; ! int ret = -1; ! ! if (!valid_namespace(flags, &attrnamespace)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! { ! File_ExtAttr_setflags_t setflags = File_ExtAttr_flags2setflags(flags); ! switch (setflags) ! { ! case SET_CREATEIFNEEDED: ! case SET_REPLACE: ! /* Default behaviour */ ! break; ! ! case SET_CREATE: ! /* ! * This needs to be emulated, since the default *BSD calls ! * don't provide a way of failing if the attribute exists. ! * This emulation is inherently racy. ! */ ! { ! ssize_t sz = extattr_get_file(path, attrnamespace, attrname, NULL, 0); ! if (sz >= 0) ! { ! /* Attribute already exists => fail. */ ! errno = EEXIST; ! ok = 0; ! } ! } ! break; ! } ! } ! ! if (ok) ! { ! ret = extattr_set_file(path, attrnamespace, attrname, attrvalue, slen); ! ret = bsd_extattr_set_succeeded(slen, ret); ! } ! ! return ok ? ret : -1; } *************** *** 44,52 **** const char *attrname, const char *attrvalue, ! const size_t slen) { ! /* XXX: Namespace? */ ! int ret = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); ! return bsd_extattr_set_succeeded(slen, ret); } --- 138,278 ---- const char *attrname, const char *attrvalue, ! const size_t slen, ! struct hv *flags) { ! int attrnamespace = -1; ! int ok = 1; ! int ret = -1; ! ! if (!valid_namespace(flags, &attrnamespace)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! { ! File_ExtAttr_setflags_t setflags = File_ExtAttr_flags2setflags(flags); ! switch (setflags) ! { ! case SET_CREATEIFNEEDED: ! case SET_REPLACE: ! /* Default behaviour */ ! break; ! ! case SET_CREATE: ! /* ! * This needs to be emulated, since the default *BSD calls ! * don't provide a way of failing if the attribute exists. ! * This emulation is inherently racy. ! */ ! { ! ssize_t sz = extattr_get_fd(fd, attrnamespace, attrname, NULL, 0); ! if (sz >= 0) ! { ! /* Attribute already exists => fail. */ ! errno = EEXIST; ! ok = 0; ! } ! } ! break; ! } ! } ! ! if (ok) ! { ! ret = extattr_set_fd(fd, attrnamespace, attrname, attrvalue, slen); ! ret = bsd_extattr_set_succeeded(slen, ret); ! } ! ! return ret; ! } ! ! int ! bsd_getxattr (const char *path, ! const char *attrname, ! void *attrvalue, ! const size_t slen, ! struct hv *flags) ! { ! int attrnamespace = -1; ! int ok = 1; ! int ret = -1; ! ! if (!valid_namespace(flags, &attrnamespace)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! ret = extattr_get_file(path, attrnamespace, attrname, attrvalue, slen); ! ! return ok ? ret : -1; ! } ! ! int ! bsd_fgetxattr (const int fd, ! const char *attrname, ! void *attrvalue, ! const size_t slen, ! struct hv *flags) ! { ! int attrnamespace = -1; ! int ok = 1; ! int ret = -1; ! ! if (!valid_namespace(flags, &attrnamespace)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! ret = extattr_get_fd(fd, attrnamespace, attrname, attrvalue, slen); ! ! return ok ? ret : -1; ! } ! ! int ! bsd_removexattr (const char *path, ! const char *attrname, ! struct hv *flags) ! { ! int attrnamespace = -1; ! int ok = 1; ! int ret = -1; ! ! if (!valid_namespace(flags, &attrnamespace)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! ret = extattr_delete_file(path, attrnamespace, attrname); ! ! return ok ? ret : -1; ! } ! ! int ! bsd_fremovexattr (const int fd, ! const char *attrname, ! struct hv *flags) ! { ! int attrnamespace = -1; ! int ok = 1; ! int ret = -1; ! ! if (!valid_namespace(flags, &attrnamespace)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! ret = extattr_delete_fd(fd, attrnamespace, attrname); ! ! return ok ? ret : -1; } *************** *** 68,72 **** ssize_t ! bsd_listxattr (const char *path, char *buf, const size_t buflen) { ssize_t ret; --- 294,301 ---- ssize_t ! bsd_listxattr (const char *path, ! char *buf, ! const size_t buflen, ! struct hv *flags) { ssize_t ret; *************** *** 86,90 **** ssize_t ! bsd_flistxattr (const int fd, char *buf, const size_t buflen) { ssize_t ret; --- 315,322 ---- ssize_t ! bsd_flistxattr (const int fd, ! char *buf, ! const size_t buflen, ! struct hv *flags) { ssize_t ret; Index: flags.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/flags.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** flags.h 28 Aug 2006 11:45:40 -0000 1.1 --- flags.h 30 Sep 2006 22:10:12 -0000 1.2 *************** *** 2,5 **** --- 2,13 ---- #define EXTATTR_FLAGS_H + struct hv; + + typedef enum { + SET_CREATEIFNEEDED = 0, + SET_CREATE, + SET_REPLACE + } File_ExtAttr_setflags_t; + static const char NAMESPACE_KEY[] = "namespace"; *************** *** 7,9 **** --- 15,19 ---- static const char REPLACE_KEY[] = "replace"; + File_ExtAttr_setflags_t File_ExtAttr_flags2setflags (struct hv *flags); + #endif /* EXTATTR_FLAGS_H */ Index: portable.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/portable.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** portable.h 28 Aug 2006 11:45:40 -0000 1.9 --- portable.h 30 Sep 2006 22:10:12 -0000 1.10 *************** *** 18,22 **** return setxattr(path, attrname, attrvalue, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_setxattr(path, attrname, attrvalue, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) return solaris_setxattr(path, attrname, attrvalue, slen, flags); --- 18,22 ---- return setxattr(path, attrname, attrvalue, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_setxattr(path, attrname, attrvalue, slen, flags); #elif defined(EXTATTR_SOLARIS) return solaris_setxattr(path, attrname, attrvalue, slen, flags); *************** *** 36,40 **** return fsetxattr(fd, attrname, attrvalue, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_fsetxattr(fd, attrname, attrvalue, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) return solaris_fsetxattr(fd, attrname, attrvalue, slen, flags); --- 36,40 ---- return fsetxattr(fd, attrname, attrvalue, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_fsetxattr(fd, attrname, attrvalue, slen, flags); #elif defined(EXTATTR_SOLARIS) return solaris_fsetxattr(fd, attrname, attrvalue, slen, flags); *************** *** 54,59 **** return getxattr(path, attrname, attrvalue, slen, 0, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! /* XXX: flags? Namespace? */ ! return extattr_get_file(path, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); #elif defined(EXTATTR_SOLARIS) return solaris_getxattr(path, attrname, attrvalue, slen, flags); --- 54,58 ---- return getxattr(path, attrname, attrvalue, slen, 0, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_getxattr(path, attrname, attrvalue, slen, flags); #elif defined(EXTATTR_SOLARIS) return solaris_getxattr(path, attrname, attrvalue, slen, flags); *************** *** 73,78 **** return fgetxattr(fd, attrname, attrvalue, slen, 0, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! /* XXX: flags? Namespace? */ ! return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); #elif defined(EXTATTR_SOLARIS) return solaris_fgetxattr(fd, attrname, attrvalue, slen, flags); --- 72,76 ---- return fgetxattr(fd, attrname, attrvalue, slen, 0, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_fgetxattr(fd, attrname, attrvalue, slen, flags); #elif defined(EXTATTR_SOLARIS) return solaris_fgetxattr(fd, attrname, attrvalue, slen, flags); *************** *** 112,117 **** return removexattr(path, name, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! /* XXX: flags? Namespace? */ ! return extattr_delete_file(path, EXTATTR_NAMESPACE_USER, name); #elif defined(EXTATTR_SOLARIS) return solaris_removexattr(path, name, flags); --- 110,114 ---- return removexattr(path, name, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_removexattr(path, name, flags); #elif defined(EXTATTR_SOLARIS) return solaris_removexattr(path, name, flags); *************** *** 127,132 **** return fremovexattr(fd, name, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! /* XXX: flags? Namespace? */ ! return extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name); #elif defined(EXTATTR_SOLARIS) return solaris_fremovexattr(fd, name, flags); --- 124,128 ---- return fremovexattr(fd, name, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_fremovexattr(fd, name, flags); #elif defined(EXTATTR_SOLARIS) return solaris_fremovexattr(fd, name, flags); *************** *** 145,149 **** return listxattr(path, buf, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_listxattr(path, buf, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) return solaris_listxattr(path, buf, slen, flags); --- 141,145 ---- return listxattr(path, buf, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_listxattr(path, buf, slen, flags); #elif defined(EXTATTR_SOLARIS) return solaris_listxattr(path, buf, slen, flags); *************** *** 162,166 **** return flistxattr(fd, buf, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_flistxattr(fd, buf, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) return solaris_flistxattr(fd, buf, slen, flags); --- 158,162 ---- return flistxattr(fd, buf, slen, 0 /* XXX: flags? */); #elif defined(EXTATTR_BSD) ! return bsd_flistxattr(fd, buf, slen, flags); #elif defined(EXTATTR_SOLARIS) return solaris_flistxattr(fd, buf, slen, flags); Index: TODO =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/TODO,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** TODO 15 Aug 2006 08:43:40 -0000 1.11 --- TODO 30 Sep 2006 22:10:12 -0000 1.12 *************** *** 31,34 **** --- 31,36 ---- on Linux, nothing on the other platforms. + TODO: How to handle "user." and the list retrieval? + Document pre-reqs for test suite: Test::Distribution, Test::Pod::Coverage Include these in a .spec file that we can include with distro Index: extattr_bsd.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_bsd.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** extattr_bsd.h 15 Aug 2006 09:14:20 -0000 1.3 --- extattr_bsd.h 30 Sep 2006 22:10:12 -0000 1.4 *************** *** 6,26 **** #include <sys/uio.h> int bsd_setxattr (const char *path, const char *attrname, const char *attrvalue, ! const size_t slen); int bsd_fsetxattr (const int fd, const char *attrname, const char *attrvalue, ! const size_t slen); ssize_t bsd_listxattr (const char *path, char *buf, ! const size_t buflen); ssize_t bsd_flistxattr (const int fd, char *buf, ! const size_t buflen); #endif /* EXTATTR_BSD_H */ --- 6,52 ---- #include <sys/uio.h> + struct hv; + int bsd_setxattr (const char *path, const char *attrname, const char *attrvalue, ! const size_t slen, ! struct hv *flags); int bsd_fsetxattr (const int fd, const char *attrname, const char *attrvalue, ! const size_t slen, ! struct hv *flags); ! ! int bsd_getxattr (const char *path, ! const char *attrname, ! void *attrvalue, ! const size_t slen, ! struct hv *flags); ! ! int bsd_fgetxattr (const int fd, ! const char *attrname, ! void *attrvalue, ! const size_t slen, ! struct hv *flags); ! ! int bsd_removexattr (const char *path, ! const char *attrname, ! struct hv *flags); ! ! int bsd_fremovexattr (const int fd, ! const char *attrname, ! struct hv *flags); ssize_t bsd_listxattr (const char *path, char *buf, ! const size_t buflen, ! struct hv *flags); ssize_t bsd_flistxattr (const int fd, char *buf, ! const size_t buflen, ! struct hv *flags); #endif /* EXTATTR_BSD_H */ |
From: Richard D. <ric...@us...> - 2006-09-30 22:10:16
|
Update of /cvsroot/file-extattr/File-ExtAttr/t In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv1641/t Modified Files: 32nsnonuser.t Log Message: Initial BSD support for attribute flag Index: 32nsnonuser.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/32nsnonuser.t,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** 32nsnonuser.t 28 Aug 2006 11:45:40 -0000 1.2 --- 32nsnonuser.t 30 Sep 2006 22:10:12 -0000 1.3 *************** *** 27,31 **** #set it setfattr($filename, "$key", $val, { namespace => 'nonuser' }); ! is ($warning =~ /(Operation not supported|No such file or directory)/, 1); #read it back --- 27,31 ---- #set it setfattr($filename, "$key", $val, { namespace => 'nonuser' }); ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); #read it back *************** *** 34,38 **** #delete it delfattr($filename, "$key", { namespace => 'nonuser' }); ! is ($warning =~ /(Operation not supported|No such file or directory)/, 1); #check that it's gone --- 34,38 ---- #delete it delfattr($filename, "$key", { namespace => 'nonuser' }); ! is ($warning =~ /(Operation not supported|No such file or directory|Attribute not found)/, 1); #check that it's gone |
From: Richard D. <ric...@us...> - 2006-09-30 22:10:16
|
Update of /cvsroot/file-extattr/File-ExtAttr/lib/File In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv1641/lib/File Modified Files: ExtAttr.pm Log Message: Initial BSD support for attribute flag Index: ExtAttr.pm =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/lib/File/ExtAttr.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ExtAttr.pm 19 Aug 2006 18:34:42 -0000 1.15 --- ExtAttr.pm 30 Sep 2006 22:10:12 -0000 1.16 *************** *** 204,207 **** --- 204,210 ---- If the attribute could not be set, a warning is issued. + Note that C<create> cannot be implemented in a race-free manner on *BSD. + If your code relies on the C<create> behaviour, it may be insecure on *BSD. + =cut |
From: Richard D. <ric...@us...> - 2006-08-28 11:45:47
|
Update of /cvsroot/file-extattr/File-ExtAttr/t In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv8764/t Modified Files: 32nsnonuser.t Log Message: Solaris support for create/replace; Solaris namespace awareness; bugfix: strerror_r different with glibc than POSIX Index: 32nsnonuser.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/32nsnonuser.t,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** 32nsnonuser.t 19 Aug 2006 14:06:25 -0000 1.1 --- 32nsnonuser.t 28 Aug 2006 11:45:40 -0000 1.2 *************** *** 27,31 **** #set it setfattr($filename, "$key", $val, { namespace => 'nonuser' }); ! is ($warning =~ /Operation not supported/, 1); #read it back --- 27,31 ---- #set it setfattr($filename, "$key", $val, { namespace => 'nonuser' }); ! is ($warning =~ /(Operation not supported|No such file or directory)/, 1); #read it back *************** *** 34,38 **** #delete it delfattr($filename, "$key", { namespace => 'nonuser' }); ! is ($warning =~ /Operation not supported/, 1); #check that it's gone --- 34,38 ---- #delete it delfattr($filename, "$key", { namespace => 'nonuser' }); ! is ($warning =~ /(Operation not supported|No such file or directory)/, 1); #check that it's gone |
From: Richard D. <ric...@us...> - 2006-08-28 11:45:47
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv8764 Modified Files: Changes extattr_linux.c extattr_solaris.c extattr_solaris.h helpers.c portable.h Added Files: flags.h Log Message: Solaris support for create/replace; Solaris namespace awareness; bugfix: strerror_r different with glibc than POSIX Index: extattr_solaris.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_solaris.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** extattr_solaris.h 14 Aug 2006 22:00:27 -0000 1.2 --- extattr_solaris.h 28 Aug 2006 11:45:40 -0000 1.3 *************** *** 14,22 **** #endif int solaris_setxattr (const char *path, const char *attrname, const char *attrvalue, const size_t slen, ! const int flags); int solaris_fsetxattr (const int fd, --- 14,24 ---- #endif + struct hv; + int solaris_setxattr (const char *path, const char *attrname, const char *attrvalue, const size_t slen, ! struct hv *flags); int solaris_fsetxattr (const int fd, *************** *** 24,50 **** const char *attrvalue, const size_t slen, ! const int flags); int solaris_getxattr (const char *path, const char *attrname, void *attrvalue, ! const size_t slen); int solaris_fgetxattr (const int fd, const char *attrname, void *attrvalue, ! const size_t slen); ! int solaris_removexattr (const char *path, const char *attrname); ! int solaris_fremovexattr (const int fd, const char *attrname); ssize_t solaris_listxattr (const char *path, char *buf, ! const size_t buflen); ssize_t solaris_flistxattr (const int fd, char *buf, ! const size_t buflen); #endif /* EXTATTR_SOLARIS_H */ --- 26,60 ---- const char *attrvalue, const size_t slen, ! struct hv *flags); int solaris_getxattr (const char *path, const char *attrname, void *attrvalue, ! const size_t slen, ! struct hv *flags); int solaris_fgetxattr (const int fd, const char *attrname, void *attrvalue, ! const size_t slen, ! struct hv *flags); ! int solaris_removexattr (const char *path, ! const char *attrname, ! struct hv *flags); ! int solaris_fremovexattr (const int fd, ! const char *attrname, ! struct hv *flags); ssize_t solaris_listxattr (const char *path, char *buf, ! const size_t buflen, ! struct hv *flags); ssize_t solaris_flistxattr (const int fd, char *buf, ! const size_t buflen, ! struct hv *flags); #endif /* EXTATTR_SOLARIS_H */ Index: extattr_linux.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_linux.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** extattr_linux.c 19 Aug 2006 18:27:18 -0000 1.2 --- extattr_linux.c 28 Aug 2006 11:45:39 -0000 1.3 *************** *** 7,10 **** --- 7,12 ---- #include "XSUB.h" + #include "flags.h" + static const char NAMESPACE_DEFAULT[] = "user"; *************** *** 12,17 **** flags2setflags (struct hv *flags) { - static const char CREATE_KEY[] = "create"; - static const char REPLACE_KEY[] = "replace"; const size_t CREATE_KEYLEN = strlen(CREATE_KEY); const size_t REPLACE_KEYLEN = strlen(REPLACE_KEY); --- 14,17 ---- *************** *** 35,39 **** flags2namespace (struct hv *flags) { - static const char NAMESPACE_KEY[] = "namespace"; const size_t NAMESPACE_KEYLEN = strlen(NAMESPACE_KEY); SV **psv_ns; --- 35,38 ---- Index: extattr_solaris.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_solaris.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** extattr_solaris.c 14 Aug 2006 22:00:27 -0000 1.2 --- extattr_solaris.c 28 Aug 2006 11:45:40 -0000 1.3 *************** *** 9,14 **** --- 9,79 ---- #include <sys/types.h> + #include "EXTERN.h" + #include "perl.h" + #include "XSUB.h" + + #include "flags.h" + static const mode_t ATTRMODE = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP; + typedef enum { + SET_CREATEIFNEEDED = 0, + SET_CREATE, + SET_REPLACE + } setflags_t; + + static setflags_t + flags2setflags (struct hv *flags) + { + const size_t CREATE_KEYLEN = strlen(CREATE_KEY); + const size_t REPLACE_KEYLEN = strlen(REPLACE_KEY); + SV **psv_ns; + setflags_t ret = SET_CREATEIFNEEDED; + + /* + * ASSUMPTION: Perl layer must ensure that create & replace + * aren't used at the same time. + */ + if (flags && (psv_ns = hv_fetch(flags, CREATE_KEY, CREATE_KEYLEN, 0))) + ret = SvIV(*psv_ns) ? SET_CREATE : SET_CREATEIFNEEDED; + + if (flags && (psv_ns = hv_fetch(flags, REPLACE_KEY, REPLACE_KEYLEN, 0))) + ret = SvIV(*psv_ns) ? SET_REPLACE : SET_CREATEIFNEEDED; + + return ret; + } + + static int + valid_namespace (struct hv *flags) + { + const size_t NAMESPACE_KEYLEN = strlen(NAMESPACE_KEY); + SV **psv_ns; + char *ns = NULL; + int ok = 1; /* Default is valid */ + + if (flags && (psv_ns = hv_fetch(flags, NAMESPACE_KEY, NAMESPACE_KEYLEN, 0))) + { + /* + * Undefined => default. Otherwise treat "user" as if it were valid, + * for compatibility with the default on Linux and *BSD. + * An empty namespace (i.e.: zero-length) is not the same as the default. + */ + if (SvOK(*psv_ns)) + { + char *s; + STRLEN len = 0; + + s = SvPV(*psv_ns, len); + + if (len) + ok = (memcmp("user", s, len) == 0); + else + ok = 0; + } + } + + return ok; + } + static int writexattr (const int attrfd, *************** *** 158,170 **** const char *attrvalue, const size_t slen, ! const int flags) { /* XXX: Support overwrite/no overwrite flags */ int saved_errno = 0; int ok = 1; ! int attrfd = attropen(path, attrname, O_RDWR|O_CREAT, ATTRMODE); /* XXX: More common code? */ ! if (attrfd == -1) ok = 0; if (ok && (writexattr(attrfd, attrvalue, slen) == -1)) --- 223,254 ---- const char *attrvalue, const size_t slen, ! struct hv *flags) { /* XXX: Support overwrite/no overwrite flags */ int saved_errno = 0; int ok = 1; ! setflags_t setflags; ! int openflags = O_RDWR; ! int attrfd = -1; ! ! setflags = flags2setflags(flags); ! switch (setflags) ! { ! case SET_CREATEIFNEEDED: openflags |= O_CREAT; break; ! case SET_CREATE: openflags |= O_CREAT | O_EXCL; break; ! case SET_REPLACE: break; ! } ! ! if (!valid_namespace(flags)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! attrfd = attropen(path, attrname, openflags, ATTRMODE); /* XXX: More common code? */ ! if (ok && (attrfd == -1)) ok = 0; if (ok && (writexattr(attrfd, attrvalue, slen) == -1)) *************** *** 185,197 **** const char *attrvalue, const size_t slen, ! const int flags) { /* XXX: Support overwrite/no overwrite flags */ int saved_errno = 0; int ok = 1; ! int attrfd = openat(fd, attrname, O_RDWR|O_CREAT|O_XATTR, ATTRMODE); /* XXX: More common code? */ ! if (attrfd == -1) ok = 0; if (ok && (writexattr(attrfd, attrvalue, slen) == -1)) --- 269,300 ---- const char *attrvalue, const size_t slen, ! struct hv *flags) { /* XXX: Support overwrite/no overwrite flags */ int saved_errno = 0; int ok = 1; ! int openflags = O_RDWR | O_XATTR; ! setflags_t setflags; ! int attrfd = -1; ! ! setflags = flags2setflags(flags); ! switch (setflags) ! { ! case SET_CREATEIFNEEDED: openflags |= O_CREAT; break; ! case SET_CREATE: openflags |= O_CREAT | O_EXCL; break; ! case SET_REPLACE: break; ! } ! ! if (!valid_namespace(flags)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! attrfd = openat(fd, attrname, openflags, ATTRMODE); /* XXX: More common code? */ ! if (ok && (attrfd == -1)) ok = 0; if (ok && (writexattr(attrfd, attrvalue, slen) == -1)) *************** *** 212,219 **** const char *attrname, void *attrvalue, ! const size_t slen) { ! const int attrfd = attropen(path, attrname, O_RDONLY); ! return readclose(attrfd, attrvalue, slen); } --- 315,334 ---- const char *attrname, void *attrvalue, ! const size_t slen, ! struct hv *flags) { ! int attrfd = -1; ! int ok = 1; ! ! if (!valid_namespace(flags)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! attrfd = attropen(path, attrname, O_RDONLY); ! ! return ok ? readclose(attrfd, attrvalue, slen) : -1; } *************** *** 222,247 **** const char *attrname, void *attrvalue, ! const size_t slen) { ! int attrfd = openat(fd, attrname, O_RDONLY|O_XATTR); ! return readclose(attrfd, attrvalue, slen); } int ! solaris_removexattr (const char *path, const char *attrname) { ! int attrdirfd = attropen(path, ".", O_RDONLY); ! return unlinkclose(attrdirfd, attrname); } int ! solaris_fremovexattr (const int fd, const char *attrname) { ! int attrdirfd = openat(fd, ".", O_RDONLY|O_XATTR); ! return unlinkclose(attrdirfd, attrname); } ssize_t ! solaris_listxattr (const char *path, char *buf, const size_t buflen) { int attrdirfd = attropen(path, ".", O_RDONLY); --- 337,403 ---- const char *attrname, void *attrvalue, ! const size_t slen, ! struct hv *flags) { ! int attrfd = -1; ! int ok = 1; ! ! if (!valid_namespace(flags)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! attrfd = openat(fd, attrname, O_RDONLY|O_XATTR); ! ! return ok ? readclose(attrfd, attrvalue, slen) : -1; } int ! solaris_removexattr (const char *path, ! const char *attrname, ! struct hv *flags) { ! int attrdirfd = -1; ! int ok = 1; ! ! if (!valid_namespace(flags)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! attrdirfd = attropen(path, ".", O_RDONLY); ! ! return ok ? unlinkclose(attrdirfd, attrname) : -1; } int ! solaris_fremovexattr (const int fd, ! const char *attrname, ! struct hv *flags) { ! int attrdirfd = -1; ! int ok = 1; ! ! if (!valid_namespace(flags)) ! { ! errno = ENOATTR; ! ok = 0; ! } ! ! if (ok) ! attrdirfd = openat(fd, ".", O_RDONLY|O_XATTR); ! ! return ok ? unlinkclose(attrdirfd, attrname) : -1; } ssize_t ! solaris_listxattr (const char *path, ! char *buf, ! const size_t buflen, ! struct hv *flags) { int attrdirfd = attropen(path, ".", O_RDONLY); *************** *** 250,254 **** ssize_t ! solaris_flistxattr (const int fd, char *buf, const size_t buflen) { int attrdirfd = openat(fd, ".", O_RDONLY|O_XATTR); --- 406,413 ---- ssize_t ! solaris_flistxattr (const int fd, ! char *buf, ! const size_t buflen, ! struct hv *flags) { int attrdirfd = openat(fd, ".", O_RDONLY|O_XATTR); Index: helpers.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/helpers.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** helpers.c 6 Mar 2006 20:04:08 -0000 1.2 --- helpers.c 28 Aug 2006 11:45:40 -0000 1.3 *************** *** 9,20 **** #include "helpers.h" void setattr_warn (const char *funcname, const char *attrname, const int the_errno) { int is_user_xattr; ! char * errstr; is_user_xattr = (strncmp(attrname, "user.", 5) == 0); ! New(1, errstr, 1000, char); // Try to give the user a useful hint of what went wrong. --- 9,46 ---- #include "helpers.h" + #ifdef __GLIBC__ + + static inline char * + my_strerror_r (const int the_errno, char *buf, const size_t buflen) + { + buf[0] = '\0'; + + return strerror_r(the_errno, buf, buflen); + } + + #else + + static inline char * + my_strerror_r (const int the_errno, char *buf, const size_t buflen) + { + buf[0] = '\0'; + strerror_r(the_errno, buf, buflen); + + return buf; + } + + #endif + void setattr_warn (const char *funcname, const char *attrname, const int the_errno) { + static const size_t BUFLEN = 100; int is_user_xattr; ! char *buf; ! char *errstr; is_user_xattr = (strncmp(attrname, "user.", 5) == 0); ! New(1, buf, BUFLEN, char); ! errstr = my_strerror_r(the_errno, buf, BUFLEN); // Try to give the user a useful hint of what went wrong. *************** *** 31,35 **** " needs a \"user.\" prefix?", funcname, ! strerror_r(the_errno,errstr,1000)); } else --- 57,61 ---- " needs a \"user.\" prefix?", funcname, ! errstr); } else *************** *** 39,52 **** " with an option to enable extended attributes?", funcname, ! strerror_r(the_errno,errstr,1000)); } } else { ! warn("%s failed: %s", ! funcname, ! strerror_r(the_errno,errstr,1000)); } ! Safefree(errstr); } --- 65,76 ---- " with an option to enable extended attributes?", funcname, ! errstr); } } else { ! warn("%s failed: %s", funcname, errstr); } ! Safefree(buf); } --- NEW FILE: flags.h --- #ifndef EXTATTR_FLAGS_H #define EXTATTR_FLAGS_H static const char NAMESPACE_KEY[] = "namespace"; static const char CREATE_KEY[] = "create"; static const char REPLACE_KEY[] = "replace"; #endif /* EXTATTR_FLAGS_H */ Index: portable.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/portable.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** portable.h 19 Aug 2006 14:06:25 -0000 1.8 --- portable.h 28 Aug 2006 11:45:40 -0000 1.9 *************** *** 20,24 **** return bsd_setxattr(path, attrname, attrvalue, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) ! return solaris_setxattr(path, attrname, attrvalue, slen, 0 /* XXX: flags? */); #else return linux_setxattr(path, attrname, attrvalue, slen, flags); --- 20,24 ---- return bsd_setxattr(path, attrname, attrvalue, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) ! return solaris_setxattr(path, attrname, attrvalue, slen, flags); #else return linux_setxattr(path, attrname, attrvalue, slen, flags); *************** *** 38,42 **** return bsd_fsetxattr(fd, attrname, attrvalue, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) ! return solaris_fsetxattr(fd, attrname, attrvalue, slen, 0 /* XXX: flags? */); #else return linux_fsetxattr(fd, attrname, attrvalue, slen, flags); --- 38,42 ---- return bsd_fsetxattr(fd, attrname, attrvalue, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) ! return solaris_fsetxattr(fd, attrname, attrvalue, slen, flags); #else return linux_fsetxattr(fd, attrname, attrvalue, slen, flags); *************** *** 57,61 **** return extattr_get_file(path, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); #elif defined(EXTATTR_SOLARIS) ! return solaris_getxattr(path, attrname, attrvalue, slen /* XXX: flags? */); #else return linux_getxattr(path, attrname, attrvalue, slen, flags); --- 57,61 ---- return extattr_get_file(path, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); #elif defined(EXTATTR_SOLARIS) ! return solaris_getxattr(path, attrname, attrvalue, slen, flags); #else return linux_getxattr(path, attrname, attrvalue, slen, flags); *************** *** 76,80 **** return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); #elif defined(EXTATTR_SOLARIS) ! return solaris_fgetxattr(fd, attrname, attrvalue, slen /* XXX: flags? */); #else return linux_fgetxattr(fd, attrname, attrvalue, slen, flags); --- 76,80 ---- return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); #elif defined(EXTATTR_SOLARIS) ! return solaris_fgetxattr(fd, attrname, attrvalue, slen, flags); #else return linux_fgetxattr(fd, attrname, attrvalue, slen, flags); *************** *** 115,119 **** return extattr_delete_file(path, EXTATTR_NAMESPACE_USER, name); #elif defined(EXTATTR_SOLARIS) ! return solaris_removexattr(path, name /* XXX: flags? */); #else return linux_removexattr(path, name, flags); --- 115,119 ---- return extattr_delete_file(path, EXTATTR_NAMESPACE_USER, name); #elif defined(EXTATTR_SOLARIS) ! return solaris_removexattr(path, name, flags); #else return linux_removexattr(path, name, flags); *************** *** 130,134 **** return extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name); #elif defined(EXTATTR_SOLARIS) ! return solaris_fremovexattr(fd, name /* XXX: flags? */); #else return linux_fremovexattr(fd, name, flags); --- 130,134 ---- return extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name); #elif defined(EXTATTR_SOLARIS) ! return solaris_fremovexattr(fd, name, flags); #else return linux_fremovexattr(fd, name, flags); *************** *** 147,151 **** return bsd_listxattr(path, buf, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) ! return solaris_listxattr(path, buf, slen /* XXX: flags? */); #else return linux_listxattr(path, buf, slen, flags); --- 147,151 ---- return bsd_listxattr(path, buf, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) ! return solaris_listxattr(path, buf, slen, flags); #else return linux_listxattr(path, buf, slen, flags); *************** *** 164,168 **** return bsd_flistxattr(fd, buf, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) ! return solaris_flistxattr(fd, buf, slen /* XXX: flags? */); #else return linux_flistxattr(fd, buf, slen, flags); --- 164,168 ---- return bsd_flistxattr(fd, buf, slen /* XXX: flags? */); #elif defined(EXTATTR_SOLARIS) ! return solaris_flistxattr(fd, buf, slen, flags); #else return linux_flistxattr(fd, buf, slen, flags); Index: Changes =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/Changes,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Changes 15 Aug 2006 09:18:04 -0000 1.17 --- Changes 28 Aug 2006 11:45:39 -0000 1.18 *************** *** 1,7 **** Revision history for Perl extension File::ExtAttr. ! 1.00 2006-08-15 - (richdawe) Add support for Solaris 10. - (richdawe) Add support for File::ExtAttr::Tie on *BSD. 0.05 2006-05-27 --- 1,10 ---- Revision history for Perl extension File::ExtAttr. ! 1.00 2006-08-28 - (richdawe) Add support for Solaris 10. - (richdawe) Add support for File::ExtAttr::Tie on *BSD. + - (richdawe) API change: Namespace and the create/replace flag + are now passed via a hash. This breaks API compatibility. + There should be no further API changes. 0.05 2006-05-27 |
From: Richard D. <ric...@us...> - 2006-08-19 18:49:16
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv16477 Modified Files: MANIFEST Log Message: Fix manifest Index: MANIFEST =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/MANIFEST,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** MANIFEST 19 Aug 2006 14:06:22 -0000 1.12 --- MANIFEST 19 Aug 2006 18:49:13 -0000 1.13 *************** *** 21,28 **** t/02load-all.t t/03pod-coverage.t - t/10constants.t t/11basic.t t/13long.t t/14optional.t t/20tie-basic.t t/30nsbasic.t --- 21,30 ---- t/02load-all.t t/03pod-coverage.t t/11basic.t t/13long.t t/14optional.t + t/15create.t + t/16replace.t + t/17createreplace.t t/20tie-basic.t t/30nsbasic.t |
From: Richard D. <ric...@us...> - 2006-08-19 18:34:46
|
Update of /cvsroot/file-extattr/File-ExtAttr/lib/File In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv10710/lib/File Modified Files: ExtAttr.pm Log Message: Remove code for constants -- it's not needed, now we have portable flags Index: ExtAttr.pm =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/lib/File/ExtAttr.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** ExtAttr.pm 19 Aug 2006 18:27:18 -0000 1.14 --- ExtAttr.pm 19 Aug 2006 18:34:42 -0000 1.15 *************** *** 138,164 **** $File::ExtAttr::MAX_INITIAL_VALUELEN = 255; - sub AUTOLOAD { - # This AUTOLOAD is used to 'autoload' constants from the constant() - # XS function. - - my $constname; - our $AUTOLOAD; - ($constname = $AUTOLOAD) =~ s/.*:://; - croak "&File::ExtAttr::constant not defined" if $constname eq 'constant'; - my ($error, $val) = constant($constname); - if ($error) { croak $error; } - { - no strict 'refs'; - # Fixed between 5.005_53 and 5.005_61 - #XXX if ($] >= 5.00561) { - #XXX *$AUTOLOAD = sub () { $val }; - #XXX } - #XXX else { - *$AUTOLOAD = sub { $val }; - #XXX } - } - goto &$AUTOLOAD; - } - require XSLoader; XSLoader::load('File::ExtAttr', $VERSION); --- 138,141 ---- |
From: Richard D. <ric...@us...> - 2006-08-19 18:34:46
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv10710 Modified Files: ExtAttr.xs Makefile.PL Log Message: Remove code for constants -- it's not needed, now we have portable flags Index: ExtAttr.xs =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/ExtAttr.xs,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ExtAttr.xs 19 Aug 2006 18:27:18 -0000 1.18 --- ExtAttr.xs 19 Aug 2006 18:34:42 -0000 1.19 *************** *** 7,12 **** #include "portable.h" - /* NB: Include this after portable.h (or <sys/xattr.h>) */ - #include "const-c.inc" #define MAX_INITIAL_VALUELEN_VARNAME "File::ExtAttr::MAX_INITIAL_VALUELEN" --- 7,10 ---- *************** *** 16,21 **** MODULE = File::ExtAttr PACKAGE = File::ExtAttr - INCLUDE: const-xs.inc - PROTOTYPES: ENABLE --- 14,17 ---- Index: Makefile.PL =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/Makefile.PL,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Makefile.PL 20 Jan 2006 22:43:37 -0000 1.5 --- Makefile.PL 19 Aug 2006 18:34:42 -0000 1.6 *************** *** 46,72 **** # OBJECT => '$(O_FILES)', # link all the C files too ); - if (eval {require ExtUtils::Constant; 1}) { - # If you edit these definitions to change the constants used by this module, - # you will need to use the generated const-c.inc and const-xs.inc - # files to replace their "fallback" counterparts before distributing your - # changes. - my @names = (qw(XATTR_CREATE XATTR_REPLACE)); - ExtUtils::Constant::WriteConstants( - NAME => 'File::ExtAttr', - NAMES => \@names, - DEFAULT_TYPE => 'IV', - C_FILE => 'const-c.inc', - XS_FILE => 'const-xs.inc', - ); - - } - else { - use File::Copy; - use File::Spec; - foreach my $file ('const-c.inc', 'const-xs.inc') { - my $fallback = File::Spec->catfile('fallback', $file); - copy ($fallback, $file) or die "Can't copy $fallback to $file: $!"; - } - } --- 46,49 ---- |
From: Richard D. <ric...@us...> - 2006-08-19 18:34:46
|
Update of /cvsroot/file-extattr/File-ExtAttr/t In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv10710/t Removed Files: 10constants.t Log Message: Remove code for constants -- it's not needed, now we have portable flags --- 10constants.t DELETED --- |
From: Richard D. <ric...@us...> - 2006-08-19 18:27:22
|
Update of /cvsroot/file-extattr/File-ExtAttr/lib/File In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv7869/lib/File Modified Files: ExtAttr.pm Log Message: Add create and replace flags (to replace usage of XATTR_CREATE, XATTR_REPLACE); bugfix: setfattr returns 0 on failure now Index: ExtAttr.pm =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/lib/File/ExtAttr.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ExtAttr.pm 19 Aug 2006 14:06:25 -0000 1.13 --- ExtAttr.pm 19 Aug 2006 18:27:18 -0000 1.14 *************** *** 218,233 **** C<$filehandle> (which should be an IO::Handle). ! XXX: FIXME: Below ! ! C<$flags> allows control of whether the attribute should be created ! or should replace an existing attribute's value. The value ! C<File::ExtAttr::XATTR_CREATE> will cause setfattr to fail ! if the attribute already exists. The value C<File::ExtAttr::XATTR_REPLACE> ! will cause setfattr to fail if the attribute does not already exist. ! If C<$flags> is omitted, then the attribute will be created if necessary ! or silently replaced. ! ! NOTE: C<XATTR_*> are currently Linux-specific. A more portable set of flags ! is on the to-do list. If the attribute could not be set, a warning is issued. --- 218,227 ---- C<$filehandle> (which should be an IO::Handle). ! C<%flags> allows control of whether the attribute should be created ! or should replace an existing attribute's value. If the key C<create> ! is true, setfattr will fail if the attribute already exists. If the key ! C<replace> is true, setfattr will fail if the attribute ! does not already exist. If neither is specified, then the attribute ! will be created (if necessary) or silently replaced. If the attribute could not be set, a warning is issued. *************** *** 237,247 **** sub setfattr { ! my $file = shift; return _is_fh($file) # File handle ! ? _fsetfattr($file->fileno(), @_) # Filename ! : _setfattr($file, @_); } --- 231,244 ---- sub setfattr { ! my ($file, $attrname, $attrval, $flagsref) = @_; ! ! die "Only one of the 'create' and 'replace' options can be passed to setfattr" ! if ($flagsref->{create} && $flagsref->{replace}); return _is_fh($file) # File handle ! ? _fsetfattr($file->fileno(), $attrname, $attrval, $flagsref) # Filename ! : _setfattr($file, $attrname, $attrval, $flagsref); } |
From: Richard D. <ric...@us...> - 2006-08-19 18:27:22
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv7869 Modified Files: ExtAttr.xs extattr_linux.c Log Message: Add create and replace flags (to replace usage of XATTR_CREATE, XATTR_REPLACE); bugfix: setfattr returns 0 on failure now Index: extattr_linux.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_linux.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** extattr_linux.c 19 Aug 2006 14:06:22 -0000 1.1 --- extattr_linux.c 19 Aug 2006 18:27:18 -0000 1.2 *************** *** 9,12 **** --- 9,35 ---- static const char NAMESPACE_DEFAULT[] = "user"; + static int + flags2setflags (struct hv *flags) + { + static const char CREATE_KEY[] = "create"; + static const char REPLACE_KEY[] = "replace"; + const size_t CREATE_KEYLEN = strlen(CREATE_KEY); + const size_t REPLACE_KEYLEN = strlen(REPLACE_KEY); + SV **psv_ns; + int ret = 0; + + /* + * ASSUMPTION: Perl layer must ensure that create & replace + * aren't used at the same time. + */ + if (flags && (psv_ns = hv_fetch(flags, CREATE_KEY, CREATE_KEYLEN, 0))) + ret = SvIV(*psv_ns) ? XATTR_CREATE : 0; + + if (flags && (psv_ns = hv_fetch(flags, REPLACE_KEY, REPLACE_KEYLEN, 0))) + ret = SvIV(*psv_ns) ? XATTR_REPLACE : 0; + + return ret; + } + static char * flags2namespace (struct hv *flags) *************** *** 70,79 **** int ret; char *q; ! /* XXX: Other flags? */ q = qualify_attrname(attrname, flags); if (q) { ! ret = setxattr(path, q, attrvalue, slen, 0); free(q); } --- 93,104 ---- int ret; char *q; + int setflags; ! setflags = flags2setflags(flags); q = qualify_attrname(attrname, flags); + if (q) { ! ret = setxattr(path, q, attrvalue, slen, setflags); free(q); } *************** *** 96,105 **** int ret; char *q; ! /* XXX: Other flags? */ q = qualify_attrname(attrname, flags); if (q) { ! ret = fsetxattr(fd, q, attrvalue, slen, 0); free(q); } --- 121,132 ---- int ret; char *q; + int setflags; ! setflags = flags2setflags(flags); q = qualify_attrname(attrname, flags); + if (q) { ! ret = fsetxattr(fd, q, attrvalue, slen, setflags); free(q); } Index: ExtAttr.xs =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/ExtAttr.xs,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** ExtAttr.xs 19 Aug 2006 14:06:22 -0000 1.17 --- ExtAttr.xs 19 Aug 2006 18:27:18 -0000 1.18 *************** *** 36,43 **** rc = portable_setxattr(path, attrname, attrvalue, slen, flags); if (rc == -1) ! { ! setattr_warn("setxattr", attrname, errno); ! XSRETURN_UNDEF; ! } RETVAL = (rc == 0); --- 36,40 ---- rc = portable_setxattr(path, attrname, attrvalue, slen, flags); if (rc == -1) ! setattr_warn("setxattr", attrname, errno); RETVAL = (rc == 0); *************** *** 61,68 **** rc = portable_fsetxattr(fd, attrname, attrvalue, slen, flags); if (rc == -1) ! { ! setattr_warn("fsetxattr", attrname, errno); ! XSRETURN_UNDEF; ! } RETVAL = (rc == 0); --- 58,62 ---- rc = portable_fsetxattr(fd, attrname, attrvalue, slen, flags); if (rc == -1) ! setattr_warn("fsetxattr", attrname, errno); RETVAL = (rc == 0); |