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
* 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)
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)