aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-12-05 16:40:36 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-12-05 16:40:36 +0000
commit30e5cf8875f757581256a4ec4f6935d1cb28a0fb (patch)
treea0c4334ef3dce586ff4cd306fada42de87b70fa7
parent15437e3e2a0cc9e4ba25066fd562b2862d38799b (diff)
downloadbusybox-w32-30e5cf8875f757581256a4ec4f6935d1cb28a0fb.tar.gz
busybox-w32-30e5cf8875f757581256a4ec4f6935d1cb28a0fb.tar.bz2
busybox-w32-30e5cf8875f757581256a4ec4f6935d1cb28a0fb.zip
mount: cosmetics, no code changes (verified with objdump -drsx)
-rw-r--r--util-linux/mount.c138
1 files changed, 58 insertions, 80 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 313521aa0..175328f41 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -9,14 +9,14 @@
9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 9 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
10 */ 10 */
11 11
12/* Design notes: There is no spec for mount. Remind me to write one. 12// Design notes: There is no spec for mount. Remind me to write one.
13 13//
14 mount_main() calls singlemount() which calls mount_it_now(). 14// mount_main() calls singlemount() which calls mount_it_now().
15 15//
16 mount_main() can loop through /etc/fstab for mount -a 16// mount_main() can loop through /etc/fstab for mount -a
17 singlemount() can loop through /etc/filesystems for fstype detection. 17// singlemount() can loop through /etc/filesystems for fstype detection.
18 mount_it_now() does the actual mount. 18// mount_it_now() does the actual mount.
19*/ 19//
20 20
21#include <mntent.h> 21#include <mntent.h>
22#include <syslog.h> 22#include <syslog.h>
@@ -26,7 +26,7 @@
26#include "volume_id.h" 26#include "volume_id.h"
27#endif 27#endif
28 28
29/* Needed for nfs support only */ 29// Needed for nfs support only
30#include <sys/utsname.h> 30#include <sys/utsname.h>
31#undef TRUE 31#undef TRUE
32#undef FALSE 32#undef FALSE
@@ -37,15 +37,15 @@
37#ifndef MS_SILENT 37#ifndef MS_SILENT
38#define MS_SILENT (1 << 15) 38#define MS_SILENT (1 << 15)
39#endif 39#endif
40/* Grab more as needed from util-linux's mount/mount_constants.h */ 40// Grab more as needed from util-linux's mount/mount_constants.h
41#ifndef MS_DIRSYNC 41#ifndef MS_DIRSYNC
42#define MS_DIRSYNC 128 /* Directory modifications are synchronous */ 42#define MS_DIRSYNC 128 // Directory modifications are synchronous
43#endif 43#endif
44 44
45 45
46#if defined(__dietlibc__) 46#if defined(__dietlibc__)
47/* 16.12.2006, Sampo Kellomaki (sampo@iki.fi) 47// 16.12.2006, Sampo Kellomaki (sampo@iki.fi)
48 * dietlibc-0.30 does not have implementation of getmntent_r() */ 48// dietlibc-0.30 does not have implementation of getmntent_r()
49static struct mntent *getmntent_r(FILE* stream, struct mntent* result, 49static struct mntent *getmntent_r(FILE* stream, struct mntent* result,
50 char* buffer UNUSED_PARAM, int bufsize UNUSED_PARAM) 50 char* buffer UNUSED_PARAM, int bufsize UNUSED_PARAM)
51{ 51{
@@ -99,9 +99,8 @@ enum {
99// This may be useful e.g. for /dev/fd if a login script makes 99// This may be useful e.g. for /dev/fd if a login script makes
100// the console user owner of this device. 100// the console user owner of this device.
101 101
102/* Standard mount options (from -o options or --options), with corresponding 102// Standard mount options (from -o options or --options),
103 * flags */ 103// with corresponding flags
104
105static const int32_t mount_options[] = { 104static const int32_t mount_options[] = {
106 // MS_FLAGS set a bit. ~MS_FLAGS disable that bit. 0 flags are NOPs. 105 // MS_FLAGS set a bit. ~MS_FLAGS disable that bit. 0 flags are NOPs.
107 106
@@ -166,7 +165,7 @@ static const char mount_option_str[] =
166 ) 165 )
167 USE_FEATURE_MOUNT_FSTAB( 166 USE_FEATURE_MOUNT_FSTAB(
168 "defaults" "\0" 167 "defaults" "\0"
169 /* "quiet" "\0" - do not filter out, vfat wants to see it */ 168 // "quiet" "\0" - do not filter out, vfat wants to see it
170 "noauto" "\0" 169 "noauto" "\0"
171 "sw" "\0" 170 "sw" "\0"
172 "swap" "\0" 171 "swap" "\0"
@@ -275,11 +274,11 @@ static int resolve_mount_spec(char **fsname)
275 return 0; 274 return 0;
276} 275}
277 276
278/* Append mount options to string */ 277// Append mount options to string
279static void append_mount_options(char **oldopts, const char *newopts) 278static void append_mount_options(char **oldopts, const char *newopts)
280{ 279{
281 if (*oldopts && **oldopts) { 280 if (*oldopts && **oldopts) {
282 /* do not insert options which are already there */ 281 // Do not insert options which are already there
283 while (newopts[0]) { 282 while (newopts[0]) {
284 char *p; 283 char *p;
285 int len = strlen(newopts); 284 int len = strlen(newopts);
@@ -307,8 +306,8 @@ static void append_mount_options(char **oldopts, const char *newopts)
307 } 306 }
308} 307}
309 308
310/* Use the mount_options list to parse options into flags. 309// Use the mount_options list to parse options into flags.
311 * Also return list of unrecognized options if unrecognized!=NULL */ 310// Also return list of unrecognized options if unrecognized != NULL
312static long parse_mount_options(char *options, char **unrecognized) 311static long parse_mount_options(char *options, char **unrecognized)
313{ 312{
314 long flags = MS_SILENT; 313 long flags = MS_SILENT;
@@ -321,7 +320,7 @@ static long parse_mount_options(char *options, char **unrecognized)
321 320
322 if (comma) *comma = '\0'; 321 if (comma) *comma = '\0';
323 322
324/* FIXME: use hasmntopt() */ 323// FIXME: use hasmntopt()
325 // Find this option in mount_options 324 // Find this option in mount_options
326 for (i = 0; i < ARRAY_SIZE(mount_options); i++) { 325 for (i = 0; i < ARRAY_SIZE(mount_options); i++) {
327 if (!strcasecmp(option_str, options)) { 326 if (!strcasecmp(option_str, options)) {
@@ -332,7 +331,7 @@ static long parse_mount_options(char *options, char **unrecognized)
332 } 331 }
333 option_str += strlen(option_str) + 1; 332 option_str += strlen(option_str) + 1;
334 } 333 }
335 // If unrecognized not NULL, append unrecognized mount options */ 334 // If unrecognized not NULL, append unrecognized mount options
336 if (unrecognized && i == ARRAY_SIZE(mount_options)) { 335 if (unrecognized && i == ARRAY_SIZE(mount_options)) {
337 // Add it to strflags, to pass on to kernel 336 // Add it to strflags, to pass on to kernel
338 i = *unrecognized ? strlen(*unrecognized) : 0; 337 i = *unrecognized ? strlen(*unrecognized) : 0;
@@ -354,7 +353,6 @@ static long parse_mount_options(char *options, char **unrecognized)
354} 353}
355 354
356// Return a list of all block device backed filesystems 355// Return a list of all block device backed filesystems
357
358static llist_t *get_block_backed_filesystems(void) 356static llist_t *get_block_backed_filesystems(void)
359{ 357{
360 static const char filesystems[2][sizeof("/proc/filesystems")] = { 358 static const char filesystems[2][sizeof("/proc/filesystems")] = {
@@ -448,8 +446,8 @@ static int mount_it_now(struct mntent *mp, long vfsflags, char *filteropts)
448 if (rc && errno == EPERM) 446 if (rc && errno == EPERM)
449 bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); 447 bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
450 448
451 /* If the mount was successful, and we're maintaining an old-style 449 // If the mount was successful, and we're maintaining an old-style
452 * mtab file by hand, add the new entry to it now. */ 450 // mtab file by hand, add the new entry to it now.
453 mtab: 451 mtab:
454 if (useMtab && !rc && !(vfsflags & MS_REMOUNT)) { 452 if (useMtab && !rc && !(vfsflags & MS_REMOUNT)) {
455 char *fsname; 453 char *fsname;
@@ -479,7 +477,7 @@ static int mount_it_now(struct mntent *mp, long vfsflags, char *filteropts)
479 477
480 mp->mnt_dir = bb_simplify_path(mp->mnt_dir); 478 mp->mnt_dir = bb_simplify_path(mp->mnt_dir);
481 fsname = 0; 479 fsname = 0;
482 if (!mp->mnt_type || !*mp->mnt_type) { /* bind mount */ 480 if (!mp->mnt_type || !*mp->mnt_type) { // bind mount
483 mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname); 481 mp->mnt_fsname = fsname = bb_simplify_path(mp->mnt_fsname);
484 mp->mnt_type = (char*)"bind"; 482 mp->mnt_type = (char*)"bind";
485 } 483 }
@@ -723,8 +721,7 @@ enum {
723#define EDQUOT ENOSPC 721#define EDQUOT ENOSPC
724#endif 722#endif
725 723
726// Convert each NFSERR_BLAH into EBLAH 724/* Convert each NFSERR_BLAH into EBLAH */
727
728static const struct { 725static const struct {
729 short stat; 726 short stat;
730 short errnum; 727 short errnum;
@@ -734,7 +731,6 @@ static const struct {
734 {28,ENOSPC}, {30,EROFS}, {63,ENAMETOOLONG}, {66,ENOTEMPTY}, {69,EDQUOT}, 731 {28,ENOSPC}, {30,EROFS}, {63,ENAMETOOLONG}, {66,ENOTEMPTY}, {69,EDQUOT},
735 {70,ESTALE}, {71,EREMOTE}, {-1,EIO} 732 {70,ESTALE}, {71,EREMOTE}, {-1,EIO}
736}; 733};
737
738static char *nfs_strerror(int status) 734static char *nfs_strerror(int status)
739{ 735{
740 int i; 736 int i;
@@ -920,7 +916,7 @@ static int daemonize(void)
920static inline int daemonize(void) { return -ENOSYS; } 916static inline int daemonize(void) { return -ENOSYS; }
921#endif 917#endif
922 918
923// TODO 919/* TODO */
924static inline int we_saw_this_host_before(const char *hostname UNUSED_PARAM) 920static inline int we_saw_this_host_before(const char *hostname UNUSED_PARAM)
925{ 921{
926 return 0; 922 return 0;
@@ -939,7 +935,7 @@ static void error_msg_rpc(const char *msg)
939 bb_error_msg("%.*s", len, msg); 935 bb_error_msg("%.*s", len, msg);
940} 936}
941 937
942// NB: mp->xxx fields may be trashed on exit 938/* NB: mp->xxx fields may be trashed on exit */
943static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts) 939static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
944{ 940{
945 CLIENT *mclient; 941 CLIENT *mclient;
@@ -1290,7 +1286,7 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1290 } 1286 }
1291 } 1287 }
1292 1288
1293 /* create mount daemon client */ 1289 /* Create mount daemon client */
1294 /* See if the nfs host = mount host. */ 1290 /* See if the nfs host = mount host. */
1295 if (mounthost) { 1291 if (mounthost) {
1296 if (mounthost[0] >= '0' && mounthost[0] <= '9') { 1292 if (mounthost[0] >= '0' && mounthost[0] <= '9') {
@@ -1336,12 +1332,12 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1336 retry_timeout.tv_usec = 0; 1332 retry_timeout.tv_usec = 0;
1337 total_timeout.tv_sec = 20; 1333 total_timeout.tv_sec = 20;
1338 total_timeout.tv_usec = 0; 1334 total_timeout.tv_usec = 0;
1339//FIXME: use monotonic()? 1335/* FIXME: use monotonic()? */
1340 timeout = time(NULL) + 60 * retry; 1336 timeout = time(NULL) + 60 * retry;
1341 prevt = 0; 1337 prevt = 0;
1342 t = 30; 1338 t = 30;
1343 retry: 1339 retry:
1344 /* be careful not to use too many CPU cycles */ 1340 /* Be careful not to use too many CPU cycles */
1345 if (t - prevt < 30) 1341 if (t - prevt < 30)
1346 sleep(30); 1342 sleep(30);
1347 1343
@@ -1381,10 +1377,11 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1381 error_msg_rpc(clnt_spcreateerror(" ")); 1377 error_msg_rpc(clnt_spcreateerror(" "));
1382 } else { 1378 } else {
1383 enum clnt_stat clnt_stat; 1379 enum clnt_stat clnt_stat;
1384 /* try to mount hostname:pathname */ 1380
1381 /* Try to mount hostname:pathname */
1385 mclient->cl_auth = authunix_create_default(); 1382 mclient->cl_auth = authunix_create_default();
1386 1383
1387 /* make pointers in xdr_mountres3 NULL so 1384 /* Make pointers in xdr_mountres3 NULL so
1388 * that xdr_array allocates memory for us 1385 * that xdr_array allocates memory for us
1389 */ 1386 */
1390 memset(&status, 0, sizeof(status)); 1387 memset(&status, 0, sizeof(status));
@@ -1421,7 +1418,6 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1421 } 1418 }
1422 1419
1423 /* Timeout. We are going to retry... maybe */ 1420 /* Timeout. We are going to retry... maybe */
1424
1425 if (!bg) 1421 if (!bg)
1426 goto fail; 1422 goto fail;
1427 if (!daemonized) { 1423 if (!daemonized) {
@@ -1475,8 +1471,7 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1475 data.flags |= NFS_MOUNT_VER3; 1471 data.flags |= NFS_MOUNT_VER3;
1476 } 1472 }
1477 1473
1478 /* create nfs socket for kernel */ 1474 /* Create nfs socket for kernel */
1479
1480 if (tcp) { 1475 if (tcp) {
1481 if (nfs_mount_version < 3) { 1476 if (nfs_mount_version < 3) {
1482 bb_error_msg("NFS over TCP is not supported"); 1477 bb_error_msg("NFS over TCP is not supported");
@@ -1502,14 +1497,12 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1502 } 1497 }
1503 server_addr.sin_port = htons(port); 1498 server_addr.sin_port = htons(port);
1504 1499
1505 /* prepare data structure for kernel */ 1500 /* Prepare data structure for kernel */
1506
1507 data.fd = fsock; 1501 data.fd = fsock;
1508 memcpy((char *) &data.addr, (char *) &server_addr, sizeof(data.addr)); 1502 memcpy((char *) &data.addr, (char *) &server_addr, sizeof(data.addr));
1509 strncpy(data.hostname, hostname, sizeof(data.hostname)); 1503 strncpy(data.hostname, hostname, sizeof(data.hostname));
1510 1504
1511 /* clean up */ 1505 /* Clean up */
1512
1513 auth_destroy(mclient->cl_auth); 1506 auth_destroy(mclient->cl_auth);
1514 clnt_destroy(mclient); 1507 clnt_destroy(mclient);
1515 close(msock); 1508 close(msock);
@@ -1523,7 +1516,7 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1523 if (!daemonized) { 1516 if (!daemonized) {
1524 daemonized = daemonize(); 1517 daemonized = daemonize();
1525 if (daemonized <= 0) { /* parent or error */ 1518 if (daemonized <= 0) { /* parent or error */
1526// FIXME: parent doesn't close fsock - ??! 1519/* FIXME: parent doesn't close fsock - ??! */
1527 retval = -daemonized; 1520 retval = -daemonized;
1528 goto ret; 1521 goto ret;
1529 } 1522 }
@@ -1535,14 +1528,14 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1535 } 1528 }
1536 } 1529 }
1537 1530
1538 do_mount: /* perform actual mount */ 1531 /* Perform actual mount */
1539 1532 do_mount:
1540 mp->mnt_type = (char*)"nfs"; 1533 mp->mnt_type = (char*)"nfs";
1541 retval = mount_it_now(mp, vfsflags, (char*)&data); 1534 retval = mount_it_now(mp, vfsflags, (char*)&data);
1542 goto ret; 1535 goto ret;
1543 1536
1544 fail: /* abort */ 1537 /* Abort */
1545 1538 fail:
1546 if (msock >= 0) { 1539 if (msock >= 0) {
1547 if (mclient) { 1540 if (mclient) {
1548 auth_destroy(mclient->cl_auth); 1541 auth_destroy(mclient->cl_auth);
@@ -1560,12 +1553,12 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
1560 return retval; 1553 return retval;
1561} 1554}
1562 1555
1563#else /* !ENABLE_FEATURE_MOUNT_NFS */ 1556#else // !ENABLE_FEATURE_MOUNT_NFS
1564 1557
1565/* Never called. Call should be optimized out. */ 1558// Never called. Call should be optimized out.
1566int nfsmount(struct mntent *mp, long vfsflags, char *filteropts); 1559int nfsmount(struct mntent *mp, long vfsflags, char *filteropts);
1567 1560
1568#endif /* !ENABLE_FEATURE_MOUNT_NFS */ 1561#endif // !ENABLE_FEATURE_MOUNT_NFS
1569 1562
1570// Mount one directory. Handles CIFS, NFS, loopback, autobind, and filesystem 1563// Mount one directory. Handles CIFS, NFS, loopback, autobind, and filesystem
1571// type detection. Returns 0 for success, nonzero for failure. 1564// type detection. Returns 0 for success, nonzero for failure.
@@ -1580,13 +1573,11 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1580 1573
1581 vfsflags = parse_mount_options(mp->mnt_opts, &filteropts); 1574 vfsflags = parse_mount_options(mp->mnt_opts, &filteropts);
1582 1575
1583 // Treat fstype "auto" as unspecified. 1576 // Treat fstype "auto" as unspecified
1584
1585 if (mp->mnt_type && strcmp(mp->mnt_type, "auto") == 0) 1577 if (mp->mnt_type && strcmp(mp->mnt_type, "auto") == 0)
1586 mp->mnt_type = NULL; 1578 mp->mnt_type = NULL;
1587 1579
1588 // Might this be a virtual filesystem? 1580 // Might this be a virtual filesystem?
1589
1590 if (ENABLE_FEATURE_MOUNT_HELPERS 1581 if (ENABLE_FEATURE_MOUNT_HELPERS
1591 && (strchr(mp->mnt_fsname, '#')) 1582 && (strchr(mp->mnt_fsname, '#'))
1592 ) { 1583 ) {
@@ -1609,7 +1600,6 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1609 } 1600 }
1610 1601
1611 // Might this be an CIFS filesystem? 1602 // Might this be an CIFS filesystem?
1612
1613 if (ENABLE_FEATURE_MOUNT_CIFS 1603 if (ENABLE_FEATURE_MOUNT_CIFS
1614 && (!mp->mnt_type || strcmp(mp->mnt_type, "cifs") == 0) 1604 && (!mp->mnt_type || strcmp(mp->mnt_type, "cifs") == 0)
1615 && (mp->mnt_fsname[0] == '/' || mp->mnt_fsname[0] == '\\') 1605 && (mp->mnt_fsname[0] == '/' || mp->mnt_fsname[0] == '\\')
@@ -1621,12 +1611,10 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1621 1611
1622 rc = 1; 1612 rc = 1;
1623 // Replace '/' with '\' and verify that unc points to "//server/share". 1613 // Replace '/' with '\' and verify that unc points to "//server/share".
1624
1625 for (s = mp->mnt_fsname; *s; ++s) 1614 for (s = mp->mnt_fsname; *s; ++s)
1626 if (*s == '/') *s = '\\'; 1615 if (*s == '/') *s = '\\';
1627 1616
1628 // get server IP 1617 // Get server IP
1629
1630 s = strrchr(mp->mnt_fsname, '\\'); 1618 s = strrchr(mp->mnt_fsname, '\\');
1631 if (s <= mp->mnt_fsname+1) goto report_error; 1619 if (s <= mp->mnt_fsname+1) goto report_error;
1632 *s = '\0'; 1620 *s = '\0';
@@ -1634,18 +1622,16 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1634 *s = '\\'; 1622 *s = '\\';
1635 if (!lsa) goto report_error; 1623 if (!lsa) goto report_error;
1636 1624
1637 // insert ip=... option into string flags. 1625 // Insert ip=... option into string flags.
1638
1639 dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa); 1626 dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
1640 ip = xasprintf("ip=%s", dotted); 1627 ip = xasprintf("ip=%s", dotted);
1641 parse_mount_options(ip, &filteropts); 1628 parse_mount_options(ip, &filteropts);
1642 1629
1643 // compose new unc '\\server-ip\share' 1630 // Compose new unc '\\server-ip\share'
1644 // (s => slash after hostname) 1631 // (s => slash after hostname)
1645
1646 mp->mnt_fsname = xasprintf("\\\\%s%s", dotted, s); 1632 mp->mnt_fsname = xasprintf("\\\\%s%s", dotted, s);
1647 1633
1648 // lock is required 1634 // Lock is required
1649 vfsflags |= MS_MANDLOCK; 1635 vfsflags |= MS_MANDLOCK;
1650 1636
1651 mp->mnt_type = (char*)"cifs"; 1637 mp->mnt_type = (char*)"cifs";
@@ -1660,7 +1646,6 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1660 } 1646 }
1661 1647
1662 // Might this be an NFS filesystem? 1648 // Might this be an NFS filesystem?
1663
1664 if (ENABLE_FEATURE_MOUNT_NFS 1649 if (ENABLE_FEATURE_MOUNT_NFS
1665 && (!mp->mnt_type || !strcmp(mp->mnt_type, "nfs")) 1650 && (!mp->mnt_type || !strcmp(mp->mnt_type, "nfs"))
1666 && strchr(mp->mnt_fsname, ':') != NULL 1651 && strchr(mp->mnt_fsname, ':') != NULL
@@ -1673,15 +1658,13 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1673 // a synthetic filesystem like proc or sysfs.) 1658 // a synthetic filesystem like proc or sysfs.)
1674 // (We use stat, not lstat, in order to allow 1659 // (We use stat, not lstat, in order to allow
1675 // mount symlink_to_file_or_blkdev dir) 1660 // mount symlink_to_file_or_blkdev dir)
1676
1677 if (!stat(mp->mnt_fsname, &st) 1661 if (!stat(mp->mnt_fsname, &st)
1678 && !(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE)) 1662 && !(vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))
1679 ) { 1663 ) {
1680 // Do we need to allocate a loopback device for it? 1664 // Do we need to allocate a loopback device for it?
1681
1682 if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) { 1665 if (ENABLE_FEATURE_MOUNT_LOOP && S_ISREG(st.st_mode)) {
1683 loopFile = bb_simplify_path(mp->mnt_fsname); 1666 loopFile = bb_simplify_path(mp->mnt_fsname);
1684 mp->mnt_fsname = NULL; /* will receive malloced loop dev name */ 1667 mp->mnt_fsname = NULL; // will receive malloced loop dev name
1685 if (set_loop(&(mp->mnt_fsname), loopFile, 0) < 0) { 1668 if (set_loop(&(mp->mnt_fsname), loopFile, 0) < 0) {
1686 if (errno == EPERM || errno == EACCES) 1669 if (errno == EPERM || errno == EACCES)
1687 bb_error_msg(bb_msg_perm_denied_are_you_root); 1670 bb_error_msg(bb_msg_perm_denied_are_you_root);
@@ -1691,24 +1674,21 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1691 } 1674 }
1692 1675
1693 // Autodetect bind mounts 1676 // Autodetect bind mounts
1694
1695 } else if (S_ISDIR(st.st_mode) && !mp->mnt_type) 1677 } else if (S_ISDIR(st.st_mode) && !mp->mnt_type)
1696 vfsflags |= MS_BIND; 1678 vfsflags |= MS_BIND;
1697 } 1679 }
1698 1680
1699 /* If we know the fstype (or don't need to), jump straight 1681 // If we know the fstype (or don't need to), jump straight
1700 * to the actual mount. */ 1682 // to the actual mount.
1701
1702 if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE))) 1683 if (mp->mnt_type || (vfsflags & (MS_REMOUNT | MS_BIND | MS_MOVE)))
1703 rc = mount_it_now(mp, vfsflags, filteropts); 1684 rc = mount_it_now(mp, vfsflags, filteropts);
1704 else { 1685 else {
1705 // Loop through filesystem types until mount succeeds 1686 // Loop through filesystem types until mount succeeds
1706 // or we run out 1687 // or we run out
1707 1688
1708 /* Initialize list of block backed filesystems. This has to be 1689 // Initialize list of block backed filesystems. This has to be
1709 * done here so that during "mount -a", mounts after /proc shows up 1690 // done here so that during "mount -a", mounts after /proc shows up
1710 * can autodetect. */ 1691 // can autodetect.
1711
1712 if (!fslist) { 1692 if (!fslist) {
1713 fslist = get_block_backed_filesystems(); 1693 fslist = get_block_backed_filesystems();
1714 if (ENABLE_FEATURE_CLEAN_UP && fslist) 1694 if (ENABLE_FEATURE_CLEAN_UP && fslist)
@@ -1723,7 +1703,6 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1723 } 1703 }
1724 1704
1725 // If mount failed, clean up loop file (if any). 1705 // If mount failed, clean up loop file (if any).
1726
1727 if (ENABLE_FEATURE_MOUNT_LOOP && rc && loopFile) { 1706 if (ENABLE_FEATURE_MOUNT_LOOP && rc && loopFile) {
1728 del_loop(mp->mnt_fsname); 1707 del_loop(mp->mnt_fsname);
1729 if (ENABLE_FEATURE_CLEAN_UP) { 1708 if (ENABLE_FEATURE_CLEAN_UP) {
@@ -1745,7 +1724,6 @@ static int singlemount(struct mntent *mp, int ignore_busy)
1745 1724
1746// Parse options, if necessary parse fstab/mtab, and call singlemount for 1725// Parse options, if necessary parse fstab/mtab, and call singlemount for
1747// each directory to be mounted. 1726// each directory to be mounted.
1748
1749static const char must_be_root[] ALIGN1 = "you must be root"; 1727static const char must_be_root[] ALIGN1 = "you must be root";
1750 1728
1751int mount_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 1729int mount_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -1840,8 +1818,8 @@ int mount_main(int argc UNUSED_PARAM, char **argv)
1840 if (ENABLE_FEATURE_MOUNT_FLAGS 1818 if (ENABLE_FEATURE_MOUNT_FLAGS
1841 && (i & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)) 1819 && (i & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
1842 ) { 1820 ) {
1843 rc = verbose_mount(/*source:*/ "", /*target:*/ argv[0], 1821 // verbose_mount(source, target, type, flags, data)
1844 /*type:*/ "", /*flags:*/ i, /*data:*/ ""); 1822 rc = verbose_mount("", argv[0], "", i, "");
1845 if (rc) 1823 if (rc)
1846 bb_simple_perror_msg_and_die(argv[0]); 1824 bb_simple_perror_msg_and_die(argv[0]);
1847 return rc; 1825 return rc;