diff options
author | Jeremy Katz <katzj@redhat.com> | 2002-02-21 21:41:51 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2002-02-21 21:41:51 +0000 |
commit | a93e80b2fc0f4db6c255879dc911fd686c38cdab (patch) | |
tree | 4caaa1ce6327d24e0c573cd93e87a27520da801c | |
parent | 13c8e367dc242b1b142c42624fc7a1cedfe066a5 (diff) | |
download | anaconda-a93e80b2fc0f4db6c255879dc911fd686c38cdab.tar.gz anaconda-a93e80b2fc0f4db6c255879dc911fd686c38cdab.tar.xz anaconda-a93e80b2fc0f4db6c255879dc911fd686c38cdab.zip |
loader merge from HEAD for
* diet
* nfsiso
* mediacheck
and all of the fun infrastructure to support the above
59 files changed, 2725 insertions, 740 deletions
diff --git a/Makefile.inc b/Makefile.inc index 0facf62b9..d03619a24 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -5,6 +5,8 @@ PYTHONLIBDIR = /usr/lib/anaconda RUNTIMEDIR = /usr/lib/anaconda-runtime ANACONDADATADIR = /usr/share/anaconda +PYTHON = python1.5 +PYTHONINCLUDE = /usr/include/python1.5 ARCH := $(patsubst i%86,i386,$(shell uname -m)) ARCH := $(patsubst sparc%,sparc,$(ARCH)) diff --git a/collage/Makefile b/collage/Makefile index 6696d3191..f20c76eed 100644 --- a/collage/Makefile +++ b/collage/Makefile @@ -1,8 +1,13 @@ include ../Makefile.inc +ISYSLIB=isys +ifeq ($(ARCH),i386) +ISYSLIB=isys-diet +endif + CFLAGS = -Wall -g -O2 LDFLAGS = -g -LOADLIBES = -L../isys -lisys -lresolv -lz +LOADLIBES = -L../isys -L../isys/gzlib -l$(ISYSLIB) -lgunzip -lresolv -lz ifeq (.depend,$(wildcard .depend)) TARGET=all diff --git a/collage/commands.c b/collage/commands.c index 59e014681..802c90a5f 100644 --- a/collage/commands.c +++ b/collage/commands.c @@ -1,5 +1,6 @@ #include <errno.h> #include <fcntl.h> +#include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -10,7 +11,6 @@ #include <sys/sysmacros.h> #include <sys/statfs.h> #include <unistd.h> -#include <zlib.h> #include "../isys/imount.h" #include "../isys/isys.h" @@ -19,6 +19,16 @@ #include "mount_by_label.h" #include "../isys/cpio.h" +int mygethostbyname(char * host, struct in_addr * address) { + struct hostent * hostinfo; + + hostinfo = gethostbyname(host); + if (!hostinfo) return 1; + + memcpy(address, hostinfo->h_addr_list[0], hostinfo->h_length); + return 0; +} + static int copyfd(int to, int from); static int copyfd(int to, int from) { @@ -190,10 +200,12 @@ int uncpioCommand(int argc, char ** argv) { return 1; } - cfd = gzdopen(0, "r"); + cfd = gunzip_dopen(0); rc = myCpioInstallArchive(cfd, NULL, 0, NULL, NULL, &fail); + gunzip_close(cfd); + if (rc) { fprintf(stderr, "cpio failed on %s: ", fail); if (rc & CPIOERR_CHECK_ERRNO) diff --git a/loader/Makefile b/loader/Makefile index 3bf0a3eee..c9fb028cb 100644 --- a/loader/Makefile +++ b/loader/Makefile @@ -4,42 +4,48 @@ VERSION = 7.2 DESTDIR = ../../trees/initrd -ARCH := $(patsubst i%86,i386,$(shell uname -m)) -ARCH := $(patsubst sparc%,sparc,$(ARCH)) - OBJS = log.o windows.o modules.o devices.o cdrom.o urls.o kickstart.o lang.o \ - misc.o ftp.o + misc.o ftp.o md5.o mediacheck.o + +SLANGLIB = -lslang ifneq (ia64, $(ARCH)) +ifneq (i386, $(ARCH)) OBJS += fnmatch-stub.o printf-stub.o pwd-stub.o dl-stub.o SLANGLIB = ../minislang/libslang.a -else -SLANGLIB = -lslang +endif endif LOADEROBJS = loader.o loader-pcmcia.o popen.o SOURCES = $(subst .o,.c,$(OBJS)) loader.c BINS = init DIRS = -NETOBJS = net.o +NETOBJS = net.o telnet.o telnetd.o PCMCIAOBJS = pcmcia.o $(NETOBJS) -#OPTS = -Os -g -OPTS = -Os -g +OPTS = -Os +DEBUG = -g -MODULELINKAGE := -lmodutils -lmodutilutil -lmodutilobj +MODULELINKAGE :=-lmodutils -lmodutilutil -lmodutilobj -CFLAGS = $(DEBUG) $(OPTS) -ffunction-sections -Wall -D_GNU_SOURCE=1 -I/usr/include/kudzu -I/usr/include/rpm -I.. -DUSE_ALT_DNS=1 -DVERSION='"$(VERSION)"' -DHAVE_LIBIO_H -ggdb +COPTS = $(DEBUG) -Wall -DVERSION='"$(VERSION)"' + +CFLAGS = $(COPTS) $(OPTS) -ffunction-sections -D_GNU_SOURCE=1 -I/usr/include/kudzu -I/usr/include/rpm -I.. -DHAVE_LIBIO_H -ggdb ALLOBJS = $(OBJS) $(PCMCIAOBJS) +ISYS = ../isys/libisys.a +GUNZIP = ../isys/gzlib/libgunzip.a +LOADERLIBS = -lpci + # XXX Japanese is i386 only at the moment ifeq (i386, $(ARCH)) BINS += loader-local loader-network loader-pcmcia ifeq (1, $(JAPANESE)) - BINS += loader-local-kon loader-network-kon loader-pcmcia-kon KONOBJS = ./kon2/src/libkon.a ./kon2/src/display.a ./kon2/lib/libgon.a + CFLAGS += -DINCLUDE_KON + DIRS += kon2 endif -DIRS += pcmcia-install kon2 -OBJS += stubs.o +DIRS += pcmcia-install +OBJS += dietstubs.o ctype.o endif ifeq (ia64, $(ARCH)) @@ -52,13 +58,15 @@ OBJS += stubs.o endif ifeq (s390, $(ARCH)) -BINS += loader loader-local +BINS += loader OBJS += stubs.o +S390FILES = load_anaconda endif ifeq (s390x, $(ARCH)) -BINS += loader loader-local +BINS += loader OBJS += stubs.o +S390FILES = load_anaconda endif ifeq (sparc, $(ARCH)) @@ -76,8 +84,15 @@ STATIC = -static ifeq (i386, $(ARCH)) MINILIBC=minilibc.o -CFLAGS+=-DUSE_MINILIBC=1 -DUSE_LOGDEV +COPTS+=-DUSE_MINILIBC=1 -DUSE_LOGDEV LDFLAGS = -nostdlib /usr/lib/crt1.o +LOADERLIBS += -lrpc +ISYS = ../isys/libisys-diet.a +SLANGLIB = ../minislang/libslang-diet.a +GUNZIP = ../isys/gzlib/libgunzip-diet.a +DIET=diet +REALCC=gcc +CC=$(DIET) $(REALCC) STATIC=-static else ifeq (sparc, $(ARCH)) @@ -91,19 +106,16 @@ STATIC=-static endif endif -LANGS = $(shell awk '{ print $$2 }' ../lang-table | egrep -v '(^en$$)|(^ja$$)') +LANGS = $(shell awk '{ print $$2 }' ../lang-table | egrep -v '(^en$$)') TR = $(patsubst %,tr/%.tr,$(LANGS)) TRFILES = $(patsubst %,%.tr,$(LANGS)) -all: dirs $(BINS) loader.tr kon-loader.tr +all: dirs $(BINS) loader.tr loader.tr: $(TR) ../lang-table (cd tr; ls $(TRFILES) | cpio --quiet -Hcrc -o | gzip -9) > $@ -kon-loader.tr: tr/ja.tr ../lang-table - (cd tr; echo ja.tr | cpio --quiet -Hcrc -o | gzip -9) > $@ - loader.po: *.c xgettext --default-domain=loader --add-comments \ --keyword=_ --keyword=N_ *.c @@ -123,62 +135,41 @@ install: all strip $(DESTDIR)/$(RUNTIMEDIR)/loader/$$n; \ done install -m 644 loader.tr $(DESTDIR)/$(RUNTIMEDIR)/loader - install -m 644 kon-loader.tr $(DESTDIR)/$(RUNTIMEDIR)/loader install -m 644 module-info $(DESTDIR)/$(RUNTIMEDIR)/loader + for n in $(S390FILES); do \ + install -m 755 s390/$$n $(DESTDIR)/$(RUNTIMEDIR)/loader; \ + done install -m 644 kon.cfg $(DESTDIR)/$(RUNTIMEDIR)/loader install -m 644 minikon.fnt $(DESTDIR)/$(RUNTIMEDIR)/loader urltest: urltest.o ftp.o urls.o lang.o log.o windows.o - $(CC) -g -o urltest urltest.o -lnewt ftp.o urls.o lang.o log.o windows.o -lz ../isys/libisys.a -lresolv + $(CC) -g -o urltest urltest.o -lnewt ftp.o urls.o lang.o log.o windows.o -lz $(ISYS) -lresolv loader: loader.o $(OBJS) $(NETOBJS) $(CC) -g $(STATIC) -o $@ $^ -lpopt \ - -lkudzu_loader ../isys/libisys.a ../balkan/libbalkan.a \ - $(MODULELINKAGE) \ - -lpump -lz -lresolv -lnewt $(SLANGLIB) -lpci + -lkudzu_loader $(ISYS) ../balkan/libbalkan.a \ + $(MODULELINKAGE) $(GUNZIP) \ + -lpump -lz -lnewt $(SLANGLIB) $(LOADERLIBS) $(KONOBJS) loader-local: loader-local.o $(OBJS) $(CC) -g $(STATIC) -o $@ $^ -lpopt \ - -lkudzu_loader ../isys/libisys.a ../balkan/libbalkan.a \ - $(MODULELINKAGE) \ - -L ../stubs -lz -lresolv -lnewt $(SLANGLIB) -lpci - -loader-local-kon: loader-local-kon.o $(OBJS) - $(CC) -g $(STATIC) -o $@ $^ -lpopt \ - -lkudzu_loader ../isys/libisys.a ../balkan/libbalkan.a \ - $(MODULELINKAGE) \ - -L ../stubs -lz -lresolv -lnewt $(SLANGLIB) -lpci \ - $(KONOBJS) + -lkudzu_loader $(ISYS) ../balkan/libbalkan.a \ + $(MODULELINKAGE) $(GUNZIP) \ + -L ../stubs -lz -lnewt $(SLANGLIB) $(LOADERLIBS) $(KONOBJS) loader-network: loader-net.o $(OBJS) $(NETOBJS) $(CC) -g $(STATIC) -o $@ $^ -lpopt \ - -lkudzu_loader ../isys/libisys.a ../balkan/libbalkan.a \ - $(MODULELINKAGE) \ - -lpump -lz -lresolv -lnewt $(SLANGLIB) -lpci -lutil - -loader-network-kon: loader-net-kon.o $(OBJS) $(NETOBJS) - $(CC) -g $(STATIC) -o $@ $^ -lpopt \ - -lkudzu_loader ../isys/libisys.a ../balkan/libbalkan.a \ - $(MODULELINKAGE) \ - -lpump -lz -lresolv -lnewt $(SLANGLIB) -lpci -lutil \ - $(KONOBJS) + -lkudzu_loader $(ISYS) ../balkan/libbalkan.a \ + $(MODULELINKAGE) $(GUNZIP) \ + -lpump -L ../stubs -lnewt $(SLANGLIB) $(LOADERLIBS) $(KONOBJS) loader-pcmcia: loader-pcmcia.o pcmcia.o popen.o $(OBJS) $(PCMCIAOBJS) $(CC) -g $(STATIC) -o $@ loader-pcmcia.o $(OBJS) \ $(PCMCIAOBJS) -L pcmcia-install/cardmgr -lcardmgr -lprobe popen.o \ -lpopt \ - -lkudzu_loader ../isys/libisys.a ../balkan/libbalkan.a \ - $(MODULELINKAGE) \ - -lpump -lz -lresolv -lnewt $(SLANGLIB) -lpci -lutil - -loader-pcmcia-kon: loader-pcmcia-kon.o pcmcia.o popen.o $(OBJS) $(PCMCIAOBJS) - $(CC) -g $(STATIC) -o $@ loader-pcmcia-kon.o $(OBJS) \ - $(PCMCIAOBJS) -L pcmcia-install/cardmgr -lcardmgr -lprobe popen.o \ - -lpopt \ - -lkudzu_loader ../isys/libisys.a ../balkan/libbalkan.a \ - $(MODULELINKAGE) \ - -lpump -lz -lresolv -lnewt $(SLANGLIB) -lpci -lutil \ - $(KONOBJS) + -lkudzu_loader $(ISYS) ../balkan/libbalkan.a \ + $(MODULELINKAGE) $(GUNZIP) \ + -lpump -lz -lresolv -lnewt $(SLANGLIB) $(LOADERLIBS) $(KONOBJS) loader.o: loader.c $(CC) -DINCLUDE_LOCAL -DINCLUDE_NETWORK $(CFLAGS) -o $@ -c $< @@ -186,31 +177,33 @@ loader.o: loader.c loader-local.o: loader.c $(CC) -DINCLUDE_LOCAL $(CFLAGS) -o $@ -c $< -loader-local-kon.o: loader.c - $(CC) -DINCLUDE_LOCAL -DINCLUDE_KON $(CFLAGS) -o $@ -c $< - loader-net.o: loader.c $(CC) -DINCLUDE_NETWORK $(CFLAGS) -o $@ -c $< -loader-net-kon.o: loader.c - $(CC) -DINCLUDE_NETWORK -DINCLUDE_KON $(CFLAGS) -o $@ -c $< - loader-pcmcia.o: loader.c $(CC) -DINCLUDE_PCMCIA -DINCLUDE_LOCAL -DINCLUDE_NETWORK \ $(CFLAGS) -o $@ -c $< -loader-pcmcia-kon.o: loader.c - $(CC) -DINCLUDE_PCMCIA -DINCLUDE_LOCAL -DINCLUDE_NETWORK \ - -DINCLUDE_KON $(CFLAGS) -o $@ -c $< - init: init.o $(MINILIBC) - $(CC) $(STATIC) -g $(LDFLAGS) -o $@ init.o $(MINILIBC) + $(REALCC) $(STATIC) $(COPTS) $(LDFLAGS) -o $@ init.o $(MINILIBC) + +init.o: init.c + $(REALCC) -O2 $(COPTS) -c -o init.o init.c + +minilibc.o: minilibc.c + $(REALCC) -O2 $(COPTS) -c -o minilibc.o minilibc.c + +mkctype: mkctype.c + $(REALCC) $(COPTS) -o mkctype mkctype.c + +ctype.c: mkctype + ./mkctype > ctype.c clean: - rm -f *.o .depend *~ loader-local loader-network loader.old loader-pcmcia probe modprobe \ - loader.po loader.tr tr/*.tr loader init loader-local-kon loader-network-kon \ - loader-pcmcia-kon - for n in "$(DIRS)" ; do \ + rm -f *.o .depend *~ loader-local loader-network loader.old \ + loader-pcmcia probe modprobe loader.po loader.tr tr/*.tr \ + loader init ctype.c mkctype + for n in $(DIRS); do \ (cd $$n; make clean) \ done diff --git a/loader/devices.c b/loader/devices.c index a3f98e142..fbf3d924f 100644 --- a/loader/devices.c +++ b/loader/devices.c @@ -7,8 +7,9 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <sys/ioctl.h> +#include <sys/stat.h> #include <sys/utsname.h> -#include <zlib.h> #include <linux/fd.h> #include "devices.h" @@ -20,7 +21,7 @@ #include "misc.h" #include "modules.h" #include "windows.h" -#include "../kudzu/kudzu.h" +#include "kudzu/kudzu.h" #include "isys/cpio.h" void eject(char * deviceName) { @@ -41,6 +42,7 @@ void eject(char * deviceName) { unlink("/tmp/ejectDevice"); } + static int getModuleArgs(struct moduleInfo * mod, char *** argPtr) { struct newtWinEntry * entries; int i; @@ -240,9 +242,6 @@ int devLoadDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, if (rc == 2) return LOADER_BACK; - mlLoadModule("vfat", NULL, modLoaded, (*modDepsPtr), NULL, modInfo, - flags); - ddi->device = strdup(device); ddi->mntDevice = malloc(strlen(device) + 10); sprintf(ddi->mntDevice, "/tmp/%s", device); @@ -417,13 +416,8 @@ int devDeviceMenu(enum driverMajor type, moduleInfoSet modInfo, } } - if (mod->major == DRIVER_SCSI) { - scsiWindow(mod->moduleName); - sleep(1); - } - rc = mlLoadModule(mod->moduleName, mod->locationID, modLoaded, + rc = mlLoadModule(mod->moduleName, modLoaded, *modDepsPtr, args, modInfo, flags); - if (mod->major == DRIVER_SCSI) newtPopWindow(); if (args) { for (arg = args; *arg; arg++) @@ -441,100 +435,6 @@ int devDeviceMenu(enum driverMajor type, moduleInfoSet modInfo, return rc; } -char * extractModule(struct driverDiskInfo * ddi, char * modName) { - char * pattern[] = { NULL, NULL }; - struct utsname un; - gzFile from; - gzFile to; - int first = 1; - int fd; - char * buf; - struct stat sb; - int rc; - int failed; - char * toPath; - char * chptr; - - uname(&un); - - /* strip off BOOT, -SMP, whatever */ - chptr = un.release + strlen(un.release) - 1; - while (!isdigit(*chptr)) chptr--; - *(chptr + 1) = '\0'; - - pattern[0] = alloca(strlen(modName) + strlen(un.release) + 5); - sprintf(pattern[0], "%s*/%s.o", un.release, modName); - logMessage("extracting pattern %s", pattern[0]); - - if (ddi->device) - devMakeInode(ddi->device, ddi->mntDevice); - - while (1) { - failed = 0; - - if (doPwMount(ddi->mntDevice, "/tmp/drivers", ddi->fs, 1, 0, - NULL, NULL)) - failed = 1; - - if (failed && !first) { - newtWinMessage(_("Error"), _("OK"), - _("Failed to mount driver disk: %s."), strerror(errno)); - } else if (!failed) { - if ((fd = open("/tmp/drivers/rhdd-6.1", O_RDONLY)) < 0) - failed = 1; - if (!failed) { - fstat(fd, &sb); - buf = malloc(sb.st_size + 1); - read(fd, buf, sb.st_size); - if (buf[sb.st_size - 1] == '\n') - sb.st_size--; - buf[sb.st_size] = '\0'; - close(fd); - - failed = strcmp(buf, ddi->title); - free(buf); - } - - if (failed && !first) { - umount("/tmp/drivers"); - newtWinMessage(_("Error"), _("OK"), - _("The wrong diskette was inserted.")); - } - } - - if (!failed) { - from = gzopen("/tmp/drivers/modules.cgz", "r"); - toPath = malloc(strlen(modName) + 30); - sprintf(toPath, "/tmp/modules/%s", modName); - mkdirChain(toPath); - strcat(toPath, "/modules.cgz"); - to = gzopen(toPath, "w"); - - winStatus(50, 3, _("Loading"), _("Loading %s driver..."), modName); - - myCpioFilterArchive(from, to, pattern); - - newtPopWindow(); - - gzclose(from); - gzclose(to); - umount("/tmp/drivers"); - - sprintf(toPath, "/tmp/modules/%s", modName); - return toPath; - } - - first = 0; - - if (ddi->device) - eject(ddi->device); - - rc = newtWinChoice(_("Driver Disk"), _("OK"), _("Cancel"), - _("Please insert the %s driver disk now."), ddi->title); - if (rc == 2) return NULL; - } -} - void ddReadDriverDiskModInfo(moduleInfoSet modInfo) { int num = 0; char fileName[80]; @@ -565,3 +465,4 @@ void ddReadDriverDiskModInfo(moduleInfoSet modInfo) { } } + diff --git a/loader/devices.h b/loader/devices.h index d20e54bd9..a4305c61a 100644 --- a/loader/devices.h +++ b/loader/devices.h @@ -21,8 +21,7 @@ int devInitDriverDisk(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps *modDepsPtr, int flags, char * mntPoint, struct driverDiskInfo * ddi); void ddReadDriverDiskModInfo(moduleInfoSet modInfo); - void ejectFloppy(void); -char * extractModule(struct driverDiskInfo * location, char * modName); +void eject(char * deviceName); #endif diff --git a/loader/dietstubs.c b/loader/dietstubs.c new file mode 100644 index 000000000..0c2f8cacc --- /dev/null +++ b/loader/dietstubs.c @@ -0,0 +1,168 @@ +#include <errno.h> +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <setjmp.h> +#include <ctype.h> +#include <stdarg.h> + +struct glibc_stat { + long long st_dev; + unsigned short int __pad1; + long st_ino; + int st_mode; + int st_nlink; + int st_uid; + int st_gid; + long long st_rdev; + unsigned short int __pad2; + long st_size; + long st_blksize; + long st_blocks; + long st_atime; + unsigned long int __unused1; + long st_mtime; + unsigned long int __unused2; + long st_ctime; + unsigned long int __unused3; + unsigned long int __unused4; + unsigned long int __unused5; +}; + +static void stat_copy(struct stat * from, struct glibc_stat * to) { + to->st_dev = from->st_dev; + to->st_ino = from->st_ino; + to->st_mode = from->st_mode; + to->st_nlink = from->st_nlink; + to->st_uid = from->st_uid; + to->st_gid = from->st_gid; + to->st_rdev = from->st_rdev; + to->st_size = from->st_size; + to->st_blksize = from->st_blksize; + to->st_blocks = from->st_blocks; + to->st_atime = from->st_atime; + to->st_mtime = from->st_mtime; + to->st_ctime = from->st_ctime; +} + +int __xstat (int __ver, __const char *__filename, struct glibc_stat * sb) { + struct stat s; + int rc = stat(__filename, &s); + + if (!rc) stat_copy(&s, sb); + + return rc; +} + +int __lxstat (int __ver, __const char *__filename, struct glibc_stat * sb) { + struct stat s; + int rc = lstat(__filename, &s); + + if (!rc) stat_copy(&s, sb); + + return rc; +} + +int __fxstat (int __ver, int fd, struct glibc_stat * sb) { + struct stat s; + int rc = fstat(fd, &s); + + if (!rc) stat_copy(&s, sb); + + return rc; +} + +extern double strtod (__const char * __nptr, char ** __endptr); + +double __strtod_internal (__const char *__restrict __nptr, + char **__restrict __endptr, int __group) { + return strtod(__nptr, __endptr); +} + + +long int __strtol_internal(const char * nptr, char ** endptr, + int base, int group) { + return strtol(nptr, endptr, base); +} + +unsigned long int __strtoul_internal (__const char *__restrict __nptr, + char **__restrict __endptr, + int __base, int __group) __THROW { + return strtoul(__nptr, __endptr, __base); +} + +char * __strdup(const char * s) { + return strdup(s); +} + +void __assert_fail (__const char *__assertion, __const char *__file, + unsigned int __line, __const char *__function) { + fprintf(stderr, "%s:%d assertion failed in %s()\n", + __file, __line, __function); + abort(); +} + +long long llseek(int fd, long long offest, int whence); + +long long lseek64(int fd, long long offset, int whence) { + return llseek(fd, offset, whence); +} + +int _setjmp(jmp_buf buf) { + return setjmp(buf); +} + +char * strcasestr(char * haystack1, char * needle1) { + char * haystack = strdup(haystack1); + char * needle = strdup(needle1); + char * chptr; + + for (chptr = haystack; *chptr; chptr++) *chptr = toupper(*chptr); + for (chptr = needle; *chptr; chptr++) *chptr = toupper(*chptr); + + chptr = strstr(needle, haystack); + if (!chptr) return NULL; + + return (chptr - haystack) + haystack1; +} + +int _IO_putc(char c, void * f) { + return putc(c, f); +} + +int _IO_getc(void * f) { + return getc(f); +} + +int __xmknod (int __ver, const char * path, unsigned int mode, + long long * dev) { + return mknod(path, mode, *dev); +} + + +/* this should print the name of the app, but how? probably in a global + somewhere (like env is) */ +void warn(char * format, ...) { + va_list args; + int err = errno; + + va_start(args, format); + + fprintf(stderr, "warning: "); + vfprintf(stderr, format, args); + fprintf(stderr, ": %s\n", strerror(err)); + + va_end(args); + + errno = err; +} + +int pwrite(int fd, const void *buf, size_t count, off_t offset) { + return __pwrite(fd, buf, count, offset); +} + +void * __rawmemchr (void* s, int c) { + while (*(char *)s != c) + s++; + return s; +} diff --git a/loader/ftp.c b/loader/ftp.c index 7f0286f2d..2356f418c 100644 --- a/loader/ftp.c +++ b/loader/ftp.c @@ -185,8 +185,7 @@ int ftpCommand(int sock, char * command, ...) { return 0; } -#if !defined(USE_ALT_DNS) || !USE_ALT_DNS -static int mygethostbyname(const char * host, struct in_addr * address) { +int mygethostbyname(char * host, struct in_addr * address) { struct hostent * hostinfo; hostinfo = gethostbyname(host); @@ -195,7 +194,6 @@ static int mygethostbyname(const char * host, struct in_addr * address) { memcpy(address, hostinfo->h_addr_list[0], hostinfo->h_length); return 0; } -#endif static int getHostAddress(const char * host, struct in_addr * address) { if (isdigit(host[0])) { diff --git a/loader/init.c b/loader/init.c index 8c7d12279..b708adae7 100644 --- a/loader/init.c +++ b/loader/init.c @@ -5,7 +5,7 @@ * * Erik Troan (ewt@redhat.com) * - * Copyright 1996 Red Hat Software + * Copyright 1996 - 2002 Red Hat Software * * This software may be freely redistributed under the terms of the GNU * public license. @@ -103,7 +103,7 @@ char * env[] = { * */ -int testing; +int testing=0; void printstr(char * string) { write(1, string, strlen(string)); @@ -120,7 +120,9 @@ void fatal_error(int usePerror) { printf("\nI can't recover from this.\n"); if (testing) exit(0); +#if !defined(__s390__) && !defined(__s390x__) while (1) ; +#endif } int doMke2fs(char * device, char * size) { @@ -542,7 +544,9 @@ int main(int argc, char **argv) { char twelve = 12; int i; +#if !defined(__s390__) && !defined(__s390x__) testing = (getppid() != 0) && (getppid() != 1); +#endif if (!testing) { /* turn off screen blanking */ @@ -587,6 +591,7 @@ int main(int argc, char **argv) { break; } +#if !defined(__s390__) && !defined(__s390x__) if (ioctl (0, TIOCLINUX, &twelve) < 0) isSerial = 2; @@ -629,6 +634,7 @@ int main(int argc, char **argv) { dup2(fd, 1); dup2(fd, 2); close(fd); +#endif setsid(); if (ioctl(0, TIOCSCTTY, NULL)) { @@ -673,15 +679,21 @@ int main(int argc, char **argv) { } } +#if !defined(__s390__) && !defined(__s390x__) +#define RAMDISK_DEVICE "/dev/ram" +#else +#define RAMDISK_DEVICE "/dev/ram2" +#endif + if (!testing && roRoot) { printf("creating 300k of ramdisk space... "); - if (doMke2fs("/dev/ram", "300")) + if (doMke2fs(RAMDISK_DEVICE, "300")) fatal_error(0); printf("done\n"); printf("mounting /tmp from ramdisk... "); - if (mount("/dev/ram", "/tmp", "ext2", 0, NULL)) + if (mount(RAMDISK_DEVICE, "/tmp", "ext2", 0, NULL)) fatal_error(1); printf("done\n"); diff --git a/loader/kickstart.c b/loader/kickstart.c index 919066588..e8e5e5a13 100644 --- a/loader/kickstart.c +++ b/loader/kickstart.c @@ -35,6 +35,7 @@ struct ksCommandNames ksTable[] = { { KS_CMD_XDISPLAY, "xdisplay" }, { KS_CMD_DRIVERDISK, "driverdisk" }, { KS_CMD_DEVICEPROBE, "deviceprobe" }, + { KS_CMD_KEYBOARD, "keyboard" }, { KS_CMD_NONE, NULL } }; diff --git a/loader/kickstart.h b/loader/kickstart.h index ca85e3479..856160fc1 100644 --- a/loader/kickstart.h +++ b/loader/kickstart.h @@ -11,6 +11,7 @@ #define KS_CMD_TEXT 8 #define KS_CMD_DRIVERDISK 9 #define KS_CMD_DEVICEPROBE 10 +#define KS_CMD_KEYBOARD 11 int ksReadCommands(char * cmdFile); int ksGetCommand(int cmd, char ** last, int * argc, char *** argv); diff --git a/loader/kon2/Makefile b/loader/kon2/Makefile index 0f541ebd0..fcfdd8ea6 100644 --- a/loader/kon2/Makefile +++ b/loader/kon2/Makefile @@ -9,6 +9,9 @@ LIB = $(shell pwd)/lib/libgon.a MFLAGS = INCDIR=$(INCDIR) LIB=$(LIB) +CC = diet gcc +MAKE := $(MAKE) "CC=$(CC)" + ifdef MINI_KON SUBDIRS = lib src else diff --git a/loader/kon2/include/mem.h b/loader/kon2/include/mem.h index 1efc44021..9f5ddb87a 100644 --- a/loader/kon2/include/mem.h +++ b/loader/kon2/include/mem.h @@ -54,7 +54,6 @@ static __inline__ return value; } -extern u_char PortInb(u_short); extern void wzero(void *, int); extern void wmove(void *, void *, int); extern void lmove(void *, void *, int); diff --git a/loader/kon2/include/types.h b/loader/kon2/include/types.h new file mode 100644 index 000000000..69bc800d1 --- /dev/null +++ b/loader/kon2/include/types.h @@ -0,0 +1,3 @@ +typedef unsigned short u_short; +typedef unsigned char u_char; +typedef unsigned int u_int; diff --git a/loader/kon2/lib/coding.c b/loader/kon2/lib/coding.c index ae1a1c5a8..4e1846d08 100644 --- a/loader/kon2/lib/coding.c +++ b/loader/kon2/lib/coding.c @@ -26,6 +26,7 @@ */ #include <config.h> +#include <types.h> #include <stdio.h> #include <errno.h> diff --git a/loader/kon2/lib/font.c b/loader/kon2/lib/font.c index 2ada5c5b1..a424fc1b3 100644 --- a/loader/kon2/lib/font.c +++ b/loader/kon2/lib/font.c @@ -26,6 +26,7 @@ */ #include <config.h> +#include <types.h> #include <stdio.h> #include <stdlib.h> diff --git a/loader/kon2/lib/mem.c b/loader/kon2/lib/mem.c index dba505f55..d43ea48f0 100644 --- a/loader/kon2/lib/mem.c +++ b/loader/kon2/lib/mem.c @@ -25,6 +25,7 @@ * */ +#include "../include/types.h" #include <sys/types.h> #include <mem.h> #if defined(linux) diff --git a/loader/kon2/src/child.c b/loader/kon2/src/child.c index 95523fa31..5fca88f13 100644 --- a/loader/kon2/src/child.c +++ b/loader/kon2/src/child.c @@ -26,6 +26,7 @@ */ #include <config.h> +#include <types.h> #include <stdio.h> #include <stdlib.h> diff --git a/loader/kon2/src/display/svga.c b/loader/kon2/src/display/svga.c index d2d9dffde..f1385548e 100644 --- a/loader/kon2/src/display/svga.c +++ b/loader/kon2/src/display/svga.c @@ -32,6 +32,7 @@ */ #include <config.h> +#include <types.h> #ifdef HAS_VGA diff --git a/loader/kon2/src/display/vga.c b/loader/kon2/src/display/vga.c index 48201f584..78940b29b 100644 --- a/loader/kon2/src/display/vga.c +++ b/loader/kon2/src/display/vga.c @@ -32,6 +32,7 @@ */ #include <config.h> +#include <types.h> #ifdef HAS_VGA diff --git a/loader/kon2/src/errors.c b/loader/kon2/src/errors.c index 13069352e..5b73a1e69 100644 --- a/loader/kon2/src/errors.c +++ b/loader/kon2/src/errors.c @@ -25,6 +25,7 @@ * */ #include <config.h> +#include <types.h> #include <stdio.h> #include <errno.h> diff --git a/loader/kon2/src/fnld.c b/loader/kon2/src/fnld.c index 5ea59ad0b..c747d49d2 100644 --- a/loader/kon2/src/fnld.c +++ b/loader/kon2/src/fnld.c @@ -26,6 +26,7 @@ */ #include <config.h> +#include <types.h> #include <stdio.h> #include <stdlib.h> diff --git a/loader/kon2/src/term.c b/loader/kon2/src/term.c index 7133363ee..5e2b16ff9 100644 --- a/loader/kon2/src/term.c +++ b/loader/kon2/src/term.c @@ -45,6 +45,7 @@ #include <sys/wait.h> #include <config.h> +#include <types.h> #include <getcap.h> #include <defs.h> diff --git a/loader/kon2/src/vc.c b/loader/kon2/src/vc.c index e2f588fad..b60068b91 100644 --- a/loader/kon2/src/vc.c +++ b/loader/kon2/src/vc.c @@ -27,6 +27,7 @@ */ #include <config.h> +#include <types.h> #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/loader/kon2/src/vt.c b/loader/kon2/src/vt.c index df019e33d..106eefbce 100644 --- a/loader/kon2/src/vt.c +++ b/loader/kon2/src/vt.c @@ -25,6 +25,8 @@ * */ +#include <types.h> + #include <stdio.h> #include <unistd.h> #include <string.h> diff --git a/loader/lang.c b/loader/lang.c index d9f3c2d82..f03bce727 100644 --- a/loader/lang.c +++ b/loader/lang.c @@ -6,10 +6,8 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/kd.h> #include <sys/ioctl.h> #include <unistd.h> -#include <zlib.h> #include <glob.h> /* XXX rpmlib.h */ #include <dirent.h> /* XXX rpmlib.h */ @@ -21,7 +19,10 @@ #include "loader.h" #include "lang.h" #include "log.h" +#include "misc.h" #include "windows.h" +#include "isys/gzlib/gzlib.h" +#include "kickstart.h" #define errorWindow(String) \ newtWinMessage(_("Error"), _("OK"), String, strerror (errno)); @@ -52,13 +53,6 @@ static int aStringCmp(const void * a, const void * b) { return 1; } -static int simpleStringCmp(const void * a, const void * b) { - const char * first = *((const char **) a); - const char * second = *((const char **) b); - - return strcmp(first, second); -} - char * translateString(char * str) { unsigned int sum = 0, xor = 0; int len = 0; @@ -144,7 +138,7 @@ void loadLanguage (char * file, int flags) { sprintf(filename, "/etc/loader.tr"); } - stream = gzopen(file, "r"); + stream = gunzip_open(file); if (!stream) { newtWinMessage("Error", "OK", "Translation for %s is not available. " @@ -155,7 +149,7 @@ void loadLanguage (char * file, int flags) { sprintf(filename, "%s.tr", key); rc = installCpioFile(stream, filename, "/tmp/translation", 1); - gzclose(stream); + gunzip_close(stream); if (rc || access("/tmp/translation", R_OK)) { newtWinMessage("Error", "OK", "Cannot get translation file %s.\n", @@ -205,7 +199,7 @@ static int loadFont(char * fontFile, int flags) { #if 0 if (!FL_TESTING(flags)) { #endif - stream = gzopen("/etc/fonts.cgz", "r"); + stream = gunzip_open("/etc/fonts.cgz"); if (!stream) { newtWinMessage("Error", "OK", "Cannot open fonts: %s", strerror(errno)); @@ -213,7 +207,7 @@ static int loadFont(char * fontFile, int flags) { } rc = installCpioFile(stream, fontFile, "/tmp/font", 1); - gzclose(stream); + gunzip_close(stream); if (rc || access("/tmp/font", R_OK)) { return LOADER_ERROR; } @@ -273,34 +267,59 @@ int chooseLanguage(char ** lang, int flags) { char ** langs; int i; int english = 0; + int current = -1; + extern int continuing; + char * currentLangName = getenv("LANG"); + int numLangs = 0; + char * langPicked; if (!languages) loadLanguageList(flags); langs = alloca(sizeof(*langs) * (numLanguages + 1)); for (i = 0; i < numLanguages; i++) { + /* If we're running in kon, only offer languages which use the + Kon or default8x16 fonts. Don't display languages which require + Kon font if we have no way of providing it. */ + if (!haveKon && !strcmp(languages[i].font, "Kon")) + continue; + if (continuing && strcmp(languages[i].font, "Kon") && + continuing && strcmp(languages[i].font, "default8x16")) + continue; + if (!strncmp(languages[i].key, "en", 2)) - english = i; - langs[i] = languages[i].lang; + english = numLangs; + if (currentLangName && + !strcmp(languages[i].lc_all, currentLangName)) + current = numLangs; + + langs[numLangs++] = languages[i].lang; } - langs[i] = NULL; + langs[numLangs] = NULL; - choice = english; - - if (getenv("LANG")) { - for (choice = 0; choice < numLanguages; choice++) - if (!strcmp(languages[choice].lc_all, getenv("LANG"))) break; - if (choice == numLanguages) choice = 0; - } + if (current >= 0) + choice = current; + else + choice = english; newtWinMenu(_("Choose a Language"), _("What language should be used " "during the installation process?"), 40, 5, 5, 8, langs, &choice, _("OK"), NULL); - *lang = languages[choice].lc_all; + langPicked = langs[choice]; + for (i = 0; i < numLanguages; i++) { + if (!strcmp(langPicked, languages[i].lang)) { + *lang = languages[i].lc_all; + choice = i; + break; + } + } + + /* this can't happen */ + if (i == numLanguages) abort(); - if (choice == english) { + if (!strncmp(languages[choice].key, "en", 2)) { /* stick with the default (English) */ unsetenv("LANG"); unsetenv("LANGKEY"); @@ -334,7 +353,6 @@ int chooseLanguage(char ** lang, int flags) { } if (haveKon) { - extern int continuing; extern void stopNewt(void); if (!strcmp (languages[choice].font, "Kon") && !continuing) { @@ -353,9 +371,7 @@ int chooseLanguage(char ** lang, int flags) { /* load the language only if it is displayable */ /* If we need kon and have it, or if it's not kon or none, load the lang */ - if ((!strcmp(languages[choice].font, "Kon") && haveKon) || - (strcmp(languages[choice].font, "None") && - strcmp(languages[choice].font, "Kon"))) { + if ((strcmp(languages[choice].font, "None"))) { loadLanguage (NULL, flags); } else { newtWinMessage("Language Unavailable", "OK", @@ -364,6 +380,7 @@ int chooseLanguage(char ** lang, int flags) { "display of %s is possible.", languages[choice].lang, languages[choice].lang); } + if (languages[choice].map) loadFont(languages[choice].map, flags); @@ -392,7 +409,7 @@ static int loadKeymap(gzFile stream) { int magic; short keymap[NR_KEYS]; - if (gzread(stream, &magic, sizeof(magic)) != sizeof(magic)) { + if (gunzip_read(stream, &magic, sizeof(magic)) != sizeof(magic)) { logMessage("failed to read kmap magic: %s", strerror(errno)); return LOADER_ERROR; } @@ -402,7 +419,7 @@ static int loadKeymap(gzFile stream) { return LOADER_ERROR; } - if (gzread(stream, keymaps, sizeof(keymaps)) != sizeof(keymaps)) { + if (gunzip_read(stream, keymaps, sizeof(keymaps)) != sizeof(keymaps)) { logMessage("failed to read keymap header: %s", strerror(errno)); return LOADER_ERROR; } @@ -417,7 +434,7 @@ static int loadKeymap(gzFile stream) { for (kmap = 0; kmap < MAX_NR_KEYMAPS; kmap++) { if (!keymaps[kmap]) continue; - if (gzread(stream, keymap, sizeof(keymap)) != sizeof(keymap)) { + if (gunzip_read(stream, keymap, sizeof(keymap)) != sizeof(keymap)) { logMessage("failed to read keymap data: %s", strerror(errno)); close(console); return LOADER_ERROR; @@ -455,6 +472,8 @@ int chooseKeyboard(char ** keymap, char ** kbdtypep, int flags) { int i; char * defkbd = keymap ? *keymap : NULL; char *lang; + int argc; + char **argv; #ifdef __sparc__ #define KBDTYPE_SUN 0 @@ -484,7 +503,7 @@ int chooseKeyboard(char ** keymap, char ** kbdtypep, int flags) { } } } else -#endif +#endif /* kickstart sparc crap */ { char twelve = 12; int fd; @@ -501,7 +520,7 @@ int chooseKeyboard(char ** keymap, char ** kbdtypep, int flags) { } } } -#endif +#endif /* sparc */ if (!languages) loadLanguageList(flags); @@ -521,25 +540,25 @@ int chooseKeyboard(char ** keymap, char ** kbdtypep, int flags) { strcmp(kbdEntry->lang, getenv("LANG"))) kbdEntry++; if (kbdEntry->keyboard) defkbd = kbdEntry->keyboard; -#endif +#endif /* more sparc drain bamage */ } if (!defkbd) #ifdef __sparc__ if (kbdtype == KBDTYPE_SUN) defkbd = "sunkeymap"; else -#endif +#endif /* sparc drain bamage */ defkbd = "us"; - f = gzopen("/etc/keymaps.gz", "r"); + f = gunzip_open("/etc/keymaps.gz"); if (!f) { errorWindow("cannot open /etc/keymaps.gz: %s"); return LOADER_ERROR; } - if (gzread(f, &hdr, sizeof(hdr)) != sizeof(hdr)) { + if (gunzip_read(f, &hdr, sizeof(hdr)) != sizeof(hdr)) { errorWindow("failed to read keymaps header: %s"); - gzclose(f); + gunzip_close(f); return LOADER_ERROR; } @@ -547,14 +566,13 @@ int chooseKeyboard(char ** keymap, char ** kbdtypep, int flags) { i = hdr.numEntries * sizeof(*infoTable); infoTable = alloca(i); - if (gzread(f, infoTable, i) != i) { + if (gunzip_read(f, infoTable, i) != i) { errorWindow("failed to read keymap information: %s"); - gzclose(f); + gunzip_close(f); return LOADER_ERROR; } -#if 0 - if (kickstart) { + if (FL_KICKSTART(flags)) { if (!ksGetCommand(KS_CMD_KEYBOARD, NULL, &argc, &argv)) { if (argc < 2) { logMessage("no argument passed to keyboard " @@ -579,7 +597,6 @@ int chooseKeyboard(char ** keymap, char ** kbdtypep, int flags) { } } } -#endif if (num == -1 ) { #ifdef __sparc__ @@ -634,17 +651,17 @@ int chooseKeyboard(char ** keymap, char ** kbdtypep, int flags) { #endif for (i = 0; i < num; i++) { - if (gzread(f, buf, infoTable[i].size) != infoTable[i].size) { + if (gunzip_read(f, buf, infoTable[i].size) != infoTable[i].size) { logMessage("error reading %d bytes from file: %s", infoTable[i].size, strerror(errno)); - gzclose(f); + gunzip_close(f); rc = LOADER_ERROR; } } if (!rc) rc = loadKeymap(f); - gzclose(f); + gunzip_close(f); if (keymap) *keymap = strdup(infoTable[num].name); diff --git a/loader/loader.c b/loader/loader.c index 267e9ba9e..67190ebe2 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -9,7 +9,7 @@ * Erik Troan <ewt@redhat.com> * Matt Wilson <msw@redhat.com> * - * Copyright 1999 Red Hat, Inc. + * Copyright 1997 - 2002 Red Hat, Inc. * * This software may be freely redistributed under the terms of the GNU * public license. @@ -29,6 +29,7 @@ #include <net/if.h> #include <newt.h> #include <popt.h> +#include <syslog.h> #include <stdlib.h> #include <string.h> @@ -38,9 +39,12 @@ #include <sys/sysmacros.h> #include <sys/utsname.h> #include <unistd.h> -#include <zlib.h> #include <sys/vt.h> +#if defined(__i386__) || defined(__ia64__) || defined(__alpha__) +#include <linux/cdrom.h> +#endif + #include <popt.h> /* Need to tell loop.h what the actual dev_t type is. */ #undef dev_t @@ -57,6 +61,7 @@ #include "isys/imount.h" #include "isys/isys.h" #include "isys/probe.h" +#include "isys/gzlib/gzlib.h" #include "cdrom.h" #include "devices.h" @@ -64,6 +69,7 @@ #include "lang.h" #include "loader.h" #include "log.h" +#include "mediacheck.h" #include "misc.h" #include "modules.h" #include "net.h" @@ -79,6 +85,7 @@ int kon_main(int argc, char ** argv); static int mountLoopback(char * fsystem, char * mntpoint, char * device); static int umountLoopback(char * mntpoint, char * device); int copyDirectory(char * from, char * to); +static char * mediaCheckISODir(char *path); #if defined(__ia64__) static char * floppyDevice = "hda"; @@ -157,30 +164,31 @@ static int setupRamdisk(void) { done = 1; - f = gzopen("/etc/ramfs.img", "r"); + f = gunzip_open("/etc/ramfs.img"); if (f) { char buf[10240]; int i, j = 0; int fd; - fd = open("/dev/ram", O_RDWR); + fd = open(RAMDISK_DEVICE, O_RDWR); logMessage("copying file to fd %d", fd); - while ((i = gzread(f, buf, sizeof(buf))) > 0) { + while ((i = gunzip_read(f, buf, sizeof(buf))) > 0) { j += write(fd, buf, i); } logMessage("wrote %d bytes", j); close(fd); - gzclose(f); + gunzip_close(f); } - doPwMount("/dev/ram", "/tmp/ramfs", "ext2", 0, 0, NULL, NULL); + if (doPwMount(RAMDISK_DEVICE, "/tmp/ramfs", "ext2", 0, 0, NULL, NULL)) + logMessage("failed to mount ramfs image"); return 0; } -static void startNewt(int flags) { +void startNewt(int flags) { if (!newtRunning) { newtInit(); newtCls(); @@ -203,51 +211,44 @@ static void spawnShell(int flags) { pid_t pid; int fd; - if (FL_SERIAL(flags)) { - logMessage("not spawning a shell over a serial connection"); + if (FL_SERIAL(flags) || FL_NOSHELL(flags)) { + logMessage("not spawning a shell"); return; } - if (FL_NOSHELL(flags)) { - logMessage("not spawning a shell when noshell used"); + + fd = open("/dev/tty2", O_RDWR); + if (fd < 0) { + logMessage("cannot open /dev/tty2 -- no shell will be provided"); + return; + } else if (access("/bin/sh", X_OK)) { + logMessage("cannot open shell - /bin/sh doesn't exist"); return; } - if (!FL_TESTING(flags)) { - fd = open("/dev/tty2", O_RDWR); - if (fd < 0) { - logMessage("cannot open /dev/tty2 -- no shell will be provided"); - return; - } else if (access("/bin/sh", X_OK)) { - logMessage("cannot open shell - /bin/sh doesn't exist"); - return; - } - if (!(pid = fork())) { - dup2(fd, 0); - dup2(fd, 1); - dup2(fd, 2); - - close(fd); - setsid(); - if (ioctl(0, TIOCSCTTY, NULL)) { - logMessage("could not set new controlling tty"); - } + if (!(pid = fork())) { + dup2(fd, 0); + dup2(fd, 1); + dup2(fd, 2); - signal(SIGINT, SIG_DFL); - signal(SIGTSTP, SIG_DFL); + close(fd); + setsid(); + if (ioctl(0, TIOCSCTTY, NULL)) { + logMessage("could not set new controlling tty"); + } - setenv("LD_LIBRARY_PATH", - "/lib:/usr/lib:/usr/X11R6/lib:/mnt/usr/lib:" - "/mnt/sysimage/lib:/mnt/sysimage/usr/lib", 1); + signal(SIGINT, SIG_DFL); + signal(SIGTSTP, SIG_DFL); - execl("/bin/sh", "-/bin/sh", NULL); - logMessage("exec of /bin/sh failed: %s", strerror(errno)); - } + setenv("LD_LIBRARY_PATH", + "/lib:/usr/lib:/usr/X11R6/lib:/mnt/usr/lib:" + "/mnt/sysimage/lib:/mnt/sysimage/usr/lib", 1); - close(fd); - } else { - logMessage("not spawning a shell as we're in test mode"); + execl("/bin/sh", "-/bin/sh", NULL); + logMessage("exec of /bin/sh failed: %s", strerror(errno)); } + close(fd); + return; } @@ -413,6 +414,7 @@ int manualDeviceCheck(moduleInfoSet modInfo, moduleList modLoaded, int busProbe(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps modDeps, int justProbe, struct knownDevices * kd, int flags) { int i; + char modules[1024]; struct moduleInfo ** modList; if (FL_NOPROBE(flags)) return 0; @@ -423,33 +425,19 @@ int busProbe(moduleInfoSet modInfo, moduleList modLoaded, moduleDeps modDeps, if (detectHardware(modInfo, &modList, flags)) { logMessage("failed to scan pci bus!"); return 0; + } else if (modList && justProbe) { + for (i = 0; modList[i]; i++) + if (modList[i]->major == DRIVER_NET) + printf("%s\n", modList[i]->moduleName); } else if (modList) { - logMessage("found devices justProbe is %d", justProbe); + *modules = '\0'; for (i = 0; modList[i]; i++) { - if (justProbe) { - printf("%s\n", modList[i]->moduleName); - } else { - if (modList[i]->major == DRIVER_NET) { - mlLoadModule(modList[i]->moduleName, - modList[i]->locationID, - modLoaded, modDeps, NULL, modInfo, flags); - } - } + if (i) strcat(modules, ":"); + strcat(modules, modList[i]->moduleName); } - for (i = 0; !justProbe && modList[i]; i++) { - if (modList[i]->major == DRIVER_SCSI) { - startNewt(flags); - - scsiWindow(modList[i]->moduleName); - mlLoadModule(modList[i]->moduleName, - modList[i]->locationID, modLoaded, modDeps, - NULL, modInfo, flags); - sleep(1); - newtPopWindow(); - } - } + mlLoadModuleSet(modules, modLoaded, modDeps, modInfo, flags); kdFindScsiList(kd, 0); kdFindNetList(kd, 0); @@ -486,6 +474,52 @@ static int setupStage2Image(int fd, char * dest, int flags, return 0; } +/* returns the *absolute* path (malloced) to the #1 iso image */ +char * validIsoImages(char * dirName) { + DIR * dir; + struct dirent * ent; + char isoImage[1024]; + + if (!(dir = opendir(dirName))) { + newtWinMessage(_("Error"), _("OK"), + _("Failed to read directory %s: %s"), + dirName, strerror(errno)); + return 0; + } + + /* Walk through the directories looking for a Red Hat CD image. */ + errno = 0; + while ((ent = readdir(dir))) { + sprintf(isoImage, "%s/%s", dirName, ent->d_name); + + if (fileIsIso(isoImage)) { + errno = 0; + continue; + } + + if (mountLoopback(isoImage, "/tmp/loopimage", "loop0")) { + logMessage("failed to mount %s", isoImage); + errno = 0; + continue; + } + + if (!access("/tmp/loopimage/RedHat/base/hdstg1.img", F_OK)) { + umountLoopback("/tmp/loopimage", "loop0"); + break; + } + + umountLoopback("/tmp/loopimage", "loop0"); + + errno = 0; + } + + closedir(dir); + + if (!ent) return NULL; + + return strdup(isoImage); +} + #ifdef INCLUDE_LOCAL static int loadLocalImages(char * prefix, char * dir, int flags, char * device, char * mntpoint) { @@ -531,8 +565,7 @@ static char * setupIsoImages(char * device, char * type, char * dirName, int rc; char * url; char filespec[1024]; - DIR * dir; - struct dirent * ent; + char * path; logMessage("mounting device %s as %s", device, type); @@ -545,47 +578,36 @@ static char * setupIsoImages(char * device, char * type, char * dirName, return NULL; sprintf(filespec, "/tmp/hdimage/%s", dirName); - if (!(dir = opendir(filespec))) { - newtWinMessage(_("Error"), _("OK"), - _("Failed to read directory %s: %s"), - filespec, strerror(errno)); - umount("/tmp/hdimage"); - return NULL; - } - - /* Walk through the directories looking for a Red Hat CD image. */ - errno = 0; - while ((ent = readdir(dir))) { - sprintf(filespec, "/tmp/hdimage/%s/%s", dirName, ent->d_name); - - if (fileIsIso(filespec)) { - errno = 0; - continue; - } - if (mountLoopback(filespec, "/tmp/loopimage", "loop0")) { - errno = 0; - continue; + path = validIsoImages(filespec); + + if (path) { + rc = mountLoopback(path, "/tmp/loopimage", "loop0"); + if (!rc) { + rc = loadLocalImages("/tmp/loopimage", "/", flags, "loop1", + "/mnt/runtime"); + if (rc) { + newtWinMessage(_("Error"), _("OK"), + _("An error occured reading the install " + "from the ISO images. Please check your ISO " + "images and try again.")); + } } - rc = loadLocalImages("/tmp/loopimage", "/", flags, "loop1", - "/mnt/runtime"); - if (!rc) { - umountLoopback("/tmp/loopimage", "loop0"); - break; - } + umount("/tmp/loopimage"); - umountLoopback("/tmp/loopimage", "loop0"); + if (!FL_KICKSTART(flags) && FL_MEDIACHECK(flags)) + mediaCheckISODir("/mnt/source"); - errno = 0; + } else { + rc = 1; } - closedir(dir); umount("/tmp/hdimage"); - if (!ent) return NULL; + if (rc) return NULL; } - + url = malloc(50 + strlen(dirName ? dirName : "")); sprintf(url, "hd://%s:%s/%s", device, type, dirName ? dirName : "."); @@ -639,6 +661,7 @@ static int umountLoopback(char * mntpoint, char * device) { return 0; } + static int mountLoopback(char * fsystem, char * mntpoint, char * device) { struct loop_info loopInfo; int targfd, loopfd; @@ -760,6 +783,54 @@ static void useMntSourceUpdates() { } } + +/* XXX this ignores "location", which should be fixed */ +static char * mediaCheckISODir(char *path) { + DIR * dir; + struct dirent * ent; + char isoImage[1024]; + char tmpmessage[1024]; + int rc; + + + if (!(dir = opendir(path))) { + newtWinMessage(_("Error"), _("OK"), + _("Failed to read directory %s: %s"), + path, strerror(errno)); + return 0; + } + + /* Walk through the directories looking for a Red Hat CD images. */ + errno = 0; + while ((ent = readdir(dir))) { + sprintf(isoImage, "%s/%s", path, ent->d_name); + + if (fileIsIso(isoImage)) { + errno = 0; + continue; + } + + + snprintf(tmpmessage, sizeof(tmpmessage), + _("Would you like to perform an integrity " + "check of the ISO image %s?"), isoImage); + + rc = newtWinChoice(_("Integrity Check"), _("Test"), _("Skip"), + tmpmessage); + + if (rc == 2) { + closedir(dir); + return NULL; + } else { + mediaCheckFile(isoImage); + continue; + } + } + + closedir(dir); + return NULL; +} + #ifdef INCLUDE_LOCAL static char * mountHardDrive(struct installMethod * method, @@ -769,6 +840,11 @@ static char * mountHardDrive(struct installMethod * method, int rc; int fd; int i, j; +#if defined (__s390__) || defined (__s390x__) + static struct networkDeviceConfig netDev; + struct iurlinfo ui; + char * devName; +#endif struct { char name[20]; int type; @@ -787,11 +863,9 @@ static char * mountHardDrive(struct installMethod * method, static int ufsloaded; #endif - mlLoadModule("vfat", NULL, modLoaded, *modDepsPtr, - NULL, modInfo, flags); - while (!done) { numPartitions = 0; +#if !defined (__s390__) && !defined (__s390x__) for (i = 0; i < kd->numKnown; i++) { if (kd->known[i].class == CLASS_HD) { devMakeInode(kd->known[i].name, "/tmp/hddevice"); @@ -806,8 +880,8 @@ static char * mountHardDrive(struct installMethod * method, case BALKAN_PART_UFS: if (!ufsloaded) { ufsloaded = 1; - mlLoadModule("ufs", NULL, modLoaded, - *modDepsPtr, NULL, modInfo, + mlLoadModuleSet("ufs", modLoaded, + *modDepsPtr, modInfo, flags); } /* FALLTHROUGH */ @@ -855,6 +929,38 @@ static char * mountHardDrive(struct installMethod * method, continue; } +#else + /* s390 */ + memset(&ui, 0, sizeof(ui)); + memset(&netDev, 0, sizeof(netDev)); + netDev.isDynamic = 1; + i = ensureNetDevice(kd, modInfo, modLoaded, modDepsPtr, flags, &devName); + if (i) return NULL; + rc = readNetConfig(devName, &netDev, flags); + if (rc) { + if (!FL_TESTING(flags)) pumpDisableInterface(devName); + return NULL; + } + setupRemote(&ui); + for(c = 'a'; c <= 'z'; c++) { + for(i = 1; i < 4; i++) { + char dev[7]; + sprintf(dev, "dasd%c%d", c, i); + devMakeInode(dev, "/tmp/hddevice"); + fd = open("/tmp/hddevice", O_RDONLY); + if (fd >= 0) { + close(fd); + sprintf(partitions[numPartitions].name, "/dev/%s", dev); + partitions[numPartitions].type = BALKAN_PART_EXT2; + numPartitions++; + } + } + } + mlLoadModule("isofs", NULL, modLoaded, *modDepsPtr, + NULL, modInfo, flags); + +#endif + text = newtTextboxReflowed(-1, -1, _("What partition and directory on that partition hold the " "CD (iso9660) images for Red Hat Linux? If you don't " @@ -950,11 +1056,90 @@ static char * mountHardDrive(struct installMethod * method, } free(dir); +#if defined (__s390__) || defined (__s390x__) + writeNetInfo("/tmp/netinfo", &netDev, kd); +#endif return url; } +void ejectCdrom(void) { + int ejectfd; + + logMessage("ejecting /tmp/cdrom..."); + if ((ejectfd = open("/tmp/cdrom", O_RDONLY | O_NONBLOCK, 0)) >= 0) { + if (ioctl(ejectfd, CDROMEJECT, 0)) + logMessage("eject failed %d ", errno); + close(ejectfd); + } else { + logMessage("eject failed %d ", errno); + } +} + +/* XXX this ignores "location", which should be fixed */ +static char * mediaCheckCdrom(char *cddriver) { + int rc; + + devMakeInode(cddriver, "/tmp/cdrom"); + + do { + mediaCheckFile("/tmp/cdrom"); + + ejectCdrom(); + + rc = newtWinChoice(_("Media Check"), _("Test"), _("Continue"), + _("Please insert any additional media you " + "would like to test and press %s.\n\n" + "Otherwise insert CD #1 into your drive " + "and press %s to continue."), + _("Test"), _("Continue")); + + if (rc == 2) { + unlink("/tmp/cdrom"); + return NULL; + } else { + continue; + } + } while (1); + + return NULL; +} + +static void wrongCDMessage(void) { + newtWinMessage(_("Error"), _("OK"), + _("I could not find a Red Hat Linux " + "CDROM in any of your CDROM drives. Please insert " + "the Red Hat CD and press \"OK\" to retry.")); +} + +/* put mounts back and continue */ +static void mountCdromStage2(char *cddev) { + int gotcd1=0; + + devMakeInode(cddev, "/tmp/cdrom"); + do { + do { + if (doPwMount("/tmp/cdrom", "/mnt/source", + "iso9660", 1, 0, NULL, NULL)) { + ejectCdrom(); + wrongCDMessage(); + } else { + break; + } + } while (1); + + if (mountLoopback("/mnt/source/RedHat/base/stage2.img", + "/mnt/runtime", "loop0")) { + umount("/mnt/source"); + ejectCdrom(); + wrongCDMessage(); + } else { + gotcd1 = 1; + } + } while (!gotcd1); +} + /* XXX this ignores "location", which should be fixed */ static char * setupCdrom(struct installMethod * method, char * location, struct knownDevices * kd, @@ -981,12 +1166,36 @@ static char * setupCdrom(struct installMethod * method, if (!mountLoopback("/mnt/source/RedHat/base/stage2.img", "/mnt/runtime", "loop0")) { useMntSourceUpdates(); - + buf = malloc(200); sprintf(buf, "cdrom://%s/mnt/source", kd->known[i].name); + + /* check image(s) if not kickstart and requested */ + if (!FL_KICKSTART(flags) && FL_MEDIACHECK(flags)) { + + startNewt(flags); + rc = newtWinChoice(_("CD Found"), _("OK"), + _("Skip"), + _("We will now test your media before installing.\n\nChoose 'Skip' " + "if you would like to skip this test.")); + + if (rc != 2) { + + /* unmount CD now we've identified */ + /* a valid disc #1 is present */ + umount("/mnt/runtime"); + umountLoopback("/mnt/runtime", "loop0"); + umount("/mnt/source"); + + /* test CD(s) */ + mediaCheckCdrom(kd->known[i].name); + + /* remount stage2 from CD #1 and proceed */ + mountCdromStage2(kd->known[i].name); + } + } return buf; } - } umount("/mnt/source"); } @@ -1017,6 +1226,9 @@ static char * mountCdromImage(struct installMethod * method, char * location, struct knownDevices * kd, moduleInfoSet modInfo, moduleList modLoaded, moduleDeps * modDepsPtr, int flags) { + + /* first do media check if necessary */ + return setupCdrom(method, location, kd, modInfo, modLoaded, modDepsPtr, flags, 0, 1); } @@ -1113,15 +1325,22 @@ static char * mountNfsImage(struct installMethod * method, moduleInfoSet modInfo, moduleList modLoaded, moduleDeps * modDepsPtr, int flags) { static struct networkDeviceConfig netDev; + struct iurlinfo ui; char * devName; int i, rc; char * host = NULL; char * dir = NULL; char * fullPath; + char * path; + char * url = NULL; int stage = NFS_STAGE_IP; +/*XXX + mlLoadModuleSet("nfs", modLoaded, *modDepsPtr, modInfo, flags);*/ + initLoopback(); + memset(&ui, 0, sizeof(ui)); memset(&netDev, 0, sizeof(netDev)); netDev.isDynamic = 1; @@ -1136,6 +1355,11 @@ static char * mountNfsImage(struct installMethod * method, if (!FL_TESTING(flags)) pumpDisableInterface(devName); return NULL; } +#if defined (__s390__) || defined (__s390x__) + setupRemote(&ui); + host = ui.address; + dir = ui.prefix; +#endif stage = NFS_STAGE_NFS; break; @@ -1147,13 +1371,13 @@ static char * mountNfsImage(struct installMethod * method, break; case NFS_STAGE_MOUNT: + mlLoadModuleSet("nfs", modLoaded, *modDepsPtr, modInfo, flags); + if (FL_TESTING(flags)) { stage = NFS_STAGE_DONE; break; } - mlLoadModule("nfs", NULL, modLoaded, *modDepsPtr, NULL, modInfo, - flags); fullPath = alloca(strlen(host) + strlen(dir) + 2); sprintf(fullPath, "%s:%s", host, dir); @@ -1165,8 +1389,28 @@ static char * mountNfsImage(struct installMethod * method, if (!access("/mnt/source/RedHat/base/stage2.img", R_OK)) { if (!mountLoopback("/mnt/source/RedHat/base/stage2.img", "/mnt/runtime", "loop0")) { + rmdir("/mnt/source"); + symlink("/mnt/source", "/mnt/source"); useMntSourceUpdates(); stage = NFS_STAGE_DONE; + url = "nfs://mnt/source/."; + } + } else if ((path = validIsoImages("/mnt/source"))) { + useMntSourceUpdates(); + + if (mountLoopback(path, "/mnt/source2", "loop1")) + logMessage("failed to mount iso loopback!"); + else { + if (mountLoopback("/mnt/source2/RedHat/base/stage2.img", + "/mnt/runtime", "loop0")) { + logMessage("failed to mount install loopback!"); + } else { + stage = NFS_STAGE_DONE; + url = "nfsiso:/mnt/source"; + if (!FL_KICKSTART(flags) && FL_MEDIACHECK(flags)) + mediaCheckISODir("/mnt/source"); + + } } } else { umount("/mnt/source"); @@ -1179,7 +1423,7 @@ static char * mountNfsImage(struct installMethod * method, _("I could not mount that directory from the server")); } - break; + break; /* from switch */ } } @@ -1188,7 +1432,7 @@ static char * mountNfsImage(struct installMethod * method, free(host); free(dir); - return "nfs://mnt/source/."; + return url; } #endif @@ -1283,6 +1527,7 @@ static char * mountUrlImage(struct installMethod * method, char * url; char * login; char * finalPrefix; + int dir = 1; enum urlprotocol_t proto = !strcmp(method->name, "FTP") ? URL_METHOD_FTP : URL_METHOD_HTTP; @@ -1310,33 +1555,51 @@ static char * mountUrlImage(struct installMethod * method, if (!FL_TESTING(flags)) pumpDisableInterface(devName); return NULL; } +#if defined (__s390__) || defined (__s390x__) + if (dir == -1) { + return NULL; + } + setupRemote(&ui); +#endif stage = URL_STAGE_MAIN; + dir = 1; case URL_STAGE_MAIN: rc = urlMainSetupPanel(&ui, proto, &needsSecondary); - if (rc) - stage = URL_STAGE_IP; - else - stage = needsSecondary != ' ' ? - URL_STAGE_SECOND : URL_STAGE_FETCH; + if (rc) { + stage = URL_STAGE_IP; + dir = -1; + } else { + stage = needsSecondary != ' ' ? URL_STAGE_SECOND : URL_STAGE_FETCH; + dir = 1; + } break; case URL_STAGE_SECOND: rc = urlSecondarySetupPanel(&ui, proto); - stage = rc ? URL_STAGE_MAIN : URL_STAGE_FETCH; + if (rc) { + stage = URL_STAGE_MAIN; + dir = -1; + } else { + stage = URL_STAGE_FETCH; + dir = 1; + } break; case URL_STAGE_FETCH: if (FL_TESTING(flags)) { stage = URL_STAGE_DONE; + dir = 1; break; } - if (loadUrlImages(&ui, flags)) + if (loadUrlImages(&ui, flags)) { stage = URL_STAGE_MAIN; - else + dir = -1; + } else { stage = URL_STAGE_DONE; - + dir = 1; + } break; } } @@ -1414,8 +1677,15 @@ static char * doMountImage(char * location, free(class); } -#if defined(__alpha__) || defined(__ia64__) - for (i = 0; i < numMethods; i++) { +#if defined(__s390__) || defined(__s390x__) + #define STARTMETHOD 1 +#else + #define STARTMETHOD 0 +#endif + +#if defined(__alpha__) || defined(__ia64__) \ + || defined(__s390__ ) || defined(__s390x__) + for (i = ; i < numMethods; i++) { installNames[numValidMethods] = _(installMethods[i].name); validMethods[numValidMethods++] = i; } @@ -1471,9 +1741,9 @@ static char * doMountImage(char * location, Red Hat CD. If there is one there, just die happy */ if (!FL_EXPERT(flags)) { # endif - url = setupCdrom(NULL, location, kd, modInfo, modLoaded, modDepsPtr, - flags, 1, 1); - if (url) return url; + url = setupCdrom(NULL, location, kd, modInfo, modLoaded, modDepsPtr, + flags, 1, 1); + if (url) return url; } #endif /* defined (INCLUDE_LOCAL) || defined (__sparc__) */ @@ -1621,10 +1891,6 @@ static int kickstartDevices(struct knownDevices * kd, moduleInfoSet modInfo, ddi->mntDevice = fsDevice; } - if (!strcmp(ddi->fs, "vfat")) - mlLoadModule("vfat", NULL, modLoaded, *modDepsPtr, NULL, - modInfo, flags); - logMessage("looking for driver disk (%s, %s, %s)", ddi->fs, ddi->device, ddi->mntDevice); @@ -1677,7 +1943,7 @@ static int kickstartDevices(struct knownDevices * kd, moduleInfoSet modInfo, else optv = NULL; - rc = mlLoadModule(device, mi->locationID, modLoaded, + rc = mlLoadModule(device, modLoaded, *modDepsPtr, optv, modInfo, flags); if (optv) free(optv); @@ -1812,6 +2078,8 @@ static char * setupKickstart(char * location, struct knownDevices * kd, } } + chooseKeyboard(NULL, NULL, flags); + #ifdef INCLUDE_NETWORK if (ksType == KS_CMD_NFS || ksType == KS_CMD_URL) { startNewt(flags); @@ -1825,7 +2093,7 @@ static char * setupKickstart(char * location, struct knownDevices * kd, #ifdef INCLUDE_NETWORK if (ksType == KS_CMD_NFS) { int count = 0; - mlLoadModule("nfs", NULL, modLoaded, *modDepsPtr, NULL, modInfo, flags); + mlLoadModuleSet("nfs", modLoaded, *modDepsPtr, modInfo, flags); fullPath = alloca(strlen(host) + strlen(dir) + 2); sprintf(fullPath, "%s:%s", host, dir); @@ -1955,6 +2223,8 @@ static int parseCmdLineFlags(int flags, char * cmdLine, char ** ksSource, flags |= LOADER_FLAGS_NOSHELL; else if (!strcasecmp(argv[i], "lowres")) flags |= LOADER_FLAGS_LOWRES; + else if (!strcasecmp(argv[i], "mediacheck")) + flags |= LOADER_FLAGS_MEDIACHECK; else if (!strcasecmp(argv[i], "nofb")) flags |= LOADER_FLAGS_NOFB; else if (!strcasecmp(argv[i], "nousbstorage")) @@ -1969,8 +2239,6 @@ static int parseCmdLineFlags(int flags, char * cmdLine, char ** ksSource, flags |= LOADER_FLAGS_TEXT; else if (!strcasecmp(argv[i], "updates")) flags |= LOADER_FLAGS_UPDATES; - else if (!strcasecmp(argv[i], "upgrade")) - *instClass = "upgradeonly"; else if (!strncasecmp(argv[i], "class=", 6)) *instClass = argv[i] + 6; else if (!strcasecmp(argv[i], "isa")) @@ -2090,7 +2358,7 @@ int kickstartFromNfs(struct knownDevices * kd, char * location, logMessage("ks server: %s file: %s", ksPath, file); - mlLoadModule("nfs", NULL, modLoaded, *modDepsPtr, NULL, NULL, flags); + mlLoadModuleSet("nfs", modLoaded, *modDepsPtr, NULL, flags); if (doPwMount(ksPath, "/tmp/nfskd", "nfs", 1, 0, NULL, NULL)) { logMessage("failed to mount %s", ksPath); @@ -2174,7 +2442,7 @@ int kickstartFromHttp(struct knownDevices * kd, char * location, fd = urlinstStartTransfer(&ui, file, 1); if (fd < 0) { - logMessage("failed to retrieve http:/%s/%s", ksPath, file); + logMessage("failed to retrieve http:/%s/%s/%s", ui.address, ui.prefix, file); return 1; } @@ -2198,9 +2466,8 @@ int kickstartFromHardDrive(char * location, char * fileName; char * fullFn; - mlLoadModule("vfat", NULL, modLoaded, *modDepsPtr, NULL, NULL, flags); #ifdef __sparc__ - mlLoadModule("ufs", NULL, modLoaded, *modDepsPtr, NULL, NULL, flags); + mlLoadModuleSet("ufs", modLoaded, *modDepsPtr, NULL, flags); #endif fileName = strchr(source, '/'); @@ -2241,8 +2508,6 @@ int kickstartFromHardDrive(char * location, int kickstartFromFloppy(char * location, moduleList modLoaded, moduleDeps * modDepsPtr, int flags) { - mlLoadModule("vfat", NULL, modLoaded, *modDepsPtr, NULL, NULL, flags); - if (devMakeInode(floppyDevice, "/tmp/floppy")) return 1; @@ -2396,8 +2661,8 @@ void loadUfs(struct knownDevices *kd, moduleList modLoaded, for (j = 0; j < table.maxNumPartitions; j++) { if (table.parts[j].type == BALKAN_PART_UFS) { if (!ufsloaded) { - mlLoadModule("ufs", NULL, modLoaded, - *modDepsPtr, NULL, NULL, flags); + mlLoadModuleSet("ufs", modLoaded, + *modDepsPtr, NULL, flags); ufsloaded = 1; } } @@ -2417,13 +2682,8 @@ void loadUfs(struct knownDevices *kd, moduleList modLoaded, void setFloppyDevice(int flags) { #if defined(__i386__) || defined(__ia64__) struct device ** devices; - char line[256]; - const char * match = "Floppy drive(s): "; int foundFd0 = 0; int i = 0; - FILE * f; - - /*if (FL_TESTING(flags)) return;*/ logMessage("probing for floppy devices"); @@ -2453,8 +2713,7 @@ void setFloppyDevice(int flags) { static int usbInitialize(moduleList modLoaded, moduleDeps modDeps, moduleInfoSet modInfo, int flags) { struct device ** devices; - - if (FL_TESTING(flags)) return 0; + char * buf; if (FL_NOUSB(flags)) return 0; @@ -2468,12 +2727,17 @@ static int usbInitialize(moduleList modLoaded, moduleDeps modDeps, } logMessage("found USB controller %s", devices[0]->driver); - if (mlLoadModule(devices[0]->driver, NULL, modLoaded, modDeps, NULL, - modInfo, flags)) { + + if (mlLoadModuleSet(devices[0]->driver, modLoaded, modDeps, modInfo, + flags)) { logMessage("failed to insert usb module"); - return 1; + /* dont return, just keep going. */ + /* may have USB built into kernel */ + /* return 1; */ } + if (FL_TESTING(flags)) return 0; + if (doPwMount("/proc/bus/usb", "/proc/bus/usb", "usbdevfs", 0, 0, NULL, NULL)) logMessage("failed to mount device usbdevfs: %s", strerror(errno)); @@ -2481,12 +2745,12 @@ static int usbInitialize(moduleList modLoaded, moduleDeps modDeps, /* sleep so we make sure usb devices get properly initialized */ sleep(2); - mlLoadModule("hid", NULL, modLoaded, modDeps, NULL, modInfo, flags); - mlLoadModule("keybdev", NULL, modLoaded, modDeps, NULL, modInfo, flags); - - if (FL_NOUSBSTORAGE(flags)) return 0; - mlLoadModule("usb-storage", NULL, modLoaded, modDeps, NULL, modInfo, flags); + buf = alloca(40); + sprintf(buf, "hid:keybdev%s", + (FL_NOUSBSTORAGE(flags) ? "" : ":usb-storage")); + mlLoadModuleSet(buf, modLoaded, modDeps, modInfo, flags); sleep(1); + return 0; } @@ -2495,17 +2759,20 @@ static int usbInitialize(moduleList modLoaded, moduleDeps modDeps, static void usbInitializeMouse(moduleList modLoaded, moduleDeps modDeps, moduleInfoSet modInfo, int flags) { +#if !defined (__s390__) && !defined (__s390x__) + return; +#else if (FL_NOUSB(flags)) return; logMessage("looking for USB mouse..."); if (probeDevices(CLASS_MOUSE, BUS_USB, PROBE_ALL)) { logMessage("USB mouse found, loading mousedev module"); - if (mlLoadModule("mousedev", NULL, modLoaded, modDeps, NULL, modInfo, - flags)) { + if (mlLoadModuleSet("mousedev", modLoaded, modDeps, modInfo, flags)) { logMessage ("failed to loading mousedev module"); return; } } +#endif } @@ -2514,6 +2781,11 @@ static int agpgartInitialize(moduleList modLoaded, moduleDeps modDeps, struct device ** devices, *p; int i; +#if defined (__s390__) && defined (__s390x__) + /* obviously no agp on s/390 :) */ + return 0; +#else + if (FL_TESTING(flags)) return 0; logMessage("looking for video cards requiring agpgart module"); @@ -2536,8 +2808,8 @@ static int agpgartInitialize(moduleList modLoaded, moduleDeps modDeps, logMessage("found %s card requiring agpgart, loading module", p->driver+5); - if (mlLoadModule("agpgart", NULL, modLoaded, modDeps, NULL, - modInfo, flags)) { + if (mlLoadModuleSet("agpgart", modLoaded, modDeps, modInfo, + flags)) { logMessage("failed to insert agpgart module"); return 1; } else { @@ -2549,14 +2821,13 @@ static int agpgartInitialize(moduleList modLoaded, moduleDeps modDeps, } return 0; +#endif } static void scsiSetup(moduleList modLoaded, moduleDeps modDeps, moduleInfoSet modInfo, int flags, struct knownDevices * kd) { - mlLoadModule("sd_mod", NULL, modLoaded, modDeps, NULL, modInfo, flags); - mlLoadModule("sr_mod", NULL, modLoaded, modDeps, NULL, modInfo, - flags); + mlLoadModuleSet("sd_mod:sr_mod", modLoaded, modDeps, modInfo, flags); } static void ideSetup(moduleList modLoaded, moduleDeps modDeps, @@ -2564,7 +2835,7 @@ static void ideSetup(moduleList modLoaded, moduleDeps modDeps, struct knownDevices * kd) { /* This is fast enough that we don't need a screen to pop up */ - mlLoadModule("ide-cd", NULL, modLoaded, modDeps, NULL, modInfo, flags); + mlLoadModuleSet("ide-cd", modLoaded, modDeps, modInfo, flags); kdFindIdeList(kd, 0); } @@ -2591,6 +2862,7 @@ int main(int argc, char ** argv) { int i, rc; int flags = 0; int testing = 0; + int mediacheck = 0; char * lang = NULL; char * keymap = NULL; char * kbdtype = NULL; @@ -2611,6 +2883,7 @@ int main(int argc, char ** argv) { { "ksfile", '\0', POPT_ARG_STRING, &ksFile, 0 }, { "probe", '\0', POPT_ARG_NONE, &probeOnly, 0 }, { "test", '\0', POPT_ARG_NONE, &testing, 0 }, + { "mediacheck", '\0', POPT_ARG_NONE, &mediacheck, 0}, { 0, 0, 0, 0, 0 } }; @@ -2647,7 +2920,9 @@ int main(int argc, char ** argv) { flags |= LOADER_FLAGS_SERIAL; } - if (!FL_TESTING(flags)) { + /* don't start modules.conf if continuing as there could be modules + already loaded from a driver disk */ + if ((!FL_TESTING(flags)) && !continuing) { int fd; fd = open("/tmp/modules.conf", O_WRONLY | O_CREAT, 0666); @@ -2680,6 +2955,12 @@ int main(int argc, char ** argv) { } if (testing) flags |= LOADER_FLAGS_TESTING; + if (mediacheck) flags |= LOADER_FLAGS_MEDIACHECK; + +#if defined (__s390__) && !defined (__s390x__) + flags |= LOADER_FLAGS_NOSHELL | LOADER_FLAGS_NOUSB; +#endif + flags = parseCmdLineFlags(flags, cmdLine, &ksSource, &ksNetDevice, &instClass); @@ -2697,6 +2978,8 @@ int main(int argc, char ** argv) { } openLog(FL_TESTING(flags)); + if (!FL_TESTING(flags)) + openlog("loader", 0, LOG_LOCAL0); checkForRam(flags); @@ -2705,9 +2988,11 @@ int main(int argc, char ** argv) { modDeps = mlNewDeps(); mlLoadDeps(&modDeps, "/modules/modules.dep"); - mlLoadModule("cramfs", NULL, modLoaded, modDeps, NULL, modInfo, flags); -#if 0 - mlLoadModule("ramfs", NULL, modLoaded, modDeps, NULL, modInfo, flags); + mlLoadModuleSet("cramfs:vfat", modLoaded, modDeps, modInfo, flags); + + +#if defined (__s390__) || defined (__s390x__) + mlLoadModule("loop", NULL, modLoaded, modDeps, NULL, modInfo, flags); #endif if (!continuing) { @@ -2757,6 +3042,10 @@ int main(int argc, char ** argv) { kdFindNetList(&kd, continuing ? 0 : CODE_PCMCIA); #endif + /* we have to explicitly read this to let libkudzu know we want to + merge in future tables rather then replace the initial one */ + pciReadDrivers("/modules/pcitable"); + if (!continuing) { if ((access("/proc/bus/pci/devices", R_OK) && access("/proc/openprom", R_OK)) || FL_MODDISK(flags)) { @@ -2821,14 +3110,15 @@ int main(int argc, char ** argv) { return 1; } - kickstartNetwork(&ksNetDevice, &netDev, NULL, flags); - writeNetInfo("/tmp/netinfo", &netDev, &kd); + if (!FL_TESTING(flags)) { + kickstartNetwork(&ksNetDevice, &netDev, NULL, flags); + writeNetInfo("/tmp/netinfo", &netDev, &kd); + } - stopNewt(); -#if 0 - beTelnet(); -#endif - startNewt(flags); + if (!beTelnet(flags)) { + flags |= LOADER_FLAGS_TEXT | LOADER_FLAGS_NOSHELL; + haveKon = 0; + } } #endif @@ -2857,10 +3147,7 @@ int main(int argc, char ** argv) { "/modules/pcitable"); #ifndef __sparc__ - /* we need to keep stage1 modules around to reload usb-storage. - increases our memory footprint a little :( */ - mkdir("/modules/stage1", 0755); - rename("/modules/modules.cgz", "/modules/stage1/modules.cgz"); + unlink("/modules/modules.cgz"); symlink("../mnt/runtime/modules/modules.cgz", "/modules/modules.cgz"); @@ -2912,6 +3199,23 @@ int main(int argc, char ** argv) { busProbe(modInfo, modLoaded, modDeps, 0, &kd, flags); + /* look for hard drives; if there aren't any warn the user and + let him add drivers manually */ + for (i = 0; i < kd.numKnown; i++) + if (kd.known[i].class == CLASS_HD) break; + + if (i == kd.numKnown) { + int rc; + + startNewt(flags); + rc = newtWinChoice(_("Warning"), _("Yes"), _("No"), + _("No hard drives have been found. You probably need to " + "manually choose device drivers for the installation to " + "succeed. Would you like to select drivers now?")); + + if (rc != 2) flags |= LOADER_FLAGS_ISA; + } + if (((access("/proc/bus/pci/devices", R_OK) && access("/proc/openprom", R_OK)) || FL_ISA(flags) || FL_NOPROBE(flags)) && !ksFile) { @@ -2927,13 +3231,9 @@ int main(int argc, char ** argv) { /* We must look for cards which require the agpgart module */ agpgartInitialize(modLoaded, modDeps, modInfo, flags); - mlLoadModule("raid0", NULL, modLoaded, modDeps, NULL, modInfo, flags); - mlLoadModule("raid1", NULL, modLoaded, modDeps, NULL, modInfo, flags); - mlLoadModule("raid5", NULL, modLoaded, modDeps, NULL, modInfo, flags); - mlLoadModule("msdos", NULL, modLoaded, modDeps, NULL, modInfo, flags); - mlLoadModule("vfat", NULL, modLoaded, modDeps, NULL, modInfo, flags); - mlLoadModule("ext3", NULL, modLoaded, modDeps, NULL, modInfo, flags); - mlLoadModule("reiserfs", NULL, modLoaded, modDeps, NULL, modInfo, flags); + mlLoadModuleSet("raid0:raid1:raid5:msdos:ext3:reiserfs:jfs:xfs:lvm-mod", + modLoaded, modDeps, modInfo, flags); + usbInitializeMouse(modLoaded, modDeps, modInfo, flags); @@ -3076,4 +3376,3 @@ int main(int argc, char ** argv) { return 1; } - diff --git a/loader/loader.h b/loader/loader.h index e6d526b9f..a27495c4e 100644 --- a/loader/loader.h +++ b/loader/loader.h @@ -28,7 +28,8 @@ #define LOADER_FLAGS_TELNETD (1 << 22) #define LOADER_FLAGS_NOPASS (1 << 23) #define LOADER_FLAGS_KSHTTP (1 << 24) -#define LOADER_FLAGS_NOUSBSTORAGE (1 << 25) +#define LOADER_FLAGS_MEDIACHECK (1 << 25) +#define LOADER_FLAGS_NOUSBSTORAGE (1 << 26) #define FL_TESTING(a) ((a) & LOADER_FLAGS_TESTING) #define FL_EXPERT(a) ((a) & LOADER_FLAGS_EXPERT) @@ -55,8 +56,18 @@ #define FL_TELNETD(a) ((a) & LOADER_FLAGS_TELNETD) #define FL_NOPASS(a) ((a) & LOADER_FLAGS_NOPASS) #define FL_KSHTTP(a) ((a) & LOADER_FLAGS_KSHTTP) +#define FL_MEDIACHECK(a) ((a) & LOADER_FLAGS_MEDIACHECK) #define FL_NOUSBSTORAGE(a) ((a) & LOADER_FLAGS_NOUSBSTORAGE) #define CODE_PCMCIA 1 +#if !defined(__s390__) && !defined(__s390x__) +#define RAMDISK_DEVICE "/dev/ram" +#else +#define RAMDISK_DEVICE "/dev/ram2" +#endif + +void startNewt(int flags); +void stopNewt(void); + void setFloppyDevice(int flags); diff --git a/loader/md5.c b/loader/md5.c new file mode 100644 index 000000000..fe032ebba --- /dev/null +++ b/loader/md5.c @@ -0,0 +1,256 @@ +/* + * $Id$ + * + * This code implements the MD5 message-digest algorithm. + * The algorithm is due to Ron Rivest. This code was + * written by Colin Plumb in 1993, no copyright is claimed. + * This code is in the public domain; do with it what you wish. + * + * Equivalent code is available from RSA Data Security, Inc. + * This code has been tested against that, and is equivalent, + * except that you don't need to include two pages of legalese + * with every copy. + * + * To compute the message digest of a chunk of bytes, declare an + * MD5Context structure, pass it to MD5Init, call MD5Update as + * needed on buffers full of bytes, and then call MD5Final, which + * will fill a supplied 16-byte array with the digest. + * + */ + +#include <string.h> +#include "md5.h" + +#ifndef HIGHFIRST +#define byteReverse(buf, len) /* Nothing */ +#else +static void byteReverse(unsigned char *buf, unsigned longs); + +#ifndef ASM_MD5 +/* + * Note: this code is harmless on little-endian machines. + */ +static void byteReverse(unsigned char *buf, unsigned longs) +{ + uint32 t; + do { + t = (uint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 | + ((unsigned) buf[1] << 8 | buf[0]); + *(uint32 *) buf = t; + buf += 4; + } while (--longs); +} +#endif +#endif + +/* + * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious + * initialization constants. + */ +void MD5_Init(struct MD5Context *ctx) +{ + ctx->buf[0] = 0x67452301U; + ctx->buf[1] = 0xefcdab89U; + ctx->buf[2] = 0x98badcfeU; + ctx->buf[3] = 0x10325476U; + + ctx->bits[0] = 0; + ctx->bits[1] = 0; +} + +/* + * Update context to reflect the concatenation of another buffer full + * of bytes. + */ +void MD5_Update(struct MD5Context *ctx, unsigned const char *buf, unsigned len) +{ + uint32 t; + + /* Update bitcount */ + + t = ctx->bits[0]; + if ((ctx->bits[0] = t + ((uint32) len << 3)) < t) + ctx->bits[1]++; /* Carry from low to high */ + ctx->bits[1] += len >> 29; + + t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */ + + /* Handle any leading odd-sized chunks */ + + if (t) { + unsigned char *p = (unsigned char *) ctx->in + t; + + t = 64 - t; + if (len < t) { + memcpy(p, buf, len); + return; + } + memcpy(p, buf, t); + byteReverse(ctx->in, 16); + MD5_Transform(ctx->buf, (uint32 *) ctx->in); + buf += t; + len -= t; + } + /* Process data in 64-byte chunks */ + + while (len >= 64) { + memcpy(ctx->in, buf, 64); + byteReverse(ctx->in, 16); + MD5_Transform(ctx->buf, (uint32 *) ctx->in); + buf += 64; + len -= 64; + } + + /* Handle any remaining bytes of data. */ + + memcpy(ctx->in, buf, len); +} + +/* + * Final wrapup - pad to 64-byte boundary with the bit pattern + * 1 0* (64-bit count of bits processed, MSB-first) + */ +void MD5_Final(unsigned char digest[16], struct MD5Context *ctx) +{ + unsigned count; + unsigned char *p; + + /* Compute number of bytes mod 64 */ + count = (ctx->bits[0] >> 3) & 0x3F; + + /* Set the first char of padding to 0x80. This is safe since there is + always at least one byte free */ + p = ctx->in + count; + *p++ = 0x80; + + /* Bytes of padding needed to make 64 bytes */ + count = 64 - 1 - count; + + /* Pad out to 56 mod 64 */ + if (count < 8) { + /* Two lots of padding: Pad the first block to 64 bytes */ + memset(p, 0, count); + byteReverse(ctx->in, 16); + MD5_Transform(ctx->buf, (uint32 *) ctx->in); + + /* Now fill the next block with 56 bytes */ + memset(ctx->in, 0, 56); + } else { + /* Pad block to 56 bytes */ + memset(p, 0, count - 8); + } + byteReverse(ctx->in, 14); + + /* Append length in bits and transform */ + ((uint32 *) ctx->in)[14] = ctx->bits[0]; + ((uint32 *) ctx->in)[15] = ctx->bits[1]; + + MD5_Transform(ctx->buf, (uint32 *) ctx->in); + byteReverse((unsigned char *) ctx->buf, 4); + memcpy(digest, ctx->buf, 16); + memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */ +} + +#ifndef ASM_MD5 + +/* The four core functions - F1 is optimized somewhat */ + +/* #define F1(x, y, z) (x & y | ~x & z) */ +#define F1(x, y, z) (z ^ (x & (y ^ z))) +#define F2(x, y, z) F1(z, x, y) +#define F3(x, y, z) (x ^ y ^ z) +#define F4(x, y, z) (y ^ (x | ~z)) + +/* This is the central step in the MD5 algorithm. */ +#define MD5STEP(f, w, x, y, z, data, s) \ + ( w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x ) + +/* + * The core of the MD5 algorithm, this alters an existing MD5 hash to + * reflect the addition of 16 longwords of new data. MD5Update blocks + * the data and converts bytes into longwords for this routine. + */ +void MD5_Transform(uint32 buf[4], uint32 const in[16]) +{ + register uint32 a, b, c, d; + + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478U, 7); + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756U, 12); + MD5STEP(F1, c, d, a, b, in[2] + 0x242070dbU, 17); + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceeeU, 22); + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0fafU, 7); + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62aU, 12); + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613U, 17); + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501U, 22); + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8U, 7); + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7afU, 12); + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1U, 17); + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7beU, 22); + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122U, 7); + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193U, 12); + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438eU, 17); + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821U, 22); + + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562U, 5); + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340U, 9); + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51U, 14); + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aaU, 20); + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105dU, 5); + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453U, 9); + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681U, 14); + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8U, 20); + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6U, 5); + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6U, 9); + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87U, 14); + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14edU, 20); + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905U, 5); + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8U, 9); + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9U, 14); + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8aU, 20); + + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942U, 4); + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681U, 11); + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122U, 16); + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380cU, 23); + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44U, 4); + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9U, 11); + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60U, 16); + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70U, 23); + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6U, 4); + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127faU, 11); + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085U, 16); + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05U, 23); + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039U, 4); + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5U, 11); + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8U, 16); + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665U, 23); + + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244U, 6); + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97U, 10); + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7U, 15); + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039U, 21); + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3U, 6); + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92U, 10); + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47dU, 15); + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1U, 21); + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4fU, 6); + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0U, 10); + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314U, 15); + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1U, 21); + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82U, 6); + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235U, 10); + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bbU, 15); + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391U, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; +} + +#endif diff --git a/loader/md5.h b/loader/md5.h new file mode 100644 index 000000000..bacfb534a --- /dev/null +++ b/loader/md5.h @@ -0,0 +1,25 @@ + +#ifndef MD5_H +#define MD5_H + +#include <sys/types.h> + +typedef u_int32_t uint32; + +struct MD5Context { + uint32 buf[4]; + uint32 bits[2]; + unsigned char in[64]; +}; + +void MD5_Init(struct MD5Context *); +void MD5_Update(struct MD5Context *, unsigned const char *, unsigned); +void MD5_Final(unsigned char digest[16], struct MD5Context *); + +/* + * This is needed to make RSAREF happy on some MS-DOS compilers. + */ + +typedef struct MD5Context MD5_CTX; + +#endif /* MD5_H */ diff --git a/loader/mediacheck.c b/loader/mediacheck.c new file mode 100644 index 000000000..4c93b7a64 --- /dev/null +++ b/loader/mediacheck.c @@ -0,0 +1,284 @@ +/* simple program to check implanted md5sum in an iso 9660 image */ +/* Copyright 2001 Red Hat, Inc. */ +/* Michael Fulbright msf@redhat.com */ + +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <fcntl.h> +#include <string.h> +#include <newt.h> + +#include "md5.h" + +#define APPDATA_OFFSET 883 +#define SIZE_OFFSET 84 + +#define MAX(x, y) ((x > y) ? x : y) +#define MIN(x, y) ((x < y) ? x : y) + +/* number of sectors to ignore at end of iso when computing sum */ +#define SKIPSECTORS 15 + +typedef void (*checkCallback)(void *, long long offset); + +struct progressCBdata { + newtComponent scale; + newtComponent label; +}; + +#ifdef TESTING +#define _(x) (x) +#else +#include "lang.h" +#endif + +/* finds primary volume descriptor and returns info from it */ +/* mediasum must be a preallocated buffer at least 33 bytes long */ +int parsepvd(int isofd, char *mediasum, long long *isosize) { + unsigned char buf[2048]; + long long offset; + unsigned char *p; + + if (lseek(isofd, (off_t)(16L * 2048L), SEEK_SET) == -1) + return ((long long)-1); + + offset = (16L * 2048L); + for (;1;) { + read(isofd, buf, 2048); + if (buf[0] == 1) + /* found primary volume descriptor */ + break; + else if (buf[0] == 255) + /* hit end and didn't find primary volume descriptor */ + return ((long long)-1); + offset += 2048L; + } + + /* read out md5sum */ + memcpy(mediasum, buf + APPDATA_OFFSET + 13, 32); + mediasum[32] = '\0'; + + for (p=mediasum; *p; p++) + if (*p != ' ') + break; + + /* if the md5sum was all spaces, we didn't find md5sum */ + if (!*p) + return -1; + + /* get isosize */ + *isosize = (buf[SIZE_OFFSET]*0x1000000+buf[SIZE_OFFSET+1]*0x10000 + + buf[SIZE_OFFSET+2]*0x100 + buf[SIZE_OFFSET+3]) * 2048LL; + + return offset; +} + +/* returns -1 if no checksum encoded in media, 0 if no match, 1 if match */ +/* mediasum is the sum encoded in media, computedsum is one we compute */ +/* both strings must be pre-allocated at least 33 chars in length */ +int checkmd5sum(int isofd, char *mediasum, char *computedsum, + checkCallback cb, void *cbdata) { + int nread; + int i; + int appdata_start_offset, appdata_end_offset; + int nattempt; + unsigned int bufsize = 32768; + unsigned char md5sum[16]; + unsigned int len; + unsigned char *buf; + long long isosize, offset, pvd_offset, apoff; + MD5_CTX md5ctx; + + if ((pvd_offset = parsepvd(isofd, mediasum, &isosize)) < 0) + return -1; + + /* printf("Mediasum = %s\n",mediasum); */ + + /* rewind, compute md5sum */ + lseek(isofd, 0L, SEEK_SET); + + MD5_Init(&md5ctx); + + offset = 0; + apoff = pvd_offset + APPDATA_OFFSET; + + buf = malloc(bufsize * sizeof(unsigned char)); + while (offset < isosize - SKIPSECTORS*2048) { + nattempt = MIN(isosize - SKIPSECTORS*2048 - offset, bufsize); + + /* printf("%lld %lld %lld %d\n", offset, isosize, isosize-SKIPSECTORS*2048, nattempt); */ + + nread = read(isofd, buf, nattempt); + if (nread <= 0) + break; + + /* overwrite md5sum we implanted with original data */ + if (offset < apoff && offset+nread >= apoff) { + appdata_start_offset = apoff - offset; + appdata_end_offset = MIN(appdata_start_offset+MIN(nread, 512), + offset + nread - apoff); + len = appdata_end_offset - appdata_start_offset; + memset(buf+appdata_start_offset, ' ', len); + } else if (offset >= apoff && offset+nread < apoff + 512) { + appdata_start_offset = 0; + appdata_end_offset = nread; + len = appdata_end_offset - appdata_start_offset; + memset(buf+appdata_start_offset, ' ', len); + } else if (offset < apoff + 512 && offset+nread >= apoff + 512) { + appdata_start_offset = 0; + appdata_end_offset = apoff + 512 - offset; + len = appdata_end_offset - appdata_start_offset; + memset(buf+appdata_start_offset, ' ', len); + } + + MD5_Update(&md5ctx, buf, nread); + offset = offset + nread; + if (cb) + cb(cbdata, offset); + } + + if (cb) + cb(cbdata, isosize); + + sleep(1); + + free(buf); + + MD5_Final(md5sum, &md5ctx); + + *computedsum = '\0'; + for (i=0; i<16; i++) { + char tmpstr[4]; + snprintf (tmpstr, 4, "%02x", md5sum[i]); + strcat(computedsum, tmpstr); + } + + /* printf("mediasum, computedsum = %s %s\n", mediasum, computedsum); */ + + if (strcmp(mediasum, computedsum)) + return 0; + else + return 1; + } + + +static void readCB(void *co, long long pos) { + struct progressCBdata *data = co; + static int tick = 0; + char tickmark[2] = "-"; + char * ticks = "-\\|/"; + + newtScaleSet(data->scale, pos); + tick++; + if (tick > 399) tick = 0; + *tickmark = ticks[tick / 100]; + + newtLabelSetText(data->label, tickmark); + newtRefresh(); +} + +int doMediaCheck(int isofd, char *mediasum, char *computedsum, long long *isosize) { + struct progressCBdata data; + newtComponent t, f, scale, label; + int rc; + int llen; + + if (parsepvd(isofd, mediasum, isosize) < 0) { + newtWinMessage(_("Error"), _("OK"), + _("Unable to read the disc checksum from the " + "primary volume descriptor. This probably " + "means the disc was created without adding the " + "checksum.")); + return -1; + } + + newtCenteredWindow(35, 6, _("Media Check")); + t = newtTextbox(1, 1, 24, 3, NEWT_TEXTBOX_WRAP); + newtTextboxSetText(t, _("Checking media now...")); + llen = strlen(_("Checking media now...")); + + label = newtLabel(llen+2, 1, "-"); + f = newtForm(NULL, NULL, 0); + newtFormAddComponent(f, t); + scale = newtScale(3, 3, 25, *isosize); + newtFormAddComponent(f, scale); + + newtDrawForm(f); + newtRefresh(); + + data.scale = scale; + data.label = label; + + rc = checkmd5sum(isofd, mediasum, computedsum, readCB, &data); + + newtFormDestroy(f); + newtPopWindow(); + + return rc; +} + +int mediaCheckFile(char *file) { + int isofd; + int rc; + char *result; + unsigned char mediasum[33], computedsum[33]; + char tmpstr[256]; + long long isosize; + newtComponent t, f; + + isofd = open(file, O_RDONLY); + + if (isofd < 0) { + newtWinMessage(_("Error"), _("OK"), _("Unable to find install image " + "%s"), file); + return -1; + } + + rc = doMediaCheck(isofd, mediasum, computedsum, &isosize); + + close(isofd); + + /* printf("isosize = %lld\n", isosize); + printf("%s\n%s\n", mediasum, computedsum);*/ + + if ( rc == 0) + result = _("FAIL.\n\nIt is not recommended to use this media."); + else if (rc > 0) + result = _("PASS.\n\nIt is OK to install from this media."); + else + result = _("NA.\n\nNo checksum information available, unable to verify media."); + + newtCenteredWindow(60, 10, _("Media Check Result")); + t = newtTextbox(4, 1, 52 , 5, NEWT_TEXTBOX_WRAP); + snprintf(tmpstr, sizeof(tmpstr), _("The media check is complete, the " + "result is: %s"), result); + newtTextboxSetText(t, tmpstr); + f = newtForm(NULL, NULL, 0); + newtFormAddComponent(f, t); + newtFormAddComponent(f, newtButton(26, 6, _("OK"))); + + newtRunForm(f); + newtFormDestroy(f); + newtPopWindow(); + return rc; +} + +#ifdef TESTING + +int main(int argc, char **argv) { + int rc; + + if (argc < 2) { + printf("Usage: checkisomd5 <isofilename>\n\n"); + exit(1); + } + + newtInit(); + newtCls(); + rc = mediaCheckFile(argv[1]); + newtFinished(); +} +#endif diff --git a/loader/mediacheck.h b/loader/mediacheck.h new file mode 100644 index 000000000..c7c0c4d46 --- /dev/null +++ b/loader/mediacheck.h @@ -0,0 +1,5 @@ +/* simple program to check implanted md5sum in an iso 9660 image */ +/* Copyright 2001 Red Hat, Inc. */ +/* Michael Fulbright msf@redhat.com */ + +int mediaCheckFile(char *file); diff --git a/loader/minilibc.h b/loader/minilibc.h index c774e92b2..32bf3307a 100644 --- a/loader/minilibc.h +++ b/loader/minilibc.h @@ -20,6 +20,18 @@ extern char ** _environ; extern int errno; +/* from /usr/include/bits/sigset.h */ +/* A `sigset_t' has a bit for each signal. */ + +#define _SIGSET_NWORDS (1024 / (8 * sizeof (unsigned long int))) +typedef struct + { + unsigned long int __val[_SIGSET_NWORDS]; + } __sigset_t; + +/* from /usr/include/signal.h */ +typedef __sigset_t sigset_t; + /* Aieee, gcc 2.95+ creates a stub for posix_types.h on i386 which brings glibc headers in and thus makes __FD_SET etc. not defined with 2.3+ kernels. */ #define _FEATURES_H 1 diff --git a/loader/misc.c b/loader/misc.c index 568df2ea3..059197419 100644 --- a/loader/misc.c +++ b/loader/misc.c @@ -59,3 +59,10 @@ char * readLine(FILE * f) { return strdup(buf); } +int simpleStringCmp(const void * a, const void * b) { + const char * first = *((const char **) a); + const char * second = *((const char **) b); + + return strcmp(first, second); +} + diff --git a/loader/misc.h b/loader/misc.h index ce4b39b73..905f31a71 100644 --- a/loader/misc.h +++ b/loader/misc.h @@ -4,5 +4,7 @@ int copyFile(char * source, char * dest); int copyFileFd(int infd, char * dest); char * readLine(FILE * f); +int simpleStringCmp(const void * a, const void * b); +int mediaCheckFile(char *file); #endif diff --git a/loader/mkctype.c b/loader/mkctype.c new file mode 100644 index 000000000..c8d34b9c3 --- /dev/null +++ b/loader/mkctype.c @@ -0,0 +1,47 @@ +#include <ctype.h> +#include <stdio.h> + +int main(int argc, char ** argv) { + int i; + + printf("#include <sys/types.h>\n\n"); + + printf("static const unsigned short int __ctype_b_internal[] = {"); + + for (i = -128; i < 256; i++) { + if (!(i % 8)) { + printf("\n"); + } + + printf("\t0x%x,", __ctype_b[i]); + } + + printf("\n};\n\n"); + printf("const unsigned short int * __ctype_b = __ctype_b_internal + 128;\n\n"); + + printf("const int __ctype_toupper_internal[] = {"); + for (i = -128; i < 256; i++) { + if (!(i % 8)) { + printf("\n"); + } + + printf("\t0x%x,", __ctype_toupper[i]); + } + + printf("\n};\n\n"); + printf("const int * __ctype_toupper = __ctype_toupper_internal + 128;\n\n"); + + printf("const int __ctype_tolower_internal[] = {"); + for (i = -128; i < 256; i++) { + if (!(i % 8)) { + printf("\n"); + } + + printf("\t0x%x,", __ctype_tolower[i]); + } + + printf("\n};\n\n"); + printf("const int * __ctype_tolower = __ctype_tolower_internal + 128;\n\n"); + + return 0; +}; diff --git a/loader/module-info b/loader/module-info index 800a5b8e6..6d3fc5d1b 100644 --- a/loader/module-info +++ b/loader/module-info @@ -489,6 +489,16 @@ yellowfin eth "Packet Engines G-NIC PCI Gigabit" +# S/390 stuff +netiucv + eth + "S/390 Inter-User Communication Vehicle (iucv)" + +ctc + eth + "S/390 Channel to Channel" + + # NOT YET MODULARIZED! #znet # eth @@ -577,6 +587,10 @@ dmx319ld scsi_hostadapter "Domex DMX3191D" +dpt_i2o + scsi_hostadapter + "Adaptec I2O RAID Driver" + dtc scsi_hostadapter "DTC 3180/3280" @@ -688,7 +702,11 @@ qlogicfas qla1280 scsi_hostadapter - "Qlogic 1280" + "Qlogic 1280/12160" + +qla2x00 + scsi_hostadapter + "Qlogic 2x00" qla2200 scsi_hostadapter diff --git a/loader/modules.c b/loader/modules.c index 3ae3ab406..6897ff95f 100644 --- a/loader/modules.c +++ b/loader/modules.c @@ -11,22 +11,61 @@ #include <sys/utsname.h> #include <sys/wait.h> #include <unistd.h> -#include <zlib.h> #include "isys/imount.h" #include "isys/isys.h" +#include "isys/cpio.h" #include "lang.h" #include "loader.h" #include "log.h" +#include "misc.h" #include "modules.h" #include "devices.h" +#include "windows.h" struct moduleDependency_s { char * name; char ** deps; }; +struct extractedModule { + char * path; + char * location; +}; + +static int ethCount(void); +static int scsiCount(void); +int mlReadLoadedList(moduleList * mlp); +void mlFreeList(moduleList ml); +moduleDeps mlNewDeps(void); +int mlLoadDeps(moduleDeps * moduleDepListPtr, const char * path); +char ** tsortModules(moduleList modLoaded, moduleDeps ml, char ** args, + int depth, char *** listPtr, int * listSizePtr); +static int loadModule(const char * modName, struct extractedModule * path, + moduleList modLoaded, char ** args, + moduleInfoSet modInfo, int flags); +static char * filterDriverModules(struct driverDiskInfo * ddi, + char * const * modNames); +static struct extractedModule * extractModules (struct driverDiskInfo * ddi, + char * const * modNames, struct extractedModule * oldPaths); +static int doLoadModules(const char * origModNames, moduleList modLoaded, + moduleDeps modDeps, moduleInfoSet modInfo, int flags, + const char * argModule, char ** args); +int mlLoadModule(const char * modName, + moduleList modLoaded, moduleDeps modDeps, char ** args, + moduleInfoSet modInfo, int flags); +int mlLoadModuleSet(const char * modNames, + moduleList modLoaded, moduleDeps modDeps, + moduleInfoSet modInfo, int flags); +char ** mlGetDeps(moduleDeps modDeps, const char * modName); +int mlModuleInList(const char * modName, moduleList list); +int mlWriteConfModules(moduleList list, int fd); +int simpleRemoveLoadedModule(const char * modName, moduleList modLoaded, + int flags); +int reloadUnloadedModule(char * modName, void * location, + moduleList modLoaded, char ** args, int flags); + static int ethCount(void) { int fd; char buf[16384]; @@ -69,7 +108,6 @@ static int scsiCount(void) { return count; } - int mlReadLoadedList(moduleList * mlp) { int fd; char * start; @@ -100,7 +138,7 @@ int mlReadLoadedList(moduleList * mlp) { ml->mods[ml->numModules].path = NULL; ml->mods[ml->numModules].weLoaded = 0; *end = ' '; - ml->numModules++; + /*ml->numModules++;*/ start = strchr(end, '\n'); if (start) start++; } @@ -216,77 +254,125 @@ int mlLoadDeps(moduleDeps * moduleDepListPtr, const char * path) { return 0; } -static void removeExtractedModule(char * path) { - char * fn = alloca(strlen(path) + 20); +/* this leaks memory if their is a loop in the modules. oh well. */ +char ** tsortModules(moduleList modLoaded, moduleDeps ml, char ** args, + int depth, char *** listPtr, int * listSizePtr) { + int listSize; + char ** list; + char ** next; + char ** deps; + + if (!depth) { + int count; + + listSize = 5; + list = malloc((listSize + 1) * sizeof(*list)); + *list = NULL; + + listPtr = &list; + listSizePtr = &listSize; + + for (deps = args, count = 0; *deps; deps++, count++); + } else { + list = *listPtr; + listSize = *listSizePtr; + } + + if (depth++ > 100) { + return NULL; + } + + while (*args) { + /* don't load it twice */ + next = list; + while (*next && strcmp(*next, *args)) next++; + + if (*next || mlModuleInList(*args, modLoaded)) { + args++; + continue; + } + + /* load everything this depends on */ + deps = mlGetDeps(ml, *args); + if (deps) { + if (!tsortModules(modLoaded, ml, deps, depth, listPtr, listSizePtr)) + return NULL; + + list = *listPtr; + listSize = *listSizePtr; + } + + /* add this to the list */ + next = list; + while (*next) next++; + + if ((next - list) >= listSize) { + int count = next - list; + + listSize += 10; + /* leave room for a NULL */ + list = realloc(list, sizeof(*list) * (listSize + 1)); + + *listSizePtr = listSize; + *listPtr = list; + + next = list + count; + } - sprintf(fn, "%s/modules.cgz", path); - unlink(fn); - rmdir(path); + next[0] = *args; + next[1] = NULL; + + args++; + } + + return list; } -int mlLoadModule(char * modName, void * location, moduleList modLoaded, - moduleDeps modDeps, char ** args, moduleInfoSet modInfo, - int flags) { - moduleDeps dep; - char ** nextDep, ** argPtr; +static int loadModule(const char * modName, struct extractedModule * path, + moduleList modLoaded, char ** args, + moduleInfoSet modInfo, int flags) { char fileName[200]; int rc, i; - char ** arg, ** newArgs; + char ** arg, ** newArgs, ** argPtr; struct moduleInfo * mi = NULL; int ethDevices = -1; pid_t child; int status; - char * path = NULL; - int needUmount = 0; + int popWindow = 0; - if (mlModuleInList(modName, modLoaded)) { + if (mlModuleInList(modName, modLoaded)) return 0; - } if (modInfo && (mi = isysFindModuleInfo(modInfo, modName))) { if (mi->major == DRIVER_NET && mi->minor == DRIVER_MINOR_ETHERNET) { ethDevices = ethCount(); } - } - for (dep = modDeps; dep->name && strcmp(dep->name, modName); - dep++); - - if (dep && dep->deps) { - nextDep = dep->deps; - while (*nextDep) { - if (mlLoadModule(*nextDep, location, modLoaded, modDeps, NULL, - modInfo, flags) && location) - mlLoadModule(*nextDep, NULL, modLoaded, modDeps, NULL, - modInfo, flags); - nextDep++; + if (mi->major == DRIVER_SCSI) { + startNewt(flags); + scsiWindow(modName); + popWindow = 1; } } - if (location) - path = extractModule(location, modName); - sprintf(fileName, "%s.o", modName); for (argPtr = args; argPtr && *argPtr; argPtr++) { strcat(fileName, " "); strcat(fileName, *argPtr); } - sprintf(fileName, "%s.o", modName); - if (modInfo && (mi = isysFindModuleInfo(modInfo, modName))) { if (mi->major == DRIVER_SCSI) { + /* XXX this shouldn't happen before every load but instead + * just before loading a module group */ simpleRemoveLoadedModule("usb-storage", modLoaded, flags); } } if (FL_TESTING(flags)) { - logMessage("would have insmod %s", fileName); + logMessage("would have insmod %s", path); rc = 0; } else { - logMessage("going to insmod %s (path is %s)", fileName, - path ? path : "NULL"); - if (!(child = fork())) { int fd = open("/dev/tty3", O_RDWR); @@ -295,7 +381,7 @@ int mlLoadModule(char * modName, void * location, moduleList modLoaded, dup2(fd, 2); close(fd); - rc = insmod(fileName, path, args); + rc = insmod(path->path, NULL, args); _exit(rc); } @@ -309,20 +395,17 @@ int mlLoadModule(char * modName, void * location, moduleList modLoaded, } if (modInfo && (strncmp(modName, "usb-storage", 11) != 0) && (mi = isysFindModuleInfo(modInfo, modName))) { - if (mi->major == DRIVER_SCSI) { - reloadUnloadedModule("usb-storage", NULL, modLoaded, NULL, flags); + if (mi->major == DRIVER_SCSI) { + reloadUnloadedModule("usb-storage", NULL, modLoaded, NULL, flags); setFloppyDevice(flags); - } + } } - - if (needUmount) - umount(path); if (!rc) { modLoaded->mods[modLoaded->numModules].name = strdup(modName); modLoaded->mods[modLoaded->numModules].weLoaded = 1; - /* path is malloced by extractModule() */ - modLoaded->mods[modLoaded->numModules].path = path; + modLoaded->mods[modLoaded->numModules].path = + path->location ? strdup(path->location) : NULL; modLoaded->mods[modLoaded->numModules].firstDevNum = -1; modLoaded->mods[modLoaded->numModules].lastDevNum = -1; modLoaded->mods[modLoaded->numModules].written = 0; @@ -351,127 +434,343 @@ int mlLoadModule(char * modName, void * location, moduleList modLoaded, } modLoaded->mods[modLoaded->numModules++].args = newArgs; - /* */ - if (!FL_TESTING(flags)) { - int fd; - - fd = open("/tmp/modules.conf", O_WRONLY | O_CREAT | O_APPEND, - 0666); - if (fd == -1) { - logMessage("error appending to /tmp/modules.conf: %s\n", - strerror(errno)); - } else { - mlWriteConfModules(modLoaded, fd); + } + + if (popWindow) { + sleep(1); + newtPopWindow(); + } + + return rc; +} + +static char * filterDriverModules(struct driverDiskInfo * ddi, + char * const * modNames) { + struct utsname un; + gzFile from; + gzFile to; + int first = 1; + int fd; + char * buf; + struct stat sb; + int rc; + int failed; + char * toPath; + char * chptr; + char ** pattern, ** p; + int i; + + uname(&un); + /* strip off BOOT, -SMP, whatever */ + chptr = un.release + strlen(un.release) - 1; + while (!isdigit(*chptr)) chptr--; + *(chptr + 1) = '\0'; + + for (i = 0; modNames[i]; i++) ; + pattern = alloca((i + 1) * sizeof(*pattern)); + + for (i = 0, p = pattern; modNames[i]; i++, p++) { + *p = alloca(strlen(modNames[i]) + strlen(un.release) + 5); + sprintf(*p, "%s*/%s.o", un.release, modNames[i]); + logMessage("extracting pattern %s%s%s", *p, + ddi->title ? " from " : "", + ddi->title ? ddi->title : ""); + } + *p = NULL; + + if (ddi->device) + devMakeInode(ddi->device, ddi->mntDevice); + + while (1) { + failed = 0; + + if (doPwMount(ddi->mntDevice, "/tmp/drivers", ddi->fs, 1, 0, + NULL, NULL)) + failed = 1; + + if (failed && !first) { + newtWinMessage(_("Error"), _("OK"), + _("Failed to mount driver disk: %s."), strerror(errno)); + } else if (!failed) { + if ((fd = open("/tmp/drivers/rhdd-6.1", O_RDONLY)) < 0) + failed = 1; + if (!failed) { + fstat(fd, &sb); + buf = malloc(sb.st_size + 1); + read(fd, buf, sb.st_size); + if (buf[sb.st_size - 1] == '\n') + sb.st_size--; + buf[sb.st_size] = '\0'; close(fd); + + failed = strcmp(buf, ddi->title); + free(buf); + } + + if (failed && !first) { + umount("/tmp/drivers"); + newtWinMessage(_("Error"), _("OK"), + _("The wrong diskette was inserted.")); } } - } else { - if (path) removeExtractedModule(path); - free(path); - } - return rc; + if (!failed) { + from = gunzip_open("/tmp/drivers/modules.cgz"); + toPath = malloc(strlen(modNames[0]) + 30); + sprintf(toPath, "/tmp/modules/%s", modNames[0]); + mkdirChain(toPath); + strcat(toPath, "/modules.cgz"); + to = gzip_open(toPath, O_TRUNC | O_RDWR | O_CREAT, 0600); + + /* This message isn't good, but it'll do. */ + winStatus(50, 3, _("Loading"), _("Loading %s driver..."), + modNames[0]); + + myCpioFilterArchive(from, to, pattern); + + newtPopWindow(); + + gunzip_close(from); + gunzip_close(to); + umount("/tmp/drivers"); + + return toPath; + } + + first = 0; + + if (ddi->device) + eject(ddi->device); + + rc = newtWinChoice(_("Driver Disk"), _("OK"), _("Cancel"), + _("Please insert the %s driver disk now."), ddi->title); + if (rc == 2) return NULL; + } } -/* simple removal of a loaded module which is going to be reloaded. - * Note that this does NOT modify the modLoaded struct at all - */ -int simpleRemoveLoadedModule(const char * modName, moduleList modLoaded, - int flags) { - int rc, status; - pid_t child; +static struct extractedModule * extractModules (struct driverDiskInfo * ddi, + char * const * modNames, struct extractedModule * oldPaths) { + gzFile fd; + char * ballPath; + struct cpioFileMapping * map; + int i, numMaps; + char * const * m; + struct utsname u; + int rc; + const char * failedFile; + char fn[255]; + struct stat sb; - if (!mlModuleInList(modName, modLoaded)) { - return 0; - } - - if (FL_TESTING(flags)) { - logMessage("would have rmmod %s", modName); - rc = 0; + /* this needs to know about modules64.cgz for sparc */ + + uname(&u); + + if (ddi) { + logMessage("looking for drivers on driver disk"); + ballPath = filterDriverModules(ddi, modNames); } else { - logMessage("going to rmmod %s", modName); - if (!(child = fork())) { - int fd = open("/dev/tty3", O_RDWR); + ballPath = strdup("/modules/modules.cgz"); + } - dup2(fd, 0); - dup2(fd, 1); - dup2(fd, 2); - close(fd); + fd = gunzip_open(ballPath); + if (!fd) { + logMessage("failed to open %s", ballPath); + free(ballPath); + return NULL; + } + free(ballPath); - execl("/sbin/rmmod", "/sbin/rmmod", modName, NULL); - _exit(rc); + for (m = modNames, i = 0; *m; i++, m++); + + map = alloca(sizeof(*map) * i); + memset(map, 0, sizeof(*map) * i); + if (!oldPaths) + /* +1 NULL terminates this list */ + oldPaths = calloc(i + 1, sizeof(*oldPaths)); + + for (m = modNames, i = 0, numMaps = 0; *m; m++, i++) { + if (!oldPaths[i].path) { + map[numMaps].archivePath = alloca(strlen(u.release) + + strlen(*m) + 25); + sprintf(map[numMaps].archivePath, "%s/%s.o", u.release, *m); + map[numMaps].fsPath = alloca(10 + strlen(*m)); + sprintf(map[numMaps].fsPath, "/tmp/%s.o", *m); + unlink(map[numMaps].fsPath); + map[numMaps].mapFlags = CPIO_MAP_PATH; + numMaps++; } + } - waitpid(child, &status, 0); - - if (!WIFEXITED(status) || WEXITSTATUS(status)) { - rc = 1; - } else { - rc = 0; + /* nothing to do */ + if (!numMaps) { + gunzip_close(fd); + return oldPaths; + } + + qsort(map, numMaps, sizeof(*map), myCpioFileMapCmp); + rc = myCpioInstallArchive(fd, map, numMaps, NULL, NULL, &failedFile); + + gunzip_close(fd); + + for (m = modNames, i = 0, numMaps = 0; *m; m++, i++) { + if (!oldPaths[i].path) { + /* can't trust map; the order changed thanks to qsort */ + sprintf(fn, "/tmp/%s.o", modNames[i]); + if (!stat(fn, &sb)) { + if (ddi) + logMessage("module %s found on driver disk %s (%d bytes)", + modNames[i], ddi->title, sb.st_size); + oldPaths[i].path = strdup(fn); + /* null otherwise from calloc() */ + if (ddi) + oldPaths[i].location = strdup(ballPath); + } + numMaps++; } } - return rc; -} -/* simple reinsertion of a module; just looks for the module and reloads it - * if we think it was already loaded - */ -int reloadUnloadedModule(char * modName, void * location, moduleList modLoaded, - char ** args, int flags) { - char fileName[200]; - int rc, status; - pid_t child; - char * path = NULL; - char ** argPtr; + return oldPaths; +} - if (!mlModuleInList(modName, modLoaded)) { - return 0; +static int doLoadModules(const char * origModNames, moduleList modLoaded, + moduleDeps modDeps, moduleInfoSet modInfo, int flags, + const char * argModule, char ** args) { + char * modNames; + char * end, * start, * next; + char ** initialList; + int i; + char ** list, ** l; + struct extractedModule * paths, * p; + struct moduleInfo * mi; + char items[1024] = ""; + + start = modNames = alloca(strlen(origModNames) + 1); + strcpy(modNames, origModNames); + + next = start, i = 1; + while (*next) { + if (*next == ':') i++; + next++; } - if (location) { - path = extractModule(location, modName); - } else { - path = malloc(25); - sprintf(path, "/modules/stage1/"); + + initialList = alloca(sizeof(*initialList) * (i + 1)); + + i = 0; + while (start) { + next = end = strchr(start, ':'); + if (next) *end = '\0', next++; + + if (mlModuleInList(start, modLoaded)) { + /* already loaded */ + start = next; + continue; + } + + initialList[i++] = start; + + start = next; } + initialList[i] = NULL; - sprintf(fileName, "%s.o", modName); - for (argPtr = args; argPtr && *argPtr; argPtr++) { - strcat(fileName, " "); - strcat(fileName, *argPtr); + list = tsortModules(modLoaded, modDeps, initialList, 0, NULL, NULL); + if (!list) { + logMessage("found loop in module dependencies; not inserting anything"); + return 1; } - sprintf(fileName, "%s.o", modName); + for (i = 0; list[i]; i++) { + strcat(items, " "); + strcat(items, list[i]); + } - if (FL_TESTING(flags)) { - logMessage("would have insmod %s", fileName); - rc = 0; - } else { - logMessage("going to insmod %s (path is %s)", fileName, - path ? path : "NULL"); + logMessage("modules to insert%s", items); - if (!(child = fork())) { - int fd = open("/dev/tty3", O_RDWR); + paths = NULL; + if (modInfo) { + for (i = 0; list[i]; i++) { + if (paths && paths[i].path) continue; + mi = isysFindModuleInfo(modInfo, list[i]); - dup2(fd, 0); - dup2(fd, 1); - dup2(fd, 2); - close(fd); + if (mi && mi->locationID) + paths = extractModules(mi->locationID, list, paths); + } + } - rc = insmod(fileName, path, args); - _exit(rc); + paths = extractModules(NULL, list, paths); + i = 0; + if (!paths) { + logMessage("no modules found -- aborting insertion"); + i++; + } else { + *items = '\0'; + + /* if any modules weren't found, holler */ + for (l = list, p = paths; *l && p; l++, p++) { + if (!p->path) { + if (*items) strcat(items, " "); + strcat(items, *l); + i++; + } } - waitpid(child, &status, 0); + if (*items) logMessage("module(s) %s not found", items); + } - if (!WIFEXITED(status) || WEXITSTATUS(status)) { - rc = 1; + /* insert the modules now */ + for (l = list, p = paths; paths && *l; l++, p++) { + if (p->path && loadModule(*l, p, modLoaded, + (argModule && !strcmp(argModule, *l)) ? args : NULL, + modInfo, flags)) { + logMessage("failed to insert %s", *p); + } else if (p->path) { + logMessage("inserted %s", p->path); + } + } + + if (!FL_TESTING(flags)) { + int fd; + + fd = open("/tmp/modules.conf", O_WRONLY | O_CREAT | O_APPEND, + 0666); + if (fd == -1) { + logMessage("error appending to /tmp/modules.conf: %s\n", + strerror(errno)); } else { - rc = 0; + mlWriteConfModules(modLoaded, fd); + close(fd); } } - logMessage("reloadModule returning %d", rc); - return rc; + for (p = paths; p->path; p++) { + unlink(p->path); + free(p->path); + if (p->location) free(p->location); + } + + free(paths); + free(list); + + logMessage("load module set done"); + + return i; +} + +/* loads a single module (preloading and dependencies), passing "args" to + the module as its argument */ +int mlLoadModule(const char * modName, + moduleList modLoaded, moduleDeps modDeps, char ** args, + moduleInfoSet modInfo, int flags) { + return doLoadModules(modName, modLoaded, modDeps, modInfo, flags, + modName, args); +} + +/* loads a : separated list of modules. the arg only applies to the + first module in the list */ +int mlLoadModuleSet(const char * modNames, + moduleList modLoaded, moduleDeps modDeps, + moduleInfoSet modInfo, int flags) { + return doLoadModules(modNames, modLoaded, modDeps, modInfo, flags, + NULL, NULL); } char ** mlGetDeps(moduleDeps modDeps, const char * modName) { @@ -502,7 +801,9 @@ int mlWriteConfModules(moduleList list, int fd) { int scsiNum; int ethNum; int trNum = 0; + int iucvNum = 0; char ** arg; + char *iucvopt; if (!list) return 0; @@ -539,6 +840,8 @@ int mlWriteConfModules(moduleList list, int fd) { strcat(buf2, "\nalias "); } strcat(buf, buf2); + if(!strstr(lm->name, "iucv")) + iucvNum++; } break; @@ -568,6 +871,114 @@ int mlWriteConfModules(moduleList list, int fd) { write(fd, buf, strlen(buf)); } } - + if (iucvNum) { + iucvopt = getenv("IUCV"); + if (iucvopt && *iucvopt) { + sprintf(buf, "options netiucv %s\n", iucvopt); + write(fd, buf, strlen(buf)); + } + } return 0; } + +/* simple removal of a loaded module which is going to be reloaded. + * Note that this does NOT modify the modLoaded struct at all + */ +int simpleRemoveLoadedModule(const char * modName, moduleList modLoaded, + int flags) { + int status, rc = 0; + pid_t child; + + if (!mlModuleInList(modName, modLoaded)) { + return 0; + } + + if (FL_TESTING(flags)) { + logMessage("would have rmmod %s", modName); + rc = 0; + } else { + logMessage("going to rmmod %s", modName); + if (!(child = fork())) { + int fd = open("/dev/tty3", O_RDWR); + + dup2(fd, 0); + dup2(fd, 1); + dup2(fd, 2); + close(fd); + + execl("/sbin/rmmod", "/sbin/rmmod", modName, NULL); + _exit(rc); + } + + waitpid(child, &status, 0); + + if (!WIFEXITED(status) || WEXITSTATUS(status)) { + rc = 1; + } else { + rc = 0; + } + } + return rc; +} + +/* simple reinsertion of a module; just looks for the module and reloads it + * if we think it was already loaded + */ +int reloadUnloadedModule(char * modName, void * location, + moduleList modLoaded, char ** args, int flags) { + char fileName[200]; + int rc, status; + pid_t child; + struct extractedModule * path; + char ** argPtr; + char * list[2]; + + if (!mlModuleInList(modName, modLoaded)) { + return 0; + } + + list[0] = modName; + list[1] = NULL; + + if (location) + path = extractModules(location, tsortModules(modLoaded, NULL, list, 0, NULL, NULL), NULL); + + sprintf(fileName, "%s.o", modName); + for (argPtr = args; argPtr && *argPtr; argPtr++) { + strcat(fileName, " "); + strcat(fileName, *argPtr); + } + + sprintf(fileName, "%s.o", modName); + + if (FL_TESTING(flags)) { + logMessage("would have insmod %s", fileName); + rc = 0; + } else { + logMessage("going to insmod %s", fileName); + + if (!(child = fork())) { + int fd = open("/dev/tty3", O_RDWR); + + dup2(fd, 0); + dup2(fd, 1); + dup2(fd, 2); + close(fd); + + rc = insmod(fileName, NULL, args); + _exit(rc); + } + + waitpid(child, &status, 0); + + if (!WIFEXITED(status) || WEXITSTATUS(status)) { + rc = 1; + } else { + rc = 0; + } + } + + logMessage("reloadModule returning %d", rc); + return rc; +} + diff --git a/loader/modules.h b/loader/modules.h index cf41aeee9..ab3e1b280 100644 --- a/loader/modules.h +++ b/loader/modules.h @@ -27,16 +27,22 @@ int mlReadLoadedList(moduleList * list); void mlFreeList(moduleList list); int mlLoadDeps(moduleDeps * moduleDepList, const char * path); moduleDeps mlNewDeps(void); -int mlLoadModule(char * modName, void * location, moduleList modLoaded, - moduleDeps modDeps, char ** args, moduleInfoSet modInfo, - int flags); + +int mlLoadModuleSet(const char * origModNames, moduleList modLoaded, + moduleDeps modDeps, moduleInfoSet modInfo, + int flags); + +int mlLoadModule(const char * origModNames, moduleList modLoaded, + moduleDeps modDeps, char ** args, moduleInfoSet modInfo, + int flags); + char ** mlGetDeps(moduleDeps modDeps, const char * modName); int mlModuleInList(const char * modName, moduleList list); int mlWriteConfModules(moduleList list, int fd); int simpleRemoveLoadedModule(const char * modName, moduleList modLoaded, int flags); -int reloadUnloadedModule(char * modName, void * location, moduleList modLoaded, - char ** args, int flags); +int reloadUnloadedModule(char * modName, void * location, + moduleList modLoaded, char ** args, int flags); #endif diff --git a/loader/net.c b/loader/net.c index 08d037cc1..e3d677616 100644 --- a/loader/net.c +++ b/loader/net.c @@ -28,8 +28,8 @@ #include <stdlib.h> #include <string.h> -#ifdef __STANDALONE__ #include <netdb.h> +#ifdef __STANDALONE__ #include <libintl.h> #include <locale.h> @@ -446,48 +446,55 @@ int readNetConfig(char * device, struct networkDeviceConfig * cfg, int flags) { strcpy(newCfg.dev.device, device); newCfg.isDynamic = 0; env = getenv("IPADDR"); - if (env) { - inet_aton(env, &newCfg.dev.ip); + if (env && *env) { + if(inet_aton(env, &newCfg.dev.ip)) newCfg.dev.set |= PUMP_INTFINFO_HAS_IP; } env = getenv("NETMASK"); - if (env) { - inet_aton(env, &newCfg.dev.netmask); + if (env && *env) { + if(inet_aton(env, &newCfg.dev.netmask)) newCfg.dev.set |= PUMP_INTFINFO_HAS_NETMASK; } env = getenv("GATEWAY"); - if (env) { - inet_aton(env, &newCfg.dev.gateway); + if (env && *env) { + if(inet_aton(env, &newCfg.dev.gateway)) newCfg.dev.set |= PUMP_NETINFO_HAS_GATEWAY; } env = getenv("NETWORK"); - if (env) { - inet_aton(env, &newCfg.dev.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; + } if (!strncmp(newCfg.dev.device, "ctc", 3)) { - env = getenv("REMIP"); - if (env) { - inet_aton(env, &newCfg.dev.broadcast); - newCfg.dev.set |= PUMP_INTFINFO_HAS_BROADCAST; - } - } else { - env = getenv("BROADCAST"); - if (env) { - inet_aton(env, &newCfg.dev.broadcast); - newCfg.dev.set |= PUMP_INTFINFO_HAS_BROADCAST; - } + env = getenv("REMIP"); + if (env && *env) { + if(inet_aton(env, &newCfg.dev.gateway)) + newCfg.dev.set |= PUMP_NETINFO_HAS_GATEWAY; + } + } + env = getenv("BROADCAST"); + if (env && *env) { + if(inet_aton(env, &newCfg.dev.broadcast)) + newCfg.dev.set |= PUMP_INTFINFO_HAS_BROADCAST; } #endif /* s390 */ #ifdef __STANDALONE__ if (!newCfg.isDynamic) #endif - cfg->dev = newCfg.dev; cfg->isDynamic = newCfg.isDynamic; + memcpy(&cfg->dev,&newCfg.dev,sizeof(newCfg.dev)); fillInIpInfo(cfg); +#if !defined(__s390__) && !defined(__s390x__) if (!(cfg->dev.set & PUMP_NETINFO_HAS_GATEWAY)) { if (*c.gw && inet_aton(c.gw, &addr)) { cfg->dev.gateway = addr; @@ -502,7 +509,6 @@ int readNetConfig(char * device, struct networkDeviceConfig * cfg, int flags) { } } -#if !defined(__s390__) && !defined(__s390x__) newtPopWindow(); #endif if (!FL_TESTING(flags)) { @@ -518,11 +524,13 @@ int readNetConfig(char * device, struct networkDeviceConfig * cfg, int flags) { } int configureNetwork(struct networkDeviceConfig * dev) { +#if !defined(__s390__) && !defined(__s390x__) pumpSetupInterface(&dev->dev); if (dev->dev.set & PUMP_NETINFO_HAS_GATEWAY) pumpSetupDefaultGateway(&dev->dev.gateway); +#endif return 0; } @@ -555,8 +563,14 @@ int writeNetInfo(const char * fn, struct networkDeviceConfig * dev, fprintf(f, "BOOTPROTO=static\n"); fprintf(f, "IPADDR=%s\n", inet_ntoa(dev->dev.ip)); fprintf(f, "NETMASK=%s\n", inet_ntoa(dev->dev.netmask)); - if (dev->dev.set & PUMP_NETINFO_HAS_GATEWAY) - fprintf(f, "GATEWAY=%s\n", inet_ntoa(dev->dev.gateway)); + if (dev->dev.set & PUMP_NETINFO_HAS_GATEWAY) { + fprintf(f, "GATEWAY=%s\n", inet_ntoa(dev->dev.gateway)); + if (!strncmp(dev->dev.device, "ctc", 3) || \ + !strncmp(dev->dev.device, "iucv", 4)) + fprintf(f, "REMIP=%s\n", inet_ntoa(dev->dev.gateway)); + } + if (dev->dev.set & PUMP_INTFINFO_HAS_BROADCAST) + fprintf(f, "BROADCAST=%s\n", inet_ntoa(dev->dev.broadcast)); } if (dev->dev.set & PUMP_NETINFO_HAS_HOSTNAME) @@ -573,6 +587,9 @@ int writeResolvConf(struct networkDeviceConfig * net) { char * filename = "/etc/resolv.conf"; FILE * f; int i; +#if defined(__s390__) || defined(__s390x__) + return 0; +#endif if (!(net->dev.set & PUMP_NETINFO_HAS_DOMAIN) && !net->dev.numDns) return LOADER_ERROR; @@ -598,9 +615,7 @@ int writeResolvConf(struct networkDeviceConfig * net) { int findHostAndDomain(struct networkDeviceConfig * dev, int flags) { char * name, * chptr; -#ifdef __STANDALONE__ struct hostent * he; -#endif if (!FL_TESTING(flags)) { writeResolvConf(dev); @@ -609,12 +624,8 @@ int findHostAndDomain(struct networkDeviceConfig * dev, int flags) { if (!(dev->dev.set & PUMP_NETINFO_HAS_HOSTNAME)) { winStatus(40, 3, _("Hostname"), _("Determining host name and domain...")); -#ifdef __STANDALONE__ he = gethostbyaddr( (char *) &dev->dev.ip, sizeof (dev->dev.ip), AF_INET); name = he ? he->h_name : 0; -#else - name = mygethostbyaddr(inet_ntoa(dev->dev.ip)); -#endif newtPopWindow(); if (!name) { diff --git a/loader/pcmcia.c b/loader/pcmcia.c index 8a70996c6..6cb9f469b 100644 --- a/loader/pcmcia.c +++ b/loader/pcmcia.c @@ -1,3 +1,4 @@ +#include <errno.h> #include <fcntl.h> #include <kudzu/kudzu.h> #include <newt.h> @@ -91,8 +92,7 @@ int startPcmcia(char * floppyDevice, moduleList modLoaded, moduleDeps modDeps, logMessage("need to load %s", pcic); winStatus(40, 3, title, text); - if (mlLoadModule("pcmcia_core", NULL, modLoaded, modDeps, - NULL, modInfo, flags)) { + if (mlLoadModuleSet("pcmcia_core", modLoaded, modDeps, modInfo, flags)) { logMessage("failed to load pcmcia_core -- ask for pcmciadd"); rc = 1; newtPopWindow(); @@ -125,8 +125,8 @@ int startPcmcia(char * floppyDevice, moduleList modLoaded, moduleDeps modDeps, logMessage("read %s", buf); if (i == 23 && !strcmp(buf, "PCMCIA Driver Diskette\n")) { winStatus(40, 3, title, text); - if (mlLoadModule("pcmcia_core", NULL, modLoaded, modDeps, - NULL, modInfo, flags)) { + if (mlLoadModuleSet("pcmcia_core", modLoaded, modDeps, + modInfo, flags)) { newtPopWindow(); newtWinMessage(_("Error"), _("OK"), _("That floppy does not look like a " @@ -144,16 +144,10 @@ int startPcmcia(char * floppyDevice, moduleList modLoaded, moduleDeps modDeps, } } - if (mlLoadModule(pcic, NULL, modLoaded, modDeps, NULL, - modInfo, flags)) { - logMessage("failed to load pcic"); - umount("/modules"); - return LOADER_ERROR; - } + sprintf(buf, "%s:ds", pcic); - if (mlLoadModule("ds", NULL, modLoaded, modDeps, NULL, - modInfo, flags)) { - logMessage("failed to load ds"); + if (mlLoadModuleSet(buf, modLoaded, modDeps, modInfo, flags)) { + logMessage("failed to load pcic.o or ds.o"); umount("/modules"); return LOADER_ERROR; } @@ -172,6 +166,6 @@ int startPcmcia(char * floppyDevice, moduleList modLoaded, moduleDeps modDeps, umount("/modules"); strcpy(pcicPtr, pcic); - + return 0; } diff --git a/loader/stubs.c b/loader/stubs.c index 5ce4b7b85..735843ec9 100644 --- a/loader/stubs.c +++ b/loader/stubs.c @@ -81,6 +81,11 @@ __gconv_compare_alias (const char *name1, const char *name2) { return 0; } +int +__gconv_compare_alias_cache (const char *name1, const char *name2, int *result) { + return 0; +} + void __gconv_release_step () { } diff --git a/loader/telnet.c b/loader/telnet.c index bf53476aa..fda836639 100644 --- a/loader/telnet.c +++ b/loader/telnet.c @@ -20,6 +20,7 @@ /* Shamelessly stolen from ttywatch -- oot */ +#include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -36,6 +37,8 @@ #define SE "\xf0" #define ECHO "\x01" #define SUPPRESS_GO_AHEAD "\x03" +#define TERMINAL_TYPE "\x18" +#define NAWS "\x1f" #define LINEMODE "\x22" #define NEWENVIRON "\x27" #define MODE "\x01" @@ -52,25 +55,97 @@ * too. */ void -telnet_negotiate(int socket) { +telnet_negotiate(int socket, char ** term_type_ptr, int * heightPtr, + int * widthPtr) { + char ch; + int done = 0; + char * termType = NULL; + int termLength = 0, termAlloced = 0; + enum { ST_NONE, ST_TERMTYPE, ST_WINDOWSIZE } state; + char sizeBuf[4]; + int height = -1, width = -1; + char * sizePtr = sizeBuf; char request[]= IAC DONT ECHO IAC WILL ECHO + IAC WILL NAWS IAC WILL SUPPRESS_GO_AHEAD IAC DO SUPPRESS_GO_AHEAD IAC DONT NEWENVIRON IAC WONT NEWENVIRON - IAC DO LINEMODE - IAC SB LINEMODE MODE "0" IAC SE + IAC WONT LINEMODE + IAC DO NAWS + IAC SB TERMINAL_TYPE "\x01" IAC SE ; + write(socket, request, sizeof(request)-1); + + /* Read from the terminal until we get the terminal type. This will + do bad things if the client doesn't send the terminal type, but + those clients have existed for aeons (right?) */ + + do { + read(socket, &ch, 1); + if (ch != '\xff') { + abort(); + } + + read(socket, &ch, 1); /* command */ + + if (ch != '\xfa') { + read(socket, &ch, 1); /* verb */ + continue; + } + + read(socket, &ch, 1); /* suboption */ + if (ch == '\x18') { + state = ST_TERMTYPE; + read(socket, &ch, 1); /* should be 0x0! */ + done = 1; + } else if (ch == '\x1f') { + state = ST_WINDOWSIZE; + } else { + state = ST_NONE;; + } + + read(socket, &ch, 1); /* data */ + while (ch != '\xff') { + if (state == ST_TERMTYPE) { + if (termAlloced == termLength) { + termAlloced += 10; + termType = realloc(termType, termAlloced + 1); + } + + termType[termLength++] = tolower(ch); + } else if (state == ST_WINDOWSIZE) { + if ((sizePtr - sizeBuf) < sizeof(sizeBuf)) + *sizePtr++ = ch; + } + + read(socket, &ch, 1); /* data */ + } + + read(socket, &ch, 1); /* should be a SE */ + + } while (!done); + + termType[termLength] = '\0'; + + if (sizePtr - sizeBuf == sizeof(sizeBuf)) { + width = (sizeBuf[0] << 8) + sizeBuf[1]; + height = (sizeBuf[2] << 8) + sizeBuf[3]; + } + + if (heightPtr) *heightPtr = height; + if (widthPtr) *widthPtr = width; + + if (term_type_ptr) *term_type_ptr = termType; } int telnet_process_input(telnet_state * ts, char *data, int len) { char *s, *d; /* source, destination */ -# define DEBUG_TELNET 0 # if DEBUG_TELNET printf("\nprinting packet:"); for (s=data; s<data+len; s++) { @@ -135,7 +210,7 @@ telnet_process_input(telnet_state * ts, char *data, int len) { *ts = TS_DATA; } else { # if DEBUG_TELNET - printf("IAC without SE in SB\n"); + printf("IAC without SE in SB (offset %d)\n", s-data-1); # endif /* DEBUG_TELNET */ *ts = TS_SB; } @@ -159,6 +234,7 @@ telnet_process_input(telnet_state * ts, char *data, int len) { } printf("\n"); #endif /* DEBUG_TELNET */ + return len; } diff --git a/loader/telnet.h b/loader/telnet.h index f43ed2b65..58ea5ba0a 100644 --- a/loader/telnet.h +++ b/loader/telnet.h @@ -30,7 +30,8 @@ typedef enum { } telnet_state; void -telnet_negotiate(int socket); +telnet_negotiate(int socket, char ** term_type_ptr, int * heightPtr, + int * widthPtr); int telnet_process_input(telnet_state * ts, char *data, int len); void diff --git a/loader/telnetd.c b/loader/telnetd.c index d1ae82fa1..3dcb318f8 100644 --- a/loader/telnetd.c +++ b/loader/telnetd.c @@ -1,22 +1,33 @@ /* Glue to tie telnet.c from ttywatch to the loader */ #include <arpa/inet.h> +#include <ctype.h> #include <errno.h> +#include <fcntl.h> #include <netinet/in.h> +#include <newt.h> #include <pty.h> +#include <stdlib.h> #include <string.h> +#include <sys/ioctl.h> #include <sys/poll.h> #include <sys/signal.h> #include <sys/socket.h> #include <sys/types.h> -#include <termios.h> #include <unistd.h> +#include "lang.h" +#include "loader.h" #include "log.h" #include "telnet.h" +#include "windows.h" + +#ifndef IPPORT_TELNET +#define IPPORT_TELNET 23 +#endif /* Forks, keeping the loader as our child (so we know when it dies). */ -int beTelnet(void) { +int beTelnet(int flags) { int sock; int conn; int addrLength; @@ -27,7 +38,9 @@ int beTelnet(void) { char buf[4096]; struct pollfd fds[3]; telnet_state ts = TS_DATA; - struct termios orig, new; + char * termType; + int height, width; + struct winsize ws; if ((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) { logMessage("socket: %s", strerror(errno)); @@ -48,54 +61,88 @@ int beTelnet(void) { bind(sock, (struct sockaddr *) &address, sizeof(address)); listen(sock, 5); - printf("Waiting for telnet connection on port 23..."); + winStatus(45, 3, _("Telnet"), _("Waiting for telnet connection...")); if ((conn = accept(sock, (struct sockaddr *) &address, &addrLength)) < 0) { - logMessage("accept: %s", strerror(errno)); - exit(0); + newtWinMessage(_("Error"), _("OK"), "accept failed: %s", + strerror(errno)); + close(sock); return -1; } - printf(" got a connection.\n"); + stopNewt(); close(sock); - telnet_negotiate(conn); - child = forkpty(&masterFd, NULL, NULL, NULL); + telnet_negotiate(conn, &termType, &height, &width); + +#ifdef DEBUG + printf("got term type %s\n", termType); +#endif - if (child < 0) { - logMessage("forkpty: %s", strerror(errno)); + masterFd = open("/dev/ptyp0", O_RDWR); + if (masterFd < 0) { + logMessage("cannot open /dev/ttyp0"); close(conn); return -1; - } else if (child) { + } + + if (height != -1 && width != -1) { +#ifdef DEBUF + printf("setting window size to %d x %d\n", width, height); +#endif + ws.ws_row = height; + ws.ws_col = width; + ioctl(masterFd, TIOCSWINSZ, &ws); + } + + + child = fork(); + + if (child) { +#ifndef DEBUG + startNewt(flags); + winStatus(45, 3, _("Telnet"), _("Running anaconda via telnet...")); +#endif + fds[0].events = POLLIN; fds[0].fd = masterFd; fds[1].events = POLLIN; fds[1].fd = conn; - fds[2].events = POLLIN; - fds[2].fd = STDIN_FILENO; - - tcgetattr(STDIN_FILENO, &orig); - tcgetattr(STDIN_FILENO, &new); - new.c_lflag &= ~(ICANON | ECHO | ECHOCTL | ECHONL); - new.c_oflag &= ~ONLCR; - new.c_iflag &= ~ICRNL; - new.c_cc[VSUSP] = 0; - tcsetattr(STDIN_FILENO, 0, &new); - - while ((i = poll(fds, 3, -1)) > 0) { + while ((i = poll(fds, 2, -1)) > 0) { if (fds[0].revents) { i = read(masterFd, buf, sizeof(buf)); +#ifdef DEBUG + { + int j; + int row; + + for (row = 0; row < (i / 12) + 1; row++) { + printf("wrote:"); + for (j = (row * 12); j < i && j < ((row + 1) * 12); j++) + printf(" 0x%2x", (unsigned char) buf[j]); + printf("\n"); + printf("wrote:"); + for (j = (row * 12); j < i && j < ((row + 1) * 12); j++) + { + if (isprint(buf[j])) + printf(" %c ", buf[j]); + else + printf(" "); + } + printf("\n"); + } + } +#endif /* child died */ if (i < 0) break; telnet_send_output(conn, buf, i); - write(STDOUT_FILENO, buf, i); } if (fds[1].revents) { @@ -107,26 +154,50 @@ int beTelnet(void) { i = telnet_process_input(&ts, buf, i); write(masterFd, buf, i); - } - if (fds[2].revents) { - i = read(STDIN_FILENO, buf, sizeof(buf)); - write(masterFd, buf, i); +#ifdef DEBUG + { + int j; + + printf("got:"); + for (j = 0; j < i; j++) + printf(" 0x%x", (unsigned char) buf[j]); + printf("\n"); + } +#endif + } } - printf("out of poll %d\n", i); if (i < 0) { logMessage("poll: %s", strerror(errno)); } +#ifndef DEBUG + stopNewt(); +#endif + kill(child, SIGTERM); close(conn); - tcsetattr(STDIN_FILENO, 0, &orig); exit(0); } + close(masterFd); + setsid(); + close(0); + close(1); + close(2); + + open("/dev/ttyp0", O_RDWR); + dup(0); + dup(0); + + /* brand new tty! */ + setenv("TERM", termType, 1); + + startNewt(flags); + return 0; } diff --git a/loader/urls.c b/loader/urls.c index 7939a566c..52ce537f2 100644 --- a/loader/urls.c +++ b/loader/urls.c @@ -115,6 +115,41 @@ int urlinstFinishTransfer(struct iurlinfo * ui, int fd) { return 0; } +int setupRemote(struct iurlinfo * ui) { + char *env, *d, *e; + + if (!(env = getenv("RPMSERVER"))) { + ui->address = ""; + ui->prefix = ""; + return 0; + } + + if (!strncmp(env, "ftp://",6)) + env += 6; + else if (!strncmp(env, "http://",7)) + env += 7; + + if (!(d = index (env, '/'))) { + d = ""; + ui->prefix = strdup(d); + } + else /* make sure the path either starts with a / or a ~ */ + if(*d != '/') { + ui->prefix = (char *)malloc(strlen(d)+2); + *ui->prefix = '/'; + strcat(ui->prefix, d); + } + else ui->prefix = strdup(d); + + ui->address = strdup(env); + if (ui->address && (d = index (ui->address, '/'))) + *d = '\0'; + if (ui->address && (d = index (ui->address, ':'))) + *d = '\0'; + + return 0; +} + char * addrToIp(char * hostname) { struct in_addr ad; char * chptr; diff --git a/loader/urls.h b/loader/urls.h index 82e8c4457..29cd46798 100644 --- a/loader/urls.h +++ b/loader/urls.h @@ -15,6 +15,7 @@ struct iurlinfo { int ftpPort; }; +int setupRemote(struct iurlinfo * ui); int urlMainSetupPanel(struct iurlinfo * ui, urlprotocol protocol, char * doSecondarySetup); int urlSecondarySetupPanel(struct iurlinfo * ui, urlprotocol protocol); diff --git a/loader/urltest.c b/loader/urltest.c index e9e22b5c7..7df2bf555 100644 --- a/loader/urltest.c +++ b/loader/urltest.c @@ -2,33 +2,43 @@ #include "urls.h" +int haveKon = 0; +int continuing = 0; + +void stopNewt(void) { +} + int main(void) { struct iurlinfo iu; char doSecondary; - char buf[1024]; int fd; int size; + int total = 0; + char buf[16384]; + newtInit(); newtCls(); memset(&iu, 0, sizeof(iu)); - iu.protocol = URL_METHOD_FTP; - iu.address = "mercury.devel.redhat.com"; - iu.prefix = "/mnt/redhat/test/oot/i386"; - iu.protocol = URL_METHOD_HTTP; - iu.address = "mercury.devel.redhat.com"; + iu.address = "localhost"; iu.prefix = "/"; - fd = urlinstStartTransfer(&iu, "test.html"); + iu.protocol = URL_METHOD_FTP; + iu.address = "localhost"; + iu.prefix = "/pub/oot/i386"; + + fd = urlinstStartTransfer(&iu, "RedHat/base/netstg1.img", 1); if (fd >= 0) { - size = read(fd, buf, sizeof(buf)); - buf[size] = '\0'; + while ((size = read(fd, buf, sizeof(buf))) > 0) + total += size; urlinstFinishTransfer(&iu, fd); - newtWinMessage("Got it", "OK", "Got: '%s'", buf); + newtWinMessage("Got it", "OK", "Got: %d bytes\n", total); + } else { + newtWinMessage("Failed", "OK", ":-("); } newtFinished(); diff --git a/loader/windows.c b/loader/windows.c index 86c1ed6eb..61ca8e7ad 100644 --- a/loader/windows.c +++ b/loader/windows.c @@ -42,7 +42,7 @@ void winStatus(int width, int height, char * title, newtFormDestroy(f); } -void scsiWindow(char * driver) { +void scsiWindow(const char * driver) { winStatus(40, 3, _("Loading SCSI driver"), _("Loading %s driver..."), driver); } diff --git a/loader/windows.h b/loader/windows.h index 959199b2b..93b38b2c0 100644 --- a/loader/windows.h +++ b/loader/windows.h @@ -2,6 +2,6 @@ #define _WINDOWS_H_ void winStatus(int width, int height, char * title, char * text, ...); -void scsiWindow(char * driver); +void scsiWindow(const char * driver); #endif /* _WINDOWS_H_ */ diff --git a/minislang/.cvsignore b/minislang/.cvsignore index 4671378ae..647e78600 100644 --- a/minislang/.cvsignore +++ b/minislang/.cvsignore @@ -1 +1,3 @@ .depend +*.lo +*.do diff --git a/minislang/Makefile b/minislang/Makefile index 4fd0180d5..8fad5038e 100644 --- a/minislang/Makefile +++ b/minislang/Makefile @@ -3,9 +3,15 @@ include ../Makefile.inc OBJS = sldisply.o slerr.o slgetkey.o slmisc.o slsignal.o slsmg.o \ sltermin.o slutty.o slkanji.o SOBJS = $(patsubst %.o,%.lo,$(OBJS)) +DOBJS = $(patsubst %.o,%.do,$(OBJS)) CFLAGS = -Os +STATICLIB=libslang.a($(OBJS)) +ifeq (i386, $(ARCH)) +STATICLIB=libslang-diet.a($(DOBJS)) +endif + ifeq (.depend,$(wildcard .depend)) TARGET=all else @@ -14,16 +20,19 @@ endif everything: $(TARGET) -all: libslang.so libslang.a($(OBJS)) +all: libslang.so $(STATICLIB) %.lo: %.c $(CC) -c $(CFLAGS) -fPIC -o $@ $< +%.do: %.c + diet $(CC) -c $(CFLAGS) -o $@ $< + libslang.so: $(SOBJS) gcc -o $@ -shared -Wl,-soname,libslang.so.1 $(SOBJS) clean: - rm -f *.o *.so *.lo libslang.so libslang.a + rm -f *.o *.so *.lo *.do libslang.so libslang.a libslang-diet.a install: libslang.so install -s libslang.so $(DESTDIR)/$(RUNTIMEDIR)/libslang.so.1 diff --git a/minislang/slsmg.c b/minislang/slsmg.c index fbd45d8d3..3ba382092 100644 --- a/minislang/slsmg.c +++ b/minislang/slsmg.c @@ -882,7 +882,8 @@ static void init_alt_char_set (void) int i; unsigned char *p, *pmax, ch; - if (Alt_Char_Set[128] == 128) return; + /*don't do this! it prevents us from later changing the terminal type */ + /*if (Alt_Char_Set[128] == 128) return;*/ i = 32; memset ((char *)Alt_Char_Set, ' ', i); @@ -1353,59 +1354,3 @@ SLsmg_set_color_in_region (int color, int r, int c, unsigned int dr, unsigned in } } - -void SLsmg_set_terminal_info (SLsmg_Term_Type *tt) -{ - if (tt == NULL) /* use default */ - return; - - if ((tt->tt_normal_video == NULL) - || (tt->tt_goto_rc == NULL) - || (tt->tt_cls == NULL) - || (tt->tt_del_eol == NULL) - || (tt->tt_smart_puts == NULL) - || (tt->tt_flush_output == NULL) - || (tt->tt_reset_video == NULL) - || (tt->tt_init_video == NULL) -#ifndef IBMPC_SYSTEM - || (tt->tt_set_scroll_region == NULL) - || (tt->tt_reverse_index == NULL) - || (tt->tt_reset_scroll_region == NULL) - || (tt->tt_delete_nlines == NULL) - /* Variables */ - || (tt->tt_term_cannot_scroll == NULL) - || (tt->tt_has_alt_charset == NULL) -#if 0 /* These can be NULL */ - || (tt->tt_use_blink_for_acs == NULL) - || (tt->tt_graphic_char_pairs == NULL) -#endif - || (tt->tt_screen_cols == NULL) - || (tt->tt_screen_rows == NULL) -#endif - ) - SLang_exit_error ("Terminal not powerful enough for SLsmg"); - - tt_normal_video = tt->tt_normal_video; - tt_goto_rc = tt->tt_goto_rc; - tt_cls = tt->tt_cls; - tt_del_eol = tt->tt_del_eol; - tt_smart_puts = tt->tt_smart_puts; - tt_flush_output = tt->tt_flush_output; - tt_reset_video = tt->tt_reset_video; - tt_init_video = tt->tt_init_video; - -#ifndef IBMPC_SYSTEM - tt_set_scroll_region = tt->tt_set_scroll_region; - tt_reverse_index = tt->tt_reverse_index; - tt_reset_scroll_region = tt->tt_reset_scroll_region; - tt_delete_nlines = tt->tt_delete_nlines; - - tt_Term_Cannot_Scroll = tt->tt_term_cannot_scroll; - tt_Has_Alt_Charset = tt->tt_has_alt_charset; - tt_Use_Blink_For_ACS = tt->tt_use_blink_for_acs; - tt_Graphics_Char_Pairs = tt->tt_graphic_char_pairs; -#endif - - tt_Screen_Cols = tt->tt_screen_cols; - tt_Screen_Rows = tt->tt_screen_rows; -} diff --git a/scripts/splitdistro b/scripts/splitdistro index 87cc1445b..5ba06f833 100755 --- a/scripts/splitdistro +++ b/scripts/splitdistro @@ -6,7 +6,7 @@ disc2dirs = [ "preview" ] # These files appear on all binary CDs jointfiles = [ "COPYING", "RPM-GPG-KEY", "README", "autorun" ] -targetSize = 650 * 1024 * 1024 +targetSize = 640 * 1024 * 1024 # Leave about 1.2MB of space on the disc fudgeFactor = 1.2 * 1024 * 1024 @@ -30,7 +30,11 @@ def moveFiles(srcDir, destDir, files): for fn in files: src = "%s/%s" % (srcDir, fn) dest = "%s/%s" % (destDir, fn) - os.rename(src, dest) + try: + os.rename(src, dest) + except: + print "in moveFiles, src was %s, dest was %s" % (src, dest) + raise RuntimeError def excessFiles(path, fileList, maxSize): total = 0 @@ -103,8 +107,11 @@ if not os.path.isdir(srcDir): disc1Dir = distDir + "-disc1" disc2Dir = distDir + "-disc2" -disc1SrcDir = distDir + "-disc3" -disc2SrcDir = distDir + "-disc4" +disc3Dir = distDir + "-disc3" +disc1SrcDir = distDir + "-disc4" +disc2SrcDir = distDir + "-disc5" +# we have leftover space on the third disc to use for sources +disc3SrcDir = distDir + "-disc3" id = 0 @@ -143,8 +150,9 @@ disc1used = totalsize - rpmsize - dirsize os.system("rm -rf %s %s %s %s" % ( disc1Dir, disc2Dir, disc1SrcDir, disc2SrcDir)) -os.system("mkdir -p %s %s %s/SRPMS %s/RedHat/RPMS" % - (disc1Dir, disc1SrcDir, disc2SrcDir, disc2Dir)) +os.system("mkdir -p %s %s %s/SRPMS %s/RedHat/RPMS %s/RedHat/RPMS %s/SRPMS" % + (disc1Dir, disc1SrcDir, disc2SrcDir, disc2Dir, + disc3Dir, disc3SrcDir)) print "Creating disc1..." @@ -169,23 +177,49 @@ moveFiles("%s/RedHat/RPMS" % disc1Dir, "%s/RedHat/RPMS" % disc2Dir, disc2pkgs); +print "Creating disc3..." +stamp(disc3Dir, "disc3", arch, startedAt) + +for file in jointfiles: + src = "%s/%s" % (disc1Dir, file) + dest = "%s/%s" %(disc3Dir, file) + try: + os.link(src, dest) + except OSError, (errno, msg): + print "**** WARNING linking %s to %s: %s" % (src, dest, msg) + +disc3pkgs = excessFiles(distDir + "/RedHat/RPMS", binPkgList, + targetSize * 2 - disc1used - fudgeFactor) + +moveFiles("%s/RedHat/RPMS" % disc2Dir, + "%s/RedHat/RPMS" % disc3Dir, + disc3pkgs); + print "Creating first source disc..." os.system("cp -al %s/. %s" % (srcDir, disc1SrcDir)) -stamp(disc1SrcDir, "disc3", arch, startedAt) +stamp(disc1SrcDir, "disc4", arch, startedAt) print "Creating second source disc..." -stamp(disc2SrcDir, "disc4", arch, startedAt) +stamp(disc2SrcDir, "disc5", arch, startedAt) srcPkgList = os.listdir("%s/SRPMS" % disc1SrcDir) srcPkgList.sort() -disc2pkgs = excessFiles(disc1SrcDir + "/SRPMS", srcPkgList, +disc2pkgs = excessFiles(srcDir + "/SRPMS", srcPkgList, targetSize - fudgeFactor) moveFiles("%s/SRPMS" % disc1SrcDir, "%s/SRPMS" % disc2SrcDir, disc2pkgs); -sys.exit(0) +print "Dropping remainder of sources on third disc..." +disc3pkgs = excessFiles(srcDir + "/SRPMS", srcPkgList, + (targetSize - fudgeFactor) * 2) +moveFiles("%s/SRPMS" % disc2SrcDir, + "%s/SRPMS" % disc3SrcDir, + disc3pkgs) + +#sys.exit(0) sys.stdout.flush() -os.system("du -sh %s %s %s" % (disc1Dir, disc2Dir, disc1SrcDir)) +os.system("du -sh %s %s %s %s %s" % (disc1Dir, disc2Dir, disc3Dir, + disc1SrcDir, disc2SrcDir)) diff --git a/utils/Makefile b/utils/Makefile index 17429ccc0..c2035ffe2 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -3,8 +3,11 @@ include ../Makefile.inc ARCH := $(patsubst i%86,i386,$(shell uname -m)) ARCH := $(patsubst sparc%,sparc,$(ARCH)) -LOADLIBES = -L../isys -lisys -lpopt -CFLAGS = -Wall -g -I/usr/include/rpm -I.. +ISYSLIB=isys + +LOADLIBES = -L../isys -l$(ISYSLIB) -lpopt +CFLAGS = -Wall -g -I.. +RPMCFLAGS = -I/usr/include/rpm LDFLAGS = -g -static MODDEPS = moddeps @@ -18,15 +21,20 @@ everything: $(TARGET) all: modlist $(MODDEPS) genhdlist snarffont mapshdr readmap -modlist: modlist.o ../isys/libisys.a +modlist: modlist.o + +modules.o: ../loader/modules.c + cp ../loader/modules.c ./ + $(CC) $(CFLAGS) -I../loader -c modules.c -moddeps: moddeps.o - $(CC) $(LDFLAGS) -o moddeps moddeps.o ../loader/modules.o \ - $(LOADLIBES) -lmodutils -lmodutilobj -lmodutilutil \ - -lrpm -lrpmdb -lrpmio -lbz2 -lz -lpopt +moddeps: moddeps.o modules.o + $(CC) $(LDFLAGS) -o moddeps moddeps.o modules.o \ + $(LOADLIBES) -lresolv \ + -lmodutils -lmodutilobj -lmodutilutil \ + -lpopt -lgunzip -L../isys/gzlib -lbz2 genhdlist: genhdlist.c hash.c - $(CC) $(LDFLAGS) $(CFLAGS) -o genhdlist genhdlist.c hash.c -lrpm -lrpmdb -lrpmio \ + $(CC) $(LDFLAGS) $(CFLAGS) $(RPMCFLAGS) -o genhdlist genhdlist.c hash.c -lrpm -lrpmdb -lrpmio \ -lbz2 -lz -lpopt depends: diff --git a/utils/fpswa/Makefile b/utils/fpswa/Makefile new file mode 100644 index 000000000..ada7fd75b --- /dev/null +++ b/utils/fpswa/Makefile @@ -0,0 +1,11 @@ +INC = /usr/include +LIB_DIR = /usr/lib +LIBS = $(LIB_DIR)/libbfd.a $(LIB_DIR)/libiberty.a + +all: fpswa_version + +fpswa_version:fpswa_version.c $(LIBS) + gcc -g -I$(INC) -o fpswa_version fpswa_version.c $(LIBS) + +clean: + rm -f fpswa_version diff --git a/utils/fpswa/fpswa_version.c b/utils/fpswa/fpswa_version.c new file mode 100644 index 000000000..6a41451dd --- /dev/null +++ b/utils/fpswa/fpswa_version.c @@ -0,0 +1,228 @@ +/* + FPSWA Version + Parse the FPSWA.efi executable to find the version information. + The output may be used to compare multiple executables to determine + the newest version. + + Copyright 2002 Intel Corporation + Copyright 2002 Jenna Hall <jenna.s.hall@intel.com> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <stdio.h> +#include <string.h> +#include <stddef.h> +#include <bfd.h> +#include <errno.h> +#include <fcntl.h> +#include <malloc.h> + +#define SEARCH_STRING "FileVersion" +#define FILENAME_DESCRIPTOR "InternalName" +#define FILENAME "fpswa.efi" +#define MAX_VERSION_LENGTH 8 + +/* Static declarations */ + +static off_t rsrc_offset = 0; /* rc info offset - found in header */ +static size_t rsrc_size = 0; /* rc info size - found in header */ +static int exit_status = 0; +static char *default_target = NULL; /* default at runtime */ + +static void +parse_section_header (bfd *, asection *, PTR); + +static void +parse_bfd (bfd *); + +static void +parse_file (char *, char *); + +static void +extract_offset (char **); + +static void +parse_unicode(ssize_t, unsigned short *); + +static void +locate_file_version (char **); + + +/* Definitions */ + +static void +parse_section_header (bfd *abfd, asection *section, PTR ignored ATTRIBUTE_UNUSED) +{ + unsigned int opb = bfd_octets_per_byte(abfd); + + if (!strcmp(bfd_get_section_name(abfd, section), ".rsrc")) { + rsrc_offset = section->filepos; + rsrc_size = (bfd_section_size(abfd, section) / opb); + } +} + +static void +parse_bfd (bfd *abfd) +{ + char **matching; + + if (bfd_check_format_matches (abfd, bfd_object, &matching)) { + bfd_map_over_sections (abfd, parse_section_header, (PTR) NULL); + return; + } + else { + fprintf(stderr, "Error: not an object file!\n"); + return; + } +} + +static void +parse_file (char *filename, char *target) +{ + bfd *file; + + file = bfd_openr (filename, target); + if (file == NULL) { + fprintf(stderr, "BFD library error!\n"); + exit_status = 1; + return; + } + + parse_bfd (file); + + bfd_close (file); +} + +/* + * Parse the executable to find the .rsrc header offset + */ +static void +extract_offset (char **argv) +{ + char *target = default_target; + + bfd_init (); + + parse_file (argv[1], target); +} + +/* + * Parse the unicode-encoded rc section of the FPSWA file to find the + * version string + */ +static void +parse_unicode(ssize_t rc_section_size, unsigned short *buf) +{ + unsigned int i= 0; + char version_string[MAX_VERSION_LENGTH]; + char *temp_ptr; + unsigned short *buffer_ptr = buf; + + temp_ptr = SEARCH_STRING; + + /* locate the version search string within the Unicode buffer */ + while (buffer_ptr && (temp_ptr[0] != '\0')) { + if (*buffer_ptr == temp_ptr[0]) { + temp_ptr++; + } + else // reset + temp_ptr = SEARCH_STRING; + buffer_ptr++; + } + + /* parse past the Unicode NULL characters */ + while (*buffer_ptr == 0) { + buffer_ptr++; + } + + /* capture the version number string */ + while (*buffer_ptr != '\0') { + version_string[i] = *buffer_ptr; + buffer_ptr++; i++; + } + /* NULL terminate the string */ + version_string[i] = '\0'; + + /* output version string to user */ + printf("%s\n", version_string); + +} + +/* + * Locate the rc info at that offset in the executable, + * then parse that section to locate the FileVersion string + */ +static void +locate_file_version (char **argv) +{ + int fd; + ssize_t bytes_read = 0; + unsigned short *buf = malloc(rsrc_size); + + if (buf == NULL) { + fprintf(stderr, "Malloc failed! Exiting...\n"); + free(buf); + exit(1); + } + + if ((fd = open(argv[1], O_RDONLY)) < 0) { + fprintf(stderr, "Open failed: %s\n", sys_errlist[errno]); + free(buf); + exit(1); + } + + /* first search to the beginning of the rc info section */ + if (lseek(fd, rsrc_offset, SEEK_SET) < 0) { + /* seek error; exit */ + fprintf(stderr, "Seek failed: %s\n", sys_errlist[errno]); + close(fd); + free(buf); + exit(1); + } + + /* next load the rc info section into the buffer for parsing */ + if ((bytes_read = read(fd, buf, rsrc_size)) < 0) { + /* read error; exit */ + fprintf(stderr, "Read failed: %s\n", sys_errlist[errno]); + close(fd); + free(buf); + exit(1); + } + + /* now parse the rc info section for the FileVersion string */ + parse_unicode(bytes_read, buf); + + free(buf); + close(fd); +} + +int +main (int argc, char **argv) +{ + if (argc != 2) { + fprintf(stderr, "Usage: %s FPSWA.efi\n", argv[0]); + exit(1); + } + + /* parse the executable to find the .rsrc header offset */ + extract_offset(argv); + + /* locate the rc info at that offset in the executable, + then parse that section to locate the FileVersion string */ + locate_file_version(argv); + + return exit_status; +} diff --git a/utils/fpswa/readme b/utils/fpswa/readme new file mode 100644 index 000000000..628b6220a --- /dev/null +++ b/utils/fpswa/readme @@ -0,0 +1,10 @@ +*******************************
+FPSWA.efi version check utility
+*******************************
+
+Usage: fpswa_version FPSWA.efi
+
+
+This utility will extract the version number from an FPSWA.efi binary file.
+The output may then be compared with the output from other FPSWA.efi binaries
+to determine which is the newest on the system, for OS installation purposes.
diff --git a/utils/moddeps.c b/utils/moddeps.c index df22f23f9..a6239df35 100644 --- a/utils/moddeps.c +++ b/utils/moddeps.c @@ -10,10 +10,35 @@ void setFloppyDevice(int flags) { } -int extractModule(location, modName) { +char *translateString(char *str) { + return NULL; +} + +int extractModules(int location, char * modName) { return 0; } +void scsiWindow(const char * foo) { +} + +void startNewt(int flags) { +} + +void newtPopWindow(void) { +} + +void newtWinChoice(void) { +} + +void newtWinMessage(void) { +} + +void eject(void) { +} + +void winStatus(void) { +} + int main(int argc, char ** argv) { poptContext optCon; char * modDepsFile = NULL; |