More stuff -- ready for release.
-Erik
This commit is contained in:
parent
d0246fb72b
commit
cf8c9cf7b9
@ -9,10 +9,18 @@
|
|||||||
* Wrote sed -- weighs only 1.8k (5.8k with full regular expressions!).
|
* Wrote sed -- weighs only 1.8k (5.8k with full regular expressions!).
|
||||||
* Fixed a stupid seg-fault in sync
|
* Fixed a stupid seg-fault in sync
|
||||||
* Fixed mount -- mount -a failed to parse and apply mount options
|
* Fixed mount -- mount -a failed to parse and apply mount options
|
||||||
|
* Fixed umount -n (patch thanks to Matthew Grant <grantma@anathoth.gen.nz>)
|
||||||
|
* umount -a no longer umounts /proc
|
||||||
* Added BB_MTAB, allowing (at the cost of ~1.5k and the need for a rw /etc)
|
* Added BB_MTAB, allowing (at the cost of ~1.5k and the need for a rw /etc)
|
||||||
folks to use a real /etc/mtab file instead of a symlink to /proc/mounts.
|
folks to use a real /etc/mtab file instead of a symlink to /proc/mounts.
|
||||||
mount, and umount will add/remove entries and df will now use /etc/mtab
|
mount, and umount will add/remove entries and df will now use /etc/mtab
|
||||||
if BB_MTAB is defined.
|
if BB_MTAB is defined.
|
||||||
|
* Fixed a nice bug in recursiveAction() which caused it to infinitely
|
||||||
|
hunt through /proc/../fd/* creating new file descriptors if it
|
||||||
|
followed the /dev/fd link over to /proc. recursiveAction() now
|
||||||
|
lstat's the file when followLinks==FALSE so it won't follow links
|
||||||
|
as the name suggests. Fix thanks to Matt Porter <porter@debian.org>.
|
||||||
|
|
||||||
|
|
||||||
-Erik Andersen
|
-Erik Andersen
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#define BB_MORE
|
#define BB_MORE
|
||||||
#define BB_MOUNT
|
#define BB_MOUNT
|
||||||
//#define BB_MT
|
//#define BB_MT
|
||||||
#define BB_MTAB
|
//#define BB_MTAB
|
||||||
#define BB_MV
|
#define BB_MV
|
||||||
//#define BB_PRINTF
|
//#define BB_PRINTF
|
||||||
#define BB_PS
|
#define BB_PS
|
||||||
|
60
init.c
60
init.c
@ -123,13 +123,6 @@ 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[] = {
|
|
||||||
'\003', '\034', '\177', '\025', '\004', '\0',
|
|
||||||
'\1', '\0', '\021', '\023', '\032', '\0', '\022',
|
|
||||||
'\017', '\027', '\026', '\0'
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
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',
|
||||||
@ -160,44 +153,6 @@ void set_term( int fd)
|
|||||||
tcsetattr(fd, TCSANOW, &tty);
|
tcsetattr(fd, TCSANOW, &tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set terminal settings to reasonable defaults */
|
|
||||||
void set_term_old( int fd)
|
|
||||||
{
|
|
||||||
struct termios tty;
|
|
||||||
|
|
||||||
ioctl(fd, TCGETA, &tty);
|
|
||||||
|
|
||||||
tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD;
|
|
||||||
tty.c_cflag |= HUPCL|CLOCAL;
|
|
||||||
|
|
||||||
tty.c_cc[VINTR] = 3;
|
|
||||||
tty.c_cc[VQUIT] = 28;
|
|
||||||
tty.c_cc[VERASE] = 127;
|
|
||||||
//tty.c_cc[VKILL] = 21;
|
|
||||||
tty.c_cc[VKILL] = 24;
|
|
||||||
tty.c_cc[VEOF] = 4;
|
|
||||||
tty.c_cc[VTIME] = 0;
|
|
||||||
tty.c_cc[VMIN] = 1;
|
|
||||||
tty.c_cc[VSWTC] = 0;
|
|
||||||
tty.c_cc[VSTART] = 17;
|
|
||||||
tty.c_cc[VSTOP] = 19;
|
|
||||||
tty.c_cc[VSUSP] = 26;
|
|
||||||
tty.c_cc[VEOL] = 0;
|
|
||||||
tty.c_cc[VREPRINT] = 18;
|
|
||||||
tty.c_cc[VDISCARD] = 15;
|
|
||||||
tty.c_cc[VWERASE] = 23;
|
|
||||||
tty.c_cc[VLNEXT] = 22;
|
|
||||||
tty.c_cc[VEOL2] = 0;
|
|
||||||
|
|
||||||
|
|
||||||
tty.c_line = 0;
|
|
||||||
tty.c_iflag = IGNPAR|ICRNL|IXON|IXOFF|IXANY;
|
|
||||||
tty.c_oflag = OPOST|ONLCR;
|
|
||||||
tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOPRT|ECHOKE|IEXTEN;
|
|
||||||
|
|
||||||
ioctl(fd, TCSETA, &tty);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* How much memory does this machine have? */
|
/* How much memory does this machine have? */
|
||||||
static int mem_total()
|
static int mem_total()
|
||||||
{
|
{
|
||||||
@ -395,7 +350,12 @@ static void shutdown_system(void)
|
|||||||
waitfor(run( swap_off_cmd, console, FALSE));
|
waitfor(run( swap_off_cmd, console, FALSE));
|
||||||
waitfor(run( umount_cmd, console, FALSE));
|
waitfor(run( umount_cmd, console, FALSE));
|
||||||
sync();
|
sync();
|
||||||
|
message(CONSOLE, "Skipping bdflush\r\n");
|
||||||
|
if (get_kernel_revision() <= 2 * 65536 + 2 * 256 + 11) {
|
||||||
|
/* bdflush, kupdate not needed for kernels >2.2.11 */
|
||||||
bdflush(1, 0);
|
bdflush(1, 0);
|
||||||
|
sync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void halt_signal(int sig)
|
static void halt_signal(int sig)
|
||||||
@ -518,15 +478,19 @@ extern int init_main(int argc, char **argv)
|
|||||||
if (wpid > 0 ) {
|
if (wpid > 0 ) {
|
||||||
message(LOG, "pid %d exited, status=%x.\n", wpid, status);
|
message(LOG, "pid %d exited, status=%x.\n", wpid, status);
|
||||||
}
|
}
|
||||||
|
/* Don't respawn init script if it exits */
|
||||||
if (wpid == pid1) {
|
if (wpid == pid1) {
|
||||||
|
if (run_rc == FALSE) {
|
||||||
pid1 = 0;
|
pid1 = 0;
|
||||||
if (run_rc == TRUE) {
|
}
|
||||||
/* Don't respawn init script if it exits,
|
#if 0
|
||||||
* Start a shell instead. */
|
/* Turn this on to start a shell on the console if the init script exits.... */
|
||||||
|
else {
|
||||||
run_rc=FALSE;
|
run_rc=FALSE;
|
||||||
wait_for_enter=TRUE;
|
wait_for_enter=TRUE;
|
||||||
tty0_commands=shell_commands;
|
tty0_commands=shell_commands;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (wpid == pid2) {
|
if (wpid == pid2) {
|
||||||
pid2 = 0;
|
pid2 = 0;
|
||||||
|
60
init/init.c
60
init/init.c
@ -123,13 +123,6 @@ 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[] = {
|
|
||||||
'\003', '\034', '\177', '\025', '\004', '\0',
|
|
||||||
'\1', '\0', '\021', '\023', '\032', '\0', '\022',
|
|
||||||
'\017', '\027', '\026', '\0'
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
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',
|
||||||
@ -160,44 +153,6 @@ void set_term( int fd)
|
|||||||
tcsetattr(fd, TCSANOW, &tty);
|
tcsetattr(fd, TCSANOW, &tty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set terminal settings to reasonable defaults */
|
|
||||||
void set_term_old( int fd)
|
|
||||||
{
|
|
||||||
struct termios tty;
|
|
||||||
|
|
||||||
ioctl(fd, TCGETA, &tty);
|
|
||||||
|
|
||||||
tty.c_cflag &= CBAUD|CBAUDEX|CSIZE|CSTOPB|PARENB|PARODD;
|
|
||||||
tty.c_cflag |= HUPCL|CLOCAL;
|
|
||||||
|
|
||||||
tty.c_cc[VINTR] = 3;
|
|
||||||
tty.c_cc[VQUIT] = 28;
|
|
||||||
tty.c_cc[VERASE] = 127;
|
|
||||||
//tty.c_cc[VKILL] = 21;
|
|
||||||
tty.c_cc[VKILL] = 24;
|
|
||||||
tty.c_cc[VEOF] = 4;
|
|
||||||
tty.c_cc[VTIME] = 0;
|
|
||||||
tty.c_cc[VMIN] = 1;
|
|
||||||
tty.c_cc[VSWTC] = 0;
|
|
||||||
tty.c_cc[VSTART] = 17;
|
|
||||||
tty.c_cc[VSTOP] = 19;
|
|
||||||
tty.c_cc[VSUSP] = 26;
|
|
||||||
tty.c_cc[VEOL] = 0;
|
|
||||||
tty.c_cc[VREPRINT] = 18;
|
|
||||||
tty.c_cc[VDISCARD] = 15;
|
|
||||||
tty.c_cc[VWERASE] = 23;
|
|
||||||
tty.c_cc[VLNEXT] = 22;
|
|
||||||
tty.c_cc[VEOL2] = 0;
|
|
||||||
|
|
||||||
|
|
||||||
tty.c_line = 0;
|
|
||||||
tty.c_iflag = IGNPAR|ICRNL|IXON|IXOFF|IXANY;
|
|
||||||
tty.c_oflag = OPOST|ONLCR;
|
|
||||||
tty.c_lflag = ISIG|ICANON|ECHO|ECHOE|ECHOK|ECHOCTL|ECHOPRT|ECHOKE|IEXTEN;
|
|
||||||
|
|
||||||
ioctl(fd, TCSETA, &tty);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* How much memory does this machine have? */
|
/* How much memory does this machine have? */
|
||||||
static int mem_total()
|
static int mem_total()
|
||||||
{
|
{
|
||||||
@ -395,7 +350,12 @@ static void shutdown_system(void)
|
|||||||
waitfor(run( swap_off_cmd, console, FALSE));
|
waitfor(run( swap_off_cmd, console, FALSE));
|
||||||
waitfor(run( umount_cmd, console, FALSE));
|
waitfor(run( umount_cmd, console, FALSE));
|
||||||
sync();
|
sync();
|
||||||
|
message(CONSOLE, "Skipping bdflush\r\n");
|
||||||
|
if (get_kernel_revision() <= 2 * 65536 + 2 * 256 + 11) {
|
||||||
|
/* bdflush, kupdate not needed for kernels >2.2.11 */
|
||||||
bdflush(1, 0);
|
bdflush(1, 0);
|
||||||
|
sync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void halt_signal(int sig)
|
static void halt_signal(int sig)
|
||||||
@ -518,15 +478,19 @@ extern int init_main(int argc, char **argv)
|
|||||||
if (wpid > 0 ) {
|
if (wpid > 0 ) {
|
||||||
message(LOG, "pid %d exited, status=%x.\n", wpid, status);
|
message(LOG, "pid %d exited, status=%x.\n", wpid, status);
|
||||||
}
|
}
|
||||||
|
/* Don't respawn init script if it exits */
|
||||||
if (wpid == pid1) {
|
if (wpid == pid1) {
|
||||||
|
if (run_rc == FALSE) {
|
||||||
pid1 = 0;
|
pid1 = 0;
|
||||||
if (run_rc == TRUE) {
|
}
|
||||||
/* Don't respawn init script if it exits,
|
#if 0
|
||||||
* Start a shell instead. */
|
/* Turn this on to start a shell on the console if the init script exits.... */
|
||||||
|
else {
|
||||||
run_rc=FALSE;
|
run_rc=FALSE;
|
||||||
wait_for_enter=TRUE;
|
wait_for_enter=TRUE;
|
||||||
tty0_commands=shell_commands;
|
tty0_commands=shell_commands;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (wpid == pid2) {
|
if (wpid == pid2) {
|
||||||
pid2 = 0;
|
pid2 = 0;
|
||||||
|
9
umount.c
9
umount.c
@ -76,6 +76,10 @@ umount_all(int useMtab)
|
|||||||
if (strcmp (blockDevice, "/dev/root") == 0)
|
if (strcmp (blockDevice, "/dev/root") == 0)
|
||||||
blockDevice = (getfsfile ("/"))->fs_spec;
|
blockDevice = (getfsfile ("/"))->fs_spec;
|
||||||
#endif
|
#endif
|
||||||
|
/* Don't umount /proc when doing umount -a */
|
||||||
|
if (strcmp (blockDevice, "proc") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
status=do_umount (m->mnt_dir, useMtab);
|
status=do_umount (m->mnt_dir, useMtab);
|
||||||
if (status!=0) {
|
if (status!=0) {
|
||||||
/* Don't bother retrying the umount on busy devices */
|
/* Don't bother retrying the umount on busy devices */
|
||||||
@ -83,9 +87,6 @@ umount_all(int useMtab)
|
|||||||
perror(m->mnt_dir);
|
perror(m->mnt_dir);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
printf ("Trying to umount %s failed: %s\n",
|
|
||||||
m->mnt_dir, strerror(errno));
|
|
||||||
printf ("Instead trying to umount %s\n", blockDevice);
|
|
||||||
status=do_umount (blockDevice, useMtab);
|
status=do_umount (blockDevice, useMtab);
|
||||||
if (status!=0) {
|
if (status!=0) {
|
||||||
printf ("Couldn't umount %s on %s (type %s): %s\n",
|
printf ("Couldn't umount %s on %s (type %s): %s\n",
|
||||||
@ -107,7 +108,7 @@ umount_main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse any options */
|
/* Parse any options */
|
||||||
while (argc-- > 0 && **(++argv) == '-') {
|
while (argc-- > 0 && **(argv++) == '-') {
|
||||||
while (*++(*argv)) switch (**argv) {
|
while (*++(*argv)) switch (**argv) {
|
||||||
case 'a':
|
case 'a':
|
||||||
umountAll = TRUE;
|
umountAll = TRUE;
|
||||||
|
@ -76,6 +76,10 @@ umount_all(int useMtab)
|
|||||||
if (strcmp (blockDevice, "/dev/root") == 0)
|
if (strcmp (blockDevice, "/dev/root") == 0)
|
||||||
blockDevice = (getfsfile ("/"))->fs_spec;
|
blockDevice = (getfsfile ("/"))->fs_spec;
|
||||||
#endif
|
#endif
|
||||||
|
/* Don't umount /proc when doing umount -a */
|
||||||
|
if (strcmp (blockDevice, "proc") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
status=do_umount (m->mnt_dir, useMtab);
|
status=do_umount (m->mnt_dir, useMtab);
|
||||||
if (status!=0) {
|
if (status!=0) {
|
||||||
/* Don't bother retrying the umount on busy devices */
|
/* Don't bother retrying the umount on busy devices */
|
||||||
@ -83,9 +87,6 @@ umount_all(int useMtab)
|
|||||||
perror(m->mnt_dir);
|
perror(m->mnt_dir);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
printf ("Trying to umount %s failed: %s\n",
|
|
||||||
m->mnt_dir, strerror(errno));
|
|
||||||
printf ("Instead trying to umount %s\n", blockDevice);
|
|
||||||
status=do_umount (blockDevice, useMtab);
|
status=do_umount (blockDevice, useMtab);
|
||||||
if (status!=0) {
|
if (status!=0) {
|
||||||
printf ("Couldn't umount %s on %s (type %s): %s\n",
|
printf ("Couldn't umount %s on %s (type %s): %s\n",
|
||||||
@ -107,7 +108,7 @@ umount_main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Parse any options */
|
/* Parse any options */
|
||||||
while (argc-- > 0 && **(++argv) == '-') {
|
while (argc-- > 0 && **(argv++) == '-') {
|
||||||
while (*++(*argv)) switch (**argv) {
|
while (*++(*argv)) switch (**argv) {
|
||||||
case 'a':
|
case 'a':
|
||||||
umountAll = TRUE;
|
umountAll = TRUE;
|
||||||
|
@ -393,7 +393,8 @@ int fullRead(int fd, char *buf, int len)
|
|||||||
*
|
*
|
||||||
* Unfortunatly, while nftw(3) could replace this and reduce
|
* Unfortunatly, while nftw(3) could replace this and reduce
|
||||||
* code size a bit, nftw() wasn't supported before GNU libc 2.1,
|
* code size a bit, nftw() wasn't supported before GNU libc 2.1,
|
||||||
* and so isn't sufficiently portable to take over...
|
* and so isn't sufficiently portable to take over since glibc2.1
|
||||||
|
* is so stinking huge.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst,
|
recursiveAction(const char *fileName, int recurse, int followLinks, int depthFirst,
|
||||||
@ -404,7 +405,7 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir
|
|||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
struct dirent *next;
|
struct dirent *next;
|
||||||
|
|
||||||
if (followLinks == FALSE)
|
if (followLinks == TRUE)
|
||||||
status = stat(fileName, &statbuf);
|
status = stat(fileName, &statbuf);
|
||||||
else
|
else
|
||||||
status = lstat(fileName, &statbuf);
|
status = lstat(fileName, &statbuf);
|
||||||
@ -414,6 +415,9 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir
|
|||||||
return (FALSE);
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( (followLinks == FALSE) && (S_ISLNK(statbuf.st_mode)) )
|
||||||
|
return (TRUE);
|
||||||
|
|
||||||
if (recurse == FALSE) {
|
if (recurse == FALSE) {
|
||||||
if (S_ISDIR(statbuf.st_mode)) {
|
if (S_ISDIR(statbuf.st_mode)) {
|
||||||
if (dirAction != NULL)
|
if (dirAction != NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user