2 # Update, add or delete a filesystem
4 require './zones-lib.pl';
7 $zinfo = &get_zone($in{'zone'});
8 $zinfo || &error($text{'edit_egone'});
10 # Find the filesystem object
11 ($fs) = grep { $_->{'dir'} eq $in{'old'} } @{$zinfo->{'fs'}};
12 $fs || &error($text{'fs_egone'});
13 $mount = &get_active_mount($zinfo, $fs);
16 $fs = { 'keytype' => 'fs',
17 'type' => $in{'type'} };
21 # Just remove this filesystem
22 &delete_zone_object($zinfo, $fs);
24 # Attempt to un-mount it (if mounted)
26 &error_setup($text{'fs_err3'});
27 &mount::unmount_dir(@$mount);
32 $form = &get_fs_form(\%in, $zinfo, $fs, $fs->{'type'});
33 $form->validate_redirect("edit_fs.cgi");
34 $fs->{'dir'} = $form->get_value("dir");
35 if (&indexof($fs->{'type'}, &mount::list_fstypes()) >= 0) {
36 # Parse friendly filesystem forms
37 $fs->{'special'} = &mount::check_location($fs->{'type'});
38 &mount::check_options($fs->{'type'});
39 $fs->{'options'} = &mount::join_options($fs->{'type'});
42 # Just use user-entered device and options
43 $fs->{'special'} = $form->get_value("special");
44 $fs->{'options'} = $form->get_value("options");
46 if ($fs->{'special'} =~ /^\/dev\/dsk\/(.*)$/) {
47 $fs->{'raw'} = "/dev/rdsk/$1";
49 &find_clash($zinfo, $fs) &&
50 $form->validate_redirect("edit_fs.cgi",
51 [ [ "dir", $text{'fs_eclash'} ] ]);
53 # Save the filesystem settings
54 $mp = &get_zone_root($zinfo).$fs->{'dir'};
56 &create_zone_object($zinfo, $fs);
60 &error_setup($text{'fs_err2'});
61 &system_logged("mkdir -p ".quotemeta($mp));
62 &mount::mount_dir($mp,
69 &modify_zone_object($zinfo, $fs);
71 # Attempt to re-mount it
73 &error_setup($text{'fs_err4'});
74 &mount::unmount_dir(@$mount);
75 if ($fs->{'dir'} ne $in{'old'}) {
76 &system_logged("mkdir -p ".quotemeta($mp));
78 print STDERR "mounting $fs->{'special'} on $mp with type $fs->{'type'} and options $fs->{'options'}\n";
79 &mount::mount_dir($mp,
87 &webmin_log($in{'new'} ? "create" : $in{'delete'} ? "delete" : "modify",
88 "fs", $in{'old'} || $fs->{'dir'}, $fs);
89 &redirect("edit_zone.cgi?zone=$in{'zone'}");