From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 2/2 v4] Btrfs-progs: cmd option to show or set the subvol label
Date: Mon, 25 Feb 2013 13:31:29 +0800 [thread overview]
Message-ID: <1361770289-1165-3-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1361770289-1165-1-git-send-email-anand.jain@oracle.com>
This adds the command option label to the subvol sub-command,
this is a generic patch which will stay irrespective of which
approach we take, that is the ioctl-way or the attributes.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
cmds-subvolume.c | 37 +++++++++++++++++++++++++++++++++++++
man/btrfs.8.in | 6 ++++++
2 files changed, 43 insertions(+)
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index ea128fc..1951c51 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -35,12 +35,48 @@
#include "utils.h"
#include "btrfs-list.h"
#include "utils.h"
+#include "btrfslabel.h"
static const char * const subvolume_cmd_group_usage[] = {
"btrfs subvolume <command> <args>",
NULL
};
+static const char * const cmd_subvol_label_usage[] = {
+ "btrfs subvolume label <path> [label]",
+ "Show or set label for the subvol or snapshot",
+ NULL
+};
+
+static int cmd_subvol_label(int argc, char **argv)
+{
+ struct stat st;
+ char label[BTRFS_SUBVOL_LABEL_SIZE+1];
+ int ret;
+
+ if (check_argc_min(argc, 2) || check_argc_max(argc, 3))
+ usage(cmd_subvol_label_usage);
+
+ if (stat(argv[1], &st) < 0) {
+ fprintf(stderr, "Error: %s\n",strerror(errno));
+ return -errno;
+ }
+ if (!S_ISDIR(st.st_mode)) {
+ fprintf(stderr, "Error: Not a dir\n");
+ return -1;
+ }
+ if (argc > 2)
+ return set_subvol_label(argv[1], argv[2]);
+ else {
+ ret = get_subvol_label(argv[1], label);
+ if (ret)
+ return ret;
+ label[BTRFS_SUBVOL_LABEL_SIZE]=0;
+ printf("%s\n",label);
+ }
+ return 0;
+}
+
/*
* test if path is a directory
* this function return
@@ -933,6 +969,7 @@ const struct cmd_group subvolume_cmd_group = {
cmd_subvol_set_default_usage, NULL, 0 },
{ "find-new", cmd_find_new, cmd_find_new_usage, NULL, 0 },
{ "show", cmd_subvol_show, cmd_subvol_show_usage, NULL, 0 },
+ { "label", cmd_subvol_label, cmd_subvol_label_usage, NULL, 0 },
{ 0, 0, 0, 0, 0 }
}
};
diff --git a/man/btrfs.8.in b/man/btrfs.8.in
index 94f4ffe..cd2e4e5 100644
--- a/man/btrfs.8.in
+++ b/man/btrfs.8.in
@@ -17,6 +17,8 @@ btrfs \- control a btrfs filesystem
.PP
\fBbtrfs\fP \fBsubvolume get-default\fP\fI <path>\fP
.PP
+\fBbtrfs\fP \fBsubvolume label\fP\fI <path> [label]\fP
+.PP
\fBbtrfs\fP \fBsubvolume find-new\fP\fI <subvolume> <last_gen>\fP
.PP
\fBbtrfs\fP \fBsubvolume show\fP\fI <path>\fP
@@ -177,6 +179,10 @@ Get the default subvolume of the filesystem \fI<path>\fR. The output format
is similar to \fBsubvolume list\fR command.
.TP
+\fBsubvolume label\fR\fI <path> [label]\fR
+Show or set \fI[label]\fR for the subvolume or the snapshot \fI<path>\fR.
+.TP
+
\fBsubvolume find-new\fR\fI <subvolume> <last_gen>\fR
List the recently modified files in a subvolume, after \fI<last_gen>\fR ID.
.TP
--
1.8.1.227.g44fe835
next prev parent reply other threads:[~2013-02-25 5:31 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-01 10:46 [Request for review] [RFC] Add label support for snapshots and subvols Anand jain
2012-11-01 10:46 ` [PATCH 1/2] Btrfs-progs: move open_file_or_dir() to utils.c Anand jain
2012-11-01 10:46 ` [PATCH 2/2] Btrfs-progs: add feature to label subvol and snapshot Anand jain
2012-11-01 10:46 ` [PATCH] Btrfs: add label to snapshot and subvol Anand jain
2012-11-05 7:39 ` Jan Schmidt
2012-11-16 5:15 ` Anand Jain
2012-11-01 22:16 ` [Request for review] [RFC] Add label support for snapshots and subvols cwillu
2012-11-01 22:28 ` Fajar A. Nugraha
2012-11-01 22:32 ` Hugo Mills
2012-11-01 22:49 ` Fajar A. Nugraha
2012-11-05 7:24 ` Anand Jain
2012-11-05 23:22 ` David Sterba
2012-11-01 23:04 ` Goffredo Baroncelli
2012-11-16 4:52 ` [Request for review v2] " Anand jain
2012-11-16 4:52 ` [PATCH 1/3] Btrfs-progs: move open_file_or_dir() to utils.c Anand jain
2012-11-16 4:52 ` [PATCH v2] Btrfs: add label to snapshot and subvol Anand jain
2012-11-16 6:33 ` Miao Xie
2012-11-27 18:26 ` Anand Jain
2012-11-16 4:52 ` [PATCH 2/3] Btrfs-progs: add feature to label subvol and snapshot Anand jain
2012-11-16 4:52 ` [PATCH 3/3] Btrfs-progs: cmd option to show or set the subvol label Anand jain
2012-11-27 18:29 ` [Request for review v3] [RFC] Add label support for snapshots and subvols Anand jain
2012-11-27 18:29 ` [PATCH v3] Btrfs: add label to snapshot and subvol Anand jain
2012-11-28 3:05 ` Miao Xie
2012-11-28 10:02 ` Anand Jain
2012-11-28 10:25 ` Miao Xie
2012-11-28 12:17 ` Anand Jain
2012-11-28 12:15 ` Anand jain
2012-11-27 18:29 ` [PATCH 1/3] Btrfs-progs: move open_file_or_dir() to utils.c Anand jain
2012-11-27 18:29 ` [PATCH 2/3] Btrfs-progs: add feature to label subvol and snapshot Anand jain
2012-11-27 18:29 ` [PATCH 3/3] Btrfs-progs: cmd option to show or set the subvol label Anand jain
2012-11-30 15:47 ` [PATCH 0/3] Add subvol and snapshot attribute label Anand jain
2012-11-30 15:48 ` [PATCH 1/3] Btrfs-progs: move open_file_or_dir() to utils.c Anand jain
2012-11-30 15:48 ` [PATCH 2/3] Btrfs-progs: add attribute label for subvol and snapshot Anand jain
2012-11-30 15:48 ` [PATCH 3/3] Btrfs-progs: cmd option to show or set the subvol label Anand jain
2013-02-25 5:31 ` [PATCH 0/2 v4] Btrfs-progs: Add support for " Anand Jain
2013-02-25 5:31 ` [PATCH 1/2 v4] Btrfs-progs: add feature to label subvol and snapshot Anand Jain
2013-02-25 5:31 ` Anand Jain [this message]
2013-02-25 5:31 ` [PATCH v4] Btrfs: Add support for subvol label Anand Jain
2013-02-25 5:31 ` [PATCH v4] Btrfs: ability to add label to snapshot and subvol Anand Jain
2013-02-25 20:45 ` Hugo Mills
2013-03-01 10:36 ` Anand Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1361770289-1165-3-git-send-email-anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).