mirror of
https://github.com/sheumann/hush.git
synced 2025-01-18 07:31:34 +00:00
Latest and greatest
-Erik
This commit is contained in:
parent
0dfac6b9ce
commit
96bcfd346b
28
Changelog
28
Changelog
@ -1,11 +1,21 @@
|
|||||||
0.35
|
0.35
|
||||||
|
* gzip now obeys the principle of least surprise and acts like god intended
|
||||||
|
(i.e. it accepts a file name, answers --help, and obeys the '-c' flag
|
||||||
|
and only then outputs to stdout).
|
||||||
|
* Fixed more.c to compile autowidth on sparc and set initial winsize
|
||||||
|
to 0,0 in case the TIOCGWINSZ ioctl fails. Fix thanks to Eric Delaunay.
|
||||||
* Fixed tar so it now works as expected (it had TRUE/FALSE backwards)
|
* Fixed tar so it now works as expected (it had TRUE/FALSE backwards)
|
||||||
* tar now accepts --help
|
* tar now accepts --help
|
||||||
* chmod, chown, and chgrp usage now works
|
* chmod, chown, and chgrp usage now works
|
||||||
* General usage cleanups in most apps
|
* General usage (i.e. --help) cleanups for most apps
|
||||||
* umount now parses options correctly
|
* umount now parses options correctly
|
||||||
|
* tar can now unpack tarballs containing device special files,
|
||||||
|
sockets, and fifos (though it can't pack them up) thanks
|
||||||
|
to Matt Porter. Creating archives containing these is still
|
||||||
|
left to the interested student.
|
||||||
|
* fixed up the license in more.c to properly point to Bruce Perens.
|
||||||
|
|
||||||
-Erik Andersen
|
-Erik Andersen, Nov 11, 1999
|
||||||
|
|
||||||
0.34
|
0.34
|
||||||
* ls -l now displays link names outside the current directory,
|
* ls -l now displays link names outside the current directory,
|
||||||
@ -27,7 +37,7 @@
|
|||||||
* ls -l now bypasses libc6 nss when displaying user/group names.
|
* ls -l now bypasses libc6 nss when displaying user/group names.
|
||||||
Now uses my_getpwuid and my_getgrgid.
|
Now uses my_getpwuid and my_getgrgid.
|
||||||
|
|
||||||
-Erik Andersen
|
-Erik Andersen, Nov 8, 1999
|
||||||
|
|
||||||
0.33
|
0.33
|
||||||
* Fixed a bug where init could hang instead of rebooting.
|
* Fixed a bug where init could hang instead of rebooting.
|
||||||
@ -39,7 +49,7 @@
|
|||||||
state the real root device name)
|
state the real root device name)
|
||||||
* merged some redundant code from mtab.c/df.c into utility.c
|
* merged some redundant code from mtab.c/df.c into utility.c
|
||||||
|
|
||||||
-Erik Andersen
|
-Erik Andersen, Nov 5, 1999
|
||||||
|
|
||||||
0.32
|
0.32
|
||||||
* More changes -- many thanks to Lineo for paying me to work on
|
* More changes -- many thanks to Lineo for paying me to work on
|
||||||
@ -68,7 +78,7 @@
|
|||||||
as the name suggests. Fix thanks to Matt Porter <porter@debian.org>.
|
as the name suggests. Fix thanks to Matt Porter <porter@debian.org>.
|
||||||
|
|
||||||
|
|
||||||
-Erik Andersen
|
-Erik Andersen, Nov 4, 1999
|
||||||
|
|
||||||
0.31
|
0.31
|
||||||
* I added a changelog for version 0.30.
|
* I added a changelog for version 0.30.
|
||||||
@ -83,7 +93,7 @@
|
|||||||
it wasn't supported before GNU libc 2.1, and some folks use
|
it wasn't supported before GNU libc 2.1, and some folks use
|
||||||
glibc 2.0.7 since it is much smaller than that latest and greatest.
|
glibc 2.0.7 since it is much smaller than that latest and greatest.
|
||||||
|
|
||||||
-Erik Andersen
|
-Erik Andersen, Oct 21, 1999
|
||||||
|
|
||||||
0.30
|
0.30
|
||||||
Major changes -- lots of stuff rewritten. Many thanks to Lineo for
|
Major changes -- lots of stuff rewritten. Many thanks to Lineo for
|
||||||
@ -152,7 +162,11 @@
|
|||||||
* sfdisk -- Added from util-linux (minus internationalization and such).
|
* sfdisk -- Added from util-linux (minus internationalization and such).
|
||||||
* Probably some other changes that I forgot to document...
|
* Probably some other changes that I forgot to document...
|
||||||
|
|
||||||
-Erik Andersen
|
-Erik Andersen, Oct 20, 1999
|
||||||
|
|
||||||
|
0.29
|
||||||
|
This version was a messy pre-alpha. stay away or it will bite you.
|
||||||
|
-Erik Andersen, Sep 24, 1999
|
||||||
|
|
||||||
0.28
|
0.28
|
||||||
mini-netcat (mnc) rewritten.
|
mini-netcat (mnc) rewritten.
|
||||||
|
14
Makefile
14
Makefile
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
PROG=busybox
|
PROG=busybox
|
||||||
VERSION=0.34
|
VERSION=0.35
|
||||||
BUILDTIME=$(shell date "+%Y%m%d-%H%M")
|
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
|
||||||
@ -58,14 +58,14 @@ OBJECTS=$(shell ./busybox.sh)
|
|||||||
CFLAGS+= -DBB_VER='"$(VERSION)"'
|
CFLAGS+= -DBB_VER='"$(VERSION)"'
|
||||||
CFLAGS+= -DBB_BT='"$(BUILDTIME)"'
|
CFLAGS+= -DBB_BT='"$(BUILDTIME)"'
|
||||||
|
|
||||||
all: busybox links
|
all: busybox busybox.links
|
||||||
|
|
||||||
busybox: $(OBJECTS)
|
busybox: $(OBJECTS)
|
||||||
$(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES)
|
$(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES)
|
||||||
$(STRIP)
|
$(STRIP)
|
||||||
|
|
||||||
links:
|
busybox.links:
|
||||||
- ./busybox.mkll | sort >busybox.links
|
- ./busybox.mkll | sort >$@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
- rm -f $(PROG) busybox.links *~ *.o core
|
- rm -f $(PROG) busybox.links *~ *.o core
|
||||||
@ -80,3 +80,9 @@ $(OBJECTS): busybox.def.h internal.h Makefile
|
|||||||
install: $(PROG)
|
install: $(PROG)
|
||||||
install.sh $(BINDIR)
|
install.sh $(BINDIR)
|
||||||
|
|
||||||
|
whichversion:
|
||||||
|
@echo $(VERSION)
|
||||||
|
|
||||||
|
release: distclean
|
||||||
|
(cd .. ; cp -a busybox busybox-$(VERSION); tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION))
|
||||||
|
|
||||||
|
102
archival/gzip.c
102
archival/gzip.c
@ -12,10 +12,11 @@
|
|||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
static const char gzip_usage[] =
|
static const char gzip_usage[] =
|
||||||
"gzip [OPTION]... [FILE]...\n\n"
|
"gzip [OPTION]... FILE\n\n"
|
||||||
"Compress FILEs with maximum compression.\n\n"
|
"Compress FILE with maximum compression.\n"
|
||||||
|
"When FILE is -, reads standard input. Implies -c.\n\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
"\t-c\tWrite output on standard output\n";
|
"\t-c\tWrite output to standard output instead of FILE.gz\n";
|
||||||
|
|
||||||
|
|
||||||
/* gzip.h -- common declarations for all gzip modules
|
/* gzip.h -- common declarations for all gzip modules
|
||||||
@ -1731,7 +1732,6 @@ DECLARE(uch, window, 2L*WSIZE);
|
|||||||
|
|
||||||
int ascii = 0; /* convert end-of-lines to local OS conventions */
|
int ascii = 0; /* convert end-of-lines to local OS conventions */
|
||||||
int decompress = 0; /* decompress (-d) */
|
int decompress = 0; /* decompress (-d) */
|
||||||
int tostdout = 0; /* uncompress to stdout (-c) */
|
|
||||||
int no_name = -1; /* don't save or restore the original file name */
|
int no_name = -1; /* don't save or restore the original file name */
|
||||||
int no_time = -1; /* don't save or restore the original file time */
|
int no_time = -1; /* don't save or restore the original file time */
|
||||||
int foreground; /* set if program run in foreground */
|
int foreground; /* set if program run in foreground */
|
||||||
@ -1770,13 +1770,25 @@ unsigned outcnt; /* bytes in output buffer */
|
|||||||
// char **argv;
|
// char **argv;
|
||||||
int gzip_main(int argc, char ** argv)
|
int gzip_main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
|
int result;
|
||||||
int inFileNum;
|
int inFileNum;
|
||||||
int outFileNum;
|
int outFileNum;
|
||||||
|
struct stat statBuf;
|
||||||
|
char* delFileName;
|
||||||
|
int tostdout = 0;
|
||||||
|
int fromstdin = 0;
|
||||||
|
|
||||||
|
if (argc==1)
|
||||||
|
usage(gzip_usage);
|
||||||
|
|
||||||
/* Parse any options */
|
/* Parse any options */
|
||||||
while (--argc > 0 && **(++argv) == '-') {
|
while (--argc > 0 && **(++argv) == '-') {
|
||||||
|
if (*((*argv)+1) == '\0') {
|
||||||
|
fromstdin = 1;
|
||||||
|
tostdout = 1;
|
||||||
|
}
|
||||||
while (*(++(*argv))) {
|
while (*(++(*argv))) {
|
||||||
|
fprintf(stderr, "**argv='%c'\n", **argv);
|
||||||
switch (**argv) {
|
switch (**argv) {
|
||||||
case 'c':
|
case 'c':
|
||||||
tostdout = 1;
|
tostdout = 1;
|
||||||
@ -1817,18 +1829,40 @@ int gzip_main(int argc, char ** argv)
|
|||||||
ALLOC(ush, tab_prefix1, 1L<<(BITS-1));
|
ALLOC(ush, tab_prefix1, 1L<<(BITS-1));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (fromstdin==1) {
|
||||||
|
strcpy(ofname, "stdin");
|
||||||
|
|
||||||
|
inFileNum=fileno(stdin);
|
||||||
|
time_stamp = 0; /* time unknown by default */
|
||||||
|
ifile_size = -1L; /* convention for unknown size */
|
||||||
|
} else {
|
||||||
|
/* Open up the input file */
|
||||||
|
if (*argv=='\0')
|
||||||
|
usage(gzip_usage);
|
||||||
|
strncpy(ifname, *argv, MAX_PATH_LEN);
|
||||||
|
|
||||||
|
/* Open input fille */
|
||||||
|
inFileNum=open( ifname, O_RDONLY);
|
||||||
|
if (inFileNum < 0) {
|
||||||
|
perror(ifname);
|
||||||
|
do_exit(WARNING);
|
||||||
|
}
|
||||||
|
/* Get the time stamp on the input file. */
|
||||||
|
result = stat(ifname, &statBuf);
|
||||||
|
if (result < 0) {
|
||||||
|
perror(ifname);
|
||||||
|
do_exit(WARNING);
|
||||||
|
}
|
||||||
|
time_stamp = statBuf.st_ctime;
|
||||||
|
ifile_size = statBuf.st_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (tostdout==1) {
|
if (tostdout==1) {
|
||||||
/* And get to work */
|
/* And get to work */
|
||||||
SET_BINARY_MODE(fileno(stdout));
|
|
||||||
strcpy(ifname, "stdin");
|
|
||||||
strcpy(ofname, "stdout");
|
strcpy(ofname, "stdout");
|
||||||
inFileNum=fileno(stdin);
|
|
||||||
outFileNum=fileno(stdout);
|
outFileNum=fileno(stdout);
|
||||||
|
SET_BINARY_MODE(fileno(stdout));
|
||||||
/* Get the time stamp on the input file. */
|
|
||||||
time_stamp = 0; /* time unknown by default */
|
|
||||||
|
|
||||||
ifile_size = -1L; /* convention for unknown size */
|
|
||||||
|
|
||||||
clear_bufs(); /* clear input and output buffers */
|
clear_bufs(); /* clear input and output buffers */
|
||||||
part_nb = 0;
|
part_nb = 0;
|
||||||
@ -1837,44 +1871,39 @@ int gzip_main(int argc, char ** argv)
|
|||||||
zip(inFileNum, outFileNum);
|
zip(inFileNum, outFileNum);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int result;
|
|
||||||
struct stat statBuf;
|
|
||||||
|
|
||||||
/* And get to work */
|
/* And get to work */
|
||||||
if (*argv=='\0')
|
strncpy(ofname, ifname, MAX_PATH_LEN-4);
|
||||||
usage(gzip_usage);
|
|
||||||
strncpy(ifname, *argv, MAX_PATH_LEN);
|
|
||||||
strncpy(ofname, *argv, MAX_PATH_LEN-4);
|
|
||||||
strcat(ofname, ".gz");
|
strcat(ofname, ".gz");
|
||||||
|
|
||||||
inFileNum=open( ifname, O_RDONLY);
|
|
||||||
if (inFileNum < 0) {
|
|
||||||
perror(ifname);
|
|
||||||
do_exit(WARNING);
|
|
||||||
}
|
|
||||||
result = stat(ifname, &statBuf);
|
|
||||||
if (result < 0) {
|
|
||||||
perror(ifname);
|
|
||||||
do_exit(WARNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
outFileNum=open( ofname, O_RDONLY);
|
/* Open output fille */
|
||||||
|
outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW);
|
||||||
if (outFileNum < 0) {
|
if (outFileNum < 0) {
|
||||||
perror(ofname);
|
perror(ofname);
|
||||||
do_exit(WARNING);
|
do_exit(WARNING);
|
||||||
}
|
}
|
||||||
SET_BINARY_MODE(outFileNum);
|
SET_BINARY_MODE(outFileNum);
|
||||||
|
/* Set permissions on the file */
|
||||||
/* Get the time stamp on the input file. */
|
fchmod(outFileNum, statBuf.st_mode);
|
||||||
time_stamp = statBuf.st_ctime; /* time unknown by default */
|
|
||||||
|
|
||||||
ifile_size = statBuf.st_size; /* convention for unknown size */
|
|
||||||
|
|
||||||
clear_bufs(); /* clear input and output buffers */
|
clear_bufs(); /* clear input and output buffers */
|
||||||
part_nb = 0;
|
part_nb = 0;
|
||||||
|
|
||||||
/* Actually do the compression/decompression. */
|
/* Actually do the compression/decompression. */
|
||||||
zip(inFileNum, outFileNum);
|
result=zip(inFileNum, outFileNum);
|
||||||
|
close( outFileNum);
|
||||||
|
close( inFileNum);
|
||||||
|
/* Delete the original file */
|
||||||
|
if (result == OK)
|
||||||
|
delFileName=ifname;
|
||||||
|
else
|
||||||
|
delFileName=ofname;
|
||||||
|
|
||||||
|
if (unlink (delFileName) < 0) {
|
||||||
|
perror (delFileName);
|
||||||
|
exit( FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
do_exit(exit_code);
|
do_exit(exit_code);
|
||||||
@ -3198,6 +3227,7 @@ int zip(in, out)
|
|||||||
|
|
||||||
/* Write the header to the gzip file. See algorithm.doc for the format */
|
/* Write the header to the gzip file. See algorithm.doc for the format */
|
||||||
|
|
||||||
|
|
||||||
method = DEFLATED;
|
method = DEFLATED;
|
||||||
put_byte(GZIP_MAGIC[0]); /* magic header */
|
put_byte(GZIP_MAGIC[0]); /* magic header */
|
||||||
put_byte(GZIP_MAGIC[1]);
|
put_byte(GZIP_MAGIC[1]);
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
* Modified for busybox by Erik Andersen <andersee@debian.org>
|
* Modified for busybox by Erik Andersen <andersee@debian.org>
|
||||||
* Adjusted to grok stdin/stdout options.
|
* Adjusted to grok stdin/stdout options.
|
||||||
*
|
*
|
||||||
|
* Modified to handle device special files by Matt Porter
|
||||||
|
* <porter@debian.org>
|
||||||
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -34,6 +37,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
|
||||||
static const char tar_usage[] =
|
static const char tar_usage[] =
|
||||||
@ -377,12 +381,15 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
int uid;
|
int uid;
|
||||||
int gid;
|
int gid;
|
||||||
int checkSum;
|
int checkSum;
|
||||||
|
int major;
|
||||||
|
int minor;
|
||||||
long size;
|
long size;
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
const char *name;
|
const char *name;
|
||||||
int cc;
|
int cc;
|
||||||
int hardLink;
|
int hardLink;
|
||||||
int softLink;
|
int softLink;
|
||||||
|
int devFileFlag;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the block is completely empty, then this is the end of the
|
* If the block is completely empty, then this is the end of the
|
||||||
@ -411,6 +418,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
size = getOctal (hp->size, sizeof (hp->size));
|
size = getOctal (hp->size, sizeof (hp->size));
|
||||||
mtime = getOctal (hp->mtime, sizeof (hp->mtime));
|
mtime = getOctal (hp->mtime, sizeof (hp->mtime));
|
||||||
checkSum = getOctal (hp->checkSum, sizeof (hp->checkSum));
|
checkSum = getOctal (hp->checkSum, sizeof (hp->checkSum));
|
||||||
|
major = getOctal (hp->devMajor, sizeof (hp->devMajor));
|
||||||
|
minor = getOctal (hp->devMinor, sizeof (hp->devMinor));
|
||||||
|
|
||||||
if ((mode < 0) || (uid < 0) || (gid < 0) || (size < 0)) {
|
if ((mode < 0) || (uid < 0) || (gid < 0) || (size < 0)) {
|
||||||
if (badHeader==FALSE)
|
if (badHeader==FALSE)
|
||||||
@ -423,6 +432,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
|
|
||||||
badHeader = FALSE;
|
badHeader = FALSE;
|
||||||
skipFileFlag = FALSE;
|
skipFileFlag = FALSE;
|
||||||
|
devFileFlag = FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for the file modes.
|
* Check for the file modes.
|
||||||
@ -434,12 +444,10 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
(hp->typeFlag == TAR_TYPE_SOFT_LINK - '0'));
|
(hp->typeFlag == TAR_TYPE_SOFT_LINK - '0'));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for a directory or a regular file.
|
* Check for a directory.
|
||||||
*/
|
*/
|
||||||
if (name[strlen (name) - 1] == '/')
|
if (name[strlen (name) - 1] == '/')
|
||||||
mode |= S_IFDIR;
|
mode |= S_IFDIR;
|
||||||
else if ((mode & S_IFMT) == 0)
|
|
||||||
mode |= S_IFREG;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for absolute paths in the file.
|
* Check for absolute paths in the file.
|
||||||
@ -462,7 +470,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
* If not, then set up to skip it.
|
* If not, then set up to skip it.
|
||||||
*/
|
*/
|
||||||
if (wantFileName (name, fileCount, fileTable) == FALSE) {
|
if (wantFileName (name, fileCount, fileTable) == FALSE) {
|
||||||
if (!hardLink && !softLink && S_ISREG (mode)) {
|
if ( !hardLink && !softLink && (S_ISREG (mode) || S_ISCHR (mode)
|
||||||
|
|| S_ISBLK (mode) || S_ISSOCK(mode) || S_ISFIFO(mode) ) ) {
|
||||||
inHeader = (size == 0)? TRUE : FALSE;
|
inHeader = (size == 0)? TRUE : FALSE;
|
||||||
dataCc = size;
|
dataCc = size;
|
||||||
}
|
}
|
||||||
@ -487,7 +496,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
printf (" (link to \"%s\")", hp->linkName);
|
printf (" (link to \"%s\")", hp->linkName);
|
||||||
else if (softLink)
|
else if (softLink)
|
||||||
printf (" (symlink to \"%s\")", hp->linkName);
|
printf (" (symlink to \"%s\")", hp->linkName);
|
||||||
else if (S_ISREG (mode)) {
|
else if (S_ISREG (mode) || S_ISCHR (mode) || S_ISBLK (mode) ||
|
||||||
|
S_ISSOCK(mode) || S_ISFIFO(mode) ) {
|
||||||
inHeader = (size == 0)? TRUE : FALSE;
|
inHeader = (size == 0)? TRUE : FALSE;
|
||||||
dataCc = size;
|
dataCc = size;
|
||||||
}
|
}
|
||||||
@ -543,8 +553,17 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
*/
|
*/
|
||||||
if (tostdoutFlag == TRUE)
|
if (tostdoutFlag == TRUE)
|
||||||
outFd = STDOUT;
|
outFd = STDOUT;
|
||||||
else
|
else {
|
||||||
outFd = open (name, O_WRONLY | O_CREAT | O_TRUNC, mode);
|
if ( S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) ) {
|
||||||
|
devFileFlag = TRUE;
|
||||||
|
outFd = mknod (name, mode, makedev(major, minor) );
|
||||||
|
}
|
||||||
|
else if (S_ISFIFO(mode) ) {
|
||||||
|
outFd = mkfifo(name, mode);
|
||||||
|
} else {
|
||||||
|
outFd = open (name, O_WRONLY | O_CREAT | O_TRUNC, mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (outFd < 0) {
|
if (outFd < 0) {
|
||||||
perror (name);
|
perror (name);
|
||||||
@ -555,7 +574,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
/*
|
/*
|
||||||
* If the file is empty, then that's all we need to do.
|
* If the file is empty, then that's all we need to do.
|
||||||
*/
|
*/
|
||||||
if (size == 0 && tostdoutFlag == FALSE) {
|
if (size == 0 && (tostdoutFlag == FALSE) && (devFileFlag == FALSE)) {
|
||||||
(void) close (outFd);
|
(void) close (outFd);
|
||||||
outFd = -1;
|
outFd = -1;
|
||||||
}
|
}
|
||||||
@ -735,13 +754,17 @@ static void saveFile (const char *fileName, int seeLinks)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISREG (mode)) {
|
if (S_ISREG (mode)) {
|
||||||
saveRegularFile (fileName, &statbuf);
|
saveRegularFile (fileName, &statbuf);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Some day add support for tarring these up... but not today. :) */
|
||||||
|
// if (S_ISLNK(mode) || S_ISFIFO(mode) || S_ISBLK(mode) || S_ISCHR (mode) ) {
|
||||||
|
// fprintf (stderr, "%s: This version of tar can't store this type of file\n", fileName);
|
||||||
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The file is a strange type of file, ignore it.
|
* The file is a strange type of file, ignore it.
|
||||||
*/
|
*/
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
//#define BB_FDFLUSH
|
//#define BB_FDFLUSH
|
||||||
#define BB_FIND
|
#define BB_FIND
|
||||||
#define BB_FSCK_MINIX
|
#define BB_FSCK_MINIX
|
||||||
#define BB_MKFS_MINIX
|
//#define BB_MKFS_MINIX
|
||||||
#define BB_CHVT
|
#define BB_CHVT
|
||||||
#define BB_DEALLOCVT
|
#define BB_DEALLOCVT
|
||||||
#define BB_GREP
|
#define BB_GREP
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
Name: busybox
|
Name: busybox
|
||||||
Version: 0.33
|
Version: 0.35
|
||||||
Release: 1
|
Release: 1
|
||||||
Group: System/Utilities
|
Group: System/Utilities
|
||||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
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>
|
Packager : Erik Andersen <andersen@lineo.com>
|
||||||
Conflicts: fileutils grep shellutils
|
Conflicts: fileutils grep shellutils
|
||||||
Buildroot: /tmp/%{Name}-%{Version}
|
Buildroot: /tmp/%{Name}-%{Version}
|
||||||
Source: busybox-%{Version}.tar.gz
|
Source: %{Name}-%{Version}.tar.gz
|
||||||
|
|
||||||
%Description
|
%Description
|
||||||
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
|
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
|
||||||
@ -18,7 +18,7 @@ is makes an excellent environment for a "rescue" disk or any small or
|
|||||||
embedded system.
|
embedded system.
|
||||||
|
|
||||||
%Prep
|
%Prep
|
||||||
%setup -q -n busybox
|
%setup -q -n %{Name}-%{Version}
|
||||||
|
|
||||||
%Build
|
%Build
|
||||||
make
|
make
|
||||||
|
@ -42,7 +42,7 @@ static int df(char *device, const char *mountPoint)
|
|||||||
|
|
||||||
if (statfs(mountPoint, &s) != 0) {
|
if (statfs(mountPoint, &s) != 0) {
|
||||||
perror(mountPoint);
|
perror(mountPoint);
|
||||||
return 1;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.f_blocks > 0) {
|
if (s.f_blocks > 0) {
|
||||||
@ -64,7 +64,7 @@ static int df(char *device, const char *mountPoint)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int df_main(int argc, char **argv)
|
extern int df_main(int argc, char **argv)
|
||||||
@ -83,15 +83,15 @@ extern int df_main(int argc, char **argv)
|
|||||||
if ((mountEntry = findMountPoint(argv[1], mtab_file)) ==
|
if ((mountEntry = findMountPoint(argv[1], mtab_file)) ==
|
||||||
0) {
|
0) {
|
||||||
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
|
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
|
||||||
return 1;
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
return status;
|
exit( status);
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
return 0;
|
exit( TRUE);
|
||||||
} else {
|
} else {
|
||||||
FILE *mountTable;
|
FILE *mountTable;
|
||||||
struct mntent *mountEntry;
|
struct mntent *mountEntry;
|
||||||
@ -105,10 +105,10 @@ extern int df_main(int argc, char **argv)
|
|||||||
while ((mountEntry = getmntent(mountTable))) {
|
while ((mountEntry = getmntent(mountTable))) {
|
||||||
int status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
int status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
exit( status);
|
||||||
}
|
}
|
||||||
endmntent(mountTable);
|
endmntent(mountTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
exit( TRUE);
|
||||||
}
|
}
|
||||||
|
14
df.c
14
df.c
@ -42,7 +42,7 @@ static int df(char *device, const char *mountPoint)
|
|||||||
|
|
||||||
if (statfs(mountPoint, &s) != 0) {
|
if (statfs(mountPoint, &s) != 0) {
|
||||||
perror(mountPoint);
|
perror(mountPoint);
|
||||||
return 1;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s.f_blocks > 0) {
|
if (s.f_blocks > 0) {
|
||||||
@ -64,7 +64,7 @@ static int df(char *device, const char *mountPoint)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int df_main(int argc, char **argv)
|
extern int df_main(int argc, char **argv)
|
||||||
@ -83,15 +83,15 @@ extern int df_main(int argc, char **argv)
|
|||||||
if ((mountEntry = findMountPoint(argv[1], mtab_file)) ==
|
if ((mountEntry = findMountPoint(argv[1], mtab_file)) ==
|
||||||
0) {
|
0) {
|
||||||
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
|
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
|
||||||
return 1;
|
exit( FALSE);
|
||||||
}
|
}
|
||||||
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||||
if (status != 0)
|
if (status != 0)
|
||||||
return status;
|
exit( status);
|
||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
}
|
}
|
||||||
return 0;
|
exit( TRUE);
|
||||||
} else {
|
} else {
|
||||||
FILE *mountTable;
|
FILE *mountTable;
|
||||||
struct mntent *mountEntry;
|
struct mntent *mountEntry;
|
||||||
@ -105,10 +105,10 @@ extern int df_main(int argc, char **argv)
|
|||||||
while ((mountEntry = getmntent(mountTable))) {
|
while ((mountEntry = getmntent(mountTable))) {
|
||||||
int status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
int status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
exit( status);
|
||||||
}
|
}
|
||||||
endmntent(mountTable);
|
endmntent(mountTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
exit( TRUE);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
Name: busybox
|
Name: busybox
|
||||||
Version: 0.33
|
Version: 0.35
|
||||||
Release: 1
|
Release: 1
|
||||||
Group: System/Utilities
|
Group: System/Utilities
|
||||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
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>
|
Packager : Erik Andersen <andersen@lineo.com>
|
||||||
Conflicts: fileutils grep shellutils
|
Conflicts: fileutils grep shellutils
|
||||||
Buildroot: /tmp/%{Name}-%{Version}
|
Buildroot: /tmp/%{Name}-%{Version}
|
||||||
Source: busybox-%{Version}.tar.gz
|
Source: %{Name}-%{Version}.tar.gz
|
||||||
|
|
||||||
%Description
|
%Description
|
||||||
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
|
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
|
||||||
@ -18,7 +18,7 @@ is makes an excellent environment for a "rescue" disk or any small or
|
|||||||
embedded system.
|
embedded system.
|
||||||
|
|
||||||
%Prep
|
%Prep
|
||||||
%setup -q -n busybox
|
%setup -q -n %{Name}-%{Version}
|
||||||
|
|
||||||
%Build
|
%Build
|
||||||
make
|
make
|
||||||
|
102
gzip.c
102
gzip.c
@ -12,10 +12,11 @@
|
|||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
static const char gzip_usage[] =
|
static const char gzip_usage[] =
|
||||||
"gzip [OPTION]... [FILE]...\n\n"
|
"gzip [OPTION]... FILE\n\n"
|
||||||
"Compress FILEs with maximum compression.\n\n"
|
"Compress FILE with maximum compression.\n"
|
||||||
|
"When FILE is -, reads standard input. Implies -c.\n\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
"\t-c\tWrite output on standard output\n";
|
"\t-c\tWrite output to standard output instead of FILE.gz\n";
|
||||||
|
|
||||||
|
|
||||||
/* gzip.h -- common declarations for all gzip modules
|
/* gzip.h -- common declarations for all gzip modules
|
||||||
@ -1731,7 +1732,6 @@ DECLARE(uch, window, 2L*WSIZE);
|
|||||||
|
|
||||||
int ascii = 0; /* convert end-of-lines to local OS conventions */
|
int ascii = 0; /* convert end-of-lines to local OS conventions */
|
||||||
int decompress = 0; /* decompress (-d) */
|
int decompress = 0; /* decompress (-d) */
|
||||||
int tostdout = 0; /* uncompress to stdout (-c) */
|
|
||||||
int no_name = -1; /* don't save or restore the original file name */
|
int no_name = -1; /* don't save or restore the original file name */
|
||||||
int no_time = -1; /* don't save or restore the original file time */
|
int no_time = -1; /* don't save or restore the original file time */
|
||||||
int foreground; /* set if program run in foreground */
|
int foreground; /* set if program run in foreground */
|
||||||
@ -1770,13 +1770,25 @@ unsigned outcnt; /* bytes in output buffer */
|
|||||||
// char **argv;
|
// char **argv;
|
||||||
int gzip_main(int argc, char ** argv)
|
int gzip_main(int argc, char ** argv)
|
||||||
{
|
{
|
||||||
|
int result;
|
||||||
int inFileNum;
|
int inFileNum;
|
||||||
int outFileNum;
|
int outFileNum;
|
||||||
|
struct stat statBuf;
|
||||||
|
char* delFileName;
|
||||||
|
int tostdout = 0;
|
||||||
|
int fromstdin = 0;
|
||||||
|
|
||||||
|
if (argc==1)
|
||||||
|
usage(gzip_usage);
|
||||||
|
|
||||||
/* Parse any options */
|
/* Parse any options */
|
||||||
while (--argc > 0 && **(++argv) == '-') {
|
while (--argc > 0 && **(++argv) == '-') {
|
||||||
|
if (*((*argv)+1) == '\0') {
|
||||||
|
fromstdin = 1;
|
||||||
|
tostdout = 1;
|
||||||
|
}
|
||||||
while (*(++(*argv))) {
|
while (*(++(*argv))) {
|
||||||
|
fprintf(stderr, "**argv='%c'\n", **argv);
|
||||||
switch (**argv) {
|
switch (**argv) {
|
||||||
case 'c':
|
case 'c':
|
||||||
tostdout = 1;
|
tostdout = 1;
|
||||||
@ -1817,18 +1829,40 @@ int gzip_main(int argc, char ** argv)
|
|||||||
ALLOC(ush, tab_prefix1, 1L<<(BITS-1));
|
ALLOC(ush, tab_prefix1, 1L<<(BITS-1));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (fromstdin==1) {
|
||||||
|
strcpy(ofname, "stdin");
|
||||||
|
|
||||||
|
inFileNum=fileno(stdin);
|
||||||
|
time_stamp = 0; /* time unknown by default */
|
||||||
|
ifile_size = -1L; /* convention for unknown size */
|
||||||
|
} else {
|
||||||
|
/* Open up the input file */
|
||||||
|
if (*argv=='\0')
|
||||||
|
usage(gzip_usage);
|
||||||
|
strncpy(ifname, *argv, MAX_PATH_LEN);
|
||||||
|
|
||||||
|
/* Open input fille */
|
||||||
|
inFileNum=open( ifname, O_RDONLY);
|
||||||
|
if (inFileNum < 0) {
|
||||||
|
perror(ifname);
|
||||||
|
do_exit(WARNING);
|
||||||
|
}
|
||||||
|
/* Get the time stamp on the input file. */
|
||||||
|
result = stat(ifname, &statBuf);
|
||||||
|
if (result < 0) {
|
||||||
|
perror(ifname);
|
||||||
|
do_exit(WARNING);
|
||||||
|
}
|
||||||
|
time_stamp = statBuf.st_ctime;
|
||||||
|
ifile_size = statBuf.st_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (tostdout==1) {
|
if (tostdout==1) {
|
||||||
/* And get to work */
|
/* And get to work */
|
||||||
SET_BINARY_MODE(fileno(stdout));
|
|
||||||
strcpy(ifname, "stdin");
|
|
||||||
strcpy(ofname, "stdout");
|
strcpy(ofname, "stdout");
|
||||||
inFileNum=fileno(stdin);
|
|
||||||
outFileNum=fileno(stdout);
|
outFileNum=fileno(stdout);
|
||||||
|
SET_BINARY_MODE(fileno(stdout));
|
||||||
/* Get the time stamp on the input file. */
|
|
||||||
time_stamp = 0; /* time unknown by default */
|
|
||||||
|
|
||||||
ifile_size = -1L; /* convention for unknown size */
|
|
||||||
|
|
||||||
clear_bufs(); /* clear input and output buffers */
|
clear_bufs(); /* clear input and output buffers */
|
||||||
part_nb = 0;
|
part_nb = 0;
|
||||||
@ -1837,44 +1871,39 @@ int gzip_main(int argc, char ** argv)
|
|||||||
zip(inFileNum, outFileNum);
|
zip(inFileNum, outFileNum);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
int result;
|
|
||||||
struct stat statBuf;
|
|
||||||
|
|
||||||
/* And get to work */
|
/* And get to work */
|
||||||
if (*argv=='\0')
|
strncpy(ofname, ifname, MAX_PATH_LEN-4);
|
||||||
usage(gzip_usage);
|
|
||||||
strncpy(ifname, *argv, MAX_PATH_LEN);
|
|
||||||
strncpy(ofname, *argv, MAX_PATH_LEN-4);
|
|
||||||
strcat(ofname, ".gz");
|
strcat(ofname, ".gz");
|
||||||
|
|
||||||
inFileNum=open( ifname, O_RDONLY);
|
|
||||||
if (inFileNum < 0) {
|
|
||||||
perror(ifname);
|
|
||||||
do_exit(WARNING);
|
|
||||||
}
|
|
||||||
result = stat(ifname, &statBuf);
|
|
||||||
if (result < 0) {
|
|
||||||
perror(ifname);
|
|
||||||
do_exit(WARNING);
|
|
||||||
}
|
|
||||||
|
|
||||||
outFileNum=open( ofname, O_RDONLY);
|
/* Open output fille */
|
||||||
|
outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW);
|
||||||
if (outFileNum < 0) {
|
if (outFileNum < 0) {
|
||||||
perror(ofname);
|
perror(ofname);
|
||||||
do_exit(WARNING);
|
do_exit(WARNING);
|
||||||
}
|
}
|
||||||
SET_BINARY_MODE(outFileNum);
|
SET_BINARY_MODE(outFileNum);
|
||||||
|
/* Set permissions on the file */
|
||||||
/* Get the time stamp on the input file. */
|
fchmod(outFileNum, statBuf.st_mode);
|
||||||
time_stamp = statBuf.st_ctime; /* time unknown by default */
|
|
||||||
|
|
||||||
ifile_size = statBuf.st_size; /* convention for unknown size */
|
|
||||||
|
|
||||||
clear_bufs(); /* clear input and output buffers */
|
clear_bufs(); /* clear input and output buffers */
|
||||||
part_nb = 0;
|
part_nb = 0;
|
||||||
|
|
||||||
/* Actually do the compression/decompression. */
|
/* Actually do the compression/decompression. */
|
||||||
zip(inFileNum, outFileNum);
|
result=zip(inFileNum, outFileNum);
|
||||||
|
close( outFileNum);
|
||||||
|
close( inFileNum);
|
||||||
|
/* Delete the original file */
|
||||||
|
if (result == OK)
|
||||||
|
delFileName=ifname;
|
||||||
|
else
|
||||||
|
delFileName=ofname;
|
||||||
|
|
||||||
|
if (unlink (delFileName) < 0) {
|
||||||
|
perror (delFileName);
|
||||||
|
exit( FALSE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
do_exit(exit_code);
|
do_exit(exit_code);
|
||||||
@ -3198,6 +3227,7 @@ int zip(in, out)
|
|||||||
|
|
||||||
/* Write the header to the gzip file. See algorithm.doc for the format */
|
/* Write the header to the gzip file. See algorithm.doc for the format */
|
||||||
|
|
||||||
|
|
||||||
method = DEFLATED;
|
method = DEFLATED;
|
||||||
put_byte(GZIP_MAGIC[0]); /* magic header */
|
put_byte(GZIP_MAGIC[0]); /* magic header */
|
||||||
put_byte(GZIP_MAGIC[1]);
|
put_byte(GZIP_MAGIC[1]);
|
||||||
|
13
more.c
13
more.c
@ -2,10 +2,11 @@
|
|||||||
* Mini more implementation for busybox
|
* Mini more implementation for busybox
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 by Lineo, inc.
|
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
|
||||||
* Blended by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
*
|
||||||
* based on the original more implementation and code from the Debian
|
* Latest version blended together by Erik Andersen <andersen@lineo.com>,
|
||||||
* boot-floppies team.
|
* based on the original more implementation by Bruce, and code from the
|
||||||
|
* Debian boot-floppies team.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -68,7 +69,7 @@ static const char more_usage[] = "more [file ...]\n";
|
|||||||
#define TERMINAL_HEIGHT 24
|
#define TERMINAL_HEIGHT 24
|
||||||
|
|
||||||
|
|
||||||
#if defined BB_FEATURE_AUTOWIDTH && ! defined USE_OLD_TERMIO
|
#if defined BB_FEATURE_AUTOWIDTH
|
||||||
static int terminal_width = 0, terminal_height = 0;
|
static int terminal_width = 0, terminal_height = 0;
|
||||||
#else
|
#else
|
||||||
#define terminal_width TERMINAL_WIDTH
|
#define terminal_width TERMINAL_WIDTH
|
||||||
@ -84,7 +85,7 @@ extern int more_main(int argc, char **argv)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
#ifdef BB_FEATURE_AUTOWIDTH
|
#ifdef BB_FEATURE_AUTOWIDTH
|
||||||
struct winsize win;
|
struct winsize win = {0,0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
argc--;
|
argc--;
|
||||||
|
2
regexp.c
2
regexp.c
@ -504,7 +504,7 @@ extern regexp *regcomp(char* text)
|
|||||||
int token;
|
int token;
|
||||||
int peek;
|
int peek;
|
||||||
char *build;
|
char *build;
|
||||||
regexp *re;
|
regexp *re; // Ignore compiler whining. If we longjmp, we don't use re anymore.
|
||||||
|
|
||||||
|
|
||||||
/* prepare for error handling */
|
/* prepare for error handling */
|
||||||
|
41
tar.c
41
tar.c
@ -10,6 +10,9 @@
|
|||||||
* Modified for busybox by Erik Andersen <andersee@debian.org>
|
* Modified for busybox by Erik Andersen <andersee@debian.org>
|
||||||
* Adjusted to grok stdin/stdout options.
|
* Adjusted to grok stdin/stdout options.
|
||||||
*
|
*
|
||||||
|
* Modified to handle device special files by Matt Porter
|
||||||
|
* <porter@debian.org>
|
||||||
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -34,6 +37,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
|
||||||
static const char tar_usage[] =
|
static const char tar_usage[] =
|
||||||
@ -377,12 +381,15 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
int uid;
|
int uid;
|
||||||
int gid;
|
int gid;
|
||||||
int checkSum;
|
int checkSum;
|
||||||
|
int major;
|
||||||
|
int minor;
|
||||||
long size;
|
long size;
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
const char *name;
|
const char *name;
|
||||||
int cc;
|
int cc;
|
||||||
int hardLink;
|
int hardLink;
|
||||||
int softLink;
|
int softLink;
|
||||||
|
int devFileFlag;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the block is completely empty, then this is the end of the
|
* If the block is completely empty, then this is the end of the
|
||||||
@ -411,6 +418,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
size = getOctal (hp->size, sizeof (hp->size));
|
size = getOctal (hp->size, sizeof (hp->size));
|
||||||
mtime = getOctal (hp->mtime, sizeof (hp->mtime));
|
mtime = getOctal (hp->mtime, sizeof (hp->mtime));
|
||||||
checkSum = getOctal (hp->checkSum, sizeof (hp->checkSum));
|
checkSum = getOctal (hp->checkSum, sizeof (hp->checkSum));
|
||||||
|
major = getOctal (hp->devMajor, sizeof (hp->devMajor));
|
||||||
|
minor = getOctal (hp->devMinor, sizeof (hp->devMinor));
|
||||||
|
|
||||||
if ((mode < 0) || (uid < 0) || (gid < 0) || (size < 0)) {
|
if ((mode < 0) || (uid < 0) || (gid < 0) || (size < 0)) {
|
||||||
if (badHeader==FALSE)
|
if (badHeader==FALSE)
|
||||||
@ -423,6 +432,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
|
|
||||||
badHeader = FALSE;
|
badHeader = FALSE;
|
||||||
skipFileFlag = FALSE;
|
skipFileFlag = FALSE;
|
||||||
|
devFileFlag = FALSE;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for the file modes.
|
* Check for the file modes.
|
||||||
@ -434,12 +444,10 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
(hp->typeFlag == TAR_TYPE_SOFT_LINK - '0'));
|
(hp->typeFlag == TAR_TYPE_SOFT_LINK - '0'));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for a directory or a regular file.
|
* Check for a directory.
|
||||||
*/
|
*/
|
||||||
if (name[strlen (name) - 1] == '/')
|
if (name[strlen (name) - 1] == '/')
|
||||||
mode |= S_IFDIR;
|
mode |= S_IFDIR;
|
||||||
else if ((mode & S_IFMT) == 0)
|
|
||||||
mode |= S_IFREG;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for absolute paths in the file.
|
* Check for absolute paths in the file.
|
||||||
@ -462,7 +470,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
* If not, then set up to skip it.
|
* If not, then set up to skip it.
|
||||||
*/
|
*/
|
||||||
if (wantFileName (name, fileCount, fileTable) == FALSE) {
|
if (wantFileName (name, fileCount, fileTable) == FALSE) {
|
||||||
if (!hardLink && !softLink && S_ISREG (mode)) {
|
if ( !hardLink && !softLink && (S_ISREG (mode) || S_ISCHR (mode)
|
||||||
|
|| S_ISBLK (mode) || S_ISSOCK(mode) || S_ISFIFO(mode) ) ) {
|
||||||
inHeader = (size == 0)? TRUE : FALSE;
|
inHeader = (size == 0)? TRUE : FALSE;
|
||||||
dataCc = size;
|
dataCc = size;
|
||||||
}
|
}
|
||||||
@ -487,7 +496,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
printf (" (link to \"%s\")", hp->linkName);
|
printf (" (link to \"%s\")", hp->linkName);
|
||||||
else if (softLink)
|
else if (softLink)
|
||||||
printf (" (symlink to \"%s\")", hp->linkName);
|
printf (" (symlink to \"%s\")", hp->linkName);
|
||||||
else if (S_ISREG (mode)) {
|
else if (S_ISREG (mode) || S_ISCHR (mode) || S_ISBLK (mode) ||
|
||||||
|
S_ISSOCK(mode) || S_ISFIFO(mode) ) {
|
||||||
inHeader = (size == 0)? TRUE : FALSE;
|
inHeader = (size == 0)? TRUE : FALSE;
|
||||||
dataCc = size;
|
dataCc = size;
|
||||||
}
|
}
|
||||||
@ -543,8 +553,17 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
*/
|
*/
|
||||||
if (tostdoutFlag == TRUE)
|
if (tostdoutFlag == TRUE)
|
||||||
outFd = STDOUT;
|
outFd = STDOUT;
|
||||||
else
|
else {
|
||||||
outFd = open (name, O_WRONLY | O_CREAT | O_TRUNC, mode);
|
if ( S_ISCHR(mode) || S_ISBLK(mode) || S_ISSOCK(mode) ) {
|
||||||
|
devFileFlag = TRUE;
|
||||||
|
outFd = mknod (name, mode, makedev(major, minor) );
|
||||||
|
}
|
||||||
|
else if (S_ISFIFO(mode) ) {
|
||||||
|
outFd = mkfifo(name, mode);
|
||||||
|
} else {
|
||||||
|
outFd = open (name, O_WRONLY | O_CREAT | O_TRUNC, mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (outFd < 0) {
|
if (outFd < 0) {
|
||||||
perror (name);
|
perror (name);
|
||||||
@ -555,7 +574,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
|
|||||||
/*
|
/*
|
||||||
* If the file is empty, then that's all we need to do.
|
* If the file is empty, then that's all we need to do.
|
||||||
*/
|
*/
|
||||||
if (size == 0 && tostdoutFlag == FALSE) {
|
if (size == 0 && (tostdoutFlag == FALSE) && (devFileFlag == FALSE)) {
|
||||||
(void) close (outFd);
|
(void) close (outFd);
|
||||||
outFd = -1;
|
outFd = -1;
|
||||||
}
|
}
|
||||||
@ -735,13 +754,17 @@ static void saveFile (const char *fileName, int seeLinks)
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISREG (mode)) {
|
if (S_ISREG (mode)) {
|
||||||
saveRegularFile (fileName, &statbuf);
|
saveRegularFile (fileName, &statbuf);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Some day add support for tarring these up... but not today. :) */
|
||||||
|
// if (S_ISLNK(mode) || S_ISFIFO(mode) || S_ISBLK(mode) || S_ISCHR (mode) ) {
|
||||||
|
// fprintf (stderr, "%s: This version of tar can't store this type of file\n", fileName);
|
||||||
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The file is a strange type of file, ignore it.
|
* The file is a strange type of file, ignore it.
|
||||||
*/
|
*/
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
* Mini more implementation for busybox
|
* Mini more implementation for busybox
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Copyright (C) 1999 by Lineo, inc.
|
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
|
||||||
* Blended by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
*
|
||||||
* based on the original more implementation and code from the Debian
|
* Latest version blended together by Erik Andersen <andersen@lineo.com>,
|
||||||
* boot-floppies team.
|
* based on the original more implementation by Bruce, and code from the
|
||||||
|
* Debian boot-floppies team.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -68,7 +69,7 @@ static const char more_usage[] = "more [file ...]\n";
|
|||||||
#define TERMINAL_HEIGHT 24
|
#define TERMINAL_HEIGHT 24
|
||||||
|
|
||||||
|
|
||||||
#if defined BB_FEATURE_AUTOWIDTH && ! defined USE_OLD_TERMIO
|
#if defined BB_FEATURE_AUTOWIDTH
|
||||||
static int terminal_width = 0, terminal_height = 0;
|
static int terminal_width = 0, terminal_height = 0;
|
||||||
#else
|
#else
|
||||||
#define terminal_width TERMINAL_WIDTH
|
#define terminal_width TERMINAL_WIDTH
|
||||||
@ -84,7 +85,7 @@ extern int more_main(int argc, char **argv)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
#ifdef BB_FEATURE_AUTOWIDTH
|
#ifdef BB_FEATURE_AUTOWIDTH
|
||||||
struct winsize win;
|
struct winsize win = {0,0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
argc--;
|
argc--;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user