# Sys::Guestfs::Lib
-# Copyright (C) 2009 Red Hat Inc.
+# Copyright (C) 2009-2010 Red Hat Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
use strict;
use warnings;
+# The minor part of this version number is incremented when some
+# change is made to this module. The major part is incremented if we
+# make a change which is not backwards compatible. It is not related
+# to the libguestfs version number.
+use vars qw($VERSION);
+$VERSION = '0.1';
+
use Carp qw(croak);
use Sys::Guestfs;
partitions and logical volumes found on it.
What is returned is everything that could contain a filesystem (or
-swap). Physical volumes are excluded from the list, and so are any
-devices which are partitioned (eg. C</dev/sda> would not be returned
-if C</dev/sda1> exists).
+swap). Physical volumes are not normally included from the list
+except if they contain a filesystem directly. Nor are devices which
+are partitioned (eg. C</dev/sda> would not be returned if C</dev/sda1>
+exists).
=cut
sub get_partitions
{
+ local $_;
my $g = shift;
+ # Look to see if any devices directly contain filesystems (RHBZ#590167).
+ my @devices = $g->list_devices ();
+ my @fses_on_device = ();
+ foreach (@devices) {
+ eval { $g->mount_ro ($_, "/"); };
+ push @fses_on_device, $_ unless $@;
+ $g->umount_all ();
+ }
+
my @partitions = $g->list_partitions ();
my @pvs = $g->pvs ();
@partitions = grep { ! _is_pv ($_, @pvs) } @partitions;
my @lvs;
@lvs = $g->lvs () if feature_available ($g, "lvm2");
- return sort (@lvs, @partitions);
+ return sort (@fses_on_device, @lvs, @partitions);
}
sub _is_pv {