Copyright (C) Jeremy Allison 1998-2005
Copyright (C) Timur Bakeyev 2005
Copyright (C) Bjoern Jacke 2006-2007
+ Copyright (C) Herb Lewis 2003
+ Copyright (C) Andrew Bartlett 2012
** NOTE! The following LGPL license applies to the replace
** library. This does NOT imply that all of Samba is released
#include "replace.h"
#include "system/filesys.h"
+#include "system/dir.h"
/******** Solaris EA helper function prototypes ********/
#ifdef HAVE_ATTROPEN
#ifndef XATTR_ADDITIONAL_OPTIONS
return getxattr(path, name, value, size);
#else
+
+/* So that we do not recursivly call this function */
+#undef getxattr
int options = 0;
return getxattr(path, name, value, size, 0, options);
#endif
* that the buffer is large enough to fit the returned value.
*/
if((retval=extattr_get_file(path, attrnamespace, attrname, NULL, 0)) >= 0) {
- if(retval > size) {
+ if (size == 0) {
+ return retval;
+ } else if (retval > size) {
errno = ERANGE;
return -1;
}
if (strncmp(name, "system", 6) == 0) flags |= ATTR_ROOT;
retval = attr_get(path, attrname, (char *)value, &valuelength, flags);
+ if (size == 0 && retval == -1 && errno == E2BIG) {
+ return valuelength;
+ }
return retval ? retval : valuelength;
#elif defined(HAVE_ATTROPEN)
#ifndef XATTR_ADDITIONAL_OPTIONS
return fgetxattr(filedes, name, value, size);
#else
+
+/* So that we do not recursivly call this function */
+#undef fgetxattr
int options = 0;
return fgetxattr(filedes, name, value, size, 0, options);
#endif
const char *attrname = ((s=strchr(name, '.')) == NULL) ? name : s + 1;
if((retval=extattr_get_fd(filedes, attrnamespace, attrname, NULL, 0)) >= 0) {
- if(retval > size) {
+ if (size == 0) {
+ return retval;
+ } else if (retval > size) {
errno = ERANGE;
return -1;
}
if (strncmp(name, "system", 6) == 0) flags |= ATTR_ROOT;
retval = attr_getf(filedes, attrname, (char *)value, &valuelength, flags);
-
+ if (size == 0 && retval == -1 && errno == E2BIG) {
+ return valuelength;
+ }
return retval ? retval : valuelength;
#elif defined(HAVE_ATTROPEN)
ssize_t ret = -1;
#endif
-#if defined(HAVE_ATTR_LIST) && defined(HAVE_SYS_ATTRIBUTES_H)
+#if defined(HAVE_ATTR_LIST) && (defined(HAVE_SYS_ATTRIBUTES_H) || defined(HAVE_ATTR_ATTRIBUTES_H))
static char attr_buffer[ATTR_MAX_VALUELEN];
static ssize_t irix_attr_list(const char *path, int filedes, char *list, size_t size, int flags)
size_t ent_size, left = size;
char *bp = list;
- while (True) {
+ while (true) {
if (filedes)
retval = attr_listf(filedes, attr_buffer, ATTR_MAX_VALUELEN, flags, cursor);
else
if (retval == 0) {
flags |= ATTR_ROOT;
cursor = 0;
- while (True) {
+ while (true) {
if (filedes)
retval = attr_listf(filedes, attr_buffer, ATTR_MAX_VALUELEN, flags, cursor);
else
#ifndef XATTR_ADDITIONAL_OPTIONS
return listxattr(path, list, size);
#else
+/* So that we do not recursivly call this function */
+#undef listxattr
int options = 0;
return listxattr(path, list, size, options);
#endif
#ifndef XATTR_ADDITIONAL_OPTIONS
return flistxattr(filedes, list, size);
#else
+/* So that we do not recursivly call this function */
+#undef flistxattr
int options = 0;
return flistxattr(filedes, list, size, options);
#endif
#ifndef XATTR_ADDITIONAL_OPTIONS
return removexattr(path, name);
#else
+/* So that we do not recursivly call this function */
+#undef removexattr
int options = 0;
return removexattr(path, name, options);
#endif
#ifndef XATTR_ADDITIONAL_OPTIONS
return fremovexattr(filedes, name);
#else
+/* So that we do not recursivly call this function */
+#undef fremovexattr
int options = 0;
return fremovexattr(filedes, name, options);
#endif
#ifndef XATTR_ADDITIONAL_OPTIONS
return setxattr(path, name, value, size, flags);
#else
+/* So that we do not recursivly call this function */
+#undef setxattr
int options = 0;
return setxattr(path, name, value, size, 0, options);
#endif
#ifndef XATTR_ADDITIONAL_OPTIONS
return fsetxattr(filedes, name, value, size, flags);
#else
+/* So that we do not recursivly call this function */
+#undef fsetxattr
int options = 0;
return fsetxattr(filedes, name, value, size, 0, options);
#endif