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; + } |