summaryrefslogtreecommitdiffstats
path: root/loader2
diff options
context:
space:
mode:
authorJeremy Katz <katzj@redhat.com>2003-04-24 15:46:31 +0000
committerJeremy Katz <katzj@redhat.com>2003-04-24 15:46:31 +0000
commit0a562126d84c59a113231ae7ab38984f92d62153 (patch)
tree5e87b9094f4ebdc328979e3a0640dee5f1fc40cb /loader2
parentdd200d781bd9012f562399c2ee69c23fe60d86b9 (diff)
downloadanaconda-0a562126d84c59a113231ae7ab38984f92d62153.tar.gz
anaconda-0a562126d84c59a113231ae7ab38984f92d62153.tar.xz
anaconda-0a562126d84c59a113231ae7ab38984f92d62153.zip
another taroon merge. tagged before as before-taroon-merge, after as
after-taroon-merge this one adds s390 fixes, basic i/p series platform support, support for multiple kernels and one second stage, cmdline kickstart mode (nice for s390), some warning cleanups.
Diffstat (limited to 'loader2')
-rw-r--r--loader2/.cvsignore1
-rw-r--r--loader2/Makefile21
-rw-r--r--loader2/devt.h32
-rw-r--r--loader2/driverdisk.c1
-rw-r--r--loader2/driverdisk.h1
-rw-r--r--loader2/hardware.c15
-rw-r--r--loader2/hdinstall.c11
-rw-r--r--loader2/init.c248
-rw-r--r--loader2/kickstart.c9
-rw-r--r--loader2/kickstart.h3
-rw-r--r--loader2/linuxrc.s390187
-rw-r--r--loader2/loader.c52
-rw-r--r--loader2/loader.h8
-rw-r--r--loader2/loadermisc.h2
-rw-r--r--loader2/log.h2
-rw-r--r--loader2/method.c24
-rw-r--r--loader2/module-info24
-rw-r--r--loader2/modules.c4
-rw-r--r--loader2/net.c74
-rw-r--r--loader2/nfsinstall.c5
-rw-r--r--loader2/shutdown.c108
-rw-r--r--loader2/undomounts.c228
-rw-r--r--loader2/urlinstall.c5
-rw-r--r--loader2/usb.c1
24 files changed, 606 insertions, 460 deletions
diff --git a/loader2/.cvsignore b/loader2/.cvsignore
index 217ec702a..b3b2b52cf 100644
--- a/loader2/.cvsignore
+++ b/loader2/.cvsignore
@@ -7,3 +7,4 @@ loader.tr
.depend
font.bgf.gz
loader.po
+shutdown
diff --git a/loader2/Makefile b/loader2/Makefile
index 778db6adf..ad2a10d8e 100644
--- a/loader2/Makefile
+++ b/loader2/Makefile
@@ -14,7 +14,7 @@ ISYSLIB = ../isys/libisys.a
GUNZIP = -lz
MODULELINKAGE :=-lmodutils -lmodutilutil -lmodutilobj
-BINS = init loader
+BINS = loader
HWOBJS = pcmcia.o usb.o firewire.o hardware.o
METHOBJS = method.o cdinstall.o hdinstall.o nfsinstall.o urlinstall.o
@@ -51,8 +51,12 @@ else
OBJS += wcstubs.o
endif
+# linuxrc + shutdown on s390, init everywhere else
ifneq (,$(filter s390 s390x,$(ARCH)))
-BINS += linuxrc.s390
+BINS += linuxrc.s390 shutdown
+SHUTDOWNOPTS = -DAS_SHUTDOWN=1
+else
+BINS += init
endif
# translation stuff
@@ -83,12 +87,21 @@ loader.po: $(wildcard *.c)
linuxrc.s390:
@echo "Nothing to do for $@"
-init: init.o
- $(CC) $(STATIC) $(COPTS) $(LDFLAGS) -o $@ init.o
+init: init.o undomounts.o shutdown.o
+ $(CC) $(STATIC) $(COPTS) $(LDFLAGS) -o $@ $^
+
+shutdown: shutdown.o undomounts.o
+ $(CC) $(STATIC) $(COPTS) $(SHUTDOWNOPTS) $(LDFLAGS) -o $@ $^
init.o: init.c
$(CC) $(COPTS) -c -o init.o init.c
+undomounts.o: undomounts.c
+ $(CC) $(COPTS) -c -o undomounts.o undomounts.c
+
+shutdown.o: shutdown.c
+ $(CC) $(COPTS) $(SHUTDOWNOPTS) -c -o shutdown.o shutdown.c
+
mkctype: mkctype.c
$(REALCC) $(COPTS) -o mkctype mkctype.c
diff --git a/loader2/devt.h b/loader2/devt.h
new file mode 100644
index 000000000..03dc4c472
--- /dev/null
+++ b/loader2/devt.h
@@ -0,0 +1,32 @@
+/*
+ * devt.h: handle declaration of dev_t to be sane for loopback purposes
+ *
+ * Copyright 1996 - 2003 Red Hat, Inc.
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef DEVT_H
+#define DEVT_H
+
+/* Need to tell loop.h what the actual dev_t type is. */
+#undef dev_t
+#if defined(__alpha) || (defined(__sparc__) && defined(__arch64__))
+#define dev_t unsigned int
+#else
+#if defined(__x86_64__)
+#define dev_t unsigned long
+#else
+#define dev_t unsigned short
+#endif
+#endif
+#include <linux/loop.h>
+#undef dev_t
+#define dev_t dev_t
+
+#endif
diff --git a/loader2/driverdisk.c b/loader2/driverdisk.c
index 950dd0c50..8b2442be5 100644
--- a/loader2/driverdisk.c
+++ b/loader2/driverdisk.c
@@ -32,6 +32,7 @@
#include "moduleinfo.h"
#include "windows.h"
#include "hardware.h"
+#include "driverdisk.h"
#include "../isys/isys.h"
#include "../isys/imount.h"
diff --git a/loader2/driverdisk.h b/loader2/driverdisk.h
index 1e81d9d9e..58d6d72bc 100644
--- a/loader2/driverdisk.h
+++ b/loader2/driverdisk.h
@@ -1,6 +1,7 @@
#ifndef DRIVERDISK_H
#define DRIVERDISK_H
+#include "loader.h"
#include "modules.h"
#include "moduledeps.h"
#include "moduleinfo.h"
diff --git a/loader2/hardware.c b/loader2/hardware.c
index 14ad47525..509fd4cb5 100644
--- a/loader2/hardware.c
+++ b/loader2/hardware.c
@@ -204,6 +204,18 @@ void updateKnownDevices(struct knownDevices * kd) {
kdFindNetList(kd, 0);
}
+int probeiSeries(moduleInfoSet modInfo, moduleList modLoaded,
+ moduleDeps modDeps, struct knownDevices * kd, int flags) {
+ /* this is a hack since we can't really probe on iSeries */
+#ifdef __powerpc__
+ if (!access("/proc/iSeries", X_OK)) {
+ mlLoadModuleSet("veth:viodasd:viocd", modLoaded, modDeps, modInfo, flags);
+ updateKnownDevices(kd);
+ }
+#endif
+ return 0;
+}
+
int busProbe(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps modDeps,
int justProbe, struct knownDevices * kd, int flags) {
int i;
@@ -215,6 +227,9 @@ int busProbe(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps modDeps,
initializePcmciaController(modLoaded, modDeps, modInfo, flags);
if (FL_NOPROBE(flags)) return 0;
+
+ /* we can't really *probe* on iSeries, but we can pretend */
+ probeiSeries(modInfo, modLoaded, modDeps, kd, flags);
if (canProbeDevices()) {
/* autodetect whatever we can */
diff --git a/loader2/hdinstall.c b/loader2/hdinstall.c
index fc05f21ba..54ccec89f 100644
--- a/loader2/hdinstall.c
+++ b/loader2/hdinstall.c
@@ -199,6 +199,17 @@ static int loadHDImages(char * prefix, char * dir, int flags,
return 1;
}
+ if (!verifyStamp(mntpoint)) {
+ char * buf;
+ buf = sdupprintf(_("The %s installation tree in that directory does "
+ "not seem to match your boot media."),
+ getProductName());
+
+ newtWinMessage(_("Error"), _("OK"), buf);
+ umountLoopback(mntpoint, device);
+ return 1;
+ }
+
/* handle updates.img now before we copy stage2 over... this allows
* us to keep our ramdisk size as small as possible */
sprintf(path, "%s/%s/RedHat/base/updates.img", prefix, dir ? dir : "");
diff --git a/loader2/init.c b/loader2/init.c
index 9a33cd326..a5341f7fb 100644
--- a/loader2/init.c
+++ b/loader2/init.c
@@ -5,7 +5,7 @@
*
* Erik Troan (ewt@redhat.com)
*
- * Copyright 1996 - 2002 Red Hat Software
+ * Copyright 1996 - 2003 Red Hat, Inc.
*
* This software may be freely redistributed under the terms of the GNU
* public license.
@@ -46,27 +46,11 @@
#include <sys/reboot.h>
#include <termios.h>
-/* Need to tell loop.h what the actual dev_t type is. */
-#undef dev_t
-#if defined(__alpha) || (defined(__sparc__) && defined(__arch64__))
-#define dev_t unsigned int
-#else
-#define dev_t unsigned short
-#endif
-#include <linux/loop.h>
-#undef dev_t
-#define dev_t dev_t
+#include "devt.h"
#define syslog klogctl
#endif
-struct unmountInfo {
- char * name;
- int mounted;
- int loopDevice;
- enum { FS, LOOP } what;
-} ;
-
#include <linux/cdrom.h>
#ifndef MS_REMOUNT
@@ -111,6 +95,8 @@ char * env[] = {
*/
int testing=0;
+void unmountFilesystems(void);
+void disableSwap(void);
int mystrstr(char *str1, char *str2) {
char *p;
@@ -134,7 +120,7 @@ int mystrstr(char *str1, char *str2) {
return rc;
}
-void printstr(char * string) {
+static void printstr(char * string) {
write(1, string, strlen(string));
}
@@ -364,190 +350,6 @@ int setupTerminal(int fd) {
return 0;
}
-void undoLoop(struct unmountInfo * fs, int numFs, int this);
-
-void undoMount(struct unmountInfo * fs, int numFs, int this) {
- int len = strlen(fs[this].name);
- int i;
-
- if (!fs[this].mounted) return;
- fs[this].mounted = 0;
-
- /* unmount everything underneath this */
- for (i = 0; i < numFs; i++) {
- if (fs[i].name && (strlen(fs[i].name) >= len) &&
- (fs[i].name[len] == '/') &&
- !strncmp(fs[this].name, fs[i].name, len)) {
- if (fs[i].what == LOOP)
- undoLoop(fs, numFs, i);
- else
- undoMount(fs, numFs, i);
- }
- }
-
- printf("\t%s", fs[this].name);
- /* don't need to unmount /tmp. it is busy anyway. */
- if (!testing) {
- if (umount2(fs[this].name, 0) < 0) {
- printf(" umount failed (%d)", errno);
- } else {
- printf(" done");
- }
- }
- printf("\n");
-}
-
-void undoLoop(struct unmountInfo * fs, int numFs, int this) {
- int i;
- int fd;
-
- if (!fs[this].mounted) return;
- fs[this].mounted = 0;
-
- /* find the device mount */
- for (i = 0; i < numFs; i++) {
- if (fs[i].what == FS && (fs[i].loopDevice == fs[this].loopDevice))
- break;
- }
-
- if (i < numFs) {
- /* the device is mounted, unmount it (and recursively, anything
- * underneath) */
- undoMount(fs, numFs, i);
- }
-
- unlink("/tmp/loop");
- mknod("/tmp/loop", 0600 | S_IFBLK, (7 << 8) | fs[this].loopDevice);
- printf("\tdisabling /dev/loop%d", fs[this].loopDevice);
- if ((fd = open("/tmp/loop", O_RDONLY, 0)) < 0) {
- printf(" failed to open device: %d", errno);
- } else {
- if (!testing && ioctl(fd, LOOP_CLR_FD, 0))
- printf(" LOOP_CLR_FD failed: %d", errno);
- close(fd);
- }
-
- printf("\n");
-}
-
-void unmountFilesystems(void) {
- int fd, size;
- char buf[65535]; /* this should be big enough */
- char * chptr, * start;
- struct unmountInfo filesystems[500];
- int numFilesystems = 0;
- int i;
- struct loop_info li;
- char * device;
- struct stat sb;
-
- fd = open("/proc/mounts", O_RDONLY, 0);
- if (fd < 1) {
- /* FIXME: was perror */
- printstr("failed to open /proc/mounts");
- sleep(2);
- return;
- }
-
- size = read(fd, buf, sizeof(buf) - 1);
- buf[size] = '\0';
-
- close(fd);
-
- chptr = buf;
- while (*chptr) {
- device = chptr;
- while (*chptr != ' ') chptr++;
- *chptr++ = '\0';
- start = chptr;
- while (*chptr != ' ') chptr++;
- *chptr++ = '\0';
-
- if (strcmp(start, "/") && strcmp(start, "/tmp")) {
- filesystems[numFilesystems].name = strdup(start);
- filesystems[numFilesystems].what = FS;
- filesystems[numFilesystems].mounted = 1;
-
- stat(start, &sb);
- if ((sb.st_dev >> 8) == 7) {
- filesystems[numFilesystems].loopDevice = sb.st_dev & 0xf;
- } else {
- filesystems[numFilesystems].loopDevice = -1;
- }
-
- numFilesystems++;
- }
-
- while (*chptr != '\n') chptr++;
- chptr++;
- }
-
- for (i = 0; i < 7; i++) {
- unlink("/tmp/loop");
- mknod("/tmp/loop", 0600 | S_IFBLK, (7 << 8) | i);
- if ((fd = open("/tmp/loop", O_RDONLY, 0)) >= 0) {
- if (!ioctl(fd, LOOP_GET_STATUS, &li) && li.lo_name[0]) {
- filesystems[numFilesystems].name = strdup(li.lo_name);
- filesystems[numFilesystems].what = LOOP;
- filesystems[numFilesystems].mounted = 1;
- filesystems[numFilesystems].loopDevice = i;
- numFilesystems++;
- }
-
- close(fd);
- }
- }
-
- for (i = 0; i < numFilesystems; i++) {
- if (filesystems[i].what == LOOP) {
- undoLoop(filesystems, numFilesystems, i);
- }
- }
-
- for (i = 0; i < numFilesystems; i++) {
- if ((filesystems[i].mounted) && (filesystems[i].name)) {
- undoMount(filesystems, numFilesystems, i);
- }
- }
-
- for (i = 0; i < numFilesystems; i++)
- free(filesystems[i].name);
-}
-
-void disableSwap(void) {
- int fd;
- char buf[4096];
- int i;
- char * start;
- char * chptr;
-
- if ((fd = open("/proc/swaps", O_RDONLY, 0)) < 0) return;
-
- i = read(fd, buf, sizeof(buf) - 1);
- close(fd);
- if (i < 0) return;
- buf[i] = '\0';
-
- start = buf;
- while (*start) {
- while (*start != '\n' && *start) start++;
- if (!*start) return;
-
- start++;
- if (*start != '/') return;
- chptr = start;
- while (*chptr && *chptr != ' ') chptr++;
- if (!(*chptr)) return;
- *chptr = '\0';
- printf("\t%s", start);
- if (swapoff(start))
- printf(" failed (%d)", errno);
- printf("\n");
-
- start = chptr + 1;
- }
-}
-
void ejectCdrom(void) {
int ejectfd;
struct stat sb;
@@ -831,45 +633,7 @@ int main(int argc, char **argv) {
if (testing)
exit(0);
- sync(); sync();
-
- if (!testing && !noKill) {
- printf("sending termination signals...");
- kill(-1, 15);
- sleep(2);
- printf("done\n");
-
- printf("sending kill signals...");
- kill(-1, 9);
- sleep(2);
- printf("done\n");
- }
-
- printf("disabling swap...\n");
- disableSwap();
-
- printf("unmounting filesystems...\n");
- unmountFilesystems();
-
- if (doReboot) {
- printf("rebooting system\n");
- sleep(2);
-
-#if USE_MINILIBC
- reboot(0xfee1dead, 672274793, 0x1234567);
-#else
-# ifdef __alpha__
- reboot(RB_HALT_SYSTEM);
-# else
- reboot(RB_AUTOBOOT);
-# endif
-#endif
- } else {
- printf("you may safely reboot your system\n");
- while (1);
- }
-
- exit(0);
+ shutDown(noKill, doReboot);
return 0;
}
diff --git a/loader2/kickstart.c b/loader2/kickstart.c
index 34bd2cdfb..47b213d00 100644
--- a/loader2/kickstart.c
+++ b/loader2/kickstart.c
@@ -65,6 +65,8 @@ static void setTextMode(struct loaderData_s * loaderData, int argc,
char ** argv, int * flagsPtr);
static void setGraphicalMode(struct loaderData_s * loaderData, int argc,
char ** argv, int * flagsPtr);
+static void setCmdlineMode(struct loaderData_s * loaderData, int argc,
+ char ** argv, int * flagsPtr);
void loadKickstartModule(struct loaderData_s * loaderData, int argc,
char ** argv, int * flagsPtr);
@@ -80,6 +82,7 @@ struct ksCommandNames ksTable[] = {
{ KS_CMD_LANG, "lang", setKickstartLanguage },
{ KS_CMD_DD, "driverdisk", useKickstartDD },
{ KS_CMD_DEVICE, "device", loadKickstartModule },
+ { KS_CMD_CMDLINE, "cmdline", setCmdlineMode },
{ KS_CMD_NONE, NULL, NULL }
};
@@ -374,6 +377,12 @@ static void setGraphicalMode(struct loaderData_s * loaderData, int argc,
return;
}
+static void setCmdlineMode(struct loaderData_s * loaderData, int argc,
+ char ** argv, int * flagsPtr) {
+ (*flagsPtr) = (*flagsPtr) | LOADER_FLAGS_CMDLINE;
+ return;
+}
+
void setupKickstart(struct loaderData_s * loaderData, int * flagsPtr) {
struct ksCommandNames * cmd;
int argc;
diff --git a/loader2/kickstart.h b/loader2/kickstart.h
index ed0781cf2..4cfe1bc00 100644
--- a/loader2/kickstart.h
+++ b/loader2/kickstart.h
@@ -14,7 +14,8 @@
#define KS_CMD_LANG 8
#define KS_CMD_DD 9
#define KS_CMD_DEVICE 10
-#define KS_CMD_GRAPHICAL 11
+#define KS_CMD_CMDLINE 11
+#define KS_CMD_GRAPHICAL 12
int ksReadCommands(char * cmdFile, int flags);
int ksGetCommand(int cmd, char ** last, int * argc, char *** argv);
diff --git a/loader2/linuxrc.s390 b/loader2/linuxrc.s390
index 99ce5fd26..bf35849da 100644
--- a/loader2/linuxrc.s390
+++ b/loader2/linuxrc.s390
@@ -28,13 +28,6 @@ VERSION=1.01
export TEXTDOMAIN=s390installer
export TEXTDOMAINDIR=/usr/lib/locale
-debugshell()
-{
- echo $"You have defined DEBUG, so here is a shell. You can use 'exit'"
- echo $"to go on with the normal installation process."
- /bin/sh
-}
-
startinetd()
{
echo
@@ -47,11 +40,14 @@ startinetd()
/sbin/xinetd -stayalive -reuse -pidfile /tmp/xinetd.pid
/sbin/sshd
- while : ; do
- echo
- echo $"Please connect now to $IPADDR and start 'loader' from this shell."
- ls -l /bin/sh | grep -q bash && /bin/sh --login || /bin/sh -l
- done
+ if [ -z "$RUNKS" ]; then
+ while : ; do
+ echo
+ echo $"Please connect now to $IPADDR and start 'loader' from this shell."
+ /bin/sh --login
+ [ $? = 0 ] || break
+ done
+ fi
}
S390ARCH=`uname -m`
@@ -79,11 +75,17 @@ export HOME
PYTHONPATH=/tmp/updates
export PYTHONPATH
-# limit output on x3270 console
+# remount root fs rw
+mount /dev/root / -o remount,rw
+
mount -t proc none /proc
mount -t devpts /dev/pts /dev/pts
+# limit output on x3270 console
echo "1 4 1 1" > /proc/sys/kernel/printk
+# make /tmp/ramfs
+mount -t ramfs none /tmp
+
mkdir /OCO
mount -t ext2 /dev/ram /OCO >/dev/null 2>&1
# if there is no second initrd, remove mountpoint because
@@ -95,50 +97,10 @@ fi
ifconfig lo 127.0.0.1 netmask 255.0.0.0
route add -host 127.0.0.1 dev lo 2>/dev/null
-[ -n "$DEBUG" ] && debugshell
-
LO=""
[ -L /sbin/insmod ] && LO=".o"
-# read in configuration as set by the parm file
-if [ -n "$HOST" ]; then
- set -- `echo $HOST |sed 's/:/ /g'`
- HOSTNAME=$1
- DEVICE=$2
- NETTYPE=`echo $DEVICE |sed -e 's/[0-9].*//'`
- IPADDR=$3
- if [ ":$NETTYPE" = ":iucv" ]; then
- IUCV="iucv=$4"
- GATEWAY=$5
- MTU=$6
- elif [ ":$NETTYPE" = ":ctc" -o ":$NETTYPE" = ":escon" ]; then
- GATEWAY=$4
- MTU=$5
- else
- echo $4 | grep -q "\." && MTU=$4 || echo "Invalid MTU $4, skipping"
- fi
-fi
-if [ -n "$MTU" ]; then
- MMTU="mtu $MTU"
-else
- if [ "$NETTYPE" = "ctc" ]; then
- MMTU="mtu 4096"
- MTU="4096"
- IMTU="1"
- fi
-fi
-if [ -n "$NETWORK" ]; then
- set -- `echo $NETWORK | sed 's/:/ /g'`
- NETWORKIP=$1
- NETMASK=$2
- BROADCAST=$3
- if [ ":$NETTYPE" != ":ctc" -a ":$NETTYPE" != ":iucv" -a ":$NETTYPE" != ":escon" ]; then
- GATEWAY=$4
- fi
-fi
-
-
# Parse configuration
# Check for missing parameters, prompt for them if necessary
while [ -z "$HOSTNAME" ]; do
@@ -204,56 +166,58 @@ if [ ":$NETTYPE" = ":eth" ] || [ ":$NETTYPE" = ":tr" ] || [ ":$NETTYPE" = ":hsi"
echo $"Enter the broadcast address for the new Linux guest:"
read BROADCAST
done
-fi
-
-if [ ":$NETTYPE" = ":eth" ] || [ ":$NETTYPE" = ":tr" ] || [ ":$NETTYPE" = ":hsi" ]; then
- while [ -z "$GATEWAY" ]; do
- echo $"Please enter your default gateway:"
- read GATEWAY
- done
- if echo "$CHANDEV" |grep -q "lcs"; then
- LCS="on"
- fi
- # qeth and nettype!= eth is hipersockets !
- if echo "$CHANDEV" |grep -q "qeth"; then
- if echo "$NETTYPE" |grep -q "eth"; then
- QETH="on"
- elif echo "$NETTYPE" |grep -q "hsi"; then
- HSI="on"
- elif echo "$NETTYPE" |grep -q "tr"; then
- TR="on"
- fi
- fi
+ while [ -z "$GATEWAY" ]; do
+ echo $"Please enter your default gateway:"
+ read GATEWAY
+ done
+ if echo "$CHANDEV" |grep -q "lcs"; then
+ LCS="on"
+ fi
+ # qeth and nettype!= eth is hipersockets !
+ if echo "$CHANDEV" |grep -q "qeth"; then
+ if echo "$NETTYPE" |grep -q "eth"; then
+ QETH="on"
+ elif echo "$NETTYPE" |grep -q "hsi"; then
+ HSI="on"
+ elif echo "$NETTYPE" |grep -q "tr"; then
+ TR="on"
+ fi
+ fi
else # ctc0, escon0, iucv0
- while [ -z "$GATEWAY" ]; do
- echo $"Enter the IP of your ctc/escon/iucv point-to-point partner:"
- read GATEWAY
- done
- if [ "$NETTYPE" = "ctc" ]; then
- MMTU="mtu 4096"
- MTU="4096"
- IMTU="1"
- else
- echo $"Enter the maximal transfer unit (MTU) for this connection or leave empty:"
- read MTU
- if [ -n "$MTU" ]; then
- MMTU="mtu 4096"
- fi
- fi
+ while [ -z "$GATEWAY" ]; do
+ echo $"Enter the IP of your ctc/escon/iucv point-to-point partner:"
+ read GATEWAY
+ done
- if [ ":$NETTYPE" = ":iucv" ]; then
- while [ -z "$IUCV" ]; do
- echo $"Enter iucv kernel module options (usually iucv=HOST,"
- echo $"where HOST is TCPIP for VM, \$TCPIP for VIF):"
- read IUCV
- done
- fi
+ if [ "$NETTYPE" = "ctc" ]; then
+# if [ -z "$MTU" ]; then
+# echo $"Enter the maximal transfer unit (MTU) for this connection or leave empty:"
+# read MTU
+# fi
+ if [ -z "$MTU" ]; then
+ MTU="1500"
+ fi
+ MMTU="mtu 1500" # always use mtu 1500 for the installer
+ fi
+ if [ ":$NETTYPE" = ":iucv" ]; then
+ while [ -z "$IUCV" ]; do
+ echo $"Enter iucv kernel module options (usually iucv=HOST,"
+ echo $"where HOST is TCPIP for VM, \$TCPIP for VIF):"
+ read IUCV
+ done
+ fi
+fi
+# don't ask for MTU, but use it if it has been set in the .parm file
+# don't overwrite MMTU if it has been set for CTC
+if [ -n "$MTU" -a -z "$MMTU" ]; then
+ MMTU="mtu $MTU"
fi
# configure network-interface
KERNELVERSION=`cat /proc/version | awk '{ print $3 }'`
if [ ":$NETTYPE" = ":ctc" -o ":$NETTYPE" = ":escon" ]; then
- insmod ctc$LO $CTC
+ insmod fsm$LO
+ insmod ctc$LO
ifconfig $DEVICE $IPADDR $MMTU pointopoint $GATEWAY
route add -host $IPADDR dev $DEVICE 2>/dev/null
elif [ ":$NETTYPE" = ":iucv" ]; then
@@ -270,7 +234,7 @@ else # lcs, tr, qeth, hsi or older kernel without opensource-lcs
if [ "$?" = "1" ]; then
echo $"warning: no lcs module found in the first initrd, "
echo $" looking for second initrd"
- else
+ else
ifconfig $DEVICE $IPADDR $MMTU netmask $NETMASK broadcast $BROADCAST
route add -net $NETWORK netmask $NETMASK dev $DEVICE 2>/dev/null
fi
@@ -317,8 +281,6 @@ fi
ifconfig -a
route -n
-[ -n "$DEBUG" ] && debugshell
-
echo $"Starting portmap."
portmap
@@ -338,13 +300,6 @@ if [ "$?" != "0" ]; then
insmod ext3$LO
fi
-
-# Don't add MTU to the installed system's config. It was
-# set to 4096 for the installer only
-if [ "$IMTU" = "1" ]; then
- MTU=
-fi
-
# transfer options into install environment
cat > /tmp/install.cfg << EOF
LANG="$LANG"
@@ -362,23 +317,18 @@ MTU="$MTU"
NETWORK="$NETWORK"
NETMASK="$NETMASK"
BROADCAST="$BROADCAST"
-INTERACTIVE="$INTERACTIVE"
DNS="$DNS"
SEARCHDNS="$SEARCHDNS"
-FORCEDASDFORMAT="$FORCEDASDFORMAT"
LCS="$LCS"
QETH="$QETH"
HSI="$HSI"
TR="$TR"
IUCV="$IUCV"
-CTC="$CTC"
-ROOTPW="$ROOTPW"
-CROOTPW="$CROOTPW"
ONBOOT="yes"
export LANG CHANDEV QETHPARM S390ARCH TEXTDOMAIN TEXTDOMAINDIR HSI
export HOSTNAME DEVICE NETTYPE IPADDR GATEWAY MTU
export NETWORK NETMASK BROADCAST DNS SEARCHDNS
-export LCS QETH IUCV ROOTPW CROOTPW ONBOOT
+export LCS QETH IUCV ONBOOT
export TR
EOF
# immediately read it in again to export these into the shell below
@@ -406,13 +356,20 @@ PYTHONPATH=$PYTHONPATH
export LD_LIBRARY_PATH PATH HOME PYTHONPATH
EOF
-echo $DEVICE | grep ctc && echo "REMIP=$GATEWAY" >> /tmp/netinfo
-echo $DEVICE | grep ctc && echo "export REMIP=$GATEWAY" >> /etc/profile
+if [ "$NETTYPE" = "ctc" ]; then
+ echo "REMIP=$GATEWAY" >> /tmp/netinfo
+ echo "export REMIP=$GATEWAY" >> /etc/profile
+fi
-[ -n "$DEBUG" ] && debugshell
+# I'm tired of typing this out...
+echo "loader" >> /.bash_history
startinetd
+if [ -n "$RUNKS" ]; then
+ /sbin/loader
+fi
+
umount -a
umount /proc
diff --git a/loader2/loader.c b/loader2/loader.c
index 5cffc538e..3ef520a8c 100644
--- a/loader2/loader.c
+++ b/loader2/loader.c
@@ -93,15 +93,13 @@ static int newtRunning = 0;
#endif
static struct installMethod installMethods[] = {
-#if defined(INCLUDE_LOCAL)
+#if !defined(__s390__) && !defined(__s390x__)
{ N_("Local CDROM"), "cdrom", 0, CLASS_CDROM, mountCdromImage },
- { N_("Hard drive"), "hd", 0, CLASS_HD, mountHardDrive },
#endif
-#if defined(INCLUDE_NETWORK)
+ { N_("Hard drive"), "hd", 0, CLASS_HD, mountHardDrive },
{ N_("NFS image"), "nfs", 1, CLASS_NETWORK, mountNfsImage },
{ "FTP", "ftp", 1, CLASS_NETWORK, mountUrlImage },
{ "HTTP", "http", 1, CLASS_NETWORK, mountUrlImage },
-#endif
};
static int numMethods = sizeof(installMethods) / sizeof(struct installMethod);
@@ -359,7 +357,7 @@ static void checkForHardDrives(struct knownDevices * kd, int * flagsPtr) {
return;
}
-static writeVNCPasswordFile(char *pfile, char *password) {
+static void writeVNCPasswordFile(char *pfile, char *password) {
FILE *f;
f = fopen(pfile, "w+");
@@ -367,6 +365,38 @@ static writeVNCPasswordFile(char *pfile, char *password) {
fclose(f);
}
+/* read information that's passed as environmental variables */
+static void readEnvVars(int flags, struct loaderData_s ** ld) {
+ struct loaderData_s * loaderData = *ld;
+ char * env;
+
+ env = getenv("IPADDR");
+ if (env && *env) {
+ loaderData->ip = strdup(env);
+ loaderData->ipinfo_set = 1;
+ }
+ env = getenv("NETMASK");
+ if (env && *env) {
+ loaderData->netmask = strdup(env);
+ }
+ env = getenv("GATEWAY");
+ if (env && *env) {
+ loaderData->gateway = strdup(env);
+ }
+ env = getenv("DNS");
+ if (env && *env) {
+ loaderData->dns = strdup(env);
+ }
+ env = getenv("MTU");
+ if (env && *env) {
+ loaderData->mtu = atoi(env);
+ }
+ env = getenv("REMIP");
+ if (env && *env) {
+ loaderData->ptpaddr = strdup(env);
+ }
+}
+
/* parses /proc/cmdline for any arguments which are important to us.
* NOTE: in test mode, can specify a cmdline with --cmdline
*/
@@ -421,6 +451,8 @@ static int parseCmdLineFlags(int flags, struct loaderData_s * loaderData,
flags |= LOADER_FLAGS_TEXT;
else if (!strcasecmp(argv[i], "graphical"))
flags |= LOADER_FLAGS_GRAPHICAL;
+ else if (!strcasecmp(argv[i], "cmdline"))
+ flags |= LOADER_FLAGS_CMDLINE;
else if (!strcasecmp(argv[i], "updates"))
flags |= LOADER_FLAGS_UPDATES;
else if (!strcasecmp(argv[i], "isa"))
@@ -471,7 +503,6 @@ static int parseCmdLineFlags(int flags, struct loaderData_s * loaderData,
/* the anaconda script, but don't want to represent as a */
/* LOADER_FLAGS_XXX since loader doesn't care about these */
/* particular options. */
-
/* do vncpassword case first */
if (!strncasecmp(argv[i], "vncpassword=", 12)) {
if (!FL_TESTING(flags))
@@ -481,6 +512,7 @@ static int parseCmdLineFlags(int flags, struct loaderData_s * loaderData,
!strncasecmp(argv[i], "skipddc", 7) ||
!strncasecmp(argv[i], "nomount", 7) ||
!strncasecmp(argv[i], "vnc", 3)) {
+ !strncasecmp(argv[i], "headless", 8)) {
int arglen;
arglen = strlen(argv[i])+3;
@@ -496,6 +528,8 @@ static int parseCmdLineFlags(int flags, struct loaderData_s * loaderData,
}
}
+ readEnvVars(flags, &loaderData);
+
/* NULL terminates the array of extra args */
extraArgs[numExtraArgs] = NULL;
@@ -617,7 +651,7 @@ static char *doLoaderMain(char * location,
validMethods[numValidMethods] = i;
/* have we preselected this to be our install method? */
- if (loaderData->method &&
+ if (loaderData->method && *loaderData->method &&
!strcmp(loaderData->method, installMethods[i].shortname)) {
methodNum = numValidMethods;
}
@@ -986,7 +1020,7 @@ int main(int argc, char ** argv) {
checkForRam(flags);
- mlLoadModuleSet("cramfs:vfat:nfs:loop", modLoaded, modDeps,
+ mlLoadModuleSet("cramfs:vfat:nfs:loop:isofs", modLoaded, modDeps,
modInfo, flags);
/* now let's do some initial hardware-type setup */
@@ -1181,6 +1215,8 @@ int main(int argc, char ** argv) {
*argptr++ = "-T";
else if (FL_GRAPHICAL(flags))
*argptr++ = "--graphical";
+ if (FL_CMDLINE(flags))
+ *argptr++ = "-C";
if (FL_EXPERT(flags))
*argptr++ = "--expert";
diff --git a/loader2/loader.h b/loader2/loader.h
index 4a7f940b7..4e981b60e 100644
--- a/loader2/loader.h
+++ b/loader2/loader.h
@@ -35,7 +35,8 @@
#define LOADER_FLAGS_NOPARPORT (1 << 25)
#define LOADER_FLAGS_NOIEEE1394 (1 << 26)
#define LOADER_FLAGS_NOFB (1 << 27)
-#define LOADER_FLAGS_GRAPHICAL (1 << 28)
+#define LOADER_FLAGS_CMDLINE (1 << 28)
+#define LOADER_FLAGS_GRAPHICAL (1 << 29)
#define FL_TESTING(a) ((a) & LOADER_FLAGS_TESTING)
#define FL_EXPERT(a) ((a) & LOADER_FLAGS_EXPERT)
@@ -69,7 +70,7 @@
#define FL_NOIEEE1394(a) ((a) & LOADER_FLAGS_NOIEEE1394)
#define FL_NOFB(a) ((a) & LOADER_FLAGS_NOFB)
#define FL_GRAPHICAL(a) ((a) & LOADER_FLAGS_GRAPHICAL)
-
+#define FL_CMDLINE(a) ((a) & LOADER_FLAGS_CMDLINE)
void startNewt(int flags);
@@ -89,7 +90,8 @@ struct loaderData_s {
int kbd_set;
char * netDev;
int netDev_set;
- char * ip, * netmask, *gateway, *dns, *hostname;
+ char * ip, * netmask, *gateway, *dns, *hostname, *ptpaddr;
+ int mtu;
int noDns;
int ipinfo_set;
char * ksFile;
diff --git a/loader2/loadermisc.h b/loader2/loadermisc.h
index 3e673d6e5..d44676cbd 100644
--- a/loader2/loadermisc.h
+++ b/loader2/loadermisc.h
@@ -7,6 +7,6 @@ int copyFile(char * source, char * dest);
int copyFileFd(int infd, char * dest);
char * readLine(FILE * f);
int simpleStringCmp(const void * a, const void * b);
-char * sdupprintf(const char *format, ...);
+char * sdupprintf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
#endif
diff --git a/loader2/log.h b/loader2/log.h
index a8bafa38d..6a7da0d77 100644
--- a/loader2/log.h
+++ b/loader2/log.h
@@ -6,7 +6,7 @@
extern FILE * log;
extern int logfd;
-void logMessage(const char * s, ...);
+void logMessage(const char * s, ...) __attribute__ ((format (printf, 1, 2)));;
void openLog(int useLocal);
void closeLog(void);
void setLogLevel(int level);
diff --git a/loader2/method.c b/loader2/method.c
index b2a4ecc5f..130d920ca 100644
--- a/loader2/method.c
+++ b/loader2/method.c
@@ -39,22 +39,7 @@
#include "../isys/imount.h"
#include "../isys/isys.h"
-
-/* JKFIXME: this is a pile of crap... should at least only be done once */
-/* Need to tell loop.h what the actual dev_t type is. */
-#undef dev_t
-#if defined(__alpha) || (defined(__sparc__) && defined(__arch64__))
-#define dev_t unsigned int
-#else
-#if defined(__x86_64__)
-#define dev_t unsigned long
-#else
-#define dev_t unsigned short
-#endif
-#endif
-#include <linux/loop.h>
-#undef dev_t
-#define dev_t dev_t
+#include "devt.h"
#include "nfsinstall.h"
#include "hdinstall.h"
@@ -107,7 +92,7 @@ int mountLoopback(char * fsystem, char * mntpoint, char * device) {
devMakeInode(device, filename);
loopfd = open(filename, O_RDONLY);
if (loopfd == -1) {
- logMessage("unable to open loop device", filename);
+ logMessage("unable to open loop device %s", filename);
return LOADER_ERROR;
}
logMessage("mntloop %s on %s as %s fd is %d",
@@ -115,6 +100,7 @@ int mountLoopback(char * fsystem, char * mntpoint, char * device) {
if (ioctl(loopfd, LOOP_SET_FD, targfd)) {
logMessage("LOOP_SET_FD failed: %s", strerror(errno));
+ ioctl(loopfd, LOOP_CLR_FD, 0);
close(targfd);
close(loopfd);
return LOADER_ERROR;
@@ -139,9 +125,9 @@ int mountLoopback(char * fsystem, char * mntpoint, char * device) {
0, NULL, NULL, 0)) {
if (doPwMount(filename, mntpoint, "cramfs", 1,
0, NULL, NULL, 0)) {
-
logMessage("failed to mount loop: %s",
strerror(errno));
+ ioctl(loopfd, LOOP_CLR_FD, 0);
return LOADER_ERROR;
}
}
@@ -597,7 +583,7 @@ int copyFileAndLoopbackMount(int fd, char * dest, int flags,
rc = copyFileFd(fd, dest);
stat(dest, &sb);
- logMessage("copied %d bytes to %s (%s)", sb.st_size, dest,
+ logMessage("copied %lld bytes to %s (%s)", sb.st_size, dest,
((rc) ? " incomplete" : "complete"));
if (rc) {
diff --git a/loader2/module-info b/loader2/module-info
index d154e77f7..832b4b5e0 100644
--- a/loader2/module-info
+++ b/loader2/module-info
@@ -432,7 +432,7 @@ sunqe
tg3
eth
- "Broadcom Tigon3 ethernet driver"
+ "Broadcom Tigon3 Ethernet"
tlan
eth
@@ -499,6 +499,28 @@ ctc
eth
"S/390 Channel to Channel"
+# iSeries
+veth
+ eth
+ "iSeries Virtual Ethernet"
+
+# Mac stuff
+bmac
+ eth
+ "Apple BMAC/BMAC+"
+
+mace
+ eth
+ "Apple MACE"
+
+sungem
+ eth
+ "Apple GMAC"
+
+airport
+ eth
+ "Apple Airport"
+
# NOT YET MODULARIZED!
#znet
diff --git a/loader2/modules.c b/loader2/modules.c
index 0cc7c1b50..b0df111ee 100644
--- a/loader2/modules.c
+++ b/loader2/modules.c
@@ -281,7 +281,7 @@ static int loadModule(const char * modName, struct extractedModule * path,
}
if (FL_TESTING(flags)) {
- logMessage("would have insmod %s (%s)", path, fileName);
+ logMessage("would have insmod %s (%s)", path->path, fileName);
rc = 0;
} else {
if (!(child = fork())) {
@@ -503,7 +503,7 @@ static int doLoadModules(const char * origModNames, moduleList modLoaded,
if (loadModule(*l, p, modLoaded,
(argModule && !strcmp(argModule, *l)) ? args : NULL,
modInfo, flags)) {
- logMessage("failed to insert %s", *p);
+ logMessage("failed to insert %s", p->path);
} else {
logMessage("inserted %s", p->path);
}
diff --git a/loader2/net.c b/loader2/net.c
index 432da26d5..0e4fc1925 100644
--- a/loader2/net.c
+++ b/loader2/net.c
@@ -280,6 +280,16 @@ void setupNetworkDeviceConfig(struct networkDeviceConfig * cfg,
cfg->dev.set |= PUMP_NETINFO_HAS_HOSTNAME;
}
+ if (loaderData->mtu) {
+ cfg->dev.mtu = loaderData->mtu;
+ cfg->dev.set |= PUMP_INTFINFO_HAS_MTU;
+ }
+
+ if (loaderData->ptpaddr && (inet_aton(loaderData->ptpaddr, &addr))) {
+ cfg->dev.ptpaddr = addr;
+ cfg->dev.set |= PUMP_INTFINFO_HAS_PTPADDR;
+ }
+
cfg->noDns = loaderData->noDns;
}
@@ -307,8 +317,6 @@ int readNetConfig(char * device, struct networkDeviceConfig * cfg, int flags) {
return 0;
}
- /* JKFIXME: I do NOT like this crap */
-#if !defined(__s390__) && !defined(__s390x__)
text = newtTextboxReflowed(-1, -1,
_("Please enter the IP configuration for this machine. Each "
"item should be entered as an IP address in dotted-decimal "
@@ -446,63 +454,6 @@ int readNetConfig(char * device, struct networkDeviceConfig * cfg, int flags) {
}
} while (i != 2);
-#else /* s390 now */
- char * env;
-
- /* JKFIXME: this is something of a hack... will go away better once
- * we start just reading this into the ip info in loaderdata */
- winStatus(50, 3, _("Setting up networking"),
- _("Setting up networking for %s..."), device, 0);
-
- memset(&newCfg, 0, sizeof(newCfg));
- strcpy(newCfg.dev.device, device);
- newCfg.isDynamic = 0;
- env = getenv("IPADDR");
- if (env && *env) {
- if(inet_aton(env, &newCfg.dev.ip))
- newCfg.dev.set |= PUMP_INTFINFO_HAS_IP;
- }
- env = getenv("NETMASK");
- if (env && *env) {
- if(inet_aton(env, &newCfg.dev.netmask))
- newCfg.dev.set |= PUMP_INTFINFO_HAS_NETMASK;
- }
- env = getenv("GATEWAY");
- if (env && *env) {
- if(inet_aton(env, &newCfg.dev.gateway))
- newCfg.dev.set |= PUMP_NETINFO_HAS_GATEWAY;
- }
- env = getenv("NETWORK");
- if (env && *env) {
- if(inet_aton(env, &newCfg.dev.network))
- newCfg.dev.set |= PUMP_INTFINFO_HAS_NETWORK;
- }
- env = getenv("DNS");
- if (env && *env) {
- char *s = strdup (env);
- char *t = strtok (s, ":");
- if(inet_aton((t? t : s), &newCfg.dev.dnsServers[0]))
- newCfg.dev.set |= PUMP_NETINFO_HAS_DNS;
- }
- env = getenv("BROADCAST");
- if (env && *env) {
- if(inet_aton(env, &newCfg.dev.broadcast))
- newCfg.dev.set |= PUMP_INTFINFO_HAS_BROADCAST;
- }
- env = getenv("MTU");
- if (env && *env) {
- newCfg.dev.mtu = atoi(env);
- newCfg.dev.set |= PUMP_INTFINFO_HAS_MTU;
- }
- env = getenv("REMIP");
- if (env && *env) {
- if (inet_aton(env, &newCfg.dev.ptpaddr))
- newCfg.dev.set |= PUMP_INTFINFO_HAS_PTPADDR;
- }
-
- sleep(1);
-#endif /* s390 */
-
/* preserve extra dns servers for the sake of being nice */
if (cfg->dev.numDns > newCfg.dev.numDns) {
for (i = newCfg.dev.numDns; i < cfg->dev.numDns; i++) {
@@ -538,7 +489,12 @@ int readNetConfig(char * device, struct networkDeviceConfig * cfg, int flags) {
writeResolvConf(cfg);
}
+ /* JKFIXME: this is a hack */
+#if !defined(__s390__) && !defined(__s390x__)
return 0;
+#else
+ return LOADER_NOOP;
+#endif
}
int configureNetwork(struct networkDeviceConfig * dev) {
diff --git a/loader2/nfsinstall.c b/loader2/nfsinstall.c
index e08339551..6f422ade0 100644
--- a/loader2/nfsinstall.c
+++ b/loader2/nfsinstall.c
@@ -118,7 +118,8 @@ char * mountNfsImage(struct installMethod * method,
setupNetworkDeviceConfig(&netDev, loaderData, flags);
rc = readNetConfig(devName, &netDev, flags);
- if (rc) {
+ if ((rc == LOADER_BACK) || (rc == LOADER_ERROR) ||
+ ((dir == -1) && (rc == LOADER_NOOP))) {
stage = NFS_STAGE_IFACE;
dir = -1;
break;
@@ -128,7 +129,7 @@ char * mountNfsImage(struct installMethod * method,
case NFS_STAGE_NFS:
logMessage("going to do nfsGetSetup");
- if (loaderData->method &&
+ if (loaderData->method && *loaderData->method &&
!strncmp(loaderData->method, "nfs", 3) &&
loaderData->methodData) {
host = ((struct nfsInstallData *)loaderData->methodData)->host;
diff --git a/loader2/shutdown.c b/loader2/shutdown.c
new file mode 100644
index 000000000..33dab7bad
--- /dev/null
+++ b/loader2/shutdown.c
@@ -0,0 +1,108 @@
+/*
+ * shutdown.c
+ *
+ * Shutdown a running system. If built with -DAS_SHUTDOWN=1, then
+ * it builds a standalone shutdown binary.
+ *
+ * Copyright 1996 - 2003 Red Hat, Inc.
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <fcntl.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/reboot.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#ifdef AS_SHUTDOWN
+int testing = 0;
+#else
+extern int testing;
+#endif
+
+void disableSwap(void);
+void unmountFilesystems(void);
+
+
+void shutDown(int noKill, int doReboot) {
+ sync(); sync();
+
+ if (!testing && !noKill) {
+ printf("sending termination signals...");
+ kill(-1, 15);
+ sleep(2);
+ printf("done\n");
+
+ printf("sending kill signals...");
+ kill(-1, 9);
+ sleep(2);
+ printf("done\n");
+ }
+
+ printf("disabling swap...\n");
+ disableSwap();
+
+ printf("unmounting filesystems...\n");
+ unmountFilesystems();
+
+ if (doReboot) {
+ printf("rebooting system\n");
+ sleep(2);
+
+#if USE_MINILIBC
+ reboot(0xfee1dead, 672274793, 0x1234567);
+#else
+ reboot(RB_AUTOBOOT);
+#endif
+ } else {
+ printf("you may safely reboot your system\n");
+#if !defined(__s390__) && !defined(__s390x__)
+ while (1);
+#else
+ reboot(RB_HALT_SYSTEM);
+#endif
+ }
+
+ exit(0);
+
+ return;
+}
+
+#ifdef AS_SHUTDOWN
+int main(int argc, char ** argv) {
+ int fd;
+ int doReboot = 0;
+ int i = 1;
+
+ while (i < argc) {
+ if (!strncmp("-r", argv[i], 2))
+ doReboot = 1;
+ i++;
+ }
+
+ /* ignore some signals so we don't kill ourself */
+ signal(SIGINT, SIG_IGN);
+ signal(SIGTSTP, SIG_IGN);
+
+ /* now change to / */
+ chdir("/");
+
+ /* redirect output to the real console */
+ fd = open("/dev/console", O_RDWR);
+ dup2(fd, 0);
+ dup2(fd, 1);
+ dup2(fd, 2);
+ close(fd);
+
+ shutDown(0, doReboot);
+}
+#endif
diff --git a/loader2/undomounts.c b/loader2/undomounts.c
new file mode 100644
index 000000000..07892af57
--- /dev/null
+++ b/loader2/undomounts.c
@@ -0,0 +1,228 @@
+/*
+ * undomounts.c
+ *
+ * Handles some basic unmounting stuff for init
+ * Broken out so that it can be used on s390 in a shutdown binary
+ *
+ * Erik Troan <ewt@redhat.com>
+ * Jeremy Katz <katzj@redhat.com>
+ *
+ * Copyright 1996 - 2003 Red Hat, Inc.
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/swap.h>
+#include <unistd.h>
+
+#include "devt.h"
+
+struct unmountInfo {
+ char * name;
+ int mounted;
+ int loopDevice;
+ enum { FS, LOOP } what;
+} ;
+
+extern int testing;
+
+void undoLoop(struct unmountInfo * fs, int numFs, int this);
+
+static void printstr(char * string) {
+ write(1, string, strlen(string));
+}
+
+void undoMount(struct unmountInfo * fs, int numFs, int this) {
+ int len = strlen(fs[this].name);
+ int i;
+
+ if (!fs[this].mounted) return;
+ fs[this].mounted = 0;
+
+ /* unmount everything underneath this */
+ for (i = 0; i < numFs; i++) {
+ if (fs[i].name && (strlen(fs[i].name) >= len) &&
+ (fs[i].name[len] == '/') &&
+ !strncmp(fs[this].name, fs[i].name, len)) {
+ if (fs[i].what == LOOP)
+ undoLoop(fs, numFs, i);
+ else
+ undoMount(fs, numFs, i);
+ }
+ }
+
+ printf("\t%s", fs[this].name);
+ /* don't need to unmount /tmp. it is busy anyway. */
+ if (!testing) {
+ if (umount2(fs[this].name, 0) < 0) {
+ printf(" umount failed (%d)", errno);
+ } else {
+ printf(" done");
+ }
+ }
+ printf("\n");
+}
+
+void undoLoop(struct unmountInfo * fs, int numFs, int this) {
+ int i;
+ int fd;
+
+ if (!fs[this].mounted) return;
+ fs[this].mounted = 0;
+
+ /* find the device mount */
+ for (i = 0; i < numFs; i++) {
+ if (fs[i].what == FS && (fs[i].loopDevice == fs[this].loopDevice))
+ break;
+ }
+
+ if (i < numFs) {
+ /* the device is mounted, unmount it (and recursively, anything
+ * underneath) */
+ undoMount(fs, numFs, i);
+ }
+
+ unlink("/tmp/loop");
+ mknod("/tmp/loop", 0600 | S_IFBLK, (7 << 8) | fs[this].loopDevice);
+ printf("\tdisabling /dev/loop%d", fs[this].loopDevice);
+ if ((fd = open("/tmp/loop", O_RDONLY, 0)) < 0) {
+ printf(" failed to open device: %d", errno);
+ } else {
+ if (!testing && ioctl(fd, LOOP_CLR_FD, 0))
+ printf(" LOOP_CLR_FD failed: %d", errno);
+ close(fd);
+ }
+
+ printf("\n");
+}
+
+void unmountFilesystems(void) {
+ int fd, size;
+ char buf[65535]; /* this should be big enough */
+ char * chptr, * start;
+ struct unmountInfo filesystems[500];
+ int numFilesystems = 0;
+ int i;
+ struct loop_info li;
+ char * device;
+ struct stat sb;
+
+ fd = open("/proc/mounts", O_RDONLY, 0);
+ if (fd < 1) {
+ /* FIXME: was perror */
+ printstr("failed to open /proc/mounts");
+ sleep(2);
+ return;
+ }
+
+ size = read(fd, buf, sizeof(buf) - 1);
+ buf[size] = '\0';
+
+ close(fd);
+
+ chptr = buf;
+ while (*chptr) {
+ device = chptr;
+ while (*chptr != ' ') chptr++;
+ *chptr++ = '\0';
+ start = chptr;
+ while (*chptr != ' ') chptr++;
+ *chptr++ = '\0';
+
+ if (strcmp(start, "/") && strcmp(start, "/tmp")) {
+ filesystems[numFilesystems].name = strdup(start);
+ filesystems[numFilesystems].what = FS;
+ filesystems[numFilesystems].mounted = 1;
+
+ stat(start, &sb);
+ if ((sb.st_dev >> 8) == 7) {
+ filesystems[numFilesystems].loopDevice = sb.st_dev & 0xf;
+ } else {
+ filesystems[numFilesystems].loopDevice = -1;
+ }
+
+ numFilesystems++;
+ }
+
+ while (*chptr != '\n') chptr++;
+ chptr++;
+ }
+
+ for (i = 0; i < 7; i++) {
+ unlink("/tmp/loop");
+ mknod("/tmp/loop", 0600 | S_IFBLK, (7 << 8) | i);
+ if ((fd = open("/tmp/loop", O_RDONLY, 0)) >= 0) {
+ if (!ioctl(fd, LOOP_GET_STATUS, &li) && li.lo_name[0]) {
+ filesystems[numFilesystems].name = strdup(li.lo_name);
+ filesystems[numFilesystems].what = LOOP;
+ filesystems[numFilesystems].mounted = 1;
+ filesystems[numFilesystems].loopDevice = i;
+ numFilesystems++;
+ }
+
+ close(fd);
+ }
+ }
+
+ for (i = 0; i < numFilesystems; i++) {
+ if (filesystems[i].what == LOOP) {
+ undoLoop(filesystems, numFilesystems, i);
+ }
+ }
+
+ for (i = 0; i < numFilesystems; i++) {
+ if ((filesystems[i].mounted) && (filesystems[i].name)) {
+ undoMount(filesystems, numFilesystems, i);
+ }
+ }
+
+ for (i = 0; i < numFilesystems; i++)
+ free(filesystems[i].name);
+}
+
+void disableSwap(void) {
+ int fd;
+ char buf[4096];
+ int i;
+ char * start;
+ char * chptr;
+
+ if ((fd = open("/proc/swaps", O_RDONLY, 0)) < 0) return;
+
+ i = read(fd, buf, sizeof(buf) - 1);
+ close(fd);
+ if (i < 0) return;
+ buf[i] = '\0';
+
+ start = buf;
+ while (*start) {
+ while (*start != '\n' && *start) start++;
+ if (!*start) return;
+
+ start++;
+ if (*start != '/') return;
+ chptr = start;
+ while (*chptr && *chptr != ' ') chptr++;
+ if (!(*chptr)) return;
+ *chptr = '\0';
+ printf("\t%s", start);
+ if (swapoff(start))
+ printf(" failed (%d)", errno);
+ printf("\n");
+
+ start = chptr + 1;
+ }
+}
diff --git a/loader2/urlinstall.c b/loader2/urlinstall.c
index 2ce84ce7c..ed4ac80c4 100644
--- a/loader2/urlinstall.c
+++ b/loader2/urlinstall.c
@@ -211,7 +211,8 @@ char * mountUrlImage(struct installMethod * method,
setupNetworkDeviceConfig(&netDev, loaderData, flags);
rc = readNetConfig(devName, &netDev, flags);
- if (rc) {
+ if ((rc == LOADER_BACK) || (rc == LOADER_ERROR) ||
+ ((dir == -1) && (rc == LOADER_NOOP))) {
stage = URL_STAGE_IFACE;
dir = -1;
break;
@@ -220,7 +221,7 @@ char * mountUrlImage(struct installMethod * method,
dir = 1;
case URL_STAGE_MAIN:
- if (loaderData->method &&
+ if (loaderData->method && *loaderData->method &&
(!strncmp(loaderData->method, "ftp", 3) ||
!strncmp(loaderData->method, "http", 3)) &&
loaderData->methodData) {
diff --git a/loader2/usb.c b/loader2/usb.c
index 028559ebe..bea93d333 100644
--- a/loader2/usb.c
+++ b/loader2/usb.c
@@ -23,6 +23,7 @@
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "loader.h"
#include "log.h"