Re: [PATCH 2/3] Btrfs-progs: make get default report correctly

2012-07-02 Thread Ilya Dryomov
On Mon, Jul 02, 2012 at 09:39:45AM +0800, Liu Bo wrote:
 On 06/29/2012 06:36 PM, Ilya Dryomov wrote:
 
  On Fri, Jun 29, 2012 at 06:00:37PM +0800, Liu Bo wrote:
  We have both set-default and get-default, but actually our get-default
  does not show which one is the default one.
 
  This patch plus the kernel side patch fix this.
  
  Are you referring to the fact that get-default in Chris' btrfs-progs
  master lists all subvolumes instead of showing the default one?  If so,
  I fixed that problem a while ago, patch is in Hugo's integration branch.
  
 
 
 So can you please show me a link about your patch?

I'm sorry, it turns out Hugo hasn't pushed it yet.  Here is a link:
http://thread.gmane.org/gmane.comp.file-systems.btrfs/16187/

Thanks,

Ilya
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] Btrfs-progs: make get default report correctly

2012-07-02 Thread Liu Bo
On 07/02/2012 05:45 PM, Ilya Dryomov wrote:

 On Mon, Jul 02, 2012 at 09:39:45AM +0800, Liu Bo wrote:
 On 06/29/2012 06:36 PM, Ilya Dryomov wrote:

 On Fri, Jun 29, 2012 at 06:00:37PM +0800, Liu Bo wrote:
 We have both set-default and get-default, but actually our get-default
 does not show which one is the default one.

 This patch plus the kernel side patch fix this.
 Are you referring to the fact that get-default in Chris' btrfs-progs
 master lists all subvolumes instead of showing the default one?  If so,
 I fixed that problem a while ago, patch is in Hugo's integration branch.


 So can you please show me a link about your patch?
 
 I'm sorry, it turns out Hugo hasn't pushed it yet.  Here is a link:
 http://thread.gmane.org/gmane.comp.file-systems.btrfs/16187/
 


Fairly good patches.

thanks,
liubo

 Thanks,
 
   Ilya
 --
 To unsubscribe from this list: send the line unsubscribe linux-btrfs in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 


--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] Btrfs-progs: make get default report correctly

2012-07-01 Thread Liu Bo
On 06/29/2012 06:36 PM, Ilya Dryomov wrote:

 On Fri, Jun 29, 2012 at 06:00:37PM +0800, Liu Bo wrote:
 We have both set-default and get-default, but actually our get-default
 does not show which one is the default one.

 This patch plus the kernel side patch fix this.
 
 Are you referring to the fact that get-default in Chris' btrfs-progs
 master lists all subvolumes instead of showing the default one?  If so,
 I fixed that problem a while ago, patch is in Hugo's integration branch.
 


So can you please show me a link about your patch?

thanks,
liubo

 Thanks,
 
   Ilya
 --
 To unsubscribe from this list: send the line unsubscribe linux-btrfs in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
 


--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] Btrfs-progs: make get default report correctly

2012-06-29 Thread Liu Bo
We have both set-default and get-default, but actually our get-default
does not show which one is the default one.

This patch plus the kernel side patch fix this.

Signed-off-by: Liu Bo liubo2...@cn.fujitsu.com
---
 Makefile |6 +++---
 btrfs-list.c |   44 +---
 cmds-subvolume.c |   16 +++-
 ioctl.h  |1 +
 4 files changed, 48 insertions(+), 19 deletions(-)

diff --git a/Makefile b/Makefile
index 79818e6..5d10026 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ CFLAGS = -g -O0
 objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
  root-tree.o dir-item.o file-item.o inode-item.o \
  inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \
- volumes.o utils.o btrfs-list.o btrfslabel.o repair.o
+ volumes.o utils.o btrfs-list.o btrfslabel.o repair.o common.o
 cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
   cmds-inspect.o cmds-balance.o
 
@@ -39,8 +39,8 @@ all: version $(progs) manpages
 version:
bash version.sh
 
-btrfs: $(objects) btrfs.o help.o common.o $(cmds_objects)
-   $(CC) $(CFLAGS) -o btrfs btrfs.o help.o common.o $(cmds_objects) \
+btrfs: $(objects) btrfs.o help.o $(cmds_objects)
+   $(CC) $(CFLAGS) -o btrfs btrfs.o help.o $(cmds_objects) \
$(objects) $(LDFLAGS) $(LIBS) -lpthread
 
 calc-size: $(objects) calc-size.o
diff --git a/btrfs-list.c b/btrfs-list.c
index 5f4a9be..f1baa52 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -34,6 +34,7 @@
 #include ctree.h
 #include transaction.h
 #include utils.h
+#include commands.h
 
 /* we store all the roots we find in an rbtree so that we can
  * search for them later.
@@ -668,7 +669,42 @@ static int __list_subvol_fill_paths(int fd, struct 
root_lookup *root_lookup)
return 0;
 }
 
-int list_subvols(int fd, int print_parent)
+int subvol_get_set_flags(int fd, int set, u64 flags, u64 root_id)
+{
+   int ret = 0, e;
+   struct btrfs_ioctl_get_set_flags_args args;
+
+   memset(args, 0, sizeof(args));
+
+   if (set  flags)
+   args.flags |= flags;
+   args.objectid = root_id;
+
+   if (set)
+   ret = ioctl(fd, BTRFS_IOC_SUBVOL_SETFLAGS, args);
+   else
+   ret = ioctl(fd, BTRFS_IOC_SUBVOL_GETFLAGS, args);
+   e = errno;
+   if( ret  0 ){
+   fprintf(stderr, ERROR: unable to %s a subvolume flags- %s\n,
+   (set) ? set : get, strerror(e));
+   return 30;
+   } else if (!set) {
+   u64 flags_to_get = args.flags;
+   if (flags_to_get)
+   printf( ();
+   if (flags_to_get  BTRFS_SUBVOL_RDONLY)
+   printf(Readonly,);
+   if (flags_to_get  BTRFS_SUBVOL_DEFAULT)
+   printf(Default,);
+   if (flags_to_get)
+   printf());
+   printf(\n);
+   }
+   return 0;
+}
+
+int list_subvols(int fd, int print_parent, int get_default)
 {
struct root_lookup root_lookup;
struct rb_node *n;
@@ -704,15 +740,17 @@ int list_subvols(int fd, int print_parent)
resolve_root(root_lookup, entry, root_id, parent_id,
level, path);
if (print_parent) {
-   printf(ID %llu parent %llu top level %llu path %s\n,
+   printf(ID %llu parent %llu top level %llu path %s,
(unsigned long long)root_id,
(unsigned long long)parent_id,
(unsigned long long)level, path);
} else {
-   printf(ID %llu top level %llu path %s\n,
+   printf(ID %llu top level %llu path %s,
(unsigned long long)root_id,
(unsigned long long)level, path);
}
+   if (subvol_get_set_flags(fd, 0, 0, root_id))
+   printf(\n);
free(path);
n = rb_prev(n);
}
diff --git a/cmds-subvolume.c b/cmds-subvolume.c
index 5ee31cb..8783e67 100644
--- a/cmds-subvolume.c
+++ b/cmds-subvolume.c
@@ -32,6 +32,7 @@
 /* btrfs-list.c */
 int list_subvols(int fd, int print_parent, int get_default);
 int find_updated_files(int fd, u64 root_id, u64 oldest_gen);
+int subvol_get_set_flags(int fd, int set, u64 flags, u64 root_id);
 
 static const char * const subvolume_cmd_group_usage[] = {
btrfs subvolume command args,
@@ -520,33 +521,22 @@ static const char * const cmd_subvol_set_ro_usage[] = {
 
 static int cmd_subvol_set_ro(int argc, char **argv)
 {
-   int ret=0, fd, e;
+   int ret=0, fd;
char*path;
-   struct  btrfs_ioctl_get_set_flags_args args;
 
if (check_argc_exact(argc, 2))

Re: [PATCH 2/3] Btrfs-progs: make get default report correctly

2012-06-29 Thread Ilya Dryomov
On Fri, Jun 29, 2012 at 06:00:37PM +0800, Liu Bo wrote:
 We have both set-default and get-default, but actually our get-default
 does not show which one is the default one.
 
 This patch plus the kernel side patch fix this.

Are you referring to the fact that get-default in Chris' btrfs-progs
master lists all subvolumes instead of showing the default one?  If so,
I fixed that problem a while ago, patch is in Hugo's integration branch.

Thanks,

Ilya
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html