Commit 68190010 authored by Mike Hibler's avatar Mike Hibler
Browse files

Further hackary (actually less hacky) to get working in GEOM world.

parent 9140cebc
#!/usr/bin/perl -w #!/usr/bin/perl -w
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2000-2010 University of Utah and the Flux Group. # Copyright (c) 2000-2011 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
use English; use English;
...@@ -67,13 +67,12 @@ $ENV{'PATH'} = "/tmp:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:". ...@@ -67,13 +67,12 @@ $ENV{'PATH'} = "/tmp:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:".
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
# #
# Determine if we need the magic to enable writing the active disk. # Determine if we should use the "geom" tools to make everything happen.
# Empirically, this seems to only be needed for FreeBSD 8 and above. # Empirically, this seems to only be needed for FreeBSD 8 and above.
# #
my $needsysctl = 0; my $usegeom = 0;
my $didsysctl = 0;
if (`uname -r` =~ /^(\d+)\./ && $1 > 7) { if (`uname -r` =~ /^(\d+)\./ && $1 > 7) {
$needsysctl = $1; $usegeom = $1;
} }
# #
...@@ -244,9 +243,12 @@ if (!$forceit) { ...@@ -244,9 +243,12 @@ if (!$forceit) {
# #
# Dark magic to allow us to modify the open boot disk # Dark magic to allow us to modify the open boot disk
# #
if ($needsysctl) { if ($usegeom && $slice != 0) {
mysystem("sysctl kern.geom.debugflags=16"); if ($stype != 0) {
$didsysctl = 1; mysystem("gpart delete -i $slice $disk");
}
mysystem("gpart add -i $slice -t freebsd $disk");
$stype = 165;
} }
# #
...@@ -269,20 +271,11 @@ elsif ($stype != 165) { ...@@ -269,20 +271,11 @@ elsif ($stype != 165) {
# If not recreating the filesystems, just try to mount it # If not recreating the filesystems, just try to mount it
# #
elsif ($noinit) { elsif ($noinit) {
if ($didsysctl) {
system("sysctl kern.geom.debugflags=0");
$didsysctl = 0;
}
mysystem("mount $fsdevice $mountpoint"); mysystem("mount $fsdevice $mountpoint");
mysystem("echo \"$fsdevice $mountpoint ufs rw 0 2\" >> /etc/fstab"); mysystem("echo \"$fsdevice $mountpoint ufs rw 0 2\" >> /etc/fstab");
exit(0); exit(0);
} }
if ($didsysctl) {
system("sysctl kern.geom.debugflags=0");
$didsysctl = 0;
}
# #
# Now create the disklabel # Now create the disklabel
# #
...@@ -380,8 +373,6 @@ sub mysystem($) ...@@ -380,8 +373,6 @@ sub mysystem($)
print "'$command'\n"; print "'$command'\n";
my $rv = system($command); my $rv = system($command);
if ($rv) { if ($rv) {
system("sysctl kern.geom.debugflags=0")
if ($didsysctl);
die("*** $0:\n". die("*** $0:\n".
" Failed ($rv): '$command'\n"); " Failed ($rv): '$command'\n");
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment