Richard W.M. Jones wrote:
Subject: [PATCH] New tool: virt-list-filesystems
...
Another neat tool. Nice.
+# Try and mount each one, to see what's mountable.
+foreach $dev (@partitions) {
+ eval { $g->mount_ro ($dev, "/"); };
+ my $mountable = $@ ? 0 : 1;
+ $g->umount_all ();
+ if ($mountable) {
+ push @fses, $dev;
+ } else {
+ push @not_mountable, $dev;
+ }
+}
+
+foreach $dev (@fses) {
+ print canonicalize($dev);
+ if ($long) {
+ my $fstype;
+ eval { $fstype = $g->vfs_type ($dev); };
+ if ($fstype) {
+ print " $fstype";
+ } else {
+ print " unknown";
+ }
A small stylistic suggestion: I would write the above 5 lines
using the ||= idiom, like this:
$fstype ||= 'unknown';
print " $fstype";
Note, that that's ok as long as you really want to use
'unknown' even when the incoming $fstype happens to evaluate
to 0, too. But since that would never be a valid file system type,
this use of ||= is robust.
+ }
+ print "\n";
+}