summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2017-03-10 11:48:39 -0900
committerKent Overstreet <kent.overstreet@gmail.com>2017-03-10 11:48:39 -0900
commitc3844b0b7ff75527a87f52229f15341c24c0d356 (patch)
treeae5c5f571ea3c82d1ec99e3fce712ea88dc8e63d
parent076b4196fc340f840e83072e8ea3986a19dcb321 (diff)
cmd_migrate: fix xattrs
-rw-r--r--INSTALL7
-rw-r--r--cmd_migrate.c21
-rw-r--r--debian/control3
3 files changed, 14 insertions, 17 deletions
diff --git a/INSTALL b/INSTALL
index a23ccc9..90b3585 100644
--- 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
diff --git a/cmd_migrate.c b/cmd_migrate.c
index a2c4029..51bab3d 100644
--- a/cmd_migrate.c
+++ b/cmd_migrate.c
@@ -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,
diff --git a/debian/control b/debian/control
index 1886dfc..20cfd11 100644
--- a/debian/control
+++ b/debian/control
@@ -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/