2 # Functions for reading and editing the SGI NFS exports file
4 BEGIN { push(@INC, ".."); };
9 # Parses the exports file into a list of structures, one per export
14 open(EXPORTS, $config{'exports_file'});
20 local $nl = <EXPORTS>;
26 local @w = split(/\s+/, $_);
28 local $exp = { 'dir' => shift(@w),
32 'index' => scalar(@rv) };
35 local $opts = shift(@w);
38 foreach $o (split(/,/, $opts)) {
39 if ($o =~ /^([^=]+)=(\S*)$/) {
40 $exp->{'opts'}->{$1} = $2;
43 $exp->{'opts'}->{$o} = "";
47 $exp->{'hosts'} = \@w;
56 # create_export(&export)
59 open(EXPORTS, ">>$config{'exports_file'}");
60 print EXPORTS &export_line($_[0]),"\n";
64 # modify_export(&export)
67 local $lref = &read_file_lines($config{'exports_file'});
68 splice(@$lref, $_[0]->{'line'}, $_[0]->{'eline'} - $_[0]->{'line'} + 1,
73 # delete_export(&export)
76 local $lref = &read_file_lines($config{'exports_file'});
77 splice(@$lref, $_[0]->{'line'}, $_[0]->{'eline'} - $_[0]->{'line'} + 1);
83 local @w = ( $_[0]->{'dir'} );
85 foreach $o (keys %{$_[0]->{'opts'}}) {
86 if ($_[0]->{'opts'}->{$o} eq "") {
90 push(@o, $o."=".$_[0]->{'opts'}->{$o});
93 push(@w, "-".join(",", @o)) if (@o);
94 push(@w, @{$_[0]->{'hosts'}});