diff mbox

[V2] Btrfs-progs: Enabled setting root subvolume with subvolid=0

Message ID 1343754681-4454-2-git-send-email-alexander.karbstein@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alexander Karbstein July 31, 2012, 5:11 p.m. UTC
The command btrfs subvolume set-default 0 /path/to/fs changed the
default subvolume to whatever subvolume was currently mounted on
/path/to/fs. This patch changes this behaviour to set the default
subvolume to BTRFS_FS_TREE_OBJECTID in case the user asks for
subvolid=0

Signed-off-by: Alexander Karbstein <alexander.karbstein@gmail.com>
---
 cmds-subvolume.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 3508ce6..8f8c918 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -25,6 +25,7 @@ 
 #include <limits.h>
 
 #include "kerncompat.h"
+#include "ctree.h"
 #include "ioctl.h"
 
 #include "commands.h"
@@ -464,6 +465,9 @@  static int cmd_subvol_set_default(int argc, char **argv)
 		fprintf(stderr, "ERROR: invalid tree id (%s)\n",subvolid);
 		return 30;
 	}
+	/* Using the original root fs tree */
+	if (objectid == 0ULL)
+		objectid = BTRFS_FS_TREE_OBJECTID;
 	ret = ioctl(fd, BTRFS_IOC_DEFAULT_SUBVOL, &objectid);
 	e = errno;
 	close(fd);