]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
cmd_migrate: fix xattrs
authorKent Overstreet <kent.overstreet@gmail.com>
Fri, 10 Mar 2017 20:48:39 +0000 (11:48 -0900)
committerKent Overstreet <kent.overstreet@gmail.com>
Fri, 10 Mar 2017 20:48:39 +0000 (11:48 -0900)
INSTALL
cmd_migrate.c
debian/control

diff --git a/INSTALL b/INSTALL
index a23ccc9bedcf17a8d7d15232efd5539bccb60174..90b35853a10e230a03159d27550c4fdec101ba73 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1,13 +1,18 @@
 
 Dependencies:
 
+ * libattr1
  * libblkid
  * libuuid
  * libscrypt
  * libsodium
  * libkeyutils
+ * liburcu
+ * pkg-config
+ * zlib1g
 
 On debian, you can install these with
-    apt install -y libblkid-dev uuid-dev libscrypt-dev libsodium-dev libkeyutils-dev
+    apt install -y pkg-config libblkid-dev uuid-dev libscrypt-dev libsodium-dev
+       libkeyutils-dev liburcu-dev zlib1g-dev libattr1-dev
 
 Then, just make && make install
index a2c40296db08d0667b27a02898d8db20bb03c64e..51bab3df33e96c3f01535d91fbeb8151093371b5 100644 (file)
@@ -219,25 +219,18 @@ static void copy_xattrs(struct cache_set *c, struct bch_inode_unpacked *dst,
                        char *src)
 {
        struct bch_hash_info hash_info = bch_hash_info_init(dst);
-       ssize_t size = llistxattr(src, NULL, 0);
-       if (size < 0)
-               die("listxattr error: %s", strerror(errno));
-
-       if (!size)
-               return;
 
-       char *buf = malloc(size);
-       size = llistxattr(src, buf, size);
-       if (size < 0)
+       char attrs[XATTR_LIST_MAX];
+       ssize_t attrs_size = llistxattr(src, attrs, sizeof(attrs));
+       if (attrs_size < 0)
                die("listxattr error: %s", strerror(errno));
 
-       for (const char *next, *attr = buf;
-            attr <= buf + size;
+       for (const char *next, *attr = attrs;
+            attr < attrs + attrs_size;
             attr = next) {
                next = attr + strlen(attr) + 1;
 
-               /* max possible xattr val: */
-               static char val[64 << 10];
+               char val[XATTR_SIZE_MAX];
                ssize_t val_size = lgetxattr(src, attr, val, sizeof(val));
 
                if (val_size < 0)
@@ -250,8 +243,6 @@ static void copy_xattrs(struct cache_set *c, struct bch_inode_unpacked *dst,
                if (ret < 0)
                        die("error creating xattr: %s", strerror(-ret));
        }
-
-       free(buf);
 }
 
 static void write_data(struct cache_set *c,
index 1886dfc76d76dc1b4aea761cc59aadd092d622a8..20cfd1185b6027d04001e42126ae5a7d81f5cfe6 100644 (file)
@@ -5,7 +5,8 @@ Section: utils
 Priority: optional
 Standards-Version: 3.9.5
 Build-Depends: debhelper (>= 9), pkg-config, libblkid-dev, uuid-dev,
-       libscrypt-dev, libsodium-dev, libkeyutils-dev, liburcu-dev, zlib1g-dev
+       libscrypt-dev, libsodium-dev, libkeyutils-dev, liburcu-dev, zlib1g-dev,
+       libattr1-dev
 Vcs-Browser: http://anonscm.debian.org/gitweb/?p=collab-maint/bcache-tools.git
 Vcs-Git: git://anonscm.debian.org/collab-maint/bcache-tools.git
 Homepage: http://bcache.evilpiepirate.org/