summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2013-02-01 15:56:27 +0800
committerDavid Sterba <dsterba@suse.cz>2013-02-01 16:55:05 +0100
commit16ef0a0c3c7e7811dabee76775f170f1a7c61855 (patch)
tree5a679ea4b440044dde0ae7bcba35acc48ee03539
parente260954a9e847c1e3ed0d2f457e256eb4726f5f2 (diff)
downloadbtrfs-progs-16ef0a0c3c7e7811dabee76775f170f1a7c61855.tar.gz
btrfs-progs-16ef0a0c3c7e7811dabee76775f170f1a7c61855.tar.bz2
btrfs-progs-16ef0a0c3c7e7811dabee76775f170f1a7c61855.zip
Btrfs-progs: make get_subvol_name non cmds-send specific
get_subvol_name can be used other than the just with in cmds-send.c so this patch will make it possible with out changing the original intentions. Signed-off-by: Anand Jain <anand.jain@oracle.com>
-rw-r--r--cmds-send.c12
-rw-r--r--commands.h1
2 files changed, 7 insertions, 6 deletions
diff --git a/cmds-send.c b/cmds-send.c
index 43355dbe..69e9bcea 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -334,12 +334,12 @@ out:
return ret;
}
-static const char *get_subvol_name(struct btrfs_send *s, const char *full_path)
+char *get_subvol_name(char *mnt, char *full_path)
{
- int len = strlen(s->root_path);
+ int len = strlen(mnt);
if (!len)
return full_path;
- if (s->root_path[len - 1] != '/')
+ if (mnt[len - 1] != '/')
len += 1;
return full_path + len;
@@ -449,7 +449,7 @@ int cmd_send_start(int argc, char **argv)
if (ret < 0)
goto out;
- ret = get_root_id(&send, get_subvol_name(&send, subvol),
+ ret = get_root_id(&send, get_subvol_name(send.root_path, subvol),
&root_id);
if (ret < 0) {
fprintf(stderr, "ERROR: could not resolve "
@@ -526,7 +526,7 @@ int cmd_send_start(int argc, char **argv)
if (snapshot_parent != NULL) {
ret = get_root_id(&send,
- get_subvol_name(&send, snapshot_parent),
+ get_subvol_name(send.root_path, snapshot_parent),
&parent_root_id);
if (ret < 0) {
fprintf(stderr, "ERROR: could not resolve root_id "
@@ -585,7 +585,7 @@ int cmd_send_start(int argc, char **argv)
goto out;
}
- ret = get_root_id(&send, get_subvol_name(&send, subvol),
+ ret = get_root_id(&send, get_subvol_name(send.root_path, subvol),
&root_id);
if (ret < 0) {
fprintf(stderr, "ERROR: could not resolve root_id "
diff --git a/commands.h b/commands.h
index 1124f2e8..33eb99a8 100644
--- a/commands.h
+++ b/commands.h
@@ -111,3 +111,4 @@ int test_issubvolume(char *path);
/* send.c */
int find_mount_root(const char *path, char **mount_root);
+char *get_subvol_name(char *mnt, char *full_path);