diff options
author | Eric Andersen <andersen@codepoet.org> | 1999-10-08 17:14:14 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 1999-10-08 17:14:14 +0000 |
commit | 8341a1565306a54e685455d19efb0516ad3328a1 (patch) | |
tree | 61b2bca05cc536fc83979be4ef23604754eb1a19 | |
parent | 596e5469d00fa4a74d8a3b1ebfaae20ce8dc3afe (diff) | |
download | busybox-w32-8341a1565306a54e685455d19efb0516ad3328a1.tar.gz busybox-w32-8341a1565306a54e685455d19efb0516ad3328a1.tar.bz2 busybox-w32-8341a1565306a54e685455d19efb0516ad3328a1.zip |
Finally mount works properly. Made debugging work (no more -s ld flag
when debugging is on).
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | mount.c | 87 | ||||
-rw-r--r-- | util-linux/mount.c | 87 |
3 files changed, 99 insertions, 81 deletions
@@ -11,8 +11,10 @@ ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'` | |||
11 | ifeq ($(DODEBUG),true) | 11 | ifeq ($(DODEBUG),true) |
12 | CFLAGS=-Wall -g -D_GNU_SOURCE | 12 | CFLAGS=-Wall -g -D_GNU_SOURCE |
13 | STRIP= | 13 | STRIP= |
14 | LDFLAGS= | ||
14 | else | 15 | else |
15 | CFLAGS=-Wall -O2 -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE | 16 | CFLAGS=-Wall -O2 -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE |
17 | LDFLAGS= -s | ||
16 | STRIP= strip --remove-section=.note --remove-section=.comment busybox | 18 | STRIP= strip --remove-section=.note --remove-section=.comment busybox |
17 | endif | 19 | endif |
18 | 20 | ||
@@ -21,17 +23,15 @@ ifndef $(prefix) | |||
21 | endif | 23 | endif |
22 | BINDIR=$(prefix) | 24 | BINDIR=$(prefix) |
23 | 25 | ||
24 | LDFLAGS= -s | ||
25 | LIBRARIES=-lc | 26 | LIBRARIES=-lc |
26 | OBJECTS=$(shell ./busybox.sh) | 27 | OBJECTS=$(shell ./busybox.sh) |
27 | CFLAGS+= -DBB_VER='"$(VERSION)"' | 28 | CFLAGS+= -DBB_VER='"$(VERSION)"' |
28 | CFLAGS+= -DBB_BT='"$(BUILDTIME)"' | 29 | CFLAGS+= -DBB_BT='"$(BUILDTIME)"' |
29 | 30 | ||
30 | all: busybox links | 31 | all: busybox links |
31 | #all: busybox | ||
32 | 32 | ||
33 | busybox: $(OBJECTS) | 33 | busybox: $(OBJECTS) |
34 | $(CC) $(CFLAGS) $(LDFLAGS) -o busybox $(OBJECTS) $(LIBRARIES) | 34 | $(CC) $(LDFLAGS) -o busybox $(OBJECTS) $(LIBRARIES) |
35 | $(STRIP) | 35 | $(STRIP) |
36 | 36 | ||
37 | links: | 37 | links: |
@@ -22,8 +22,8 @@ | |||
22 | * will try mounting stuff with all fses when passed -t auto | 22 | * will try mounting stuff with all fses when passed -t auto |
23 | * | 23 | * |
24 | * 1999-04-17 Dave Cinege...Rewrote -t auto. Fixed ro mtab. | 24 | * 1999-04-17 Dave Cinege...Rewrote -t auto. Fixed ro mtab. |
25 | * 1999-10-07 Erik Andersen. Removed mtab usage, major adjustments, | 25 | * 1999-10-07 Erik Andersen. Rewrote of a lot of code. Removed mtab |
26 | * and some serious dieting all around. | 26 | * usage, major adjustments, and some serious dieting all around. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "internal.h" | 29 | #include "internal.h" |
@@ -81,36 +81,42 @@ static const struct mount_options mount_options[] = { | |||
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | /* Seperate standard mount options from the nonstandard string options */ | ||
84 | static void | 85 | static void |
85 | parse_mount_options ( char *options, unsigned long *flags, char *data) | 86 | parse_mount_options ( char *options, unsigned long *flags, char *strflags) |
86 | { | 87 | { |
87 | printf("option=%s\n", options); | 88 | while (options) { |
88 | while (*options) { | 89 | int gotone=FALSE; |
89 | char *comma = strchr (options, ','); | 90 | char *comma = strchr (options, ','); |
90 | const struct mount_options* f = mount_options; | 91 | const struct mount_options* f = mount_options; |
91 | if (comma) | 92 | if (comma) |
92 | *comma = '\0'; | 93 | *comma = '\0'; |
93 | 94 | ||
94 | printf("checking option=%s vs %s\n", options, f->name); | ||
95 | while (f->name != 0) { | 95 | while (f->name != 0) { |
96 | printf("checking option=%s vs %s\n", options, f->name); | ||
97 | if (strcasecmp (f->name, options) == 0) { | 96 | if (strcasecmp (f->name, options) == 0) { |
98 | *flags &= f->and; | 97 | *flags &= f->and; |
99 | *flags |= f->or; | 98 | *flags |= f->or; |
100 | return; | 99 | gotone=TRUE; |
100 | break; | ||
101 | } | 101 | } |
102 | f++; | 102 | f++; |
103 | } | 103 | } |
104 | if (*data) { | 104 | if (*strflags && strflags!= '\0' && gotone==FALSE) { |
105 | data += strlen (data); | 105 | char *temp=strflags; |
106 | *data++ = ','; | 106 | temp += strlen (strflags); |
107 | *temp++ = ','; | ||
108 | *temp++ = '\0'; | ||
109 | } | ||
110 | if (gotone==FALSE) { | ||
111 | strcat (strflags, options); | ||
112 | gotone=FALSE; | ||
107 | } | 113 | } |
108 | strcpy (data, options); | ||
109 | if (comma) { | 114 | if (comma) { |
110 | *comma = ','; | 115 | *comma = ','; |
111 | options = ++comma; | 116 | options = ++comma; |
112 | } else | 117 | } else { |
113 | break; | 118 | break; |
119 | } | ||
114 | } | 120 | } |
115 | } | 121 | } |
116 | 122 | ||
@@ -163,11 +169,13 @@ mount_one ( | |||
163 | 169 | ||
164 | extern int mount_main (int argc, char **argv) | 170 | extern int mount_main (int argc, char **argv) |
165 | { | 171 | { |
166 | char string_flags[1024]="\0"; | 172 | char string_flags[1024]=""; |
167 | unsigned long flags = 0; | 173 | unsigned long flags = 0; |
168 | char *filesystemType = "auto"; | 174 | char *filesystemType = "auto"; |
175 | char *device = NULL; | ||
176 | char *directory = NULL; | ||
169 | int all = 0; | 177 | int all = 0; |
170 | int i = argc; | 178 | int i; |
171 | 179 | ||
172 | if (argc == 1) { | 180 | if (argc == 1) { |
173 | FILE *mountTable; | 181 | FILE *mountTable; |
@@ -187,29 +195,31 @@ extern int mount_main (int argc, char **argv) | |||
187 | 195 | ||
188 | 196 | ||
189 | /* Parse options */ | 197 | /* Parse options */ |
190 | while (**argv) { | 198 | i = --argc; |
199 | argv++; | ||
200 | while (i > 0 && **argv) { | ||
191 | if (**argv == '-') { | 201 | if (**argv == '-') { |
192 | switch (**argv) { | 202 | while (i>0 && *++(*argv)) switch (**argv) { |
193 | case 'o': | 203 | case 'o': |
194 | if (++argv == 0) { | 204 | if (--i == 0) { |
195 | fprintf (stderr, "%s\n", mount_usage); | 205 | fprintf (stderr, "%s\n", mount_usage); |
196 | return( FALSE); | 206 | return( FALSE); |
197 | } | 207 | } |
198 | parse_mount_options (*argv, &flags, string_flags); | 208 | parse_mount_options (*(++argv), &flags, string_flags); |
199 | argc--; | 209 | --i; |
200 | argv++; | 210 | ++argv; |
201 | break; | 211 | break; |
202 | case 'r': | 212 | case 'r': |
203 | flags |= MS_RDONLY; | 213 | flags |= MS_RDONLY; |
204 | break; | 214 | break; |
205 | case 't': | 215 | case 't': |
206 | if (++argv == 0) { | 216 | if (--i == 0) { |
207 | fprintf (stderr, "%s\n", mount_usage); | 217 | fprintf (stderr, "%s\n", mount_usage); |
208 | return( FALSE); | 218 | return( FALSE); |
209 | } | 219 | } |
210 | filesystemType = *argv; | 220 | filesystemType = *(++argv); |
211 | argc--; | 221 | --i; |
212 | argv++; | 222 | ++argv; |
213 | break; | 223 | break; |
214 | case 'w': | 224 | case 'w': |
215 | flags &= ~MS_RDONLY; | 225 | flags &= ~MS_RDONLY; |
@@ -222,6 +232,16 @@ extern int mount_main (int argc, char **argv) | |||
222 | case '-': | 232 | case '-': |
223 | fprintf (stderr, "%s\n", mount_usage); | 233 | fprintf (stderr, "%s\n", mount_usage); |
224 | return( TRUE); | 234 | return( TRUE); |
235 | break; | ||
236 | } | ||
237 | } else { | ||
238 | if (device == NULL) | ||
239 | device=*argv; | ||
240 | else if (directory == NULL) | ||
241 | directory=*argv; | ||
242 | else { | ||
243 | fprintf (stderr, "%s\n", mount_usage); | ||
244 | return( TRUE); | ||
225 | } | 245 | } |
226 | } | 246 | } |
227 | i--; | 247 | i--; |
@@ -236,9 +256,6 @@ extern int mount_main (int argc, char **argv) | |||
236 | perror("/etc/fstab"); | 256 | perror("/etc/fstab"); |
237 | return( FALSE); | 257 | return( FALSE); |
238 | } | 258 | } |
239 | // FIXME: Combine read routine (make new function) with unmount_all | ||
240 | // to save space. | ||
241 | |||
242 | while ((m = getmntent (f)) != NULL) { | 259 | while ((m = getmntent (f)) != NULL) { |
243 | // If the file system isn't noauto, and isn't mounted on /, mount | 260 | // If the file system isn't noauto, and isn't mounted on /, mount |
244 | // it | 261 | // it |
@@ -250,19 +267,11 @@ extern int mount_main (int argc, char **argv) | |||
250 | m->mnt_opts); | 267 | m->mnt_opts); |
251 | } | 268 | } |
252 | } | 269 | } |
253 | |||
254 | endmntent (f); | 270 | endmntent (f); |
255 | } else { | 271 | } else { |
256 | if (argc >= 3) { | 272 | if (device && directory) { |
257 | while (i < argc) | 273 | return (mount_one (device, directory, filesystemType, |
258 | argv--; | 274 | flags, string_flags)); |
259 | while (**argv == '-') | ||
260 | argv++; | ||
261 | if (mount_one | ||
262 | (*argv, *(argv+1), filesystemType, flags, | ||
263 | string_flags) == 0) return 0; | ||
264 | else | ||
265 | return( FALSE); | ||
266 | } else { | 275 | } else { |
267 | fprintf (stderr, "%s\n", mount_usage); | 276 | fprintf (stderr, "%s\n", mount_usage); |
268 | return( FALSE); | 277 | return( FALSE); |
diff --git a/util-linux/mount.c b/util-linux/mount.c index 9a1accc88..4e5c0745b 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -22,8 +22,8 @@ | |||
22 | * will try mounting stuff with all fses when passed -t auto | 22 | * will try mounting stuff with all fses when passed -t auto |
23 | * | 23 | * |
24 | * 1999-04-17 Dave Cinege...Rewrote -t auto. Fixed ro mtab. | 24 | * 1999-04-17 Dave Cinege...Rewrote -t auto. Fixed ro mtab. |
25 | * 1999-10-07 Erik Andersen. Removed mtab usage, major adjustments, | 25 | * 1999-10-07 Erik Andersen. Rewrote of a lot of code. Removed mtab |
26 | * and some serious dieting all around. | 26 | * usage, major adjustments, and some serious dieting all around. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "internal.h" | 29 | #include "internal.h" |
@@ -81,36 +81,42 @@ static const struct mount_options mount_options[] = { | |||
81 | }; | 81 | }; |
82 | 82 | ||
83 | 83 | ||
84 | /* Seperate standard mount options from the nonstandard string options */ | ||
84 | static void | 85 | static void |
85 | parse_mount_options ( char *options, unsigned long *flags, char *data) | 86 | parse_mount_options ( char *options, unsigned long *flags, char *strflags) |
86 | { | 87 | { |
87 | printf("option=%s\n", options); | 88 | while (options) { |
88 | while (*options) { | 89 | int gotone=FALSE; |
89 | char *comma = strchr (options, ','); | 90 | char *comma = strchr (options, ','); |
90 | const struct mount_options* f = mount_options; | 91 | const struct mount_options* f = mount_options; |
91 | if (comma) | 92 | if (comma) |
92 | *comma = '\0'; | 93 | *comma = '\0'; |
93 | 94 | ||
94 | printf("checking option=%s vs %s\n", options, f->name); | ||
95 | while (f->name != 0) { | 95 | while (f->name != 0) { |
96 | printf("checking option=%s vs %s\n", options, f->name); | ||
97 | if (strcasecmp (f->name, options) == 0) { | 96 | if (strcasecmp (f->name, options) == 0) { |
98 | *flags &= f->and; | 97 | *flags &= f->and; |
99 | *flags |= f->or; | 98 | *flags |= f->or; |
100 | return; | 99 | gotone=TRUE; |
100 | break; | ||
101 | } | 101 | } |
102 | f++; | 102 | f++; |
103 | } | 103 | } |
104 | if (*data) { | 104 | if (*strflags && strflags!= '\0' && gotone==FALSE) { |
105 | data += strlen (data); | 105 | char *temp=strflags; |
106 | *data++ = ','; | 106 | temp += strlen (strflags); |
107 | *temp++ = ','; | ||
108 | *temp++ = '\0'; | ||
109 | } | ||
110 | if (gotone==FALSE) { | ||
111 | strcat (strflags, options); | ||
112 | gotone=FALSE; | ||
107 | } | 113 | } |
108 | strcpy (data, options); | ||
109 | if (comma) { | 114 | if (comma) { |
110 | *comma = ','; | 115 | *comma = ','; |
111 | options = ++comma; | 116 | options = ++comma; |
112 | } else | 117 | } else { |
113 | break; | 118 | break; |
119 | } | ||
114 | } | 120 | } |
115 | } | 121 | } |
116 | 122 | ||
@@ -163,11 +169,13 @@ mount_one ( | |||
163 | 169 | ||
164 | extern int mount_main (int argc, char **argv) | 170 | extern int mount_main (int argc, char **argv) |
165 | { | 171 | { |
166 | char string_flags[1024]="\0"; | 172 | char string_flags[1024]=""; |
167 | unsigned long flags = 0; | 173 | unsigned long flags = 0; |
168 | char *filesystemType = "auto"; | 174 | char *filesystemType = "auto"; |
175 | char *device = NULL; | ||
176 | char *directory = NULL; | ||
169 | int all = 0; | 177 | int all = 0; |
170 | int i = argc; | 178 | int i; |
171 | 179 | ||
172 | if (argc == 1) { | 180 | if (argc == 1) { |
173 | FILE *mountTable; | 181 | FILE *mountTable; |
@@ -187,29 +195,31 @@ extern int mount_main (int argc, char **argv) | |||
187 | 195 | ||
188 | 196 | ||
189 | /* Parse options */ | 197 | /* Parse options */ |
190 | while (**argv) { | 198 | i = --argc; |
199 | argv++; | ||
200 | while (i > 0 && **argv) { | ||
191 | if (**argv == '-') { | 201 | if (**argv == '-') { |
192 | switch (**argv) { | 202 | while (i>0 && *++(*argv)) switch (**argv) { |
193 | case 'o': | 203 | case 'o': |
194 | if (++argv == 0) { | 204 | if (--i == 0) { |
195 | fprintf (stderr, "%s\n", mount_usage); | 205 | fprintf (stderr, "%s\n", mount_usage); |
196 | return( FALSE); | 206 | return( FALSE); |
197 | } | 207 | } |
198 | parse_mount_options (*argv, &flags, string_flags); | 208 | parse_mount_options (*(++argv), &flags, string_flags); |
199 | argc--; | 209 | --i; |
200 | argv++; | 210 | ++argv; |
201 | break; | 211 | break; |
202 | case 'r': | 212 | case 'r': |
203 | flags |= MS_RDONLY; | 213 | flags |= MS_RDONLY; |
204 | break; | 214 | break; |
205 | case 't': | 215 | case 't': |
206 | if (++argv == 0) { | 216 | if (--i == 0) { |
207 | fprintf (stderr, "%s\n", mount_usage); | 217 | fprintf (stderr, "%s\n", mount_usage); |
208 | return( FALSE); | 218 | return( FALSE); |
209 | } | 219 | } |
210 | filesystemType = *argv; | 220 | filesystemType = *(++argv); |
211 | argc--; | 221 | --i; |
212 | argv++; | 222 | ++argv; |
213 | break; | 223 | break; |
214 | case 'w': | 224 | case 'w': |
215 | flags &= ~MS_RDONLY; | 225 | flags &= ~MS_RDONLY; |
@@ -222,6 +232,16 @@ extern int mount_main (int argc, char **argv) | |||
222 | case '-': | 232 | case '-': |
223 | fprintf (stderr, "%s\n", mount_usage); | 233 | fprintf (stderr, "%s\n", mount_usage); |
224 | return( TRUE); | 234 | return( TRUE); |
235 | break; | ||
236 | } | ||
237 | } else { | ||
238 | if (device == NULL) | ||
239 | device=*argv; | ||
240 | else if (directory == NULL) | ||
241 | directory=*argv; | ||
242 | else { | ||
243 | fprintf (stderr, "%s\n", mount_usage); | ||
244 | return( TRUE); | ||
225 | } | 245 | } |
226 | } | 246 | } |
227 | i--; | 247 | i--; |
@@ -236,9 +256,6 @@ extern int mount_main (int argc, char **argv) | |||
236 | perror("/etc/fstab"); | 256 | perror("/etc/fstab"); |
237 | return( FALSE); | 257 | return( FALSE); |
238 | } | 258 | } |
239 | // FIXME: Combine read routine (make new function) with unmount_all | ||
240 | // to save space. | ||
241 | |||
242 | while ((m = getmntent (f)) != NULL) { | 259 | while ((m = getmntent (f)) != NULL) { |
243 | // If the file system isn't noauto, and isn't mounted on /, mount | 260 | // If the file system isn't noauto, and isn't mounted on /, mount |
244 | // it | 261 | // it |
@@ -250,19 +267,11 @@ extern int mount_main (int argc, char **argv) | |||
250 | m->mnt_opts); | 267 | m->mnt_opts); |
251 | } | 268 | } |
252 | } | 269 | } |
253 | |||
254 | endmntent (f); | 270 | endmntent (f); |
255 | } else { | 271 | } else { |
256 | if (argc >= 3) { | 272 | if (device && directory) { |
257 | while (i < argc) | 273 | return (mount_one (device, directory, filesystemType, |
258 | argv--; | 274 | flags, string_flags)); |
259 | while (**argv == '-') | ||
260 | argv++; | ||
261 | if (mount_one | ||
262 | (*argv, *(argv+1), filesystemType, flags, | ||
263 | string_flags) == 0) return 0; | ||
264 | else | ||
265 | return( FALSE); | ||
266 | } else { | 275 | } else { |
267 | fprintf (stderr, "%s\n", mount_usage); | 276 | fprintf (stderr, "%s\n", mount_usage); |
268 | return( FALSE); | 277 | return( FALSE); |