summaryrefslogtreecommitdiff
path: root/mkfs/dirscan.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-05 23:18:30 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-05 23:18:30 +0200
commit6261ef9505abb26d79cc48f24bce0d4de8419a45 (patch)
tree33069695fd0723e10ff5c0e7eb1748d709de5e3d /mkfs/dirscan.c
parent40b75c24b1586e4d7ad8a9f4c14dc0b3ff99b8cd (diff)
Improve error reporting for tar2sqfs and gensquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs/dirscan.c')
-rw-r--r--mkfs/dirscan.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/mkfs/dirscan.c b/mkfs/dirscan.c
index 6d6b745..06f4d79 100644
--- a/mkfs/dirscan.c
+++ b/mkfs/dirscan.c
@@ -44,6 +44,7 @@ static int populate_xattr(sqfs_xattr_writer_t *xwr, tree_node_t *node)
{
char *key, *value = NULL, *buffer = NULL;
ssize_t buflen, vallen, keylen;
+ int ret;
buflen = listxattr(node->name, NULL, 0);
@@ -76,19 +77,22 @@ static int populate_xattr(sqfs_xattr_writer_t *xwr, tree_node_t *node)
if (vallen > 0) {
value = calloc(1, vallen);
if (value == NULL) {
- perror("xattr value buffer");
+ perror("allocating xattr value buffer");
goto fail;
}
vallen = getxattr(node->name, key, value, vallen);
if (vallen == -1) {
- perror("getxattr");
+ fprintf(stderr, "%s: getxattr: %s\n",
+ node->name, strerror(errno));
goto fail;
}
- if (sqfs_xattr_writer_add(xwr, key, value, vallen)) {
- fputs("Error storing xattr key-value pair\n",
- stderr);
+ ret = sqfs_xattr_writer_add(xwr, key, value, vallen);
+ if (ret) {
+ sqfs_perror(node->name,
+ "storing xattr key-value pairs",
+ ret);
goto fail;
}
@@ -119,6 +123,7 @@ static int populate_dir(fstree_t *fs, tree_node_t *root, dev_t devstart,
struct stat sb;
tree_node_t *n;
DIR *dir;
+ int ret;
dir = opendir(".");
if (dir == NULL) {
@@ -202,8 +207,10 @@ static int populate_dir(fstree_t *fs, tree_node_t *root, dev_t devstart,
free(path);
}
- if (sqfs_xattr_writer_end(xwr, &n->xattr_idx)) {
- fputs("error generating xattr index\n", stderr);
+ ret = sqfs_xattr_writer_end(xwr, &n->xattr_idx);
+ if (ret) {
+ sqfs_perror(n->name,
+ "completing xattr key-value pairs", ret);
return -1;
}