Commit 3c53a3f1 authored by Ryan Jackson's avatar Ryan Jackson

Added initial (but untested) port of rc.cdboot to linux.

Added a few more OS support functions to liblocsetup.
Modified ifcfg-eth99 to behave on FC9.
parent b21ec0e4
......@@ -63,6 +63,7 @@ $SFSSD = "/usr/local/sbin/sfssd";
$SFSCD = "/usr/local/sbin/sfscd";
$RPMCMD = "/usr/local/bin/rpm";
$HOSTSFILE = "/etc/hosts";
$WGET = "/usr/local/bin/wget";
#
# These are not exported
......@@ -890,4 +891,80 @@ sub os_config_gre($$$$$$$)
return 0;
}
sub os_get_disks
{
my @disks;
my $dmesgpat = "^([a-z]+\\d+):.* (\\d+)MB.*\$";
for my $cmd ("/sbin/dmesg", "cat /var/run/dmesg.boot") {
my @cmdout = `$cmd`;
foreach my $line (@cmdout) {
if ($line =~ /$dmesgpat/) {
my $name = $1;
push @disks, $name;
}
}
last if (@disks);
}
return @disks;
}
sub os_get_disk_size($)
{
my ($disk) = @_;
my $size;
$disk =~ s#^/dev/##;
my @cmdout = `$cmd`;
my $dmesgpat = "^($disk\\d+):.* (\\d+)MB.*\$";
foreach my $line (@cmdout) {
if ($line =~ /$dmesgpat/) {
my $size = $2;
last;
}
}
return $size;
}
sub os_get_partition_info($$)
{
my ($bootdev, $partition) = @_;
if (!open(FDISK, "fdisk -s $bootdev |")) {
print("Failed to run fdisk on $bootdev!");
return -1;
}
# First line looks like "/dev/ad0: 5005 cyl 255 hd 63 sec"
my $line = <FDISK>;
if (!defined($line)) {
print("No fdisk summary info for MBR on $bootdev!\n");
goto bad;
}
if (! ($line =~ /^.*cyl (\d*) hd (\d*) sec/)) {
print("Invalid fdisk summary info for MBR on $bootdev!\n");
goto bad;
}
while (<FDISK>) {
if ($_ =~ /^\s*(\d):\s*\d*\s*(\d*)\s*(0x[\w]*)\s*0x[\w]*$/) {
if ($1 == $partition) {
my $plen = $2;
my $ptype = hex($3);
close(FDISK);
return ($plen, $ptype);
}
}
}
print("No such partition in fdisk summary info for MBR on $bootdev!\n");
bad:
close(FDISK);
return -1;
}
1;
......@@ -65,24 +65,26 @@ mfs-install: destdircheck common-install etc-install \
frisbee-mfs-install: destdircheck
$(INSTALL) -m 644 $(SRCDIR)/frisbee/rc.local $(SYSETCDIR)/rc.local
$(INSTALL) -m 755 $(SRCDIR)/dhclient-exit-hooks \
$(SYSETCDIR)/dhclient-exit-hooks
$(INSTALL) -m 755 $(SRCDIR)/dhclient-enter-hooks \
$(SYSETCDIR)/dhclient-enter-hooks
@if [ -r $(SRCDIR)/master.passwd ]; then \
$(INSTALL) -m 600 $(SRCDIR)/master.passwd $(SYSETCDIR); \
pwd_mkdb -d $(SYSETCDIR) $(SYSETCDIR)/master.passwd; \
if [ ! -e $(DESTDIR)/bin/csh ]; then \
ln $(DESTDIR)/bin/sh $(DESTDIR)/bin/csh; \
fi \
fi
@if [ -r $(SRCDIR)/group ]; then \
$(INSTALL) -m 644 $(SRCDIR)/group $(SYSETCDIR); \
fi
#$(INSTALL) -m 755 $(SRCDIR)/dhclient-exit-hooks \
# $(SYSETCDIR)/dhclient-exit-hooks
#$(INSTALL) -m 755 $(SRCDIR)/dhclient-enter-hooks \
# $(SYSETCDIR)/dhclient-enter-hooks
#@if [ -r $(SRCDIR)/master.passwd ]; then \
# $(INSTALL) -m 600 $(SRCDIR)/master.passwd $(SYSETCDIR); \
# pwd_mkdb -d $(SYSETCDIR) $(SYSETCDIR)/master.passwd; \
# if [ ! -e $(DESTDIR)/bin/csh ]; then \
# ln $(DESTDIR)/bin/sh $(DESTDIR)/bin/csh; \
# fi \
#fi
#@if [ -r $(SRCDIR)/group ]; then \
# $(INSTALL) -m 644 $(SRCDIR)/group $(SYSETCDIR); \
#fi
$(INSTALL) -m 755 $(SRCDIR)/control_interface $(SYSETCDIR)/testbed
$(INSTALL) -m 755 $(SRCDIR)/rc.frisbee $(SYSETCDIR)/testbed
$(INSTALL) -m 755 $(SRCDIR)/rc.ipod $(SYSETCDIR)/testbed
$(INSTALL) -m 755 $(SRCDIR)/slicefix $(SYSETCDIR)/testbed
$(INSTALL) -m 755 $(SRCDIR)/freebsd_to_linux_disk $(SYSETCDIR)/testbed
$(INSTALL) -m 755 $(SRCDIR)/check_disklabel $(SYSETCDIR)/testbed
$(INSTALL) -m 755 -s ../tmcc-nossl $(SYSETCDIR)/testbed/tmcc
$(INSTALL) -m 755 -s ../findif $(SYSETCDIR)/testbed
rm -f $(BINDIR)/rc/rc.mkelab
......@@ -182,6 +184,12 @@ script-install: dir-install $(SCRIPTS)
$(INSTALL) -m 755 $(SRCDIR)/chipset.awk $(BINDIR)/chipset.awk
$(INSTALL) -m 755 $(SRCDIR)/cpuspeed.awk $(BINDIR)/cpuspeed.awk
$(INSTALL) -m 755 $(SRCDIR)/rc.mfs $(BINDIR)/rc/rc.mfs
$(INSTALL) -m 755 $(SRCDIR)/control_interface $(SYSETCDIR)/testbed
$(INSTALL) -m 755 $(SRCDIR)/rc.frisbee $(BINDIR)/rc/rc.frisbee
$(INSTALL) -m 755 $(SRCDIR)/slicefix $(BINDIR)/slicefix
$(INSTALL) -m 755 $(SRCDIR)/freebsd_to_linux_disk $(BINDIR)/freebsd_to_linux_disk
$(INSTALL) -m 755 $(SRCDIR)/check_disklabel $(BINDIR)/check_disklabel
$(INSTALL) -m 755 -s ../findif $(BINDIR)/findif
sfs-install:
$(INSTALL) -m 755 -o root -g root -d $(DESTDIR)/etc/sfs
......
This diff is collapsed.
......@@ -26,6 +26,8 @@ IFACETYPES="3c59x eepro100 e1000 r8169 tulip"
#
modprobe -qa $IFACETYPES
interfaces=`ifconfig -a -s | sed '1d;/^lo /d;s/ .*$//'`
#
# If dhclient returns success, then it has configured the first interface
# and gone into background mode. At that point we don't care about it any
......@@ -33,7 +35,7 @@ modprobe -qa $IFACETYPES
# dhclient will leave "up") and set ONBOOT=no to prevent ifup (our caller)
# from doing any further configuration on this fake interface.
#
if [ -x /sbin/dhclient ] && /sbin/dhclient -q ; then
if [ -x /sbin/dhclient ] && /sbin/dhclient -q $interfaces; then
killall dhclient
if [ -e $BOOTDIR/controlif ]; then
......
......@@ -62,6 +62,7 @@ $SFSSD = "/usr/local/sbin/sfssd";
$SFSCD = "/usr/local/sbin/sfscd";
$RPMCMD = "/bin/rpm";
$HOSTSFILE = "/etc/hosts";
$WGET = "/usr/bin/wget";
#
# These are not exported
......@@ -1554,4 +1555,63 @@ sub os_config_gre($$$$$$$)
return 0;
}
sub os_get_disks
{
my @blockdevs;
@blockdevs = map { s#/sys/block/## } glob('/sys/block/*');
return @blockdevs;
}
sub os_get_disk_size($)
{
my $disk = (@_);
my $size;
$disk =~ s#^/dev/##;
if (!open SIZE, "/sys/block/$disk/size") {
warn "Couldn't open /sys/block/$disk/size: $!\n";
return undef;
}
$size = <SIZE>;
close SIZE;
chomp $size;
$size = $size * 512 / 1024 / 1024;
return $size;
}
sub os_get_partition_info($$)
{
my ($bootdev, $partition) = @_;
if (!open(FDISK, "fdisk -l /dev/$bootdev |")) {
print("Failed to run fdisk on /dev/$bootdev!");
return -1;
}
while (<FDISK>) {
next if (!m#^/dev/$bootdev$partition\s+#);
s/\*//;
my ($length, $ptype) = (split /\s+/)[3,4];
$length =~ s/\+$//;
$ptype = hex($ptype);
close FDISK;
return ($length, $ptype);
}
print "No such partition in fdisk summary info for MBR on /dev/$bootdev!\n";
close FDISK;
return -1;
}
1;
Markdown is supported
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