Skip to contentSkip to conversation

How to get the default subvolume?

DISCUSSION Yi Yang 3 participants 7 messages Jul 8, 2011 Btrfs file system

lore
Share & tools
lore

Yi Yang

author
#0 lore raw

Hi,

I know I can set the default subvolume for a btrfs fs using

sudo btrfs subvolume set-default 256 /btrfs/mnt

But after that, how can get the default subvolume name? In my opinion, btrfs-progs should provide "btrfs subvolume get-default /btrfs/mnm" to get the default subvolume id and name, I think it is very easy to do this in btrfs-progs and btrfs kernel space.

#1 lore raw
Quoted 8 lines · Yi Yang

I know I can set the default subvolume for a btrfs fs using

sudo btrfs subvolume set-default 256 /btrfs/mnt

But after that, how can get the default subvolume name? In my opinion, btrfs-progs should provide "btrfs subvolume get-default /btrfs/mnm" to get the default subvolume id and name, I think it is very easy to do this in btrfs-progs and btrfs kernel space.

I don't think the current btrfs-progs will do it. As you pointed
out though, it's pretty easy to write the code to get the information (I implemented it for btrfs-gui without any additional kernel code, for example). We just need someone to implement it. :)

I'd do it myself, but there's about a dozen things higher up my
priority list right now.

Hugo.

Signature · 3 lines
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
              --- Welcome to Rivendell,  Mr Anderson... ---              
#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 7 lines · Hugo Mills
Quoted 6 lines · Yi Yang

I know I can set the default subvolume for a btrfs fs using

sudo btrfs subvolume set-default 256 /btrfs/mnt

But after that, how can get the default subvolume name? In my opinion, btrfs-progs should provide "btrfs subvolume get-default /btrfs/mnm" to

get

Quoted 11 lines
Quoted 2 lines

the default subvolume id and name, I think it is very easy to do this in btrfs-progs and btrfs kernel space.

I don't think the current btrfs-progs will do it. As you pointed out though, it's pretty easy to write the code to get the information (I implemented it for btrfs-gui without any additional kernel code, for example). We just need someone to implement it. :)

I'd do it myself, but there's about a dozen things higher up my priority list right now.

Well, I'd be happy to try it. If it's fine, I will try to follow the implementation from btrfs-gui.

Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJOFtWBAAoJEJIcBJ3+Xkgi/loP/jBB2BnrDvdRrN+gxP5XcCr8 62ZgP2XxO/MrIH5Xc4iNfUlMF8Fnttjr8LvjpbP3Q2Vfb2ogPPf6ALpBxtCOhaHJ yAFE4CvGon7f2sTGZO2EJxf4eSSoFUd19je+knPZOdyIDhc1lhXVp4LBeoPKySRe GDBQtv1uqYx79hD24R5vU5uK1xMDTVE5HHCy8jZtoaVGU4YO87u7vFfNJKqAmS/W tZbT3wkrod/HHo8sxS4ZKzPx1c0Ph/F3g/P8SWSHW5dmK/dSadRVe+Io09tyd6uu GfGMMtEs6lVjHq/gn4ebDZwk3pFmCACnCxk6cE5imGWOIvftLMCFRZkFS41BVn7s pAz+JEp7NaICKo3rbFlEZdvteBB0AaJTCeo2wAP0xD6aBEdT5MhxHZQCGi6PeRDn 2GTqw2gT+urTVa7Rr6O2PIQlC0mjFit6dVYcFzPIP/X+cXozDnuNeUmPD10VlEjN PHIOJjNX3Zod8KknQc/NX0kn3TcHZptX0EWJhtnC0X4kHMxZOUrfnlIMTjCP23pX TA4Zjc68fe5mDm75PnbT6h4QoLa5h3j8TWf8fYYFBC/FOcb4NFm4iJEA6AG7CS1l MExGgd619NWUXHDpjjhTTzerBHF+1D5XPNc0lnb7WNkjzfBQD5JfkFzCp3lzTylU dpaD5umGdM+1DlrD8NP/
=vM5/
-----END PGP SIGNATURE-----

author
#3 lore raw
In reply to Hugo Mills

That's great, can you share your source code with me? I'm very eager to get this now :-)

-----Original Message-----
From: Hugo Mills [mailto:[email protected]]
Sent: Friday, July 08, 2011 5:58 PM
To: Yang, Yi Y
Cc: [email protected]
Subject: Re: How to get the default subvolume?

Quoted 8 lines · Yi Yang

I know I can set the default subvolume for a btrfs fs using

sudo btrfs subvolume set-default 256 /btrfs/mnt

But after that, how can get the default subvolume name? In my opinion, btrfs-progs should provide "btrfs subvolume get-default /btrfs/mnm" to get the default subvolume id and name, I think it is very easy to do this in btrfs-progs and btrfs kernel space.

I don't think the current btrfs-progs will do it. As you pointed out though, it's pretty easy to write the code to get the information (I implemented it for btrfs-gui without any additional kernel code, for example). We just need someone to implement it. :)

I'd do it myself, but there's about a dozen things higher up my priority list right now.

Hugo.

--
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
--- Welcome to Rivendell, Mr Anderson... ---

#4 lore raw
Quoted 1 line · Yi Y

That's great, can you share your source code with me? I'm very eager to get this now :-)

http://carfax.org.uk/btrfs-gui
http://git.darksatanic.net/repo/btrfs-gui.git/

You probably want the btrfsgui.hlp.subvol.sv_list() function.

Hugo.

Quoted 23 lines

-----Original Message-----
From: Hugo Mills [mailto:[email protected]]
Sent: Friday, July 08, 2011 5:58 PM
To: Yang, Yi Y
Cc: [email protected]
Subject: Re: How to get the default subvolume?

Quoted 8 lines · Yi Yang

I know I can set the default subvolume for a btrfs fs using

sudo btrfs subvolume set-default 256 /btrfs/mnt

But after that, how can get the default subvolume name? In my opinion, btrfs-progs should provide "btrfs subvolume get-default /btrfs/mnm" to get the default subvolume id and name, I think it is very easy to do this in btrfs-progs and btrfs kernel space.

I don't think the current btrfs-progs will do it. As you pointed out though, it's pretty easy to write the code to get the information (I implemented it for btrfs-gui without any additional kernel code, for example). We just need someone to implement it. :)

I'd do it myself, but there's about a dozen things higher up my priority list right now.

Hugo.

Signature · 3 lines
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
                      --- vi: The core of evil. ---                      
author
#5 lore raw
Quoted 1 line

From your source, you defined some structures using python and use them to get and parse btrfs metadata, very advanced and complicated :-), do you know there is any library to provide similar APIs in order that I can use some advanced APIs and don't need to worry about frequent changes of btrfs superblock and other metadata.

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hugo Mills
Sent: Friday, July 08, 2011 6:13 PM
To: Yang, Yi Y
Cc: [email protected]
Subject: Re: How to get the default subvolume?

Quoted 2 lines · Yi Y

That's great, can you share your source code with me? I'm very eager to get this now :-)

http://carfax.org.uk/btrfs-gui
http://git.darksatanic.net/repo/btrfs-gui.git/

You probably want the btrfsgui.hlp.subvol.sv_list() function.

Hugo.

Quoted 17 lines

-----Original Message-----
From: Hugo Mills [mailto:[email protected]]
Sent: Friday, July 08, 2011 5:58 PM
To: Yang, Yi Y
Cc: [email protected]
Subject: Re: How to get the default subvolume?

Quoted 8 lines · Yi Yang

I know I can set the default subvolume for a btrfs fs using

sudo btrfs subvolume set-default 256 /btrfs/mnt

But after that, how can get the default subvolume name? In my opinion, btrfs-progs should provide "btrfs subvolume get-default /btrfs/mnm" to get the default subvolume id and name, I think it is very easy to do this in btrfs-progs and btrfs kernel space.

Quoted 9 lines

I don't think the current btrfs-progs will do it. As you pointed
out though, it's pretty easy to write the code to get the information (I implemented it for btrfs-gui without any additional kernel code, for example). We just need someone to implement it. :)

I'd do it myself, but there's about a dozen things higher up my priority list right now.

Hugo.

--
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk

                      --- vi: The core of evil. ---                      
#6 lore raw
Quoted 5 lines · Yi Y

From your source, you defined some structures using python and use them to get and parse btrfs metadata, very advanced and complicated :-), do you know there is any library to provide similar APIs in order that I can use some advanced APIs and don't need to worry about frequent changes of btrfs superblock and other metadata.

The fundamental btrfs data structures (which you'll find defined in
ctree.h in the btrfs-progs source, and which are mirrored in my python code) won't change much, since they define the on-disk layout. Changing those structures creates incompatible filesystems, which is a Bad Thing, so it doesn't happen all that often.

Hugo.

PS. On most development mailing lists, it's conventional to write your replies below the text you're replying to, not above.

Quoted 45 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Hugo Mills
Sent: Friday, July 08, 2011 6:13 PM
To: Yang, Yi Y
Cc: [email protected]
Subject: Re: How to get the default subvolume?

Quoted 2 lines · Yi Y

That's great, can you share your source code with me? I'm very eager to get this now :-)

http://carfax.org.uk/btrfs-gui
http://git.darksatanic.net/repo/btrfs-gui.git/

You probably want the btrfsgui.hlp.subvol.sv_list() function.

Hugo.

Quoted 26 lines

-----Original Message-----
From: Hugo Mills [mailto:[email protected]]
Sent: Friday, July 08, 2011 5:58 PM
To: Yang, Yi Y
Cc: [email protected]
Subject: Re: How to get the default subvolume?

Quoted 8 lines · Yi Yang

I know I can set the default subvolume for a btrfs fs using

sudo btrfs subvolume set-default 256 /btrfs/mnt

But after that, how can get the default subvolume name? In my opinion, btrfs-progs should provide "btrfs subvolume get-default /btrfs/mnm" to get the default subvolume id and name, I think it is very easy to do this in btrfs-progs and btrfs kernel space.

I don't think the current btrfs-progs will do it. As you pointed
out though, it's pretty easy to write the code to get the information (I implemented it for btrfs-gui without any additional kernel code, for example). We just need someone to implement it. :)

I'd do it myself, but there's about a dozen things higher up my priority list right now.

Hugo.

Signature · 3 lines
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
                      --- vi: The core of evil. ---