summaryrefslogtreecommitdiff
path: root/cmds-subvolume.c
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2018-12-11 10:30:30 +1100
committerDimitri John Ledkov <xnox@ubuntu.com>2018-12-11 10:30:30 +1100
commit59d2f4ec0b9dff7b56da34541dffd3e676adf584 (patch)
tree0f982d10b206f248f13de6ba48617e9bdae5e5f5 /cmds-subvolume.c
parent3b9cf4c8cda0818e4d3f9892ece9f7d99de13b03 (diff)
parent5b162a39be9dec46a22c815f43fc337b920b4252 (diff)
Update upstream source from tag 'upstream/4.19.1'
Update to upstream version '4.19.1' with Debian dir 171bf4d92c150acf94e8e0a7633c4349c4e39ad6
Diffstat (limited to 'cmds-subvolume.c')
-rw-r--r--cmds-subvolume.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 45363a5a..a8395aac 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -102,6 +102,7 @@ static int cmd_subvol_create(int argc, char **argv)
struct btrfs_qgroup_inherit *inherit = NULL;
DIR *dirstream = NULL;
+ optind = 0;
while (1) {
int c = getopt(argc, argv, "c:i:");
if (c < 0)
@@ -135,7 +136,8 @@ static int cmd_subvol_create(int argc, char **argv)
retval = 1; /* failure */
res = test_isdir(dst);
if (res < 0 && res != -ENOENT) {
- error("cannot access %s: %s", dst, strerror(-res));
+ errno = -res;
+ error("cannot access %s: %m", dst);
goto out;
}
if (res >= 0) {
@@ -154,7 +156,7 @@ static int cmd_subvol_create(int argc, char **argv)
}
len = strlen(newname);
- if (len == 0 || len >= BTRFS_VOL_NAME_MAX) {
+ if (len > BTRFS_VOL_NAME_MAX) {
error("subvolume name too long: %s", newname);
goto out;
}
@@ -248,6 +250,7 @@ static int cmd_subvol_delete(int argc, char **argv)
enum { COMMIT_AFTER = 1, COMMIT_EACH = 2 };
enum btrfs_util_error err;
+ optind = 0;
while (1) {
int c;
static const struct option long_options[] = {
@@ -335,8 +338,8 @@ again:
} else if (commit_mode == COMMIT_AFTER) {
res = get_fsid(dname, fsid, 0);
if (res < 0) {
- error("unable to get fsid for '%s': %s",
- path, strerror(-res));
+ errno = -res;
+ error("unable to get fsid for '%s': %m", path);
error(
"delete succeeded but commit may not be done in the end");
ret = 1;
@@ -466,6 +469,7 @@ static int cmd_subvol_list(int argc, char **argv)
filter_set = btrfs_list_alloc_filter_set();
comparer_set = btrfs_list_alloc_comparer_set();
+ optind = 0;
while(1) {
int c;
static const struct option long_options[] = {
@@ -636,6 +640,7 @@ static int cmd_subvol_snapshot(int argc, char **argv)
DIR *dirstream1 = NULL, *dirstream2 = NULL;
memset(&args, 0, sizeof(args));
+ optind = 0;
while (1) {
int c = getopt(argc, argv, "c:i:r");
if (c < 0)
@@ -686,7 +691,8 @@ static int cmd_subvol_snapshot(int argc, char **argv)
res = test_isdir(dst);
if (res < 0 && res != -ENOENT) {
- error("cannot access %s: %s", dst, strerror(-res));
+ errno = -res;
+ error("cannot access %s: %m", dst);
goto out;
}
if (res == 0) {
@@ -711,7 +717,7 @@ static int cmd_subvol_snapshot(int argc, char **argv)
}
len = strlen(newname);
- if (len == 0 || len >= BTRFS_VOL_NAME_MAX) {
+ if (len > BTRFS_VOL_NAME_MAX) {
error("snapshot name too long '%s'", newname);
goto out;
}
@@ -933,6 +939,7 @@ static int cmd_subvol_show(int argc, char **argv)
char *subvol_path = NULL;
enum btrfs_util_error err;
+ optind = 0;
while (1) {
int c;
static const struct option long_options[] = {
@@ -1132,6 +1139,7 @@ static int cmd_subvol_sync(int argc, char **argv)
int sleep_interval = 1;
enum btrfs_util_error err;
+ optind = 0;
while (1) {
int c = getopt(argc, argv, "s:");