summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog28
-rw-r--r--Makefile14
-rw-r--r--archival/gzip.c98
-rw-r--r--archival/tar.c41
-rw-r--r--busybox.def.h2
-rw-r--r--busybox.spec6
-rw-r--r--coreutils/df.c14
-rw-r--r--df.c14
-rw-r--r--examples/busybox.spec6
-rw-r--r--gzip.c98
-rw-r--r--more.c13
-rw-r--r--regexp.c2
-rw-r--r--tar.c41
-rw-r--r--util-linux/more.c13
14 files changed, 259 insertions, 131 deletions
diff --git a/Changelog b/Changelog
index 7279efe..f94855e 100644
--- a/Changelog
+++ b/Changelog
@@ -1,11 +1,21 @@
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)
* tar now accepts --help
* 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
+ * 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
* 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.
Now uses my_getpwuid and my_getgrgid.
- -Erik Andersen
+ -Erik Andersen, Nov 8, 1999
0.33
* Fixed a bug where init could hang instead of rebooting.
@@ -39,7 +49,7 @@
state the real root device name)
* merged some redundant code from mtab.c/df.c into utility.c
- -Erik Andersen
+ -Erik Andersen, Nov 5, 1999
0.32
* 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>.
- -Erik Andersen
+ -Erik Andersen, Nov 4, 1999
0.31
* 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
glibc 2.0.7 since it is much smaller than that latest and greatest.
- -Erik Andersen
+ -Erik Andersen, Oct 21, 1999
0.30
Major changes -- lots of stuff rewritten. Many thanks to Lineo for
@@ -152,7 +162,11 @@
* sfdisk -- Added from util-linux (minus internationalization and such).
* 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
mini-netcat (mnc) rewritten.
diff --git a/Makefile b/Makefile
index 53a7d8e..ddf356f 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@
PROG=busybox
-VERSION=0.34
+VERSION=0.35
BUILDTIME=$(shell date "+%Y%m%d-%H%M")
# Comment out the following to make a debuggable build
@@ -58,14 +58,14 @@ OBJECTS=$(shell ./busybox.sh)
CFLAGS+= -DBB_VER='"$(VERSION)"'
CFLAGS+= -DBB_BT='"$(BUILDTIME)"'
-all: busybox links
+all: busybox busybox.links
busybox: $(OBJECTS)
$(CC) $(LDFLAGS) -o $(PROG) $(OBJECTS) $(LIBRARIES)
$(STRIP)
-links:
- - ./busybox.mkll | sort >busybox.links
+busybox.links:
+ - ./busybox.mkll | sort >$@
clean:
- rm -f $(PROG) busybox.links *~ *.o core
@@ -80,3 +80,9 @@ $(OBJECTS): busybox.def.h internal.h Makefile
install: $(PROG)
install.sh $(BINDIR)
+whichversion:
+ @echo $(VERSION)
+
+release: distclean
+ (cd .. ; cp -a busybox busybox-$(VERSION); tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION))
+
diff --git a/archival/gzip.c b/archival/gzip.c
index 500d6d7..8f2c1c4 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -12,10 +12,11 @@
//#endif
static const char gzip_usage[] =
- "gzip [OPTION]... [FILE]...\n\n"
- "Compress FILEs with maximum compression.\n\n"
+ "gzip [OPTION]... FILE\n\n"
+ "Compress FILE with maximum compression.\n"
+ "When FILE is -, reads standard input. Implies -c.\n\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
@@ -1731,7 +1732,6 @@ DECLARE(uch, window, 2L*WSIZE);
int ascii = 0; /* convert end-of-lines to local OS conventions */
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_time = -1; /* don't save or restore the original file time */
int foreground; /* set if program run in foreground */
@@ -1770,13 +1770,25 @@ unsigned outcnt; /* bytes in output buffer */
// char **argv;
int gzip_main(int argc, char ** argv)
{
-
+ int result;
int inFileNum;
int outFileNum;
+ struct stat statBuf;
+ char* delFileName;
+ int tostdout = 0;
+ int fromstdin = 0;
+
+ if (argc==1)
+ usage(gzip_usage);
/* Parse any options */
while (--argc > 0 && **(++argv) == '-') {
+ if (*((*argv)+1) == '\0') {
+ fromstdin = 1;
+ tostdout = 1;
+ }
while (*(++(*argv))) {
+ fprintf(stderr, "**argv='%c'\n", **argv);
switch (**argv) {
case 'c':
tostdout = 1;
@@ -1817,64 +1829,81 @@ int gzip_main(int argc, char ** argv)
ALLOC(ush, tab_prefix1, 1L<<(BITS-1));
#endif
- if (tostdout==1) {
- /* And get to work */
- SET_BINARY_MODE(fileno(stdout));
- strcpy(ifname, "stdin");
- strcpy(ofname, "stdout");
- inFileNum=fileno(stdin);
- outFileNum=fileno(stdout);
+ if (fromstdin==1) {
+ strcpy(ofname, "stdin");
- /* Get the time stamp on the input file. */
+ inFileNum=fileno(stdin);
time_stamp = 0; /* time unknown by default */
-
ifile_size = -1L; /* convention for unknown size */
-
- clear_bufs(); /* clear input and output buffers */
- part_nb = 0;
-
- /* Actually do the compression/decompression. */
- zip(inFileNum, outFileNum);
-
} else {
- int result;
- struct stat statBuf;
-
- /* And get to work */
+ /* Open up the input file */
if (*argv=='\0')
usage(gzip_usage);
strncpy(ifname, *argv, MAX_PATH_LEN);
- strncpy(ofname, *argv, MAX_PATH_LEN-4);
- strcat(ofname, ".gz");
+ /* 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;
+ }
+
- outFileNum=open( ofname, O_RDONLY);
+ if (tostdout==1) {
+ /* And get to work */
+ strcpy(ofname, "stdout");
+ outFileNum=fileno(stdout);
+ SET_BINARY_MODE(fileno(stdout));
+
+ clear_bufs(); /* clear input and output buffers */
+ part_nb = 0;
+
+ /* Actually do the compression/decompression. */
+ zip(inFileNum, outFileNum);
+
+ } else {
+
+ /* And get to work */
+ strncpy(ofname, ifname, MAX_PATH_LEN-4);
+ strcat(ofname, ".gz");
+
+
+ /* Open output fille */
+ outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW);
if (outFileNum < 0) {
perror(ofname);
do_exit(WARNING);
}
SET_BINARY_MODE(outFileNum);
-
- /* Get the time stamp on the input file. */
- time_stamp = statBuf.st_ctime; /* time unknown by default */
-
- ifile_size = statBuf.st_size; /* convention for unknown size */
+ /* Set permissions on the file */
+ fchmod(outFileNum, statBuf.st_mode);
clear_bufs(); /* clear input and output buffers */
part_nb = 0;
/* 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);
@@ -3198,6 +3227,7 @@ int zip(in, out)
/* Write the header to the gzip file. See algorithm.doc for the format */
+
method = DEFLATED;
put_byte(GZIP_MAGIC[0]); /* magic header */
put_byte(GZIP_MAGIC[1]);
diff --git a/archival/tar.c b/archival/tar.c
index ed6f3b6..5478af8 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -10,6 +10,9 @@
* Modified for busybox by Erik Andersen <andersee@debian.org>
* 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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -34,6 +37,7 @@
#include <fcntl.h>
#include <signal.h>
#include <time.h>
+#include <sys/types.h>
static const char tar_usage[] =
@@ -377,12 +381,15 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
int uid;
int gid;
int checkSum;
+ int major;
+ int minor;
long size;
time_t mtime;
const char *name;
int cc;
int hardLink;
int softLink;
+ int devFileFlag;
/*
* 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));
mtime = getOctal (hp->mtime, sizeof (hp->mtime));
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 (badHeader==FALSE)
@@ -423,6 +432,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
badHeader = FALSE;
skipFileFlag = FALSE;
+ devFileFlag = FALSE;
/*
* Check for the file modes.
@@ -434,12 +444,10 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
(hp->typeFlag == TAR_TYPE_SOFT_LINK - '0'));
/*
- * Check for a directory or a regular file.
+ * Check for a directory.
*/
if (name[strlen (name) - 1] == '/')
mode |= S_IFDIR;
- else if ((mode & S_IFMT) == 0)
- mode |= S_IFREG;
/*
* 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 (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;
dataCc = size;
}
@@ -487,7 +496,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
printf (" (link to \"%s\")", hp->linkName);
else if (softLink)
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;
dataCc = size;
}
@@ -543,8 +553,17 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
*/
if (tostdoutFlag == TRUE)
outFd = STDOUT;
- else
- outFd = open (name, O_WRONLY | O_CREAT | O_TRUNC, mode);
+ else {
+ 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) {
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 (size == 0 && tostdoutFlag == FALSE) {
+ if (size == 0 && (tostdoutFlag == FALSE) && (devFileFlag == FALSE)) {
(void) close (outFd);
outFd = -1;
}
@@ -735,12 +754,16 @@ static void saveFile (const char *fileName, int seeLinks)
return;
}
-
if (S_ISREG (mode)) {
saveRegularFile (fileName, &statbuf);
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.
diff --git a/busybox.def.h b/busybox.def.h
index 79cbb27..5896861 100644
--- a/busybox.def.h
+++ b/busybox.def.h
@@ -17,7 +17,7 @@
//#define BB_FDFLUSH
#define BB_FIND
#define BB_FSCK_MINIX
-#define BB_MKFS_MINIX
+//#define BB_MKFS_MINIX
#define BB_CHVT
#define BB_DEALLOCVT
#define BB_GREP
diff --git a/busybox.spec b/busybox.spec
index 635ffe0..5e6befb 100644
--- a/busybox.spec
+++ b/busybox.spec
@@ -1,5 +1,5 @@
Name: busybox
-Version: 0.33
+Version: 0.35
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-%{Version}.tar.gz
+Source: %{Name}-%{Version}.tar.gz
%Description
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.
%Prep
-%setup -q -n busybox
+%setup -q -n %{Name}-%{Version}
%Build
make
diff --git a/coreutils/df.c b/coreutils/df.c
index a84a330..8b8db78 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -42,7 +42,7 @@ static int df(char *device, const char *mountPoint)
if (statfs(mountPoint, &s) != 0) {
perror(mountPoint);
- return 1;
+ return FALSE;
}
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)
@@ -83,15 +83,15 @@ extern int df_main(int argc, char **argv)
if ((mountEntry = findMountPoint(argv[1], mtab_file)) ==
0) {
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
- return 1;
+ exit( FALSE);
}
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
if (status != 0)
- return status;
+ exit( status);
argc--;
argv++;
}
- return 0;
+ exit( TRUE);
} else {
FILE *mountTable;
struct mntent *mountEntry;
@@ -105,10 +105,10 @@ extern int df_main(int argc, char **argv)
while ((mountEntry = getmntent(mountTable))) {
int status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
if (status)
- return status;
+ exit( status);
}
endmntent(mountTable);
}
- return 0;
+ exit( TRUE);
}
diff --git a/df.c b/df.c
index a84a330..8b8db78 100644
--- a/df.c
+++ b/df.c
@@ -42,7 +42,7 @@ static int df(char *device, const char *mountPoint)
if (statfs(mountPoint, &s) != 0) {
perror(mountPoint);
- return 1;
+ return FALSE;
}
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)
@@ -83,15 +83,15 @@ extern int df_main(int argc, char **argv)
if ((mountEntry = findMountPoint(argv[1], mtab_file)) ==
0) {
fprintf(stderr, "%s: can't find mount point.\n", argv[1]);
- return 1;
+ exit( FALSE);
}
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
if (status != 0)
- return status;
+ exit( status);
argc--;
argv++;
}
- return 0;
+ exit( TRUE);
} else {
FILE *mountTable;
struct mntent *mountEntry;
@@ -105,10 +105,10 @@ extern int df_main(int argc, char **argv)
while ((mountEntry = getmntent(mountTable))) {
int status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
if (status)
- return status;
+ exit( status);
}
endmntent(mountTable);
}
- return 0;
+ exit( TRUE);
}
diff --git a/examples/busybox.spec b/examples/busybox.spec
index 635ffe0..5e6befb 100644
--- a/examples/busybox.spec
+++ b/examples/busybox.spec
@@ -1,5 +1,5 @@
Name: busybox
-Version: 0.33
+Version: 0.35
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-%{Version}.tar.gz
+Source: %{Name}-%{Version}.tar.gz
%Description
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.
%Prep
-%setup -q -n busybox
+%setup -q -n %{Name}-%{Version}
%Build
make
diff --git a/gzip.c b/gzip.c
index 500d6d7..8f2c1c4 100644
--- a/gzip.c
+++ b/gzip.c
@@ -12,10 +12,11 @@
//#endif
static const char gzip_usage[] =
- "gzip [OPTION]... [FILE]...\n\n"
- "Compress FILEs with maximum compression.\n\n"
+ "gzip [OPTION]... FILE\n\n"
+ "Compress FILE with maximum compression.\n"
+ "When FILE is -, reads standard input. Implies -c.\n\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
@@ -1731,7 +1732,6 @@ DECLARE(uch, window, 2L*WSIZE);
int ascii = 0; /* convert end-of-lines to local OS conventions */
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_time = -1; /* don't save or restore the original file time */
int foreground; /* set if program run in foreground */
@@ -1770,13 +1770,25 @@ unsigned outcnt; /* bytes in output buffer */
// char **argv;
int gzip_main(int argc, char ** argv)
{
-
+ int result;
int inFileNum;
int outFileNum;
+ struct stat statBuf;
+ char* delFileName;
+ int tostdout = 0;
+ int fromstdin = 0;
+
+ if (argc==1)
+ usage(gzip_usage);
/* Parse any options */
while (--argc > 0 && **(++argv) == '-') {
+ if (*((*argv)+1) == '\0') {
+ fromstdin = 1;
+ tostdout = 1;
+ }
while (*(++(*argv))) {
+ fprintf(stderr, "**argv='%c'\n", **argv);
switch (**argv) {
case 'c':
tostdout = 1;
@@ -1817,64 +1829,81 @@ int gzip_main(int argc, char ** argv)
ALLOC(ush, tab_prefix1, 1L<<(BITS-1));
#endif
- if (tostdout==1) {
- /* And get to work */
- SET_BINARY_MODE(fileno(stdout));
- strcpy(ifname, "stdin");
- strcpy(ofname, "stdout");
- inFileNum=fileno(stdin);
- outFileNum=fileno(stdout);
+ if (fromstdin==1) {
+ strcpy(ofname, "stdin");
- /* Get the time stamp on the input file. */
+ inFileNum=fileno(stdin);
time_stamp = 0; /* time unknown by default */
-
ifile_size = -1L; /* convention for unknown size */
-
- clear_bufs(); /* clear input and output buffers */
- part_nb = 0;
-
- /* Actually do the compression/decompression. */
- zip(inFileNum, outFileNum);
-
} else {
- int result;
- struct stat statBuf;
-
- /* And get to work */
+ /* Open up the input file */
if (*argv=='\0')
usage(gzip_usage);
strncpy(ifname, *argv, MAX_PATH_LEN);
- strncpy(ofname, *argv, MAX_PATH_LEN-4);
- strcat(ofname, ".gz");
+ /* 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;
+ }
+
- outFileNum=open( ofname, O_RDONLY);
+ if (tostdout==1) {
+ /* And get to work */
+ strcpy(ofname, "stdout");
+ outFileNum=fileno(stdout);
+ SET_BINARY_MODE(fileno(stdout));
+
+ clear_bufs(); /* clear input and output buffers */
+ part_nb = 0;
+
+ /* Actually do the compression/decompression. */
+ zip(inFileNum, outFileNum);
+
+ } else {
+
+ /* And get to work */
+ strncpy(ofname, ifname, MAX_PATH_LEN-4);
+ strcat(ofname, ".gz");
+
+
+ /* Open output fille */
+ outFileNum=open( ofname, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW);
if (outFileNum < 0) {
perror(ofname);
do_exit(WARNING);
}
SET_BINARY_MODE(outFileNum);
-
- /* Get the time stamp on the input file. */
- time_stamp = statBuf.st_ctime; /* time unknown by default */
-
- ifile_size = statBuf.st_size; /* convention for unknown size */
+ /* Set permissions on the file */
+ fchmod(outFileNum, statBuf.st_mode);
clear_bufs(); /* clear input and output buffers */
part_nb = 0;
/* 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);
@@ -3198,6 +3227,7 @@ int zip(in, out)
/* Write the header to the gzip file. See algorithm.doc for the format */
+
method = DEFLATED;
put_byte(GZIP_MAGIC[0]); /* magic header */
put_byte(GZIP_MAGIC[1]);
diff --git a/more.c b/more.c
index 515857e..7d0ddb8 100644
--- a/more.c
+++ b/more.c
@@ -2,10 +2,11 @@
* Mini more implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
- * Blended by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
- * based on the original more implementation and code from the Debian
- * boot-floppies team.
+ * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
+ *
+ * Latest version blended together by Erik Andersen <andersen@lineo.com>,
+ * 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
* 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
-#if defined BB_FEATURE_AUTOWIDTH && ! defined USE_OLD_TERMIO
+#if defined BB_FEATURE_AUTOWIDTH
static int terminal_width = 0, terminal_height = 0;
#else
#define terminal_width TERMINAL_WIDTH
@@ -84,7 +85,7 @@ extern int more_main(int argc, char **argv)
struct stat st;
FILE *file;
#ifdef BB_FEATURE_AUTOWIDTH
- struct winsize win;
+ struct winsize win = {0,0};
#endif
argc--;
diff --git a/regexp.c b/regexp.c
index 5500b1d..fb01707 100644
--- a/regexp.c
+++ b/regexp.c
@@ -504,7 +504,7 @@ extern regexp *regcomp(char* text)
int token;
int peek;
char *build;
- regexp *re;
+ regexp *re; // Ignore compiler whining. If we longjmp, we don't use re anymore.
/* prepare for error handling */
diff --git a/tar.c b/tar.c
index ed6f3b6..5478af8 100644
--- a/tar.c
+++ b/tar.c
@@ -10,6 +10,9 @@
* Modified for busybox by Erik Andersen <andersee@debian.org>
* 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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -34,6 +37,7 @@
#include <fcntl.h>
#include <signal.h>
#include <time.h>
+#include <sys/types.h>
static const char tar_usage[] =
@@ -377,12 +381,15 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
int uid;
int gid;
int checkSum;
+ int major;
+ int minor;
long size;
time_t mtime;
const char *name;
int cc;
int hardLink;
int softLink;
+ int devFileFlag;
/*
* 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));
mtime = getOctal (hp->mtime, sizeof (hp->mtime));
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 (badHeader==FALSE)
@@ -423,6 +432,7 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
badHeader = FALSE;
skipFileFlag = FALSE;
+ devFileFlag = FALSE;
/*
* Check for the file modes.
@@ -434,12 +444,10 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
(hp->typeFlag == TAR_TYPE_SOFT_LINK - '0'));
/*
- * Check for a directory or a regular file.
+ * Check for a directory.
*/
if (name[strlen (name) - 1] == '/')
mode |= S_IFDIR;
- else if ((mode & S_IFMT) == 0)
- mode |= S_IFREG;
/*
* 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 (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;
dataCc = size;
}
@@ -487,7 +496,8 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
printf (" (link to \"%s\")", hp->linkName);
else if (softLink)
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;
dataCc = size;
}
@@ -543,8 +553,17 @@ readHeader (const TarHeader * hp, int fileCount, char **fileTable)
*/
if (tostdoutFlag == TRUE)
outFd = STDOUT;
- else
- outFd = open (name, O_WRONLY | O_CREAT | O_TRUNC, mode);
+ else {
+ 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) {
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 (size == 0 && tostdoutFlag == FALSE) {
+ if (size == 0 && (tostdoutFlag == FALSE) && (devFileFlag == FALSE)) {
(void) close (outFd);
outFd = -1;
}
@@ -735,12 +754,16 @@ static void saveFile (const char *fileName, int seeLinks)
return;
}
-
if (S_ISREG (mode)) {
saveRegularFile (fileName, &statbuf);
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.
diff --git a/util-linux/more.c b/util-linux/more.c
index 515857e..7d0ddb8 100644
--- a/util-linux/more.c
+++ b/util-linux/more.c
@@ -2,10 +2,11 @@
* Mini more implementation for busybox
*
*
- * Copyright (C) 1999 by Lineo, inc.
- * Blended by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
- * based on the original more implementation and code from the Debian
- * boot-floppies team.
+ * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
+ *
+ * Latest version blended together by Erik Andersen <andersen@lineo.com>,
+ * 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
* 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
-#if defined BB_FEATURE_AUTOWIDTH && ! defined USE_OLD_TERMIO
+#if defined BB_FEATURE_AUTOWIDTH
static int terminal_width = 0, terminal_height = 0;
#else
#define terminal_width TERMINAL_WIDTH
@@ -84,7 +85,7 @@ extern int more_main(int argc, char **argv)
struct stat st;
FILE *file;
#ifdef BB_FEATURE_AUTOWIDTH
- struct winsize win;
+ struct winsize win = {0,0};
#endif
argc--;