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 |