Skip to content

Commit

Permalink
fix remaining xattr-related return codes
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed Sep 6, 2023
1 parent ff3a721 commit 34051b4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<!-- test dependencies -->
<integrations-api.version>1.3.0</integrations-api.version>
<jfuse.version>0.6.0</jfuse.version>
<jfuse.version>0.6.1</jfuse.version>
<slf4j.version>2.0.7</slf4j.version>
<caffeine.version>3.1.7</caffeine.version>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,10 @@ public int getxattr(String path, String name, ByteBuffer value) {
//we use this approach because on different file systems different execptions are thrown when accessing xattr
// e.g. on Windows a NoSuchFileException, on Linux a generic FileSystenException is thrown
if (xattr.list().stream().noneMatch(key -> key.equals(name))) {
return -errno.enodata();
return switch (OS.current()) {
case MAC -> -errno.enoattr();
default -> -errno.enodata();
};
}
int size = xattr.size(name);
if (value.capacity() == 0) {
Expand All @@ -257,7 +260,7 @@ public int listxattr(String path, ByteBuffer list) {
LOG.trace("listxattr {}", path);
var xattr = Files.getFileAttributeView(node, UserDefinedFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
if (xattr == null) {
return -errno.enosys(); // TODO: return ENOTSUP
return -errno.enotsup();
}
var names = xattr.list();
if (list.capacity() == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public int removexattr(String path, String name) {
LOG.trace("removexattr {} {}", path, name);
var xattr = Files.getFileAttributeView(node, UserDefinedFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
if (xattr == null) {
return -errno.enosys(); // TODO: return ENOTSUP
return -errno.enotsup();
}
xattr.delete(name);
return 0;
Expand All @@ -127,7 +127,7 @@ public int setxattr(String path, String name, ByteBuffer value, int flags) {
LOG.trace("setxattr {} {}", path, name);
var xattr = Files.getFileAttributeView(node, UserDefinedFileAttributeView.class, LinkOption.NOFOLLOW_LINKS);
if (xattr == null) {
return -errno.enosys(); // TODO: return ENOTSUP
return -errno.enotsup();
}
xattr.write(name, value);
return 0;
Expand Down

0 comments on commit 34051b4

Please sign in to comment.