Completely remove loader/
IT IS ACCOMPLISHED.
--- loader/.gitignore | 10 - loader/Makefile.am | 97 -- loader/cdinstall.c | 421 --------- loader/cdinstall.h | 31 - loader/copy.c | 141 --- loader/copy.h | 26 - loader/dirbrowser.c | 208 ----- loader/dirbrowser.h | 32 - loader/driverdisk.c | 795 ---------------- loader/driverdisk.h | 50 - loader/driverselect.c | 243 ----- loader/fwloader.c | 673 -------------- loader/fwloader.h | 35 - loader/getparts.c | 131 --- loader/getparts.h | 27 - loader/hardware.c | 150 --- loader/hardware.h | 28 - loader/hdinstall.c | 407 -------- loader/hdinstall.h | 30 - loader/ibft.c | 105 --- loader/ibft.h | 45 - loader/kbd.c | 152 --- loader/kbd.h | 25 - loader/keymaps-i386 | Bin 12173 -> 0 bytes loader/keymaps-ppc | Bin 12871 -> 0 bytes loader/keymaps-x86_64 | Bin 12173 -> 0 bytes loader/kickstart.c | 1108 ---------------------- loader/kickstart.h | 29 - loader/lang.c | 479 ---------- loader/lang.h | 42 - loader/loader.c | 2441 ------------------------------------------------ loader/loader.h | 193 ---- loader/loadermisc.c | 168 ---- loader/loadermisc.h | 33 - loader/mediacheck.c | 115 --- loader/mediacheck.h | 25 - loader/method.c | 333 ------- loader/method.h | 51 - loader/moduleinfo.c | 274 ------ loader/moduleinfo.h | 78 -- loader/modules.c | 551 ----------- loader/modules.h | 50 - loader/net.c | 2466 ------------------------------------------------- loader/net.h | 109 --- loader/nfsinstall.c | 473 ---------- loader/nfsinstall.h | 31 - loader/readvars.c | 125 --- loader/readvars.h | 29 - loader/rpmextract.c | 260 ------ loader/rpmextract.h | 46 - loader/selinux.c | 56 -- loader/selinux.h | 27 - loader/serial.c | 222 ----- loader/serial.h | 9 - loader/simplemot | 81 -- loader/udelay.h | 199 ---- loader/unpack.c | 164 ---- loader/unpack.h | 34 - loader/urlinstall.c | 259 ------ loader/urlinstall.h | 32 - loader/urls.c | 381 -------- loader/urls.h | 31 - loader/windows.c | 116 --- loader/windows.h | 42 - 64 files changed, 0 insertions(+), 15024 deletions(-) delete mode 100644 loader/.gitignore delete mode 100644 loader/Makefile.am delete mode 100644 loader/cdinstall.c delete mode 100644 loader/cdinstall.h delete mode 100644 loader/copy.c delete mode 100644 loader/copy.h delete mode 100644 loader/dirbrowser.c delete mode 100644 loader/dirbrowser.h delete mode 100644 loader/driverdisk.c delete mode 100644 loader/driverdisk.h delete mode 100644 loader/driverselect.c delete mode 100644 loader/fwloader.c delete mode 100644 loader/fwloader.h delete mode 100644 loader/getparts.c delete mode 100644 loader/getparts.h delete mode 100644 loader/hardware.c delete mode 100644 loader/hardware.h delete mode 100644 loader/hdinstall.c delete mode 100644 loader/hdinstall.h delete mode 100644 loader/ibft.c delete mode 100644 loader/ibft.h delete mode 100644 loader/kbd.c delete mode 100644 loader/kbd.h delete mode 100644 loader/keymaps-i386 delete mode 100644 loader/keymaps-ppc delete mode 100644 loader/keymaps-x86_64 delete mode 100644 loader/kickstart.c delete mode 100644 loader/kickstart.h delete mode 100644 loader/lang.c delete mode 100644 loader/lang.h delete mode 100644 loader/loader.c delete mode 100644 loader/loader.h delete mode 100644 loader/loadermisc.c delete mode 100644 loader/loadermisc.h delete mode 100644 loader/mediacheck.c delete mode 100644 loader/mediacheck.h delete mode 100644 loader/method.c delete mode 100644 loader/method.h delete mode 100644 loader/moduleinfo.c delete mode 100644 loader/moduleinfo.h delete mode 100644 loader/modules.c delete mode 100644 loader/modules.h delete mode 100644 loader/net.c delete mode 100644 loader/net.h delete mode 100644 loader/nfsinstall.c delete mode 100644 loader/nfsinstall.h delete mode 100644 loader/readvars.c delete mode 100644 loader/readvars.h delete mode 100644 loader/rpmextract.c delete mode 100644 loader/rpmextract.h delete mode 100644 loader/selinux.c delete mode 100644 loader/selinux.h delete mode 100644 loader/serial.c delete mode 100644 loader/serial.h delete mode 100755 loader/simplemot delete mode 100644 loader/udelay.h delete mode 100644 loader/unpack.c delete mode 100644 loader/unpack.h delete mode 100644 loader/urlinstall.c delete mode 100644 loader/urlinstall.h delete mode 100644 loader/urls.c delete mode 100644 loader/urls.h delete mode 100644 loader/windows.c delete mode 100644 loader/windows.h diff --git a/loader/.gitignore b/loader/.gitignore deleted file mode 100644 index c894638..0000000 --- a/loader/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -loader -init -debug.log -loader.tr -.depend -font.bgf.gz -loader.po -shutdown -checkisomd5 -tr diff --git a/loader/Makefile.am b/loader/Makefile.am deleted file mode 100644 index 243817c..0000000 --- a/loader/Makefile.am +++ /dev/null @@ -1,97 +0,0 @@ -# loader/Makefile.am for anaconda -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published -# by the Free Software Foundation; either version 2.1 of the License, 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 Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# Author: David Cantrell <dcantrell@redhat.com> - -bootdir = $(libdir)/$(PACKAGE_NAME) -shareddir = $(datadir)/$(PACKAGE_NAME) - -boot_PROGRAMS = loader -shared_DATA = loader.tr -noinst_PROGRAMS = dirbrowser -noinst_HEADERS = *.h - -if IS_S390 -dist_shared_SCRIPTS = linuxrc.s390 -endif - -if IS_KEYMAPS_OVERRIDE_ARCH -keymapsdir = $(datadir)/$(PACKAGE_NAME) -keymaps_DATA = keymaps-override-$(ARCH) -endif - -COMMON_CFLAGS = -DUSE_LOGDEV -DVERSION='"$(PACKAGE_VERSION)"' - -loader_CFLAGS = $(COMMON_CFLAGS) $(GLIB_CFLAGS) $(LIBNM_GLIB_CFLAGS) - $(LIBCURL_CFLAGS) $(IPV6_CFLAGS) $(LIBARCHIVE_CFLAGS) - $(RPM_CFLAGS) $(PYTHON_INCLUDES) -DINCLUDE_LOCAL -DINCLUDE_NETWORK - -fno-strict-aliasing -loader_LDADD = $(NEWT_LIBS) $(GLIB_LIBS) $(LIBNL_LIBS) $(PYTHON_EMBED_LIBS) - $(LIBNM_GLIB_LIBS) $(CHECKISOMD5_LIBS) - $(LIBCURL_LIBS) $(LIBARCHIVE_LIBS) $(RPM_LIBS) - $(ISCSI_LIBS) $(top_srcdir)/pyanaconda/isys/libisys.la -lm -loader_SOURCES = loader.c copy.c moduleinfo.c loadermisc.c - modules.c windows.c lang.c kbd.c driverdisk.c - selinux.c mediacheck.c kickstart.c driverselect.c - getparts.c dirbrowser.c fwloader.c ibft.c hardware.c - method.c cdinstall.c hdinstall.c nfsinstall.c - urlinstall.c net.c urls.c rpmextract.c readvars.c - serial.c unpack.c - -dirbrowser_CFLAGS = $(COMMON_CFLAGS) -DSTANDALONE -dirbrowser_LDADD = $(NEWT_LIBS) -dirbrowser_SOURCES = dirbrowser.c - -EXTRA_DIST = simplemot keymaps-* - -CLEANFILES = keymaps-override-$(ARCH) tr/*.tr - -MAINTAINERCLEANFILES = Makefile.in - -sed_verbose = $(sed_verbose_$(V)) -sed_verbose_ = $(sed_verbose_$(AM_DEFAULT_VERBOSITY)) -sed_verbose_0 = @echo " SED "$@; - -cp_verbose = $(cp_verbose_$(V)) -cp_verbose_ = $(cp_verbose_$(AM_DEFAULT_VERBOSITY)) -cp_verbose_0 = @echo " CP "$@; - -msgmerge_verbose = $(msgmerge_verbose_$(V)) -msgmerge_verbose_ = $(msgmerge_verbose_$(AM_DEFAULT_VERBOSITY)) -msgmerge_verbose_0 = echo " MERGE "$${lang}.po; - -xgettext_verbose = $(xgettext_verbose_$(V)) -xgettext_verbose_ = $(xgettext_verbose_$(AM_DEFAULT_VERBOSITY)) -xgettext_verbose_0 = @echo " GETTXT "$@; - -keymaps-override-$(ARCH): keymaps-$(ARCH) - $(cp_verbose)cp -p $< $@ - -loader.tr: $(top_srcdir)/data/lang-table loader.po - @LANGS="`cut -f 2 $(top_srcdir)/data/lang-table | egrep -v '(^en$$)'`" ; - if [ ! -d tr ]; then - mkdir -p tr ; - fi ; - for lang in $$LANGS ; do - $(msgmerge_verbose)msgmerge -q $(top_srcdir)/po/$$lang.po loader.po | msgconv -t utf-8 | ./simplemot > tr/$$lang.tr ; - done ; - (cd tr ; ls -1 *.tr | cpio --quiet -Hcrc -o | gzip -9) > $@ - -loader.po: - $(xgettext_verbose)xgettext --default-domain=loader --add-comments - --keyword=_ --keyword=N_ *.c - $(sed_verbose)sed -i 's/charset=CHARSET/charset=UTF-8/' $@ diff --git a/loader/cdinstall.c b/loader/cdinstall.c deleted file mode 100644 index b0f8ffb..0000000 --- a/loader/cdinstall.c +++ /dev/null @@ -1,421 +0,0 @@ -/* - * cdinstall.c - code to set up cdrom installs - * - * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Red Hat, Inc. - * All rights reserved. - * - * 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 of the License, 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, see <http://www.gnu.org/licenses/>. - * - * Author(s): Erik Troan <ewt@redhat.com> - * Matt Wilson <msw@redhat.com> - * Michael Fulbright <msf@redhat.com> - * Jeremy Katz <katzj@redhat.com> - */ - -#include <ctype.h> -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <newt.h> -#include <stdlib.h> -#include <string.h> -#include <sys/mount.h> -#include <sys/ioctl.h> -#include <unistd.h> -/* FIXME Remove hack when: https://bugzilla.redhat.com/show_bug.cgi?id=478663 - is resolved */ -/* Hack both __BIG_ENDIAN and __LITTLE_ENDIAN get defined by glibc, the - kernel headers we need do not like this! */ -#if __BYTE_ORDER == __LITTLE_ENDIAN -#undef __BIG_ENDIAN -#else -#undef __LITTLE_ENDIAN -#endif -#include <asm/types.h> -#include <limits.h> -#include <linux/cdrom.h> - -#include "kickstart.h" -#include "loader.h" -#include "loadermisc.h" -#include "lang.h" -#include "modules.h" -#include "method.h" -#include "cdinstall.h" -#include "mediacheck.h" -#include "windows.h" - -#include "../pyanaconda/isys/imount.h" -#include "../pyanaconda/isys/isys.h" -#include "../pyanaconda/isys/log.h" -#include "../pyanaconda/isys/mem.h" - -/* boot flags */ -extern uint64_t flags; - -/* ejects the CD device the device node points at */ -static void ejectCdrom(char *device) { - int ejectfd; - - if (!device) return; - - if (FL_NOEJECT(flags)) { - logMessage(INFO, "noeject in effect, not ejecting cdrom"); - return; - } - - logMessage(INFO, "ejecting %s...",device); - if ((ejectfd = open(device, O_RDONLY | O_NONBLOCK, 0)) >= 0) { - ioctl(ejectfd, CDROM_LOCKDOOR, 0); - if (ioctl(ejectfd, CDROMEJECT, 0)) - logMessage(ERROR, "eject failed on device %s: %m", device); - close(ejectfd); - } else { - logMessage(ERROR, "could not open device %s: %m", device); - } -} - -static char *cdrom_drive_status(int rc) { - struct { - int code; - char *str; - } status_codes[] = - { - { CDS_NO_INFO, "CDS_NO_INFO" }, - { CDS_NO_DISC, "CDS_NO_DISC" }, - { CDS_TRAY_OPEN, "CDS_TRAY_OPEN" }, - { CDS_DRIVE_NOT_READY, "CDS_DRIVE_NOT_READY" }, - { CDS_DISC_OK, "CDS_DISC_OK" }, - { CDS_AUDIO, "CDS_AUDIO" }, - { CDS_DATA_1, "CDS_DATA_1" }, - { CDS_DATA_2, "CDS_DATA_2" }, - { CDS_XA_2_1, "CDS_XA_2_1" }, - { CDS_XA_2_2, "CDS_XA_2_2" }, - { CDS_MIXED, "CDS_MIXED" }, - { INT_MAX, NULL }, - }; - int i; - - if (rc < 0) - return strerror(-rc); - - for (i = 0; status_codes[i].code != INT_MAX; i++) { - if (status_codes[i].code == rc) - return status_codes[i].str; - } - return NULL; -} - -static int waitForCdromTrayClose(int fd) { - int rc; - int prev = INT_MAX; - - do { - char *status = NULL; - rc = ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT); - if (rc < 0) - rc = -errno; - - /* only bother to print the status if it changes */ - if (prev == INT_MAX || prev != rc) { - status = cdrom_drive_status(rc); - if (status != NULL) { - logMessage(INFO, "drive status is %s", status); - } else { - logMessage(INFO, "drive status is unknown status code %d", rc); - } - } - prev = rc; - if (rc == CDS_DRIVE_NOT_READY) - usleep(100000); - } while (rc == CDS_DRIVE_NOT_READY); - return rc; -} - -static void closeCdromTray(char *device) { - int fd; - - if (!device || !*device) - return; - - logMessage(INFO, "closing CD tray on %s .", device); - if ((fd = open(device, O_RDONLY | O_NONBLOCK, 0)) >= 0) { - if (ioctl(fd, CDROMCLOSETRAY, 0)) { - logMessage(ERROR, "closetray failed on device %s: %m", device); - } else { - waitForCdromTrayClose(fd); - ioctl(fd, CDROM_LOCKDOOR, 1); - } - close(fd); - } else { - logMessage(ERROR, "could not open device %s: %m", device); - } -} - -/* Given cd device cddriver, this function will attempt to check its internal - * checksum. - */ -static void mediaCheckCdrom(char *cddriver) { - char *descr, *tstamp; - - closeCdromTray(cddriver); - readStampFileFromIso(cddriver, &tstamp, &descr); - doMediaCheck(cddriver, descr); - - if (descr) - free(descr); - - if (tstamp) - free(tstamp); -} - -/* output an error message when CD in drive is not the correct one */ -/* Used by mountCdromStage2() */ -static void wrongCDMessage(void) { - newtWinMessage(_("Error"), _("OK"), - _("The %s disc was not found " - "in any of your drives. Please insert " - "the %s disc and press %s to retry."), - getProductName(), getProductName(), _("OK")); -} - -/* ask about doing media check */ -void queryCDMediaCheck(char *instRepo) { - int rc; - char *tmp, *device; - - /* dont bother to test in automated installs */ - if (FL_KICKSTART(flags) && !FL_MEDIACHECK(flags)) - return; - - /* Skip over the leading "cdrom://". */ - tmp = instRepo+8; - checked_asprintf(&device, "%.*s", (int) (strchr(tmp, ':')-tmp), tmp); - - /* see if we should check image(s) */ - /* in rescue mode only test if they explicitly asked to */ - if (!FL_RESCUE(flags) || FL_MEDIACHECK(flags)) { - startNewt(); - rc = newtWinChoice(_("Disc Found"), _("OK"), _("Skip"), - _("To begin testing the media before installation press %s. " - "Choose %s to skip the media test and start the installation."), - _("OK"), _("Skip")); - - if (rc != 2) { - /* We already mounted the CD earlier to verify there's installation - * media. Now we need to unmount it to perform the check, then - * remount to pretend nothing ever happened. - */ - umount("/mnt/install/source"); - mediaCheckCdrom(device); - - do { - if (doPwMount(device, "/mnt/install/source", "iso9660", "ro", NULL)) { - ejectCdrom(device); - wrongCDMessage(); - continue; - } - - if (access("/mnt/install/source/.discinfo", R_OK)) { - umount("/mnt/install/source"); - ejectCdrom(device); - wrongCDMessage(); - continue; - } - - break; - } while (1); - } - } - - free(device); -} - -int findInstallCD(struct loaderData_s *loaderData) { - int i, rc; - struct device **devices; - - devices = getDevices(DEVICE_CDROM); - if (!devices) { - logMessage(ERROR, "got to findInstallCD without a CD device"); - return LOADER_ERROR; - } - - for (i = 0; devices[i]; i++) { - char *tmp = NULL; - int fd; - - if (!devices[i]->device) - continue; - - if (strncmp("/dev/", devices[i]->device, 5)) { - checked_asprintf(&tmp, "/dev/%s", devices[i]->device); - - free(devices[i]->device); - devices[i]->device = tmp; - } - - logMessage(INFO, "trying to mount CD device %s on /mnt/install/source", - devices[i]->device); - - if (!FL_CMDLINE(flags)) - winStatus(60, 3, _("Scanning"), _("Looking for installation media on CD device %s "), devices[i]->device); - else - printf(_("Looking for installation media on CD device %s"), devices[i]->device); - - fd = open(devices[i]->device, O_RDONLY | O_NONBLOCK); - if (fd < 0) { - logMessage(ERROR, "Couldn't open %s: %m", devices[i]->device); - if (!FL_CMDLINE(flags)) - newtPopWindow(); - continue; - } - - rc = waitForCdromTrayClose(fd); - close(fd); - switch (rc) { - case CDS_NO_INFO: - logMessage(ERROR, "Drive tray reports CDS_NO_INFO"); - break; - case CDS_NO_DISC: - if (!FL_CMDLINE(flags)) - newtPopWindow(); - continue; - case CDS_TRAY_OPEN: - logMessage(ERROR, "Drive tray reports open when it should be closed"); - break; - default: - break; - } - - if (!FL_CMDLINE(flags)) - newtPopWindow(); - - if ((rc = doPwMount(devices[i]->device, "/mnt/install/source", "iso9660", "ro", NULL)) == 0) { - if (!access("/mnt/install/source/.treeinfo", R_OK) && !access("/mnt/install/source/.discinfo", R_OK)) { - loaderData->method = METHOD_CDROM; - checked_asprintf(&loaderData->instRepo, "cdrom://%s:/mnt/install/source", devices[i]->device); - return LOADER_OK; - } else { - /* This wasn't the CD we were looking for. Clean up and - * try the next drive. - */ - umount("/mnt/install/source"); - } - } - } - - return LOADER_ERROR; -} - -int promptForCdrom(struct loaderData_s *loaderData) { - int rc; - - do { - rc = findInstallCD(loaderData); - - if (loaderData->instRepo && rc == LOADER_OK) { - queryCDMediaCheck(loaderData->instRepo); - return rc; - } else { - char * buf; - - checked_asprintf(&buf, _("The %s disc was not found in any of your " - "CDROM drives. Please insert the %s disc " - "and press %s to retry."), - getProductName(), getProductName(), _("OK")); - - rc = newtWinChoice(_("Disc Not Found"), - _("OK"), _("Back"), buf, _("OK")); - free(buf); - if (rc == 2) - return LOADER_BACK; - } - } while (!loaderData->instRepo); - - return LOADER_OK; -} - -int loadCdromImages(struct loaderData_s *loaderData) { - char *device = NULL; - char *tmp; - - logMessage(DEBUGLVL, "looking for extras for CD/DVD install"); - - if (!loaderData->instRepo) - return 0; - - /* Skip over the leading "cdrom://". */ - tmp = loaderData->instRepo+8; - checked_asprintf(&device, "%.*s", (int) (strchr(tmp, ':')-tmp), tmp); - - if (doPwMount(device, "/mnt/install/source", "auto", "ro", NULL)) - return 0; - - logMessage(INFO, "Looking for updates in /mnt/install/source/images/updates.img"); - copyUpdatesImg("/mnt/install/source/images/updates.img"); - - logMessage(INFO, "Looking for product in /mnt/install/source/images/product.img"); - copyProductImg("/mnt/install/source/images/product.img"); - - umount("/mnt/install/source"); - return 1; -} - -int kickstartFromCD(char *kssrc) { - int rc, i; - char *p, *kspath; - struct device ** devices; - - logMessage(INFO, "getting kickstart file from first CDROM"); - - devices = getDevices(DEVICE_CDROM); - /* usb can take some time to settle, even with the various hacks we - * have in place. some systems use portable USB CD-ROM drives, try to - * make sure there really isn't one before bailing */ - for (i = 0; !devices && i < 10; ++i) { - logMessage(INFO, "sleeping to wait for a USB CD-ROM"); - sleep(2); - devices = getDevices(DEVICE_CDROM); - } - if (!devices) { - logMessage(ERROR, "No CDROM devices found!"); - return 1; - } - - /* format is cdrom:[/path/to/ks.cfg] */ - kspath = ""; - p = strchr(kssrc, ':'); - if (p) - kspath = p + 1; - - if (!p || strlen(kspath) < 1) - kspath = "/ks.cfg"; - - for (i=0; devices[i]; i++) { - if (!devices[i]->device) - continue; - - rc = getKickstartFromBlockDevice(devices[i]->device, kspath); - if (rc == 0) - return 0; - } - - startNewt(); - newtWinMessage(_("Error"), _("OK"), - _("Cannot find kickstart file on CDROM.")); - return 1; -} - -/* vim:set shiftwidth=4 softtabstop=4 et */ diff --git a/loader/cdinstall.h b/loader/cdinstall.h deleted file mode 100644 index f883e7a..0000000 --- a/loader/cdinstall.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * cdinstall.h - * - * Copyright (C) 2007 Red Hat, Inc. All rights reserved. - * - * 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 of the License, 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, see <http://www.gnu.org/licenses/>. - */ - -#ifndef H_CDINSTALL -#define H_CDINSTALL - -#include "method.h" - -int findInstallCD(struct loaderData_s *loaderData); -int promptForCdrom(struct loaderData_s *loaderData); -int loadCdromImages(struct loaderData_s *loaderData); -void queryCDMediaCheck(char *instRepo); - -int kickstartFromCD(char *kssrc); -#endif diff --git a/loader/copy.c b/loader/copy.c deleted file mode 100644 index 1c61233..0000000 --- a/loader/copy.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * copy.c - functions for copying files and directories - * - * Copyright (C) 2007 Red Hat, Inc. All rights reserved. - * - * 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 of the License, 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, see <http://www.gnu.org/licenses/>. - */ - -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <stdio.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> - -#include "lang.h" - -/* Recursive */ -int copyDirectory(char * from, char * to, void (*warnFn)(char *), - void (*errorFn)(char *)) { - char *msg; - DIR * dir; - struct dirent * ent; - int fd, outfd; - char buf[4096]; - int i; - struct stat sb; - char filespec[256]; - char filespec2[256]; - char link[1024]; - - mkdir(to, 0755); - - if (!(dir = opendir(from))) { - if (errorFn) { - if (asprintf(&msg, N_("Failed to read directory %s: %m"), from) == -1) { - fprintf(stderr, "%s: %d: %m ", __func__, __LINE__); - fflush(stderr); - abort(); - } - - errorFn(msg); - free(msg); - } - - return 1; - } - - errno = 0; - while ((ent = readdir(dir))) { - if (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) - continue; - - sprintf(filespec, "%s/%s", from, ent->d_name); - sprintf(filespec2, "%s/%s", to, ent->d_name); - - lstat(filespec, &sb); - - if (S_ISDIR(sb.st_mode)) { - if (copyDirectory(filespec, filespec2, warnFn, errorFn)) { - closedir(dir); - return 1; - } - } else if (S_ISLNK(sb.st_mode)) { - i = readlink(filespec, link, sizeof(link) - 1); - link[i] = ' '; - if (symlink(link, filespec2)) { - if (warnFn) { - if (asprintf(&msg, "Failed to symlink %s to %s: %m", - filespec2, link) == -1) { - fprintf(stderr, "%s: %d: %m ", __func__, __LINE__); - fflush(stderr); - abort(); - } - - warnFn(msg); - free(msg); - } - } - } else { - fd = open(filespec, O_RDONLY); - if (fd == -1) { - if (errorFn) { - if (asprintf(&msg, "Failed to open %s: %m", filespec) == -1) { - fprintf(stderr, "%s: %d: %m ", __func__, __LINE__); - fflush(stderr); - abort(); - } - - errorFn(msg); - free(msg); - } - - closedir(dir); - return 1; - } - outfd = open(filespec2, O_RDWR | O_TRUNC | O_CREAT, 0644); - if (outfd == -1) { - if (warnFn) { - if (asprintf(&msg, "Failed to create %s: %m", filespec2) == -1) { - fprintf(stderr, "%s: %d: %m ", __func__, __LINE__); - fflush(stderr); - abort(); - } - - warnFn(msg); - free(msg); - } - } else { - fchmod(outfd, sb.st_mode & 07777); - - while ((i = read(fd, buf, sizeof(buf))) > 0) - i = write(outfd, buf, i); - close(outfd); - } - - close(fd); - } - - errno = 0; - } - - closedir(dir); - - return 0; -} diff --git a/loader/copy.h b/loader/copy.h deleted file mode 100644 index 1153bf8..0000000 --- a/loader/copy.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * copy.h - * - * Copyright (C) 2007 Red Hat, Inc. All rights reserved. - * - * 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 of the License, 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, see <http://www.gnu.org/licenses/>. - */ - -#ifndef H_COPY -#define H_COPY - -int copyDirectory (char *from, char *to, void (*warnFn)(char *), - void (*errorFn)(char *)); - -#endif diff --git a/loader/dirbrowser.c b/loader/dirbrowser.c deleted file mode 100644 index e4bc9d4..0000000 --- a/loader/dirbrowser.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * dirbrowser.c - newt-based directory browser to get a file name - * - * Copyright (C) 2004 Red Hat, Inc. All rights reserved. - * - * 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 of the License, 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, see <http://www.gnu.org/licenses/>. - * - * Author(s): Jeremy Katz <katzj@redhat.com> - */ - -#include <newt.h> -#include <stdio.h> -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/types.h> -#include <dirent.h> -#include <errno.h> -#include <string.h> -#include <sys/stat.h> - -#include "dirbrowser.h" - -#ifndef STANDALONE -#include "../pyanaconda/isys/log.h" - -#include "loader.h" -#include "loadermisc.h" -#include "lang.h" -#endif - -#ifdef STANDALONE -#define _(x) x - -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); -} -#endif - -#define FSTEP 10 - -/* Return a NULL terminated list of the directory contents, non-recursively. - * Return a NULL if the directory cannot be opened. - * - * dirname -- The directory to list. - * filterfunc -- An optional function to use for filtering out the results. - * If this function returns 1, the directory is included. - * Otherwise, it is omitted. - */ -char ** get_file_list(char * dirname, filterfunc_t filterfunc) { - DIR * dir; - struct dirent *entry; - char ** files; - int numfiles = FSTEP, i = 0; - - dir = opendir(dirname); - if (dir == NULL) { - fprintf(stderr, "error opening %s: %m", dirname); - return NULL; - } - - files = malloc(numfiles * sizeof(char *)); - - while ((entry = readdir(dir))) { - if ((strlen(entry->d_name) == 1) && !strncmp(entry->d_name, ".", 1)) - continue; - if ((strlen(entry->d_name) == 2) && !strncmp(entry->d_name, "..", 2)) - continue; - if (filterfunc && !filterfunc(dirname, entry)) - continue; - - files[i] = strdup(entry->d_name); - if (i++ >= (numfiles - 1)) { - numfiles += FSTEP; - files = realloc(files, numfiles * sizeof(char *)); - } - } - files[i] = NULL; - closedir(dir); - - qsort(files, i, sizeof(*files), simpleStringCmp); - return files; -} - -/* Browse through a directory structure looking for a file. - * Returns the full path to the file. - * - * Parameters: - * title: Title for newt dialog window - * dirname: Directory to use for root of browsing. NOTE: you cannot go - * up above this root. - * filterfunc: An (optional) function to filter out files based on whatever - * criteria you want. Returns 1 if it passes, 0 if not. - * Function should take arguments of the directory name and - * the dirent for the file. - */ -char * newt_select_file(char * title, char * text, char * dirname, - filterfunc_t filterfunc) { - char ** files; - char * fn = NULL; - int i, done = 0; - char * topdir = dirname; - char * dir = malloc(PATH_MAX); - char * path = NULL; - newtGrid grid, buttons; - newtComponent f, tb, listbox, ok, cancel; - struct stat sb; - struct newtExitStruct es; - - dir = realpath(dirname, dir); - - do { - files = get_file_list(dir, filterfunc); - - f = newtForm(NULL, NULL, 0); - grid = newtCreateGrid(1, 4); - - tb = newtTextboxReflowed(-1, -1, text, 60, 0, 10, 0); - - listbox = newtListbox(12, 65, 10, - NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); - - newtListboxSetWidth(listbox, 55); - buttons = newtButtonBar(_("OK"), &ok, _("Cancel"), &cancel, NULL); - newtGridSetField(grid, 0, 0, NEWT_GRID_COMPONENT, tb, - 0, 0, 0, 1, 0, 0); - newtGridSetField(grid, 0, 1, NEWT_GRID_COMPONENT, listbox, - 0, 0, 0, 1, 0, 0); - newtGridSetField(grid, 0, 3, NEWT_GRID_SUBGRID, buttons, - 0, 0, 0, 0, 0, NEWT_GRID_FLAG_GROWX); - - /* if this isn't our topdir, we want to let them go up a dir */ - if (strcmp(topdir, dir)) - newtListboxAppendEntry(listbox, "../", ".."); - - for (i = 0; files && (files[i] != NULL); i++) { - if ((files[i] == NULL) || (strlen(files[i]) == 0)) continue; - path = malloc(strlen(files[i]) + strlen(dir) + 2); - sprintf(path, "%s/%s", dir, files[i]); - stat(path, &sb); - free(path); - if (S_ISDIR(sb.st_mode)) { - char *dir = malloc(strlen(files[i]) + 2); - sprintf(dir, "%s/", files[i]); - newtListboxAppendEntry(listbox, dir, files[i]); - } else { - newtListboxAppendEntry(listbox, files[i], files[i]); - } - } - - newtGridWrappedWindow(grid, title); - newtGridAddComponentsToForm(grid, f, 1); - newtFormRun(f, &es); - - if (es.reason == NEWT_EXIT_COMPONENT && es.u.co == cancel) { - fn = NULL; - done = -1; - } else { - fn = (char *) newtListboxGetCurrent(listbox); - path = malloc(strlen(fn) + strlen(dir) + 2); - sprintf(path, "%s/%s", dir, fn); - - stat(path, &sb); - if (!S_ISDIR(sb.st_mode)) { - fn = path; - done = 1; - } else { - dir = realpath(path, dir); - free(path); - } - } - - newtGridFree(grid, 1); - newtFormDestroy(f); - newtPopWindow(); - } while (done == 0); - - return fn; -} - -#ifdef STANDALONE -int main(int argc, char ** argv) { - char * foo; - - newtInit(); - newtCls(); - - foo = newt_select_file("Get File Name", "foo, blah blah blah", - "/etc", NULL); - newtFinished(); - printf("got %s ", foo); - return 0; -} -#endif diff --git a/loader/dirbrowser.h b/loader/dirbrowser.h deleted file mode 100644 index 77f5681..0000000 --- a/loader/dirbrowser.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * dirbrowser.h - * - * Copyright (C) 2007 Red Hat, Inc. All rights reserved. - * - * 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 of the License, 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, see <http://www.gnu.org/licenses/>. - */ - -#ifndef DIRBROWSER_H -#define DIRBROWSER_H - -#include <dirent.h> - -typedef int (*filterfunc_t)(char *, struct dirent *); - -char **get_file_list(char *dirname, filterfunc_t filterfunc); - -char * newt_select_file(char * title, char * text, char * dirname, - filterfunc_t filterfunc); - -#endif diff --git a/loader/driverdisk.c b/loader/driverdisk.c deleted file mode 100644 index f6af331..0000000 --- a/loader/driverdisk.c +++ /dev/null @@ -1,795 +0,0 @@ -/* - * driverdisk.c - driver disk functionality - * - * Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc. - * All rights reserved. - * - * 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 of the License, 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, see <http://www.gnu.org/licenses/>. - * - * Author(s): Jeremy Katz <katzj@redhat.com> - */ - -#include <errno.h> -#include <fcntl.h> -#include <newt.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <sys/stat.h> -#include <unistd.h> -#include <glib.h> - -#include <blkid/blkid.h> - -#include <glob.h> -#include <rpm/rpmlib.h> -#include <sys/utsname.h> - -#include "copy.h" -#include "loader.h" -#include "loadermisc.h" -#include "lang.h" -#include "fwloader.h" -#include "method.h" -#include "modules.h" -#include "moduleinfo.h" -#include "windows.h" -#include "hardware.h" -#include "driverdisk.h" -#include "getparts.h" -#include "dirbrowser.h" - -#include "nfsinstall.h" -#include "urlinstall.h" - -#include "rpmextract.h" -#include "unpack.h" - -#include "../pyanaconda/isys/isys.h" -#include "../pyanaconda/isys/imount.h" -#include "../pyanaconda/isys/eddsupport.h" -#include "../pyanaconda/isys/log.h" - -/* boot flags */ -extern uint64_t flags; - -/* - * check if the RPM in question provides - * Provides: <dep> = <version> - * we use it to check if kernel-modules = <kernelversion> - */ -int dlabelProvides(const char* dep, const char* version, void *userptr) -{ - char *kernelver = (char*)userptr; - - logMessage(DEBUGLVL, "Provides: %s = %s", dep, version); - - if (version == NULL) - return -1; - - return strcmp(dep, "kernel-modules") || strcmp(version, kernelver); -} - -/* - * during cpio extraction, only extract files we need - * eg. module .ko files and firmware directory - */ -int dlabelFilter(const char* name, const struct stat *fstat, void *userptr) -{ - int l = strlen(name); - - logMessage(DEBUGLVL, "Unpacking %s", name); - - /* we want firmware files */ - if (strstr(name, "lib/firmware/") == NULL) - return 0; - - if (l<3) - return 1; - l-=3; - - /* and we want only .ko files */ - if (strcmp(".ko", name+l)) - return 1; - - /* TODO we are unpacking kernel module, read it's description */ - - return 0; -} - -char* moduleDescription(const char* modulePath) -{ - char *command = NULL; - FILE *f = NULL; - char *description = NULL; - int size; - - checked_asprintf(&command, "modinfo --description '%s'", modulePath); - f = popen(command, "r"); - free(command); - - if (f==NULL) - return NULL; - - description = malloc(sizeof(char)*256); - if (!description) - return NULL; - - size = fread(description, 1, 255, f); - if (size == 0) { - free(description); - return NULL; - } - - description[size-1]=0; /* strip the trailing newline */ - pclose(f); - - return description; -} - -int globErrFunc(const char *epath, int eerrno) -{ - /* TODO check fatal errors */ - - return 0; -} - -int dlabelUnpackRPMDir(char* rpmdir, char* destination, char *kernelver) -{ - char *globpattern; - int rc = 0; - - checked_asprintf(&globpattern, "%s/*.rpm", rpmdir); - glob_t globres; - char** globitem; - if (!glob(globpattern, GLOB_NOSORT|GLOB_NOESCAPE, globErrFunc, &globres)) { - /* iterate over all rpm files */ - globitem = globres.gl_pathv; - while (globres.gl_pathc>0 && globitem != NULL && *globitem != NULL) { - explodeRPM(*globitem, dlabelFilter, dlabelProvides, NULL, kernelver, destination); - globitem++; - } - globfree(&globres); - /* end of iteration */ - } - free(globpattern); - - return rc; -} - - -static char * driverDiskFiles[] = { "repodata", NULL }; - -static int verifyDriverDisk(char *mntpt) { - char ** fnPtr; - char file[200]; - struct stat sb; - - /* check for dd descriptor */ - sprintf(file, "%s/rhdd3", mntpt); - if (access(file, R_OK)) { - logMessage(ERROR, "can't find driver disk identifier, bad " - "driver disk"); - return LOADER_BACK; - } - - /* side effect: file is still mntpt/ddident */ - stat(file, &sb); - if (!sb.st_size) - return LOADER_BACK; - - for (fnPtr = driverDiskFiles; *fnPtr; fnPtr++) { - snprintf(file, 200, "%s/rpms/%s/%s", mntpt, getProductArch(), *fnPtr); - if (access(file, R_OK)) { - logMessage(ERROR, "cannot find %s, bad driver disk", file); - return LOADER_BACK; - } - } - - return LOADER_OK; -} - -static void copyWarnFn (char *msg) { - logMessage(WARNING, msg); -} - -static void copyErrorFn (char *msg) { - newtWinMessage(_("Error"), _("OK"), _(msg)); -} - -/* this copies the contents of the driver disk to a ramdisk and loads - * the moduleinfo, etc. assumes a "valid" driver disk mounted at mntpt */ -static int loadDriverDisk(struct loaderData_s *loaderData, char *mntpt) { - /* FIXME moduleInfoSet modInfo = loaderData->modInfo; */ - char file[200], dest[200], src[200]; - char *title; - char *fwdir = NULL; - struct moduleBallLocation * location; - struct stat sb; - static int disknum = 0; - int rc, fd; - char *kernelver; - struct utsname unamedata; - - /* check for new version */ - sprintf(file, "%s/rhdd3", mntpt); - if (access(file, R_OK)) { - /* this can't happen, we already verified it! */ - return LOADER_BACK; - } - stat(file, &sb); - title = malloc(sb.st_size + 1); - - fd = open(file, O_RDONLY); - read(fd, title, sb.st_size); - if (title[sb.st_size - 1] == ' ') - sb.st_size--; - title[sb.st_size] = ' '; - close(fd); - - /* get running kernel version */ - rc = uname(&unamedata); - checked_asprintf(&kernelver, "%s", - rc ? "unknown" : unamedata.release); - logMessage(DEBUGLVL, "Kernel version: %s", kernelver); - - sprintf(file, DD_RPMDIR_TEMPLATE, disknum); - - if (unpack_mkpath(file) != ARCHIVE_OK || - unpack_mkpath(DD_MODULES) != ARCHIVE_OK || - unpack_mkpath(DD_FIRMWARE) != ARCHIVE_OK) - goto loadDriverDiscException; - - if (!FL_CMDLINE(flags)) { - startNewt(); - winStatus(40, 3, _("Loading"), _("Reading driver disk")); - } - - location = malloc(sizeof(struct moduleBallLocation)); - location->title = strdup(title); - checked_asprintf(&location->path, DD_MODULES); - - sprintf(dest, DD_RPMDIR_TEMPLATE, disknum); - sprintf(src, "%s/rpms/%s", mntpt, getProductArch()); - copyDirectory(src, dest, copyWarnFn, copyErrorFn); - - /* unpack packages from dest into location->path */ - if (dlabelUnpackRPMDir(dest, DD_EXTRACTED, kernelver)) { - /* fatal error, log this and jump to exception handler */ - logMessage(ERROR, "Error unpacking RPMs from driver disc no.%d", - disknum); - goto loadDriverDiscException; - } - - - /* ensure updates directory exists */ - sprintf(file, "/lib/modules/%s/updates", kernelver); - if (unpack_mkpath(file) != ARCHIVE_OK) - goto loadDriverDiscException; - - /* make sure driver update are referenced from system module dir - but from a different subdir, initrd overlays use the main - /lib/modules/<kernel>/updates - */ - sprintf(file, "/lib/modules/%s/updates/DD", kernelver); - rc = symlink(DD_MODULES, file); - - /* run depmod to refresh modules db */ - if (system("depmod -a")) { - /* this is not really fatal error, it might still work, log it */ - logMessage(ERROR, "Error running depmod -a for driverdisc no.%d", disknum); - } - - checked_asprintf(&fwdir, DD_FIRMWARE); - if (!access(fwdir, R_OK|X_OK)) { - add_fw_search_dir(loaderData, fwdir); - stop_fw_loader(loaderData); - start_fw_loader(loaderData); - } - free(fwdir); - - /* TODO generate and read module info - * - * sprintf(file, "%s/modinfo", mntpt); - * readModuleInfo(file, modInfo, location, 1); - */ - -loadDriverDiscException: - - /* cleanup */ - free(kernelver); - - if (!FL_CMDLINE(flags)) - newtPopWindow(); - - disknum++; - return 0; -} - -/* Get the list of removable devices (floppy/cdrom) available. Used to - * find suitable devices for update disk / driver disk source. - * Returns the number of devices. ***devNames will be a NULL-terminated list - * of device names - */ -int getRemovableDevices(char *** devNames) { - struct device **devs; - int numDevices = 0; - int i = 0; - - devs = getDevices(DEVICE_DISK | DEVICE_CDROM); - - if(devs) for (i = 0; devs[i] ; i++) { - logMessage(DEBUGLVL, "Considering device %s (isremovable: %d)", devs[i]->device, devs[i]->priv.removable); - - /* XXX Filter out memory devices from the list for now, we have to come - up with smarter way of filtering someday.. */ - if (strncmp(devs[i]->device, "ram", 3) && strncmp(devs[i]->device, "loop", 4)) { - *devNames = realloc(*devNames, (numDevices + 2) * sizeof(char *)); - (*devNames)[numDevices] = strdup(devs[i]->device); - (*devNames)[numDevices+1] = NULL; - numDevices ++; - } - } - if (!numDevices) { - logMessage(ERROR, "no devices found to load drivers from"); - } - return numDevices; -} - -/* Prompt for loading a driver from "media" - * - * class: type of driver to load. - * usecancel: if 1, use cancel instead of back - */ -int loadDriverFromMedia(int class, struct loaderData_s *loaderData, - int usecancel, int noprobe, GTree *moduleState) { - char * device = NULL, * part = NULL, * ddfile = NULL; - char ** devNames = NULL; - enum { DEV_DEVICE, DEV_PART, DEV_CHOOSEFILE, DEV_LOADFILE, - DEV_INSERT, DEV_LOAD, DEV_PROBE, - DEV_DONE } stage = DEV_DEVICE; - int rc, num = 0; - int dir = 1; - int found = 0, before = 0; - VersionState preDDstate, postDDstate; - - while (stage != DEV_DONE) { - switch(stage) { - case DEV_DEVICE: - rc = getRemovableDevices(&devNames); - if (rc == 0) - return LOADER_BACK; - - /* we don't need to ask which to use if they only have one */ - if (rc == 1) { - device = strdup(devNames[0]); - free(devNames); - if (dir == -1) - return LOADER_BACK; - - stage = DEV_PART; - break; - } - dir = 1; - - startNewt(); - rc = newtWinMenu(_("Driver Disk Source"), - _("You have multiple devices which could serve " - "as sources for a driver disk. Which would " - "you like to use?"), 40, 10, 10, - rc < 6 ? rc : 6, devNames, - &num, _("OK"), - (usecancel) ? _("Cancel") : _("Back"), NULL); - - if (rc == 2) { - free(devNames); - return LOADER_BACK; - } - device = strdup(devNames[num]); - free(devNames); - - stage = DEV_PART; - case DEV_PART: { - char ** part_list = getPartitionsList(device); - int nump = 0, num = 0; - - if (part != NULL) - free(part); - - if ((nump = g_strv_length(part_list)) == 0) { - if (dir == -1) - stage = DEV_DEVICE; - else - stage = DEV_INSERT; - break; - } - dir = 1; - - startNewt(); - rc = newtWinMenu(_("Driver Disk Source"), - _("There are multiple partitions on this device " - "which could contain the driver disk image. " - "Which would you like to use?"), 40, 10, 10, - nump < 6 ? nump : 6, part_list, &num, _("OK"), - _("Back"), NULL); - - if (rc == 2) { - g_strfreev(part_list); - stage = DEV_DEVICE; - dir = -1; - break; - } - - part = strdup(part_list[num]); - stage = DEV_CHOOSEFILE; - - } - - case DEV_CHOOSEFILE: { - if (part == NULL) { - logMessage(ERROR, "somehow got to choosing file with a NULL part, going back"); - stage = DEV_PART; - break; - } - /* make sure nothing is mounted when we get here */ - num = umount("/mnt/install/dpart"); - if (num == -1) { - logMessage(ERROR, "error unmounting: %m"); - if ((errno != EINVAL) && (errno != ENOENT)) - exit(1); - } - - logMessage(INFO, "trying to mount %s as partition", part); - if (doPwMount(part, "/mnt/install/dpart", "auto", "ro", NULL)) { - newtWinMessage(_("Error"), _("OK"), - _("Failed to mount partition.")); - stage = DEV_PART; - break; - } - - ddfile = newt_select_file(_("Select driver disk image"), - _("Select the file which is your driver " - "disk image."), - "/mnt/install/dpart", NULL); - if (ddfile == NULL) { - umount("/mnt/install/dpart"); - stage = DEV_PART; - dir = -1; - break; - } - dir = 1; - - stage = DEV_LOADFILE; - } - - case DEV_LOADFILE: { - if (ddfile == NULL) { - logMessage(DEBUGLVL, "trying to load dd from NULL"); - stage = DEV_CHOOSEFILE; - break; - } - if (dir == -1) { - umount("/mnt/install/drivers"); - unlink("/mnt/install/drivers"); - ddfile = NULL; - stage = DEV_CHOOSEFILE; - break; - } - if (doPwMount(ddfile, "/mnt/install/drivers", "auto", "ro", NULL)) { - newtWinMessage(_("Error"), _("OK"), - _("Failed to load driver disk from file.")); - stage = DEV_CHOOSEFILE; - break; - } - stage = DEV_LOAD; - break; - } - - case DEV_INSERT: { - char * buf; - - checked_asprintf(&buf, - _("Insert your driver disk into /dev/%s " - "and press "OK" to continue."), device); - - rc = newtWinChoice(_("Insert Driver Disk"), _("OK"), _("Back"), - buf); - free(buf); - if (rc == 2) { - stage = DEV_DEVICE; - dir = -1; - break; - } - dir = 1; - - logMessage(INFO, "trying to mount %s", device); - if (doPwMount(device, "/mnt/install/drivers", "auto", "ro", NULL)) { - newtWinMessage(_("Error"), _("OK"), - _("Failed to mount driver disk.")); - stage = DEV_INSERT; - break; - } - - rc = verifyDriverDisk("/mnt/install/drivers"); - if (rc == LOADER_BACK) { - newtWinMessage(_("Error"), _("OK"), - _("Driver disk is invalid for this " - "release of %s."), getProductName()); - umount("/mnt/install/drivers"); - stage = DEV_INSERT; - break; - } - - stage = DEV_LOAD; - break; - } - case DEV_LOAD: { - struct device ** devices; - - before = 0; - found = 0; - - devices = getDevices(class); - if (devices) - for(; devices[before]; before++); - - rc = loadDriverDisk(loaderData, "/mnt/install/drivers"); - umount("/mnt/install/drivers"); - if (rc == LOADER_BACK) { - dir = -1; - if (ddfile != NULL) - stage = DEV_CHOOSEFILE; - else - stage = DEV_INSERT; - break; - } - /* fall through to probing */ - stage = DEV_PROBE; - - if (ddfile != NULL) { - umount("/mnt/install/drivers"); - unlink("/mnt/install/drivers"); - umount("/mnt/install/dpart"); - } - } - - case DEV_PROBE: { - /* if they didn't specify that we should probe, then we should - * just fall out */ - if (noprobe) { - stage = DEV_DONE; - break; - } - - /* Get info about modules before the update */ - preDDstate = mlVersions(); - - /* Unload all devices and load them again to use the updated modules */ - logMessage(INFO, "Trying to refresh loaded drivers"); - mlRestoreModuleState(moduleState); - busProbe(0); - - /* Get info about modules after the update */ - postDDstate = mlVersions(); - found = mlDetectUpdate(preDDstate, postDDstate); - logMessage(DEBUGLVL, "mlDetectUpdate returned %d", found); - - mlFreeVersions(postDDstate); - mlFreeVersions(preDDstate); - - if (found) { - stage = DEV_DONE; - break; - } - - /* we don't have any more modules of the proper class. ask - * them to manually load */ - rc = newtWinTernary(_("Error"), _("Manually choose"), - _("Continue"), _("Load another disk"), - _("No devices of the appropriate type were " - "found on this driver disk. Would you " - "like to manually select the driver, " - "continue anyway, or load another " - "driver disk?")); - - if (rc == 2) { - /* if they choose to continue, just go ahead and continue */ - stage = DEV_DONE; - } else if (rc == 3) { - /* if they choose to load another disk, back to the - * beginning with them */ - stage = DEV_DEVICE; - } else { - rc = chooseManualDriver(class, loaderData); - /* if they go back from a manual driver, we'll ask again. - * if they load something, assume it's what we need */ - if (rc == LOADER_OK) { - stage = DEV_DONE; - } - } - - break; - } - - case DEV_DONE: - break; - } - } - - return LOADER_OK; -} - - -/* looping way to load driver disks */ -int loadDriverDisks(int class, struct loaderData_s *loaderData, GTree *moduleState) { - int rc; - - rc = newtWinChoice(_("Driver disk"), _("Yes"), _("No"), - _("Do you have a driver disk?")); - if (rc != 1) - return LOADER_OK; - - rc = loadDriverFromMedia(DEVICE_ANY, loaderData, 1, 0, moduleState); - if (rc == LOADER_BACK) - return LOADER_OK; - - do { - rc = newtWinChoice(_("More Driver Disks?"), _("Yes"), _("No"), - _("Do you wish to load any more driver disks?")); - if (rc != 1) - break; - loadDriverFromMedia(DEVICE_ANY, loaderData, 0, 0, moduleState); - } while (1); - - return LOADER_OK; -} - -static void loadFromLocation(struct loaderData_s * loaderData, char * dir, GTree *moduleState) { - if (verifyDriverDisk(dir) == LOADER_BACK) { - logMessage(ERROR, "not a valid driver disk"); - return; - } - - loadDriverDisk(loaderData, dir); - - /* Unload all devices and load them again to use the updated modules */ - logMessage(INFO, "Trying to refresh loaded drivers"); - mlRestoreModuleState(moduleState); - busProbe(0); -} - -void getDDFromSource(struct loaderData_s * loaderData, char * src, GTree *moduleState) { - char *path = "/tmp/dd.img"; - int unlinkf = 0; - - if (!strncmp(src, "nfs:", 4)) { - unlinkf = 1; - if (getFileFromNfs(src + 4, "/tmp/dd.img", loaderData)) { - logMessage(ERROR, "unable to retrieve driver disk: %s", src); - return; - } - } else if (!strncmp(src, "ftp://", 6) || !strncmp(src, "http", 4)) { - unlinkf = 1; - if (getFileFromUrl(src, "/tmp/dd.img", loaderData)) { - logMessage(ERROR, "unable to retrieve driver disk: %s", src); - return; - } - /* FIXME: this is a hack so that you can load a driver disk from, eg, - * scsi cdrom drives */ -#if !defined(__s390__) && !defined(__s390x__) - } else if (!strncmp(src, "cdrom", 5)) { - loadDriverDisks(DEVICE_ANY, loaderData, moduleState); - return; -#endif - } else if (!strncmp(src, "path:", 5)) { - path = src + 5; - } else { - newtWinMessage(_("Kickstart Error"), _("OK"), - _("Unknown driver disk kickstart source: %s"), src); - return; - } - - if (!doPwMount(path, "/mnt/install/drivers", "auto", "ro", NULL)) { - loadFromLocation(loaderData, "/mnt/install/drivers", moduleState); - umount("/mnt/install/drivers"); - unlink("/mnt/install/drivers"); - if (unlinkf) unlink(path); - } - -} - -void getDDFromDev(struct loaderData_s * loaderData, char * dev, GTree* moduleState) { - if (doPwMount(dev, "/mnt/install/drivers", "auto", "ro", NULL)) { - logMessage(ERROR, "unable to mount driver disk %s", dev); - return; - } - - loadFromLocation(loaderData, "/mnt/install/drivers", moduleState); - umount("/mnt/install/drivers"); - unlink("/mnt/install/drivers"); -} - - -/* - * Look for partition with specific label (part of #316481) - */ -GSList* findDriverDiskByLabel(void) -{ - char *ddLabel = "OEMDRV"; - GSList *ddDevice = NULL; - blkid_cache bCache; - - int res; - blkid_dev_iterate bIter; - blkid_dev bDev; - - if (blkid_get_cache(&bCache, NULL)<0) { - logMessage(ERROR, "Cannot initialize cache instance for blkid"); - return NULL; - } - if ((res = blkid_probe_all(bCache))<0) { - logMessage(ERROR, "Cannot probe devices in blkid: %d", res); - return NULL; - } - if ((res = blkid_probe_all_removable(bCache))<0) { - logMessage(ERROR, "Cannot probe removable devices in blkid: %d", res); - } - - bIter = blkid_dev_iterate_begin(bCache); - blkid_dev_set_search(bIter, "LABEL", ddLabel); - while ((res = blkid_dev_next(bIter, &bDev)) == 0) { - bDev = blkid_verify(bCache, bDev); - if (!bDev) - continue; - - char *devname = strdup(blkid_dev_devname(bDev)); - logMessage(DEBUGLVL, "Adding driver disc %s to the list " - "of available DDs.", devname); - ddDevice = g_slist_prepend(ddDevice, (gpointer)devname); - /* Freeing bDev is taken care of by the put cache call */ - } - blkid_dev_iterate_end(bIter); - - blkid_put_cache(bCache); - - return ddDevice; -} - -int loadDriverDiskFromPartition(struct loaderData_s *loaderData, char* device) -{ - int rc; - - logMessage(INFO, "trying to mount %s", device); - if (doPwMount(device, "/mnt/install/drivers", "auto", "ro", NULL)) { - logMessage(ERROR, "Failed to mount driver disk."); - return -1; - } - - rc = verifyDriverDisk("/mnt/install/drivers"); - if (rc == LOADER_BACK) { - logMessage(ERROR, "Driver disk is invalid for this " - "release of %s.", getProductName()); - umount("/tmp/drivers"); - return -2; - } - - rc = loadDriverDisk(loaderData, "/mnt/install/drivers"); - umount("/mnt/install/drivers"); - if (rc == LOADER_BACK) { - return -3; - } - - return 0; -} - diff --git a/loader/driverdisk.h b/loader/driverdisk.h deleted file mode 100644 index 302a8c4..0000000 --- a/loader/driverdisk.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * driverdisk.h - * - * Copyright (C) 2007 Red Hat, Inc. All rights reserved. - * - * 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 of the License, 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, see <http://www.gnu.org/licenses/>. - */ - -#ifndef DRIVERDISK_H -#define DRIVERDISK_H - -#include "loader.h" -#include "modules.h" -#include "moduleinfo.h" - -#define DD_RPMDIR_TEMPLATE "/tmp/DD-%d" -#define DD_EXTRACTED "/tmp/DD" -#define DD_MODULES "/tmp/DD/lib/modules" -#define DD_FIRMWARE "/tmp/DD/lib/firmware" - -extern char *ddFsTypes[]; - -int loadDriverFromMedia(int class, struct loaderData_s *loaderData, - int usecancel, int noprobe, GTree *moduleState); - -int loadDriverDisks(int class, struct loaderData_s *loaderData, GTree *moduleState); - -int getRemovableDevices(char *** devNames); - -int chooseManualDriver(int class, struct loaderData_s *loaderData); - -void getDDFromSource(struct loaderData_s * loaderData, char * src, GTree *moduleState); -void getDDFromDev(struct loaderData_s * loaderData, char * dev, GTree *moduleState); - -int loadDriverDiskFromPartition(struct loaderData_s *loaderData, char* device); - -GSList* findDriverDiskByLabel(void); - -#endif diff --git a/loader/driverselect.c b/loader/driverselect.c deleted file mode 100644 index a563bad..0000000 --- a/loader/driverselect.c +++ /dev/null @@ -1,243 +0,0 @@ -/* - * driverselect.c - functionality for manually selecting drivers - * - * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. - * All rights reserved. - * - * 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 of the License, 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, see <http://www.gnu.org/licenses/>. - * - * Author(s): Erik Troan <ewt@redhat.com> - * Jeremy Katz <katzj@redhat.com> - */ - -#include <ctype.h> -#include <newt.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <errno.h> - -#include "../pyanaconda/isys/log.h" - -#include "modules.h" -#include "moduleinfo.h" -#include "loader.h" -#include "loadermisc.h" -#include "lang.h" -#include "driverdisk.h" - -struct sortModuleList { - int |
| All times are GMT. The time now is 07:50 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.