diff options
author | Stefan Tomanek <stefan.tomanek@wertarbyte.de> | 2010-11-07 16:54:49 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2010-11-10 10:43:05 +0100 |
commit | f1db21218b35b618f622deb94b6e5ab2c62bbd17 (patch) | |
tree | 54673bd388300203faf724cf8034b2ce278014f0 /src/xattr.c | |
parent | 892cacef43b4871d8ce50b2e61a143ede1b3083e (diff) |
write extended attributes by using fsetxattr
Instead of reopening the downloaded file, fsetxattr uses the (already
open) file descriptor to attach extended attributes. This makes the
procedure more robust against errors caused by moved or deleted files.
Diffstat (limited to 'src/xattr.c')
-rw-r--r-- | src/xattr.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/xattr.c b/src/xattr.c index e03509680..a770405c9 100644 --- a/src/xattr.c +++ b/src/xattr.c @@ -25,7 +25,7 @@ #include <curl/curl.h> #include "xattr.h" -#ifdef HAVE_SETXATTR +#ifdef HAVE_FSETXATTR #include <sys/types.h> #include <string.h> #include <sys/xattr.h> /* include header from libc, not from libattr */ @@ -46,7 +46,7 @@ static const struct xattr_mapping { /* store metadata from the curl request alongside the downloaded * file using extended attributes */ -int write_xattr(CURL *curl, const char *filename) +int fwrite_xattr(CURL *curl, int fd) { int i = 0; int err = 0; @@ -55,17 +55,17 @@ int write_xattr(CURL *curl, const char *filename) char *value = NULL; CURLcode rc = curl_easy_getinfo(curl, mappings[i].info, &value); if ( rc == CURLE_OK && value ) { - err = setxattr( filename, mappings[i].attr, value, strlen(value), 0 ); + err = fsetxattr( fd, mappings[i].attr, value, strlen(value), 0 ); } i++; } return err; } #else -int write_xattr(CURL *curl, const char *filename) +int fwrite_xattr(CURL *curl, int fd) { (void)curl; - (void)filename; + (void)fd; return 0; } #endif |