mirror of
https://github.com/sheumann/hush.git
synced 2025-02-23 02:29:20 +00:00
Stuf
This commit is contained in:
parent
ab746abfc0
commit
08b1034f4f
@ -1,3 +1,8 @@
|
|||||||
|
0.37
|
||||||
|
* Now 'rm -R' and 'rm -r' both work.
|
||||||
|
|
||||||
|
-Erik Andrsen
|
||||||
|
|
||||||
0.36
|
0.36
|
||||||
* fixed dd so it properly defaults to stdin and stdout when no
|
* fixed dd so it properly defaults to stdin and stdout when no
|
||||||
if= and of= are set (fix thanks to Eric Delaunay).
|
if= and of= are set (fix thanks to Eric Delaunay).
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysmacros.h>
|
||||||
|
|
||||||
|
|
||||||
static const char tar_usage[] =
|
static const char tar_usage[] =
|
||||||
@ -276,7 +277,7 @@ static void readTarFile (int fileCount, char **fileTable)
|
|||||||
* Open the tar file for reading.
|
* Open the tar file for reading.
|
||||||
*/
|
*/
|
||||||
if ((tarName == NULL) || !strcmp (tarName, "-")) {
|
if ((tarName == NULL) || !strcmp (tarName, "-")) {
|
||||||
tarFd = STDIN;
|
tarFd = fileno(stdin);
|
||||||
} else
|
} else
|
||||||
tarFd = open (tarName, O_RDONLY);
|
tarFd = open (tarName, O_RDONLY);
|
||||||
|
|
||||||
@ -552,7 +553,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
* Start the output file.
|
* Start the output file.
|
||||||
*/
|
*/
|
||||||
if (tostdoutFlag == TRUE)
|
if (tostdoutFlag == TRUE)
|
||||||
outFd = STDOUT;
|
outFd = fileno(stdout);
|
||||||
else {
|
else {
|
||||||
if ( S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) ) {
|
if ( S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) ) {
|
||||||
devFileFlag = TRUE;
|
devFileFlag = TRUE;
|
||||||
@ -650,7 +651,7 @@ static void writeTarFile (int fileCount, char **fileTable)
|
|||||||
*/
|
*/
|
||||||
if ((tarName == NULL) || !strcmp (tarName, "-")) {
|
if ((tarName == NULL) || !strcmp (tarName, "-")) {
|
||||||
tostdoutFlag = TRUE;
|
tostdoutFlag = TRUE;
|
||||||
tarFd = STDOUT;
|
tarFd = fileno(stdout);
|
||||||
} else
|
} else
|
||||||
tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
|
|
||||||
|
@ -162,8 +162,13 @@ extern int dd_main (int argc, char **argv)
|
|||||||
intotal = 0;
|
intotal = 0;
|
||||||
outTotal = 0;
|
outTotal = 0;
|
||||||
|
|
||||||
if (inFile == NULL)
|
if (inFile == NULL) {
|
||||||
inFd = STDIN;
|
struct stat statBuf;
|
||||||
|
inFd = fileno(stdin);
|
||||||
|
if (fstat(inFd, &statBuf) < 0)
|
||||||
|
exit( FALSE);
|
||||||
|
count = statBuf.st_size;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
inFd = open (inFile, 0);
|
inFd = open (inFile, 0);
|
||||||
|
|
||||||
@ -174,7 +179,7 @@ extern int dd_main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (outFile == NULL)
|
if (outFile == NULL)
|
||||||
outFd = STDOUT;
|
outFd = fileno(stdout);
|
||||||
else
|
else
|
||||||
outFd = creat (outFile, 0666);
|
outFd = creat (outFile, 0666);
|
||||||
|
|
||||||
@ -191,6 +196,8 @@ extern int dd_main (int argc, char **argv)
|
|||||||
if (inCc < 0) {
|
if (inCc < 0) {
|
||||||
perror (inFile);
|
perror (inFile);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
} else if (inCc == 0) {
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
intotal += inCc;
|
intotal += inCc;
|
||||||
cp = buf;
|
cp = buf;
|
||||||
@ -202,6 +209,8 @@ extern int dd_main (int argc, char **argv)
|
|||||||
if (outCc < 0) {
|
if (outCc < 0) {
|
||||||
perror (outFile);
|
perror (outFile);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
} else if (outCc == 0) {
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
inCc -= outCc;
|
inCc -= outCc;
|
||||||
|
@ -475,7 +475,7 @@ ls_main(int argc, char * * argv)
|
|||||||
|
|
||||||
/* choose a display format */
|
/* choose a display format */
|
||||||
if (display_fmt == FMT_AUTO)
|
if (display_fmt == FMT_AUTO)
|
||||||
display_fmt = isatty(STDOUT_FILENO) ? FMT_COLUMNS : FMT_SINGLE;
|
display_fmt = isatty(fileno(stdout)) ? FMT_COLUMNS : FMT_SINGLE;
|
||||||
if (argi < argc - 1)
|
if (argi < argc - 1)
|
||||||
opts |= DISP_DIRNAME; /* 2 or more items? label directories */
|
opts |= DISP_DIRNAME; /* 2 or more items? label directories */
|
||||||
#ifdef FEATURE_AUTOWIDTH
|
#ifdef FEATURE_AUTOWIDTH
|
||||||
|
@ -85,8 +85,9 @@ extern int mkdir_main(int argc, char **argv)
|
|||||||
fprintf(stderr, "%s: File exists\n", *argv);
|
fprintf(stderr, "%s: File exists\n", *argv);
|
||||||
exit( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
if (parentFlag == TRUE)
|
if (parentFlag == TRUE) {
|
||||||
createPath(*argv, mode);
|
createPath(*argv, mode);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (mkdir (*argv, mode) != 0) {
|
if (mkdir (*argv, mode) != 0) {
|
||||||
perror(*argv);
|
perror(*argv);
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
static const char* rm_usage = "rm [OPTION]... FILE...\n\n"
|
static const char* rm_usage = "rm [OPTION]... FILE...\n\n"
|
||||||
"Remove (unlink) the FILE(s).\n\n"
|
"Remove (unlink) the FILE(s).\n\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
"\t-f\tremove existing destinations, never prompt\n"
|
"\t-f\t\tremove existing destinations, never prompt\n"
|
||||||
"\t-r\tremove the contents of directories recursively\n";
|
"\t-r or -R\tremove the contents of directories recursively\n";
|
||||||
|
|
||||||
|
|
||||||
static int recursiveFlag = FALSE;
|
static int recursiveFlag = FALSE;
|
||||||
@ -72,6 +72,7 @@ extern int rm_main(int argc, char **argv)
|
|||||||
while (**argv == '-') {
|
while (**argv == '-') {
|
||||||
while (*++(*argv))
|
while (*++(*argv))
|
||||||
switch (**argv) {
|
switch (**argv) {
|
||||||
|
case 'R':
|
||||||
case 'r':
|
case 'r':
|
||||||
recursiveFlag = TRUE;
|
recursiveFlag = TRUE;
|
||||||
break;
|
break;
|
||||||
|
15
dd.c
15
dd.c
@ -162,8 +162,13 @@ extern int dd_main (int argc, char **argv)
|
|||||||
intotal = 0;
|
intotal = 0;
|
||||||
outTotal = 0;
|
outTotal = 0;
|
||||||
|
|
||||||
if (inFile == NULL)
|
if (inFile == NULL) {
|
||||||
inFd = STDIN;
|
struct stat statBuf;
|
||||||
|
inFd = fileno(stdin);
|
||||||
|
if (fstat(inFd, &statBuf) < 0)
|
||||||
|
exit( FALSE);
|
||||||
|
count = statBuf.st_size;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
inFd = open (inFile, 0);
|
inFd = open (inFile, 0);
|
||||||
|
|
||||||
@ -174,7 +179,7 @@ extern int dd_main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (outFile == NULL)
|
if (outFile == NULL)
|
||||||
outFd = STDOUT;
|
outFd = fileno(stdout);
|
||||||
else
|
else
|
||||||
outFd = creat (outFile, 0666);
|
outFd = creat (outFile, 0666);
|
||||||
|
|
||||||
@ -191,6 +196,8 @@ extern int dd_main (int argc, char **argv)
|
|||||||
if (inCc < 0) {
|
if (inCc < 0) {
|
||||||
perror (inFile);
|
perror (inFile);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
} else if (inCc == 0) {
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
intotal += inCc;
|
intotal += inCc;
|
||||||
cp = buf;
|
cp = buf;
|
||||||
@ -202,6 +209,8 @@ extern int dd_main (int argc, char **argv)
|
|||||||
if (outCc < 0) {
|
if (outCc < 0) {
|
||||||
perror (outFile);
|
perror (outFile);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
} else if (outCc == 0) {
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
inCc -= outCc;
|
inCc -= outCc;
|
||||||
|
35
init.c
35
init.c
@ -130,32 +130,40 @@ void message(int device, char *fmt, ...)
|
|||||||
void set_term( int fd)
|
void set_term( int fd)
|
||||||
{
|
{
|
||||||
struct termios tty;
|
struct termios tty;
|
||||||
|
#if 0
|
||||||
static const char control_characters[] = {
|
static const char control_characters[] = {
|
||||||
'\003', '\034', '\177', '\030', '\004', '\0',
|
'\003', '\034', '\177', '\030', '\004', '\0',
|
||||||
'\1', '\0', '\021', '\023', '\032', '\0', '\022',
|
'\1', '\0', '\021', '\023', '\032', '\0', '\022',
|
||||||
'\017', '\027', '\026', '\0'
|
'\017', '\027', '\026', '\0'
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
static const char control_characters[] = {
|
||||||
|
'\003', '\034', '\177', '\025', '\004', '\0',
|
||||||
|
'\1', '\0', '\021', '\023', '\032', '\0', '\022',
|
||||||
|
'\017', '\027', '\026', '\0'
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
tcgetattr(fd, &tty);
|
tcgetattr(fd, &tty);
|
||||||
|
|
||||||
/* Make it be sane */
|
/* set control chars */
|
||||||
tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD;
|
memcpy(tty.c_cc, control_characters, sizeof(control_characters));
|
||||||
tty.c_cflag |= HUPCL|CLOCAL;
|
|
||||||
|
|
||||||
/* input modes */
|
|
||||||
tty.c_iflag = IGNPAR|ICRNL|IXON|IXOFF|IXANY;
|
|
||||||
|
|
||||||
/* use line dicipline 0 */
|
/* use line dicipline 0 */
|
||||||
tty.c_line = 0;
|
tty.c_line = 0;
|
||||||
|
|
||||||
|
/* Make it be sane */
|
||||||
|
//tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD;
|
||||||
|
//tty.c_cflag |= HUPCL|CLOCAL;
|
||||||
|
|
||||||
|
/* input modes */
|
||||||
|
tty.c_iflag = ICRNL|IXON|IXOFF;
|
||||||
|
|
||||||
/* output modes */
|
/* output modes */
|
||||||
tty.c_oflag = OPOST|ONLCR;
|
tty.c_oflag = OPOST|ONLCR;
|
||||||
|
|
||||||
/* local modes */
|
/* local modes */
|
||||||
tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOPRT|ECHOKE|IEXTEN;
|
tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOKE|IEXTEN;
|
||||||
|
|
||||||
/* control chars */
|
|
||||||
memcpy(tty.c_cc, control_characters, sizeof(control_characters));
|
|
||||||
|
|
||||||
tcsetattr(fd, TCSANOW, &tty);
|
tcsetattr(fd, TCSANOW, &tty);
|
||||||
}
|
}
|
||||||
@ -210,7 +218,7 @@ static void console_init()
|
|||||||
|
|
||||||
console = the_console;
|
console = the_console;
|
||||||
/* 2.2 kernels: identify the real console backend and try to use it */
|
/* 2.2 kernels: identify the real console backend and try to use it */
|
||||||
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
|
if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
|
||||||
/* this is a serial console */
|
/* this is a serial console */
|
||||||
snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line );
|
snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line );
|
||||||
}
|
}
|
||||||
@ -245,6 +253,7 @@ static void console_init()
|
|||||||
/* check for serial console and disable logging to tty3 & running a
|
/* check for serial console and disable logging to tty3 & running a
|
||||||
* shell to tty2 */
|
* shell to tty2 */
|
||||||
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
|
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
|
||||||
|
message(LOG|CONSOLE, "serial console detected. Disabling 2nd virtual terminal.\r\n", console );
|
||||||
log = NULL;
|
log = NULL;
|
||||||
second_console = NULL;
|
second_console = NULL;
|
||||||
}
|
}
|
||||||
@ -362,7 +371,7 @@ static void shutdown_system(void)
|
|||||||
/* Allow Ctrl-Alt-Del to reboot system. */
|
/* Allow Ctrl-Alt-Del to reboot system. */
|
||||||
reboot(RB_ENABLE_CAD);
|
reboot(RB_ENABLE_CAD);
|
||||||
#endif
|
#endif
|
||||||
message(CONSOLE, "The system is going down NOW !!\r\n");
|
message(CONSOLE, "\r\nThe system is going down NOW !!\r\n");
|
||||||
sync();
|
sync();
|
||||||
/* Send signals to every process _except_ pid 1 */
|
/* Send signals to every process _except_ pid 1 */
|
||||||
message(CONSOLE, "Sending SIGHUP to all processes.\r\n");
|
message(CONSOLE, "Sending SIGHUP to all processes.\r\n");
|
||||||
@ -376,7 +385,9 @@ static void shutdown_system(void)
|
|||||||
kill(-1, SIGKILL);
|
kill(-1, SIGKILL);
|
||||||
#endif
|
#endif
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
message(CONSOLE, "Disabling swap.\r\n");
|
||||||
waitfor(run( swap_off_cmd, console, FALSE));
|
waitfor(run( swap_off_cmd, console, FALSE));
|
||||||
|
message(CONSOLE, "Unmounting filesystems.\r\n");
|
||||||
waitfor(run( umount_cmd, console, FALSE));
|
waitfor(run( umount_cmd, console, FALSE));
|
||||||
sync();
|
sync();
|
||||||
if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) {
|
if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) {
|
||||||
|
35
init/init.c
35
init/init.c
@ -130,32 +130,40 @@ void message(int device, char *fmt, ...)
|
|||||||
void set_term( int fd)
|
void set_term( int fd)
|
||||||
{
|
{
|
||||||
struct termios tty;
|
struct termios tty;
|
||||||
|
#if 0
|
||||||
static const char control_characters[] = {
|
static const char control_characters[] = {
|
||||||
'\003', '\034', '\177', '\030', '\004', '\0',
|
'\003', '\034', '\177', '\030', '\004', '\0',
|
||||||
'\1', '\0', '\021', '\023', '\032', '\0', '\022',
|
'\1', '\0', '\021', '\023', '\032', '\0', '\022',
|
||||||
'\017', '\027', '\026', '\0'
|
'\017', '\027', '\026', '\0'
|
||||||
};
|
};
|
||||||
|
#else
|
||||||
|
static const char control_characters[] = {
|
||||||
|
'\003', '\034', '\177', '\025', '\004', '\0',
|
||||||
|
'\1', '\0', '\021', '\023', '\032', '\0', '\022',
|
||||||
|
'\017', '\027', '\026', '\0'
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
tcgetattr(fd, &tty);
|
tcgetattr(fd, &tty);
|
||||||
|
|
||||||
/* Make it be sane */
|
/* set control chars */
|
||||||
tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD;
|
memcpy(tty.c_cc, control_characters, sizeof(control_characters));
|
||||||
tty.c_cflag |= HUPCL|CLOCAL;
|
|
||||||
|
|
||||||
/* input modes */
|
|
||||||
tty.c_iflag = IGNPAR|ICRNL|IXON|IXOFF|IXANY;
|
|
||||||
|
|
||||||
/* use line dicipline 0 */
|
/* use line dicipline 0 */
|
||||||
tty.c_line = 0;
|
tty.c_line = 0;
|
||||||
|
|
||||||
|
/* Make it be sane */
|
||||||
|
//tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD;
|
||||||
|
//tty.c_cflag |= HUPCL|CLOCAL;
|
||||||
|
|
||||||
|
/* input modes */
|
||||||
|
tty.c_iflag = ICRNL|IXON|IXOFF;
|
||||||
|
|
||||||
/* output modes */
|
/* output modes */
|
||||||
tty.c_oflag = OPOST|ONLCR;
|
tty.c_oflag = OPOST|ONLCR;
|
||||||
|
|
||||||
/* local modes */
|
/* local modes */
|
||||||
tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOPRT|ECHOKE|IEXTEN;
|
tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOKE|IEXTEN;
|
||||||
|
|
||||||
/* control chars */
|
|
||||||
memcpy(tty.c_cc, control_characters, sizeof(control_characters));
|
|
||||||
|
|
||||||
tcsetattr(fd, TCSANOW, &tty);
|
tcsetattr(fd, TCSANOW, &tty);
|
||||||
}
|
}
|
||||||
@ -210,7 +218,7 @@ static void console_init()
|
|||||||
|
|
||||||
console = the_console;
|
console = the_console;
|
||||||
/* 2.2 kernels: identify the real console backend and try to use it */
|
/* 2.2 kernels: identify the real console backend and try to use it */
|
||||||
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
|
if (ioctl(0, TIOCGSERIAL, &sr) == 0) {
|
||||||
/* this is a serial console */
|
/* this is a serial console */
|
||||||
snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line );
|
snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line );
|
||||||
}
|
}
|
||||||
@ -245,6 +253,7 @@ static void console_init()
|
|||||||
/* check for serial console and disable logging to tty3 & running a
|
/* check for serial console and disable logging to tty3 & running a
|
||||||
* shell to tty2 */
|
* shell to tty2 */
|
||||||
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
|
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
|
||||||
|
message(LOG|CONSOLE, "serial console detected. Disabling 2nd virtual terminal.\r\n", console );
|
||||||
log = NULL;
|
log = NULL;
|
||||||
second_console = NULL;
|
second_console = NULL;
|
||||||
}
|
}
|
||||||
@ -362,7 +371,7 @@ static void shutdown_system(void)
|
|||||||
/* Allow Ctrl-Alt-Del to reboot system. */
|
/* Allow Ctrl-Alt-Del to reboot system. */
|
||||||
reboot(RB_ENABLE_CAD);
|
reboot(RB_ENABLE_CAD);
|
||||||
#endif
|
#endif
|
||||||
message(CONSOLE, "The system is going down NOW !!\r\n");
|
message(CONSOLE, "\r\nThe system is going down NOW !!\r\n");
|
||||||
sync();
|
sync();
|
||||||
/* Send signals to every process _except_ pid 1 */
|
/* Send signals to every process _except_ pid 1 */
|
||||||
message(CONSOLE, "Sending SIGHUP to all processes.\r\n");
|
message(CONSOLE, "Sending SIGHUP to all processes.\r\n");
|
||||||
@ -376,7 +385,9 @@ static void shutdown_system(void)
|
|||||||
kill(-1, SIGKILL);
|
kill(-1, SIGKILL);
|
||||||
#endif
|
#endif
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
message(CONSOLE, "Disabling swap.\r\n");
|
||||||
waitfor(run( swap_off_cmd, console, FALSE));
|
waitfor(run( swap_off_cmd, console, FALSE));
|
||||||
|
message(CONSOLE, "Unmounting filesystems.\r\n");
|
||||||
waitfor(run( umount_cmd, console, FALSE));
|
waitfor(run( umount_cmd, console, FALSE));
|
||||||
sync();
|
sync();
|
||||||
if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) {
|
if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) {
|
||||||
|
@ -33,8 +33,6 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Some useful definitions */
|
/* Some useful definitions */
|
||||||
#define STDIN 0
|
|
||||||
#define STDOUT 1
|
|
||||||
#define FALSE ((int) 1)
|
#define FALSE ((int) 1)
|
||||||
#define TRUE ((int) 0)
|
#define TRUE ((int) 0)
|
||||||
|
|
||||||
|
2
ls.c
2
ls.c
@ -475,7 +475,7 @@ ls_main(int argc, char * * argv)
|
|||||||
|
|
||||||
/* choose a display format */
|
/* choose a display format */
|
||||||
if (display_fmt == FMT_AUTO)
|
if (display_fmt == FMT_AUTO)
|
||||||
display_fmt = isatty(STDOUT_FILENO) ? FMT_COLUMNS : FMT_SINGLE;
|
display_fmt = isatty(fileno(stdout)) ? FMT_COLUMNS : FMT_SINGLE;
|
||||||
if (argi < argc - 1)
|
if (argi < argc - 1)
|
||||||
opts |= DISP_DIRNAME; /* 2 or more items? label directories */
|
opts |= DISP_DIRNAME; /* 2 or more items? label directories */
|
||||||
#ifdef FEATURE_AUTOWIDTH
|
#ifdef FEATURE_AUTOWIDTH
|
||||||
|
3
mkdir.c
3
mkdir.c
@ -85,8 +85,9 @@ extern int mkdir_main(int argc, char **argv)
|
|||||||
fprintf(stderr, "%s: File exists\n", *argv);
|
fprintf(stderr, "%s: File exists\n", *argv);
|
||||||
exit( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
if (parentFlag == TRUE)
|
if (parentFlag == TRUE) {
|
||||||
createPath(*argv, mode);
|
createPath(*argv, mode);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (mkdir (*argv, mode) != 0) {
|
if (mkdir (*argv, mode) != 0) {
|
||||||
perror(*argv);
|
perror(*argv);
|
||||||
|
2
more.c
2
more.c
@ -122,7 +122,7 @@ extern int more_main(int argc, char **argv)
|
|||||||
stty(fileno(cin), &new_settings);
|
stty(fileno(cin), &new_settings);
|
||||||
|
|
||||||
#ifdef BB_FEATURE_AUTOWIDTH
|
#ifdef BB_FEATURE_AUTOWIDTH
|
||||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &win);
|
ioctl(fileno(stdout), TIOCGWINSZ, &win);
|
||||||
if (win.ws_row > 4)
|
if (win.ws_row > 4)
|
||||||
terminal_height = win.ws_row - 2;
|
terminal_height = win.ws_row - 2;
|
||||||
if (win.ws_col > 0)
|
if (win.ws_col > 0)
|
||||||
|
5
rm.c
5
rm.c
@ -31,8 +31,8 @@
|
|||||||
static const char* rm_usage = "rm [OPTION]... FILE...\n\n"
|
static const char* rm_usage = "rm [OPTION]... FILE...\n\n"
|
||||||
"Remove (unlink) the FILE(s).\n\n"
|
"Remove (unlink) the FILE(s).\n\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
"\t-f\tremove existing destinations, never prompt\n"
|
"\t-f\t\tremove existing destinations, never prompt\n"
|
||||||
"\t-r\tremove the contents of directories recursively\n";
|
"\t-r or -R\tremove the contents of directories recursively\n";
|
||||||
|
|
||||||
|
|
||||||
static int recursiveFlag = FALSE;
|
static int recursiveFlag = FALSE;
|
||||||
@ -72,6 +72,7 @@ extern int rm_main(int argc, char **argv)
|
|||||||
while (**argv == '-') {
|
while (**argv == '-') {
|
||||||
while (*++(*argv))
|
while (*++(*argv))
|
||||||
switch (**argv) {
|
switch (**argv) {
|
||||||
|
case 'R':
|
||||||
case 'r':
|
case 'r':
|
||||||
recursiveFlag = TRUE;
|
recursiveFlag = TRUE;
|
||||||
break;
|
break;
|
||||||
|
7
tar.c
7
tar.c
@ -38,6 +38,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysmacros.h>
|
||||||
|
|
||||||
|
|
||||||
static const char tar_usage[] =
|
static const char tar_usage[] =
|
||||||
@ -276,7 +277,7 @@ static void readTarFile (int fileCount, char **fileTable)
|
|||||||
* Open the tar file for reading.
|
* Open the tar file for reading.
|
||||||
*/
|
*/
|
||||||
if ((tarName == NULL) || !strcmp (tarName, "-")) {
|
if ((tarName == NULL) || !strcmp (tarName, "-")) {
|
||||||
tarFd = STDIN;
|
tarFd = fileno(stdin);
|
||||||
} else
|
} else
|
||||||
tarFd = open (tarName, O_RDONLY);
|
tarFd = open (tarName, O_RDONLY);
|
||||||
|
|
||||||
@ -552,7 +553,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
* Start the output file.
|
* Start the output file.
|
||||||
*/
|
*/
|
||||||
if (tostdoutFlag == TRUE)
|
if (tostdoutFlag == TRUE)
|
||||||
outFd = STDOUT;
|
outFd = fileno(stdout);
|
||||||
else {
|
else {
|
||||||
if ( S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) ) {
|
if ( S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) ) {
|
||||||
devFileFlag = TRUE;
|
devFileFlag = TRUE;
|
||||||
@ -650,7 +651,7 @@ static void writeTarFile (int fileCount, char **fileTable)
|
|||||||
*/
|
*/
|
||||||
if ((tarName == NULL) || !strcmp (tarName, "-")) {
|
if ((tarName == NULL) || !strcmp (tarName, "-")) {
|
||||||
tostdoutFlag = TRUE;
|
tostdoutFlag = TRUE;
|
||||||
tarFd = STDOUT;
|
tarFd = fileno(stdout);
|
||||||
} else
|
} else
|
||||||
tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ extern int more_main(int argc, char **argv)
|
|||||||
stty(fileno(cin), &new_settings);
|
stty(fileno(cin), &new_settings);
|
||||||
|
|
||||||
#ifdef BB_FEATURE_AUTOWIDTH
|
#ifdef BB_FEATURE_AUTOWIDTH
|
||||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &win);
|
ioctl(fileno(stdout), TIOCGWINSZ, &win);
|
||||||
if (win.ws_row > 4)
|
if (win.ws_row > 4)
|
||||||
terminal_height = win.ws_row - 2;
|
terminal_height = win.ws_row - 2;
|
||||||
if (win.ws_col > 0)
|
if (win.ws_col > 0)
|
||||||
|
@ -482,6 +482,10 @@ extern void createPath (const char *name, int mode)
|
|||||||
char buf[NAME_MAX];
|
char buf[NAME_MAX];
|
||||||
|
|
||||||
strcpy (buf, name);
|
strcpy (buf, name);
|
||||||
|
if (buf[strlen(buf)]!='/') {
|
||||||
|
buf[strlen(buf)] = '/';
|
||||||
|
buf[strlen(buf)+1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
cp = strchr (buf, '/');
|
cp = strchr (buf, '/');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user