aboutsummaryrefslogtreecommitdiffstats
path: root/cmds-subvolume.c
diff options
context:
space:
mode:
authorSatoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>2014-08-01 11:44:21 +0900
committerDavid Sterba <dsterba@suse.cz>2014-08-22 15:07:04 +0200
commit91b33340576e9c59353a89f0edb7b72a5a60ad3f (patch)
tree9d4419ca90279b312f22ab4b2f925b1c80bb2428 /cmds-subvolume.c
parentf0884b5dc30c134bcb87a43342ca26d0773295ee (diff)
downloadbtrfs-progs-91b33340576e9c59353a89f0edb7b72a5a60ad3f.tar.gz
btrfs-progs-91b33340576e9c59353a89f0edb7b72a5a60ad3f.tar.xz
btrfs-progs-91b33340576e9c59353a89f0edb7b72a5a60ad3f.zip
btrfs-progs: introduce test_issubvolname() for simplicity
There are many duplicated codes to check if the given string is correct subvolume name. Introduce test_issubvolname() for this purpose for simplicity. Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Cc: David Sterba <dsterba@suse.cz> Cc: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-subvolume.c')
-rw-r--r--cmds-subvolume.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index c589284..29ded12 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -126,8 +126,7 @@ static int cmd_subvol_create(int argc, char **argv)
dupdir = strdup(dst);
dstdir = dirname(dupdir);
- if (!strcmp(newname, ".") || !strcmp(newname, "..") ||
- strchr(newname, '/') ){
+ if (!test_issubvolname(newname)) {
fprintf(stderr, "ERROR: incorrect subvolume name '%s'\n",
newname);
goto out;
@@ -301,8 +300,7 @@ again:
vname = basename(dupvname);
free(cpath);
- if (!strcmp(vname, ".") || !strcmp(vname, "..") ||
- strchr(vname, '/')) {
+ if (!test_issubvolname(vname)) {
fprintf(stderr, "ERROR: incorrect subvolume name '%s'\n",
vname);
ret = 1;
@@ -672,8 +670,7 @@ static int cmd_snapshot(int argc, char **argv)
dstdir = dirname(dupdir);
}
- if (!strcmp(newname, ".") || !strcmp(newname, "..") ||
- strchr(newname, '/') ){
+ if (!test_issubvolname(newname)) {
fprintf(stderr, "ERROR: incorrect snapshot name '%s'\n",
newname);
goto out;