aboutsummaryrefslogtreecommitdiff
path: root/util-linux/mount.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-09-15 13:28:30 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-09-15 13:28:30 +0000
commit2535f12cf21b3dd481d59ea1678f9dc05c404efe (patch)
tree4a0a72b83a693b1dc9bf31acd7bcf6ee726d9a5c /util-linux/mount.c
parent32eb1f6cb95024e9db28b689891d04769a8b9b35 (diff)
downloadbusybox-w32-2535f12cf21b3dd481d59ea1678f9dc05c404efe.tar.gz
busybox-w32-2535f12cf21b3dd481d59ea1678f9dc05c404efe.tar.bz2
busybox-w32-2535f12cf21b3dd481d59ea1678f9dc05c404efe.zip
httpd: do not clear environment
mount: mount helpers support (by Vladimir Dronnikov <dronnikov@gmail.ru>)
Diffstat (limited to 'util-linux/mount.c')
-rw-r--r--util-linux/mount.c55
1 files changed, 40 insertions, 15 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 91f09e15c..d391a26e1 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -18,8 +18,8 @@
18 mount_it_now() does the actual mount. 18 mount_it_now() does the actual mount.
19*/ 19*/
20 20
21#include "libbb.h"
22#include <mntent.h> 21#include <mntent.h>
22#include "libbb.h"
23 23
24/* Needed for nfs support only... */ 24/* Needed for nfs support only... */
25#include <syslog.h> 25#include <syslog.h>
@@ -30,20 +30,23 @@
30#include <rpc/pmap_prot.h> 30#include <rpc/pmap_prot.h>
31#include <rpc/pmap_clnt.h> 31#include <rpc/pmap_clnt.h>
32 32
33#ifndef MS_SILENT
34#define MS_SILENT (1 << 15)
35#endif
33 36
34#if defined(__dietlibc__) 37#if defined(__dietlibc__)
35/* 16.12.2006, Sampo Kellomaki (sampo@iki.fi) 38/* 16.12.2006, Sampo Kellomaki (sampo@iki.fi)
36 * dietlibc-0.30 does not have implementation of getmntent_r() */ 39 * dietlibc-0.30 does not have implementation of getmntent_r() */
37/* OTOH: why we use getmntent_r instead of getmntent? TODO... */
38struct mntent *getmntent_r(FILE* stream, struct mntent* result, char* buffer, int bufsize) 40struct mntent *getmntent_r(FILE* stream, struct mntent* result, char* buffer, int bufsize)
39{ 41{
40 /* *** XXX FIXME WARNING: This hack is NOT thread safe. --Sampo */
41 struct mntent* ment = getmntent(stream); 42 struct mntent* ment = getmntent(stream);
42 memcpy(result, ment, sizeof(struct mntent)); 43 memcpy(result, ment, sizeof(struct mntent));
43 return result; 44 return result;
44} 45}
45#endif 46#endif
46 47
48#define getmntent_buf bb_common_bufsiz1
49
47 50
48// Not real flags, but we want to be able to check for this. 51// Not real flags, but we want to be able to check for this.
49enum { 52enum {
@@ -186,11 +189,11 @@ static int parse_mount_options(char *options, char **unrecognized)
186 strcpy((*unrecognized)+i, options); 189 strcpy((*unrecognized)+i, options);
187 } 190 }
188 191
189 // Advance to next option, or finish 192 if (!comma)
190 if (comma) { 193 break;
191 *comma = ','; 194 // Advance to next option
192 options = ++comma; 195 *comma = ',';
193 } else break; 196 options = ++comma;
194 } 197 }
195 198
196 return flags; 199 return flags;
@@ -262,8 +265,9 @@ static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts)
262 vfsflags, filteropts); 265 vfsflags, filteropts);
263 if (!rc || (vfsflags&MS_RDONLY) || (errno!=EACCES && errno!=EROFS)) 266 if (!rc || (vfsflags&MS_RDONLY) || (errno!=EACCES && errno!=EROFS))
264 break; 267 break;
265 bb_error_msg("%s is write-protected, mounting read-only", 268 if (!(vfsflags & MS_SILENT))
266 mp->mnt_fsname); 269 bb_error_msg("%s is write-protected, mounting read-only",
270 mp->mnt_fsname);
267 vfsflags |= MS_RDONLY; 271 vfsflags |= MS_RDONLY;
268 } 272 }
269 273
@@ -1399,6 +1403,27 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1399 if (mp->mnt_type && strcmp(mp->mnt_type,"auto") == 0) 1403 if (mp->mnt_type && strcmp(mp->mnt_type,"auto") == 0)
1400 mp->mnt_type = 0; 1404 mp->mnt_type = 0;
1401 1405
1406 // Might this be a virtual filesystem?
1407
1408 if (ENABLE_FEATURE_MOUNT_HELPERS
1409 && (strchr(mp->mnt_fsname,'#'))
1410 ) {
1411 char *s, *p, *args[35];
1412 int n = 0;
1413 for (s = p = mp->mnt_fsname; *s && n < 35-3; ++s) {
1414 if (s[0] == '#' && s[1] != '#') {
1415 *s = '\0';
1416 args[n++] = p;
1417 p = s + 1;
1418 }
1419 }
1420 args[n++] = p;
1421 args[n++] = mp->mnt_dir;
1422 args[n] = NULL;
1423 rc = wait4pid(xspawn(args));
1424 goto report_error;
1425 }
1426
1402 // Might this be an CIFS filesystem? 1427 // Might this be an CIFS filesystem?
1403 1428
1404 if (ENABLE_FEATURE_MOUNT_CIFS 1429 if (ENABLE_FEATURE_MOUNT_CIFS
@@ -1593,8 +1618,8 @@ int mount_main(int argc, char **argv)
1593 1618
1594 if (!mountTable) bb_error_msg_and_die("no %s", bb_path_mtab_file); 1619 if (!mountTable) bb_error_msg_and_die("no %s", bb_path_mtab_file);
1595 1620
1596 while (getmntent_r(mountTable, mtpair, bb_common_bufsiz1, 1621 while (getmntent_r(mountTable, &mtpair[0], getmntent_buf,
1597 sizeof(bb_common_bufsiz1))) 1622 sizeof(getmntent_buf)))
1598 { 1623 {
1599 // Don't show rootfs. FIXME: why?? 1624 // Don't show rootfs. FIXME: why??
1600 // util-linux 2.12a happily shows rootfs... 1625 // util-linux 2.12a happily shows rootfs...
@@ -1657,9 +1682,9 @@ int mount_main(int argc, char **argv)
1657 1682
1658 // Get next fstab entry 1683 // Get next fstab entry
1659 1684
1660 if (!getmntent_r(fstab, mtcur, bb_common_bufsiz1 1685 if (!getmntent_r(fstab, mtcur, getmntent_buf
1661 + (mtcur==mtpair ? sizeof(bb_common_bufsiz1)/2 : 0), 1686 + (mtcur==mtpair ? sizeof(getmntent_buf)/2 : 0),
1662 sizeof(bb_common_bufsiz1)/2)) 1687 sizeof(getmntent_buf)/2))
1663 { 1688 {
1664 // Were we looking for something specific? 1689 // Were we looking for something specific?
1665 1690