From da2111e23971a7dbe6356cb7f82cd9751047b1f6 Mon Sep 17 00:00:00 2001 From: Leonid Krivoshein Date: Sun, 22 Apr 2018 16:12:26 +0300 Subject: [PATCH] init.c, disk.c, cdrom.c, network.c: whitespace cleanup. --- cdrom.c | 6 ++--- disk.c | 3 ++- init.c | 77 +++++++++++++++++++++++++++---------------------------- network.c | 23 ++++++++--------- 4 files changed, 53 insertions(+), 56 deletions(-) diff --git a/cdrom.c b/cdrom.c index a85e2b0..22c6d5e 100644 --- a/cdrom.c +++ b/cdrom.c @@ -15,7 +15,7 @@ /* * Portions from Erik Troan (ewt@redhat.com) * - * Copyright 1996 Red Hat Software + * Copyright 1996 Red Hat Software * */ @@ -134,7 +134,7 @@ static enum return_type do_with_device(char * dev_name, char * dev_model) add_to_env("PREFIX", "/"); return RETURN_OK; -} +} static enum return_type try_with_device(char * dev_name, char * dev_model) { @@ -213,7 +213,6 @@ enum return_type cdrom_prepare(void) int period=5; update_splash("prepare"); - fprintf(stderr,"%c[1A",27); for(i=0; i 0) + if ((i = read(in, buf, sizeof(buf))) > 0) ii = write(out, buf, i); } @@ -157,8 +157,8 @@ static void spawn_hook(char *av[]) struct stat st; int status; - if (stat(av[0], &st) || !S_ISREG(st.st_mode) || !(st.st_mode & S_IXUSR)) return; - if (waitpid(spawn(av), &status, 0) < 0 || !(WIFEXITED(status))) fatal(av[0]); + if (stat(av[0], &st) || !S_ISREG(st.st_mode) || !(st.st_mode & S_IXUSR)) return; + if (waitpid(spawn(av), &status, 0) < 0 || !(WIFEXITED(status))) fatal(av[0]); } static void take_env(int fd) @@ -201,16 +201,16 @@ static int nuke_dirent(int len, const char *dir, const char *name, dev_t me) char path[bytes]; int xlen; struct stat st; - + xlen = snprintf(path, bytes, "%s/%s", dir, name); /* assert(xlen < bytes); */ - + if ( lstat(path, &st) ) return ENOENT; /* Return 0 since already gone? */ - + if ( st.st_dev != me ) - return 0; /* DO NOT recurse down mount points!!!!! */ - + return 0; /* DO NOT recurse down mount points!!!!! */ + return nuke(path); } @@ -222,19 +222,19 @@ static int nuke_dir(const char *what) struct dirent *d; int err = 0; struct stat st; - + if ( lstat(what, &st) ) return errno; - + if ( !S_ISDIR(st.st_mode) ) return ENOTDIR; - + if ( !(dir = opendir(what)) ) { /* EACCES means we can't read it. Might be empty and removable; if not, the rmdir() in nuke() will trigger an error. */ return (errno == EACCES) ? 0 : errno; } - + while ( (d = readdir(dir)) ) { /* Skip . and .. */ if ( d->d_name[0] == '.' && @@ -248,9 +248,9 @@ static int nuke_dir(const char *what) return err; } } - + closedir(dir); - + return 0; } @@ -258,7 +258,7 @@ static int nuke(const char *what) { int rv; int err = 0; - + rv = unlink(what); if ( rv < 0 ) { if ( errno == EISDIR ) { @@ -269,7 +269,7 @@ static int nuke(const char *what) err = errno; } } - + if ( err ) { errno = err; fatal(what); @@ -289,14 +289,14 @@ struct filesystem static void unmount_filesystems(void) { int fd, size; - char buf[65535]; /* this should be big enough */ + char buf[65535]; /* this should be big enough */ char *p; struct filesystem fs[500]; int numfs = 0; int i, nb; - - printf("unmounting filesystems...\n"); - + + printf("unmounting filesystems...\n"); + fd = open("/proc/mounts", O_RDONLY, 0); if (fd < 1) { warn("failed to open /proc/mounts"); @@ -344,13 +344,13 @@ static void unmount_filesystems(void) } } } while (nb); - + for (i = nb = 0; i < numfs; i++) if (fs[i].mounted) { printf("\t%s umount failed\n", fs[i].name); if (strcmp(fs[i].fs, "ext2") == 0) nb++; /* don't count not-ext2 umount failed */ } - + if (nb) { fatal("failed to umount some filesystems\n"); } @@ -414,16 +414,15 @@ int main(int argc, char **argv) if (sethostname("localhost.localdomain", sizeof("localhost.localdomain")) < 0) warn("could not set hostname"); - + /* the default domainname (as of 2.0.35) is "(none)", which confuses glibc */ if (setdomainname("", 0) < 0) warn("could not set domainname"); - + if (mkdirs_dev(".initramfs", "pts", "shm", NULL) < 0) fatal("mkdir\n"); klogpid = doklog(); - spawn_hook(init_top); if (mkdirs_dev(".udev", ".udev/db", NULL) < 0) @@ -441,7 +440,7 @@ int main(int argc, char **argv) if (waitpid(spawn(udevtrigger), &wait_status, 0) < 0 || !(WIFEXITED(wait_status))) warn("udevtrigger"); - + if (waitpid(spawn(udevsettle), &wait_status, 0) < 0 || !(WIFEXITED(wait_status))) warn("udevsettle"); @@ -452,12 +451,12 @@ int main(int argc, char **argv) /* Go into normal init mode - keep going, and then do a orderly shutdown when: - + 1) install exits - 2) we receive a SIGHUP + 2) we receive a SIGHUP */ - printf("Running stage1...\n"); + printf("Running stage1...\n"); /* create a pipe for env passing */ if (pipe(fds) < 0) @@ -476,26 +475,26 @@ int main(int argc, char **argv) if (!(WIFEXITED(wait_status))) { /* something went wrong */ - + printf("wait_status: %i, install exited abnormally ", wait_status); if (WIFSIGNALED(wait_status)) printf("-- received signal %d", WTERMSIG(wait_status)); printf("\n"); - + sync(); sync(); - + printf("sending termination signals..."); kill(-1, 15); sleep(2); printf("done\n"); - + printf("sending kill signals..."); kill(-1, 9); sleep(2); printf("done\n"); - + unmount_filesystems(); - + printf("you may safely reboot your system\n"); while (1); } diff --git a/network.c b/network.c index d3af53a..006e53b 100644 --- a/network.c +++ b/network.c @@ -15,7 +15,7 @@ /* * Portions from Erik Troan (ewt@redhat.com) * - * Copyright 1996 Red Hat Software + * Copyright 1996 Red Hat Software * */ #include @@ -555,7 +555,6 @@ static char * interface_select(void) static int current_iface_auto=0; interfaces = get_net_devices(); - ptr = interfaces; while (ptr && *ptr) { count++; @@ -580,19 +579,19 @@ static char * interface_select(void) } if (IS_AUTOMATIC) { - if (streq(get_auto_value("interface"), "")) { - if (interfaces[current_iface_auto]!=NULL) + if (streq(get_auto_value("interface"), "")) { + if (interfaces[current_iface_auto] != NULL) return interfaces[current_iface_auto++]; else unset_param(MODE_AUTOMATIC); /* we are in a fallback mode */ - } else { + } else { if (current_iface_auto++ > 1) unset_param(MODE_AUTOMATIC); /* if interface was defined make only one try */ - } + } } results = ask_from_list_comments_auto("Please choose the network device to boot from.", - interfaces, descriptions, &choice, "interface", interfaces); + interfaces, descriptions, &choice, "interface", interfaces); if (results != RETURN_OK) return NULL; @@ -615,16 +614,16 @@ static enum return_type intf_select_and_up(void) enum return_type results; char * iface = NULL; - - if (already_done) return RETURN_OK; + if (already_done) + return RETURN_OK; if ((iface = interface_select()) == NULL) return RETURN_BACK; - - for (i = 0; i < num_interfaces ; i++) + + for (i = 0; i < num_interfaces; i++) if (!strcmp(intf[i].device, iface)) sel_intf = &(intf[i]); - + if (sel_intf == NULL) { sel_intf = &(intf[num_interfaces]); strcpy(sel_intf->device, iface);