Some formatting updates (ran the code through indent)

-Erik
This commit is contained in:
Erik Andersen
2000-02-08 19:58:47 +00:00
parent c0bf817bbc
commit e49d5ecbbe
163 changed files with 27109 additions and 26607 deletions

View File

@@ -1,3 +1,4 @@
/* vi: set sw=4 ts=4: */
/*
* public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com>
*
@@ -15,37 +16,38 @@
#include <utmp.h>
static const char dutmp_usage[] = "dutmp\n"
"\n"
"\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
"\tdutmp /var/run/utmp\n";
"\n"
extern int dutmp_main (int argc, char **argv)
"\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
"\tdutmp /var/run/utmp\n";
extern int dutmp_main(int argc, char **argv)
{
FILE *f = stdin;
struct utmp ut;
FILE *f = stdin;
struct utmp ut;
if ((argc < 2) || (**(argv + 1) == '-')) {
usage( dutmp_usage);
}
if ((argc < 2) || (**(argv + 1) == '-')) {
usage(dutmp_usage);
}
if ( **(++argv) == 0 ) {
f = fopen (*(++argv), "r");
if (f < 0 ) {
perror (*argv);
exit (FALSE);
}
}
if (**(++argv) == 0) {
f = fopen(*(++argv), "r");
if (f < 0) {
perror(*argv);
exit(FALSE);
}
}
while (fread (&ut, 1, sizeof (struct utmp), f)) {
// printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n",
printf ("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
ut.ut_type, ut.ut_pid, ut.ut_line,
ut.ut_id, ut.ut_user, ut.ut_host,
ut.ut_exit.e_termination, ut.ut_exit.e_exit,
ut.ut_session,
ut.ut_tv.tv_sec, ut.ut_tv.tv_usec, ut.ut_addr);
}
while (fread(&ut, 1, sizeof(struct utmp), f)) {
// printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n",
printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
ut.ut_type, ut.ut_pid, ut.ut_line,
ut.ut_id, ut.ut_user, ut.ut_host,
ut.ut_exit.e_termination, ut.ut_exit.e_exit,
ut.ut_session,
ut.ut_tv.tv_sec, ut.ut_tv.tv_usec, ut.ut_addr);
}
exit (TRUE);
exit(TRUE);
}

View File

@@ -1,3 +1,4 @@
/* vi: set sw=4 ts=4: */
/*
* public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com>
*
@@ -5,7 +6,7 @@
* Make ranges of device files quickly.
* known bugs: can't deal with alpha ranges
*/
#include "internal.h"
#include <stdio.h>
#include <stdlib.h>
@@ -15,60 +16,64 @@
#include <sys/types.h>
#include <sys/stat.h>
static const char makedevs_usage[] =
"makedevs 0.01 -- Create an entire range of device files\n\n"
"\tmakedevs /dev/ttyS c 4 64 0 63 (ttyS0-ttyS63)\n"
"\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n";
static const char makedevs_usage[] =
"makedevs 0.01 -- Create an entire range of device files\n\n"
"\tmakedevs /dev/ttyS c 4 64 0 63 (ttyS0-ttyS63)\n"
int
makedevs_main(int argc, char * * argv)
"\tmakedevs /dev/hda b 3 0 0 8 s (hda,hda1-hda8)\n";
int makedevs_main(int argc, char **argv)
{
const char *basedev = argv[1];
const char *type = argv[2];
int major = atoi(argv[3]);
int Sminor = atoi(argv[4]);
int S = atoi(argv[5]);
int E = atoi(argv[6]);
int sbase = argc == 8 ? 1 : 0;
const char *basedev = argv[1];
const char *type = argv[2];
int major = atoi(argv[3]);
int Sminor = atoi(argv[4]);
int S = atoi(argv[5]);
int E = atoi(argv[6]);
int sbase = argc == 8 ? 1 : 0;
mode_t mode = 0;
dev_t dev = 0;
char devname[255];
char buf[255];
mode_t mode = 0;
dev_t dev = 0;
char devname[255];
char buf[255];
switch (type[0]) {
case 'c':
mode = S_IFCHR; break;
case 'b':
mode = S_IFBLK; break;
case 'f':
mode = S_IFIFO; break;
default:
usage( makedevs_usage);
}
mode |= 0660;
case 'c':
mode = S_IFCHR;
break;
case 'b':
mode = S_IFBLK;
break;
case 'f':
mode = S_IFIFO;
break;
default:
usage(makedevs_usage);
}
mode |= 0660;
while (S <= E) {
while ( S <= E ) {
if (type[0] != 'f')
dev = (major << 8) | Sminor;
strcpy(devname, basedev);
if (sbase == 0) {
sprintf(buf, "%d", S);
sprintf(buf, "%d", S);
strcat(devname, buf);
} else {
sbase = 0;
}
if (mknod (devname, mode, dev))
printf("Failed to create: %s\n", devname);
S++; Sminor++;
if (mknod(devname, mode, dev))
printf("Failed to create: %s\n", devname);
S++;
Sminor++;
}
return 0;
return 0;
}
/*

View File

@@ -1,97 +1,97 @@
/* vi: set sw=4 ts=4: */
#include "internal.h"
#include <stdio.h>
#include <sys/mtio.h>
#include <sys/fcntl.h>
static const char mt_usage[] = "mt [-f device] opcode value\n";
static const char mt_usage[] = "mt [-f device] opcode value\n";
struct mt_opcodes {
char * name;
short value;
char *name;
short value;
};
/* missing: eod/seod, stoptions, stwrthreshold, densities */
static const struct mt_opcodes opcodes[] = {
{ "bsf", MTBSF },
{ "bsfm", MTBSFM },
{ "bsr", MTBSR },
{ "bss", MTBSS },
{ "datacompression", MTCOMPRESSION },
{ "eom", MTEOM },
{ "erase", MTERASE },
{ "fsf", MTFSF },
{ "fsfm", MTFSFM },
{ "fsr", MTFSR },
{ "fss", MTFSS },
{ "load", MTLOAD },
{ "lock", MTLOCK },
{ "mkpart", MTMKPART },
{ "nop", MTNOP },
{ "offline",MTOFFL },
{ "rewoffline",MTOFFL },
{ "ras1", MTRAS1 },
{ "ras2", MTRAS2 },
{ "ras3", MTRAS3 },
{ "reset", MTRESET },
{ "retension", MTRETEN },
{ "rew", MTREW },
{ "seek", MTSEEK },
{ "setblk", MTSETBLK },
{ "setdensity", MTSETDENSITY },
{ "drvbuffer", MTSETDRVBUFFER },
{ "setpart", MTSETPART },
{ "tell", MTTELL },
{ "wset", MTWSM },
{ "unload", MTUNLOAD },
{ "unlock", MTUNLOCK },
{ "eof", MTWEOF },
{ "weof", MTWEOF },
{ 0, 0 }
static const struct mt_opcodes opcodes[] = {
{"bsf", MTBSF},
{"bsfm", MTBSFM},
{"bsr", MTBSR},
{"bss", MTBSS},
{"datacompression", MTCOMPRESSION},
{"eom", MTEOM},
{"erase", MTERASE},
{"fsf", MTFSF},
{"fsfm", MTFSFM},
{"fsr", MTFSR},
{"fss", MTFSS},
{"load", MTLOAD},
{"lock", MTLOCK},
{"mkpart", MTMKPART},
{"nop", MTNOP},
{"offline", MTOFFL},
{"rewoffline", MTOFFL},
{"ras1", MTRAS1},
{"ras2", MTRAS2},
{"ras3", MTRAS3},
{"reset", MTRESET},
{"retension", MTRETEN},
{"rew", MTREW},
{"seek", MTSEEK},
{"setblk", MTSETBLK},
{"setdensity", MTSETDENSITY},
{"drvbuffer", MTSETDRVBUFFER},
{"setpart", MTSETPART},
{"tell", MTTELL},
{"wset", MTWSM},
{"unload", MTUNLOAD},
{"unlock", MTUNLOCK},
{"eof", MTWEOF},
{"weof", MTWEOF},
{0, 0}
};
extern int
mt_main(int argc, char** argv)
extern int mt_main(int argc, char **argv)
{
const char * file = "/dev/tape";
const struct mt_opcodes * code = opcodes;
struct mtop op;
int fd;
if ( strcmp(argv[1], "-f") == 0 ) {
if ( argc < 4 ) {
usage (mt_usage);
const char *file = "/dev/tape";
const struct mt_opcodes *code = opcodes;
struct mtop op;
int fd;
if (strcmp(argv[1], "-f") == 0) {
if (argc < 4) {
usage(mt_usage);
}
file = argv[2];
argv += 2;
argc -= 2;
}
while ( code->name != 0 ) {
if ( strcmp(code->name, argv[1]) == 0 )
while (code->name != 0) {
if (strcmp(code->name, argv[1]) == 0)
break;
code++;
}
if ( code->name == 0 ) {
if (code->name == 0) {
fprintf(stderr, "mt: unrecognized opcode %s.\n", argv[1]);
return( FALSE);
return (FALSE);
}
op.mt_op = code->value;
if ( argc >= 3 )
op.mt_count = atoi(argv[2]);
if (argc >= 3)
op.mt_count = atoi(argv[2]);
else
op.mt_count = 1; /* One, not zero, right? */
op.mt_count = 1; /* One, not zero, right? */
if ( (fd = open(file, O_RDONLY, 0)) < 0 ) {
if ((fd = open(file, O_RDONLY, 0)) < 0) {
perror(file);
return( FALSE);
return (FALSE);
}
if ( ioctl(fd, MTIOCTOP, &op) != 0 ) {
if (ioctl(fd, MTIOCTOP, &op) != 0) {
perror(file);
return( FALSE);
return (FALSE);
}
return( TRUE);
return (TRUE);
}

View File

@@ -1,3 +1,4 @@
/* vi: set sw=4 ts=4: */
/*
* Mini update implementation for busybox
*
@@ -27,20 +28,19 @@
#include <sys/kdaemon.h>
#else
_syscall2(int, bdflush, int, func, int, data);
#endif /* __GLIBC__ */
#endif /* __GLIBC__ */
extern int
update_main(int argc, char** argv)
extern int update_main(int argc, char **argv)
{
/*
* Update is actually two daemons, bdflush and update.
*/
int pid;
int pid;
pid = fork();
if ( pid < 0 )
if (pid < 0)
return pid;
else if ( pid == 0 ) {
else if (pid == 0) {
/*
* This is no longer necessary since 1.3.5x, but it will harmlessly
* exit if that is the case.
@@ -52,11 +52,11 @@ update_main(int argc, char** argv)
_exit(0);
}
pid = fork();
if ( pid < 0 )
if (pid < 0)
return pid;
else if ( pid == 0 ) {
else if (pid == 0) {
argv[0] = "update";
for ( ; ; ) {
for (;;) {
sync();
sleep(30);
}