From patchwork Tue Jul 31 17:11:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Karbstein X-Patchwork-Id: 1261251 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 36626DF26F for ; Tue, 31 Jul 2012 17:20:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751838Ab2GaRUS (ORCPT ); Tue, 31 Jul 2012 13:20:18 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:52328 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751166Ab2GaRUR (ORCPT ); Tue, 31 Jul 2012 13:20:17 -0400 Received: by wibhr14 with SMTP id hr14so3127427wib.1 for ; Tue, 31 Jul 2012 10:20:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=SoMawZZMokW1Y/v4J4kWjFMhQnUocOF9kSIypZo289M=; b=seWg8hQQPSUl8UvmnHewbZIysO8vZtR0nW9mbhz0RII3wPTQHzg+6BHk2SAfP3vuTX 8AiqzbhrBNoQFnGojeDcCUX89BSC74do/Pl+xyucpdRRmjAfZHCpS07yafQjnWgGz80l 5EygA7DFnm70BW5OH9b4qzk3RAY4oraz+QtoOA+rdQp5NO7pHmH80siKqeN1tfLg0eun Jds8fj/tn8QzbU3PQ36kt2Z2CiqZuANM+Tu8WqBcIyC24KFyGj46E6zjmixQRPa4cqVg 2htUcc9TQ97kWP12LiOCSFMnkIyD78xYgI3X9RKohQrPNElGycXncsweFGjC8GFnFjqb BYQA== Received: by 10.216.235.102 with SMTP id t80mr7936433weq.87.1343754723269; Tue, 31 Jul 2012 10:12:03 -0700 (PDT) Received: from localhost.localdomain ([83.144.232.2]) by mx.google.com with ESMTPS id w7sm23076134wiz.0.2012.07.31.10.12.01 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 31 Jul 2012 10:12:02 -0700 (PDT) From: Alexander Karbstein To: linux-btrfs@vger.kernel.org Cc: Alexander Karbstein Subject: [PATCH V2] Btrfs-progs: Enabled setting root subvolume with subvolid=0 Date: Tue, 31 Jul 2012 19:11:21 +0200 Message-Id: <1343754681-4454-2-git-send-email-alexander.karbstein@gmail.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <50173463.5060405@cn.fujitsu.com> References: <50173463.5060405@cn.fujitsu.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org 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 --- cmds-subvolume.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) 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 #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);