Reset mounts?

Wesley Shields wxs at atarininja.org
Thu Apr 26 12:23:19 EDT 2007


On Thu, Apr 26, 2007 at 12:20:21PM -0400, Wesley Shields wrote:
> Earlier this week I was using tc to set mounts for various jails and
> ports trees.  I then tried to remove those mounts using tc and was
> unable to do so.  I came up with the following patch which adds a -r
> argument to setSrcMount and setPortsMount which will reset the mount.
> 
> Is doing this a good idea, or was there some other way?  Trying 'tc
> setPortsMount -p FreeBSD-Ports -m ""' didn't work.
> 
> This is my first time really looking at the underlying code so please be
> nice.  :)
> 
> -- WXS

The patch was apparently stripped.  I've put it below.  Sorry for that.

-- WXS

--- tc.orig	Tue Apr 24 17:19:49 2007
+++ tc	Thu Apr 26 09:40:45 2007
@@ -264,14 +264,14 @@
         "setSrcMount" => {
                 func   => \&setSrcMount,
                 help   => "Set the src mount source for the given jail",
-                usage  => "-j <jail name> -m <mountsource>",
-                optstr => 'j:m:',
+                usage  => "-j <jail name> -m <mountsource> -r",
+                optstr => 'j:m:r',
         },
         "setPortsMount" => {
                 func   => \&setPortsMount,
                 help   => "Set the ports mount source for the given portstree",
-                usage  => "-p <portstree name> -m <mountsource>",
-                optstr => 'p:m:',
+                usage  => "-p <portstree name> -m <mountsource> -r",
+                optstr => 'p:m:r',
         },
         "rmHost" => {
                 func   => \&rmHost,
@@ -1597,7 +1597,7 @@
 }
 
 sub setSrcMount {
-        if (!$opts->{'j'} || !$opts->{'m'}) {
+        if (!$opts->{'j'} && (!$opts->{'m'} || !$opts->{'r'})) {
                 usage("setSrcMount");
         }
 
@@ -1609,7 +1609,12 @@
 
         my $jail = $ds->getJailByName($jail_name);
 
-        $jail->setSrcMount($opts->{'m'});
+        if ($opts->{'r'}) {
+                $jail->setSrcMount("");
+        }
+        else {
+                $jail->setSrcMount($opts->{'m'});
+        }
 
         my $rc = $ds->updateJail($jail);
 
@@ -1623,7 +1628,7 @@
 }
 
 sub setPortsMount {
-        if (!$opts->{'p'} || !$opts->{'m'}) {
+        if (!$opts->{'p'} && (!$opts->{'m'} || !$opts->{'r'})) {
                 usage("setPortsMount");
         }
 
@@ -1635,7 +1640,12 @@
 
         my $portstree = $ds->getPortsTreeByName($portstree_name);
 
-        $portstree->setPortsMount($opts->{'m'});
+        if ($opts->{'r'}) {
+                $portstree->setPortsMount("");
+        }
+        else  {
+                $portstree->setPortsMount($opts->{'m'});
+        }
 
         my $rc = $ds->updatePortsTree($portstree);
 


More information about the tinderbox-list mailing list