diff options
author | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 12:13:01 +0300 |
---|---|---|
committer | Manuel Novoa III <mjn3@codepoet.org> | 2003-03-19 12:13:01 +0300 |
commit | cad5364599eb5062d59e0c397ed638ddd61a8d5d (patch) | |
tree | a318d0f03aa076c74b576ea45dc543a5669e8e91 /util-linux | |
parent | e01f9662a5bd5d91be4f6b3941b57fff73cd5af1 (diff) |
Major coreutils update.
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/dmesg.c | 8 | ||||
-rw-r--r-- | util-linux/fbset.c | 16 | ||||
-rw-r--r-- | util-linux/fdflush.c | 12 | ||||
-rw-r--r-- | util-linux/fdisk.c | 10 | ||||
-rw-r--r-- | util-linux/freeramdisk.c | 6 | ||||
-rw-r--r-- | util-linux/fsck_minix.c | 10 | ||||
-rw-r--r-- | util-linux/getopt.c | 22 | ||||
-rw-r--r-- | util-linux/hexdump.c | 149 | ||||
-rw-r--r-- | util-linux/hwclock.c | 18 | ||||
-rw-r--r-- | util-linux/losetup.c | 6 | ||||
-rw-r--r-- | util-linux/mkfs_minix.c | 62 | ||||
-rw-r--r-- | util-linux/mkswap.c | 46 | ||||
-rw-r--r-- | util-linux/more.c | 4 | ||||
-rw-r--r-- | util-linux/mount.c | 34 | ||||
-rw-r--r-- | util-linux/nfsmount.c | 30 | ||||
-rw-r--r-- | util-linux/pivot_root.c | 4 | ||||
-rw-r--r-- | util-linux/rdate.c | 8 | ||||
-rw-r--r-- | util-linux/swaponoff.c | 14 | ||||
-rw-r--r-- | util-linux/umount.c | 21 |
19 files changed, 226 insertions, 254 deletions
diff --git a/util-linux/dmesg.c b/util-linux/dmesg.c index aa8eb95c9..fb1639ace 100644 --- a/util-linux/dmesg.c +++ b/util-linux/dmesg.c @@ -42,7 +42,7 @@ int dmesg_main(int argc, char **argv) int lastc; int cmd = 3; - while ((i = getopt(argc, argv, "cn:s:")) != EOF) { + while ((i = getopt(argc, argv, "cn:s:")) > 0) { switch (i) { case 'c': cmd = 4; @@ -58,12 +58,12 @@ int dmesg_main(int argc, char **argv) bufsize = bb_xgetlarg(optarg, 10, 4096, 512*1024); break; default: - show_usage(); + bb_show_usage(); } } if (optind < argc) { - show_usage(); + bb_show_usage(); } if (cmd == 8) { @@ -98,5 +98,5 @@ all_done: #endif return EXIT_SUCCESS; die_the_death: - perror_msg_and_die(NULL); + bb_perror_nomsg_and_die(); } diff --git a/util-linux/fbset.c b/util-linux/fbset.c index 9423abc09..afd9e64be 100644 --- a/util-linux/fbset.c +++ b/util-linux/fbset.c @@ -194,7 +194,7 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn, char buf[256]; char *p = buf; - f = xfopen(fn, "r"); + f = bb_xfopen(fn, "r"); while (!feof(f)) { fgets(buf, sizeof(buf), f); if ((p = strstr(buf, "mode ")) || (p = strstr(buf, "mode\t"))) { @@ -279,7 +279,7 @@ static int readmode(struct fb_var_screeninfo *base, const char *fn, } } #else - error_msg( "mode reading not compiled in"); + bb_error_msg( "mode reading not compiled in"); #endif return 0; } @@ -350,7 +350,7 @@ extern int fbset_main(int argc, char **argv) for (i = 0; g_cmdoptions[i].name; i++) { if (!strcmp(thisarg, g_cmdoptions[i].name)) { if (argc - 1 < g_cmdoptions[i].param_count) - show_usage(); + bb_show_usage(); switch (g_cmdoptions[i].code) { case CMD_FB: fbdev = argv[1]; @@ -399,18 +399,18 @@ extern int fbset_main(int argc, char **argv) mode = *argv; g_options |= OPT_READMODE; } else { - show_usage(); + bb_show_usage(); } } } if ((fh = open(fbdev, O_RDONLY)) < 0) - perror_msg_and_die("fbset(open)"); + bb_perror_msg_and_die("fbset(open)"); if (ioctl(fh, FBIOGET_VSCREENINFO, &var)) - perror_msg_and_die("fbset(ioctl)"); + bb_perror_msg_and_die("fbset(ioctl)"); if (g_options & OPT_READMODE) { if (!readmode(&var, modefile, mode)) { - error_msg("Unknown video mode `%s'", mode); + bb_error_msg("Unknown video mode `%s'", mode); return EXIT_FAILURE; } } @@ -418,7 +418,7 @@ extern int fbset_main(int argc, char **argv) setmode(&var, &varset); if (g_options & OPT_CHANGE) if (ioctl(fh, FBIOPUT_VSCREENINFO, &var)) - perror_msg_and_die("fbset(ioctl)"); + bb_perror_msg_and_die("fbset(ioctl)"); showmode(&var); /* Don't close the file, as exiting will take care of that */ /* close(fh); */ diff --git a/util-linux/fdflush.c b/util-linux/fdflush.c index 0756ddfbf..c3fcf3325 100644 --- a/util-linux/fdflush.c +++ b/util-linux/fdflush.c @@ -25,6 +25,7 @@ #include <sys/ioctl.h> #include <fcntl.h> #include <stdlib.h> +#include <unistd.h> #include "busybox.h" /* From <linux/fd.h> */ @@ -35,22 +36,19 @@ extern int fdflush_main(int argc, char **argv) int fd, result; if (argc <= 1) - show_usage(); - if ((fd = open(*(++argv), 0)) < 0) - goto die_the_death; + bb_show_usage(); + + fd = bb_xopen(argv[1], 0); result = ioctl(fd, FDFLUSH, 0); #ifdef CONFIG_FEATURE_CLEAN_UP close(fd); #endif if (result) { - goto die_the_death; + bb_perror_nomsg_and_die(); } /* Don't bother closing. Exit does * that, so we can save a few bytes */ return EXIT_SUCCESS; - -die_the_death: - perror_msg_and_die(NULL); } diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 696e64c7d..71fbe074e 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c @@ -5655,7 +5655,7 @@ tryprocpt(void) { char line[100], ptname[100], devname[120], *s; int ma, mi, sz; - procpt = wfopen(PROC_PARTITIONS, "r"); + procpt = bb_wfopen(PROC_PARTITIONS, "r"); while (fgets(line, sizeof(line), procpt)) { if (sscanf (line, " %d %d %d %[^\n ]", @@ -5711,7 +5711,7 @@ int fdisk_main(int argc, char **argv) { sector_size = atoi(optarg); if (sector_size != 512 && sector_size != 1024 && sector_size != 2048) - show_usage(); + bb_show_usage(); sector_offset = 2; user_set_sector_size = 1; break; @@ -5746,7 +5746,7 @@ int fdisk_main(int argc, char **argv) { printf("fdisk v" UTIL_LINUX_VERSION "\n"); return 0; default: - show_usage(); + bb_show_usage(); } } @@ -5794,7 +5794,7 @@ int fdisk_main(int argc, char **argv) { opts = argc - optind; if (opts <= 0) - show_usage(); + bb_show_usage(); for (j = optind; j < argc; j++) { disk_device = argv[j]; @@ -5816,7 +5816,7 @@ int fdisk_main(int argc, char **argv) { if (argc-optind == 1) disk_device = argv[optind]; else - show_usage(); + bb_show_usage(); get_boot(fdisk); diff --git a/util-linux/freeramdisk.c b/util-linux/freeramdisk.c index dd7700c06..9276a6c40 100644 --- a/util-linux/freeramdisk.c +++ b/util-linux/freeramdisk.c @@ -41,17 +41,17 @@ freeramdisk_main(int argc, char **argv) FILE *f; if (argc != 2) { - show_usage(); + bb_show_usage(); } - f = xfopen(argv[1], "r+"); + f = bb_xfopen(argv[1], "r+"); result = ioctl(fileno(f), BLKFLSBUF); #ifdef CONFIG_FEATURE_CLEAN_UP fclose(f); #endif if (result < 0) { - perror_msg_and_die("failed ioctl on %s", argv[1]); + bb_perror_msg_and_die("failed ioctl on %s", argv[1]); } /* Don't bother closing. Exit does diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c index d332b6b0a..3a691476e 100644 --- a/util-linux/fsck_minix.c +++ b/util-linux/fsck_minix.c @@ -279,7 +279,7 @@ static void leave(int status) static void die(const char *str) { - error_msg("%s", str); + bb_error_msg("%s", str); leave(8); } @@ -1344,7 +1344,7 @@ extern int fsck_minix_main(int argc, char **argv) argv++; if (argv[0][0] != '-') { if (device_name) - show_usage(); + bb_show_usage(); else device_name = argv[0]; } else @@ -1374,11 +1374,11 @@ extern int fsck_minix_main(int argc, char **argv) force = 1; break; default: - show_usage(); + bb_show_usage(); } } if (!device_name) - show_usage(); + bb_show_usage(); check_mount(); /* trying to check a mounted filesystem? */ if (repair && !automatic) { if (!isatty(0) || !isatty(1)) @@ -1399,7 +1399,7 @@ extern int fsck_minix_main(int argc, char **argv) * flags and whether or not the -f switch was specified on the * command line. */ - printf("%s, %s\n", applet_name, program_version); + printf("%s, %s\n", bb_applet_name, program_version); if (!(Super.s_state & MINIX_ERROR_FS) && (Super.s_state & MINIX_VALID_FS) && !force) { if (repair) diff --git a/util-linux/getopt.c b/util-linux/getopt.c index e126d7b6e..25eeab69b 100644 --- a/util-linux/getopt.c +++ b/util-linux/getopt.c @@ -37,7 +37,7 @@ * <misiek@misiek.eu.org>) * Ported to Busybox - Alfred M. Szmidt <ams@trillian.itslinux.org> * Removed --version/-V and --help/-h in - * Removed prase_error(), using error_msg() from Busybox instead + * Removed prase_error(), using bb_error_msg() from Busybox instead * Replaced our_malloc with xmalloc and our_realloc with xrealloc * */ @@ -95,7 +95,7 @@ const char *normalize(const char *arg) free(BUFFER); if (!quote) { /* Just copy arg */ - BUFFER=xstrdup(arg); + BUFFER=bb_xstrdup(arg); return BUFFER; } @@ -224,7 +224,7 @@ void add_longopt(const char *name,int has_arg) long_options[long_options_nr-1].has_arg=has_arg; long_options[long_options_nr-1].flag=NULL; long_options[long_options_nr-1].val=LONG_OPT; - long_options[long_options_nr-1].name=xstrdup(name); + long_options[long_options_nr-1].name=bb_xstrdup(name); } long_options_nr++; } @@ -254,7 +254,7 @@ void add_long_options(char *options) arg_opt=required_argument; } if (tlen == 0) - error_msg("empty long option after -l or --long argument"); + bb_error_msg("empty long option after -l or --long argument"); } add_longopt(tokptr,arg_opt); } @@ -273,7 +273,7 @@ void set_shell(const char *new_shell) else if (!strcmp(new_shell,"csh")) shell=TCSH; else - error_msg("unknown shell after -s or --shell argument"); + bb_error_msg("unknown shell after -s or --shell argument"); } @@ -322,7 +322,7 @@ int getopt_main(int argc, char *argv[]) printf(" --\n"); return 0; } else - error_msg_and_die("missing optstring argument"); + bb_error_msg_and_die("missing optstring argument"); } if (argv[1][0] != '-' || compatible) { @@ -340,14 +340,14 @@ int getopt_main(int argc, char *argv[]) break; case 'o': free(optstr); - optstr=xstrdup(optarg); + optstr=bb_xstrdup(optarg); break; case 'l': add_long_options(optarg); break; case 'n': free(name); - name=xstrdup(optarg); + name=bb_xstrdup(optarg); break; case 'q': quiet_errors=1; @@ -364,14 +364,14 @@ int getopt_main(int argc, char *argv[]) quote=0; break; default: - show_usage(); + bb_show_usage(); } if (!optstr) { if (optind >= argc) - error_msg_and_die("missing optstring argument"); + bb_error_msg_and_die("missing optstring argument"); else { - optstr=xstrdup(argv[optind]); + optstr=bb_xstrdup(argv[optind]); optind++; } } diff --git a/util-linux/hexdump.c b/util-linux/hexdump.c index 33648f918..1858b08d4 100644 --- a/util-linux/hexdump.c +++ b/util-linux/hexdump.c @@ -25,115 +25,92 @@ #include <getopt.h> #include <stdlib.h> #include <string.h> -#include "dump.h" #include "busybox.h" +#include "dump.h" -extern off_t skip; /* bytes to skip */ - -extern FS *fshead; /* head of format strings */ -extern int blocksize; /* data block size */ -extern int length; /* max bytes to read */ - -void addfile(char *name) +static void bb_dump_addfile(char *name) { register char *p; FILE *fp; - int ch; - char buf[2048 + 1]; + char *buf; - if (!(fp = fopen(name, "r"))) { - error_msg_and_die("hexdump: can't read %s.\n", name); - } - while (fgets(buf, sizeof(buf), fp)) { - if (!(p = index(buf, '\n'))) { - error_msg("hexdump: line too long.\n"); - while ((ch = getchar()) != '\n' && ch != EOF); - continue; - } - *p = '\0'; - for (p = buf; *p && isspace(*p); ++p); - if (!*p || *p == '#') { - continue; + fp = bb_xfopen(name, "r"); + + while ((buf = bb_get_chomped_line_from_file(fp)) != NULL) { + p = (char *) bb_skip_whitespace(buf); + + if (*p && (*p != '#')) { + bb_dump_add(p); } - add(p); + free(buf); } - (void)fclose(fp); + fclose(fp); } +static const char * const add_strings[] = { + "\"%07.7_ax \" 16/1 \"%03o \" \"\\n\"", /* b */ + "\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\"", /* c */ + "\"%07.7_ax \" 8/2 \" %05u \" \"\\n\"", /* d */ + "\"%07.7_ax \" 8/2 \" %06o \" \"\\n\"", /* o */ + "\"%07.7_ax \" 8/2 \" %04x \" \"\\n\"", /* x */ +}; + +static const char add_first[] = "\"%07.7_Ax\n\""; + +static const char hexdump_opts[] = "bcdoxe:f:n:s:v"; + +static const struct suffix_mult suffixes[] = { + {"b", 512 }, + {"k", 1024 }, + {"m", 1024*1024 }, + {NULL, 0 } +}; + int hexdump_main(int argc, char **argv) { // register FS *tfs; - char *p; + const char *p; int ch; - extern enum _vflag vflag; - vflag = FIRST; - length = -1; - while ((ch = getopt(argc, argv, "bcde:f:n:os:vx")) != EOF) { - switch (ch) { - case 'b': - add("\"%07.7_Ax\n\""); - add("\"%07.7_ax \" 16/1 \"%03o \" \"\\n\""); - break; - case 'c': - add("\"%07.7_Ax\n\""); - add("\"%07.7_ax \" 16/1 \"%3_c \" \"\\n\""); - break; - case 'd': - add("\"%07.7_Ax\n\""); - add("\"%07.7_ax \" 8/2 \" %05u \" \"\\n\""); - break; - case 'e': - add(optarg); - break; - case 'f': - addfile(optarg); - break; - case 'n': - if ((length = atoi(optarg)) < 0) { - error_msg_and_die("hexdump: bad length value.\n"); - } - break; - case 'o': - add("\"%07.7_Ax\n\""); - add("\"%07.7_ax \" 8/2 \" %06o \" \"\\n\""); - break; - case 's': - if ((skip = strtol(optarg, &p, 0)) < 0) { - error_msg_and_die("hexdump: bad skip value.\n"); - } - switch(*p) { - case 'b': - skip *= 512; - break; - case 'k': - skip *= 1024; - break; - case 'm': - skip *= 1048576; - break; + bb_dump_vflag = FIRST; + bb_dump_length = -1; + + while ((ch = getopt(argc, argv, hexdump_opts)) > 0) { + if ((p = strchr(hexdump_opts, ch)) != NULL) { + if ((p - hexdump_opts) < 5) { + bb_dump_add(add_first); + bb_dump_add(add_strings[(int)(p - hexdump_opts)]); + } else { + /* Sae a little bit of space below by omitting the 'else's. */ + if (ch == 'e') { + bb_dump_add(optarg); + } /* else */ + if (ch == 'f') { + bb_dump_addfile(optarg); + } /* else */ + if (ch == 'n') { + bb_dump_length = bb_xgetularg10_bnd(optarg, 0, INT_MAX); + } /* else */ + if (ch == 's') { + bb_dump_skip = bb_xgetularg_bnd_sfx(optarg, 10, 0, LONG_MAX, suffixes); + } /* else */ + if (ch == 'v') { + bb_dump_vflag = ALL; + } } - break; - case 'v': - vflag = ALL; - break; - case 'x': - add("\"%07.7_Ax\n\""); - add("\"%07.7_ax \" 8/2 \" %04x \" \"\\n\""); - break; - case '?': - show_usage(); + } else { + bb_show_usage(); } } - if (!fshead) { - add("\"%07.7_Ax\n\""); - add("\"%07.7_ax \" 8/2 \"%04x \" \"\\n\""); + if (!bb_dump_fshead) { + bb_dump_add(add_first); + bb_dump_add("\"%07.7_ax \" 8/2 \"%04x \" \"\\n\""); } argv += optind; - return(dump(argv)); + return(bb_dump_dump(argv)); } /* * Copyright (c) 1989 The Regents of the University of California. diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c index 815b60b21..2eee3cfdb 100644 --- a/util-linux/hwclock.c +++ b/util-linux/hwclock.c @@ -77,11 +77,11 @@ time_t read_rtc ( int utc ) if (( rtc = open ( "/dev/rtc", O_RDONLY )) < 0 ) { if (( rtc = open ( "/dev/misc/rtc", O_RDONLY )) < 0 ) - perror_msg_and_die ( "Could not access RTC" ); + bb_perror_msg_and_die ( "Could not access RTC" ); } memset ( &tm, 0, sizeof( struct tm )); if ( ioctl ( rtc, RTC_RD_TIME, &tm ) < 0 ) - perror_msg_and_die ( "Could not read time from RTC" ); + bb_perror_msg_and_die ( "Could not read time from RTC" ); tm. tm_isdst = -1; // not known close ( rtc ); @@ -111,7 +111,7 @@ void write_rtc ( time_t t, int utc ) if (( rtc = open ( "/dev/rtc", O_WRONLY )) < 0 ) { if (( rtc = open ( "/dev/misc/rtc", O_WRONLY )) < 0 ) - perror_msg_and_die ( "Could not access RTC" ); + bb_perror_msg_and_die ( "Could not access RTC" ); } printf ( "1\n" ); @@ -122,7 +122,7 @@ void write_rtc ( time_t t, int utc ) printf ( "2\n") ; if ( ioctl ( rtc, RTC_SET_TIME, &tm ) < 0 ) - perror_msg_and_die ( "Could not set the RTC time" ); + bb_perror_msg_and_die ( "Could not set the RTC time" ); close ( rtc ); } @@ -138,7 +138,7 @@ int show_clock ( int utc ) safe_strncpy ( buffer, ctime ( &t ), sizeof( buffer )); if ( buffer [0] ) - buffer [xstrlen ( buffer ) - 1] = 0; + buffer [bb_strlen ( buffer ) - 1] = 0; //printf ( "%s %.6f seconds %s\n", buffer, 0.0, utc ? "" : ( ptm-> tm_isdst ? tzname [1] : tzname [0] )); printf ( "%s %.6f seconds\n", buffer, 0.0 ); @@ -154,7 +154,7 @@ int to_sys_clock ( int utc ) tv. tv_sec = read_rtc ( utc ); if ( settimeofday ( &tv, &tz )) - perror_msg_and_die ( "settimeofday() failed" ); + bb_perror_msg_and_die ( "settimeofday() failed" ); return 0; } @@ -165,7 +165,7 @@ int from_sys_clock ( int utc ) struct timezone tz = { 0, 0 }; if ( gettimeofday ( &tv, &tz )) - perror_msg_and_die ( "gettimeofday() failed" ); + bb_perror_msg_and_die ( "gettimeofday() failed" ); write_rtc ( tv. tv_sec, utc ); return 0; @@ -181,7 +181,7 @@ int check_utc ( void ) char buffer [128]; while ( fgets ( buffer, sizeof( buffer ), f )) { - int len = xstrlen ( buffer ); + int len = bb_strlen ( buffer ); while ( len && isspace ( buffer [len - 1] )) len--; @@ -238,7 +238,7 @@ extern int hwclock_main ( int argc, char **argv ) utc_arg = 1; break; default: - show_usage(); + bb_show_usage(); break; } } diff --git a/util-linux/losetup.c b/util-linux/losetup.c index bfeb6b274..e2ea538d5 100644 --- a/util-linux/losetup.c +++ b/util-linux/losetup.c @@ -39,16 +39,16 @@ losetup_main (int argc, char **argv) break; case 'o': - offset = parse_number (optarg, NULL); + offset = bb_xparse_number (optarg, NULL); break; default: - show_usage (); + bb_show_usage(); } if ((delete && (offset || optind + 1 != argc)) || (!delete && optind + 2 != argc)) - show_usage (); + bb_show_usage(); if (delete) return del_loop (argv[optind]) ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c index 94f29e55d..75a909e6b 100644 --- a/util-linux/mkfs_minix.c +++ b/util-linux/mkfs_minix.c @@ -268,7 +268,7 @@ extern inline void check_mount(void) if (!mnt) return; - error_msg_and_die("%s is mounted; will not make a filesystem here!", device_name); + bb_error_msg_and_die("%s is mounted; will not make a filesystem here!", device_name); } static long valid_offset(int fd, int offset) @@ -307,7 +307,7 @@ extern inline int get_size(const char *file) long size; if ((fd = open(file, O_RDWR)) < 0) - perror_msg_and_die("%s", file); + bb_perror_msg_and_die("%s", file); if (ioctl(fd, BLKGETSIZE, &size) >= 0) { close(fd); return (size * 512); @@ -325,28 +325,28 @@ extern inline void write_tables(void) Super.s_state &= ~MINIX_ERROR_FS; if (lseek(DEV, 0, SEEK_SET)) - error_msg_and_die("seek to boot block failed in write_tables"); + bb_error_msg_and_die("seek to boot block failed in write_tables"); if (512 != write(DEV, boot_block_buffer, 512)) - error_msg_and_die("unable to clear boot sector"); + bb_error_msg_and_die("unable to clear boot sector"); if (BLOCK_SIZE != lseek(DEV, BLOCK_SIZE, SEEK_SET)) - error_msg_and_die("seek failed in write_tables"); + bb_error_msg_and_die("seek failed in write_tables"); if (BLOCK_SIZE != write(DEV, super_block_buffer, BLOCK_SIZE)) - error_msg_and_die("unable to write super-block"); + bb_error_msg_and_die("unable to write super-block"); if (IMAPS * BLOCK_SIZE != write(DEV, inode_map, IMAPS * BLOCK_SIZE)) - error_msg_and_die("unable to write inode map"); + bb_error_msg_and_die("unable to write inode map"); if (ZMAPS * BLOCK_SIZE != write(DEV, zone_map, ZMAPS * BLOCK_SIZE)) - error_msg_and_die("unable to write zone map"); + bb_error_msg_and_die("unable to write zone map"); if (INODE_BUFFER_SIZE != write(DEV, inode_buffer, INODE_BUFFER_SIZE)) - error_msg_and_die("unable to write inodes"); + bb_error_msg_and_die("unable to write inodes"); } static void write_block(int blk, char *buffer) { if (blk * BLOCK_SIZE != lseek(DEV, blk * BLOCK_SIZE, SEEK_SET)) - error_msg_and_die("seek failed in write_block"); + bb_error_msg_and_die("seek failed in write_block"); if (BLOCK_SIZE != write(DEV, buffer, BLOCK_SIZE)) - error_msg_and_die("write failed in write_block"); + bb_error_msg_and_die("write failed in write_block"); } static int get_free_block(void) @@ -354,7 +354,7 @@ static int get_free_block(void) int blk; if (used_good_blocks + 1 >= MAX_GOOD_BLOCKS) - error_msg_and_die("too many bad blocks"); + bb_error_msg_and_die("too many bad blocks"); if (used_good_blocks) blk = good_blocks_table[used_good_blocks - 1] + 1; else @@ -362,7 +362,7 @@ static int get_free_block(void) while (blk < ZONES && zone_in_use(blk)) blk++; if (blk >= ZONES) - error_msg_and_die("not enough good blocks"); + bb_error_msg_and_die("not enough good blocks"); good_blocks_table[used_good_blocks] = blk; used_good_blocks++; return blk; @@ -428,7 +428,7 @@ extern inline void make_bad_inode(void) goto end_bad; } } - error_msg_and_die("too many bad blocks"); + bb_error_msg_and_die("too many bad blocks"); end_bad: if (ind) write_block(ind, (char *) ind_block); @@ -478,7 +478,7 @@ extern inline void make_bad_inode2(void) } } /* Could make triple indirect block here */ - error_msg_and_die("too many bad blocks"); + bb_error_msg_and_die("too many bad blocks"); end_bad: if (ind) write_block(ind, (char *) ind_block); @@ -579,7 +579,7 @@ extern inline void setup_tables(void) * /sbin/mkfs.minix -i 200 test.fs * */ if (i >= 999) { - error_msg_and_die("unable to allocate buffers for maps"); + bb_error_msg_and_die("unable to allocate buffers for maps"); } FIRSTZONE = NORM_FIRSTZONE; inode_map = xmalloc(IMAPS * BLOCK_SIZE); @@ -610,7 +610,7 @@ extern inline long do_check(char *buffer, int try, unsigned int current_block) /* Seek to the correct loc. */ if (lseek(DEV, current_block * BLOCK_SIZE, SEEK_SET) != current_block * BLOCK_SIZE) { - error_msg_and_die("seek failed during testing of blocks"); + bb_error_msg_and_die("seek failed during testing of blocks"); } @@ -650,7 +650,7 @@ static void check_blocks(void) while (currently_testing < ZONES) { if (lseek(DEV, currently_testing * BLOCK_SIZE, SEEK_SET) != currently_testing * BLOCK_SIZE) - error_msg_and_die("seek failed in check_blocks"); + bb_error_msg_and_die("seek failed in check_blocks"); try = TEST_BUFFER_BLOCKS; if (currently_testing + try > ZONES) try = ZONES - currently_testing; @@ -659,7 +659,7 @@ static void check_blocks(void) if (got == try) continue; if (currently_testing < FIRSTZONE) - error_msg_and_die("bad blocks before data-area: cannot make fs"); + bb_error_msg_and_die("bad blocks before data-area: cannot make fs"); mark_zone(currently_testing); badblocks++; currently_testing++; @@ -675,7 +675,7 @@ static void get_list_blocks(char *filename) FILE *listfile; unsigned long blockno; - listfile = xfopen(filename, "r"); + listfile = bb_xfopen(filename, "r"); while (!feof(listfile)) { fscanf(listfile, "%ld\n", &blockno); mark_zone(blockno); @@ -696,10 +696,10 @@ extern int mkfs_minix_main(int argc, char **argv) int stopIt=FALSE; if (INODE_SIZE * MINIX_INODES_PER_BLOCK != BLOCK_SIZE) - error_msg_and_die("bad inode size"); + bb_error_msg_and_die("bad inode size"); #ifdef CONFIG_FEATURE_MINIX2 if (INODE_SIZE2 * MINIX2_INODES_PER_BLOCK != BLOCK_SIZE) - error_msg_and_die("bad inode size"); + bb_error_msg_and_die("bad inode size"); #endif /* Parse options */ @@ -725,7 +725,7 @@ extern int mkfs_minix_main(int argc, char **argv) } req_nr_inodes = strtoul(cp, &tmp, 0); if (*tmp) - show_usage(); + bb_show_usage(); stopIt=TRUE; break; } @@ -749,13 +749,13 @@ extern int mkfs_minix_main(int argc, char **argv) } i = strtoul(cp, &tmp, 0); if (*tmp) - show_usage(); + bb_show_usage(); if (i == 14) magic = MINIX_SUPER_MAGIC; else if (i == 30) magic = MINIX_SUPER_MAGIC2; else - show_usage(); + bb_show_usage(); namelen = i; dirsize = i + 2; stopIt=TRUE; @@ -765,7 +765,7 @@ extern int mkfs_minix_main(int argc, char **argv) #ifdef CONFIG_FEATURE_MINIX2 version2 = 1; #else - error_msg("%s: not compiled with minix v2 support", + bb_error_msg("%s: not compiled with minix v2 support", device_name); exit(-1); #endif @@ -774,7 +774,7 @@ extern int mkfs_minix_main(int argc, char **argv) case 'h': default: goodbye: - show_usage(); + bb_show_usage(); } } } else { @@ -792,7 +792,7 @@ goodbye: if (device_name && !BLOCKS) BLOCKS = get_size(device_name) / 1024; if (!device_name || BLOCKS < 10) { - show_usage(); + bb_show_usage(); } #ifdef CONFIG_FEATURE_MINIX2 if (version2) { @@ -816,13 +816,13 @@ goodbye: strcpy(tmp + 2, ".badblocks"); DEV = open(device_name, O_RDWR); if (DEV < 0) - error_msg_and_die("unable to open %s", device_name); + bb_error_msg_and_die("unable to open %s", device_name); if (fstat(DEV, &statbuf) < 0) - error_msg_and_die("unable to stat %s", device_name); + bb_error_msg_and_die("unable to stat %s", device_name); if (!S_ISBLK(statbuf.st_mode)) check = 0; else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340) - error_msg_and_die("will not try to make filesystem on '%s'", device_name); + bb_error_msg_and_die("will not try to make filesystem on '%s'", device_name); setup_tables(); if (check) check_blocks(); diff --git a/util-linux/mkswap.c b/util-linux/mkswap.c index de10ba71f..15db392d2 100644 --- a/util-linux/mkswap.c +++ b/util-linux/mkswap.c @@ -87,7 +87,7 @@ static inline void init_signature_page(void) #ifdef PAGE_SIZE if (pagesize != PAGE_SIZE) - error_msg("Assuming pages of size %d", pagesize); + bb_error_msg("Assuming pages of size %d", pagesize); #endif signature_page = (int *) xmalloc(pagesize); memset(signature_page, 0, pagesize); @@ -185,7 +185,7 @@ static inline void page_bad(int page) bit_test_and_clear(signature_page, page); else { if (badpages == MAX_BADPAGES) - error_msg_and_die("too many bad pages"); + bb_error_msg_and_die("too many bad pages"); p->badpages[badpages] = page; } badpages++; @@ -206,7 +206,7 @@ static void check_blocks(void) } if (do_seek && lseek(DEV, current_page * pagesize, SEEK_SET) != current_page * pagesize) - error_msg_and_die("seek failed in check_blocks"); + bb_error_msg_and_die("seek failed in check_blocks"); if ((do_seek = (pagesize != read(DEV, buffer, pagesize)))) { page_bad(current_page++); continue; @@ -255,7 +255,7 @@ static long get_size(const char *file) long size; if ((fd = open(file, O_RDONLY)) < 0) - perror_msg_and_die("%s", file); + bb_perror_msg_and_die("%s", file); if (ioctl(fd, BLKGETSIZE, &size) >= 0) { int sectors_per_page = pagesize / 512; @@ -287,7 +287,7 @@ int mkswap_main(int argc, char **argv) PAGES = strtol(argv[0], &tmp, 0) / blocks_per_page; if (*tmp) - show_usage(); + bb_show_usage(); } else device_name = argv[0]; } else { @@ -302,19 +302,19 @@ int mkswap_main(int argc, char **argv) version = atoi(argv[0] + 2); break; default: - show_usage(); + bb_show_usage(); } } } if (!device_name) { - error_msg("error: Nowhere to set up swap on?"); - show_usage(); + bb_error_msg("error: Nowhere to set up swap on?"); + bb_show_usage(); } sz = get_size(device_name); if (!PAGES) { PAGES = sz; } else if (PAGES > sz && !force) { - error_msg("error: size %ld is larger than device size %d", + bb_error_msg("error: size %ld is larger than device size %d", PAGES * (pagesize / 1024), sz * (pagesize / 1024)); return EXIT_FAILURE; } @@ -330,13 +330,13 @@ int mkswap_main(int argc, char **argv) version = 1; } if (version != 0 && version != 1) { - error_msg("error: unknown version %d", version); - show_usage(); + bb_error_msg("error: unknown version %d", version); + bb_show_usage(); } if (PAGES < 10) { - error_msg("error: swap area needs to be at least %ldkB", + bb_error_msg("error: swap area needs to be at least %ldkB", (long) (10 * pagesize / 1024)); - show_usage(); + bb_show_usage(); } #if 0 maxpages = ((version == 0) ? V0_MAX_PAGES : V1_MAX_PAGES); @@ -353,17 +353,17 @@ int mkswap_main(int argc, char **argv) #endif if (PAGES > maxpages) { PAGES = maxpages; - error_msg("warning: truncating swap area to %ldkB", + bb_error_msg("warning: truncating swap area to %ldkB", PAGES * pagesize / 1024); } DEV = open(device_name, O_RDWR); if (DEV < 0 || fstat(DEV, &statbuf) < 0) - perror_msg_and_die("%s", device_name); + bb_perror_msg_and_die("%s", device_name); if (!S_ISBLK(statbuf.st_mode)) check = 0; else if (statbuf.st_rdev == 0x0300 || statbuf.st_rdev == 0x0340) - error_msg_and_die("Will not try to make swapdevice on '%s'", device_name); + bb_error_msg_and_die("Will not try to make swapdevice on '%s'", device_name); #ifdef __sparc__ if (!force && version == 0) { @@ -372,13 +372,13 @@ int mkswap_main(int argc, char **argv) unsigned short *q, sum; if (read(DEV, buffer, 512) != 512) - error_msg_and_die("fatal: first page unreadable"); + bb_error_msg_and_die("fatal: first page unreadable"); if (buffer[508] == 0xDA && buffer[509] == 0xBE) { q = (unsigned short *) (buffer + 510); for (sum = 0; q >= (unsigned short *) buffer;) sum ^= *q--; if (!sum) { - error_msg("Device '%s' contains a valid Sun disklabel.\n" + bb_error_msg("Device '%s' contains a valid Sun disklabel.\n" "This probably means creating v0 swap would destroy your partition table\n" "No swap created. If you really want to create swap v0 on that device, use\n" "the -f option to force it.", device_name); @@ -391,7 +391,7 @@ int mkswap_main(int argc, char **argv) if (version == 0 || check) check_blocks(); if (version == 0 && !bit_test_and_clear(signature_page, 0)) - error_msg_and_die("fatal: first page unreadable"); + bb_error_msg_and_die("fatal: first page unreadable"); if (version == 1) { p->version = version; p->last_page = PAGES - 1; @@ -400,23 +400,23 @@ int mkswap_main(int argc, char **argv) goodpages = PAGES - badpages - 1; if (goodpages <= 0) - error_msg_and_die("Unable to set up swap-space: unreadable"); + bb_error_msg_and_die("Unable to set up swap-space: unreadable"); printf("Setting up swapspace version %d, size = %ld bytes\n", version, (long) (goodpages * pagesize)); write_signature((version == 0) ? "SWAP-SPACE" : "SWAPSPACE2"); offset = ((version == 0) ? 0 : 1024); if (lseek(DEV, offset, SEEK_SET) != offset) - error_msg_and_die("unable to rewind swap-device"); + bb_error_msg_and_die("unable to rewind swap-device"); if (write(DEV, (char *) signature_page + offset, pagesize - offset) != pagesize - offset) - error_msg_and_die("unable to write signature page"); + bb_error_msg_and_die("unable to write signature page"); /* * A subsequent swapon() will fail if the signature * is not actually on disk. (This is a kernel bug.) */ if (fsync(DEV)) - error_msg_and_die("fsync failed"); + bb_error_msg_and_die("fsync failed"); return EXIT_SUCCESS; } diff --git a/util-linux/more.c b/util-linux/more.c index c26e4fe54..ff0557d22 100644 --- a/util-linux/more.c +++ b/util-linux/more.c @@ -81,7 +81,7 @@ extern int more_main(int argc, char **argv) if(isatty(fileno(stdout))) { cin = fopen(CURRENT_TTY, "r"); if (!cin) - cin = xfopen(CONSOLE_DEV, "r"); + cin = bb_xfopen(CONSOLE_DEV, "r"); please_display_more_prompt = 0; #ifdef CONFIG_FEATURE_USE_TERMIOS getTermSettings(fileno(cin), &initial_settings); @@ -105,7 +105,7 @@ extern int more_main(int argc, char **argv) if (argc == 0) { file = stdin; } else - file = wfopen(*argv, "r"); + file = bb_wfopen(*argv, "r"); if(file==0) goto loop; diff --git a/util-linux/mount.c b/util-linux/mount.c index b3e945ce3..d02005600 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -86,8 +86,6 @@ extern int umount2(__const char *__special_file, int __flags); extern int sysfs(int option, unsigned int fs_index, char *buf); -extern const char mtab_file[]; /* Defined in utility.c */ - struct mount_options { const char *name; unsigned long and; @@ -136,20 +134,20 @@ do_mount(char *specialfile, char *dir, char *filesystemtype, long flags, specialfile = find_unused_loop_device(); if (specialfile == NULL) { - error_msg_and_die("Could not find a spare loop device"); + bb_error_msg_and_die("Could not find a spare loop device"); } if (set_loop(specialfile, lofile, 0, &loro)) { - error_msg_and_die("Could not setup loop device"); + bb_error_msg_and_die("Could not setup loop device"); } if (!(flags & MS_RDONLY) && loro) { /* loop is ro, but wanted rw */ - error_msg("WARNING: loop device is read-only"); + bb_error_msg("WARNING: loop device is read-only"); flags |= MS_RDONLY; } } #endif status = mount(specialfile, dir, filesystemtype, flags, string_flags); if (status < 0 && errno == EROFS) { - error_msg("%s is write-protected, mounting read-only", + bb_error_msg("%s is write-protected, mounting read-only", specialfile); status = mount(specialfile, dir, filesystemtype, flags |= MS_RDONLY, string_flags); @@ -181,7 +179,7 @@ do_mount(char *specialfile, char *dir, char *filesystemtype, long flags, #endif if (errno == EPERM) { - error_msg_and_die("permission denied. Are you root?"); + bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); } return (FALSE); @@ -268,7 +266,7 @@ static int mount_one(char *blockDevice, char *directory, char *filesystemType, filesystemType = buf; - if (xstrlen(filesystemType)) { + if (bb_strlen(filesystemType)) { status = do_mount(blockDevice, directory, filesystemType, flags | MS_MGC_VAL, string_flags, @@ -284,7 +282,7 @@ static int mount_one(char *blockDevice, char *directory, char *filesystemType, } if ((!f || read_proc) && !status) { - f = xfopen("/proc/filesystems", "r"); + f = bb_xfopen("/proc/filesystems", "r"); while (fgets(buf, sizeof(buf), f) != NULL) { filesystemType = buf; @@ -319,7 +317,7 @@ static int mount_one(char *blockDevice, char *directory, char *filesystemType, if (!status) { if (whineOnErrors) { - perror_msg("Mounting %s on %s failed", blockDevice, directory); + bb_perror_msg("Mounting %s on %s failed", blockDevice, directory); } return (FALSE); } @@ -328,7 +326,7 @@ static int mount_one(char *blockDevice, char *directory, char *filesystemType, static void show_mounts(char *onlytype) { - FILE *mountTable = setmntent(mtab_file, "r"); + FILE *mountTable = setmntent(bb_path_mtab_file, "r"); if (mountTable) { struct mntent *m; @@ -351,7 +349,7 @@ static void show_mounts(char *onlytype) } endmntent(mountTable); } else { - perror_msg_and_die("%s", mtab_file); + bb_perror_msg_and_die(bb_path_mtab_file); } exit(EXIT_SUCCESS); } @@ -359,7 +357,7 @@ static void show_mounts(char *onlytype) extern int mount_main(int argc, char **argv) { struct stat statbuf; - char *string_flags = xstrdup(""); + char *string_flags = bb_xstrdup(""); char *extra_opts; int flags = 0; char *filesystemType = "auto"; @@ -413,7 +411,7 @@ extern int mount_main(int argc, char **argv) if (optind < argc) { /* if device is a filename get its real path */ if (stat(argv[optind], &statbuf) == 0) { - char *tmp = simplify_path(argv[optind]); + char *tmp = bb_simplify_path(argv[optind]); safe_strncpy(device, tmp, PATH_MAX); } else { @@ -422,13 +420,13 @@ extern int mount_main(int argc, char **argv) } if (optind + 1 < argc) - directory = simplify_path(argv[optind + 1]); + directory = bb_simplify_path(argv[optind + 1]); if (all || optind + 1 == argc) { f = setmntent("/etc/fstab", "r"); if (f == NULL) - perror_msg_and_die("\nCannot read /etc/fstab"); + bb_perror_msg_and_die("\nCannot read /etc/fstab"); while ((m = getmntent(f)) != NULL) { if (!all && (optind + 1 == argc) @@ -452,7 +450,7 @@ extern int mount_main(int argc, char **argv) strcpy(device, m->mnt_fsname); strcpy(directory, m->mnt_dir); - filesystemType = xstrdup(m->mnt_type); + filesystemType = bb_xstrdup(m->mnt_type); singlemount: extra_opts = string_flags; rc = EXIT_SUCCESS; @@ -462,7 +460,7 @@ extern int mount_main(int argc, char **argv) if (nfsmount (device, directory, &flags, &extra_opts, &string_flags, 1)) { - perror_msg("nfsmount failed"); + bb_perror_msg("nfsmount failed"); rc = EXIT_FAILURE; } } diff --git a/util-linux/nfsmount.c b/util-linux/nfsmount.c index ba14aa6bc..0edfdf34a 100644 --- a/util-linux/nfsmount.c +++ b/util-linux/nfsmount.c @@ -357,7 +357,7 @@ int nfsmount(const char *spec, const char *node, int *flags, msock = fsock = -1; mclient = NULL; if (strlen(spec) >= sizeof(hostdir)) { - error_msg("excessively long host:dir argument"); + bb_error_msg("excessively long host:dir argument"); goto fail; } strcpy(hostdir, spec); @@ -369,10 +369,10 @@ int nfsmount(const char *spec, const char *node, int *flags, until they can be fully supported. (mack@sgi.com) */ if ((s = strchr(hostdir, ','))) { *s = '\0'; - error_msg("warning: multiple hostnames not supported"); + bb_error_msg("warning: multiple hostnames not supported"); } } else { - error_msg("directory to mount not in host:dir format"); + bb_error_msg("directory to mount not in host:dir format"); goto fail; } @@ -382,11 +382,11 @@ int nfsmount(const char *spec, const char *node, int *flags, #endif { if ((hp = gethostbyname(hostname)) == NULL) { - herror_msg("%s", hostname); + bb_herror_msg("%s", hostname); goto fail; } else { if (hp->h_length > sizeof(struct in_addr)) { - error_msg("got bad hp->h_length"); + bb_error_msg("got bad hp->h_length"); hp->h_length = sizeof(struct in_addr); } memcpy(&server_addr.sin_addr, @@ -403,12 +403,12 @@ int nfsmount(const char *spec, const char *node, int *flags, if (!old_opts) old_opts = ""; if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) { - error_msg("excessively long option argument"); + bb_error_msg("excessively long option argument"); goto fail; } sprintf(new_opts, "%s%saddr=%s", old_opts, *old_opts ? "," : "", s); - *extra_opts = xstrdup(new_opts); + *extra_opts = bb_xstrdup(new_opts); /* Set default options. * rsize/wsize (and bsize, for ver >= 3) are left 0 in order to @@ -476,7 +476,7 @@ int nfsmount(const char *spec, const char *node, int *flags, else if (!strcmp(opt, "mountport")) mountport = val; else if (!strcmp(opt, "mounthost")) - mounthost=xstrndup(opteq+1, + mounthost=bb_xstrndup(opteq+1, strcspn(opteq+1," \t\n\r,")); else if (!strcmp(opt, "mountprog")) mountprog = val; @@ -563,11 +563,11 @@ int nfsmount(const char *spec, const char *node, int *flags, data.flags |= (nolock ? NFS_MOUNT_NONLM : 0); #endif if (nfsvers > MAX_NFSPROT) { - error_msg("NFSv%d not supported!", nfsvers); + bb_error_msg("NFSv%d not supported!", nfsvers); return 0; } if (mountvers > MAX_NFSPROT) { - error_msg("NFSv%d not supported!", nfsvers); + bb_error_msg("NFSv%d not supported!", nfsvers); return 0; } if (nfsvers && !mountvers) @@ -627,11 +627,11 @@ int nfsmount(const char *spec, const char *node, int *flags, mount_server_addr.sin_addr.s_addr = inet_addr(hostname); } else { if ((hp = gethostbyname(mounthost)) == NULL) { - herror_msg("%s", mounthost); + bb_herror_msg("%s", mounthost); goto fail; } else { if (hp->h_length > sizeof(struct in_addr)) { - error_msg("got bad hp->h_length?"); + bb_error_msg("got bad hp->h_length?"); hp->h_length = sizeof(struct in_addr); } mount_server_addr.sin_family = AF_INET; @@ -753,7 +753,7 @@ int nfsmount(const char *spec, const char *node, int *flags, if (!bg) goto fail; if (!running_bg) { - prev_bg_host = xstrdup(hostname); + prev_bg_host = bb_xstrdup(hostname); if (retry > 0) retval = EX_BG; goto fail; @@ -766,7 +766,7 @@ int nfsmount(const char *spec, const char *node, int *flags, if (nfsvers == 2) { if (status.nfsv2.fhs_status != 0) { - error_msg("%s:%s failed, reason given by server: %s", + bb_error_msg("%s:%s failed, reason given by server: %s", hostname, pathname, nfs_strerror(status.nfsv2.fhs_status)); goto fail; @@ -784,7 +784,7 @@ int nfsmount(const char *spec, const char *node, int *flags, #if NFS_MOUNT_VERSION >= 4 fhandle3 *my_fhandle; if (status.nfsv3.fhs_status != 0) { - error_msg("%s:%s failed, reason given by server: %s", + bb_error_msg("%s:%s failed, reason given by server: %s", hostname, pathname, nfs_strerror(status.nfsv3.fhs_status)); goto fail; diff --git a/util-linux/pivot_root.c b/util-linux/pivot_root.c index ba26b9c58..39453a261 100644 --- a/util-linux/pivot_root.c +++ b/util-linux/pivot_root.c @@ -16,10 +16,10 @@ extern int pivot_root(const char * new_root,const char * put_old); int pivot_root_main(int argc, char **argv) { if (argc != 3) - show_usage(); + bb_show_usage(); if (pivot_root(argv[1],argv[2]) < 0) - perror_msg_and_die("pivot_root"); + bb_perror_msg_and_die("pivot_root"); return EXIT_SUCCESS; diff --git a/util-linux/rdate.c b/util-linux/rdate.c index df7d7bbc4..3c3b152a2 100644 --- a/util-linux/rdate.c +++ b/util-linux/rdate.c @@ -49,7 +49,7 @@ static time_t askremotedate(const char *host) fd = xconnect(host, port); if (read(fd, (void *)&nett, 4) != 4) /* read time from server */ - error_msg_and_die("%s did not send the complete time", host); + bb_error_msg_and_die("%s did not send the complete time", host); close(fd); @@ -83,18 +83,18 @@ int rdate_main(int argc, char **argv) setdate = 0; break; default: - show_usage(); + bb_show_usage(); } } if (optind == argc) - show_usage(); + bb_show_usage(); remote_time = askremotedate(argv[optind]); if (setdate) { if (stime(&remote_time) < 0) - perror_msg_and_die("Could not set time of day"); + bb_perror_msg_and_die("Could not set time of day"); } if (printdate) diff --git a/util-linux/swaponoff.c b/util-linux/swaponoff.c index 918a5bc0e..b323cb10a 100644 --- a/util-linux/swaponoff.c +++ b/util-linux/swaponoff.c @@ -51,13 +51,13 @@ static int swap_enable_disable(const char *device) struct stat st; if (stat(device, &st) < 0) { - perror_msg_and_die("cannot stat %s"); + bb_perror_msg_and_die("cannot stat %s", device); } /* test for holes */ if (S_ISREG(st.st_mode)) { if (st.st_blocks * 512 < st.st_size) { - error_msg_and_die("swap file has holes"); + bb_error_msg_and_die("swap file has holes"); } } @@ -67,7 +67,7 @@ static int swap_enable_disable(const char *device) status = swapoff(device); if (status != 0) { - perror_msg("%s", device); + bb_perror_msg("%s", device); return EXIT_FAILURE; } return EXIT_SUCCESS; @@ -80,7 +80,7 @@ static int do_em_all(void) int err = 0; if (f == NULL) - perror_msg_and_die("/etc/fstab"); + bb_perror_msg_and_die("/etc/fstab"); while ((m = getmntent(f)) != NULL) { if (strcmp(m->mnt_type, MNTTYPE_SWAP)==0) { if(swap_enable_disable(m->mnt_fsname) == EXIT_FAILURE) @@ -94,7 +94,7 @@ static int do_em_all(void) extern int swap_on_off_main(int argc, char **argv) { - if (applet_name[5] == 'f') { /* "swapoff" */ + if (bb_applet_name[5] == 'f') { /* "swapoff" */ whichApp = SWAPOFF_APP; } @@ -113,7 +113,7 @@ extern int swap_on_off_main(int argc, char **argv) struct stat statBuf; if (stat("/etc/fstab", &statBuf) < 0) - error_msg_and_die("/etc/fstab file missing"); + bb_error_msg_and_die("/etc/fstab file missing"); } return do_em_all(); break; @@ -124,5 +124,5 @@ extern int swap_on_off_main(int argc, char **argv) return swap_enable_disable(*argv); usage_and_exit: - show_usage(); + bb_show_usage(); } diff --git a/util-linux/umount.c b/util-linux/umount.c index 391d245a8..1d3e89301 100644 --- a/util-linux/umount.c +++ b/util-linux/umount.c @@ -67,7 +67,6 @@ static int useMtab = TRUE; #endif static int umountAll = FALSE; static int doRemount = FALSE; -extern const char mtab_file[]; /* Defined in utility.c */ @@ -87,8 +86,8 @@ static void mtab_read(void) if (mtab_cache != NULL) return; - if ((fp = setmntent(mtab_file, "r")) == NULL) { - error_msg("Cannot open %s", mtab_file); + if ((fp = setmntent(bb_path_mtab_file, "r")) == NULL) { + bb_error_msg("Cannot open %s", bb_path_mtab_file); return; } while ((e = getmntent(fp))) { @@ -185,7 +184,7 @@ static int do_umount(const char *name) if (status != 0 && doForce) { status = umount2(blockDevice, MNT_FORCE); if (status != 0) { - error_msg_and_die("forced umount of %s failed!", blockDevice); + bb_error_msg_and_die("forced umount of %s failed!", blockDevice); } } #endif @@ -193,9 +192,9 @@ static int do_umount(const char *name) status = mount(blockDevice, name, NULL, MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL); if (status == 0) { - error_msg("%s busy - remounted read-only", blockDevice); + bb_error_msg("%s busy - remounted read-only", blockDevice); } else { - error_msg("Cannot remount %s read-only", blockDevice); + bb_error_msg("Cannot remount %s read-only", blockDevice); } } if (status == 0) { @@ -221,7 +220,7 @@ static int umount_all(void) if (!do_umount(mountpt)) { /* Don't bother retrying the umount on busy devices */ if (errno == EBUSY) { - perror_msg("%s", mountpt); + bb_perror_msg("%s", mountpt); status = FALSE; continue; } @@ -241,7 +240,7 @@ extern int umount_main(int argc, char **argv) char path[PATH_MAX]; if (argc < 2) { - show_usage(); + bb_show_usage(); } #ifdef CONFIG_FEATURE_CLEAN_UP atexit(mtab_free); @@ -275,7 +274,7 @@ extern int umount_main(int argc, char **argv) case 'v': break; /* ignore -v */ default: - show_usage(); + bb_show_usage(); } } @@ -287,9 +286,9 @@ extern int umount_main(int argc, char **argv) return EXIT_FAILURE; } if (realpath(*argv, path) == NULL) - perror_msg_and_die("%s", path); + bb_perror_msg_and_die("%s", path); if (do_umount(path)) return EXIT_SUCCESS; - perror_msg_and_die("%s", *argv); + bb_perror_msg_and_die("%s", *argv); } |