From: Richard D. <ric...@us...> - 2008-06-15 10:22:37
|
Update of /cvsroot/file-extattr/File-ExtAttr In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv13462 Modified Files: Changes extattr_bsd.c Log Message: Update BSD layer to use new error reporting convention Index: Changes =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/Changes,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** Changes 3 May 2008 09:22:13 -0000 1.42 --- Changes 15 Jun 2008 10:22:40 -0000 1.43 *************** *** 21,25 **** XXX: This is incomplete: ! - Test on FreeBSD, Solaris. - Make sure I've actually addressed API concerns in #32670. --- 21,25 ---- XXX: This is incomplete: ! - Test on Solaris. - Make sure I've actually addressed API concerns in #32670. *************** *** 30,34 **** - (richdawe) Operations with non-default or non-"user" namespaces will now fail with EOPNOTSUPP instead of ENOATTR ! on Mac OS X. This behaviour is like Linux. 1.07 2007-12-15 --- 30,34 ---- - (richdawe) Operations with non-default or non-"user" namespaces will now fail with EOPNOTSUPP instead of ENOATTR ! on Mac OS X and *BSD. This behaviour is like Linux. 1.07 2007-12-15 Index: extattr_bsd.c =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/extattr_bsd.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** extattr_bsd.c 2 Oct 2006 22:05:04 -0000 1.6 --- extattr_bsd.c 15 Jun 2008 10:22:40 -0000 1.7 *************** *** 58,74 **** 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; ! } } --- 58,68 ---- bsd_extattr_set_succeeded (const int expected, const int actual) { ! int ret = 0; ! if (actual == -1) { ! ret = -errno; ! } else if (actual != expected) { ! /* Pretend there's not enough space for the data. */ ! ret = -ENOBUFS; } *************** *** 84,97 **** { 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); --- 78,89 ---- { int attrnamespace = -1; ! int ret = 0; if (!valid_namespace(flags, &attrnamespace)) { ! ret = -EOPNOTSUPP; } ! if (ret == 0) { File_ExtAttr_setflags_t setflags = File_ExtAttr_flags2setflags(flags); *************** *** 114,119 **** { /* Attribute already exists => fail. */ ! errno = EEXIST; ! ok = 0; } } --- 106,110 ---- { /* Attribute already exists => fail. */ ! ret = -EEXIST; } } *************** *** 122,126 **** } ! if (ok) { ret = extattr_set_file(path, attrnamespace, attrname, attrvalue, slen); --- 113,117 ---- } ! if (ret == 0) { ret = extattr_set_file(path, attrnamespace, attrname, attrvalue, slen); *************** *** 128,132 **** } ! return ok ? ret : -1; } --- 119,123 ---- } ! return ret; } *************** *** 139,152 **** { 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); --- 130,141 ---- { int attrnamespace = -1; ! int ret = 0; if (!valid_namespace(flags, &attrnamespace)) { ! ret = -EOPNOTSUPP; } ! if (ret == 0) { File_ExtAttr_setflags_t setflags = File_ExtAttr_flags2setflags(flags); *************** *** 169,174 **** { /* Attribute already exists => fail. */ ! errno = EEXIST; ! ok = 0; } } --- 158,162 ---- { /* Attribute already exists => fail. */ ! ret = -EEXIST; } } *************** *** 177,181 **** } ! if (ok) { ret = extattr_set_fd(fd, attrnamespace, attrname, attrvalue, slen); --- 165,169 ---- } ! if (ret == 0) { ret = extattr_set_fd(fd, attrnamespace, attrname, attrvalue, slen); *************** *** 194,210 **** { 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; } --- 182,200 ---- { int attrnamespace = -1; ! int ret = 0; if (!valid_namespace(flags, &attrnamespace)) { ! ret = -EOPNOTSUPP; } ! if (ret == 0) { ret = extattr_get_file(path, attrnamespace, attrname, attrvalue, slen); + if (ret < 0) { + ret = -errno; + } + } ! return ret; } *************** *** 217,233 **** { 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; } --- 207,225 ---- { int attrnamespace = -1; ! int ret = 0; if (!valid_namespace(flags, &attrnamespace)) { ! ret = -EOPNOTSUPP; } ! if (ret == 0) { ret = extattr_get_fd(fd, attrnamespace, attrname, attrvalue, slen); + if (ret < 0) { + ret = -errno; + } + } ! return ret; } *************** *** 238,254 **** { 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; } --- 230,248 ---- { int attrnamespace = -1; ! int ret = 0; if (!valid_namespace(flags, &attrnamespace)) { ! ret = -EOPNOTSUPP; } ! if (ret == 0) { ret = extattr_delete_file(path, attrnamespace, attrname); + if (ret < 0) { + ret = -errno; + } + } ! return ret; } *************** *** 259,275 **** { 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; } --- 253,271 ---- { int attrnamespace = -1; ! int ret = 0; if (!valid_namespace(flags, &attrnamespace)) { ! ret = -EOPNOTSUPP; } ! if (ret == 0) { ret = extattr_delete_fd(fd, attrnamespace, attrname); + if (ret < 0) { + ret = -errno; + } + } ! return ret; } *************** *** 297,310 **** { int attrnamespace = -1; ! int ok = 1; ! ssize_t ret; if (!valid_namespace(flags, &attrnamespace)) { ! errno = ENOATTR; ! ok = 0; } ! if (ok) { ret = extattr_list_file(path, --- 293,304 ---- { int attrnamespace = -1; ! ssize_t ret = 0; if (!valid_namespace(flags, &attrnamespace)) { ! ret = -EOPNOTSUPP; } ! if (ret == 0) { ret = extattr_list_file(path, *************** *** 316,322 **** if (buflen && (ret > 0)) reformat_list(buf, ret); } ! return ok ? ret : -1; } --- 310,320 ---- if (buflen && (ret > 0)) reformat_list(buf, ret); + + if (ret < 0) { + ret = -errno; + } } ! return ret; } *************** *** 328,341 **** { int attrnamespace = -1; ! int ok = 1; ! ssize_t ret; if (!valid_namespace(flags, &attrnamespace)) { ! errno = ENOATTR; ! ok = 0; } ! if (ok) { ret = extattr_list_fd(fd, --- 326,337 ---- { int attrnamespace = -1; ! ssize_t ret = 0; if (!valid_namespace(flags, &attrnamespace)) { ! ret = -EOPNOTSUPP; } ! if (ret == 0) { ret = extattr_list_fd(fd, *************** *** 347,353 **** if (buflen && (ret > 0)) reformat_list(buf, ret); } ! return ok ? ret : -1; } --- 343,353 ---- if (buflen && (ret > 0)) reformat_list(buf, ret); + + if (ret < 0) { + ret = -errno; + } } ! return ret; } *************** *** 357,361 **** { size_t len = 0; ! int ret; if (iHasUser) --- 357,361 ---- { size_t len = 0; ! ssize_t ret = 0; if (iHasUser) *************** *** 387,392 **** else { ! errno = ERANGE; ! ret = -1; } --- 387,391 ---- else { ! ret = -ERANGE; } *************** *** 402,406 **** int iHasUser = 0; int iHasSystem = 0; ! ssize_t ret; ret = extattr_list_file(path, EXTATTR_NAMESPACE_USER, NULL, 0); --- 401,405 ---- int iHasUser = 0; int iHasSystem = 0; ! ssize_t ret = 0; ret = extattr_list_file(path, EXTATTR_NAMESPACE_USER, NULL, 0); |