Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e2bb288da | ||
|
|
add0158554 | ||
|
|
3d8dbe1ca0 | ||
|
|
50d6360771 | ||
|
|
fbb39c83b6 | ||
|
|
07e5297ca7 | ||
|
|
dc6301e7ca | ||
|
|
350577c5a0 | ||
|
|
29d2e362de | ||
|
|
bc34190694 | ||
|
|
f14937d177 | ||
|
|
e18c75a563 | ||
|
|
9997685953 |
No files matched your search
@@ -1,5 +1,42 @@
|
||||
0.34
|
||||
* ls -l now displays lnik names outside the current directory,
|
||||
Patch thanks to Eric Delaunay
|
||||
* init now properly handles sparc serial consoles and does a
|
||||
better job of finding the real consol device rather than using
|
||||
/dev/console which doesn't support job control. Patch also
|
||||
thanks to Eric Delaunay.
|
||||
* more started to read from stdin after the last file was finished, and
|
||||
options were not parsed correctly (fix thanks to Eric Delaunay).
|
||||
* more will now use the terminal size if BB_FEATURE_AUTOWIDTH is on.
|
||||
* rm wouldn't remove a symlink unless the symlink was valid. This was
|
||||
a side effect of the busybox 0.32 recursiveAction() fix. Things
|
||||
should now work correctly.
|
||||
* grep wouldn't grep stdin. Now it does.
|
||||
* sed wouldn't sed stdin. Now it does.
|
||||
* sed was appending a \n to the end of lines with replacements.
|
||||
Now it doesn't do that.
|
||||
* ls -l now bypasses libc6 nss when displaying user/group names.
|
||||
Now uses my_getpwuid and my_getgrgid.
|
||||
|
||||
-Erik Andersen
|
||||
|
||||
0.33
|
||||
* Fixed a bug where init could hang instead of rebooting.
|
||||
* Removed some debugging noise from init.c
|
||||
* Fixed ln so it works now (it was very broken).
|
||||
* Fixed df so it won't segfault when there is no /etc/fstab,
|
||||
* If BB_MTAB is not defined, df and mount will whine if /etc/fstab
|
||||
is not installed (since they cannot fixup "/dev/root" to
|
||||
state the real root device name)
|
||||
* merged some redundant code from mtab.c/df.c into utility.c
|
||||
|
||||
-Erik Andersen
|
||||
|
||||
0.32
|
||||
* usage() now printf the BusyBox version. This will help folks
|
||||
* More changes -- many thanks to Lineo for paying me to work on
|
||||
busybox. If you have any problems please let me know ASAP
|
||||
at andersen@lineo.com or andersee@debian.org
|
||||
* usage() now prints the BusyBox version. This will help folks
|
||||
realize that they are not in Kansas anymore.
|
||||
* Fixed mkdir -m option so that it works.
|
||||
* kill segfaulted w/o any arguments. Now it doesn't do that.
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
PROG=busybox
|
||||
VERSION=0.32
|
||||
VERSION=0.34
|
||||
BUILDTIME=$(shell date "+%Y%m%d-%H%M")
|
||||
|
||||
# Comment out the following to make a debuggable build
|
||||
|
||||
@@ -380,7 +380,6 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */
|
||||
# undef LZW
|
||||
#endif
|
||||
|
||||
/* $Id: gzip.c,v 1.5 1999/10/23 07:09:58 andersen Exp $ */
|
||||
/* tailor.h -- target dependent definitions
|
||||
* Copyright (C) 1992-1993 Jean-loup Gailly.
|
||||
* This is free software; you can redistribute it and/or modify it under the
|
||||
@@ -391,7 +390,6 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */
|
||||
* The target dependent functions should be defined in tailor.c.
|
||||
*/
|
||||
|
||||
/* $Id: gzip.c,v 1.5 1999/10/23 07:09:58 andersen Exp $ */
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
|
||||
+12
-3
@@ -35,6 +35,16 @@
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
/* Note that tar.c expects TRUE and FALSE to be defined
|
||||
* exactly the opposite of how they are used everywhere else.
|
||||
* Some time this should be integrated a bit better, but this
|
||||
* does the job for now.
|
||||
*/
|
||||
#undef FALSE
|
||||
#undef TRUE
|
||||
#define FALSE ((int) 0)
|
||||
#define TRUE ((int) 1)
|
||||
|
||||
|
||||
static const char tar_usage[] =
|
||||
"tar -[cxtvOf] [tarFileName] [FILE] ...\n"
|
||||
@@ -169,10 +179,9 @@ extern int tar_main (int argc, char **argv)
|
||||
/*
|
||||
* Parse the options.
|
||||
*/
|
||||
options = *argv++;
|
||||
argc--;
|
||||
|
||||
if (**argv == '-') {
|
||||
options = (*argv++) + 1;
|
||||
argc--;
|
||||
for (; *options; options++) {
|
||||
switch (*options) {
|
||||
case 'f':
|
||||
|
||||
+13
-14
@@ -2,7 +2,6 @@
|
||||
* This file is parsed by sed. You MUST use single line comments.
|
||||
* IE //#define BB_BLAH
|
||||
*/
|
||||
|
||||
#define BB_BUSYBOX
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
@@ -13,53 +12,53 @@
|
||||
#define BB_DD
|
||||
#define BB_DF
|
||||
#define BB_DMESG
|
||||
//#define BB_DUTMP
|
||||
//#define BB_FDFLUSH
|
||||
#define BB_DUTMP
|
||||
#define BB_FDFLUSH
|
||||
#define BB_FIND
|
||||
#define BB_FSCK_MINIX
|
||||
#define BB_MKFS_MINIX
|
||||
#define BB_CHVT
|
||||
#define BB_DEALLOCVT
|
||||
#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_LOADFONT
|
||||
#define BB_LOADKMAP
|
||||
#define BB_LS
|
||||
//#define BB_MAKEDEVS
|
||||
//#define BB_MATH
|
||||
#define BB_MAKEDEVS
|
||||
#define BB_MATH
|
||||
#define BB_MKDIR
|
||||
#define BB_MKNOD
|
||||
#define BB_MKSWAP
|
||||
//#define BB_MNC
|
||||
#define BB_MNC
|
||||
#define BB_MORE
|
||||
#define BB_MOUNT
|
||||
//#define BB_MT
|
||||
//#define BB_MTAB
|
||||
#define BB_MT
|
||||
#define BB_MTAB
|
||||
#define BB_MV
|
||||
//#define BB_PRINTF
|
||||
#define BB_PRINTF
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
#define BB_REGEXP
|
||||
#define BB_REBOOT
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
//#define BB_SFDISK
|
||||
#define BB_SFDISK
|
||||
#define BB_SED
|
||||
#define BB_SLEEP
|
||||
#define BB_SWAPONOFF
|
||||
#define BB_SYNC
|
||||
#define BB_TAR
|
||||
#define BB_TOUCH
|
||||
//#define BB_TRUE_FALSE // Supplied by ash
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_UMOUNT
|
||||
#define BB_UPDATE
|
||||
#define BB_UNAME
|
||||
#define BB_ZCAT
|
||||
//#define BB_GZIP
|
||||
#define BB_GZIP
|
||||
// Don't turn BB_UTILITY off. It contains support code
|
||||
// that compiles to 0 if everything else if turned off.
|
||||
#define BB_UTILITY
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
Name: busybox
|
||||
Version: 0.32
|
||||
Version: 0.33
|
||||
Release: 1
|
||||
Group: System/Utilities
|
||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
||||
@@ -7,7 +7,7 @@ Copyright: GPL
|
||||
Packager : Erik Andersen <andersen@lineo.com>
|
||||
Conflicts: fileutils grep shellutils
|
||||
Buildroot: /tmp/%{Name}-%{Version}
|
||||
Source: busybox-0.32.tar.gz
|
||||
Source: busybox-%{Version}.tar.gz
|
||||
|
||||
%Description
|
||||
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
|
||||
|
||||
+10
-44
@@ -38,6 +38,7 @@ static int df(char *device, const char *mountPoint)
|
||||
struct statfs s;
|
||||
long blocks_used;
|
||||
long blocks_percent_used;
|
||||
struct fstab* fstabItem;
|
||||
|
||||
if (statfs(mountPoint, &s) != 0) {
|
||||
perror(mountPoint);
|
||||
@@ -48,9 +49,12 @@ static int df(char *device, const char *mountPoint)
|
||||
blocks_used = s.f_blocks - s.f_bfree;
|
||||
blocks_percent_used = (long)
|
||||
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
|
||||
if (strcmp(device, "/dev/root") == 0)
|
||||
device = (getfsfile("/"))->fs_spec;
|
||||
|
||||
/* Note that if /etc/fstab is missing, libc can't fix up /dev/root for us */
|
||||
if (strcmp (device, "/dev/root") == 0) {
|
||||
fstabItem = getfsfile ("/");
|
||||
if (fstabItem != NULL)
|
||||
device = fstabItem->fs_spec;
|
||||
}
|
||||
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
||||
device,
|
||||
(long) (s.f_blocks * (s.f_bsize / 1024.0)),
|
||||
@@ -63,52 +67,14 @@ static int df(char *device, const char *mountPoint)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a block device, find the mount table entry if that block device
|
||||
* is mounted.
|
||||
*
|
||||
* Given any other file (or directory), find the mount table entry for its
|
||||
* filesystem.
|
||||
*/
|
||||
extern struct mntent *findMountPoint(const char *name, const char *table)
|
||||
{
|
||||
struct stat s;
|
||||
dev_t mountDevice;
|
||||
FILE *mountTable;
|
||||
struct mntent *mountEntry;
|
||||
|
||||
if (stat(name, &s) != 0)
|
||||
return 0;
|
||||
|
||||
if ((s.st_mode & S_IFMT) == S_IFBLK)
|
||||
mountDevice = s.st_rdev;
|
||||
else
|
||||
mountDevice = s.st_dev;
|
||||
|
||||
|
||||
if ((mountTable = setmntent(table, "r")) == 0)
|
||||
return 0;
|
||||
|
||||
while ((mountEntry = getmntent(mountTable)) != 0) {
|
||||
if (strcmp(name, mountEntry->mnt_dir) == 0
|
||||
|| strcmp(name, mountEntry->mnt_fsname) == 0) /* String match. */
|
||||
break;
|
||||
if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == mountDevice) /* Match the device. */
|
||||
break;
|
||||
if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == mountDevice) /* Match the directory's mount point. */
|
||||
break;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
return mountEntry;
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern int df_main(int argc, char **argv)
|
||||
{
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
|
||||
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
|
||||
|
||||
/* Only compiled in if BB_MTAB is not defined */
|
||||
whine_if_fstab_is_missing();
|
||||
|
||||
if (argc > 1) {
|
||||
struct mntent *mountEntry;
|
||||
int status;
|
||||
|
||||
+14
-19
@@ -27,23 +27,21 @@
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
static const char ln_usage[] = "ln [-s] [-f] original-name additional-name\n"
|
||||
"\n"
|
||||
"\tAdd a new name that refers to the same file as \"original-name\"\n"
|
||||
"\n"
|
||||
"\t-s:\tUse a \"symbolic\" link, instead of a \"hard\" link.\n"
|
||||
"\t-f:\tRemove existing destination files.\n";
|
||||
static const char ln_usage[] = "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n"
|
||||
"Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n"
|
||||
"\nOptions:\n"
|
||||
"\t-s\tmake symbolic links instead of hard links\n"
|
||||
"\t-f\tremove existing destination files\n";
|
||||
|
||||
|
||||
static int symlinkFlag = FALSE;
|
||||
static int removeoldFlag = FALSE;
|
||||
static const char *destName;
|
||||
|
||||
|
||||
extern int ln_main(int argc, char **argv)
|
||||
{
|
||||
int status;
|
||||
char newdestName[NAME_MAX];
|
||||
static char* linkName;
|
||||
|
||||
if (argc < 3) {
|
||||
usage (ln_usage);
|
||||
@@ -69,30 +67,27 @@ extern int ln_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
destName = argv[argc - 1];
|
||||
linkName = argv[argc - 1];
|
||||
|
||||
if ((argc > 3) && !(isDirectory(destName))) {
|
||||
fprintf(stderr, "%s: not a directory\n", destName);
|
||||
if ((argc > 3) && !(isDirectory(linkName))) {
|
||||
fprintf(stderr, "%s: not a directory\n", linkName);
|
||||
exit (FALSE);
|
||||
}
|
||||
|
||||
while (argc-- >= 2) {
|
||||
strcpy(newdestName, destName);
|
||||
strcat(newdestName, (*argv)+(strlen(*(++argv))));
|
||||
|
||||
if (removeoldFlag==TRUE ) {
|
||||
status = ( unlink(newdestName) && errno != ENOENT );
|
||||
status = ( unlink(linkName) && errno != ENOENT );
|
||||
if ( status != 0 ) {
|
||||
perror(newdestName);
|
||||
perror(linkName);
|
||||
exit( FALSE);
|
||||
}
|
||||
}
|
||||
if ( symlinkFlag==TRUE)
|
||||
status = symlink(*argv, newdestName);
|
||||
status = symlink(*argv, linkName);
|
||||
else
|
||||
status = link(*argv, newdestName);
|
||||
status = link(*argv, linkName);
|
||||
if ( status != 0 ) {
|
||||
perror(newdestName);
|
||||
perror(linkName);
|
||||
exit( FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-53
@@ -40,7 +40,7 @@
|
||||
* 1. requires lstat (BSD) - how do you do it without?
|
||||
*/
|
||||
|
||||
//#define FEATURE_USERNAME /* show username/groupnames (libc6 uses NSS) */
|
||||
#define FEATURE_USERNAME /* show username/groupnames (bypasses libc6 NSS) */
|
||||
#define FEATURE_TIMESTAMPS /* show file timestamps */
|
||||
#define FEATURE_AUTOWIDTH /* calculate terminal & column widths */
|
||||
#define FEATURE_FILETYPECHAR /* enable -p and -F */
|
||||
@@ -64,10 +64,6 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#ifdef FEATURE_USERNAME
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#endif
|
||||
#ifdef FEATURE_TIMESTAMPS
|
||||
#include <time.h>
|
||||
#endif
|
||||
@@ -83,27 +79,6 @@
|
||||
#define MINOR(dev) ((dev)&0xff)
|
||||
#endif
|
||||
|
||||
#define MODE1 "rwxrwxrwx"
|
||||
#define MODE0 "---------"
|
||||
#define SMODE1 "..s..s..t"
|
||||
#define SMODE0 "..S..S..T"
|
||||
|
||||
/* The 9 mode bits to test */
|
||||
|
||||
static const mode_t MBIT[] = {
|
||||
S_IRUSR, S_IWUSR, S_IXUSR,
|
||||
S_IRGRP, S_IWGRP, S_IXGRP,
|
||||
S_IROTH, S_IWOTH, S_IXOTH
|
||||
};
|
||||
|
||||
/* The special bits. If set, display SMODE0/1 instead of MODE0/1 */
|
||||
|
||||
static const mode_t SBIT[] = {
|
||||
0, 0, S_ISUID,
|
||||
0, 0, S_ISGID,
|
||||
0, 0, S_ISVTX
|
||||
};
|
||||
|
||||
#define FMT_AUTO 0
|
||||
#define FMT_LONG 1 /* one record per line, extended info */
|
||||
#define FMT_SINGLE 2 /* one record per line */
|
||||
@@ -206,7 +181,7 @@ static char append_char(mode_t mode)
|
||||
**
|
||||
**/
|
||||
|
||||
static void list_single(const char *name, struct stat *info)
|
||||
static void list_single(const char *name, struct stat *info, const char *fullname)
|
||||
{
|
||||
char scratch[PATH_MAX];
|
||||
short len = strlen(name);
|
||||
@@ -216,45 +191,35 @@ static void list_single(const char *name, struct stat *info)
|
||||
|
||||
if (display_fmt == FMT_LONG) {
|
||||
mode_t mode = info->st_mode;
|
||||
int i;
|
||||
|
||||
scratch[0] = TYPECHAR(mode);
|
||||
for (i=0; i<9; i++)
|
||||
if (mode & SBIT[i])
|
||||
scratch[i+1] = (mode & MBIT[i])
|
||||
? SMODE1[i]
|
||||
: SMODE0[i];
|
||||
else
|
||||
scratch[i+1] = (mode & MBIT[i])
|
||||
? MODE1[i]
|
||||
: MODE0[i];
|
||||
newline();
|
||||
wr(scratch, 10);
|
||||
wr(modeString(mode), 10);
|
||||
column=10;
|
||||
writenum((long)info->st_nlink,(short)4);
|
||||
writenum((long)info->st_nlink,(short)5);
|
||||
fputs(" ", stdout);
|
||||
#ifdef FEATURE_USERNAME
|
||||
if (!(opts & DISP_NUMERIC)) {
|
||||
struct passwd *pw = getpwuid(info->st_uid);
|
||||
if (pw)
|
||||
fputs(pw->pw_name, stdout);
|
||||
scratch[8]='\0';
|
||||
my_getpwuid( scratch, info->st_uid);
|
||||
if (*scratch)
|
||||
fputs(scratch, stdout);
|
||||
else
|
||||
writenum((long)info->st_uid,(short)0);
|
||||
} else
|
||||
#endif
|
||||
writenum((long)info->st_uid,(short)0);
|
||||
tab(24);
|
||||
tab(16);
|
||||
#ifdef FEATURE_USERNAME
|
||||
if (!(opts & DISP_NUMERIC)) {
|
||||
struct group *gr = getgrgid(info->st_gid);
|
||||
if (gr)
|
||||
fputs(gr->gr_name, stdout);
|
||||
scratch[8]='\0';
|
||||
my_getgrgid( scratch, info->st_gid);
|
||||
if (*scratch)
|
||||
fputs(scratch, stdout);
|
||||
else
|
||||
writenum((long)info->st_gid,(short)0);
|
||||
} else
|
||||
#endif
|
||||
writenum((long)info->st_gid,(short)0);
|
||||
tab(33);
|
||||
tab(17);
|
||||
if (S_ISBLK(mode) || S_ISCHR(mode)) {
|
||||
writenum((long)MAJOR(info->st_rdev),(short)3);
|
||||
fputs(", ", stdout);
|
||||
@@ -297,12 +262,12 @@ static void list_single(const char *name, struct stat *info)
|
||||
wr(name, len);
|
||||
if (S_ISLNK(mode)) {
|
||||
wr(" -> ", 4);
|
||||
len = readlink(name, scratch, sizeof scratch);
|
||||
len = readlink(fullname, scratch, sizeof scratch);
|
||||
if (len > 0) fwrite(scratch, 1, len, stdout);
|
||||
#ifdef FEATURE_FILETYPECHAR
|
||||
/* show type of destination */
|
||||
if (opts & DISP_FTYPE) {
|
||||
if (!stat(name, info)) {
|
||||
if (!stat(fullname, info)) {
|
||||
append = append_char(info->st_mode);
|
||||
if (append)
|
||||
fputc(append, stdout);
|
||||
@@ -372,7 +337,7 @@ static int list_item(const char *name)
|
||||
|
||||
if (!S_ISDIR(info.st_mode) ||
|
||||
(opts & DIR_NOLIST)) {
|
||||
list_single(name, &info);
|
||||
list_single(name, &info, name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -424,7 +389,7 @@ static int list_item(const char *name)
|
||||
strcpy(fnend, entry->d_name);
|
||||
if (lstat(fullname, &info))
|
||||
goto direrr; /* (shouldn't fail) */
|
||||
list_single(entry->d_name, &info);
|
||||
list_single(entry->d_name, &info, fullname);
|
||||
}
|
||||
closedir(dir);
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ extern int rm_main(int argc, char **argv)
|
||||
|
||||
while (argc-- > 0) {
|
||||
srcName = *(argv++);
|
||||
if (recursiveAction( srcName, recursiveFlag, TRUE, TRUE,
|
||||
if (recursiveAction( srcName, recursiveFlag, FALSE, TRUE,
|
||||
fileAction, dirAction) == FALSE) {
|
||||
exit( FALSE);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ static int df(char *device, const char *mountPoint)
|
||||
struct statfs s;
|
||||
long blocks_used;
|
||||
long blocks_percent_used;
|
||||
struct fstab* fstabItem;
|
||||
|
||||
if (statfs(mountPoint, &s) != 0) {
|
||||
perror(mountPoint);
|
||||
@@ -48,9 +49,12 @@ static int df(char *device, const char *mountPoint)
|
||||
blocks_used = s.f_blocks - s.f_bfree;
|
||||
blocks_percent_used = (long)
|
||||
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
|
||||
if (strcmp(device, "/dev/root") == 0)
|
||||
device = (getfsfile("/"))->fs_spec;
|
||||
|
||||
/* Note that if /etc/fstab is missing, libc can't fix up /dev/root for us */
|
||||
if (strcmp (device, "/dev/root") == 0) {
|
||||
fstabItem = getfsfile ("/");
|
||||
if (fstabItem != NULL)
|
||||
device = fstabItem->fs_spec;
|
||||
}
|
||||
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
||||
device,
|
||||
(long) (s.f_blocks * (s.f_bsize / 1024.0)),
|
||||
@@ -63,52 +67,14 @@ static int df(char *device, const char *mountPoint)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given a block device, find the mount table entry if that block device
|
||||
* is mounted.
|
||||
*
|
||||
* Given any other file (or directory), find the mount table entry for its
|
||||
* filesystem.
|
||||
*/
|
||||
extern struct mntent *findMountPoint(const char *name, const char *table)
|
||||
{
|
||||
struct stat s;
|
||||
dev_t mountDevice;
|
||||
FILE *mountTable;
|
||||
struct mntent *mountEntry;
|
||||
|
||||
if (stat(name, &s) != 0)
|
||||
return 0;
|
||||
|
||||
if ((s.st_mode & S_IFMT) == S_IFBLK)
|
||||
mountDevice = s.st_rdev;
|
||||
else
|
||||
mountDevice = s.st_dev;
|
||||
|
||||
|
||||
if ((mountTable = setmntent(table, "r")) == 0)
|
||||
return 0;
|
||||
|
||||
while ((mountEntry = getmntent(mountTable)) != 0) {
|
||||
if (strcmp(name, mountEntry->mnt_dir) == 0
|
||||
|| strcmp(name, mountEntry->mnt_fsname) == 0) /* String match. */
|
||||
break;
|
||||
if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == mountDevice) /* Match the device. */
|
||||
break;
|
||||
if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == mountDevice) /* Match the directory's mount point. */
|
||||
break;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
return mountEntry;
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern int df_main(int argc, char **argv)
|
||||
{
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
|
||||
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
|
||||
|
||||
/* Only compiled in if BB_MTAB is not defined */
|
||||
whine_if_fstab_is_missing();
|
||||
|
||||
if (argc > 1) {
|
||||
struct mntent *mountEntry;
|
||||
int status;
|
||||
|
||||
@@ -19,7 +19,7 @@ static const char dutmp_usage[] = "dutmp\n"
|
||||
"\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
|
||||
"\tdutmp /var/run/utmp\n";
|
||||
|
||||
static int dutmp_main (int argc, char **argv)
|
||||
extern int dutmp_main (int argc, char **argv)
|
||||
{
|
||||
|
||||
FILE *f = stdin;
|
||||
|
||||
+37
-35
@@ -45,9 +45,23 @@ static const char sed_usage[] =
|
||||
#else
|
||||
"This version of sed matches strings (not full regexps).\n";
|
||||
#endif
|
||||
|
||||
|
||||
static void do_sed(FILE *fp, char *needle, char *newNeedle, int ignoreCase, int printFlag, int quietFlag)
|
||||
{
|
||||
int foundOne=FALSE;
|
||||
char haystack[1024];
|
||||
|
||||
|
||||
while (fgets (haystack, 1023, fp)) {
|
||||
foundOne = replace_match(haystack, needle, newNeedle, ignoreCase);
|
||||
if (foundOne==TRUE && printFlag==TRUE) {
|
||||
fprintf(stdout, haystack);
|
||||
}
|
||||
if (quietFlag==FALSE) {
|
||||
fprintf(stdout, haystack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern int sed_main (int argc, char **argv)
|
||||
{
|
||||
@@ -56,11 +70,9 @@ extern int sed_main (int argc, char **argv)
|
||||
char *name;
|
||||
char *cp;
|
||||
int ignoreCase=FALSE;
|
||||
int foundOne=FALSE;
|
||||
int printFlag=FALSE;
|
||||
int quietFlag=FALSE;
|
||||
int stopNow;
|
||||
char *haystack;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
@@ -73,24 +85,23 @@ extern int sed_main (int argc, char **argv)
|
||||
cp = *argv++;
|
||||
stopNow=FALSE;
|
||||
|
||||
while (*++cp && stopNow==FALSE)
|
||||
while (*++cp && stopNow==FALSE) {
|
||||
switch (*cp) {
|
||||
case 'n':
|
||||
quietFlag = TRUE;
|
||||
break;
|
||||
case 'e':
|
||||
if (*(cp+1)==0 && --argc < 0) {
|
||||
fprintf(stderr, "A\n");
|
||||
usage( sed_usage);
|
||||
}
|
||||
cp = *argv++;
|
||||
if ( *++cp != 's')
|
||||
cp = *argv++;
|
||||
while( *cp ) {
|
||||
if (*cp == 's' && strlen(cp) > 3 && *(cp+1) == '/') {
|
||||
char* pos=needle=cp+2;
|
||||
for(;;) {
|
||||
pos = strchr(pos, '/');
|
||||
if (pos==NULL) {
|
||||
fprintf(stderr, "B\n");
|
||||
usage( sed_usage);
|
||||
}
|
||||
if (*(pos-1) == '\\') {
|
||||
@@ -104,7 +115,6 @@ extern int sed_main (int argc, char **argv)
|
||||
for(;;) {
|
||||
pos = strchr(pos, '/');
|
||||
if (pos==NULL) {
|
||||
fprintf(stderr, "C\n");
|
||||
usage( sed_usage);
|
||||
}
|
||||
if (*(pos-1) == '\\') {
|
||||
@@ -116,7 +126,6 @@ extern int sed_main (int argc, char **argv)
|
||||
*pos=0;
|
||||
if (pos+2 != 0) {
|
||||
while (*++pos) {
|
||||
fprintf(stderr, "pos='%s'\n", pos);
|
||||
switch (*pos) {
|
||||
case 'i':
|
||||
ignoreCase=TRUE;
|
||||
@@ -134,42 +143,35 @@ extern int sed_main (int argc, char **argv)
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
fprintf(stderr, "replace '%s' with '%s'\n", needle, newNeedle);
|
||||
//fprintf(stderr, "replace '%s' with '%s'\n", needle, newNeedle);
|
||||
stopNow=TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "D\n");
|
||||
usage(sed_usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (argc-- > 0) {
|
||||
name = *argv++;
|
||||
if (argc==0) {
|
||||
do_sed( stdin, needle, newNeedle, ignoreCase, printFlag, quietFlag);
|
||||
} else {
|
||||
while (argc-- > 0) {
|
||||
name = *argv++;
|
||||
|
||||
fp = fopen (name, "r");
|
||||
if (fp == NULL) {
|
||||
perror (name);
|
||||
continue;
|
||||
fp = fopen (name, "r");
|
||||
if (fp == NULL) {
|
||||
perror (name);
|
||||
continue;
|
||||
}
|
||||
|
||||
do_sed( fp, needle, newNeedle, ignoreCase, printFlag, quietFlag);
|
||||
|
||||
if (ferror (fp))
|
||||
perror (name);
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
haystack = (char*)malloc( 1024);
|
||||
while (fgets (haystack, 1023, fp)) {
|
||||
|
||||
foundOne = replace_match(haystack, needle, newNeedle, ignoreCase);
|
||||
if (foundOne==TRUE && printFlag==TRUE)
|
||||
fputs (haystack, stdout);
|
||||
if (quietFlag==FALSE)
|
||||
fputs (haystack, stdout);
|
||||
/* Avoid any mem leaks */
|
||||
free(haystack);
|
||||
haystack = (char*)malloc( BUF_SIZE);
|
||||
}
|
||||
|
||||
if (ferror (fp))
|
||||
perror (name);
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
exit( TRUE);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Name: busybox
|
||||
Version: 0.32
|
||||
Version: 0.33
|
||||
Release: 1
|
||||
Group: System/Utilities
|
||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
||||
@@ -7,7 +7,7 @@ Copyright: GPL
|
||||
Packager : Erik Andersen <andersen@lineo.com>
|
||||
Conflicts: fileutils grep shellutils
|
||||
Buildroot: /tmp/%{Name}-%{Version}
|
||||
Source: busybox-0.32.tar.gz
|
||||
Source: busybox-%{Version}.tar.gz
|
||||
|
||||
%Description
|
||||
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
|
||||
|
||||
+47
-37
@@ -40,21 +40,46 @@ static const char grep_usage[] =
|
||||
#if defined BB_REGEXP
|
||||
"This version of grep matches full regexps.\n";
|
||||
#else
|
||||
"This version of grep matches strings (not full regexps).\n";
|
||||
"This version of grep matches strings (not regexps).\n";
|
||||
#endif
|
||||
|
||||
|
||||
static void do_grep(FILE *fp, char* needle, char *fileName, int tellName, int ignoreCase, int tellLine)
|
||||
{
|
||||
char *cp;
|
||||
long line = 0;
|
||||
char haystack[BUF_SIZE];
|
||||
|
||||
while (fgets (haystack, sizeof (haystack), fp)) {
|
||||
line++;
|
||||
cp = &haystack[strlen (haystack) - 1];
|
||||
|
||||
if (*cp != '\n')
|
||||
fprintf (stderr, "%s: Line too long\n", fileName);
|
||||
|
||||
if (find_match(haystack, needle, ignoreCase) == TRUE) {
|
||||
if (tellName==TRUE)
|
||||
printf ("%s:", fileName);
|
||||
|
||||
if (tellLine==TRUE)
|
||||
printf ("%ld:", line);
|
||||
|
||||
fputs (haystack, stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern int grep_main (int argc, char **argv)
|
||||
{
|
||||
FILE *fp;
|
||||
char *needle;
|
||||
char *name;
|
||||
char *cp;
|
||||
int tellName=TRUE;
|
||||
char *needle;
|
||||
char *fileName;
|
||||
int tellName=FALSE;
|
||||
int ignoreCase=FALSE;
|
||||
int tellLine=FALSE;
|
||||
long line;
|
||||
char haystack[BUF_SIZE];
|
||||
|
||||
|
||||
ignoreCase = FALSE;
|
||||
tellLine = FALSE;
|
||||
@@ -76,7 +101,7 @@ extern int grep_main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
tellName = FALSE;
|
||||
tellName = TRUE;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
@@ -91,39 +116,24 @@ extern int grep_main (int argc, char **argv)
|
||||
needle = *argv++;
|
||||
argc--;
|
||||
|
||||
while (argc-- > 0) {
|
||||
name = *argv++;
|
||||
if (argc==0) {
|
||||
do_grep( stdin, needle, "stdin", FALSE, ignoreCase, tellLine);
|
||||
} else {
|
||||
while (argc-- > 0) {
|
||||
fileName = *argv++;
|
||||
|
||||
fp = fopen (name, "r");
|
||||
if (fp == NULL) {
|
||||
perror (name);
|
||||
continue;
|
||||
}
|
||||
|
||||
line = 0;
|
||||
|
||||
while (fgets (haystack, sizeof (haystack), fp)) {
|
||||
line++;
|
||||
cp = &haystack[strlen (haystack) - 1];
|
||||
|
||||
if (*cp != '\n')
|
||||
fprintf (stderr, "%s: Line too long\n", name);
|
||||
|
||||
if (find_match(haystack, needle, ignoreCase) == TRUE) {
|
||||
if (tellName==TRUE)
|
||||
printf ("%s: ", name);
|
||||
|
||||
if (tellLine==TRUE)
|
||||
printf ("%ld: ", line);
|
||||
|
||||
fputs (haystack, stdout);
|
||||
fp = fopen (fileName, "r");
|
||||
if (fp == NULL) {
|
||||
perror (fileName);
|
||||
continue;
|
||||
}
|
||||
|
||||
do_grep( fp, needle, fileName, tellName, ignoreCase, tellLine);
|
||||
|
||||
if (ferror (fp))
|
||||
perror (fileName);
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
if (ferror (fp))
|
||||
perror (name);
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
exit( TRUE);
|
||||
}
|
||||
|
||||
@@ -40,21 +40,46 @@ static const char grep_usage[] =
|
||||
#if defined BB_REGEXP
|
||||
"This version of grep matches full regexps.\n";
|
||||
#else
|
||||
"This version of grep matches strings (not full regexps).\n";
|
||||
"This version of grep matches strings (not regexps).\n";
|
||||
#endif
|
||||
|
||||
|
||||
static void do_grep(FILE *fp, char* needle, char *fileName, int tellName, int ignoreCase, int tellLine)
|
||||
{
|
||||
char *cp;
|
||||
long line = 0;
|
||||
char haystack[BUF_SIZE];
|
||||
|
||||
while (fgets (haystack, sizeof (haystack), fp)) {
|
||||
line++;
|
||||
cp = &haystack[strlen (haystack) - 1];
|
||||
|
||||
if (*cp != '\n')
|
||||
fprintf (stderr, "%s: Line too long\n", fileName);
|
||||
|
||||
if (find_match(haystack, needle, ignoreCase) == TRUE) {
|
||||
if (tellName==TRUE)
|
||||
printf ("%s:", fileName);
|
||||
|
||||
if (tellLine==TRUE)
|
||||
printf ("%ld:", line);
|
||||
|
||||
fputs (haystack, stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern int grep_main (int argc, char **argv)
|
||||
{
|
||||
FILE *fp;
|
||||
char *needle;
|
||||
char *name;
|
||||
char *cp;
|
||||
int tellName=TRUE;
|
||||
char *needle;
|
||||
char *fileName;
|
||||
int tellName=FALSE;
|
||||
int ignoreCase=FALSE;
|
||||
int tellLine=FALSE;
|
||||
long line;
|
||||
char haystack[BUF_SIZE];
|
||||
|
||||
|
||||
ignoreCase = FALSE;
|
||||
tellLine = FALSE;
|
||||
@@ -76,7 +101,7 @@ extern int grep_main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
tellName = FALSE;
|
||||
tellName = TRUE;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
@@ -91,39 +116,24 @@ extern int grep_main (int argc, char **argv)
|
||||
needle = *argv++;
|
||||
argc--;
|
||||
|
||||
while (argc-- > 0) {
|
||||
name = *argv++;
|
||||
if (argc==0) {
|
||||
do_grep( stdin, needle, "stdin", FALSE, ignoreCase, tellLine);
|
||||
} else {
|
||||
while (argc-- > 0) {
|
||||
fileName = *argv++;
|
||||
|
||||
fp = fopen (name, "r");
|
||||
if (fp == NULL) {
|
||||
perror (name);
|
||||
continue;
|
||||
}
|
||||
|
||||
line = 0;
|
||||
|
||||
while (fgets (haystack, sizeof (haystack), fp)) {
|
||||
line++;
|
||||
cp = &haystack[strlen (haystack) - 1];
|
||||
|
||||
if (*cp != '\n')
|
||||
fprintf (stderr, "%s: Line too long\n", name);
|
||||
|
||||
if (find_match(haystack, needle, ignoreCase) == TRUE) {
|
||||
if (tellName==TRUE)
|
||||
printf ("%s: ", name);
|
||||
|
||||
if (tellLine==TRUE)
|
||||
printf ("%ld: ", line);
|
||||
|
||||
fputs (haystack, stdout);
|
||||
fp = fopen (fileName, "r");
|
||||
if (fp == NULL) {
|
||||
perror (fileName);
|
||||
continue;
|
||||
}
|
||||
|
||||
do_grep( fp, needle, fileName, tellName, ignoreCase, tellLine);
|
||||
|
||||
if (ferror (fp))
|
||||
perror (fileName);
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
if (ferror (fp))
|
||||
perror (name);
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
exit( TRUE);
|
||||
}
|
||||
|
||||
@@ -380,7 +380,6 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */
|
||||
# undef LZW
|
||||
#endif
|
||||
|
||||
/* $Id: gzip.c,v 1.5 1999/10/23 07:09:58 andersen Exp $ */
|
||||
/* tailor.h -- target dependent definitions
|
||||
* Copyright (C) 1992-1993 Jean-loup Gailly.
|
||||
* This is free software; you can redistribute it and/or modify it under the
|
||||
@@ -391,7 +390,6 @@ extern int block_mode; /* block compress mode -C compatible with 2.0 */
|
||||
* The target dependent functions should be defined in tailor.c.
|
||||
*/
|
||||
|
||||
/* $Id: gzip.c,v 1.5 1999/10/23 07:09:58 andersen Exp $ */
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
static char *console = VT_CONSOLE;
|
||||
static char *second_console = VT_SECONDARY;
|
||||
static char *log = VT_LOG;
|
||||
|
||||
static int kernel_version = 0;
|
||||
|
||||
|
||||
/* try to open up the specified device */
|
||||
@@ -88,8 +88,14 @@ void message(int device, char *fmt, ...)
|
||||
|
||||
/* Take full control of the log tty, and never close it.
|
||||
* It's mine, all mine! Muhahahaha! */
|
||||
if (log_fd==-1) {
|
||||
if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) {
|
||||
if (log_fd < 0) {
|
||||
if (log == NULL) {
|
||||
/* don't even try to log, because there is no such console */
|
||||
log_fd = -2;
|
||||
/* log to main console instead */
|
||||
device = CONSOLE;
|
||||
}
|
||||
else if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) {
|
||||
log_fd=-1;
|
||||
fprintf(stderr, "Bummer, can't write to log on %s!\r\n", log);
|
||||
fflush(stderr);
|
||||
@@ -97,7 +103,7 @@ void message(int device, char *fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
if ( (device & LOG) && (log_fd != -1) ) {
|
||||
if ( (device & LOG) && (log_fd >= 0) ) {
|
||||
va_start(arguments, fmt);
|
||||
vdprintf(log_fd, fmt, arguments);
|
||||
va_end(arguments);
|
||||
@@ -180,25 +186,40 @@ static void console_init()
|
||||
int fd;
|
||||
int tried_devcons = 0;
|
||||
int tried_vtprimary = 0;
|
||||
struct serial_struct sr;
|
||||
char *s;
|
||||
|
||||
if ((s = getenv("CONSOLE")) != NULL) {
|
||||
console = s;
|
||||
/* Apparently the sparc does wierd things... */
|
||||
#if defined (__sparc__)
|
||||
if (strncmp( s, "/dev/tty", 8 )==0) {
|
||||
switch( s[8]) {
|
||||
case 'a':
|
||||
s=SERIAL_CON0;
|
||||
break;
|
||||
case 'b':
|
||||
s=SERIAL_CON1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if #cpu(sparc)
|
||||
/* sparc kernel supports console=tty[ab] parameter which is also
|
||||
* passed to init, so catch it here */
|
||||
else if ((s = getenv("console")) != NULL) {
|
||||
/* remap tty[ab] to /dev/ttyS[01] */
|
||||
if (strcmp( s, "ttya" )==0)
|
||||
console = SERIAL_CON0;
|
||||
else if (strcmp( s, "ttyb" )==0)
|
||||
console = SERIAL_CON1;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
console = VT_CONSOLE;
|
||||
tried_devcons++;
|
||||
else {
|
||||
struct vt_stat vt;
|
||||
static char the_console[13];
|
||||
|
||||
console = the_console;
|
||||
/* 2.2 kernels: identify the real console backend and try to use it */
|
||||
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
|
||||
/* this is a serial console */
|
||||
snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line );
|
||||
}
|
||||
else if (ioctl(0, VT_GETSTATE, &vt) == 0) {
|
||||
/* this is linux virtual tty */
|
||||
snprintf( the_console, sizeof the_console, "/dev/tty%d", vt.v_active );
|
||||
} else {
|
||||
console = VT_CONSOLE;
|
||||
tried_devcons++;
|
||||
}
|
||||
}
|
||||
|
||||
while ((fd = open(console, O_RDONLY | O_NONBLOCK)) < 0) {
|
||||
@@ -219,8 +240,15 @@ static void console_init()
|
||||
if (fd < 0)
|
||||
/* Perhaps we should panic here? */
|
||||
console = "/dev/null";
|
||||
else
|
||||
else {
|
||||
/* check for serial console and disable logging to tty3 & running a
|
||||
* shell to tty2 */
|
||||
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
|
||||
log = NULL;
|
||||
second_console = NULL;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
message(LOG, "console=%s\n", console );
|
||||
}
|
||||
|
||||
@@ -350,9 +378,9 @@ static void shutdown_system(void)
|
||||
waitfor(run( swap_off_cmd, console, FALSE));
|
||||
waitfor(run( umount_cmd, console, FALSE));
|
||||
sync();
|
||||
message(CONSOLE, "Skipping bdflush\r\n");
|
||||
if (get_kernel_revision() <= 2 * 65536 + 2 * 256 + 11) {
|
||||
if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) {
|
||||
/* bdflush, kupdate not needed for kernels >2.2.11 */
|
||||
message(CONSOLE, "Flushing buffers.\r\n");
|
||||
bdflush(1, 0);
|
||||
sync();
|
||||
}
|
||||
@@ -445,9 +473,10 @@ extern int init_main(int argc, char **argv)
|
||||
|
||||
|
||||
/* Mount /proc */
|
||||
if (mount ("proc", "/proc", "proc", 0, 0) == 0)
|
||||
if (mount ("proc", "/proc", "proc", 0, 0) == 0) {
|
||||
message(CONSOLE|LOG, "Mounting /proc: done.\n");
|
||||
else
|
||||
kernel_version = get_kernel_revision();
|
||||
} else
|
||||
message(CONSOLE|LOG, "Mounting /proc: failed!\n");
|
||||
|
||||
/* Make sure there is enough memory to do something useful. */
|
||||
@@ -471,7 +500,7 @@ extern int init_main(int argc, char **argv)
|
||||
if (pid1 == 0 && tty0_commands) {
|
||||
pid1 = run(tty0_commands, console, wait_for_enter);
|
||||
}
|
||||
if (pid2 == 0 && tty1_commands) {
|
||||
if (pid2 == 0 && tty1_commands && second_console) {
|
||||
pid2 = run(tty1_commands, second_console, TRUE);
|
||||
}
|
||||
wpid = wait(&status);
|
||||
|
||||
+53
-24
@@ -56,7 +56,7 @@
|
||||
static char *console = VT_CONSOLE;
|
||||
static char *second_console = VT_SECONDARY;
|
||||
static char *log = VT_LOG;
|
||||
|
||||
static int kernel_version = 0;
|
||||
|
||||
|
||||
/* try to open up the specified device */
|
||||
@@ -88,8 +88,14 @@ void message(int device, char *fmt, ...)
|
||||
|
||||
/* Take full control of the log tty, and never close it.
|
||||
* It's mine, all mine! Muhahahaha! */
|
||||
if (log_fd==-1) {
|
||||
if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) {
|
||||
if (log_fd < 0) {
|
||||
if (log == NULL) {
|
||||
/* don't even try to log, because there is no such console */
|
||||
log_fd = -2;
|
||||
/* log to main console instead */
|
||||
device = CONSOLE;
|
||||
}
|
||||
else if ((log_fd = device_open(log, O_RDWR|O_NDELAY)) < 0) {
|
||||
log_fd=-1;
|
||||
fprintf(stderr, "Bummer, can't write to log on %s!\r\n", log);
|
||||
fflush(stderr);
|
||||
@@ -97,7 +103,7 @@ void message(int device, char *fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
if ( (device & LOG) && (log_fd != -1) ) {
|
||||
if ( (device & LOG) && (log_fd >= 0) ) {
|
||||
va_start(arguments, fmt);
|
||||
vdprintf(log_fd, fmt, arguments);
|
||||
va_end(arguments);
|
||||
@@ -180,25 +186,40 @@ static void console_init()
|
||||
int fd;
|
||||
int tried_devcons = 0;
|
||||
int tried_vtprimary = 0;
|
||||
struct serial_struct sr;
|
||||
char *s;
|
||||
|
||||
if ((s = getenv("CONSOLE")) != NULL) {
|
||||
console = s;
|
||||
/* Apparently the sparc does wierd things... */
|
||||
#if defined (__sparc__)
|
||||
if (strncmp( s, "/dev/tty", 8 )==0) {
|
||||
switch( s[8]) {
|
||||
case 'a':
|
||||
s=SERIAL_CON0;
|
||||
break;
|
||||
case 'b':
|
||||
s=SERIAL_CON1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if #cpu(sparc)
|
||||
/* sparc kernel supports console=tty[ab] parameter which is also
|
||||
* passed to init, so catch it here */
|
||||
else if ((s = getenv("console")) != NULL) {
|
||||
/* remap tty[ab] to /dev/ttyS[01] */
|
||||
if (strcmp( s, "ttya" )==0)
|
||||
console = SERIAL_CON0;
|
||||
else if (strcmp( s, "ttyb" )==0)
|
||||
console = SERIAL_CON1;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
console = VT_CONSOLE;
|
||||
tried_devcons++;
|
||||
else {
|
||||
struct vt_stat vt;
|
||||
static char the_console[13];
|
||||
|
||||
console = the_console;
|
||||
/* 2.2 kernels: identify the real console backend and try to use it */
|
||||
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
|
||||
/* this is a serial console */
|
||||
snprintf( the_console, sizeof the_console, "/dev/ttyS%d", sr.line );
|
||||
}
|
||||
else if (ioctl(0, VT_GETSTATE, &vt) == 0) {
|
||||
/* this is linux virtual tty */
|
||||
snprintf( the_console, sizeof the_console, "/dev/tty%d", vt.v_active );
|
||||
} else {
|
||||
console = VT_CONSOLE;
|
||||
tried_devcons++;
|
||||
}
|
||||
}
|
||||
|
||||
while ((fd = open(console, O_RDONLY | O_NONBLOCK)) < 0) {
|
||||
@@ -219,8 +240,15 @@ static void console_init()
|
||||
if (fd < 0)
|
||||
/* Perhaps we should panic here? */
|
||||
console = "/dev/null";
|
||||
else
|
||||
else {
|
||||
/* check for serial console and disable logging to tty3 & running a
|
||||
* shell to tty2 */
|
||||
if (ioctl(0,TIOCGSERIAL,&sr) == 0) {
|
||||
log = NULL;
|
||||
second_console = NULL;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
message(LOG, "console=%s\n", console );
|
||||
}
|
||||
|
||||
@@ -350,9 +378,9 @@ static void shutdown_system(void)
|
||||
waitfor(run( swap_off_cmd, console, FALSE));
|
||||
waitfor(run( umount_cmd, console, FALSE));
|
||||
sync();
|
||||
message(CONSOLE, "Skipping bdflush\r\n");
|
||||
if (get_kernel_revision() <= 2 * 65536 + 2 * 256 + 11) {
|
||||
if (kernel_version > 0 && kernel_version <= 2 * 65536 + 2 * 256 + 11) {
|
||||
/* bdflush, kupdate not needed for kernels >2.2.11 */
|
||||
message(CONSOLE, "Flushing buffers.\r\n");
|
||||
bdflush(1, 0);
|
||||
sync();
|
||||
}
|
||||
@@ -445,9 +473,10 @@ extern int init_main(int argc, char **argv)
|
||||
|
||||
|
||||
/* Mount /proc */
|
||||
if (mount ("proc", "/proc", "proc", 0, 0) == 0)
|
||||
if (mount ("proc", "/proc", "proc", 0, 0) == 0) {
|
||||
message(CONSOLE|LOG, "Mounting /proc: done.\n");
|
||||
else
|
||||
kernel_version = get_kernel_revision();
|
||||
} else
|
||||
message(CONSOLE|LOG, "Mounting /proc: failed!\n");
|
||||
|
||||
/* Make sure there is enough memory to do something useful. */
|
||||
@@ -471,7 +500,7 @@ extern int init_main(int argc, char **argv)
|
||||
if (pid1 == 0 && tty0_commands) {
|
||||
pid1 = run(tty0_commands, console, wait_for_enter);
|
||||
}
|
||||
if (pid2 == 0 && tty1_commands) {
|
||||
if (pid2 == 0 && tty1_commands && second_console) {
|
||||
pid2 = run(tty1_commands, second_console, TRUE);
|
||||
}
|
||||
wpid = wait(&status);
|
||||
|
||||
+9
-1
@@ -29,6 +29,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <mntent.h>
|
||||
|
||||
|
||||
/* Some useful definitions */
|
||||
@@ -145,12 +146,19 @@ extern void my_getpwuid(char* name, uid_t uid);
|
||||
extern void my_getgrgid(char* group, gid_t gid);
|
||||
extern int get_kernel_revision();
|
||||
extern int get_console_fd(char* tty_name);
|
||||
|
||||
extern struct mntent *findMountPoint(const char *name, const char *table);
|
||||
extern void write_mtab(char* blockDevice, char* directory,
|
||||
char* filesystemType, long flags, char* string_flags);
|
||||
extern void erase_mtab(const char * name);
|
||||
|
||||
|
||||
#if defined BB_MTAB
|
||||
#define whine_if_fstab_is_missing() {}
|
||||
#else
|
||||
extern void whine_if_fstab_is_missing();
|
||||
#endif
|
||||
|
||||
|
||||
#if defined (BB_FSCK_MINIX) || defined (BB_MKFS_MINIX)
|
||||
|
||||
static inline int bit(char * addr,unsigned int nr)
|
||||
|
||||
@@ -27,23 +27,21 @@
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
static const char ln_usage[] = "ln [-s] [-f] original-name additional-name\n"
|
||||
"\n"
|
||||
"\tAdd a new name that refers to the same file as \"original-name\"\n"
|
||||
"\n"
|
||||
"\t-s:\tUse a \"symbolic\" link, instead of a \"hard\" link.\n"
|
||||
"\t-f:\tRemove existing destination files.\n";
|
||||
static const char ln_usage[] = "ln [OPTION] TARGET... LINK_NAME|DIRECTORY\n"
|
||||
"Create a link named LINK_NAME or DIRECTORY to the specified TARGET\n"
|
||||
"\nOptions:\n"
|
||||
"\t-s\tmake symbolic links instead of hard links\n"
|
||||
"\t-f\tremove existing destination files\n";
|
||||
|
||||
|
||||
static int symlinkFlag = FALSE;
|
||||
static int removeoldFlag = FALSE;
|
||||
static const char *destName;
|
||||
|
||||
|
||||
extern int ln_main(int argc, char **argv)
|
||||
{
|
||||
int status;
|
||||
char newdestName[NAME_MAX];
|
||||
static char* linkName;
|
||||
|
||||
if (argc < 3) {
|
||||
usage (ln_usage);
|
||||
@@ -69,30 +67,27 @@ extern int ln_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
destName = argv[argc - 1];
|
||||
linkName = argv[argc - 1];
|
||||
|
||||
if ((argc > 3) && !(isDirectory(destName))) {
|
||||
fprintf(stderr, "%s: not a directory\n", destName);
|
||||
if ((argc > 3) && !(isDirectory(linkName))) {
|
||||
fprintf(stderr, "%s: not a directory\n", linkName);
|
||||
exit (FALSE);
|
||||
}
|
||||
|
||||
while (argc-- >= 2) {
|
||||
strcpy(newdestName, destName);
|
||||
strcat(newdestName, (*argv)+(strlen(*(++argv))));
|
||||
|
||||
if (removeoldFlag==TRUE ) {
|
||||
status = ( unlink(newdestName) && errno != ENOENT );
|
||||
status = ( unlink(linkName) && errno != ENOENT );
|
||||
if ( status != 0 ) {
|
||||
perror(newdestName);
|
||||
perror(linkName);
|
||||
exit( FALSE);
|
||||
}
|
||||
}
|
||||
if ( symlinkFlag==TRUE)
|
||||
status = symlink(*argv, newdestName);
|
||||
status = symlink(*argv, linkName);
|
||||
else
|
||||
status = link(*argv, newdestName);
|
||||
status = link(*argv, linkName);
|
||||
if ( status != 0 ) {
|
||||
perror(newdestName);
|
||||
perror(linkName);
|
||||
exit( FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
* 1. requires lstat (BSD) - how do you do it without?
|
||||
*/
|
||||
|
||||
//#define FEATURE_USERNAME /* show username/groupnames (libc6 uses NSS) */
|
||||
#define FEATURE_USERNAME /* show username/groupnames (bypasses libc6 NSS) */
|
||||
#define FEATURE_TIMESTAMPS /* show file timestamps */
|
||||
#define FEATURE_AUTOWIDTH /* calculate terminal & column widths */
|
||||
#define FEATURE_FILETYPECHAR /* enable -p and -F */
|
||||
@@ -64,10 +64,6 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#ifdef FEATURE_USERNAME
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#endif
|
||||
#ifdef FEATURE_TIMESTAMPS
|
||||
#include <time.h>
|
||||
#endif
|
||||
@@ -83,27 +79,6 @@
|
||||
#define MINOR(dev) ((dev)&0xff)
|
||||
#endif
|
||||
|
||||
#define MODE1 "rwxrwxrwx"
|
||||
#define MODE0 "---------"
|
||||
#define SMODE1 "..s..s..t"
|
||||
#define SMODE0 "..S..S..T"
|
||||
|
||||
/* The 9 mode bits to test */
|
||||
|
||||
static const mode_t MBIT[] = {
|
||||
S_IRUSR, S_IWUSR, S_IXUSR,
|
||||
S_IRGRP, S_IWGRP, S_IXGRP,
|
||||
S_IROTH, S_IWOTH, S_IXOTH
|
||||
};
|
||||
|
||||
/* The special bits. If set, display SMODE0/1 instead of MODE0/1 */
|
||||
|
||||
static const mode_t SBIT[] = {
|
||||
0, 0, S_ISUID,
|
||||
0, 0, S_ISGID,
|
||||
0, 0, S_ISVTX
|
||||
};
|
||||
|
||||
#define FMT_AUTO 0
|
||||
#define FMT_LONG 1 /* one record per line, extended info */
|
||||
#define FMT_SINGLE 2 /* one record per line */
|
||||
@@ -206,7 +181,7 @@ static char append_char(mode_t mode)
|
||||
**
|
||||
**/
|
||||
|
||||
static void list_single(const char *name, struct stat *info)
|
||||
static void list_single(const char *name, struct stat *info, const char *fullname)
|
||||
{
|
||||
char scratch[PATH_MAX];
|
||||
short len = strlen(name);
|
||||
@@ -216,45 +191,35 @@ static void list_single(const char *name, struct stat *info)
|
||||
|
||||
if (display_fmt == FMT_LONG) {
|
||||
mode_t mode = info->st_mode;
|
||||
int i;
|
||||
|
||||
scratch[0] = TYPECHAR(mode);
|
||||
for (i=0; i<9; i++)
|
||||
if (mode & SBIT[i])
|
||||
scratch[i+1] = (mode & MBIT[i])
|
||||
? SMODE1[i]
|
||||
: SMODE0[i];
|
||||
else
|
||||
scratch[i+1] = (mode & MBIT[i])
|
||||
? MODE1[i]
|
||||
: MODE0[i];
|
||||
newline();
|
||||
wr(scratch, 10);
|
||||
wr(modeString(mode), 10);
|
||||
column=10;
|
||||
writenum((long)info->st_nlink,(short)4);
|
||||
writenum((long)info->st_nlink,(short)5);
|
||||
fputs(" ", stdout);
|
||||
#ifdef FEATURE_USERNAME
|
||||
if (!(opts & DISP_NUMERIC)) {
|
||||
struct passwd *pw = getpwuid(info->st_uid);
|
||||
if (pw)
|
||||
fputs(pw->pw_name, stdout);
|
||||
scratch[8]='\0';
|
||||
my_getpwuid( scratch, info->st_uid);
|
||||
if (*scratch)
|
||||
fputs(scratch, stdout);
|
||||
else
|
||||
writenum((long)info->st_uid,(short)0);
|
||||
} else
|
||||
#endif
|
||||
writenum((long)info->st_uid,(short)0);
|
||||
tab(24);
|
||||
tab(16);
|
||||
#ifdef FEATURE_USERNAME
|
||||
if (!(opts & DISP_NUMERIC)) {
|
||||
struct group *gr = getgrgid(info->st_gid);
|
||||
if (gr)
|
||||
fputs(gr->gr_name, stdout);
|
||||
scratch[8]='\0';
|
||||
my_getgrgid( scratch, info->st_gid);
|
||||
if (*scratch)
|
||||
fputs(scratch, stdout);
|
||||
else
|
||||
writenum((long)info->st_gid,(short)0);
|
||||
} else
|
||||
#endif
|
||||
writenum((long)info->st_gid,(short)0);
|
||||
tab(33);
|
||||
tab(17);
|
||||
if (S_ISBLK(mode) || S_ISCHR(mode)) {
|
||||
writenum((long)MAJOR(info->st_rdev),(short)3);
|
||||
fputs(", ", stdout);
|
||||
@@ -297,12 +262,12 @@ static void list_single(const char *name, struct stat *info)
|
||||
wr(name, len);
|
||||
if (S_ISLNK(mode)) {
|
||||
wr(" -> ", 4);
|
||||
len = readlink(name, scratch, sizeof scratch);
|
||||
len = readlink(fullname, scratch, sizeof scratch);
|
||||
if (len > 0) fwrite(scratch, 1, len, stdout);
|
||||
#ifdef FEATURE_FILETYPECHAR
|
||||
/* show type of destination */
|
||||
if (opts & DISP_FTYPE) {
|
||||
if (!stat(name, info)) {
|
||||
if (!stat(fullname, info)) {
|
||||
append = append_char(info->st_mode);
|
||||
if (append)
|
||||
fputc(append, stdout);
|
||||
@@ -372,7 +337,7 @@ static int list_item(const char *name)
|
||||
|
||||
if (!S_ISDIR(info.st_mode) ||
|
||||
(opts & DIR_NOLIST)) {
|
||||
list_single(name, &info);
|
||||
list_single(name, &info, name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -424,7 +389,7 @@ static int list_item(const char *name)
|
||||
strcpy(fnend, entry->d_name);
|
||||
if (lstat(fullname, &info))
|
||||
goto direrr; /* (shouldn't fail) */
|
||||
list_single(entry->d_name, &info);
|
||||
list_single(entry->d_name, &info, fullname);
|
||||
}
|
||||
closedir(dir);
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ static const char dutmp_usage[] = "dutmp\n"
|
||||
"\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
|
||||
"\tdutmp /var/run/utmp\n";
|
||||
|
||||
static int dutmp_main (int argc, char **argv)
|
||||
extern int dutmp_main (int argc, char **argv)
|
||||
{
|
||||
|
||||
FILE *f = stdin;
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
|
||||
|
||||
/* Turning this off makes things a bit smaller (and less pretty) */
|
||||
#define BB_MORE_TERM
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
/* Turning this off makes things a bit smaller (and less pretty) */
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
|
||||
|
||||
|
||||
@@ -33,19 +35,16 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
static const char more_usage[] = "[file ...]";
|
||||
|
||||
|
||||
/* ED: sparc termios is broken: revert back to old termio handling. */
|
||||
#ifdef BB_MORE_TERM
|
||||
#ifdef BB_FEATURE_USE_TERMIOS
|
||||
|
||||
|
||||
#if defined (__sparc__)
|
||||
#if #cpu(sparc)
|
||||
# define USE_OLD_TERMIO
|
||||
# include <termio.h>
|
||||
# include <sys/ioctl.h>
|
||||
# define termios termio
|
||||
# define stty(fd,argp) ioctl(fd,TCSETAF,argp)
|
||||
#else
|
||||
@@ -58,24 +57,43 @@ static const char more_usage[] = "[file ...]";
|
||||
|
||||
void gotsig(int sig) {
|
||||
stty(fileno(cin), &initial_settings);
|
||||
fprintf(stdout, "\n");
|
||||
exit( TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define TERMINAL_WIDTH 79 /* not 80 in case terminal has linefold bug */
|
||||
#define TERMINAL_HEIGHT 24
|
||||
|
||||
|
||||
#if defined BB_FEATURE_AUTOWIDTH && ! defined USE_OLD_TERMIO
|
||||
static int terminal_width = 0, terminal_height = 0;
|
||||
#else
|
||||
#define terminal_width TERMINAL_WIDTH
|
||||
#define terminal_height TERMINAL_HEIGHT
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
extern int more_main(int argc, char **argv)
|
||||
{
|
||||
int c, lines=0, input=0;
|
||||
int next_page=0;
|
||||
struct stat st;
|
||||
FILE *file;
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
struct winsize win;
|
||||
#endif
|
||||
|
||||
if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) {
|
||||
usage (more_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
while (argc >= 0) {
|
||||
if ( argc > 0 && (strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0) ) {
|
||||
usage (more_usage);
|
||||
}
|
||||
do {
|
||||
if (argc==0) {
|
||||
file = stdin;
|
||||
}
|
||||
@@ -88,7 +106,7 @@ extern int more_main(int argc, char **argv)
|
||||
}
|
||||
fstat(fileno(file), &st);
|
||||
|
||||
#ifdef BB_MORE_TERM
|
||||
#ifdef BB_FEATURE_USE_TERMIOS
|
||||
cin = fopen("/dev/tty", "r");
|
||||
if (!cin)
|
||||
cin = fopen("/dev/console", "r");
|
||||
@@ -101,8 +119,18 @@ extern int more_main(int argc, char **argv)
|
||||
new_settings.c_lflag &= ~ICANON;
|
||||
new_settings.c_lflag &= ~ECHO;
|
||||
stty(fileno(cin), &new_settings);
|
||||
|
||||
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &win);
|
||||
if (win.ws_row > 4)
|
||||
terminal_height = win.ws_row - 2;
|
||||
if (win.ws_col > 0)
|
||||
terminal_width = win.ws_col - 1;
|
||||
#endif
|
||||
|
||||
(void) signal(SIGINT, gotsig);
|
||||
(void) signal(SIGQUIT, gotsig);
|
||||
(void) signal(SIGTERM, gotsig);
|
||||
|
||||
#endif
|
||||
while ((c = getc(file)) != EOF) {
|
||||
@@ -117,7 +145,7 @@ extern int more_main(int argc, char **argv)
|
||||
st.st_size);
|
||||
}
|
||||
len += fprintf(stdout, "%s",
|
||||
#ifdef BB_MORE_TERM
|
||||
#ifdef BB_FEATURE_USE_TERMIOS
|
||||
""
|
||||
#else
|
||||
"\n"
|
||||
@@ -127,34 +155,40 @@ extern int more_main(int argc, char **argv)
|
||||
fflush(stdout);
|
||||
input = getc( cin);
|
||||
|
||||
#ifdef BB_MORE_TERM
|
||||
#ifdef BB_FEATURE_USE_TERMIOS
|
||||
/* Erase the "More" message */
|
||||
while(len-- > 0)
|
||||
while(--len >= 0)
|
||||
putc('\b', stdout);
|
||||
while(len++ < 79)
|
||||
while(++len <= terminal_width)
|
||||
putc(' ', stdout);
|
||||
while(len-- > 0)
|
||||
while(--len >= 0)
|
||||
putc('\b', stdout);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
}
|
||||
if (input=='q')
|
||||
goto end;
|
||||
if (input==' ' && c == '\n' )
|
||||
next_page = 1;
|
||||
if ( c == '\n' && ++lines == 24 )
|
||||
next_page = 1;
|
||||
if (c == '\n' ) {
|
||||
switch(input) {
|
||||
case 'q':
|
||||
goto end;
|
||||
case '\n':
|
||||
/* increment by just one line if we are at
|
||||
* the end of this line*/
|
||||
next_page = 1;
|
||||
break;
|
||||
}
|
||||
if ( ++lines == terminal_height )
|
||||
next_page = 1;
|
||||
}
|
||||
putc(c, stdout);
|
||||
}
|
||||
fclose(file);
|
||||
fflush(stdout);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
} while (--argc > 0);
|
||||
end:
|
||||
#ifdef BB_MORE_TERM
|
||||
#ifdef BB_FEATURE_USE_TERMIOS
|
||||
gotsig(0);
|
||||
#endif
|
||||
exit(TRUE);
|
||||
|
||||
@@ -208,14 +208,13 @@ extern int mount_main (int argc, char **argv)
|
||||
char *filesystemType = "auto";
|
||||
char *device = NULL;
|
||||
char *directory = NULL;
|
||||
struct stat statBuf;
|
||||
int all = FALSE;
|
||||
int fakeIt = FALSE;
|
||||
int useMtab = TRUE;
|
||||
int i;
|
||||
|
||||
if (stat("/etc/fstab", &statBuf) < 0)
|
||||
fprintf(stderr, "/etc/fstab file missing -- Please install one.\n\n");
|
||||
/* Only compiled in if BB_MTAB is not defined */
|
||||
whine_if_fstab_is_missing();
|
||||
|
||||
if (argc == 1) {
|
||||
FILE *mountTable = setmntent (mtab_file, "r");
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
#include "internal.h"
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
extern const char mtab_file[]; /* Defined in utility.c */
|
||||
|
||||
static char *
|
||||
stralloc(const char * string)
|
||||
{
|
||||
int length = strlen(string) + 1;
|
||||
char * n = malloc(length);
|
||||
memcpy(n, string, length);
|
||||
return n;
|
||||
}
|
||||
|
||||
extern void
|
||||
erase_mtab(const char * name)
|
||||
{
|
||||
struct mntent entries[20];
|
||||
int count = 0;
|
||||
FILE *mountTable = setmntent(mtab_file, "r");
|
||||
struct mntent * m;
|
||||
|
||||
if ( mountTable == 0
|
||||
&& (mountTable = setmntent("/proc/mounts", "r")) == 0 ) {
|
||||
perror(mtab_file);
|
||||
return;
|
||||
}
|
||||
|
||||
while ( (m = getmntent(mountTable)) != 0 ) {
|
||||
entries[count].mnt_fsname = stralloc(m->mnt_fsname);
|
||||
entries[count].mnt_dir = stralloc(m->mnt_dir);
|
||||
entries[count].mnt_type = stralloc(m->mnt_type);
|
||||
entries[count].mnt_opts = stralloc(m->mnt_opts);
|
||||
entries[count].mnt_freq = m->mnt_freq;
|
||||
entries[count].mnt_passno = m->mnt_passno;
|
||||
count++;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
if ( (mountTable = setmntent(mtab_file, "w")) ) {
|
||||
int i;
|
||||
for ( i = 0; i < count; i++ ) {
|
||||
int result = ( strcmp(entries[i].mnt_fsname, name) == 0
|
||||
|| strcmp(entries[i].mnt_dir, name) == 0 );
|
||||
|
||||
if ( result )
|
||||
continue;
|
||||
else
|
||||
addmntent(mountTable, &entries[i]);
|
||||
}
|
||||
endmntent(mountTable);
|
||||
}
|
||||
else if ( errno != EROFS )
|
||||
perror(mtab_file);
|
||||
}
|
||||
|
||||
extern void
|
||||
write_mtab(char* blockDevice, char* directory,
|
||||
char* filesystemType, long flags, char* string_flags)
|
||||
{
|
||||
FILE *mountTable = setmntent(mtab_file, "a+");
|
||||
struct mntent m;
|
||||
|
||||
if ( mountTable == 0 ) {
|
||||
perror(mtab_file);
|
||||
return;
|
||||
}
|
||||
if (mountTable) {
|
||||
int length = strlen(directory);
|
||||
|
||||
if ( length > 1 && directory[length - 1] == '/' )
|
||||
directory[length - 1] = '\0';
|
||||
|
||||
if ( filesystemType == 0 ) {
|
||||
struct mntent * p
|
||||
= findMountPoint(blockDevice, "/proc/mounts");
|
||||
|
||||
if ( p && p->mnt_type )
|
||||
filesystemType = p->mnt_type;
|
||||
}
|
||||
m.mnt_fsname = blockDevice;
|
||||
m.mnt_dir = directory;
|
||||
m.mnt_type = filesystemType ? filesystemType : "default";
|
||||
|
||||
if (*string_flags) {
|
||||
m.mnt_opts = string_flags;
|
||||
} else {
|
||||
if ( (flags | MS_RDONLY) == flags )
|
||||
m.mnt_opts = "ro";
|
||||
else
|
||||
m.mnt_opts = "rw";
|
||||
}
|
||||
|
||||
m.mnt_freq = 0;
|
||||
m.mnt_passno = 0;
|
||||
addmntent(mountTable, &m);
|
||||
endmntent(mountTable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ static void parse_proc_status(char* S, proc_t* P)
|
||||
);
|
||||
else fprintf(stderr, "Internal error!\n");
|
||||
|
||||
/* For busybox, ignoring effecting, saved, etc */
|
||||
/* For busybox, ignoring effective, saved, etc */
|
||||
tmp = strstr (S,"Uid:");
|
||||
if(tmp) sscanf (tmp,
|
||||
"Uid:\t%d", &P->ruid);
|
||||
|
||||
@@ -74,7 +74,7 @@ static void parse_proc_status(char* S, proc_t* P)
|
||||
);
|
||||
else fprintf(stderr, "Internal error!\n");
|
||||
|
||||
/* For busybox, ignoring effecting, saved, etc */
|
||||
/* For busybox, ignoring effective, saved, etc */
|
||||
tmp = strstr (S,"Uid:");
|
||||
if(tmp) sscanf (tmp,
|
||||
"Uid:\t%d", &P->ruid);
|
||||
|
||||
@@ -50,7 +50,6 @@ extern int replace_match(char *haystack, char *needle, char *newNeedle, int igno
|
||||
} while (regexec(re, s, FALSE, ignoreCase) == TRUE);
|
||||
/* copy stuff from after the match */
|
||||
while ( (*d++ = *s++) ) {}
|
||||
d[-1] = '\n';
|
||||
d[0] = '\0';
|
||||
strcpy(haystack, buf);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ extern int rm_main(int argc, char **argv)
|
||||
|
||||
while (argc-- > 0) {
|
||||
srcName = *(argv++);
|
||||
if (recursiveAction( srcName, recursiveFlag, TRUE, TRUE,
|
||||
if (recursiveAction( srcName, recursiveFlag, FALSE, TRUE,
|
||||
fileAction, dirAction) == FALSE) {
|
||||
exit( FALSE);
|
||||
}
|
||||
|
||||
@@ -45,9 +45,23 @@ static const char sed_usage[] =
|
||||
#else
|
||||
"This version of sed matches strings (not full regexps).\n";
|
||||
#endif
|
||||
|
||||
|
||||
static void do_sed(FILE *fp, char *needle, char *newNeedle, int ignoreCase, int printFlag, int quietFlag)
|
||||
{
|
||||
int foundOne=FALSE;
|
||||
char haystack[1024];
|
||||
|
||||
|
||||
while (fgets (haystack, 1023, fp)) {
|
||||
foundOne = replace_match(haystack, needle, newNeedle, ignoreCase);
|
||||
if (foundOne==TRUE && printFlag==TRUE) {
|
||||
fprintf(stdout, haystack);
|
||||
}
|
||||
if (quietFlag==FALSE) {
|
||||
fprintf(stdout, haystack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern int sed_main (int argc, char **argv)
|
||||
{
|
||||
@@ -56,11 +70,9 @@ extern int sed_main (int argc, char **argv)
|
||||
char *name;
|
||||
char *cp;
|
||||
int ignoreCase=FALSE;
|
||||
int foundOne=FALSE;
|
||||
int printFlag=FALSE;
|
||||
int quietFlag=FALSE;
|
||||
int stopNow;
|
||||
char *haystack;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
@@ -73,24 +85,23 @@ extern int sed_main (int argc, char **argv)
|
||||
cp = *argv++;
|
||||
stopNow=FALSE;
|
||||
|
||||
while (*++cp && stopNow==FALSE)
|
||||
while (*++cp && stopNow==FALSE) {
|
||||
switch (*cp) {
|
||||
case 'n':
|
||||
quietFlag = TRUE;
|
||||
break;
|
||||
case 'e':
|
||||
if (*(cp+1)==0 && --argc < 0) {
|
||||
fprintf(stderr, "A\n");
|
||||
usage( sed_usage);
|
||||
}
|
||||
cp = *argv++;
|
||||
if ( *++cp != 's')
|
||||
cp = *argv++;
|
||||
while( *cp ) {
|
||||
if (*cp == 's' && strlen(cp) > 3 && *(cp+1) == '/') {
|
||||
char* pos=needle=cp+2;
|
||||
for(;;) {
|
||||
pos = strchr(pos, '/');
|
||||
if (pos==NULL) {
|
||||
fprintf(stderr, "B\n");
|
||||
usage( sed_usage);
|
||||
}
|
||||
if (*(pos-1) == '\\') {
|
||||
@@ -104,7 +115,6 @@ extern int sed_main (int argc, char **argv)
|
||||
for(;;) {
|
||||
pos = strchr(pos, '/');
|
||||
if (pos==NULL) {
|
||||
fprintf(stderr, "C\n");
|
||||
usage( sed_usage);
|
||||
}
|
||||
if (*(pos-1) == '\\') {
|
||||
@@ -116,7 +126,6 @@ extern int sed_main (int argc, char **argv)
|
||||
*pos=0;
|
||||
if (pos+2 != 0) {
|
||||
while (*++pos) {
|
||||
fprintf(stderr, "pos='%s'\n", pos);
|
||||
switch (*pos) {
|
||||
case 'i':
|
||||
ignoreCase=TRUE;
|
||||
@@ -134,42 +143,35 @@ extern int sed_main (int argc, char **argv)
|
||||
}
|
||||
cp++;
|
||||
}
|
||||
fprintf(stderr, "replace '%s' with '%s'\n", needle, newNeedle);
|
||||
//fprintf(stderr, "replace '%s' with '%s'\n", needle, newNeedle);
|
||||
stopNow=TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "D\n");
|
||||
usage(sed_usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (argc-- > 0) {
|
||||
name = *argv++;
|
||||
if (argc==0) {
|
||||
do_sed( stdin, needle, newNeedle, ignoreCase, printFlag, quietFlag);
|
||||
} else {
|
||||
while (argc-- > 0) {
|
||||
name = *argv++;
|
||||
|
||||
fp = fopen (name, "r");
|
||||
if (fp == NULL) {
|
||||
perror (name);
|
||||
continue;
|
||||
fp = fopen (name, "r");
|
||||
if (fp == NULL) {
|
||||
perror (name);
|
||||
continue;
|
||||
}
|
||||
|
||||
do_sed( fp, needle, newNeedle, ignoreCase, printFlag, quietFlag);
|
||||
|
||||
if (ferror (fp))
|
||||
perror (name);
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
haystack = (char*)malloc( 1024);
|
||||
while (fgets (haystack, 1023, fp)) {
|
||||
|
||||
foundOne = replace_match(haystack, needle, newNeedle, ignoreCase);
|
||||
if (foundOne==TRUE && printFlag==TRUE)
|
||||
fputs (haystack, stdout);
|
||||
if (quietFlag==FALSE)
|
||||
fputs (haystack, stdout);
|
||||
/* Avoid any mem leaks */
|
||||
free(haystack);
|
||||
haystack = (char*)malloc( BUF_SIZE);
|
||||
}
|
||||
|
||||
if (ferror (fp))
|
||||
perror (name);
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
exit( TRUE);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,16 @@
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
|
||||
/* Note that tar.c expects TRUE and FALSE to be defined
|
||||
* exactly the opposite of how they are used everywhere else.
|
||||
* Some time this should be integrated a bit better, but this
|
||||
* does the job for now.
|
||||
*/
|
||||
#undef FALSE
|
||||
#undef TRUE
|
||||
#define FALSE ((int) 0)
|
||||
#define TRUE ((int) 1)
|
||||
|
||||
|
||||
static const char tar_usage[] =
|
||||
"tar -[cxtvOf] [tarFileName] [FILE] ...\n"
|
||||
@@ -169,10 +179,9 @@ extern int tar_main (int argc, char **argv)
|
||||
/*
|
||||
* Parse the options.
|
||||
*/
|
||||
options = *argv++;
|
||||
argc--;
|
||||
|
||||
if (**argv == '-') {
|
||||
options = (*argv++) + 1;
|
||||
argc--;
|
||||
for (; *options; options++) {
|
||||
switch (*options) {
|
||||
case 'f':
|
||||
|
||||
+61
-27
@@ -25,7 +25,9 @@
|
||||
|
||||
|
||||
/* Turning this off makes things a bit smaller (and less pretty) */
|
||||
#define BB_MORE_TERM
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
/* Turning this off makes things a bit smaller (and less pretty) */
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
|
||||
|
||||
|
||||
@@ -33,19 +35,16 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
static const char more_usage[] = "[file ...]";
|
||||
|
||||
|
||||
/* ED: sparc termios is broken: revert back to old termio handling. */
|
||||
#ifdef BB_MORE_TERM
|
||||
#ifdef BB_FEATURE_USE_TERMIOS
|
||||
|
||||
|
||||
#if defined (__sparc__)
|
||||
#if #cpu(sparc)
|
||||
# define USE_OLD_TERMIO
|
||||
# include <termio.h>
|
||||
# include <sys/ioctl.h>
|
||||
# define termios termio
|
||||
# define stty(fd,argp) ioctl(fd,TCSETAF,argp)
|
||||
#else
|
||||
@@ -58,24 +57,43 @@ static const char more_usage[] = "[file ...]";
|
||||
|
||||
void gotsig(int sig) {
|
||||
stty(fileno(cin), &initial_settings);
|
||||
fprintf(stdout, "\n");
|
||||
exit( TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define TERMINAL_WIDTH 79 /* not 80 in case terminal has linefold bug */
|
||||
#define TERMINAL_HEIGHT 24
|
||||
|
||||
|
||||
#if defined BB_FEATURE_AUTOWIDTH && ! defined USE_OLD_TERMIO
|
||||
static int terminal_width = 0, terminal_height = 0;
|
||||
#else
|
||||
#define terminal_width TERMINAL_WIDTH
|
||||
#define terminal_height TERMINAL_HEIGHT
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
extern int more_main(int argc, char **argv)
|
||||
{
|
||||
int c, lines=0, input=0;
|
||||
int next_page=0;
|
||||
struct stat st;
|
||||
FILE *file;
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
struct winsize win;
|
||||
#endif
|
||||
|
||||
if ( strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0 ) {
|
||||
usage (more_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
while (argc >= 0) {
|
||||
if ( argc > 0 && (strcmp(*argv,"--help")==0 || strcmp(*argv,"-h")==0) ) {
|
||||
usage (more_usage);
|
||||
}
|
||||
do {
|
||||
if (argc==0) {
|
||||
file = stdin;
|
||||
}
|
||||
@@ -88,7 +106,7 @@ extern int more_main(int argc, char **argv)
|
||||
}
|
||||
fstat(fileno(file), &st);
|
||||
|
||||
#ifdef BB_MORE_TERM
|
||||
#ifdef BB_FEATURE_USE_TERMIOS
|
||||
cin = fopen("/dev/tty", "r");
|
||||
if (!cin)
|
||||
cin = fopen("/dev/console", "r");
|
||||
@@ -101,8 +119,18 @@ extern int more_main(int argc, char **argv)
|
||||
new_settings.c_lflag &= ~ICANON;
|
||||
new_settings.c_lflag &= ~ECHO;
|
||||
stty(fileno(cin), &new_settings);
|
||||
|
||||
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &win);
|
||||
if (win.ws_row > 4)
|
||||
terminal_height = win.ws_row - 2;
|
||||
if (win.ws_col > 0)
|
||||
terminal_width = win.ws_col - 1;
|
||||
#endif
|
||||
|
||||
(void) signal(SIGINT, gotsig);
|
||||
(void) signal(SIGQUIT, gotsig);
|
||||
(void) signal(SIGTERM, gotsig);
|
||||
|
||||
#endif
|
||||
while ((c = getc(file)) != EOF) {
|
||||
@@ -117,7 +145,7 @@ extern int more_main(int argc, char **argv)
|
||||
st.st_size);
|
||||
}
|
||||
len += fprintf(stdout, "%s",
|
||||
#ifdef BB_MORE_TERM
|
||||
#ifdef BB_FEATURE_USE_TERMIOS
|
||||
""
|
||||
#else
|
||||
"\n"
|
||||
@@ -127,34 +155,40 @@ extern int more_main(int argc, char **argv)
|
||||
fflush(stdout);
|
||||
input = getc( cin);
|
||||
|
||||
#ifdef BB_MORE_TERM
|
||||
#ifdef BB_FEATURE_USE_TERMIOS
|
||||
/* Erase the "More" message */
|
||||
while(len-- > 0)
|
||||
while(--len >= 0)
|
||||
putc('\b', stdout);
|
||||
while(len++ < 79)
|
||||
while(++len <= terminal_width)
|
||||
putc(' ', stdout);
|
||||
while(len-- > 0)
|
||||
while(--len >= 0)
|
||||
putc('\b', stdout);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
}
|
||||
if (input=='q')
|
||||
goto end;
|
||||
if (input==' ' && c == '\n' )
|
||||
next_page = 1;
|
||||
if ( c == '\n' && ++lines == 24 )
|
||||
next_page = 1;
|
||||
if (c == '\n' ) {
|
||||
switch(input) {
|
||||
case 'q':
|
||||
goto end;
|
||||
case '\n':
|
||||
/* increment by just one line if we are at
|
||||
* the end of this line*/
|
||||
next_page = 1;
|
||||
break;
|
||||
}
|
||||
if ( ++lines == terminal_height )
|
||||
next_page = 1;
|
||||
}
|
||||
putc(c, stdout);
|
||||
}
|
||||
fclose(file);
|
||||
fflush(stdout);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
} while (--argc > 0);
|
||||
end:
|
||||
#ifdef BB_MORE_TERM
|
||||
#ifdef BB_FEATURE_USE_TERMIOS
|
||||
gotsig(0);
|
||||
#endif
|
||||
exit(TRUE);
|
||||
|
||||
+2
-3
@@ -208,14 +208,13 @@ extern int mount_main (int argc, char **argv)
|
||||
char *filesystemType = "auto";
|
||||
char *device = NULL;
|
||||
char *directory = NULL;
|
||||
struct stat statBuf;
|
||||
int all = FALSE;
|
||||
int fakeIt = FALSE;
|
||||
int useMtab = TRUE;
|
||||
int i;
|
||||
|
||||
if (stat("/etc/fstab", &statBuf) < 0)
|
||||
fprintf(stderr, "/etc/fstab file missing -- Please install one.\n\n");
|
||||
/* Only compiled in if BB_MTAB is not defined */
|
||||
whine_if_fstab_is_missing();
|
||||
|
||||
if (argc == 1) {
|
||||
FILE *mountTable = setmntent (mtab_file, "r");
|
||||
|
||||
@@ -236,7 +236,30 @@ copyFile( const char *srcName, const char *destName,
|
||||
|
||||
|
||||
|
||||
#ifdef BB_TAR
|
||||
#if defined BB_TAR || defined BB_LS
|
||||
|
||||
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
|
||||
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
|
||||
|
||||
/* The special bits. If set, display SMODE0/1 instead of MODE0/1 */
|
||||
static const mode_t SBIT[] = {
|
||||
0, 0, S_ISUID,
|
||||
0, 0, S_ISGID,
|
||||
0, 0, S_ISVTX
|
||||
};
|
||||
|
||||
/* The 9 mode bits to test */
|
||||
static const mode_t MBIT[] = {
|
||||
S_IRUSR, S_IWUSR, S_IXUSR,
|
||||
S_IRGRP, S_IWGRP, S_IXGRP,
|
||||
S_IROTH, S_IWOTH, S_IXOTH
|
||||
};
|
||||
|
||||
#define MODE1 "rwxrwxrwx"
|
||||
#define MODE0 "---------"
|
||||
#define SMODE1 "..s..s..t"
|
||||
#define SMODE0 "..S..S..T"
|
||||
|
||||
/*
|
||||
* Return the standard ls-like mode string from a file mode.
|
||||
* This is static and so is overwritten on each call.
|
||||
@@ -245,64 +268,25 @@ const char *modeString(int mode)
|
||||
{
|
||||
static char buf[12];
|
||||
|
||||
strcpy(buf, "----------");
|
||||
|
||||
/*
|
||||
* Fill in the file type.
|
||||
*/
|
||||
if (S_ISDIR(mode))
|
||||
buf[0] = 'd';
|
||||
if (S_ISCHR(mode))
|
||||
buf[0] = 'c';
|
||||
if (S_ISBLK(mode))
|
||||
buf[0] = 'b';
|
||||
if (S_ISFIFO(mode))
|
||||
buf[0] = 'p';
|
||||
if (S_ISLNK(mode))
|
||||
buf[0] = 'l';
|
||||
if (S_ISSOCK(mode))
|
||||
buf[0] = 's';
|
||||
/*
|
||||
* Now fill in the normal file permissions.
|
||||
*/
|
||||
if (mode & S_IRUSR)
|
||||
buf[1] = 'r';
|
||||
if (mode & S_IWUSR)
|
||||
buf[2] = 'w';
|
||||
if (mode & S_IXUSR)
|
||||
buf[3] = 'x';
|
||||
if (mode & S_IRGRP)
|
||||
buf[4] = 'r';
|
||||
if (mode & S_IWGRP)
|
||||
buf[5] = 'w';
|
||||
if (mode & S_IXGRP)
|
||||
buf[6] = 'x';
|
||||
if (mode & S_IROTH)
|
||||
buf[7] = 'r';
|
||||
if (mode & S_IWOTH)
|
||||
buf[8] = 'w';
|
||||
if (mode & S_IXOTH)
|
||||
buf[9] = 'x';
|
||||
|
||||
/*
|
||||
* Finally fill in magic stuff like suid and sticky text.
|
||||
*/
|
||||
if (mode & S_ISUID)
|
||||
buf[3] = ((mode & S_IXUSR) ? 's' : 'S');
|
||||
if (mode & S_ISGID)
|
||||
buf[6] = ((mode & S_IXGRP) ? 's' : 'S');
|
||||
if (mode & S_ISVTX)
|
||||
buf[9] = ((mode & S_IXOTH) ? 't' : 'T');
|
||||
|
||||
int i;
|
||||
buf[0] = TYPECHAR(mode);
|
||||
for (i=0; i<9; i++) {
|
||||
if (mode & SBIT[i])
|
||||
buf[i+1] = (mode & MBIT[i])?
|
||||
SMODE1[i] : SMODE0[i];
|
||||
else
|
||||
buf[i+1] = (mode & MBIT[i])?
|
||||
MODE1[i] : MODE0[i];
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef BB_TAR
|
||||
/*
|
||||
* Get the time string to be used for a file.
|
||||
* This is down to the minute for new files, but only the date for old files.
|
||||
* The string is returned from a static buffer, and so is overwritten for
|
||||
* each call.
|
||||
* Return the standard ls-like time string from a time_t
|
||||
* This is static and so is overwritten on each call.
|
||||
*/
|
||||
const char *timeString(time_t timeVal)
|
||||
{
|
||||
@@ -325,7 +309,6 @@ const char *timeString(time_t timeVal)
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Write all of the supplied buffer out to a file.
|
||||
* This does multiple writes as necessary.
|
||||
@@ -415,8 +398,12 @@ recursiveAction(const char *fileName, int recurse, int followLinks, int depthFir
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if ( (followLinks == FALSE) && (S_ISLNK(statbuf.st_mode)) )
|
||||
return (TRUE);
|
||||
if ( (followLinks == FALSE) && (S_ISLNK(statbuf.st_mode)) ) {
|
||||
if (fileAction == NULL)
|
||||
return (TRUE);
|
||||
else
|
||||
return (fileAction(fileName, &statbuf));
|
||||
}
|
||||
|
||||
if (recurse == FALSE) {
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
@@ -868,5 +855,64 @@ extern int replace_match(char *haystack, char *needle, char *newNeedle, int igno
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined BB_DF | defined BB_MTAB
|
||||
/*
|
||||
* Given a block device, find the mount table entry if that block device
|
||||
* is mounted.
|
||||
*
|
||||
* Given any other file (or directory), find the mount table entry for its
|
||||
* filesystem.
|
||||
*/
|
||||
extern struct mntent *findMountPoint(const char *name, const char *table)
|
||||
{
|
||||
struct stat s;
|
||||
dev_t mountDevice;
|
||||
FILE *mountTable;
|
||||
struct mntent *mountEntry;
|
||||
|
||||
if (stat(name, &s) != 0)
|
||||
return 0;
|
||||
|
||||
if ((s.st_mode & S_IFMT) == S_IFBLK)
|
||||
mountDevice = s.st_rdev;
|
||||
else
|
||||
mountDevice = s.st_dev;
|
||||
|
||||
|
||||
if ((mountTable = setmntent(table, "r")) == 0)
|
||||
return 0;
|
||||
|
||||
while ((mountEntry = getmntent(mountTable)) != 0) {
|
||||
if (strcmp(name, mountEntry->mnt_dir) == 0
|
||||
|| strcmp(name, mountEntry->mnt_fsname) == 0) /* String match. */
|
||||
break;
|
||||
if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == mountDevice) /* Match the device. */
|
||||
break;
|
||||
if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == mountDevice) /* Match the directory's mount point. */
|
||||
break;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
return mountEntry;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if !defined BB_MTAB && (defined BB_MOUNT || defined BB_DF )
|
||||
extern void whine_if_fstab_is_missing()
|
||||
{
|
||||
struct stat statBuf;
|
||||
if (stat("/etc/fstab", &statBuf) < 0)
|
||||
fprintf(stderr, "/etc/fstab file missing -- install one to name /dev/root.\n\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* END CODE */
|
||||
|
||||
|
||||
@@ -76,8 +76,6 @@ static char *license_msg[] = {
|
||||
* The target dependent functions should be defined in tailor.c.
|
||||
*/
|
||||
|
||||
/* $Id: zcat.c,v 1.5 1999/10/23 07:09:58 andersen Exp $ */
|
||||
|
||||
#define RECORD_IO 0
|
||||
|
||||
#define get_char() get_byte()
|
||||
@@ -432,8 +430,6 @@ extern int unlzw OF((int in, int out));
|
||||
# undef LZW
|
||||
#endif
|
||||
|
||||
/* $Id: zcat.c,v 1.5 1999/10/23 07:09:58 andersen Exp $ */
|
||||
|
||||
/* #include "getopt.h" */
|
||||
|
||||
/* Declarations for getopt.
|
||||
|
||||
Reference in new issue
Block a user