ftp method fixed

This commit is contained in:
Sergey Bolshakov 2005-01-24 18:12:06 +00:00
parent a4108d4897
commit 67363c8441
3 changed files with 22 additions and 21 deletions

32
init.c
View File

@ -499,58 +499,62 @@ int main(int argc, char **argv)
as the root directory */
if ( stat("/", &rst) || stat(".", &cst) )
fatal_error("stat");
if ( rst.st_dev == cst.st_dev )
fatal_error("current directory on the same filesystem as the root");
/* The initramfs should have /init */
if ( stat("/init", &ist) || !S_ISREG(ist.st_mode) )
fatal_error("can't find /init on initramfs");
/* Make sure we're on a ramfs */
if ( statfs("/", &sfs) )
fatal_error("statfs /");
if ( sfs.f_type != RAMFS_MAGIC && sfs.f_type != TMPFS_MAGIC )
fatal_error("rootfs not a ramfs or tmpfs");
/* Okay, I think we should be safe... */
/* overmount image under pwd */
if ( mount(IMAGE_LOCATION, "." IMAGE_LOCATION, NULL, MS_MOVE, NULL) )
fatal_error("overmounting image location");
/* overmount image under new root if needed */
if ( statfs(IMAGE_LOCATION, &sfs) )
fatal_error("statfs "IMAGE_LOCATION);
/* if something is mounted under IMAGE_LOCATION ? */
if ( sfs.f_type != RAMFS_MAGIC && sfs.f_type != TMPFS_MAGIC )
if ( mount(IMAGE_LOCATION, "." IMAGE_LOCATION, NULL, MS_MOVE, NULL) )
fatal_error("overmounting image location");
umount("/sys");
umount("/proc/bus/usb");
umount("/proc");
/* Delete rootfs contents */
if ( nuke_dir("/") )
fatal_error("nuking initramfs contents");
/* Overmount the root */
if ( mount(".", "/", NULL, MS_MOVE, NULL) )
fatal_error("overmounting root");
/* chroot, chdir */
if ( chroot(".") || chdir("/") )
fatal_error("chroot");
/* Open /dev/console */
if ( (fd = open("/dev/console", O_RDWR)) < 0 )
fatal_error("opening console");
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
close(fd);
/* Spawn init */
printf(" done.\n");
/* Check for given init */
if (stat(stage2_argv[0], &ist) || !S_ISREG(ist.st_mode))
fatal_error("can't find init on root fs");
execve(stage2_argv[0], stage2_argv, myenv);
fatal_error("stage2"); /* Failed to spawn init */
return 0;

View File

@ -249,13 +249,11 @@ static void save_stuff_for_rescue(void)
}
enum return_type load_ramdisk_fd(int ramdisk_fd, int size)
enum return_type load_ramdisk_fd(int source_fd, int size)
{
BZFILE * st2;
char * ramdisk = "/dev/ram3"; /* warning, verify that this file exists in the initrd, and that root=/dev/ram3 is actually passed to the kernel at boot time */
int ram_fd;
char buffer[32768];
int z_errnum;
char * wait_msg = "Loading program into memory...";
int bytes_read = 0;
int actually;
@ -270,7 +268,7 @@ enum return_type load_ramdisk_fd(int ramdisk_fd, int size)
init_progression(wait_msg, size);
while ((actually = read(st2, buffer, sizeof(buffer))) > 0) {
while ((actually = read(source_fd, buffer, sizeof(buffer))) > 0) {
seems_ok = 1;
if (write(ram_fd, buffer, actually) != actually) {
log_perror("writing ramdisk");
@ -299,7 +297,7 @@ enum return_type load_ramdisk_fd(int ramdisk_fd, int size)
if (do_losetup(LIVE_DEVICE, ramdisk) == -1)
fatal_error("could not setup loopback for loaded second stage");
if (my_mount(ramdisk, LIVE_DEVICE, STAGE2FS, 1))
if (my_mount(LIVE_DEVICE, STAGE2_LOCATION, STAGE2FS, 0))
return RETURN_ERROR;
set_param(MODE_RAMDISK);
@ -316,7 +314,6 @@ enum return_type load_ramdisk_fd(int ramdisk_fd, int size)
return RETURN_OK;
}
char * get_ramdisk_realname(void)
{
char img_name[500];

2
url.c
View File

@ -177,7 +177,7 @@ int ftp_open_connection(char * host, char * name, char * password, char * proxy)
if (!strcmp(name, "")) {
name = "anonymous";
password = "-drakx@";
password = "altinst@";
}
if (strcmp(proxy, "")) {