aboutsummaryrefslogtreecommitdiff
path: root/mount.c
diff options
context:
space:
mode:
Diffstat (limited to 'mount.c')
-rw-r--r--mount.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/mount.c b/mount.c
index c3e3bbd75..37f789d3c 100644
--- a/mount.c
+++ b/mount.c
@@ -53,7 +53,7 @@
53#include <linux/loop.h> 53#include <linux/loop.h>
54 54
55 55
56static int use_loop = 0; 56static int use_loop = FALSE;
57#endif 57#endif
58 58
59extern const char mtab_file[]; /* Defined in utility.c */ 59extern const char mtab_file[]; /* Defined in utility.c */
@@ -114,13 +114,14 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
114 char *mtab_opts) 114 char *mtab_opts)
115{ 115{
116 int status = 0; 116 int status = 0;
117 char *lofile = NULL;
117 118
118#if defined BB_MTAB 119#if defined BB_MTAB
119 if (fakeIt == FALSE) 120 if (fakeIt == FALSE)
120#endif 121#endif
121 { 122 {
122#if defined BB_FEATURE_MOUNT_LOOP 123#if defined BB_FEATURE_MOUNT_LOOP
123 if (use_loop) { 124 if (use_loop==TRUE) {
124 int loro = flags & MS_RDONLY; 125 int loro = flags & MS_RDONLY;
125 char *lofile = specialfile; 126 char *lofile = specialfile;
126 127
@@ -137,6 +138,7 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
137 fprintf(stderr, "WARNING: loop device is read-only\n"); 138 fprintf(stderr, "WARNING: loop device is read-only\n");
138 flags &= ~MS_RDONLY; 139 flags &= ~MS_RDONLY;
139 } 140 }
141 use_loop = FALSE;
140 } 142 }
141#endif 143#endif
142 status = 144 status =
@@ -157,7 +159,7 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
157 159
158 /* Bummer. mount failed. Clean up */ 160 /* Bummer. mount failed. Clean up */
159#if defined BB_FEATURE_MOUNT_LOOP 161#if defined BB_FEATURE_MOUNT_LOOP
160 if (specialfile != NULL) { 162 if (lofile != NULL) {
161 del_loop(specialfile); 163 del_loop(specialfile);
162 } 164 }
163#endif 165#endif
@@ -166,20 +168,6 @@ do_mount(char *specialfile, char *dir, char *filesystemtype,
166 168
167 169
168 170
169#if defined BB_MTAB
170#define whine_if_fstab_is_missing() {}
171#else
172extern void whine_if_fstab_is_missing()
173{
174 struct stat statBuf;
175
176 if (stat("/etc/fstab", &statBuf) < 0)
177 fprintf(stderr,
178 "/etc/fstab file missing -- install one to name /dev/root.\n\n");
179}
180#endif
181
182
183/* Seperate standard mount options from the nonstandard string options */ 171/* Seperate standard mount options from the nonstandard string options */
184static void 172static void
185parse_mount_options(char *options, unsigned long *flags, char *strflags) 173parse_mount_options(char *options, unsigned long *flags, char *strflags)
@@ -204,7 +192,7 @@ parse_mount_options(char *options, unsigned long *flags, char *strflags)
204 } 192 }
205#if defined BB_FEATURE_MOUNT_LOOP 193#if defined BB_FEATURE_MOUNT_LOOP
206 if (gotone == FALSE && !strcasecmp("loop", options)) { /* loop device support */ 194 if (gotone == FALSE && !strcasecmp("loop", options)) { /* loop device support */
207 use_loop = 1; 195 use_loop = TRUE;
208 gotone = TRUE; 196 gotone = TRUE;
209 } 197 }
210#endif 198#endif
@@ -229,7 +217,7 @@ parse_mount_options(char *options, unsigned long *flags, char *strflags)
229int 217int
230mount_one(char *blockDevice, char *directory, char *filesystemType, 218mount_one(char *blockDevice, char *directory, char *filesystemType,
231 unsigned long flags, char *string_flags, int useMtab, int fakeIt, 219 unsigned long flags, char *string_flags, int useMtab, int fakeIt,
232 char *mtab_opts) 220 char *mtab_opts, int whineOnErrors)
233{ 221{
234 int status = 0; 222 int status = 0;
235 223
@@ -270,9 +258,11 @@ mount_one(char *blockDevice, char *directory, char *filesystemType,
270 fakeIt, mtab_opts); 258 fakeIt, mtab_opts);
271 } 259 }
272 260
273 if (status == FALSE) { 261 if (status == FALSE && whineOnErrors == TRUE) {
274 fprintf(stderr, "Mounting %s on %s failed: %s\n", 262 if (whineOnErrors == TRUE) {
275 blockDevice, directory, strerror(errno)); 263 fprintf(stderr, "Mounting %s on %s failed: %s\n",
264 blockDevice, directory, strerror(errno));
265 }
276 return (FALSE); 266 return (FALSE);
277 } 267 }
278 return (TRUE); 268 return (TRUE);
@@ -387,18 +377,28 @@ extern int mount_main(int argc, char **argv)
387 exit(FALSE); 377 exit(FALSE);
388 } 378 }
389 while ((m = getmntent(f)) != NULL) { 379 while ((m = getmntent(f)) != NULL) {
390 // If the file system isn't noauto, and isn't mounted on /, 380 // If the file system isn't noauto,
391 // and isn't swap or nfs, then mount it 381 // and isn't swap or nfs, then mount it
392 if ((!strstr(m->mnt_opts, "noauto")) && 382 if ((!strstr(m->mnt_opts, "noauto")) &&
393 (m->mnt_dir[1] != '\0') &&
394 (!strstr(m->mnt_type, "swap")) && 383 (!strstr(m->mnt_type, "swap")) &&
395 (!strstr(m->mnt_type, "nfs"))) { 384 (!strstr(m->mnt_type, "nfs"))) {
396 flags = 0; 385 flags = 0;
397 *string_flags = '\0'; 386 *string_flags = '\0';
398 parse_mount_options(m->mnt_opts, &flags, string_flags); 387 parse_mount_options(m->mnt_opts, &flags, string_flags);
399 mount_one(m->mnt_fsname, m->mnt_dir, m->mnt_type, 388 /* If the directory is /, try to remount
389 * with the options specified in fstab */
390 if (m->mnt_dir[0] == '/' && m->mnt_dir[1] == '\0') {
391 flags |= MS_REMOUNT;
392 }
393 if (mount_one(m->mnt_fsname, m->mnt_dir, m->mnt_type,
400 flags, string_flags, useMtab, fakeIt, 394 flags, string_flags, useMtab, fakeIt,
401 extra_opts); 395 extra_opts, FALSE))
396 {
397 /* Try again, but this time try a remount */
398 mount_one(m->mnt_fsname, m->mnt_dir, m->mnt_type,
399 flags|MS_REMOUNT, string_flags, useMtab, fakeIt,
400 extra_opts, TRUE);
401 }
402 } 402 }
403 } 403 }
404 endmntent(f); 404 endmntent(f);
@@ -414,7 +414,7 @@ extern int mount_main(int argc, char **argv)
414#endif 414#endif
415 exit(mount_one(device, directory, filesystemType, 415 exit(mount_one(device, directory, filesystemType,
416 flags, string_flags, useMtab, fakeIt, 416 flags, string_flags, useMtab, fakeIt,
417 extra_opts)); 417 extra_opts, TRUE));
418 } else { 418 } else {
419 goto goodbye; 419 goto goodbye;
420 } 420 }