On Wed, Nov 25, 2009 at 09:35:51AM +0100, Jim Meyering wrote:
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"; +}
Thanks for looking at these. I'll push this one later. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora