Finally mount works properly. Made debugging work (no more -s ld flag

when debugging is on).
This commit is contained in:
Eric Andersen 1999-10-08 17:14:14 +00:00
parent 596e5469d0
commit 8341a15653
3 changed files with 99 additions and 81 deletions

View File

@ -11,8 +11,10 @@ ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
ifeq ($(DODEBUG),true) ifeq ($(DODEBUG),true)
CFLAGS=-Wall -g -D_GNU_SOURCE CFLAGS=-Wall -g -D_GNU_SOURCE
STRIP= STRIP=
LDFLAGS=
else else
CFLAGS=-Wall -O2 -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE CFLAGS=-Wall -O2 -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
LDFLAGS= -s
STRIP= strip --remove-section=.note --remove-section=.comment busybox STRIP= strip --remove-section=.note --remove-section=.comment busybox
endif endif
@ -21,17 +23,15 @@ ifndef $(prefix)
endif endif
BINDIR=$(prefix) BINDIR=$(prefix)
LDFLAGS= -s
LIBRARIES=-lc LIBRARIES=-lc
OBJECTS=$(shell ./busybox.sh) 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 links
#all: busybox
busybox: $(OBJECTS) busybox: $(OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) -o busybox $(OBJECTS) $(LIBRARIES) $(CC) $(LDFLAGS) -o busybox $(OBJECTS) $(LIBRARIES)
$(STRIP) $(STRIP)
links: links:

87
mount.c
View File

@ -22,8 +22,8 @@
* will try mounting stuff with all fses when passed -t auto * will try mounting stuff with all fses when passed -t auto
* *
* 1999-04-17 Dave Cinege...Rewrote -t auto. Fixed ro mtab. * 1999-04-17 Dave Cinege...Rewrote -t auto. Fixed ro mtab.
* 1999-10-07 Erik Andersen. Removed mtab usage, major adjustments, * 1999-10-07 Erik Andersen. Rewrote of a lot of code. Removed mtab
* and some serious dieting all around. * usage, major adjustments, and some serious dieting all around.
*/ */
#include "internal.h" #include "internal.h"
@ -81,36 +81,42 @@ static const struct mount_options mount_options[] = {
}; };
/* Seperate standard mount options from the nonstandard string options */
static void static void
parse_mount_options ( char *options, unsigned long *flags, char *data) parse_mount_options ( char *options, unsigned long *flags, char *strflags)
{ {
printf("option=%s\n", options); while (options) {
while (*options) { int gotone=FALSE;
char *comma = strchr (options, ','); char *comma = strchr (options, ',');
const struct mount_options* f = mount_options; const struct mount_options* f = mount_options;
if (comma) if (comma)
*comma = '\0'; *comma = '\0';
printf("checking option=%s vs %s\n", options, f->name);
while (f->name != 0) { while (f->name != 0) {
printf("checking option=%s vs %s\n", options, f->name);
if (strcasecmp (f->name, options) == 0) { if (strcasecmp (f->name, options) == 0) {
*flags &= f->and; *flags &= f->and;
*flags |= f->or; *flags |= f->or;
return; gotone=TRUE;
break;
} }
f++; f++;
} }
if (*data) { if (*strflags && strflags!= '\0' && gotone==FALSE) {
data += strlen (data); char *temp=strflags;
*data++ = ','; temp += strlen (strflags);
*temp++ = ',';
*temp++ = '\0';
}
if (gotone==FALSE) {
strcat (strflags, options);
gotone=FALSE;
} }
strcpy (data, options);
if (comma) { if (comma) {
*comma = ','; *comma = ',';
options = ++comma; options = ++comma;
} else } else {
break; break;
}
} }
} }
@ -163,11 +169,13 @@ mount_one (
extern int mount_main (int argc, char **argv) extern int mount_main (int argc, char **argv)
{ {
char string_flags[1024]="\0"; char string_flags[1024]="";
unsigned long flags = 0; unsigned long flags = 0;
char *filesystemType = "auto"; char *filesystemType = "auto";
char *device = NULL;
char *directory = NULL;
int all = 0; int all = 0;
int i = argc; int i;
if (argc == 1) { if (argc == 1) {
FILE *mountTable; FILE *mountTable;
@ -187,29 +195,31 @@ extern int mount_main (int argc, char **argv)
/* Parse options */ /* Parse options */
while (**argv) { i = --argc;
argv++;
while (i > 0 && **argv) {
if (**argv == '-') { if (**argv == '-') {
switch (**argv) { while (i>0 && *++(*argv)) switch (**argv) {
case 'o': case 'o':
if (++argv == 0) { if (--i == 0) {
fprintf (stderr, "%s\n", mount_usage); fprintf (stderr, "%s\n", mount_usage);
return( FALSE); return( FALSE);
} }
parse_mount_options (*argv, &flags, string_flags); parse_mount_options (*(++argv), &flags, string_flags);
argc--; --i;
argv++; ++argv;
break; break;
case 'r': case 'r':
flags |= MS_RDONLY; flags |= MS_RDONLY;
break; break;
case 't': case 't':
if (++argv == 0) { if (--i == 0) {
fprintf (stderr, "%s\n", mount_usage); fprintf (stderr, "%s\n", mount_usage);
return( FALSE); return( FALSE);
} }
filesystemType = *argv; filesystemType = *(++argv);
argc--; --i;
argv++; ++argv;
break; break;
case 'w': case 'w':
flags &= ~MS_RDONLY; flags &= ~MS_RDONLY;
@ -222,6 +232,16 @@ extern int mount_main (int argc, char **argv)
case '-': case '-':
fprintf (stderr, "%s\n", mount_usage); fprintf (stderr, "%s\n", mount_usage);
return( TRUE); return( TRUE);
break;
}
} else {
if (device == NULL)
device=*argv;
else if (directory == NULL)
directory=*argv;
else {
fprintf (stderr, "%s\n", mount_usage);
return( TRUE);
} }
} }
i--; i--;
@ -236,9 +256,6 @@ extern int mount_main (int argc, char **argv)
perror("/etc/fstab"); perror("/etc/fstab");
return( FALSE); return( FALSE);
} }
// FIXME: Combine read routine (make new function) with unmount_all
// to save space.
while ((m = getmntent (f)) != NULL) { while ((m = getmntent (f)) != NULL) {
// If the file system isn't noauto, and isn't mounted on /, mount // If the file system isn't noauto, and isn't mounted on /, mount
// it // it
@ -250,19 +267,11 @@ extern int mount_main (int argc, char **argv)
m->mnt_opts); m->mnt_opts);
} }
} }
endmntent (f); endmntent (f);
} else { } else {
if (argc >= 3) { if (device && directory) {
while (i < argc) return (mount_one (device, directory, filesystemType,
argv--; flags, string_flags));
while (**argv == '-')
argv++;
if (mount_one
(*argv, *(argv+1), filesystemType, flags,
string_flags) == 0) return 0;
else
return( FALSE);
} else { } else {
fprintf (stderr, "%s\n", mount_usage); fprintf (stderr, "%s\n", mount_usage);
return( FALSE); return( FALSE);

View File

@ -22,8 +22,8 @@
* will try mounting stuff with all fses when passed -t auto * will try mounting stuff with all fses when passed -t auto
* *
* 1999-04-17 Dave Cinege...Rewrote -t auto. Fixed ro mtab. * 1999-04-17 Dave Cinege...Rewrote -t auto. Fixed ro mtab.
* 1999-10-07 Erik Andersen. Removed mtab usage, major adjustments, * 1999-10-07 Erik Andersen. Rewrote of a lot of code. Removed mtab
* and some serious dieting all around. * usage, major adjustments, and some serious dieting all around.
*/ */
#include "internal.h" #include "internal.h"
@ -81,36 +81,42 @@ static const struct mount_options mount_options[] = {
}; };
/* Seperate standard mount options from the nonstandard string options */
static void static void
parse_mount_options ( char *options, unsigned long *flags, char *data) parse_mount_options ( char *options, unsigned long *flags, char *strflags)
{ {
printf("option=%s\n", options); while (options) {
while (*options) { int gotone=FALSE;
char *comma = strchr (options, ','); char *comma = strchr (options, ',');
const struct mount_options* f = mount_options; const struct mount_options* f = mount_options;
if (comma) if (comma)
*comma = '\0'; *comma = '\0';
printf("checking option=%s vs %s\n", options, f->name);
while (f->name != 0) { while (f->name != 0) {
printf("checking option=%s vs %s\n", options, f->name);
if (strcasecmp (f->name, options) == 0) { if (strcasecmp (f->name, options) == 0) {
*flags &= f->and; *flags &= f->and;
*flags |= f->or; *flags |= f->or;
return; gotone=TRUE;
break;
} }
f++; f++;
} }
if (*data) { if (*strflags && strflags!= '\0' && gotone==FALSE) {
data += strlen (data); char *temp=strflags;
*data++ = ','; temp += strlen (strflags);
*temp++ = ',';
*temp++ = '\0';
}
if (gotone==FALSE) {
strcat (strflags, options);
gotone=FALSE;
} }
strcpy (data, options);
if (comma) { if (comma) {
*comma = ','; *comma = ',';
options = ++comma; options = ++comma;
} else } else {
break; break;
}
} }
} }
@ -163,11 +169,13 @@ mount_one (
extern int mount_main (int argc, char **argv) extern int mount_main (int argc, char **argv)
{ {
char string_flags[1024]="\0"; char string_flags[1024]="";
unsigned long flags = 0; unsigned long flags = 0;
char *filesystemType = "auto"; char *filesystemType = "auto";
char *device = NULL;
char *directory = NULL;
int all = 0; int all = 0;
int i = argc; int i;
if (argc == 1) { if (argc == 1) {
FILE *mountTable; FILE *mountTable;
@ -187,29 +195,31 @@ extern int mount_main (int argc, char **argv)
/* Parse options */ /* Parse options */
while (**argv) { i = --argc;
argv++;
while (i > 0 && **argv) {
if (**argv == '-') { if (**argv == '-') {
switch (**argv) { while (i>0 && *++(*argv)) switch (**argv) {
case 'o': case 'o':
if (++argv == 0) { if (--i == 0) {
fprintf (stderr, "%s\n", mount_usage); fprintf (stderr, "%s\n", mount_usage);
return( FALSE); return( FALSE);
} }
parse_mount_options (*argv, &flags, string_flags); parse_mount_options (*(++argv), &flags, string_flags);
argc--; --i;
argv++; ++argv;
break; break;
case 'r': case 'r':
flags |= MS_RDONLY; flags |= MS_RDONLY;
break; break;
case 't': case 't':
if (++argv == 0) { if (--i == 0) {
fprintf (stderr, "%s\n", mount_usage); fprintf (stderr, "%s\n", mount_usage);
return( FALSE); return( FALSE);
} }
filesystemType = *argv; filesystemType = *(++argv);
argc--; --i;
argv++; ++argv;
break; break;
case 'w': case 'w':
flags &= ~MS_RDONLY; flags &= ~MS_RDONLY;
@ -222,6 +232,16 @@ extern int mount_main (int argc, char **argv)
case '-': case '-':
fprintf (stderr, "%s\n", mount_usage); fprintf (stderr, "%s\n", mount_usage);
return( TRUE); return( TRUE);
break;
}
} else {
if (device == NULL)
device=*argv;
else if (directory == NULL)
directory=*argv;
else {
fprintf (stderr, "%s\n", mount_usage);
return( TRUE);
} }
} }
i--; i--;
@ -236,9 +256,6 @@ extern int mount_main (int argc, char **argv)
perror("/etc/fstab"); perror("/etc/fstab");
return( FALSE); return( FALSE);
} }
// FIXME: Combine read routine (make new function) with unmount_all
// to save space.
while ((m = getmntent (f)) != NULL) { while ((m = getmntent (f)) != NULL) {
// If the file system isn't noauto, and isn't mounted on /, mount // If the file system isn't noauto, and isn't mounted on /, mount
// it // it
@ -250,19 +267,11 @@ extern int mount_main (int argc, char **argv)
m->mnt_opts); m->mnt_opts);
} }
} }
endmntent (f); endmntent (f);
} else { } else {
if (argc >= 3) { if (device && directory) {
while (i < argc) return (mount_one (device, directory, filesystemType,
argv--; flags, string_flags));
while (**argv == '-')
argv++;
if (mount_one
(*argv, *(argv+1), filesystemType, flags,
string_flags) == 0) return 0;
else
return( FALSE);
} else { } else {
fprintf (stderr, "%s\n", mount_usage); fprintf (stderr, "%s\n", mount_usage);
return( FALSE); return( FALSE);