diff options
Diffstat (limited to 'mdk-stage1/tools.c')
-rw-r--r-- | mdk-stage1/tools.c | 84 |
1 files changed, 9 insertions, 75 deletions
diff --git a/mdk-stage1/tools.c b/mdk-stage1/tools.c index 95064f095..2e27688ea 100644 --- a/mdk-stage1/tools.c +++ b/mdk-stage1/tools.c @@ -1,5 +1,5 @@ /* - * Guillaume Cottenceau (gc@mandriva.com) + * Guillaume Cottenceau (gc) * * Copyright 2000 Mandriva * @@ -148,65 +148,6 @@ enum return_type copy_file(char * from, char * to, void (*callback_func)(int ove } } -enum return_type recursiveRemove(char *file) -{ - struct stat sb; - - if (lstat(file, &sb) != 0) { - log_message("failed to stat %s: %d", file, errno); - return RETURN_ERROR; - } - - /* only descend into subdirectories if device is same as dir */ - if (S_ISDIR(sb.st_mode)) { - char * strBuf = alloca(strlen(file) + 1024); - DIR * dir; - struct dirent * d; - - if (!(dir = opendir(file))) { - log_message("error opening %s: %d", file, errno); - return RETURN_ERROR; - } - while ((d = readdir(dir))) { - if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) - continue; - - strcpy(strBuf, file); - strcat(strBuf, "/"); - strcat(strBuf, d->d_name); - - if (recursiveRemove(strBuf) != 0) { - closedir(dir); - return RETURN_ERROR; - } - } - closedir(dir); - - if (rmdir(file)) { - log_message("failed to rmdir %s: %d", file, errno); - return RETURN_ERROR; - } - } else { - if (unlink(file) != 0) { - log_message("failed to remove %s: %d", file, errno); - return RETURN_ERROR; - } - } - return RETURN_OK; -} - -enum return_type recursiveRemove_if_it_exists(char *file) -{ - struct stat sb; - - if (lstat(file, &sb) != 0) { - /* if file doesn't exist, simply return OK */ - return RETURN_OK; - } - - return recursiveRemove(file); -} - enum return_type mount_compressed_image(char *compressed_image, char *location_mount) { if (lomount(compressed_image, location_mount, NULL, 1)) { @@ -272,14 +213,7 @@ int try_mount(char * dev, char * location) char device_fullname[50]; snprintf(device_fullname, sizeof(device_fullname), "/dev/%s", dev); - if (my_mount(device_fullname, location, "ext4", 0) == -1 && - my_mount(device_fullname, location, "vfat", 0) == -1 && - my_mount(device_fullname, location, "ntfs", 0) == -1 && - my_mount(device_fullname, location, "reiserfs", 0) == -1 && - my_mount(device_fullname, location, "reiser4", 0) == -1 && - my_mount(device_fullname, location, "jfs", 0) == -1 && - my_mount(device_fullname, location, "xfs", 0) == -1 && - my_mount(device_fullname, location, "iso9660", 0) == -1) { + if (my_mount(device_fullname, location, "auto", 0) == -1) { return 1; } @@ -292,8 +226,8 @@ int get_disks(char *** names, char *** models) char ** ptr; int count = 0; - my_insmod("ide_disk", ANY_DRIVER_TYPE, NULL, 0); - my_insmod("sd_mod", ANY_DRIVER_TYPE, NULL, 0); + my_modprobe("ide_disk", ANY_DRIVER_TYPE, NULL); + my_modprobe("sd_mod", ANY_DRIVER_TYPE, NULL); get_medias(DISK, names, models, BUS_ANY); @@ -313,8 +247,8 @@ int get_cdroms(char *** names, char *** models) char ** ptr; int count = 0; - my_insmod("ide_cd_mod", ANY_DRIVER_TYPE, NULL, 0); - my_insmod("sr_mod", ANY_DRIVER_TYPE, NULL, 0); + my_modprobe("ide_cd_mod", ANY_DRIVER_TYPE, NULL); + my_modprobe("sr_mod", ANY_DRIVER_TYPE, NULL); get_medias(CDROM, names, models, BUS_ANY); @@ -332,7 +266,7 @@ char * floppy_device(void) { char ** names, ** models; int fd; - my_insmod("floppy", ANY_DRIVER_TYPE, NULL, 0); + my_modprobe("floppy", ANY_DRIVER_TYPE, NULL); fd = open("/dev/fd0", O_RDONLY|O_NONBLOCK); if (fd != -1) { char drivtyp[17]; @@ -352,10 +286,10 @@ char * floppy_device(void) close(fd); } log_message("seems that you don't have a regular floppy drive"); - my_insmod("sd_mod", ANY_DRIVER_TYPE, NULL, 0); + my_modprobe("sd_mod", ANY_DRIVER_TYPE, NULL); get_medias(FLOPPY, &names, &models, BUS_ANY); if (names && *names) return asprintf_("/dev/%s", *names); else - return "/dev/fd0"; + return NULL; } |