3 # FsOpts -- encapsulate the options in an FsEntry
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
30 $self->takeArgs ('string');
31 my @optlist = split (/,/, $self->{string});
33 for my $opt (@optlist) {
34 if ($opt =~ /^(.*)=(.*)$/) {
38 $opthash->{$opt} = undef;
41 $self->{optsHash} = $opthash;
45 # exists -- the option occurs, possibly with undef value.
48 my ($self, $optnam) = @_;
49 return exists ($self->{optsHash}{$optnam});
53 my ($self, $optnam) = @_;
54 return $self->{optsHash}{$optnam};
59 my $opts = $self->{optsHash};
61 for my $key (sort keys %{$opts}) {
62 push @optlist, ("$key=" . ($opts->{$key} or "-"));
64 return join (',', @optlist);
69 # cmdLineVersion -- return a version of all options suitable for
70 # a mount command line.
71 # Note that some options in fstab can only be used in fstab,
76 my $opts = $self->{optsHash};
79 for my $key (sort keys %{$opts}) {
80 next if $key eq 'auto';
81 next if $key eq 'noauto';
82 next if $key eq 'nouser';
83 next if $key eq 'owner';
84 next if $key eq 'user';
85 next if $key eq 'users';
86 next if $key eq 'defaults';
87 my $val = $opts->{$key};
89 push @cmdLine, "$key=$val";
92 push @cmdLine, "$key";
95 if ($#cmdLine == -1) {
99 # protect against logdev=John's disk.
100 my $cmdLine = join (',', @cmdLine);
101 $cmdLine =~ s/(['\\])/\\$1/g;
102 return "-o '$cmdLine'";