Replace ENODATA with ENOATTR in xattrs functions for macOS builds.
The contract in macOS xattr functions is to return ENOATTR when an extended attribute cannot be found.pull/2/head
parent
39579a045d
commit
4ecc13c0ac
|
@ -46,6 +46,16 @@
|
|||
#define ELIBACC ENOENT
|
||||
#endif
|
||||
|
||||
/* xattr APIs in macOS differs from Linux ones in that they expect the special
|
||||
* error code ENOATTR to be returned when an attribute cannot be found. So
|
||||
* define NTFS_NOXATTR_ERRNO to the appropriate "no xattr found" errno value for
|
||||
* the platform. */
|
||||
#if defined(__APPLE__) || defined(__DARWIN__)
|
||||
#define NTFS_NOXATTR_ERRNO ENOATTR
|
||||
#else
|
||||
#define NTFS_NOXATTR_ERRNO ENODATA
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
|
|
@ -3465,7 +3465,7 @@ static void ntfs_fuse_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
|
|||
/* trusted only readable by root */
|
||||
if ((namespace == XATTRNS_TRUSTED)
|
||||
&& security.uid) {
|
||||
res = -ENODATA;
|
||||
res = -NTFS_NOXATTR_ERRNO;
|
||||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
@ -3476,7 +3476,7 @@ static void ntfs_fuse_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
|
|||
}
|
||||
/* Return with no result for symlinks, fifo, etc. */
|
||||
if (!user_xattrs_allowed(ctx, ni)) {
|
||||
res = -ENODATA;
|
||||
res = -NTFS_NOXATTR_ERRNO;
|
||||
goto exit;
|
||||
}
|
||||
/* otherwise file must be readable */
|
||||
|
@ -3493,7 +3493,7 @@ static void ntfs_fuse_getxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
|
|||
}
|
||||
na = ntfs_attr_open(ni, AT_DATA, lename, lename_len);
|
||||
if (!na) {
|
||||
res = -ENODATA;
|
||||
res = -NTFS_NOXATTR_ERRNO;
|
||||
goto exit;
|
||||
}
|
||||
rsize = na->data_size;
|
||||
|
@ -3704,7 +3704,7 @@ static void ntfs_fuse_setxattr(fuse_req_t req, fuse_ino_t ino, const char *name,
|
|||
}
|
||||
if (!na) {
|
||||
if (flags == XATTR_REPLACE) {
|
||||
res = -ENODATA;
|
||||
res = -NTFS_NOXATTR_ERRNO;
|
||||
goto exit;
|
||||
}
|
||||
if (ntfs_attr_add(ni, AT_DATA, lename, lename_len, NULL, 0)) {
|
||||
|
@ -3942,7 +3942,7 @@ static void ntfs_fuse_removexattr(fuse_req_t req, fuse_ino_t ino, const char *na
|
|||
}
|
||||
if (ntfs_attr_remove(ni, AT_DATA, lename, lename_len)) {
|
||||
if (errno == ENOENT)
|
||||
errno = ENODATA;
|
||||
errno = NTFS_NOXATTR_ERRNO;
|
||||
res = -errno;
|
||||
}
|
||||
if (!res) {
|
||||
|
|
|
@ -3236,14 +3236,14 @@ static int ntfs_fuse_getxattr(const char *path, const char *name,
|
|||
/* trusted only readable by root */
|
||||
if ((namespace == XATTRNS_TRUSTED)
|
||||
&& security.uid)
|
||||
return -ENODATA;
|
||||
return -NTFS_NOXATTR_ERRNO;
|
||||
#endif
|
||||
ni = ntfs_pathname_to_inode(ctx->vol, NULL, path);
|
||||
if (!ni)
|
||||
return -errno;
|
||||
/* Return with no result for symlinks, fifo, etc. */
|
||||
if (!user_xattrs_allowed(ctx, ni)) {
|
||||
res = -ENODATA;
|
||||
res = -NTFS_NOXATTR_ERRNO;
|
||||
goto exit;
|
||||
}
|
||||
/* otherwise file must be readable */
|
||||
|
@ -3260,7 +3260,7 @@ static int ntfs_fuse_getxattr(const char *path, const char *name,
|
|||
}
|
||||
na = ntfs_attr_open(ni, AT_DATA, lename, lename_len);
|
||||
if (!na) {
|
||||
res = -ENODATA;
|
||||
res = -NTFS_NOXATTR_ERRNO;
|
||||
goto exit;
|
||||
}
|
||||
rsize = na->data_size;
|
||||
|
@ -3450,7 +3450,7 @@ static int ntfs_fuse_setxattr(const char *path, const char *name,
|
|||
}
|
||||
if (!na) {
|
||||
if (flags == XATTR_REPLACE) {
|
||||
res = -ENODATA;
|
||||
res = -NTFS_NOXATTR_ERRNO;
|
||||
goto exit;
|
||||
}
|
||||
if (ntfs_attr_add(ni, AT_DATA, lename, lename_len, NULL, 0)) {
|
||||
|
@ -3680,7 +3680,7 @@ static int ntfs_fuse_removexattr(const char *path, const char *name)
|
|||
}
|
||||
if (ntfs_attr_remove(ni, AT_DATA, lename, lename_len)) {
|
||||
if (errno == ENOENT)
|
||||
errno = ENODATA;
|
||||
errno = NTFS_NOXATTR_ERRNO;
|
||||
res = -errno;
|
||||
}
|
||||
if (!res) {
|
||||
|
|
Loading…
Reference in New Issue