First pass at fixing tar segfault, and more portability updates.

-Erik
This commit is contained in:
Erik Andersen 2000-05-20 00:40:08 +00:00
parent 330fd2b576
commit 8ea7d8cdaf
10 changed files with 27 additions and 24 deletions

5
TODO
View File

@ -22,6 +22,11 @@ Bugs that need fixing:
- 'grep *foo file' segfaults - 'grep *foo file' segfaults
- ps dirent race bug (need to stat the file before attempting chdir) - ps dirent race bug (need to stat the file before attempting chdir)
/busybox tar tvf
Segmentation fault (core dumped)
----------- -----------
* Make insmod actually work * Make insmod actually work

View File

@ -185,7 +185,7 @@ extern int tar_main(int argc, char **argv)
usage(tar_usage); usage(tar_usage);
/* Parse any options */ /* Parse any options */
while (--argc > 0 && **(++argv) == '-') { while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
stopIt=FALSE; stopIt=FALSE;
while (stopIt==FALSE && *(++(*argv))) { while (stopIt==FALSE && *(++(*argv))) {
switch (**argv) { switch (**argv) {
@ -265,7 +265,8 @@ extern int tar_main(int argc, char **argv)
#else #else
exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList)); exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList));
#endif #endif
} else { }
if (listFlag == TRUE || extractFlag == TRUE) {
exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList)); exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList));
} }

View 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 */ /* Current termio and the previous termio before starting sh */
struct termios initial_settings, new_settings; struct termios initial_settings, new_settings;
#ifndef _POSIX_VDISABLE
#define _POSIX_VDISABLE '\0'
#endif
#endif #endif

View File

@ -97,6 +97,7 @@
#include <termios.h> #include <termios.h>
#include <mntent.h> #include <mntent.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/param.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/minix_fs.h> #include <linux/minix_fs.h>

View 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); char **extra_opts, char **mount_opts, int running_bg);
#endif #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 #ifndef RB_POWER_OFF
/* Stop system and switch power off if possable. */ /* Stop system and switch power off if possable. */
#define RB_POWER_OFF 0x4321fedc #define RB_POWER_OFF 0x4321fedc

View File

@ -74,6 +74,7 @@
#include <termios.h> #include <termios.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/param.h>
#include <mntent.h> #include <mntent.h>
#include <linux/fs.h> #include <linux/fs.h>
@ -83,10 +84,6 @@
#define HAVE_MINIX2 1 #define HAVE_MINIX2 1
#endif #endif
#ifndef __GNUC__
#error "needs gcc for the bitop-__asm__'s"
#endif
#ifndef __linux__ #ifndef __linux__
#define volatile #define volatile
#endif #endif

View 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 */ /* Current termio and the previous termio before starting sh */
struct termios initial_settings, new_settings; struct termios initial_settings, new_settings;
#ifndef _POSIX_VDISABLE
#define _POSIX_VDISABLE '\0'
#endif
#endif #endif

5
tar.c
View File

@ -185,7 +185,7 @@ extern int tar_main(int argc, char **argv)
usage(tar_usage); usage(tar_usage);
/* Parse any options */ /* Parse any options */
while (--argc > 0 && **(++argv) == '-') { while (--argc > 0 && strspn(*(++argv), "-cxt") >0 ) {
stopIt=FALSE; stopIt=FALSE;
while (stopIt==FALSE && *(++(*argv))) { while (stopIt==FALSE && *(++(*argv))) {
switch (**argv) { switch (**argv) {
@ -265,7 +265,8 @@ extern int tar_main(int argc, char **argv)
#else #else
exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList)); exit(writeTarFile(tarName, tostdoutFlag, verboseFlag, argc, argv, excludeList));
#endif #endif
} else { }
if (listFlag == TRUE || extractFlag == TRUE) {
exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList)); exit(readTarFile(tarName, extractFlag, listFlag, tostdoutFlag, verboseFlag, excludeList));
} }

View File

@ -97,6 +97,7 @@
#include <termios.h> #include <termios.h>
#include <mntent.h> #include <mntent.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/param.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/minix_fs.h> #include <linux/minix_fs.h>

View File

@ -74,6 +74,7 @@
#include <termios.h> #include <termios.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/param.h>
#include <mntent.h> #include <mntent.h>
#include <linux/fs.h> #include <linux/fs.h>
@ -83,10 +84,6 @@
#define HAVE_MINIX2 1 #define HAVE_MINIX2 1
#endif #endif
#ifndef __GNUC__
#error "needs gcc for the bitop-__asm__'s"
#endif
#ifndef __linux__ #ifndef __linux__
#define volatile #define volatile
#endif #endif