From: Eric Andersen Date: Mon, 18 Oct 1999 21:31:00 +0000 (-0000) Subject: More stuff X-Git-Tag: 0_32~42 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=703c62da63aa31d665a8215f373b26e4b54f1bf4;p=oweals%2Fbusybox.git More stuff --- diff --git a/busybox.def.h b/busybox.def.h index 8fcbf8350..c278f4ce0 100644 --- a/busybox.def.h +++ b/busybox.def.h @@ -18,10 +18,10 @@ #define BB_FDFLUSH #define BB_FIND #define BB_GREP -////#define BB_HALT +#define BB_HALT #define BB_INIT #define BB_KILL -////#define BB_LENGTH +#define BB_LENGTH #define BB_LN //#define BB_LOADKMAP ////#define BB_LOSETUP @@ -48,7 +48,7 @@ #define BB_TOUCH #define BB_TRUE #define BB_UMOUNT -//#define BB_UPDATE +#define BB_UPDATE #define BB_UTILITY #define BB_ZCAT //#define BB_GZIP diff --git a/coreutils/length.c b/coreutils/length.c index 284bbfdf9..f2dadd25c 100644 --- a/coreutils/length.c +++ b/coreutils/length.c @@ -3,11 +3,13 @@ #include #include -const char length_usage[] = "length string"; - -int -length_main(struct FileInfo * i, int argc, char * * argv) +extern int +length_main(int argc, char * * argv) { - printf("%d\n", strlen(argv[1])); - return 0; + if ( **(argv+1) == '-' ) { + fprintf(stderr, "Usage: length string\n"); + exit(FALSE); + } + printf("%d\n", strlen(argv[1])); + return( TRUE); } diff --git a/halt.c b/halt.c index 7f3ccf966..0dbdc55f1 100644 --- a/halt.c +++ b/halt.c @@ -1,12 +1,9 @@ #include "internal.h" #include -const char halt_usage[] = "halt\n" -"\n\t" -"\thalt the system.\n"; - extern int -halt_main(struct FileInfo * i, int argc, char * * argv) +halt_main(int argc, char ** argv) { - return kill(1, SIGUSR1); + exit( kill(1, SIGUSR1)); } + diff --git a/init/halt.c b/init/halt.c index 7f3ccf966..0dbdc55f1 100644 --- a/init/halt.c +++ b/init/halt.c @@ -1,12 +1,9 @@ #include "internal.h" #include -const char halt_usage[] = "halt\n" -"\n\t" -"\thalt the system.\n"; - extern int -halt_main(struct FileInfo * i, int argc, char * * argv) +halt_main(int argc, char ** argv) { - return kill(1, SIGUSR1); + exit( kill(1, SIGUSR1)); } + diff --git a/length.c b/length.c index 284bbfdf9..f2dadd25c 100644 --- a/length.c +++ b/length.c @@ -3,11 +3,13 @@ #include #include -const char length_usage[] = "length string"; - -int -length_main(struct FileInfo * i, int argc, char * * argv) +extern int +length_main(int argc, char * * argv) { - printf("%d\n", strlen(argv[1])); - return 0; + if ( **(argv+1) == '-' ) { + fprintf(stderr, "Usage: length string\n"); + exit(FALSE); + } + printf("%d\n", strlen(argv[1])); + return( TRUE); } diff --git a/losetup.c b/losetup.c deleted file mode 100644 index 2908dbc88..000000000 --- a/losetup.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - * losetup.c - setup and control loop devices - */ - - -#include "internal.h" - -const char losetup_usage[] = "losetup\n" -"\n" -"\tlosetup loop_device give info\n" -"\tlosetup -d loop_device delete\n" -"\tlosetup [ -o offset ] loop_device file setup\n"; - -/* from mount-2.6d */ - -/* - * losetup.c - setup and control loop devices - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* #include "loop.h" */ - -/* - * include/linux/loop.h - * - * Written by Theodore Ts'o, 3/29/93. - * - * Copyright 1993 by Theodore Ts'o. Redistribution of this file is - * permitted under the GNU Public License. - */ - -#define LO_NAME_SIZE 64 -#define LO_KEY_SIZE 32 - -struct loop_info { - int lo_number; /* ioctl r/o */ - dev_t lo_device; /* ioctl r/o */ - unsigned long lo_inode; /* ioctl r/o */ - dev_t lo_rdevice; /* ioctl r/o */ - int lo_offset; - int lo_encrypt_type; - int lo_encrypt_key_size; /* ioctl w/o */ - int lo_flags; /* ioctl r/o */ - char lo_name[LO_NAME_SIZE]; - unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */ - unsigned long lo_init[2]; - char reserved[4]; -}; - -/* - * IOCTL commands --- we will commandeer 0x4C ('L') - */ - -#define LOOP_SET_FD 0x4C00 -#define LOOP_CLR_FD 0x4C01 -#define LOOP_SET_STATUS 0x4C02 -#define LOOP_GET_STATUS 0x4C03 - -/* #include "lomount.h" */ - -extern int set_loop (const char *, const char *, int, int *); -extern int del_loop (const char *); - -static void show_loop(const char *device) -{ - struct loop_info loopinfo; - int fd; - - if ((fd = open(device, O_RDWR)) < 0) { - perror(device); - return; - } - if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) < 0) { - perror("Cannot get loop info"); - close(fd); - return; - } - printf("%s: [%04x]:%ld (%s) offset %d\n", - device, (unsigned int)loopinfo.lo_device, loopinfo.lo_inode, - loopinfo.lo_name, loopinfo.lo_offset); - close(fd); -} - - -int set_loop(const char *device, const char *file, int offset, int *loopro) -{ - struct loop_info loopinfo; - int fd, ffd, mode; - - mode = *loopro ? O_RDONLY : O_RDWR; - if ((ffd = open (file, mode)) < 0 && !*loopro - && (errno != EROFS || (ffd = open (file, mode = O_RDONLY)) < 0)) { - perror (file); - return 1; - } - if ((fd = open (device, mode)) < 0) { - close(ffd); - perror (device); - return 1; - } - *loopro = (mode == O_RDONLY); - - memset(&loopinfo, 0, sizeof(loopinfo)); - strncpy(loopinfo.lo_name, file, LO_NAME_SIZE); - loopinfo.lo_name[LO_NAME_SIZE-1] = 0; - - loopinfo.lo_offset = offset; - - loopinfo.lo_encrypt_key_size = 0; - if (ioctl(fd, LOOP_SET_FD, ffd) < 0) { - perror("ioctl: LOOP_SET_FD"); - exit(1); - } - if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) { - (void) ioctl(fd, LOOP_CLR_FD, 0); - perror("ioctl: LOOP_SET_STATUS"); - exit(1); - } - close(fd); - close(ffd); - return 0; -} - -int del_loop(const char *device) -{ - int fd; - - if ((fd = open(device, O_RDONLY)) < 0) { - perror(device); - exit(1); - } - if (ioctl(fd, LOOP_CLR_FD, 0) < 0) { - perror("ioctl: LOOP_CLR_FD"); - exit(1); - } - close(fd); - return(0); -} - - -static int losetup_usage_fn(void) -{ - fprintf(stderr, losetup_usage); - exit(1); -} - -int losetup_main(struct FileInfo * i, int argc, char * * argv) -{ - char *offset; - int delete,off,c; - int ro = 0; - - delete = off = 0; - offset = NULL; - while ((c = getopt(argc,argv,"do:")) != EOF) { - switch (c) { - case 'd': - delete = 1; - break; - case 'o': - offset = optarg; - break; - default: - losetup_usage_fn(); - } - } - if (argc == 1) losetup_usage_fn(); - if ((delete && (argc != optind+1 || offset)) || - (!delete && (argc < optind+1 || argc > optind+2))) - losetup_usage_fn(); - if (argc == optind+1) - if (delete) - del_loop(argv[optind]); - else - show_loop(argv[optind]); - else { - if (offset && sscanf(offset,"%d",&off) != 1) - losetup_usage_fn(); - set_loop(argv[optind],argv[optind+1],off,&ro); - } - return 0; -} diff --git a/miscutils/update.c b/miscutils/update.c index f3b7fc0c8..3a8cd37ee 100644 --- a/miscutils/update.c +++ b/miscutils/update.c @@ -1,10 +1,6 @@ #include "internal.h" #include -const char update_usage[] = "update\n" -"\n" -"\tFlush buffered data to the disk devices every 30 seconds.\n"; - #if defined(__GLIBC__) #include #else @@ -12,7 +8,7 @@ _syscall2(int, bdflush, int, func, int, data); #endif /* __GLIBC__ */ extern int -update_main(struct FileInfo * i, int argc, char * * argv) +update_main(int argc, char** argv) { /* * Update is actually two daemons, bdflush and update. diff --git a/update.c b/update.c index f3b7fc0c8..3a8cd37ee 100644 --- a/update.c +++ b/update.c @@ -1,10 +1,6 @@ #include "internal.h" #include -const char update_usage[] = "update\n" -"\n" -"\tFlush buffered data to the disk devices every 30 seconds.\n"; - #if defined(__GLIBC__) #include #else @@ -12,7 +8,7 @@ _syscall2(int, bdflush, int, func, int, data); #endif /* __GLIBC__ */ extern int -update_main(struct FileInfo * i, int argc, char * * argv) +update_main(int argc, char** argv) { /* * Update is actually two daemons, bdflush and update.