diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-05 23:18:30 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-10-05 23:18:30 +0200 |
commit | 6261ef9505abb26d79cc48f24bce0d4de8419a45 (patch) | |
tree | 33069695fd0723e10ff5c0e7eb1748d709de5e3d /mkfs | |
parent | 40b75c24b1586e4d7ad8a9f4c14dc0b3ff99b8cd (diff) |
Improve error reporting for tar2sqfs and gensquashfs
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'mkfs')
-rw-r--r-- | mkfs/dirscan.c | 21 | ||||
-rw-r--r-- | mkfs/mkfs.c | 24 | ||||
-rw-r--r-- | mkfs/selinux.c | 2 |
3 files changed, 30 insertions, 17 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; } diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c index 16f9bc0..b000652 100644 --- a/mkfs/mkfs.c +++ b/mkfs/mkfs.c @@ -73,7 +73,8 @@ static int pack_files(sqfs_data_writer_t *data, fstree_t *fs, fi->user_ptr = inode; - ret = write_data_from_file(data, inode, file, 0); + ret = write_data_from_file(fi->input_file, data, + inode, file, 0); file->destroy(file); if (ret) @@ -86,18 +87,20 @@ static int pack_files(sqfs_data_writer_t *data, fstree_t *fs, return restore_working_dir(opt); } -static int relabel_tree_dfs(sqfs_xattr_writer_t *xwr, tree_node_t *n, - void *selinux_handle) +static int relabel_tree_dfs(const char *filename, sqfs_xattr_writer_t *xwr, + tree_node_t *n, void *selinux_handle) { char *path = fstree_get_path(n); + int ret; if (path == NULL) { perror("getting absolute node path for SELinux relabeling"); return -1; } - if (sqfs_xattr_writer_begin(xwr)) { - fputs("error recoding xattr key-value pairs\n", stderr); + ret = sqfs_xattr_writer_begin(xwr); + if (ret) { + sqfs_perror(filename, "recording xattr key-value pairs", ret); return -1; } @@ -106,8 +109,10 @@ static int relabel_tree_dfs(sqfs_xattr_writer_t *xwr, tree_node_t *n, return -1; } - 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(filename, "flushing completed key-value pairs", + ret); return -1; } @@ -115,7 +120,7 @@ static int relabel_tree_dfs(sqfs_xattr_writer_t *xwr, tree_node_t *n, if (S_ISDIR(n->mode)) { for (n = n->data.dir.children; n != NULL; n = n->next) { - if (relabel_tree_dfs(xwr, n, selinux_handle)) + if (relabel_tree_dfs(filename, xwr, n, selinux_handle)) return -1; } } @@ -144,7 +149,8 @@ static int read_fstree(fstree_t *fs, options_t *opt, sqfs_xattr_writer_t *xwr, fclose(fp); if (ret == 0 && selinux_handle != NULL) - ret = relabel_tree_dfs(xwr, fs->root, selinux_handle); + ret = relabel_tree_dfs(opt->cfg.filename, xwr, + fs->root, selinux_handle); return ret; } diff --git a/mkfs/selinux.c b/mkfs/selinux.c index f2c8fee..678723b 100644 --- a/mkfs/selinux.c +++ b/mkfs/selinux.c @@ -27,7 +27,7 @@ int selinux_relable_node(void *sehnd, sqfs_xattr_writer_t *xwr, free(context); if (ret) - fputs("Error relabeling tree node\n", stderr); + sqfs_perror(node->name, "storing SELinux xattr", ret); return ret; fail: |