From: Ulli Horlacher <framstag@rus.uni-stuttgart.de>
To: linux-btrfs@vger.kernel.org
Subject: Re: subvolume list as user?
Date: Sun, 17 Sep 2017 10:48:10 +0200 [thread overview]
Message-ID: <20170917084810.GP32347@rus.uni-stuttgart.de> (raw)
In-Reply-To: <54b8bb4b-3807-15da-1db5-fab7b0ced253@libero.it>
On Sat 2017-09-16 (22:56), Goffredo Baroncelli wrote:
>> how can a user get a list of his subvolumes? He may created them some
>> time ago and forget it. He now wants to have a list of them.
>
> Far to be perfect, but this could help
>
> find / -inum 256 2>/dev/null
>
> each subvolume has inode number 256
But non-btrfs filesystems can also have an inode 256!
And it is terrible slow and inefficent.
Ok, I will add a sudo wrapper for my btrfs_subvolume_list :
#!/usr/bin/perl -w
$mounts = '/proc/mounts';
open $mounts,$mounts or die "$0: cannot open $mounts - $!\n";
while (<$mounts>) {
if (m:^(/\S+) (/\S*) btrfs:) {
push @bfs,$2;
}
}
close $mounts;
if (@bfs) {
@bfs = sort @bfs;
} else {
die "$0: no mounted btrfs filesystems\n";
}
@sv = ();
foreach my $fs (@bfs) {
push @sv,"$fs\n";
open $fs,"btrfs subvolume list '$fs'|" or next;;
while (<$fs>) {
chomp;
s:.* \d+ path :$fs/:;
push @sv,"$_\n" if -d;
}
close $fs;
}
print sort @sv;
--
Ullrich Horlacher Server und Virtualisierung
Rechenzentrum TIK
Universitaet Stuttgart E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a Tel: ++49-711-68565868
70569 Stuttgart (Germany) WWW: http://www.tik.uni-stuttgart.de/
REF:<54b8bb4b-3807-15da-1db5-fab7b0ced253@libero.it>
prev parent reply other threads:[~2017-09-17 8:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-16 9:45 subvolume list as user? Ulli Horlacher
2017-09-16 12:39 ` Hans van Kranenburg
2017-09-16 13:40 ` Hans van Kranenburg
2017-09-16 14:37 ` Ulli Horlacher
2017-09-16 20:56 ` Goffredo Baroncelli
2017-09-17 8:48 ` Ulli Horlacher [this message]
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=20170917084810.GP32347@rus.uni-stuttgart.de \
--to=framstag@rus.uni-stuttgart.de \
--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