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-08-19 18:27:22
|
Update of /cvsroot/file-extattr/File-ExtAttr/t In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv7869/t Added Files: 15create.t 16replace.t 17createreplace.t Log Message: Add create and replace flags (to replace usage of XATTR_CREATE, XATTR_REPLACE); bugfix: setfattr returns 0 on failure now --- NEW FILE: 16replace.t --- #!perl -T # 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 => 10; use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); 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"; ########################## # Filename-based tests # ########################## print "# using $filename\n"; #create it is (setfattr($filename, "$key", $val, { create => 1 }), 1); #replace it is (setfattr($filename, "$key", $val, { replace => 1 }), 1); #read it back is (getfattr($filename, "$key"), $val); #delete it ok (delfattr($filename, "$key")); #check that it's gone is (getfattr($filename, "$key"), undef); ########################## # IO::Handle-based tests # ########################## $fh = new IO::File("<$filename") || die "Unable to open $filename"; print "# using file descriptor ".$fh->fileno()."\n"; #create it is (setfattr($fh, "$key", $val, { create => 1 }), 1); #replace it is (setfattr($fh, "$key", $val, { replace => 1 }), 1); #read it back is (getfattr($fh, "$key"), $val); #delete it ok (delfattr($fh, "$key")); #check that it's gone is (getfattr($fh, "$key"), undef); END {unlink $filename if $filename}; --- NEW FILE: 15create.t --- #!perl -T # 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 => 10; use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); 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"; ########################## # Filename-based tests # ########################## print "# using $filename\n"; #create it is (setfattr($filename, "$key", $val, { create => 1 }), 1); #create it again -- should fail is (setfattr($filename, "$key", $val, { create => 1 }), 0); #read it back is (getfattr($filename, "$key"), $val); #delete it ok (delfattr($filename, "$key")); #check that it's gone is (getfattr($filename, "$key"), undef); ########################## # IO::Handle-based tests # ########################## $fh = new IO::File("<$filename") || die "Unable to open $filename"; print "# using file descriptor ".$fh->fileno()."\n"; #create it is (setfattr($fh, "$key", $val, { create => 1 }), 1); #create it again -- should fail is (setfattr($fh, "$key", $val, { create => 1 }), 0); #read it back is (getfattr($fh, "$key"), $val); #delete it ok (delfattr($fh, "$key")); #check that it's gone is (getfattr($fh, "$key"), undef); END {unlink $filename if $filename}; --- NEW FILE: 17createreplace.t --- #!perl -T # 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 => 4; use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); 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"; ########################## # Filename-based tests # ########################## print "# using $filename\n"; #create and replace it -- should fail undef $@; eval { setfattr($filename, "$key", $val, { create => 1, replace => 1 }); }; isnt ($@, undef); #check that it's not been created is (getfattr($filename, "$key"), undef); ########################## # IO::Handle-based tests # ########################## $fh = new IO::File("<$filename") || die "Unable to open $filename"; print "# using file descriptor ".$fh->fileno()."\n"; my $key2 = $key.'2'; #create and replace it -- should fail undef $@; eval { setfattr($fh, $key2, $val, { create => 1, replace => 1 }); }; isnt ($@, undef); #check that it's not been created is (getfattr($fh, $key2), undef); END {unlink $filename if $filename}; |
From: Richard D. <ric...@us...> - 2006-08-19 14:06:30
|
Update of /cvsroot/file-extattr/File-ExtAttr/lib/File In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv32007/lib/File Modified Files: ExtAttr.pm Log Message: Initial support for cross-platform namespacing on Linux Index: ExtAttr.pm =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/lib/File/ExtAttr.pm,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ExtAttr.pm 15 Aug 2006 09:18:04 -0000 1.12 --- ExtAttr.pm 19 Aug 2006 14:06:25 -0000 1.13 *************** *** 11,32 **** # Manipulate the extended attributes of files. ! setfattr('foo.txt', 'user.colour', 'red') || die; ! my $colour = getfattr('bar.txt', 'user.colour'); if (defined($colour)) { print $colour; ! delfattr('bar.txt', 'user.colour'); } # Manipulate the extended attributes of a file via a file handle. my $fh = new IO::File('<foo.txt') || die; ! setfattr($fh, 'user.colour', 'red') || die; $fh = new IO::File('<bar.txt') || die; ! $colour = getfattr($fh, 'user.colour'); if (defined($colour)) { print $colour; ! delfattr($fh, 'user.colour'); } --- 11,32 ---- # Manipulate the extended attributes of files. ! setfattr('foo.txt', 'colour', 'red') || die; ! my $colour = getfattr('bar.txt', 'colour'); if (defined($colour)) { print $colour; ! delfattr('bar.txt', 'colour'); } # Manipulate the extended attributes of a file via a file handle. my $fh = new IO::File('<foo.txt') || die; ! setfattr($fh, 'colour', 'red') || die; $fh = new IO::File('<bar.txt') || die; ! $colour = getfattr($fh, 'colour'); if (defined($colour)) { print $colour; ! delfattr($fh, 'colour'); } *************** *** 45,53 **** Extended attributes may also not be supported by your filesystem ! or require special options to be enabled for a particular filesystem ! (e.g. "mount -o user_xattr /dev/hda1 /some/path"). ! NOTE: The API is not stable. It may change as part of supporting ! multiple operating systems. =cut --- 45,108 ---- Extended attributes may also not be supported by your filesystem ! or require special options to be enabled for a particular filesystem. ! E.g.: ! mount -o user_xattr /dev/hda1 /some/path ! ! =head2 Namespaces ! ! Some implementations of extended attributes support namespacing. ! In those implementations, the attribute is referred to by namespace ! and attribute name. ! ! =over 4 ! ! =item Linux ! ! The primary namespaces are C<user> for user programs; ! C<security>, C<system> and C<trusted> for file security/access-control. ! See L<http://www.die.net/doc/linux/man/man5/attr.5.html> ! for more details. ! ! Namespaces on Linux are described by a string, but only certain values ! are supported by filesystems. In general C<user>, C<security>, C<system> ! and C<trusted> are supported, by others may be supported -- ! e.g.: C<os2> on JFS. File::Extattr will be able to access any of these. ! ! =item FreeBSD, NetBSD, OpenBSD ! ! *BSD have two namespaces: C<user> and C<system>. ! ! Namespaces on *BSD are described by an integer. File::ExtAttr will only ! be able to access attributes in C<user> and C<system>. ! ! =item Mac OS X ! ! OS X has no support for namespaces. ! ! =item Solaris ! ! Solaris has no support for namespaces. ! ! =back ! ! =head2 Flags ! ! The functions take a hash reference as their final parameter, ! which can specify flags to modify the behaviour of the functions. ! The flags specific to a function are documented in the function's ! description. ! ! All functions support a C<namespace> flag. E.g.: ! ! use File::ExtAttr ':all'; ! use IO::File; ! ! # Manipulate the extended attributes of files. ! setfattr('foo.txt', 'colour', 'red') || die; ! my $colour = getfattr('bar.txt', 'colour', { namespace => 'user'); ! ! If no namespace is specified, the default namespace will be used. ! On Linux and *BSD the default namespace will be C<user>. =cut *************** *** 136,140 **** } ! =item getfattr([$filename | $filehandle], $attrname, [$flags]) Return the value of the attribute named C<$attrname> --- 191,195 ---- } ! =item getfattr([$filename | $filehandle], $attrname, [\%flags]) Return the value of the attribute named C<$attrname> *************** *** 142,147 **** C<$filehandle> (which should be an IO::Handle). - C<$flags> are currently unused. - If no attribute is found, returns C<undef>. Otherwise gives a warning. --- 197,200 ---- *************** *** 159,163 **** } ! =item setfattr([$filename | $filehandle], $attrname, $attrval, [$flags]) Set the attribute named C<$attrname> with the value C<$attrval> --- 212,216 ---- } ! =item setfattr([$filename | $filehandle], $attrname, $attrval, [\%flags]) Set the attribute named C<$attrname> with the value C<$attrval> *************** *** 165,168 **** --- 218,223 ---- 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 *************** *** 191,195 **** } ! =item delfattr([$filename | $filehandle], $attrname, [$flags]) Delete the attribute named C<$attrname> for the file named C<$filename> --- 246,250 ---- } ! =item delfattr([$filename | $filehandle], $attrname, [\%flags]) Delete the attribute named C<$attrname> for the file named C<$filename> *************** *** 197,202 **** (which should be an IO::Handle). - C<$flags> are currently unused. - Returns true on success, otherwise false and a warning is issued. --- 252,255 ---- *************** *** 214,224 **** } ! =item listfattr([$filename | $filehandle], [$flags]) Return the attributes on the file named C<$filename> or referenced by the open filehandle C<$filehandle> (which should be an IO::Handle). - C<$flags> are currently unused. - Returns undef on failure and $! will be set. --- 267,275 ---- } ! =item listfattr([$filename | $filehandle], [\%flags]) Return the 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. *************** *** 247,252 **** None by default. ! You can request that C<getfattr>, C<setfattr> and C<delfattr> be exported ! using the tag ":all". =head2 Exportable constants --- 298,303 ---- None by default. ! You can request that C<getfattr>, C<setfattr>, C<delfattr> ! and C<listfattr> be exported using the tag ":all". =head2 Exportable constants |
From: Richard D. <ric...@us...> - 2006-08-19 14:06:30
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv32007 Modified Files: ExtAttr.xs MANIFEST extattr_linux.h extattr_os.h portable.h Added Files: extattr_linux.c Log Message: Initial support for cross-platform namespacing on Linux --- NEW FILE: extattr_linux.c --- #include "extattr_os.h" #ifdef EXTATTR_LINUX #include "EXTERN.h" #include "perl.h" #include "XSUB.h" static const char NAMESPACE_DEFAULT[] = "user"; static char * flags2namespace (struct hv *flags) { static const char NAMESPACE_KEY[] = "namespace"; const size_t NAMESPACE_KEYLEN = strlen(NAMESPACE_KEY); SV **psv_ns; char *ns = NULL; if (flags && (psv_ns = hv_fetch(flags, NAMESPACE_KEY, NAMESPACE_KEYLEN, 0))) { char *s; STRLEN len; s = SvPV(*psv_ns, len); ns = malloc(len + 1); if (ns) { strncpy(ns, s, len); ns[len] = '\0'; } } else { ns = strdup(NAMESPACE_DEFAULT); } return ns; } static char * qualify_attrname (const char *attrname, struct hv *flags) { 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; } int linux_setxattr (const char *path, const char *attrname, const char *attrvalue, const size_t slen, struct hv *flags) { int ret; char *q; /* XXX: Other flags? */ q = qualify_attrname(attrname, flags); if (q) { ret = setxattr(path, q, attrvalue, slen, 0); free(q); } else { ret = -1; errno = ENOMEM; } return ret; } int linux_fsetxattr (const int fd, const char *attrname, const char *attrvalue, const size_t slen, struct hv *flags) { int ret; char *q; /* XXX: Other flags? */ q = qualify_attrname(attrname, flags); if (q) { ret = fsetxattr(fd, q, attrvalue, slen, 0); free(q); } else { ret = -1; errno = ENOMEM; } return ret; } int linux_getxattr (const char *path, const char *attrname, void *attrvalue, const size_t slen, struct hv *flags) { int ret; char *q; q = qualify_attrname(attrname, flags); if (q) { ret = getxattr(path, q, attrvalue, slen); free(q); } else { ret = -1; errno = ENOMEM; } return ret; } int linux_fgetxattr (const int fd, const char *attrname, void *attrvalue, const size_t slen, struct hv *flags) { int ret; char *q; q = qualify_attrname(attrname, flags); if (q) { ret = fgetxattr(fd, q, attrvalue, slen); free(q); } else { ret = -1; errno = ENOMEM; } return ret; } int linux_removexattr (const char *path, const char *attrname, struct hv *flags) { int ret; char *q; /* XXX: Other flags? */ q = qualify_attrname(attrname, flags); if (q) { ret = removexattr(path, q); free(q); } else { ret = -1; errno = ENOMEM; } return ret; } int linux_fremovexattr (const int fd, const char *attrname, struct hv *flags) { int ret; char *q; /* XXX: Other flags? */ q = qualify_attrname(attrname, flags); if (q) { ret = fremovexattr(fd, q); free(q); } else { ret = -1; errno = ENOMEM; } return ret; } 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); } #endif /* EXTATTR_LINUX */ Index: ExtAttr.xs =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/ExtAttr.xs,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** ExtAttr.xs 14 Aug 2006 21:01:46 -0000 1.16 --- ExtAttr.xs 19 Aug 2006 14:06:22 -0000 1.17 *************** *** 26,30 **** const char *attrname SV * attrvalueSV ! int flags PREINIT: STRLEN slen; --- 26,30 ---- const char *attrname SV * attrvalueSV ! HV * flags PREINIT: STRLEN slen; *************** *** 51,55 **** const char *attrname SV * attrvalueSV ! int flags PREINIT: STRLEN slen; --- 51,55 ---- const char *attrname SV * attrvalueSV ! HV * flags PREINIT: STRLEN slen; *************** *** 75,79 **** const char *path const char *attrname ! int flags PREINIT: char * attrvalue; --- 75,79 ---- const char *path const char *attrname ! HV * flags PREINIT: char * attrvalue; *************** *** 82,86 **** CODE: ! buflen = portable_lenxattr(path, attrname); if (buflen <= 0) buflen = SvIV(get_sv(MAX_INITIAL_VALUELEN_VARNAME, FALSE)); --- 82,86 ---- CODE: ! buflen = portable_lenxattr(path, attrname, flags); if (buflen <= 0) buflen = SvIV(get_sv(MAX_INITIAL_VALUELEN_VARNAME, FALSE)); *************** *** 89,93 **** New(1, attrvalue, buflen, char); ! attrlen = portable_getxattr(path, attrname, attrvalue, buflen); if (attrlen == -1){ --- 89,93 ---- New(1, attrvalue, buflen, char); ! attrlen = portable_getxattr(path, attrname, attrvalue, buflen, flags); if (attrlen == -1){ *************** *** 116,120 **** int fd const char *attrname ! int flags PREINIT: char * attrvalue; --- 116,120 ---- int fd const char *attrname ! HV * flags PREINIT: char * attrvalue; *************** *** 123,127 **** CODE: ! buflen = portable_flenxattr(fd, attrname); if (buflen <= 0) buflen = SvIV(get_sv(MAX_INITIAL_VALUELEN_VARNAME, FALSE)); --- 123,127 ---- CODE: ! buflen = portable_flenxattr(fd, attrname, flags); if (buflen <= 0) buflen = SvIV(get_sv(MAX_INITIAL_VALUELEN_VARNAME, FALSE)); *************** *** 130,134 **** New(1, attrvalue, buflen, char); ! attrlen = portable_fgetxattr(fd, attrname, attrvalue, buflen); if (attrlen == -1){ --- 130,134 ---- New(1, attrvalue, buflen, char); ! attrlen = portable_fgetxattr(fd, attrname, attrvalue, buflen, flags); if (attrlen == -1){ *************** *** 157,163 **** const char *path const char *attrname ! int flags CODE: ! RETVAL = (portable_removexattr(path, attrname) == 0); OUTPUT: --- 157,163 ---- const char *path const char *attrname ! HV * flags CODE: ! RETVAL = (portable_removexattr(path, attrname, flags) == 0); OUTPUT: *************** *** 169,175 **** int fd const char *attrname ! int flags CODE: ! RETVAL = (portable_fremovexattr(fd, attrname) == 0); OUTPUT: --- 169,175 ---- int fd const char *attrname ! HV * flags CODE: ! RETVAL = (portable_fremovexattr(fd, attrname, flags) == 0); OUTPUT: *************** *** 180,184 **** const char *path int fd ! int flags PREINIT: ssize_t size, ret; --- 180,184 ---- const char *path int fd ! HV * flags PREINIT: ssize_t size, ret; *************** *** 188,194 **** PPCODE: if(fd == -1) ! size = portable_listxattr(path, NULL, 0); else ! size = portable_flistxattr(fd, NULL, 0); if (size == -1) --- 188,194 ---- PPCODE: if(fd == -1) ! size = portable_listxattr(path, NULL, 0, flags); else ! size = portable_flistxattr(fd, NULL, 0, flags); if (size == -1) *************** *** 203,209 **** if (fd == -1) ! ret = portable_listxattr(path, namebuf, size); else ! ret = portable_flistxattr(fd, namebuf, size); // There could be a race condition here, if someone adds a new --- 203,209 ---- if (fd == -1) ! ret = portable_listxattr(path, namebuf, size, flags); else ! ret = portable_flistxattr(fd, namebuf, size, flags); // There could be a race condition here, if someone adds a new Index: extattr_linux.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_linux.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** extattr_linux.h 14 Aug 2006 21:10:54 -0000 1.1 --- extattr_linux.h 19 Aug 2006 14:06:22 -0000 1.2 *************** *** 6,8 **** --- 6,52 ---- #include <attr/xattr.h> + struct hv; + + int linux_setxattr (const char *path, + const char *attrname, + const char *attrvalue, + const size_t slen, + struct hv *flags); + + int linux_fsetxattr (const int fd, + const char *attrname, + const char *attrvalue, + const size_t slen, + struct hv *flags); + + int linux_getxattr (const char *path, + const char *attrname, + void *attrvalue, + const size_t slen, + struct hv *flags); + + int linux_fgetxattr (const int fd, + const char *attrname, + void *attrvalue, + const size_t slen, + struct hv *flags); + + int linux_removexattr (const char *path, + const char *attrname, + struct hv *flags); + + int linux_fremovexattr (const int fd, + const char *attrname, + struct hv *flags); + + ssize_t linux_listxattr (const char *path, + char *buf, + const size_t buflen, + struct hv *flags); + + ssize_t linux_flistxattr (const int fd, + char *buf, + const size_t buflen, + struct hv *flags); + #endif /* EXTATTR_LINUX_H */ Index: MANIFEST =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/MANIFEST,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** MANIFEST 14 Aug 2006 21:16:47 -0000 1.11 --- MANIFEST 19 Aug 2006 14:06:22 -0000 1.12 *************** *** 23,30 **** t/10constants.t t/11basic.t - t/12nonuser.t t/13long.t t/14optional.t t/20tie-basic.t lib/File/ExtAttr.pm lib/File/ExtAttr/Tie.pm --- 23,33 ---- t/10constants.t t/11basic.t t/13long.t t/14optional.t t/20tie-basic.t + t/30nsbasic.t + t/32nsnonuser.t + t/33nslong.t + t/39nsempty.t lib/File/ExtAttr.pm lib/File/ExtAttr/Tie.pm Index: extattr_os.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_os.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** extattr_os.h 15 Aug 2006 09:14:20 -0000 1.2 --- extattr_os.h 19 Aug 2006 14:06:23 -0000 1.3 *************** *** 19,22 **** --- 19,26 ---- #endif + #if defined(linux) + #define EXTATTR_LINUX + #endif + /* Include appropriate header for this OS, defaulting to Linux-style */ #if defined(EXTATTR_BSD) Index: portable.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/portable.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** portable.h 15 Aug 2006 09:14:20 -0000 1.7 --- portable.h 19 Aug 2006 14:06:25 -0000 1.8 *************** *** 5,8 **** --- 5,10 ---- #include "extattr_os.h" + struct hv; + /* Portable extattr functions */ static inline int *************** *** 11,24 **** const void *attrvalue, const size_t slen, ! const int flags) { #ifdef EXTATTR_MACOSX ! return setxattr(path, attrname, attrvalue, slen, 0, flags); #elif defined(EXTATTR_BSD) ! return bsd_setxattr(path, attrname, attrvalue, slen); #elif defined(EXTATTR_SOLARIS) ! return solaris_setxattr(path, attrname, attrvalue, slen, flags); #else ! return setxattr(path, attrname, attrvalue, slen, flags); #endif } --- 13,26 ---- const void *attrvalue, const size_t slen, ! struct hv *flags) { #ifdef EXTATTR_MACOSX ! 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, 0 /* XXX: flags? */); #else ! return linux_setxattr(path, attrname, attrvalue, slen, flags); #endif } *************** *** 29,42 **** const void *attrvalue, const size_t slen, ! const int flags) { #ifdef EXTATTR_MACOSX ! return fsetxattr(fd, attrname, attrvalue, slen, 0, flags); #elif defined(EXTATTR_BSD) ! return bsd_fsetxattr(fd, attrname, attrvalue, slen); #elif defined(EXTATTR_SOLARIS) ! return solaris_fsetxattr(fd, attrname, attrvalue, slen, flags); #else ! return fsetxattr(fd, attrname, attrvalue, slen, flags); #endif } --- 31,44 ---- const void *attrvalue, const size_t slen, ! struct hv *flags) { #ifdef EXTATTR_MACOSX ! 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, 0 /* XXX: flags? */); #else ! return linux_fsetxattr(fd, attrname, attrvalue, slen, flags); #endif } *************** *** 46,60 **** const char *attrname, void *attrvalue, ! const size_t slen) { #ifdef EXTATTR_MACOSX ! return getxattr(path, attrname, attrvalue, slen, 0, 0); #elif defined(EXTATTR_BSD) ! /* XXX: Namespace? */ return extattr_get_file(path, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); #elif defined(EXTATTR_SOLARIS) ! return solaris_getxattr(path, attrname, attrvalue, slen); #else ! return getxattr(path, attrname, attrvalue, slen); #endif } --- 48,63 ---- const char *attrname, void *attrvalue, ! const size_t slen, ! struct hv *flags) { #ifdef EXTATTR_MACOSX ! 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 /* XXX: flags? */); #else ! return linux_getxattr(path, attrname, attrvalue, slen, flags); #endif } *************** *** 64,160 **** const char *attrname, void *attrvalue, ! const size_t slen) { #ifdef EXTATTR_MACOSX ! return fgetxattr(fd, attrname, attrvalue, slen, 0, 0); #elif defined(EXTATTR_BSD) ! /* XXX: Namespace? */ return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); #elif defined(EXTATTR_SOLARIS) ! return solaris_fgetxattr(fd, attrname, attrvalue, slen); #else ! return fgetxattr(fd, attrname, attrvalue, slen); #endif } static inline ssize_t ! portable_lenxattr (const char *path, const char *attrname) { #ifdef BSD ! /* XXX: Namespace? */ return extattr_get_file(path, EXTATTR_NAMESPACE_USER, attrname, NULL, 0); #else /* XXX: Can BSD use this too? Maybe once namespacing sorted. */ ! return portable_getxattr(path, attrname, NULL, 0); #endif } static inline int ! portable_flenxattr (int fd, const char *attrname) { #ifdef BSD ! /* XXX: Namespace? */ return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, attrname, NULL, 0); #else /* XXX: Can BSD use this too? Maybe once namespacing sorted. */ ! return portable_fgetxattr(fd, attrname, NULL, 0); #endif } static inline int ! portable_removexattr (const char *path, const char *name) { #ifdef EXTATTR_MACOSX ! return removexattr(path, name, 0); #elif defined(EXTATTR_BSD) ! /* XXX: Namespace? */ return extattr_delete_file(path, EXTATTR_NAMESPACE_USER, name); #elif defined(EXTATTR_SOLARIS) ! return solaris_removexattr(path, name); #else ! return removexattr(path, name); #endif } static inline int ! portable_fremovexattr (const int fd, const char *name) { #ifdef EXTATTR_MACOSX ! return fremovexattr(fd, name, 0); #elif defined(EXTATTR_BSD) ! /* XXX: Namespace? */ return extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name); #elif defined(EXTATTR_SOLARIS) ! return solaris_fremovexattr(fd, name); #else ! return fremovexattr(fd, name); #endif } static inline int ! portable_listxattr(const char *path, char *buf, const size_t slen) { #ifdef EXTATTR_MACOSX ! return listxattr(path, buf, slen, 0); #elif defined(EXTATTR_BSD) ! return bsd_listxattr(path, buf, slen); #elif defined(EXTATTR_SOLARIS) ! return solaris_listxattr(path, buf, slen); #else ! return listxattr(path, buf, slen); #endif } static inline int ! portable_flistxattr(const int fd, char *buf, const size_t slen) { #ifdef EXTATTR_MACOSX ! return flistxattr(fd, buf, slen, 0); #elif defined(EXTATTR_BSD) ! return bsd_flistxattr(fd, buf, slen); #elif defined(EXTATTR_SOLARIS) ! return solaris_flistxattr(fd, buf, slen); #else ! return flistxattr(fd, buf, slen); #endif } --- 67,170 ---- const char *attrname, void *attrvalue, ! const size_t slen, ! struct hv *flags) { #ifdef EXTATTR_MACOSX ! 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 /* XXX: flags? */); #else ! return linux_fgetxattr(fd, attrname, attrvalue, slen, flags); #endif } static inline ssize_t ! portable_lenxattr (const char *path, const char *attrname, struct hv *flags) { #ifdef BSD ! /* XXX: flags? Namespace? */ return extattr_get_file(path, EXTATTR_NAMESPACE_USER, attrname, NULL, 0); #else /* XXX: Can BSD use this too? Maybe once namespacing sorted. */ ! return portable_getxattr(path, attrname, NULL, 0, flags); #endif } static inline int ! portable_flenxattr (int fd, const char *attrname, struct hv *flags) { #ifdef BSD ! /* XXX: flags? Namespace? */ return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, attrname, NULL, 0); #else /* XXX: Can BSD use this too? Maybe once namespacing sorted. */ ! return portable_fgetxattr(fd, attrname, NULL, 0, flags); #endif } static inline int ! portable_removexattr (const char *path, const char *name, struct hv *flags) { #ifdef EXTATTR_MACOSX ! 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 /* XXX: flags? */); #else ! return linux_removexattr(path, name, flags); #endif } static inline int ! portable_fremovexattr (const int fd, const char *name, struct hv *flags) { #ifdef EXTATTR_MACOSX ! 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 /* XXX: flags? */); #else ! return linux_fremovexattr(fd, name, flags); #endif } static inline int ! portable_listxattr(const char *path, ! char *buf, ! const size_t slen, ! struct hv *flags) { #ifdef EXTATTR_MACOSX ! 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 /* XXX: flags? */); #else ! return linux_listxattr(path, buf, slen, flags); #endif } static inline int ! portable_flistxattr(const int fd, ! char *buf, ! const size_t slen, ! struct hv *flags) { #ifdef EXTATTR_MACOSX ! 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 /* XXX: flags? */); #else ! return linux_flistxattr(fd, buf, slen, flags); #endif } |
Update of /cvsroot/file-extattr/File-ExtAttr/t In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv32007/t Modified Files: 11basic.t 13long.t 14optional.t 20tie-basic.t Added Files: 30nsbasic.t 32nsnonuser.t 33nslong.t 39nsempty.t Removed Files: 12nonuser.t Log Message: Initial support for cross-platform namespacing on Linux --- NEW FILE: 33nslong.t --- #!perl -T # 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'; # XXX: Refactor the common bits between this and 11basic.t # into Test::Class classes? use strict; use Test::More tests => 16; use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); 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 $longval = 'A' x $File::ExtAttr::MAX_INITIAL_VALUELEN; my $longval2 = 'A' x ($File::ExtAttr::MAX_INITIAL_VALUELEN + 11); ########################## # Filename-based tests # ########################## print "# using $filename\n"; #for (1..30000) { #checking memory leaks #check a really big one, bigger than $File::ExtAttr::MAX_INITIAL_VALUELEN #Hmmm, 3991 is the biggest number that doesn't generate "no space left on device" #on my /var partition, and 920 is the biggest for my loopback partition. #What's up with that? #setfattr($filename, "$key-2", ('x' x 3991)) || die "setfattr failed on $filename: $!"; setfattr($filename, "$key", $longval, { namespace => 'user' }) || die "setfattr failed on $filename: $!"; #set it is (setfattr($filename, "$key", $longval, { namespace => 'user' }), 1); #read it back is (getfattr($filename, "$key", { namespace => 'user' }), $longval); #delete it ok (delfattr($filename, "$key", { namespace => 'user' })); #check that it's gone is (getfattr($filename, "$key", { namespace => 'user' }), undef); #set it is (setfattr($filename, "$key", $longval2, { namespace => 'user' }), 1); #read it back is (getfattr($filename, "$key", { namespace => 'user' }), $longval2); #delete it ok (delfattr($filename, "$key", { namespace => 'user' })); #check that it's gone is (getfattr($filename, "$key", { namespace => 'user' }), undef); #} #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 #check a really big one, bigger than $File::ExtAttr::MAX_INITIAL_VALUELEN #Hmmm, 3991 is the biggest number that doesn't generate "no space left on device" #on my /var partition, and 920 is the biggest for my loopback partition. #What's up with that? #setfattr($filename, "$key-2", ('x' x 3991)) || die "setfattr failed on $filename: $!"; setfattr($fh, "$key", $longval, { namespace => 'user' }) || die "setfattr failed on file descriptor ".$fh->fileno().": $!"; #set it is (setfattr($fh, "$key", $longval, { namespace => 'user' }), 1); #read it back is (getfattr($fh, "$key"), $longval, { namespace => 'user' }); #delete it ok (delfattr($fh, "$key", { namespace => 'user' })); #check that it's gone is (getfattr($fh, "$key", { namespace => 'user' }), undef); #set it is (setfattr($fh, "$key", $longval2, { namespace => 'user' }), 1); #read it back is (getfattr($fh, "$key", { namespace => 'user' }), $longval2); #delete it ok (delfattr($fh, "$key", { namespace => 'user' })); #check that it's gone is (getfattr($fh, "$key", { namespace => 'user' }), undef); #} #print STDERR "done\n"; #<STDIN>; END {unlink $filename if $filename}; --- NEW FILE: 30nsbasic.t --- #!perl -T # 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 => 8; use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); 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"; ########################## # 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); #delete it ok (delfattr($filename, "$key", { namespace => 'user' })); #check that it's gone is (getfattr($filename, "$key", { namespace => 'user' }), undef); #} #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); #delete it ok (delfattr($fh, "$key", { namespace => 'user' })); #check that it's gone is (getfattr($fh, "$key", { namespace => 'user' }), undef); #} #print STDERR "done\n"; #<STDIN>; END {unlink $filename if $filename}; Index: 13long.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/13long.t,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** 13long.t 31 Dec 2005 14:12:46 -0000 1.2 --- 13long.t 19 Aug 2006 14:06:25 -0000 1.3 *************** *** 38,68 **** #on my /var partition, and 920 is the biggest for my loopback partition. #What's up with that? ! #setfattr($filename, "user.$key-2", ('x' x 3991), 0) || die "setfattr failed on $filename: $!"; ! setfattr($filename, "user.$key", $longval, 0) || die "setfattr failed on $filename: $!"; #set it ! is (setfattr($filename, "user.$key", $longval, 0), 1); #read it back ! is (getfattr($filename, "user.$key"), $longval); #delete it ! ok (delfattr($filename, "user.$key")); #check that it's gone ! is (getfattr($filename, "user.$key"), undef); #set it ! is (setfattr($filename, "user.$key", $longval2, 0), 1); #read it back ! is (getfattr($filename, "user.$key"), $longval2); #delete it ! ok (delfattr($filename, "user.$key")); #check that it's gone ! is (getfattr($filename, "user.$key"), undef); #} #print STDERR "done\n"; --- 38,68 ---- #on my /var partition, and 920 is the biggest for my loopback partition. #What's up with that? ! #setfattr($filename, "$key-2", ('x' x 3991)) || die "setfattr failed on $filename: $!"; ! setfattr($filename, "$key", $longval) || die "setfattr failed on $filename: $!"; #set it ! is (setfattr($filename, "$key", $longval), 1); #read it back ! is (getfattr($filename, "$key"), $longval); #delete it ! ok (delfattr($filename, "$key")); #check that it's gone ! is (getfattr($filename, "$key"), undef); #set it ! is (setfattr($filename, "$key", $longval2), 1); #read it back ! is (getfattr($filename, "$key"), $longval2); #delete it ! ok (delfattr($filename, "$key")); #check that it's gone ! is (getfattr($filename, "$key"), undef); #} #print STDERR "done\n"; *************** *** 82,112 **** #on my /var partition, and 920 is the biggest for my loopback partition. #What's up with that? ! #setfattr($filename, "user.$key-2", ('x' x 3991), 0) || die "setfattr failed on $filename: $!"; ! setfattr($fh, "user.$key", $longval, 0) || die "setfattr failed on file descriptor ".$fh->fileno().": $!"; #set it ! is (setfattr($fh, "user.$key", $longval, 0), 1); #read it back ! is (getfattr($fh, "user.$key"), $longval); #delete it ! ok (delfattr($fh, "user.$key")); #check that it's gone ! is (getfattr($fh, "user.$key"), undef); #set it ! is (setfattr($fh, "user.$key", $longval2, 0), 1); #read it back ! is (getfattr($fh, "user.$key"), $longval2); #delete it ! ok (delfattr($fh, "user.$key")); #check that it's gone ! is (getfattr($fh, "user.$key"), undef); #} #print STDERR "done\n"; --- 82,112 ---- #on my /var partition, and 920 is the biggest for my loopback partition. #What's up with that? ! #setfattr($filename, "$key-2", ('x' x 3991)) || die "setfattr failed on $filename: $!"; ! setfattr($fh, "$key", $longval) || die "setfattr failed on file descriptor ".$fh->fileno().": $!"; #set it ! is (setfattr($fh, "$key", $longval), 1); #read it back ! is (getfattr($fh, "$key"), $longval); #delete it ! ok (delfattr($fh, "$key")); #check that it's gone ! is (getfattr($fh, "$key"), undef); #set it ! is (setfattr($fh, "$key", $longval2), 1); #read it back ! is (getfattr($fh, "$key"), $longval2); #delete it ! ok (delfattr($fh, "$key")); #check that it's gone ! is (getfattr($fh, "$key"), undef); #} #print STDERR "done\n"; Index: 20tie-basic.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/20tie-basic.t,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** 20tie-basic.t 15 Aug 2006 09:13:18 -0000 1.3 --- 20tie-basic.t 19 Aug 2006 14:06:25 -0000 1.4 *************** *** 22,26 **** # Test multiple attributes. ! my %test_attrs = ( 'user.foo' => '123', 'user.bar' => '456' ); my $k; --- 22,26 ---- # Test multiple attributes. ! my %test_attrs = ( 'foo' => '123', 'bar' => '456' ); my $k; Index: 14optional.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/14optional.t,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** 14optional.t 13 Dec 2005 21:36:09 -0000 1.1 --- 14optional.t 19 Aug 2006 14:06:25 -0000 1.2 *************** *** 28,44 **** #will die if xattr stuff doesn't work at all ! setfattr($filename, "user.$key", $val) || die "setfattr failed on $filename: $!"; #set it ! is (setfattr($filename, "user.$key", $val), 1); #read it back ! is (getfattr($filename, "user.$key"), $val); #delete it ! ok (delfattr($filename, "user.$key")); #check that it's gone ! is (getfattr($filename, "user.$key"), undef); #} #print STDERR "done\n"; --- 28,44 ---- #will die if xattr stuff doesn't work at all ! setfattr($filename, "$key", $val) || die "setfattr failed on $filename: $!"; #set it ! is (setfattr($filename, "$key", $val), 1); #read it back ! is (getfattr($filename, "$key"), $val); #delete it ! ok (delfattr($filename, "$key")); #check that it's gone ! is (getfattr($filename, "$key"), undef); #} #print STDERR "done\n"; --- NEW FILE: 39nsempty.t --- #!perl -T # Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Linux-xattr.t' ########################## # Test an explicitly empty namespace use strict; use Test::More tests => 8; use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); 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"; ########################## # Filename-based tests # ########################## print "# using $filename\n"; #set it - should fail undef $@; eval { setfattr($filename, "$key", $val, { namespace => '' }); }; isnt ($@, undef); #read it back - should be missing is (getfattr($filename, "$key", { namespace => '' }), undef); #delete it - should fail is (delfattr($filename, "$key", { namespace => '' }), 0); #check that it's gone is (getfattr($filename, "$key", { namespace => '' }), undef); ########################## # IO::Handle-based tests # ########################## $fh = new IO::File("<$filename") || die "Unable to open $filename"; print "# using file descriptor ".$fh->fileno()."\n"; undef $@; eval { setfattr($fh->fileno(), "$key", $val, { namespace => '' }); }; isnt ($@, undef); #read it back - should be missing is (getfattr($fh->fileno(), "$key", { namespace => '' }), undef); #delete it - should fail is (delfattr($fh->fileno(), "$key", { namespace => '' }), 0); #check that it's gone is (getfattr($fh->fileno(), "$key", { namespace => '' }), undef); END {unlink $filename if $filename}; Index: 11basic.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/11basic.t,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** 11basic.t 31 Dec 2005 14:12:46 -0000 1.2 --- 11basic.t 19 Aug 2006 14:06:25 -0000 1.3 *************** *** 33,49 **** #will die if xattr stuff doesn't work at all ! setfattr($filename, "user.$key", $val, 0) || die "setfattr failed on filename $filename: $!"; #set it ! is (setfattr($filename, "user.$key", $val, 0), 1); #read it back ! is (getfattr($filename, "user.$key"), $val); #delete it ! ok (delfattr($filename, "user.$key")); #check that it's gone ! is (getfattr($filename, "user.$key"), undef); #} #print STDERR "done\n"; --- 33,49 ---- #will die if xattr stuff doesn't work at all ! setfattr($filename, "$key", $val) || die "setfattr failed on filename $filename: $!"; #set it ! is (setfattr($filename, "$key", $val), 1); #read it back ! is (getfattr($filename, "$key"), $val); #delete it ! ok (delfattr($filename, "$key")); #check that it's gone ! is (getfattr($filename, "$key"), undef); #} #print STDERR "done\n"; *************** *** 61,78 **** #will die if xattr stuff doesn't work at all ! setfattr($fh, "user.$key", $val, 0) || die "setfattr failed on file descriptor ".$fh->fileno().": $!"; #set it ! is (setfattr($fh, "user.$key", $val, 0), 1); #read it back ! is (getfattr($fh, "user.$key"), $val); #delete it ! ok (delfattr($fh, "user.$key")); #check that it's gone ! is (getfattr($fh, "user.$key"), undef); #} #print STDERR "done\n"; --- 61,78 ---- #will die if xattr stuff doesn't work at all ! setfattr($fh, "$key", $val) || die "setfattr failed on file descriptor ".$fh->fileno().": $!"; #set it ! is (setfattr($fh, "$key", $val), 1); #read it back ! is (getfattr($fh, "$key"), $val); #delete it ! ok (delfattr($fh, "$key")); #check that it's gone ! is (getfattr($fh, "$key"), undef); #} #print STDERR "done\n"; --- 12nonuser.t DELETED --- --- NEW FILE: 32nsnonuser.t --- #!perl -T # -*-perl-*- # Test that creating non-"user."-prefixed attributes fails. # XXX: Probably Linux-specific use strict; use Test::More tests => 4; use File::Temp qw(tempfile); use File::ExtAttr qw(setfattr getfattr delfattr); # Snaffle away the warnings for later analysis. my $warning; $SIG{'__WARN__'} = sub { $warning = $_[0] }; my $TESTDIR = ($ENV{ATTR_TEST_DIR} || '.'); my ($fh, $filename) = tempfile( DIR => $TESTDIR ); close $fh || die "can't close $filename $!"; print "# using $filename\n"; #todo: try wierd characters in here? # try unicode? my $key = "alskdfjadf2340zsdflksjdfa09eralsdkfjaldkjsldkfj"; my $val = "ZZZadlf03948alsdjfaslfjaoweir12l34kealfkjalskdfas90d8fajdlfkj./.,f"; #set it setfattr($filename, "$key", $val, { namespace => 'nonuser' }); is ($warning =~ /Operation not supported/, 1); #read it back is (getfattr($filename, "$key", { namespace => 'nonuser' }), undef); #delete it delfattr($filename, "$key", { namespace => 'nonuser' }); is ($warning =~ /Operation not supported/, 1); #check that it's gone is (getfattr($filename, "$key", { namespace => 'nonuser' }), undef); END {unlink $filename if $filename}; |
From: Richard D. <ric...@us...> - 2006-08-15 09:18:07
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv25408 Modified Files: Changes META.yml README Log Message: Bump version to 1.00; summarise 1.00 changes so far Index: README =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/README,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** README 14 Aug 2006 21:01:08 -0000 1.6 --- README 15 Aug 2006 09:18:04 -0000 1.7 *************** *** 1,3 **** ! File-ExtAttr version 0.05 ========================= --- 1,3 ---- ! File-ExtAttr version 1.00 ========================= Index: Changes =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/Changes,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Changes 27 May 2006 11:52:40 -0000 1.16 --- Changes 15 Aug 2006 09:18:04 -0000 1.17 *************** *** 1,4 **** --- 1,8 ---- 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 - (richdawe) Add support for FreeBSD 6.0. This may also work Index: META.yml =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/META.yml,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** META.yml 6 Mar 2006 20:06:45 -0000 1.2 --- META.yml 15 Aug 2006 09:18:04 -0000 1.3 *************** *** 2,6 **** #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: File-ExtAttr ! version: 0.05 version_from: lib/File/ExtAttr.pm installdirs: site --- 2,6 ---- #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: File-ExtAttr ! version: 1.00 version_from: lib/File/ExtAttr.pm installdirs: site |
From: Richard D. <ric...@us...> - 2006-08-15 09:18:07
|
Update of /cvsroot/file-extattr/File-ExtAttr/lib/File In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv25408/lib/File Modified Files: ExtAttr.pm Log Message: Bump version to 1.00; summarise 1.00 changes so far Index: ExtAttr.pm =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/lib/File/ExtAttr.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ExtAttr.pm 6 Mar 2006 20:53:47 -0000 1.11 --- ExtAttr.pm 15 Aug 2006 09:18:04 -0000 1.12 *************** *** 78,82 **** ); ! our $VERSION = '0.05'; #this is used by getxattr(), needs documentation --- 78,82 ---- ); ! our $VERSION = '1.00'; #this is used by getxattr(), needs documentation |
From: Richard D. <ric...@us...> - 2006-08-15 09:14:25
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv24027 Modified Files: extattr_bsd.c extattr_bsd.h extattr_os.h portable.h Log Message: Fix BSD build; support for File::ExtAttr::Tie on BSD Index: portable.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/portable.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** portable.h 14 Aug 2006 22:00:27 -0000 1.6 --- portable.h 15 Aug 2006 09:14:20 -0000 1.7 *************** *** 138,142 **** return listxattr(path, buf, slen, 0); #elif defined(EXTATTR_BSD) ! #error "FIXME" #elif defined(EXTATTR_SOLARIS) return solaris_listxattr(path, buf, slen); --- 138,142 ---- return listxattr(path, buf, slen, 0); #elif defined(EXTATTR_BSD) ! return bsd_listxattr(path, buf, slen); #elif defined(EXTATTR_SOLARIS) return solaris_listxattr(path, buf, slen); *************** *** 152,156 **** return flistxattr(fd, buf, slen, 0); #elif defined(EXTATTR_BSD) ! #error "FIXME" #elif defined(EXTATTR_SOLARIS) return solaris_flistxattr(fd, buf, slen); --- 152,156 ---- return flistxattr(fd, buf, slen, 0); #elif defined(EXTATTR_BSD) ! return bsd_flistxattr(fd, buf, slen); #elif defined(EXTATTR_SOLARIS) return solaris_flistxattr(fd, buf, slen); Index: extattr_os.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_os.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** extattr_os.h 14 Aug 2006 21:10:54 -0000 1.1 --- extattr_os.h 15 Aug 2006 09:14:20 -0000 1.2 *************** *** 3,6 **** --- 3,8 ---- /* OS detection */ + #include <sys/param.h> + #ifdef BSD #define EXTATTR_BSD *************** *** 18,22 **** /* Include appropriate header for this OS, defaulting to Linux-style */ ! #ifdef EXTATTR_BSD #include "extattr_bsd.h" #elif defined(EXTATTR_MACOSX) --- 20,24 ---- /* Include appropriate header for this OS, defaulting to Linux-style */ ! #if defined(EXTATTR_BSD) #include "extattr_bsd.h" #elif defined(EXTATTR_MACOSX) Index: extattr_bsd.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_bsd.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** extattr_bsd.h 14 Aug 2006 21:16:47 -0000 1.2 --- extattr_bsd.h 15 Aug 2006 09:14:20 -0000 1.3 *************** *** 16,18 **** --- 16,26 ---- 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 */ Index: extattr_bsd.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_bsd.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** extattr_bsd.c 14 Aug 2006 21:16:47 -0000 1.1 --- extattr_bsd.c 15 Aug 2006 09:14:20 -0000 1.2 *************** *** 1,4 **** --- 1,8 ---- + #include "extattr_os.h" + #ifdef EXTATTR_BSD + #include <errno.h> + #include "extattr_bsd.h" *************** *** 47,49 **** --- 51,105 ---- } + /* Convert the BSD-style list to a nul-separated list. */ + static void + reformat_list (char *buf, const ssize_t len) + { + ssize_t pos = 0; + ssize_t attrlen; + + while (pos < len) + { + attrlen = (unsigned char) buf[pos]; + memmove(buf + pos, buf + pos + 1, attrlen); + buf[pos + attrlen] = '\0'; + pos += attrlen + 1; + } + } + + ssize_t + bsd_listxattr (const char *path, char *buf, const size_t buflen) + { + ssize_t ret; + + /* XXX: Namespace? */ + ret = extattr_list_file(path, + EXTATTR_NAMESPACE_USER, + /* To get the length on *BSD, pass NULL here. */ + buflen ? buf : NULL, + buflen); + + if (buflen && (ret > 0)) + reformat_list(buf, ret); + + return ret; + } + + ssize_t + bsd_flistxattr (const int fd, char *buf, const size_t buflen) + { + ssize_t ret; + + /* XXX: Namespace? */ + ret = extattr_list_fd(fd, + EXTATTR_NAMESPACE_USER, + /* To get the length on *BSD, pass NULL here. */ + buflen ? buf : NULL, + buflen); + + if (buflen && (ret > 0)) + reformat_list(buf, ret); + + return ret; + } + #endif /* EXTATTR_BSD */ |
From: Richard D. <ric...@us...> - 2006-08-15 09:13:22
|
Update of /cvsroot/file-extattr/File-ExtAttr/t In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv23643/t Modified Files: 20tie-basic.t Log Message: Slightly more thorough testing of File::ExtAttr::Tie Index: 20tie-basic.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/20tie-basic.t,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** 20tie-basic.t 27 May 2006 11:49:25 -0000 1.2 --- 20tie-basic.t 15 Aug 2006 09:13:18 -0000 1.3 *************** *** 2,6 **** use strict; ! use Test::More tests => 5; use File::Temp qw(tempfile); use File::ExtAttr::Tie; --- 2,6 ---- use strict; ! use Test::More tests => 12; use File::Temp qw(tempfile); use File::ExtAttr::Tie; *************** *** 21,41 **** ok(scalar(@ks) == 0); ! # Check that creation works. ! my $k = 'user.foo'; ! my $v = '123'; ! $extattr{$k} = $v; ! is(getfattr($filename, "$k"), $v); ! # Check that updating works. ! $extattr{$k} = "$v$v"; ! is(getfattr($filename, "$k"), "$v$v"); ! $extattr{$k} = $v; ! is(getfattr($filename, "$k"), $v); ! # Check that deletion works. ! delete $extattr{$k}; ! is(getfattr($filename, "$k"), undef); END {unlink $filename if $filename}; --- 21,63 ---- ok(scalar(@ks) == 0); ! # Test multiple attributes. ! my %test_attrs = ( 'user.foo' => '123', 'user.bar' => '456' ); ! my $k; ! foreach $k (sort(keys(%test_attrs))) ! { ! my $v = $test_attrs{$k}; ! # Check that creation works. ! $extattr{$k} = $v; ! is(getfattr($filename, "$k"), $v); ! # Check that updating works. ! $extattr{$k} = "$v$v"; ! is(getfattr($filename, "$k"), "$v$v"); ! $extattr{$k} = $v; ! is(getfattr($filename, "$k"), $v); ! ! # Check that deletion works. ! delete $extattr{$k}; ! is(getfattr($filename, "$k"), undef); ! } ! ! # Recreate the keys and check that they're all in the hash. ! ! foreach $k (sort(keys(%test_attrs))) ! { ! my $v = $test_attrs{$k}; ! ! # Check that creation works. ! $extattr{$k} = $v; ! is(getfattr($filename, "$k"), $v); ! } ! ! # Check there are only our extattrs; ignore SELinux security extattrs. ! @ks = grep { !/^security\./ } keys(%extattr); ! ok(scalar(@ks) == scalar(keys(%test_attrs))); ! print '# '.join(' ', @ks)."\n"; END {unlink $filename if $filename}; |
From: Richard D. <ric...@us...> - 2006-08-15 08:43:42
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv13800 Modified Files: TODO Log Message: TODO: Disable nuls in attribute names Index: TODO =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/TODO,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TODO 14 Aug 2006 21:01:08 -0000 1.10 --- TODO 15 Aug 2006 08:43:40 -0000 1.11 *************** *** 34,37 **** --- 34,41 ---- Include these in a .spec file that we can include with distro + Disallow nuls in the attribute names. The list handling will break + if we allow this. (Alternative is to make the portable listxattr follow + the BSD API, where the separator is a length byte.) + Rename the module? ~~~~~~~~~~~~~~~~~~ |
From: Richard D. <ric...@us...> - 2006-08-14 22:00:34
|
Update of /cvsroot/file-extattr/File-ExtAttr/t In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv28277/t Modified Files: 10constants.t Log Message: Solaris support for *listxattr() -- now 95% passes on Solaris Index: 10constants.t =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/t/10constants.t,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** 10constants.t 6 Mar 2006 20:06:46 -0000 1.3 --- 10constants.t 14 Aug 2006 22:00:28 -0000 1.4 *************** *** 9,15 **** SKIP: { ! skip('Create/replace Options not supported on this platform', 2) if ($^O =~ /bsd$/i); foreach my $constname (qw{XATTR_REPLACE XATTR_CREATE}) { eval { --- 9,18 ---- SKIP: { ! skip('Create/replace options not supported on this platform', 2) if ($^O =~ /bsd$/i); + skip('FIXME: Create/replace options not yet implemented on this platform', 2) + if ($^O =~ /^solaris$/i); + foreach my $constname (qw{XATTR_REPLACE XATTR_CREATE}) { eval { |
From: Richard D. <ric...@us...> - 2006-08-14 22:00:31
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv28277 Modified Files: extattr_solaris.c extattr_solaris.h portable.h Log Message: Solaris support for *listxattr() -- now 95% passes on Solaris Index: portable.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/portable.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** portable.h 14 Aug 2006 21:10:54 -0000 1.5 --- portable.h 14 Aug 2006 22:00:27 -0000 1.6 *************** *** 140,144 **** #error "FIXME" #elif defined(EXTATTR_SOLARIS) ! /*#error "XXX: FIXME"*/ #else return listxattr(path, buf, slen); --- 140,144 ---- #error "FIXME" #elif defined(EXTATTR_SOLARIS) ! return solaris_listxattr(path, buf, slen); #else return listxattr(path, buf, slen); *************** *** 154,158 **** #error "FIXME" #elif defined(EXTATTR_SOLARIS) ! /*#error "XXX: FIXME" */ #else return flistxattr(fd, buf, slen); --- 154,158 ---- #error "FIXME" #elif defined(EXTATTR_SOLARIS) ! return solaris_flistxattr(fd, buf, slen); #else return flistxattr(fd, buf, slen); Index: extattr_solaris.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_solaris.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** extattr_solaris.c 14 Aug 2006 21:10:54 -0000 1.1 --- extattr_solaris.c 14 Aug 2006 22:00:27 -0000 1.2 *************** *** 4,12 **** #include <errno.h> #include <unistd.h> static const mode_t ATTRMODE = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP; ! static inline int writexattr (const int attrfd, const char *attrvalue, --- 4,15 ---- #include <errno.h> + #include <string.h> #include <unistd.h> + #include <dirent.h> + #include <sys/types.h> static const mode_t ATTRMODE = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP; ! static int writexattr (const int attrfd, const char *attrvalue, *************** *** 23,27 **** } ! static inline int readclose (const int attrfd, void *attrvalue, --- 26,30 ---- } ! static int readclose (const int attrfd, void *attrvalue, *************** *** 66,70 **** } ! static inline int unlinkclose (const int attrdirfd, const char *attrname) { --- 69,73 ---- } ! static int unlinkclose (const int attrdirfd, const char *attrname) { *************** *** 89,92 **** --- 92,156 ---- } + static ssize_t + listclose (const int attrdirfd, char *buf, const size_t buflen) + { + int saved_errno = 0; + int ok = 1; + ssize_t len = 0; + DIR *dirp; + + if (attrdirfd == -1) + ok = 0; + + if (ok) + dirp = fdopendir(attrdirfd); + + if (ok) + { + struct dirent *de; + + while ((de = readdir(dirp))) + { + const size_t namelen = strlen(de->d_name); + + /* Ignore "." and ".." entries */ + if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) + continue; + + if (buflen) + { + /* Check for space, then copy directory name + nul into list. */ + if ((len + namelen + 1) > buflen) + { + errno = ERANGE; + ok = 0; + break; + } + else + { + strcpy(buf + len, de->d_name); + len += namelen; + buf[len] = '\0'; + ++len; + } + } + else + { + /* Seeing how much space is needed? */ + len += namelen + 1; + } + } + } + + if (!ok) + saved_errno = errno; + if ((attrdirfd >= 0) && (close(attrdirfd) == -1) && !saved_errno) + saved_errno = errno; + if (saved_errno) + errno = saved_errno; + + return ok ? len : -1; + } + int solaris_setxattr (const char *path, *************** *** 178,180 **** --- 242,258 ---- } + ssize_t + solaris_listxattr (const char *path, char *buf, const size_t buflen) + { + int attrdirfd = attropen(path, ".", O_RDONLY); + return listclose(attrdirfd, buf, buflen); + } + + ssize_t + solaris_flistxattr (const int fd, char *buf, const size_t buflen) + { + int attrdirfd = openat(fd, ".", O_RDONLY|O_XATTR); + return listclose(attrdirfd, buf, buflen); + } + #endif /* EXTATTR_SOLARIS */ Index: extattr_solaris.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_solaris.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** extattr_solaris.h 14 Aug 2006 21:10:54 -0000 1.1 --- extattr_solaris.h 14 Aug 2006 22:00:27 -0000 1.2 *************** *** 40,42 **** --- 40,50 ---- 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 */ |
From: Richard D. <ric...@us...> - 2006-08-14 21:16:49
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv10608 Modified Files: MANIFEST extattr_bsd.h Added Files: extattr_bsd.c Log Message: Split BSD code from header to module Index: extattr_bsd.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_bsd.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** extattr_bsd.h 14 Aug 2006 21:10:54 -0000 1.1 --- extattr_bsd.h 14 Aug 2006 21:16:47 -0000 1.2 *************** *** 6,52 **** #include <sys/uio.h> ! /* Helper to convert number of bytes written into success/failure code. */ ! static inline int ! bsd_extattr_set_succeeded (const int expected, const int actual) ! { ! int ret = -1; ! ! if (actual != -1) ! { ! if (actual != expected) ! { ! errno = ENOBUFS; /* Pretend there's not enough space for the data. */ ! ret = -1; ! } ! else ! { ! ret = 0; ! } ! } ! ! return ret; ! } ! ! static inline int ! bsd_setxattr (const char *path, ! 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); ! } ! static inline int ! bsd_fsetxattr (const int fd, ! 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); ! } #endif /* EXTATTR_BSD_H */ --- 6,18 ---- #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); #endif /* EXTATTR_BSD_H */ --- NEW FILE: extattr_bsd.c --- #ifdef EXTATTR_BSD #include "extattr_bsd.h" /* Helper to convert number of bytes written into success/failure code. */ static inline int bsd_extattr_set_succeeded (const int expected, const int actual) { int ret = -1; if (actual != -1) { if (actual != expected) { errno = ENOBUFS; /* Pretend there's not enough space for the data. */ ret = -1; } else { ret = 0; } } return ret; } int bsd_setxattr (const char *path, 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); } int bsd_fsetxattr (const int fd, 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); } #endif /* EXTATTR_BSD */ Index: MANIFEST =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/MANIFEST,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MANIFEST 14 Aug 2006 21:10:54 -0000 1.10 --- MANIFEST 14 Aug 2006 21:16:47 -0000 1.11 *************** *** 11,14 **** --- 11,15 ---- helpers.c extattr_bsd.h + extattr_bsd.c extattr_linux.h extattr_macosx.h |
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv8257 Modified Files: MANIFEST portable.h Added Files: extattr_bsd.h extattr_linux.h extattr_macosx.h extattr_os.h extattr_solaris.c extattr_solaris.h Log Message: Initial Solaris 10 support; almost works ;) --- NEW FILE: extattr_solaris.h --- #ifndef EXTATTR_SOLARIS_H #define EXTATTR_SOLARIS_H #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> /* * XXX: FIXME: Need to distinguish file non-existence and attribute * non-existence. Need to choose an unused error code somehow. */ #ifndef ENOATTR #define ENOATTR ENOENT #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, const char *attrname, 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); #endif /* EXTATTR_SOLARIS_H */ --- NEW FILE: extattr_solaris.c --- #include "extattr_os.h" #ifdef EXTATTR_SOLARIS #include <errno.h> #include <unistd.h> static const mode_t ATTRMODE = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP; static inline int writexattr (const int attrfd, const char *attrvalue, const size_t slen) { int ok = 1; if (ftruncate(attrfd, 0) == -1) ok = 0; if (ok && (write(attrfd, attrvalue, slen) != slen)) ok = 0; return ok ? 0 : -1; } static inline int readclose (const int attrfd, void *attrvalue, const size_t slen) { int sz = 0; int saved_errno = 0; int ok = 1; if (attrfd == -1) ok = 0; if (ok) { if (slen) { sz = read(attrfd, attrvalue, slen); } else { /* Request to see how much data is there. */ struct stat sbuf; if (fstat(attrfd, &sbuf) == 0) sz = sbuf.st_size; else sz = -1; } if (sz == -1) ok = 0; } if (!ok) saved_errno = errno; if ((attrfd >= 0) && (close(attrfd) == -1) && !saved_errno) saved_errno = errno; if (saved_errno) errno = saved_errno; return ok ? sz : -1; } static inline int unlinkclose (const int attrdirfd, const char *attrname) { int sz = 0; int saved_errno = 0; int ok = 1; if (attrdirfd == -1) ok = 0; if (ok && (unlinkat(attrdirfd, attrname, 0) == -1)) ok = 0; if (!ok) saved_errno = errno; if ((attrdirfd >= 0) && (close(attrdirfd) == -1) && !saved_errno) saved_errno = errno; if (saved_errno) errno = saved_errno; return ok ? sz : -1; } int solaris_setxattr (const char *path, const char *attrname, 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)) ok = 0; if (!ok) saved_errno = errno; if ((attrfd >= 0) && (close(attrfd) == -1) && !saved_errno) saved_errno = errno; if (saved_errno) errno = saved_errno; return ok ? 0 : -1; } int solaris_fsetxattr (const int fd, const char *attrname, 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)) ok = 0; if (!ok) saved_errno = errno; if ((attrfd >= 0) && (close(attrfd) == -1) && !saved_errno) saved_errno = errno; if (saved_errno) errno = saved_errno; return ok ? 0 : -1; } int solaris_getxattr (const char *path, const char *attrname, void *attrvalue, const size_t slen) { const int attrfd = attropen(path, attrname, O_RDONLY); return readclose(attrfd, attrvalue, slen); } int solaris_fgetxattr (const int fd, 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); } #endif /* EXTATTR_SOLARIS */ --- NEW FILE: extattr_macosx.h --- #ifndef EXTATTR_MACOSX_H #define EXTATTR_MACOSX_H #include <sys/types.h> #include <sys/xattr.h> #endif /* EXTATTR_MACOSX_H */ --- NEW FILE: extattr_bsd.h --- #ifndef EXTATTR_BSD_H #define EXTATTR_BSD_H #include <sys/types.h> #include <sys/extattr.h> #include <sys/uio.h> /* Helper to convert number of bytes written into success/failure code. */ static inline int bsd_extattr_set_succeeded (const int expected, const int actual) { int ret = -1; if (actual != -1) { if (actual != expected) { errno = ENOBUFS; /* Pretend there's not enough space for the data. */ ret = -1; } else { ret = 0; } } return ret; } static inline int bsd_setxattr (const char *path, 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); } static inline int bsd_fsetxattr (const int fd, 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); } #endif /* EXTATTR_BSD_H */ --- NEW FILE: extattr_os.h --- #ifndef EXTATTR_OS_H #define EXTATTR_OS_H /* OS detection */ #ifdef BSD #define EXTATTR_BSD #endif #ifdef __APPLE__ #define EXTATTR_MACOSX #endif #if defined(sun) || defined(__sun) #if defined(__SVR4) || defined(__svr4__) #define EXTATTR_SOLARIS #endif #endif /* Include appropriate header for this OS, defaulting to Linux-style */ #ifdef EXTATTR_BSD #include "extattr_bsd.h" #elif defined(EXTATTR_MACOSX) #include "extattr_macosx.h" #elif defined(EXTATTR_SOLARIS) #include "extattr_solaris.h" #else #include "extattr_linux.h" #endif #endif Index: portable.h =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/portable.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** portable.h 6 Mar 2006 20:29:14 -0000 1.4 --- portable.h 14 Aug 2006 21:10:54 -0000 1.5 *************** *** 2,42 **** #define EXTATTR_PORTABLE_H ! #include <sys/types.h> ! #ifdef __APPLE__ ! #include <sys/xattr.h> ! #elif defined(BSD) /* FreeBSD, NetBSD, OpenBSD */ ! #include <sys/extattr.h> ! #include <sys/uio.h> ! #else /* Linux */ ! #include <attr/attributes.h> ! #include <attr/xattr.h> ! #endif ! ! #ifdef BSD ! ! /* Helper to convert number of bytes written into success/failure code. */ ! static inline int ! bsd_extattr_set_succeeded (const int expected, const int actual) ! { ! int ret = -1; ! ! if (actual != -1) ! { ! if (actual != expected) ! { ! errno = ENOBUFS; /* Pretend there's not enough space for the data. */ ! ret = -1; ! } ! else ! { ! ret = 0; ! } ! } ! ! return ret; ! } ! ! #endif /* BSD */ static inline int portable_setxattr (const char *path, --- 2,9 ---- #define EXTATTR_PORTABLE_H ! /* OS detection */ ! #include "extattr_os.h" + /* Portable extattr functions */ static inline int portable_setxattr (const char *path, *************** *** 46,55 **** const int flags) { ! #ifdef __APPLE__ return setxattr(path, attrname, attrvalue, slen, 0, flags); ! #elif defined(BSD) ! /* XXX: Namespace? */ ! int ret = extattr_set_file(path, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); ! return bsd_extattr_set_succeeded(slen, ret); #else return setxattr(path, attrname, attrvalue, slen, flags); --- 13,22 ---- const int flags) { ! #ifdef EXTATTR_MACOSX return setxattr(path, attrname, attrvalue, slen, 0, flags); ! #elif defined(EXTATTR_BSD) ! return bsd_setxattr(path, attrname, attrvalue, slen); ! #elif defined(EXTATTR_SOLARIS) ! return solaris_setxattr(path, attrname, attrvalue, slen, flags); #else return setxattr(path, attrname, attrvalue, slen, flags); *************** *** 64,73 **** const int flags) { ! #ifdef __APPLE__ return fsetxattr(fd, attrname, attrvalue, slen, 0, flags); ! #elif defined(BSD) ! /* XXX: Namespace? */ ! int ret = extattr_set_fd(fd, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); ! return bsd_extattr_set_succeeded(slen, ret); #else return fsetxattr(fd, attrname, attrvalue, slen, flags); --- 31,40 ---- const int flags) { ! #ifdef EXTATTR_MACOSX return fsetxattr(fd, attrname, attrvalue, slen, 0, flags); ! #elif defined(EXTATTR_BSD) ! return bsd_fsetxattr(fd, attrname, attrvalue, slen); ! #elif defined(EXTATTR_SOLARIS) ! return solaris_fsetxattr(fd, attrname, attrvalue, slen, flags); #else return fsetxattr(fd, attrname, attrvalue, slen, flags); *************** *** 81,89 **** const size_t slen) { ! #ifdef __APPLE__ return getxattr(path, attrname, attrvalue, slen, 0, 0); ! #elif defined(BSD) /* XXX: Namespace? */ return extattr_get_file(path, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); #else return getxattr(path, attrname, attrvalue, slen); --- 48,58 ---- const size_t slen) { ! #ifdef EXTATTR_MACOSX return getxattr(path, attrname, attrvalue, slen, 0, 0); ! #elif defined(EXTATTR_BSD) /* XXX: Namespace? */ return extattr_get_file(path, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); + #elif defined(EXTATTR_SOLARIS) + return solaris_getxattr(path, attrname, attrvalue, slen); #else return getxattr(path, attrname, attrvalue, slen); *************** *** 97,105 **** const size_t slen) { ! #ifdef __APPLE__ return fgetxattr(fd, attrname, attrvalue, slen, 0, 0); ! #elif defined(BSD) /* XXX: Namespace? */ return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); #else return fgetxattr(fd, attrname, attrvalue, slen); --- 66,76 ---- const size_t slen) { ! #ifdef EXTATTR_MACOSX return fgetxattr(fd, attrname, attrvalue, slen, 0, 0); ! #elif defined(EXTATTR_BSD) /* XXX: Namespace? */ return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, attrname, attrvalue, slen); + #elif defined(EXTATTR_SOLARIS) + return solaris_fgetxattr(fd, attrname, attrvalue, slen); #else return fgetxattr(fd, attrname, attrvalue, slen); *************** *** 114,117 **** --- 85,89 ---- return extattr_get_file(path, EXTATTR_NAMESPACE_USER, attrname, NULL, 0); #else + /* XXX: Can BSD use this too? Maybe once namespacing sorted. */ return portable_getxattr(path, attrname, NULL, 0); #endif *************** *** 125,128 **** --- 97,101 ---- return extattr_get_fd(fd, EXTATTR_NAMESPACE_USER, attrname, NULL, 0); #else + /* XXX: Can BSD use this too? Maybe once namespacing sorted. */ return portable_fgetxattr(fd, attrname, NULL, 0); #endif *************** *** 132,140 **** portable_removexattr (const char *path, const char *name) { ! #ifdef __APPLE__ return removexattr(path, name, 0); ! #elif defined(BSD) /* XXX: Namespace? */ return extattr_delete_file(path, EXTATTR_NAMESPACE_USER, name); #else return removexattr(path, name); --- 105,115 ---- portable_removexattr (const char *path, const char *name) { ! #ifdef EXTATTR_MACOSX return removexattr(path, name, 0); ! #elif defined(EXTATTR_BSD) /* XXX: Namespace? */ return extattr_delete_file(path, EXTATTR_NAMESPACE_USER, name); + #elif defined(EXTATTR_SOLARIS) + return solaris_removexattr(path, name); #else return removexattr(path, name); *************** *** 145,153 **** portable_fremovexattr (const int fd, const char *name) { ! #ifdef __APPLE__ return fremovexattr(fd, name, 0); ! #elif defined(BSD) /* XXX: Namespace? */ return extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name); #else return fremovexattr(fd, name); --- 120,130 ---- portable_fremovexattr (const int fd, const char *name) { ! #ifdef EXTATTR_MACOSX return fremovexattr(fd, name, 0); ! #elif defined(EXTATTR_BSD) /* XXX: Namespace? */ return extattr_delete_fd(fd, EXTATTR_NAMESPACE_USER, name); + #elif defined(EXTATTR_SOLARIS) + return solaris_fremovexattr(fd, name); #else return fremovexattr(fd, name); *************** *** 158,163 **** portable_listxattr(const char *path, char *buf, const size_t slen) { ! #ifdef __APPLE__ return listxattr(path, buf, slen, 0); #else return listxattr(path, buf, slen); --- 135,144 ---- portable_listxattr(const char *path, char *buf, const size_t slen) { ! #ifdef EXTATTR_MACOSX return listxattr(path, buf, slen, 0); + #elif defined(EXTATTR_BSD) + #error "FIXME" + #elif defined(EXTATTR_SOLARIS) + /*#error "XXX: FIXME"*/ #else return listxattr(path, buf, slen); *************** *** 168,173 **** portable_flistxattr(const int fd, char *buf, const size_t slen) { ! #ifdef __APPLE__ return flistxattr(fd, buf, slen, 0); #else return flistxattr(fd, buf, slen); --- 149,158 ---- portable_flistxattr(const int fd, char *buf, const size_t slen) { ! #ifdef EXTATTR_MACOSX return flistxattr(fd, buf, slen, 0); + #elif defined(EXTATTR_BSD) + #error "FIXME" + #elif defined(EXTATTR_SOLARIS) + /*#error "XXX: FIXME" */ #else return flistxattr(fd, buf, slen); Index: MANIFEST =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/MANIFEST,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** MANIFEST 27 May 2006 11:54:16 -0000 1.9 --- MANIFEST 14 Aug 2006 21:10:54 -0000 1.10 *************** *** 10,13 **** --- 10,19 ---- helpers.h helpers.c + extattr_bsd.h + extattr_linux.h + extattr_macosx.h + extattr_os.h + extattr_solaris.c + extattr_solaris.h t/00load.t t/01distribution.t --- NEW FILE: extattr_linux.h --- #ifndef EXTATTR_LINUX_H #define EXTATTR_LINUX_H #include <sys/types.h> #include <attr/attributes.h> #include <attr/xattr.h> #endif /* EXTATTR_LINUX_H */ |
From: Richard D. <ric...@us...> - 2006-08-14 21:01:50
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv4263 Modified Files: ExtAttr.xs Log Message: Fix some compilation warnings about mixing code with variable declarations Index: ExtAttr.xs =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/ExtAttr.xs,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** ExtAttr.xs 6 Mar 2006 20:53:47 -0000 1.15 --- ExtAttr.xs 14 Aug 2006 21:01:46 -0000 1.16 *************** *** 27,35 **** SV * attrvalueSV int flags ! CODE: STRLEN slen; char * attrvalue; int rc; attrvalue = SvPV(attrvalueSV, slen); rc = portable_setxattr(path, attrname, attrvalue, slen, flags); --- 27,36 ---- SV * attrvalueSV int flags ! PREINIT: STRLEN slen; char * attrvalue; int rc; + CODE: attrvalue = SvPV(attrvalueSV, slen); rc = portable_setxattr(path, attrname, attrvalue, slen, flags); *************** *** 40,43 **** --- 41,45 ---- } RETVAL = (rc == 0); + OUTPUT: RETVAL *************** *** 50,58 **** SV * attrvalueSV int flags ! CODE: STRLEN slen; char * attrvalue; int rc; attrvalue = SvPV(attrvalueSV, slen); rc = portable_fsetxattr(fd, attrname, attrvalue, slen, flags); --- 52,61 ---- SV * attrvalueSV int flags ! PREINIT: STRLEN slen; char * attrvalue; int rc; + CODE: attrvalue = SvPV(attrvalueSV, slen); rc = portable_fsetxattr(fd, attrname, attrvalue, slen, flags); *************** *** 63,66 **** --- 66,70 ---- } RETVAL = (rc == 0); + OUTPUT: RETVAL *************** *** 72,80 **** const char *attrname int flags ! CODE: char * attrvalue; int attrlen; ssize_t buflen; buflen = portable_lenxattr(path, attrname); if (buflen <= 0) --- 76,85 ---- const char *attrname int flags ! PREINIT: char * attrvalue; int attrlen; ssize_t buflen; + CODE: buflen = portable_lenxattr(path, attrname); if (buflen <= 0) *************** *** 102,105 **** --- 107,111 ---- RETVAL = newSVpv(attrvalue, attrlen); Safefree(attrvalue); + OUTPUT: RETVAL *************** *** 111,119 **** const char *attrname int flags ! CODE: char * attrvalue; int attrlen; ssize_t buflen; buflen = portable_flenxattr(fd, attrname); if (buflen <= 0) --- 117,126 ---- const char *attrname int flags ! PREINIT: char * attrvalue; int attrlen; ssize_t buflen; + CODE: buflen = portable_flenxattr(fd, attrname); if (buflen <= 0) *************** *** 141,144 **** --- 148,152 ---- RETVAL = newSVpv(attrvalue, attrlen); Safefree(attrvalue); + OUTPUT: RETVAL *************** *** 173,180 **** int fd int flags ! INIT: ssize_t size, ret; char *namebuf = NULL; char *nameptr; PPCODE: if(fd == -1) --- 181,189 ---- int fd int flags ! PREINIT: ssize_t size, ret; char *namebuf = NULL; char *nameptr; + PPCODE: if(fd == -1) |
From: Richard D. <ric...@us...> - 2006-08-14 21:01:13
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv4107 Modified Files: README TODO Log Message: Document some prereqs Index: README =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/README,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** README 6 Mar 2006 20:06:45 -0000 1.5 --- README 14 Aug 2006 21:01:08 -0000 1.6 *************** *** 33,41 **** DEPENDENCIES ! This module requires these other modules and libraries: Carp Scalar::Util COPYRIGHT AND LICENCE --- 33,49 ---- DEPENDENCIES ! This module requires these other modules: Carp Scalar::Util + This module's test suite is enhanced by the presence of the following + modules: + + Test::Distribution + Test::Pod + File::Find::Rule + Module::CoreList + COPYRIGHT AND LICENCE Index: TODO =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/TODO,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TODO 27 May 2006 11:50:47 -0000 1.9 --- TODO 14 Aug 2006 21:01:08 -0000 1.10 *************** *** 31,34 **** --- 31,37 ---- on Linux, nothing on the other platforms. + Document pre-reqs for test suite: Test::Distribution, Test::Pod::Coverage + Include these in a .spec file that we can include with distro + Rename the module? ~~~~~~~~~~~~~~~~~~ |
From: Richard D. <ric...@us...> - 2006-07-14 22:31:55
|
Update of /cvsroot/file-extattr/File-Attributes-Extended In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv15859 Added Files: TODO Log Message: Testing tips --- NEW FILE: TODO --- Testing tips: "...if you put your File::Attributes::Extended in your @INC and then run the File::Attributes test suite, it should test your module automagically. It should say: t/00-load............ok 1/1# Testing File::Attributes 0.02, Perl 5.008008, /usr/bin/perl # Available backends: File::Attributes::Extended File::Attributes::Simple. t/00-load............ok instead of: t/00-load............ok 1/1# Testing File::Attributes 0.02, Perl 5.008008, /usr/bin/perl # Available backends: File::Attributes::Simple. t/00-load............ok" |