First pass at fixing tar segfault, and more portability updates.
authorErik Andersen <andersen@codepoet.org>
Sat, 20 May 2000 00:40:08 +0000 (00:40 -0000)
committerErik Andersen <andersen@codepoet.org>
Sat, 20 May 2000 00:40:08 +0000 (00:40 -0000)
 -Erik

TODO
archival/tar.c
cmdedit.c
fsck_minix.c
internal.h
mkfs_minix.c
shell/cmdedit.c
tar.c
util-linux/fsck_minix.c
util-linux/mkfs_minix.c

diff --git a/TODO b/TODO
index 7ab43c36d1f867165ac0cf5561110ae74a037df8..febd9bf51ba18a5716d65975373b05391ded7fb2 100644 (file)
--- a/TODO
+++ b/TODO
@@ -22,6 +22,11 @@ Bugs that need fixing:
  - 'grep *foo file' segfaults
  - ps dirent race bug (need to stat the file before attempting chdir)
 
+
+/busybox tar tvf
+Segmentation fault (core dumped)
+
+
 -----------
 
 * Make insmod actually work
index 6784d80ff0cd2ee05a5ca3f78233687267656ba5..c5aad45d6b568289f65f8e80aae47f01de1b9291 100644 (file)
@@ -185,7 +185,7 @@ extern int tar_main(int argc, char **argv)
                usage(tar_usage);
 
        /* Parse any options */
-       while (--argc > 0 && **(++argv) == '-') {
+       while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
                stopIt=FALSE;
                while (stopIt==FALSE && *(++(*argv))) {
                        switch (**argv) {
@@ -265,7 +265,8 @@ extern int tar_main(int argc, char **argv)
 #else
                exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList));
 #endif
-       } else {
+       }
+       if (listFlag == TRUE || extractFlag == TRUE) {
                exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList));
        }
 
index e4c88c265ac744165d475cb5f3cced4cf2973581..22831b10c7c96763e2511fb6994fb141080616b8 100644 (file)
--- a/cmdedit.c
+++ b/cmdedit.c
@@ -70,6 +70,12 @@ static struct history *his_end = NULL;       /* Last element in command line list */
 
 /* Current termio and the previous termio before starting sh */
 struct termios initial_settings, new_settings;
+
+
+#ifndef        _POSIX_VDISABLE
+#define        _POSIX_VDISABLE '\0'
+#endif
+
 #endif
 
 
index 7d27566b8579caedb1d4e7451d8ca1308feac635..1e482f3f989f29f10b38f16ba4e2ceab91404e32 100644 (file)
@@ -97,6 +97,7 @@
 #include <termios.h>
 #include <mntent.h>
 #include <sys/stat.h>
+#include <sys/param.h>
 
 #include <linux/fs.h>
 #include <linux/minix_fs.h>
index 9c55f5a49839220bbf17d386314cb2db867149a6..909bf64739a86ecccc93d7122da4cac096ed20ee 100644 (file)
@@ -284,18 +284,6 @@ int nfsmount(const char *spec, const char *node, unsigned long *flags,
        char **extra_opts, char **mount_opts, int running_bg);
 #endif
 
-#if defined (BB_FSCK_MINIX) || defined (BB_MKFS_MINIX)
-/* Bit map related macros.  */
-#ifndef setbit
-#define CHAR_BITS      8 /* Number of bits in a `char'.  */
-#define setbit(a,i)     ((a)[(i)/CHAR_BITS] |= 1<<((i)%CHAR_BITS))
-#define clrbit(a,i)     ((a)[(i)/CHAR_BITS] &= ~(1<<((i)%CHAR_BITS)))
-#define isset(a,i)      ((a)[(i)/CHAR_BITS] & (1<<((i)%CHAR_BITS)))
-#define isclr(a,i)      (((a)[(i)/CHAR_BITS] & (1<<((i)%CHAR_BITS))) == 0)
-#endif
-#endif
-
-
 #ifndef RB_POWER_OFF
 /* Stop system and switch power off if possable.  */
 #define RB_POWER_OFF   0x4321fedc
index f4f1d0997f5a2fdcfab44b0e3a23ed01f5cda117..c6f057a0787ef6bc9fc48e2b22ea6ec0bafd4c14 100644 (file)
@@ -74,6 +74,7 @@
 #include <termios.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+#include <sys/param.h>
 #include <mntent.h>
 
 #include <linux/fs.h>
 #define HAVE_MINIX2 1
 #endif
 
-#ifndef __GNUC__
-#error "needs gcc for the bitop-__asm__'s"
-#endif
-
 #ifndef __linux__
 #define volatile
 #endif
index e4c88c265ac744165d475cb5f3cced4cf2973581..22831b10c7c96763e2511fb6994fb141080616b8 100644 (file)
@@ -70,6 +70,12 @@ static struct history *his_end = NULL;       /* Last element in command line list */
 
 /* Current termio and the previous termio before starting sh */
 struct termios initial_settings, new_settings;
+
+
+#ifndef        _POSIX_VDISABLE
+#define        _POSIX_VDISABLE '\0'
+#endif
+
 #endif
 
 
diff --git a/tar.c b/tar.c
index 6784d80ff0cd2ee05a5ca3f78233687267656ba5..c5aad45d6b568289f65f8e80aae47f01de1b9291 100644 (file)
--- a/tar.c
+++ b/tar.c
@@ -185,7 +185,7 @@ extern int tar_main(int argc, char **argv)
                usage(tar_usage);
 
        /* Parse any options */
-       while (--argc > 0 && **(++argv) == '-') {
+       while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
                stopIt=FALSE;
                while (stopIt==FALSE && *(++(*argv))) {
                        switch (**argv) {
@@ -265,7 +265,8 @@ extern int tar_main(int argc, char **argv)
 #else
                exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList));
 #endif
-       } else {
+       }
+       if (listFlag == TRUE || extractFlag == TRUE) {
                exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList));
        }
 
index 7d27566b8579caedb1d4e7451d8ca1308feac635..1e482f3f989f29f10b38f16ba4e2ceab91404e32 100644 (file)
@@ -97,6 +97,7 @@
 #include <termios.h>
 #include <mntent.h>
 #include <sys/stat.h>
+#include <sys/param.h>
 
 #include <linux/fs.h>
 #include <linux/minix_fs.h>
index f4f1d0997f5a2fdcfab44b0e3a23ed01f5cda117..c6f057a0787ef6bc9fc48e2b22ea6ec0bafd4c14 100644 (file)
@@ -74,6 +74,7 @@
 #include <termios.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
+#include <sys/param.h>
 #include <mntent.h>
 
 #include <linux/fs.h>
 #define HAVE_MINIX2 1
 #endif
 
-#ifndef __GNUC__
-#error "needs gcc for the bitop-__asm__'s"
-#endif
-
 #ifndef __linux__
 #define volatile
 #endif