*: remove a few more cases of argc usage. -89 bytes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
86cfb70ca5
commit
e992bae6f9
@ -6,19 +6,12 @@
|
|||||||
*
|
*
|
||||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int chvt_main(int argc, char **argv)
|
int chvt_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
int num;
|
int num = xatou_range(single_argv(argv), 1, 63);
|
||||||
|
|
||||||
if (argc != 2) {
|
|
||||||
bb_show_usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
num = xatou_range(argv[1], 1, 63);
|
|
||||||
console_make_active(get_console_fd_or_die(), num);
|
console_make_active(get_console_fd_or_die(), num);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -12,18 +12,16 @@
|
|||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
int chroot_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int chroot_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int chroot_main(int argc, char **argv)
|
int chroot_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
if (argc < 2) {
|
|
||||||
bb_show_usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
++argv;
|
++argv;
|
||||||
|
if (!*argv)
|
||||||
|
bb_show_usage();
|
||||||
xchroot(*argv);
|
xchroot(*argv);
|
||||||
xchdir("/");
|
xchdir("/");
|
||||||
|
|
||||||
++argv;
|
++argv;
|
||||||
if (argc == 2) {
|
if (!*argv) { /* no 2nd param (PROG), use shell */
|
||||||
argv -= 2;
|
argv -= 2;
|
||||||
argv[0] = getenv("SHELL");
|
argv[0] = getenv("SHELL");
|
||||||
if (!argv[0]) {
|
if (!argv[0]) {
|
||||||
|
@ -35,7 +35,7 @@ static unsigned long kscale(unsigned long b, unsigned long bs)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int df_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int df_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int df_main(int argc, char **argv)
|
int df_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
unsigned long blocks_used;
|
unsigned long blocks_used;
|
||||||
unsigned blocks_percent_used;
|
unsigned blocks_percent_used;
|
||||||
@ -105,7 +105,7 @@ int df_main(int argc, char **argv)
|
|||||||
|
|
||||||
mount_table = NULL;
|
mount_table = NULL;
|
||||||
argv += optind;
|
argv += optind;
|
||||||
if (optind >= argc) {
|
if (!argv[0]) {
|
||||||
mount_table = setmntent(bb_path_mtab_file, "r");
|
mount_table = setmntent(bb_path_mtab_file, "r");
|
||||||
if (!mount_table)
|
if (!mount_table)
|
||||||
bb_perror_msg_and_die(bb_path_mtab_file);
|
bb_perror_msg_and_die(bb_path_mtab_file);
|
||||||
|
@ -15,13 +15,8 @@
|
|||||||
/* This is a NOFORK applet. Be very careful! */
|
/* This is a NOFORK applet. Be very careful! */
|
||||||
|
|
||||||
int dirname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int dirname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int dirname_main(int argc, char **argv)
|
int dirname_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
if (argc != 2) {
|
puts(dirname(single_argv(argv)));
|
||||||
bb_show_usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
puts(dirname(argv[1]));
|
|
||||||
|
|
||||||
return fflush_all();
|
return fflush_all();
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ static void convert(char *fn, int conv_type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int dos2unix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int dos2unix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int dos2unix_main(int argc, char **argv)
|
int dos2unix_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
int o, conv_type;
|
int o, conv_type;
|
||||||
|
|
||||||
@ -88,11 +88,11 @@ int dos2unix_main(int argc, char **argv)
|
|||||||
if (o)
|
if (o)
|
||||||
conv_type = o;
|
conv_type = o;
|
||||||
|
|
||||||
|
argv += optind;
|
||||||
do {
|
do {
|
||||||
/* might be convert(NULL) if there is no filename given */
|
/* might be convert(NULL) if there is no filename given */
|
||||||
convert(argv[optind], conv_type);
|
convert(*argv, conv_type);
|
||||||
optind++;
|
} while (*++argv);
|
||||||
} while (optind < argc);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ int ln_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
|||||||
int ln_main(int argc, char **argv)
|
int ln_main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int status = EXIT_SUCCESS;
|
int status = EXIT_SUCCESS;
|
||||||
int flag;
|
int opts;
|
||||||
char *last;
|
char *last;
|
||||||
char *src_name;
|
char *src_name;
|
||||||
char *src;
|
char *src;
|
||||||
@ -34,11 +34,8 @@ int ln_main(int argc, char **argv)
|
|||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
int (*link_func)(const char *, const char *);
|
int (*link_func)(const char *, const char *);
|
||||||
|
|
||||||
flag = getopt32(argv, "sfnbS:", &suffix);
|
opt_complementary = "-1"; /* min one arg */
|
||||||
|
opts = getopt32(argv, "sfnbS:", &suffix);
|
||||||
if (argc == optind) {
|
|
||||||
bb_show_usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
last = argv[argc - 1];
|
last = argv[argc - 1];
|
||||||
argv += optind;
|
argv += optind;
|
||||||
@ -53,7 +50,7 @@ int ln_main(int argc, char **argv)
|
|||||||
src = last;
|
src = last;
|
||||||
|
|
||||||
if (is_directory(src,
|
if (is_directory(src,
|
||||||
(flag & LN_NODEREFERENCE) ^ LN_NODEREFERENCE,
|
(opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE,
|
||||||
NULL)
|
NULL)
|
||||||
) {
|
) {
|
||||||
src_name = xstrdup(*argv);
|
src_name = xstrdup(*argv);
|
||||||
@ -61,7 +58,7 @@ int ln_main(int argc, char **argv)
|
|||||||
free(src_name);
|
free(src_name);
|
||||||
src_name = src;
|
src_name = src;
|
||||||
}
|
}
|
||||||
if (!(flag & LN_SYMLINK) && stat(*argv, &statbuf)) {
|
if (!(opts & LN_SYMLINK) && stat(*argv, &statbuf)) {
|
||||||
// coreutils: "ln dangling_symlink new_hardlink" works
|
// coreutils: "ln dangling_symlink new_hardlink" works
|
||||||
if (lstat(*argv, &statbuf) || !S_ISLNK(statbuf.st_mode)) {
|
if (lstat(*argv, &statbuf) || !S_ISLNK(statbuf.st_mode)) {
|
||||||
bb_simple_perror_msg(*argv);
|
bb_simple_perror_msg(*argv);
|
||||||
@ -71,7 +68,7 @@ int ln_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag & LN_BACKUP) {
|
if (opts & LN_BACKUP) {
|
||||||
char *backup;
|
char *backup;
|
||||||
backup = xasprintf("%s%s", src, suffix);
|
backup = xasprintf("%s%s", src, suffix);
|
||||||
if (rename(src, backup) < 0 && errno != ENOENT) {
|
if (rename(src, backup) < 0 && errno != ENOENT) {
|
||||||
@ -87,12 +84,12 @@ int ln_main(int argc, char **argv)
|
|||||||
* Therefore, always unlink().
|
* Therefore, always unlink().
|
||||||
*/
|
*/
|
||||||
unlink(src);
|
unlink(src);
|
||||||
} else if (flag & LN_FORCE) {
|
} else if (opts & LN_FORCE) {
|
||||||
unlink(src);
|
unlink(src);
|
||||||
}
|
}
|
||||||
|
|
||||||
link_func = link;
|
link_func = link;
|
||||||
if (flag & LN_SYMLINK) {
|
if (opts & LN_SYMLINK) {
|
||||||
link_func = symlink;
|
link_func = symlink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ static const char mkdir_longopts[] ALIGN1 =
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int mkdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int mkdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int mkdir_main(int argc, char **argv)
|
int mkdir_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
mode_t mode = (mode_t)(-1);
|
mode_t mode = (mode_t)(-1);
|
||||||
int status = EXIT_SUCCESS;
|
int status = EXIT_SUCCESS;
|
||||||
@ -64,11 +64,9 @@ int mkdir_main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (optind == argc) {
|
|
||||||
bb_show_usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
argv += optind;
|
argv += optind;
|
||||||
|
if (!argv[0])
|
||||||
|
bb_show_usage();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (bb_make_directory(*argv, mode, flags)) {
|
if (bb_make_directory(*argv, mode, flags)) {
|
||||||
|
@ -32,14 +32,14 @@ nohup: redirecting stderr to stdout
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int nohup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int nohup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int nohup_main(int argc, char **argv)
|
int nohup_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
const char *nohupout;
|
const char *nohupout;
|
||||||
char *home;
|
char *home;
|
||||||
|
|
||||||
xfunc_error_retval = 127;
|
xfunc_error_retval = 127;
|
||||||
|
|
||||||
if (argc < 2) bb_show_usage();
|
if (!argv[1]) bb_show_usage();
|
||||||
|
|
||||||
/* If stdin is a tty, detach from it. */
|
/* If stdin is a tty, detach from it. */
|
||||||
if (isatty(STDIN_FILENO)) {
|
if (isatty(STDIN_FILENO)) {
|
||||||
|
@ -640,29 +640,29 @@ static bool do_stat(const char *filename, const char *format)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int stat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int stat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int stat_main(int argc, char **argv)
|
int stat_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
IF_FEATURE_STAT_FORMAT(char *format = NULL;)
|
IF_FEATURE_STAT_FORMAT(char *format = NULL;)
|
||||||
int i;
|
int i;
|
||||||
int ok = 1;
|
int ok;
|
||||||
|
unsigned opts;
|
||||||
statfunc_ptr statfunc = do_stat;
|
statfunc_ptr statfunc = do_stat;
|
||||||
|
|
||||||
getopt32(argv, "ftL"
|
opt_complementary = "-1"; /* min one arg */
|
||||||
|
opts = getopt32(argv, "ftL"
|
||||||
IF_SELINUX("Z")
|
IF_SELINUX("Z")
|
||||||
IF_FEATURE_STAT_FORMAT("c:", &format)
|
IF_FEATURE_STAT_FORMAT("c:", &format)
|
||||||
);
|
);
|
||||||
|
if (opts & OPT_FILESYS) /* -f */
|
||||||
if (option_mask32 & OPT_FILESYS) /* -f */
|
|
||||||
statfunc = do_statfs;
|
statfunc = do_statfs;
|
||||||
if (argc == optind) /* files */
|
|
||||||
bb_show_usage();
|
|
||||||
|
|
||||||
#if ENABLE_SELINUX
|
#if ENABLE_SELINUX
|
||||||
if (option_mask32 & OPT_SELINUX) {
|
if (opts & OPT_SELINUX) {
|
||||||
selinux_or_die();
|
selinux_or_die();
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_SELINUX */
|
#endif
|
||||||
for (i = optind; i < argc; ++i)
|
ok = 1;
|
||||||
|
argv += optind;
|
||||||
|
for (i = 0; argv[i]; ++i)
|
||||||
ok &= statfunc(argv[i] IF_FEATURE_STAT_FORMAT(, format));
|
ok &= statfunc(argv[i] IF_FEATURE_STAT_FORMAT(, format));
|
||||||
|
|
||||||
return (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
return (ok ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
|
@ -1156,7 +1156,7 @@ static void set_control_char_or_die(const struct control_info *info,
|
|||||||
#define STTY_noargs (1 << 4)
|
#define STTY_noargs (1 << 4)
|
||||||
|
|
||||||
int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int stty_main(int argc, char **argv)
|
int stty_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
struct termios mode;
|
struct termios mode;
|
||||||
void (*output_func)(const struct termios *, const int);
|
void (*output_func)(const struct termios *, const int);
|
||||||
@ -1211,8 +1211,10 @@ int stty_main(int argc, char **argv)
|
|||||||
if (!file_name)
|
if (!file_name)
|
||||||
bb_error_msg_and_die(bb_msg_requires_arg, "-F");
|
bb_error_msg_and_die(bb_msg_requires_arg, "-F");
|
||||||
/* remove -F param from arg[vc] */
|
/* remove -F param from arg[vc] */
|
||||||
--argc;
|
while (argv[p]) {
|
||||||
while (argv[p]) { argv[p] = argv[p+1]; ++p; }
|
argv[p] = argv[p+1];
|
||||||
|
++p;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
goto end_option;
|
goto end_option;
|
||||||
default:
|
default:
|
||||||
|
@ -19,14 +19,13 @@
|
|||||||
/* This is a NOFORK applet. Be very careful! */
|
/* This is a NOFORK applet. Be very careful! */
|
||||||
|
|
||||||
int yes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int yes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int yes_main(int argc, char **argv)
|
int yes_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
char **pp;
|
char **pp;
|
||||||
|
|
||||||
argv[0] = (char*)"y";
|
argv[0] = (char*)"y";
|
||||||
if (argc != 1) {
|
if (argv[1])
|
||||||
++argv;
|
++argv;
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
pp = argv;
|
pp = argv;
|
||||||
|
@ -869,6 +869,7 @@ void bb_sanitize_stdio(void) FAST_FUNC;
|
|||||||
int sanitize_env_if_suid(void) FAST_FUNC;
|
int sanitize_env_if_suid(void) FAST_FUNC;
|
||||||
|
|
||||||
|
|
||||||
|
char* single_argv(char **argv) FAST_FUNC;
|
||||||
extern const char *const bb_argv_dash[]; /* "-", NULL */
|
extern const char *const bb_argv_dash[]; /* "-", NULL */
|
||||||
extern const char *opt_complementary;
|
extern const char *opt_complementary;
|
||||||
#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
|
#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
|
||||||
|
@ -92,6 +92,7 @@ lib-y += setup_environment.o
|
|||||||
lib-y += sha1.o
|
lib-y += sha1.o
|
||||||
lib-y += signals.o
|
lib-y += signals.o
|
||||||
lib-y += simplify_path.o
|
lib-y += simplify_path.o
|
||||||
|
lib-y += single_argv.o
|
||||||
lib-y += skip_whitespace.o
|
lib-y += skip_whitespace.o
|
||||||
lib-y += speed_table.o
|
lib-y += speed_table.o
|
||||||
lib-y += str_tolower.o
|
lib-y += str_tolower.o
|
||||||
|
16
libbb/single_argv.c
Normal file
16
libbb/single_argv.c
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/* vi: set sw=4 ts=4: */
|
||||||
|
/*
|
||||||
|
* Utility routines.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Denys Vlasenko
|
||||||
|
*
|
||||||
|
* Licensed under GPLv2, see file LICENSE in this tarball for details.
|
||||||
|
*/
|
||||||
|
#include "libbb.h"
|
||||||
|
|
||||||
|
char* FAST_FUNC single_argv(char **argv)
|
||||||
|
{
|
||||||
|
if (!argv[1] || argv[2])
|
||||||
|
bb_show_usage();
|
||||||
|
return argv[1];
|
||||||
|
}
|
@ -56,7 +56,7 @@ static const char ret_code_descript[] =
|
|||||||
;
|
;
|
||||||
|
|
||||||
int adjtimex_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int adjtimex_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int adjtimex_main(int argc, char **argv)
|
int adjtimex_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
OPT_quiet = 0x1
|
OPT_quiet = 0x1
|
||||||
@ -66,10 +66,11 @@ int adjtimex_main(int argc, char **argv)
|
|||||||
struct timex txc;
|
struct timex txc;
|
||||||
int i, ret;
|
int i, ret;
|
||||||
const char *descript;
|
const char *descript;
|
||||||
txc.modes=0;
|
|
||||||
|
|
||||||
|
opt_complementary = "=0"; /* no valid non-option parameters */
|
||||||
opt = getopt32(argv, "qo:f:p:t:",
|
opt = getopt32(argv, "qo:f:p:t:",
|
||||||
&opt_o, &opt_f, &opt_p, &opt_t);
|
&opt_o, &opt_f, &opt_p, &opt_t);
|
||||||
|
txc.modes = 0;
|
||||||
//if (opt & 0x1) // -q
|
//if (opt & 0x1) // -q
|
||||||
if (opt & 0x2) { // -o
|
if (opt & 0x2) { // -o
|
||||||
txc.offset = xatol(opt_o);
|
txc.offset = xatol(opt_o);
|
||||||
@ -87,9 +88,6 @@ int adjtimex_main(int argc, char **argv)
|
|||||||
txc.tick = xatol(opt_t);
|
txc.tick = xatol(opt_t);
|
||||||
txc.modes |= ADJ_TICK;
|
txc.modes |= ADJ_TICK;
|
||||||
}
|
}
|
||||||
if (argc != optind) { /* no valid non-option parameters */
|
|
||||||
bb_show_usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = adjtimex(&txc);
|
ret = adjtimex(&txc);
|
||||||
|
|
||||||
|
@ -14,12 +14,8 @@
|
|||||||
#include <linux/raid/md_u.h>
|
#include <linux/raid/md_u.h>
|
||||||
|
|
||||||
int raidautorun_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int raidautorun_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int raidautorun_main(int argc, char **argv)
|
int raidautorun_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
if (argc != 2)
|
xioctl(xopen(single_argv(argv), O_RDONLY), RAID_AUTORUN, NULL);
|
||||||
bb_show_usage();
|
|
||||||
|
|
||||||
xioctl(xopen(argv[1], O_RDONLY), RAID_AUTORUN, NULL);
|
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -234,21 +234,18 @@ static void sigalrm_handler(int UNUSED_PARAM signum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int rx_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int rx_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int rx_main(int argc, char **argv)
|
int rx_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
struct termios tty, orig_tty;
|
struct termios tty, orig_tty;
|
||||||
int termios_err;
|
int termios_err;
|
||||||
int file_fd;
|
int file_fd;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if (argc != 2)
|
|
||||||
bb_show_usage();
|
|
||||||
|
|
||||||
/* Disabled by vda:
|
/* Disabled by vda:
|
||||||
* why we can't receive from stdin? Why we *require*
|
* why we can't receive from stdin? Why we *require*
|
||||||
* controlling tty?? */
|
* controlling tty?? */
|
||||||
/*read_fd = xopen(CURRENT_TTY, O_RDWR);*/
|
/*read_fd = xopen(CURRENT_TTY, O_RDWR);*/
|
||||||
file_fd = xopen(argv[1], O_RDWR|O_CREAT|O_TRUNC);
|
file_fd = xopen(single_argv(argv), O_RDWR|O_CREAT|O_TRUNC);
|
||||||
|
|
||||||
termios_err = tcgetattr(read_fd, &tty);
|
termios_err = tcgetattr(read_fd, &tty);
|
||||||
if (termios_err == 0) {
|
if (termios_err == 0) {
|
||||||
|
@ -463,9 +463,7 @@ int runsv_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
INIT_G();
|
INIT_G();
|
||||||
|
|
||||||
if (!argv[1] || argv[2])
|
dir = single_argv(argv);
|
||||||
bb_show_usage();
|
|
||||||
dir = argv[1];
|
|
||||||
|
|
||||||
xpiped_pair(selfpipe);
|
xpiped_pair(selfpipe);
|
||||||
close_on_exec_on(selfpipe.rd);
|
close_on_exec_on(selfpipe.rd);
|
||||||
|
@ -2821,7 +2821,7 @@ unknown_command(int c)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int fdisk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int fdisk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int fdisk_main(int argc, char **argv)
|
int fdisk_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
unsigned opt;
|
unsigned opt;
|
||||||
/*
|
/*
|
||||||
@ -2839,7 +2839,6 @@ int fdisk_main(int argc, char **argv)
|
|||||||
opt_complementary = "b+:C+:H+:S+"; /* numeric params */
|
opt_complementary = "b+:C+:H+:S+"; /* numeric params */
|
||||||
opt = getopt32(argv, "b:C:H:lS:u" IF_FEATURE_FDISK_BLKSIZE("s"),
|
opt = getopt32(argv, "b:C:H:lS:u" IF_FEATURE_FDISK_BLKSIZE("s"),
|
||||||
§or_size, &user_cylinders, &user_heads, &user_sectors);
|
§or_size, &user_cylinders, &user_heads, &user_sectors);
|
||||||
argc -= optind;
|
|
||||||
argv += optind;
|
argv += optind;
|
||||||
if (opt & OPT_b) { // -b
|
if (opt & OPT_b) { // -b
|
||||||
/* Ugly: this sector size is really per device,
|
/* Ugly: this sector size is really per device,
|
||||||
@ -2883,14 +2882,14 @@ int fdisk_main(int argc, char **argv)
|
|||||||
int j;
|
int j;
|
||||||
|
|
||||||
nowarn = 1;
|
nowarn = 1;
|
||||||
if (argc <= 0)
|
if (!argv[0])
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
for (j = 0; j < argc; j++) {
|
for (j = 0; argv[j]; j++) {
|
||||||
unsigned long long size;
|
unsigned long long size;
|
||||||
fd = xopen(argv[j], O_RDONLY);
|
fd = xopen(argv[j], O_RDONLY);
|
||||||
size = bb_BLKGETSIZE_sectors(fd) / 2;
|
size = bb_BLKGETSIZE_sectors(fd) / 2;
|
||||||
close(fd);
|
close(fd);
|
||||||
if (argc == 1)
|
if (argv[1])
|
||||||
printf("%llu\n", size);
|
printf("%llu\n", size);
|
||||||
else
|
else
|
||||||
printf("%s: %llu\n", argv[j], size);
|
printf("%s: %llu\n", argv[j], size);
|
||||||
@ -2900,7 +2899,7 @@ int fdisk_main(int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLE_FEATURE_FDISK_WRITABLE
|
#if ENABLE_FEATURE_FDISK_WRITABLE
|
||||||
if (argc != 1)
|
if (!argv[0] || argv[1])
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
|
|
||||||
disk_device = argv[0];
|
disk_device = argv[0];
|
||||||
|
@ -15,16 +15,14 @@
|
|||||||
#define FDFLUSH _IO(2,0x4b)
|
#define FDFLUSH _IO(2,0x4b)
|
||||||
|
|
||||||
int freeramdisk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
int freeramdisk_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||||
int freeramdisk_main(int argc, char **argv)
|
int freeramdisk_main(int argc UNUSED_PARAM, char **argv)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (argc != 2) bb_show_usage();
|
fd = xopen(single_argv(argv), O_RDWR);
|
||||||
|
|
||||||
fd = xopen(argv[1], O_RDWR);
|
|
||||||
|
|
||||||
// Act like freeramdisk, fdflush, or both depending on configuration.
|
// Act like freeramdisk, fdflush, or both depending on configuration.
|
||||||
ioctl_or_perror_and_die(fd, (ENABLE_FREERAMDISK && applet_name[1]=='r')
|
ioctl_or_perror_and_die(fd, (ENABLE_FREERAMDISK && applet_name[1] == 'r')
|
||||||
|| !ENABLE_FDFLUSH ? BLKFLSBUF : FDFLUSH, NULL, "%s", argv[1]);
|
|| !ENABLE_FDFLUSH ? BLKFLSBUF : FDFLUSH, NULL, "%s", argv[1]);
|
||||||
|
|
||||||
if (ENABLE_FEATURE_CLEAN_UP) close(fd);
|
if (ENABLE_FEATURE_CLEAN_UP) close(fd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user