Fixed cp -[aR] and some other stuf.
This commit is contained in:
parent
2c1030177e
commit
3c163822d8
2
Makefile
2
Makefile
@ -4,7 +4,7 @@ BUILDTIME=$(shell date "+%Y%m%d-%H%M")
|
|||||||
|
|
||||||
# Comment out the following to make a debuggable build
|
# Comment out the following to make a debuggable build
|
||||||
# Leave this off for production use.
|
# Leave this off for production use.
|
||||||
DODEBUG=true
|
#DODEBUG=true
|
||||||
|
|
||||||
#This will choke on a non-debian system
|
#This will choke on a non-debian system
|
||||||
ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
|
ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
|
||||||
|
@ -40,13 +40,14 @@ static int followLinks = FALSE;
|
|||||||
static int preserveFlag = FALSE;
|
static int preserveFlag = FALSE;
|
||||||
static const char *srcName;
|
static const char *srcName;
|
||||||
static const char *destName;
|
static const char *destName;
|
||||||
|
static const char *skipName;
|
||||||
|
|
||||||
|
|
||||||
static int fileAction(const char *fileName)
|
static int fileAction(const char *fileName)
|
||||||
{
|
{
|
||||||
char newdestName[NAME_MAX];
|
char newdestName[NAME_MAX];
|
||||||
strcpy(newdestName, destName);
|
strcpy(newdestName, destName);
|
||||||
strcat(newdestName, fileName+(strlen(srcName)));
|
strcat(newdestName, strstr(fileName, skipName));
|
||||||
return (copyFile(fileName, newdestName, preserveFlag, followLinks));
|
return (copyFile(fileName, newdestName, preserveFlag, followLinks));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,10 +99,13 @@ extern int cp_main(int argc, char **argv)
|
|||||||
exit (FALSE);
|
exit (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (argc-- >= 2) {
|
while (argc-- > 1) {
|
||||||
srcName = *(argv++);
|
srcName = *(argv++);
|
||||||
exit( recursiveAction(srcName, recursiveFlag, followLinks,
|
skipName = strrchr(srcName, '/');
|
||||||
fileAction, fileAction));
|
if (skipName) skipName++;
|
||||||
|
if (recursiveAction(srcName, recursiveFlag, followLinks,
|
||||||
|
fileAction, fileAction) == FALSE)
|
||||||
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
exit( TRUE);
|
exit( TRUE);
|
||||||
}
|
}
|
||||||
|
@ -179,15 +179,13 @@ int ls_main(int argc, char **argv)
|
|||||||
#define FEATURE_AUTOWIDTH /* calculate terminal & column widths */
|
#define FEATURE_AUTOWIDTH /* calculate terminal & column widths */
|
||||||
#define FEATURE_FILETYPECHAR /* enable -p and -F */
|
#define FEATURE_FILETYPECHAR /* enable -p and -F */
|
||||||
|
|
||||||
#undef OP_BUF_SIZE 1024 /* leave undefined for unbuffered output */
|
|
||||||
|
|
||||||
#define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */
|
#define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */
|
||||||
#define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */
|
#define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */
|
||||||
#define COLUMN_GAP 2 /* includes the file type char, if present */
|
#define COLUMN_GAP 2 /* includes the file type char, if present */
|
||||||
|
#define HAS_REWINDDIR
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
#define HAS_REWINDDIR
|
|
||||||
|
|
||||||
#if 1 /* FIXME libc 6 */
|
#if 1 /* FIXME libc 6 */
|
||||||
# include <linux/types.h>
|
# include <linux/types.h>
|
||||||
|
12
cp.c
12
cp.c
@ -40,13 +40,14 @@ static int followLinks = FALSE;
|
|||||||
static int preserveFlag = FALSE;
|
static int preserveFlag = FALSE;
|
||||||
static const char *srcName;
|
static const char *srcName;
|
||||||
static const char *destName;
|
static const char *destName;
|
||||||
|
static const char *skipName;
|
||||||
|
|
||||||
|
|
||||||
static int fileAction(const char *fileName)
|
static int fileAction(const char *fileName)
|
||||||
{
|
{
|
||||||
char newdestName[NAME_MAX];
|
char newdestName[NAME_MAX];
|
||||||
strcpy(newdestName, destName);
|
strcpy(newdestName, destName);
|
||||||
strcat(newdestName, fileName+(strlen(srcName)));
|
strcat(newdestName, strstr(fileName, skipName));
|
||||||
return (copyFile(fileName, newdestName, preserveFlag, followLinks));
|
return (copyFile(fileName, newdestName, preserveFlag, followLinks));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,10 +99,13 @@ extern int cp_main(int argc, char **argv)
|
|||||||
exit (FALSE);
|
exit (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (argc-- >= 2) {
|
while (argc-- > 1) {
|
||||||
srcName = *(argv++);
|
srcName = *(argv++);
|
||||||
exit( recursiveAction(srcName, recursiveFlag, followLinks,
|
skipName = strrchr(srcName, '/');
|
||||||
fileAction, fileAction));
|
if (skipName) skipName++;
|
||||||
|
if (recursiveAction(srcName, recursiveFlag, followLinks,
|
||||||
|
fileAction, fileAction) == FALSE)
|
||||||
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
exit( TRUE);
|
exit( TRUE);
|
||||||
}
|
}
|
||||||
|
128
init.c
128
init.c
@ -66,11 +66,8 @@ waitfor(int pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
run(
|
run(const char* program, const char* const* arguments,
|
||||||
const char * program
|
const char* terminal, int get_enter)
|
||||||
,const char * const * arguments
|
|
||||||
,const char * terminal
|
|
||||||
,int get_enter)
|
|
||||||
{
|
{
|
||||||
static const char control_characters[] = {
|
static const char control_characters[] = {
|
||||||
'\003',
|
'\003',
|
||||||
@ -137,7 +134,8 @@ run(
|
|||||||
* before the user wants it. This is critical if swap is not
|
* before the user wants it. This is critical if swap is not
|
||||||
* enabled and the system has low memory. Generally this will
|
* enabled and the system has low memory. Generally this will
|
||||||
* be run on the second virtual console, and the first will
|
* be run on the second virtual console, and the first will
|
||||||
* be allowed to start a shell or the installation system.
|
* be allowed to start a shell or whatever an init script
|
||||||
|
* specifies.
|
||||||
*/
|
*/
|
||||||
char c;
|
char c;
|
||||||
write(1, press_enter, sizeof(press_enter) - 1);
|
write(1, press_enter, sizeof(press_enter) - 1);
|
||||||
@ -246,26 +244,49 @@ exit_signal(int sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
configure_terminals( int serial_cons );
|
configure_terminals( int serial_cons )
|
||||||
|
{
|
||||||
|
//struct stat statbuf;
|
||||||
|
char *tty;
|
||||||
|
|
||||||
|
switch (serial_cons) {
|
||||||
|
case 1:
|
||||||
|
strcpy( console, "/dev/ttyS0" );
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
strcpy( console, "/dev/ttyS1" );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
tty = ttyname(0);
|
||||||
|
if (tty) {
|
||||||
|
strcpy( console, tty );
|
||||||
|
if (!strncmp( tty, "/dev/ttyS", 9 ))
|
||||||
|
serial_cons=1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* falls back to /dev/tty1 if an error occurs */
|
||||||
|
strcpy( console, default_console );
|
||||||
|
}
|
||||||
|
if (!first_terminal)
|
||||||
|
first_terminal = console;
|
||||||
|
if (serial_cons && !strncmp(term_ptr,"TERM=linux",10))
|
||||||
|
term_ptr = "TERM=vt100";
|
||||||
|
}
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
init_main(int argc, char * * argv)
|
init_main(int argc, char * * argv)
|
||||||
{
|
{
|
||||||
static const char * const rc = "etc/rc";
|
static const char* const rc = "etc/rc";
|
||||||
const char * arguments[100];
|
const char * arguments[100];
|
||||||
int run_rc = 1;
|
int run_rc = 1;
|
||||||
int j;
|
int j;
|
||||||
int pid1 = 0;
|
int pid1 = 0;
|
||||||
int pid2 = 0;
|
int pid2 = 0;
|
||||||
int create_swap= -1;
|
int create_swap= -1;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
#ifndef INCLUDE_DINSTALL
|
const char * tty_commands[2] = { "bin/sh", "bin/sh"};
|
||||||
const char * tty_commands[2] = { "bin/sh", "bin/sh"};
|
char swap[20];
|
||||||
#else
|
int serial_console = 0;
|
||||||
const char * tty_commands[2] = { "sbin/dinstall", "bin/sh"};
|
|
||||||
#endif
|
|
||||||
char swap[20];
|
|
||||||
int serial_console = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If I am started as /linuxrc instead of /sbin/init, I don't have the
|
* If I am started as /linuxrc instead of /sbin/init, I don't have the
|
||||||
@ -330,17 +351,13 @@ init_main(int argc, char * * argv)
|
|||||||
|
|
||||||
set_free_pages();
|
set_free_pages();
|
||||||
|
|
||||||
if (mem_total() < 3500) { /* not enough memory for standard install */
|
/* not enough memory to do anything useful*/
|
||||||
|
if (mem_total() < 2000) {
|
||||||
int retval;
|
int retval;
|
||||||
retval= stat("/etc/swappartition",&statbuf);
|
retval= stat("/etc/swappartition",&statbuf);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
printf("
|
printf("You do not have enough RAM, sorry.\n");
|
||||||
You do not have enough RAM, hence you must boot using the Boot Disk
|
while (1) { sleep(1);}
|
||||||
for Low Memory systems.
|
|
||||||
|
|
||||||
Read the instructions in the install.html file.
|
|
||||||
");
|
|
||||||
while (1) {;}
|
|
||||||
} else { /* everything OK */
|
} else { /* everything OK */
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
@ -371,8 +388,13 @@ Read the instructions in the install.html file.
|
|||||||
arguments[j] = 0;
|
arguments[j] = 0;
|
||||||
|
|
||||||
if ( run_rc ) {
|
if ( run_rc ) {
|
||||||
printf("running %s\n",rc);
|
printf("running %s with args \"",rc);
|
||||||
|
for ( j = 0; j < argc; j++ ) {
|
||||||
|
printf("%s ", arguments[j]);
|
||||||
|
}
|
||||||
|
printf("\" on console %s\n", console);
|
||||||
waitfor(run(rc, arguments, console, 0));
|
waitfor(run(rc, arguments, console, 0));
|
||||||
|
printf("done.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 == create_swap) {
|
if ( 0 == create_swap) {
|
||||||
@ -392,10 +414,21 @@ Read the instructions in the install.html file.
|
|||||||
/*
|
/*
|
||||||
arguments[0] = tty_commands[0];
|
arguments[0] = tty_commands[0];
|
||||||
*/
|
*/
|
||||||
pid1 = run(tty_commands[0], arguments, first_terminal, 0);
|
printf("running %s with args \"",tty_commands[0]);
|
||||||
|
for ( j = 0; j < argc; j++ ) {
|
||||||
|
printf("%s ", arguments[j]);
|
||||||
|
}
|
||||||
|
printf("\" on console %s\n", first_terminal);
|
||||||
|
pid1 = run(tty_commands[0], arguments, first_terminal, 1);
|
||||||
}
|
}
|
||||||
if ( pid2 == 0 && tty_commands[1] )
|
if ( pid2 == 0 && tty_commands[1] ) {
|
||||||
|
printf("running %s with args \"",tty_commands[0]);
|
||||||
|
for ( j = 0; j < argc; j++ ) {
|
||||||
|
printf("%s ", arguments[j]);
|
||||||
|
}
|
||||||
|
printf("\" on console %s\n", first_terminal);
|
||||||
pid2 = run(tty_commands[1], arguments, second_terminal, 1);
|
pid2 = run(tty_commands[1], arguments, second_terminal, 1);
|
||||||
|
}
|
||||||
wpid = wait(&status);
|
wpid = wait(&status);
|
||||||
if ( wpid > 0 ) {
|
if ( wpid > 0 ) {
|
||||||
/* DEBUGGING */
|
/* DEBUGGING */
|
||||||
@ -409,32 +442,3 @@ Read the instructions in the install.html file.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
configure_terminals( int serial_cons )
|
|
||||||
{
|
|
||||||
//struct stat statbuf;
|
|
||||||
char *tty;
|
|
||||||
|
|
||||||
switch (serial_cons) {
|
|
||||||
case 1:
|
|
||||||
strcpy( console, "/dev/ttyS0" );
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
strcpy( console, "/dev/ttyS1" );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
tty = ttyname(0);
|
|
||||||
if (tty) {
|
|
||||||
strcpy( console, tty );
|
|
||||||
if (!strncmp( tty, "/dev/ttyS", 9 ))
|
|
||||||
serial_cons=1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* falls back to /dev/tty1 if an error occurs */
|
|
||||||
strcpy( console, default_console );
|
|
||||||
}
|
|
||||||
if (!first_terminal)
|
|
||||||
first_terminal = console;
|
|
||||||
if (serial_cons && !strncmp(term_ptr,"TERM=linux",10))
|
|
||||||
term_ptr = "TERM=vt100";
|
|
||||||
}
|
|
||||||
|
128
init/init.c
128
init/init.c
@ -66,11 +66,8 @@ waitfor(int pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
run(
|
run(const char* program, const char* const* arguments,
|
||||||
const char * program
|
const char* terminal, int get_enter)
|
||||||
,const char * const * arguments
|
|
||||||
,const char * terminal
|
|
||||||
,int get_enter)
|
|
||||||
{
|
{
|
||||||
static const char control_characters[] = {
|
static const char control_characters[] = {
|
||||||
'\003',
|
'\003',
|
||||||
@ -137,7 +134,8 @@ run(
|
|||||||
* before the user wants it. This is critical if swap is not
|
* before the user wants it. This is critical if swap is not
|
||||||
* enabled and the system has low memory. Generally this will
|
* enabled and the system has low memory. Generally this will
|
||||||
* be run on the second virtual console, and the first will
|
* be run on the second virtual console, and the first will
|
||||||
* be allowed to start a shell or the installation system.
|
* be allowed to start a shell or whatever an init script
|
||||||
|
* specifies.
|
||||||
*/
|
*/
|
||||||
char c;
|
char c;
|
||||||
write(1, press_enter, sizeof(press_enter) - 1);
|
write(1, press_enter, sizeof(press_enter) - 1);
|
||||||
@ -246,26 +244,49 @@ exit_signal(int sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
configure_terminals( int serial_cons );
|
configure_terminals( int serial_cons )
|
||||||
|
{
|
||||||
|
//struct stat statbuf;
|
||||||
|
char *tty;
|
||||||
|
|
||||||
|
switch (serial_cons) {
|
||||||
|
case 1:
|
||||||
|
strcpy( console, "/dev/ttyS0" );
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
strcpy( console, "/dev/ttyS1" );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
tty = ttyname(0);
|
||||||
|
if (tty) {
|
||||||
|
strcpy( console, tty );
|
||||||
|
if (!strncmp( tty, "/dev/ttyS", 9 ))
|
||||||
|
serial_cons=1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* falls back to /dev/tty1 if an error occurs */
|
||||||
|
strcpy( console, default_console );
|
||||||
|
}
|
||||||
|
if (!first_terminal)
|
||||||
|
first_terminal = console;
|
||||||
|
if (serial_cons && !strncmp(term_ptr,"TERM=linux",10))
|
||||||
|
term_ptr = "TERM=vt100";
|
||||||
|
}
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
init_main(int argc, char * * argv)
|
init_main(int argc, char * * argv)
|
||||||
{
|
{
|
||||||
static const char * const rc = "etc/rc";
|
static const char* const rc = "etc/rc";
|
||||||
const char * arguments[100];
|
const char * arguments[100];
|
||||||
int run_rc = 1;
|
int run_rc = 1;
|
||||||
int j;
|
int j;
|
||||||
int pid1 = 0;
|
int pid1 = 0;
|
||||||
int pid2 = 0;
|
int pid2 = 0;
|
||||||
int create_swap= -1;
|
int create_swap= -1;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
#ifndef INCLUDE_DINSTALL
|
const char * tty_commands[2] = { "bin/sh", "bin/sh"};
|
||||||
const char * tty_commands[2] = { "bin/sh", "bin/sh"};
|
char swap[20];
|
||||||
#else
|
int serial_console = 0;
|
||||||
const char * tty_commands[2] = { "sbin/dinstall", "bin/sh"};
|
|
||||||
#endif
|
|
||||||
char swap[20];
|
|
||||||
int serial_console = 0;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If I am started as /linuxrc instead of /sbin/init, I don't have the
|
* If I am started as /linuxrc instead of /sbin/init, I don't have the
|
||||||
@ -330,17 +351,13 @@ init_main(int argc, char * * argv)
|
|||||||
|
|
||||||
set_free_pages();
|
set_free_pages();
|
||||||
|
|
||||||
if (mem_total() < 3500) { /* not enough memory for standard install */
|
/* not enough memory to do anything useful*/
|
||||||
|
if (mem_total() < 2000) {
|
||||||
int retval;
|
int retval;
|
||||||
retval= stat("/etc/swappartition",&statbuf);
|
retval= stat("/etc/swappartition",&statbuf);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
printf("
|
printf("You do not have enough RAM, sorry.\n");
|
||||||
You do not have enough RAM, hence you must boot using the Boot Disk
|
while (1) { sleep(1);}
|
||||||
for Low Memory systems.
|
|
||||||
|
|
||||||
Read the instructions in the install.html file.
|
|
||||||
");
|
|
||||||
while (1) {;}
|
|
||||||
} else { /* everything OK */
|
} else { /* everything OK */
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
@ -371,8 +388,13 @@ Read the instructions in the install.html file.
|
|||||||
arguments[j] = 0;
|
arguments[j] = 0;
|
||||||
|
|
||||||
if ( run_rc ) {
|
if ( run_rc ) {
|
||||||
printf("running %s\n",rc);
|
printf("running %s with args \"",rc);
|
||||||
|
for ( j = 0; j < argc; j++ ) {
|
||||||
|
printf("%s ", arguments[j]);
|
||||||
|
}
|
||||||
|
printf("\" on console %s\n", console);
|
||||||
waitfor(run(rc, arguments, console, 0));
|
waitfor(run(rc, arguments, console, 0));
|
||||||
|
printf("done.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 0 == create_swap) {
|
if ( 0 == create_swap) {
|
||||||
@ -392,10 +414,21 @@ Read the instructions in the install.html file.
|
|||||||
/*
|
/*
|
||||||
arguments[0] = tty_commands[0];
|
arguments[0] = tty_commands[0];
|
||||||
*/
|
*/
|
||||||
pid1 = run(tty_commands[0], arguments, first_terminal, 0);
|
printf("running %s with args \"",tty_commands[0]);
|
||||||
|
for ( j = 0; j < argc; j++ ) {
|
||||||
|
printf("%s ", arguments[j]);
|
||||||
|
}
|
||||||
|
printf("\" on console %s\n", first_terminal);
|
||||||
|
pid1 = run(tty_commands[0], arguments, first_terminal, 1);
|
||||||
}
|
}
|
||||||
if ( pid2 == 0 && tty_commands[1] )
|
if ( pid2 == 0 && tty_commands[1] ) {
|
||||||
|
printf("running %s with args \"",tty_commands[0]);
|
||||||
|
for ( j = 0; j < argc; j++ ) {
|
||||||
|
printf("%s ", arguments[j]);
|
||||||
|
}
|
||||||
|
printf("\" on console %s\n", first_terminal);
|
||||||
pid2 = run(tty_commands[1], arguments, second_terminal, 1);
|
pid2 = run(tty_commands[1], arguments, second_terminal, 1);
|
||||||
|
}
|
||||||
wpid = wait(&status);
|
wpid = wait(&status);
|
||||||
if ( wpid > 0 ) {
|
if ( wpid > 0 ) {
|
||||||
/* DEBUGGING */
|
/* DEBUGGING */
|
||||||
@ -409,32 +442,3 @@ Read the instructions in the install.html file.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
configure_terminals( int serial_cons )
|
|
||||||
{
|
|
||||||
//struct stat statbuf;
|
|
||||||
char *tty;
|
|
||||||
|
|
||||||
switch (serial_cons) {
|
|
||||||
case 1:
|
|
||||||
strcpy( console, "/dev/ttyS0" );
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
strcpy( console, "/dev/ttyS1" );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
tty = ttyname(0);
|
|
||||||
if (tty) {
|
|
||||||
strcpy( console, tty );
|
|
||||||
if (!strncmp( tty, "/dev/ttyS", 9 ))
|
|
||||||
serial_cons=1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/* falls back to /dev/tty1 if an error occurs */
|
|
||||||
strcpy( console, default_console );
|
|
||||||
}
|
|
||||||
if (!first_terminal)
|
|
||||||
first_terminal = console;
|
|
||||||
if (serial_cons && !strncmp(term_ptr,"TERM=linux",10))
|
|
||||||
term_ptr = "TERM=vt100";
|
|
||||||
}
|
|
||||||
|
4
ls.c
4
ls.c
@ -179,15 +179,13 @@ int ls_main(int argc, char **argv)
|
|||||||
#define FEATURE_AUTOWIDTH /* calculate terminal & column widths */
|
#define FEATURE_AUTOWIDTH /* calculate terminal & column widths */
|
||||||
#define FEATURE_FILETYPECHAR /* enable -p and -F */
|
#define FEATURE_FILETYPECHAR /* enable -p and -F */
|
||||||
|
|
||||||
#undef OP_BUF_SIZE 1024 /* leave undefined for unbuffered output */
|
|
||||||
|
|
||||||
#define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */
|
#define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */
|
||||||
#define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */
|
#define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */
|
||||||
#define COLUMN_GAP 2 /* includes the file type char, if present */
|
#define COLUMN_GAP 2 /* includes the file type char, if present */
|
||||||
|
#define HAS_REWINDDIR
|
||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
#define HAS_REWINDDIR
|
|
||||||
|
|
||||||
#if 1 /* FIXME libc 6 */
|
#if 1 /* FIXME libc 6 */
|
||||||
# include <linux/types.h>
|
# include <linux/types.h>
|
||||||
|
18
mount.c
18
mount.c
@ -190,7 +190,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
endmntent (mountTable);
|
endmntent (mountTable);
|
||||||
}
|
}
|
||||||
return( TRUE);
|
exit( TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
case 'o':
|
case 'o':
|
||||||
if (--i == 0) {
|
if (--i == 0) {
|
||||||
fprintf (stderr, "%s\n", mount_usage);
|
fprintf (stderr, "%s\n", mount_usage);
|
||||||
return( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
parse_mount_options (*(++argv), &flags, string_flags);
|
parse_mount_options (*(++argv), &flags, string_flags);
|
||||||
--i;
|
--i;
|
||||||
@ -215,7 +215,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
case 't':
|
case 't':
|
||||||
if (--i == 0) {
|
if (--i == 0) {
|
||||||
fprintf (stderr, "%s\n", mount_usage);
|
fprintf (stderr, "%s\n", mount_usage);
|
||||||
return( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
filesystemType = *(++argv);
|
filesystemType = *(++argv);
|
||||||
--i;
|
--i;
|
||||||
@ -231,7 +231,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
case 'h':
|
case 'h':
|
||||||
case '-':
|
case '-':
|
||||||
fprintf (stderr, "%s\n", mount_usage);
|
fprintf (stderr, "%s\n", mount_usage);
|
||||||
return( TRUE);
|
exit( TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -241,7 +241,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
directory=*argv;
|
directory=*argv;
|
||||||
else {
|
else {
|
||||||
fprintf (stderr, "%s\n", mount_usage);
|
fprintf (stderr, "%s\n", mount_usage);
|
||||||
return( TRUE);
|
exit( TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
@ -254,7 +254,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
|
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
perror("/etc/fstab");
|
perror("/etc/fstab");
|
||||||
return( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
while ((m = getmntent (f)) != NULL) {
|
while ((m = getmntent (f)) != NULL) {
|
||||||
// If the file system isn't noauto, and isn't mounted on /, mount
|
// If the file system isn't noauto, and isn't mounted on /, mount
|
||||||
@ -270,12 +270,12 @@ extern int mount_main (int argc, char **argv)
|
|||||||
endmntent (f);
|
endmntent (f);
|
||||||
} else {
|
} else {
|
||||||
if (device && directory) {
|
if (device && directory) {
|
||||||
return (mount_one (device, directory, filesystemType,
|
exit (mount_one (device, directory, filesystemType,
|
||||||
flags, string_flags));
|
flags, string_flags));
|
||||||
} else {
|
} else {
|
||||||
fprintf (stderr, "%s\n", mount_usage);
|
fprintf (stderr, "%s\n", mount_usage);
|
||||||
return( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return( TRUE);
|
exit( TRUE);
|
||||||
}
|
}
|
||||||
|
8
umount.c
8
umount.c
@ -69,7 +69,7 @@ umount_main(int argc, char * * argv)
|
|||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "Usage: %s", umount_usage);
|
fprintf(stderr, "Usage: %s", umount_usage);
|
||||||
return(FALSE);
|
exit(FALSE);
|
||||||
}
|
}
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
@ -78,7 +78,7 @@ umount_main(int argc, char * * argv)
|
|||||||
while (**argv == '-') {
|
while (**argv == '-') {
|
||||||
while (*++(*argv)) switch (**argv) {
|
while (*++(*argv)) switch (**argv) {
|
||||||
case 'a':
|
case 'a':
|
||||||
return umount_all();
|
exit ( umount_all() );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Usage: %s\n", umount_usage);
|
fprintf(stderr, "Usage: %s\n", umount_usage);
|
||||||
@ -86,10 +86,10 @@ umount_main(int argc, char * * argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( umount(*argv) == 0 )
|
if ( umount(*argv) == 0 )
|
||||||
return (TRUE);
|
exit (TRUE);
|
||||||
else {
|
else {
|
||||||
perror("umount");
|
perror("umount");
|
||||||
return( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
endmntent (mountTable);
|
endmntent (mountTable);
|
||||||
}
|
}
|
||||||
return( TRUE);
|
exit( TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
case 'o':
|
case 'o':
|
||||||
if (--i == 0) {
|
if (--i == 0) {
|
||||||
fprintf (stderr, "%s\n", mount_usage);
|
fprintf (stderr, "%s\n", mount_usage);
|
||||||
return( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
parse_mount_options (*(++argv), &flags, string_flags);
|
parse_mount_options (*(++argv), &flags, string_flags);
|
||||||
--i;
|
--i;
|
||||||
@ -215,7 +215,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
case 't':
|
case 't':
|
||||||
if (--i == 0) {
|
if (--i == 0) {
|
||||||
fprintf (stderr, "%s\n", mount_usage);
|
fprintf (stderr, "%s\n", mount_usage);
|
||||||
return( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
filesystemType = *(++argv);
|
filesystemType = *(++argv);
|
||||||
--i;
|
--i;
|
||||||
@ -231,7 +231,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
case 'h':
|
case 'h':
|
||||||
case '-':
|
case '-':
|
||||||
fprintf (stderr, "%s\n", mount_usage);
|
fprintf (stderr, "%s\n", mount_usage);
|
||||||
return( TRUE);
|
exit( TRUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -241,7 +241,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
directory=*argv;
|
directory=*argv;
|
||||||
else {
|
else {
|
||||||
fprintf (stderr, "%s\n", mount_usage);
|
fprintf (stderr, "%s\n", mount_usage);
|
||||||
return( TRUE);
|
exit( TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
@ -254,7 +254,7 @@ extern int mount_main (int argc, char **argv)
|
|||||||
|
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
perror("/etc/fstab");
|
perror("/etc/fstab");
|
||||||
return( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
while ((m = getmntent (f)) != NULL) {
|
while ((m = getmntent (f)) != NULL) {
|
||||||
// If the file system isn't noauto, and isn't mounted on /, mount
|
// If the file system isn't noauto, and isn't mounted on /, mount
|
||||||
@ -270,12 +270,12 @@ extern int mount_main (int argc, char **argv)
|
|||||||
endmntent (f);
|
endmntent (f);
|
||||||
} else {
|
} else {
|
||||||
if (device && directory) {
|
if (device && directory) {
|
||||||
return (mount_one (device, directory, filesystemType,
|
exit (mount_one (device, directory, filesystemType,
|
||||||
flags, string_flags));
|
flags, string_flags));
|
||||||
} else {
|
} else {
|
||||||
fprintf (stderr, "%s\n", mount_usage);
|
fprintf (stderr, "%s\n", mount_usage);
|
||||||
return( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return( TRUE);
|
exit( TRUE);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ umount_main(int argc, char * * argv)
|
|||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
fprintf(stderr, "Usage: %s", umount_usage);
|
fprintf(stderr, "Usage: %s", umount_usage);
|
||||||
return(FALSE);
|
exit(FALSE);
|
||||||
}
|
}
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
@ -78,7 +78,7 @@ umount_main(int argc, char * * argv)
|
|||||||
while (**argv == '-') {
|
while (**argv == '-') {
|
||||||
while (*++(*argv)) switch (**argv) {
|
while (*++(*argv)) switch (**argv) {
|
||||||
case 'a':
|
case 'a':
|
||||||
return umount_all();
|
exit ( umount_all() );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Usage: %s\n", umount_usage);
|
fprintf(stderr, "Usage: %s\n", umount_usage);
|
||||||
@ -86,10 +86,10 @@ umount_main(int argc, char * * argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( umount(*argv) == 0 )
|
if ( umount(*argv) == 0 )
|
||||||
return (TRUE);
|
exit (TRUE);
|
||||||
else {
|
else {
|
||||||
perror("umount");
|
perror("umount");
|
||||||
return( FALSE);
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
utility.c
28
utility.c
@ -58,9 +58,8 @@ int isDirectory(const char *name)
|
|||||||
* be set.)
|
* be set.)
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
copyFile(
|
copyFile( const char *srcName, const char *destName,
|
||||||
const char *srcName,
|
int setModes, int followLinks)
|
||||||
const char *destName, int setModes, int followLinks)
|
|
||||||
{
|
{
|
||||||
int rfd;
|
int rfd;
|
||||||
int wfd;
|
int wfd;
|
||||||
@ -75,7 +74,6 @@ copyFile(
|
|||||||
result = stat(srcName, &srcStatBuf);
|
result = stat(srcName, &srcStatBuf);
|
||||||
else
|
else
|
||||||
result = lstat(srcName, &srcStatBuf);
|
result = lstat(srcName, &srcStatBuf);
|
||||||
|
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
perror(srcName);
|
perror(srcName);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -115,7 +113,8 @@ copyFile(
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
link_val[link_size] = '\0';
|
link_val[link_size] = '\0';
|
||||||
if (symlink(link_val, destName)) {
|
link_size = symlink(link_val, destName);
|
||||||
|
if (link_size != 0) {
|
||||||
perror(destName);
|
perror(destName);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
@ -179,7 +178,6 @@ copyFile(
|
|||||||
|
|
||||||
|
|
||||||
error_exit:
|
error_exit:
|
||||||
//fprintf(stderr, "choking on %s\n", destName);
|
|
||||||
perror(destName);
|
perror(destName);
|
||||||
close(rfd);
|
close(rfd);
|
||||||
close(wfd);
|
close(wfd);
|
||||||
@ -476,10 +474,11 @@ recursiveAction(const char *fileName, int recurse, int followLinks,
|
|||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
struct dirent *next;
|
struct dirent *next;
|
||||||
|
|
||||||
if (followLinks)
|
if (followLinks == FALSE)
|
||||||
status = lstat(fileName, &statbuf);
|
|
||||||
else
|
|
||||||
status = stat(fileName, &statbuf);
|
status = stat(fileName, &statbuf);
|
||||||
|
else
|
||||||
|
status = lstat(fileName, &statbuf);
|
||||||
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
perror(fileName);
|
perror(fileName);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
@ -487,16 +486,11 @@ recursiveAction(const char *fileName, int recurse, int followLinks,
|
|||||||
|
|
||||||
if (recurse == FALSE) {
|
if (recurse == FALSE) {
|
||||||
if (S_ISDIR(statbuf.st_mode)) {
|
if (S_ISDIR(statbuf.st_mode)) {
|
||||||
if (dirAction == NULL)
|
if (dirAction != NULL)
|
||||||
return (TRUE);
|
|
||||||
else
|
|
||||||
return (dirAction(fileName));
|
return (dirAction(fileName));
|
||||||
} else {
|
|
||||||
if (fileAction == NULL)
|
|
||||||
return (TRUE);
|
|
||||||
else
|
else
|
||||||
return (fileAction(fileName));
|
return (TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISDIR(statbuf.st_mode)) {
|
if (S_ISDIR(statbuf.st_mode)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user