3 # FsEntry -- encapsulate a single entry in /etc/fstab
4 # Copyright (C) 2005 Erik van Konijnenburg
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 use LabeledPartitionTab;
29 $self->takeArgs ('dev', 'mnt', 'type', 'opts');
32 sub dev { return $_[0]->{dev}; }
33 sub mnt { return $_[0]->{mnt}; }
34 sub type { return $_[0]->{type}; }
35 sub opts { return $_[0]->{opts}; }
39 my $dev = $self->dev();
40 my $mnt = $self->mnt();
41 my $type = $self->type();
42 my $opts = $self->opts()->string();
43 return "$mnt at $dev ($type) with $opts";
48 # isRequiredAtBoot -- To be mounted at boot time with mount -a.
49 # This does not imply the initrd should already mount it.
51 sub isRequiredAtBoot {
53 return 0 if ($self->type eq "ignore");
54 return 0 if ($self->opts->exists("noauto"));
60 # blockDevPath -- return blockdev pathname for an fstab entry.
61 # must resolve LABEL= and UUID=. Note that LVM and raid devices
62 # may be implemented on top of multiple other devices; this returns
63 # only the top device.
65 # Returns undef if first field of fstab entry does not point to
66 # an existing block device. Possible reasons:
67 # - filesystem does not have underlying device, such as /proc.
68 # - filesystem has a non-file underlying resource, such as NFS
69 # - garbage line with missing blockdev
70 # - filesystem has a plain file as underlying resource;
71 # this can be a loopback file system, or swap to plain file.
73 # NOTE: We should support the last case, but for now that's too difficult:
74 # imagine /a/b/c, where /a is reiserfs, b is a symlink to /d (an NFS
75 # filesystem), and /d/c is a symlink to /e/f, where /e is a ramdisk.)
79 my $dev = $self->dev();
81 if (-f $dev && $self->opts->exists('loop')) {
84 if (-f $dev && $self->type eq "swap") {
91 elsif ($dev =~ /^LABEL=(.*)/) {
92 return LabeledPartitionTab::findPathByLabel ($1);
94 elsif ($dev =~ /^UUID=(.*)/) {
95 return LabeledPartitionTab::findPathByUuid ($1);