diff mbox series

[hurd,commited,2/4] hurd: Fix getxattr("gnu.translator") returning ENODATA

Message ID 20240610200930.616306-3-samuel.thibault@ens-lyon.org
State New
Headers show
Series hurd xattr fixes | expand

Commit Message

Samuel Thibault June 10, 2024, 8:09 p.m. UTC
When no translator is set, __file_get_translator would return EINVAL
which is a confusing value. Better check for a passive translation
before getting the value.
---
 hurd/xattr.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/hurd/xattr.c b/hurd/xattr.c
index 0715ad7b02..f613d47c83 100644
--- a/hurd/xattr.c
+++ b/hurd/xattr.c
@@ -61,7 +61,16 @@  _hurd_xattr_get (io_t port, const char *name, void *value, size_t *size)
     {
       char *buf = value;
       mach_msg_type_number_t bufsz = value ? *size : 0;
-      error_t err = __file_get_translator (port, &buf, &bufsz);
+      struct stat64 st;
+      error_t err;
+
+      err = __io_stat (port, &st);
+      if (err)
+	return err;
+      if ((st.st_mode & S_IPTRANS) == 0)
+	return ENODATA;
+
+      err = __file_get_translator (port, &buf, &bufsz);
       if (err)
 	return err;
       if (value != NULL && *size < bufsz)