On some filesystems (e.g. ext3), listxattr doesn't return an error
even if extended attributes are not available.  This patch uses
getxattr instead of listxattr for the xattr check.

Signed-off-by: MORITA Kazutaka <[email protected]>
---
 sheep/farm/farm.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/sheep/farm/farm.c b/sheep/farm/farm.c
index ce76e3e..7eeae9a 100644
--- a/sheep/farm/farm.c
+++ b/sheep/farm/farm.c
@@ -328,6 +328,15 @@ static int init_sys_vdi_bitmap(char *path)
        return 0;
 }
 
+static bool is_xattr_enabled(char *path)
+{
+       int ret, dummy;
+
+       ret = getxattr(path, "user.dummy", &dummy, sizeof(dummy));
+
+       return !(ret == -1 && errno == ENOTSUP);
+}
+
 static int farm_init(char *p)
 {
        struct siocb iocb;
@@ -336,8 +345,10 @@ static int farm_init(char *p)
        if (create_directory(p) < 0)
                goto err;
 
-       if ((listxattr(p, NULL, 0) == -1) && (errno == ENOTSUP))
+       if (!is_xattr_enabled(p)) {
+               eprintf("xattrs are not enabled on %s\n", p);
                goto err;
+       }
 
        if (trunk_init() < 0)
                goto err;
-- 
1.7.2.5

-- 
sheepdog mailing list
[email protected]
http://lists.wpkg.org/mailman/listinfo/sheepdog

Reply via email to