diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-18 13:05:38 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-18 13:05:38 +0000 |
commit | b4133683a46303c624b42e2cf8515e54dfdd87be (patch) | |
tree | 6d23116cb8be642ee7714cd84ea00738e02667bd | |
parent | f732e96757090253fe4ed481674779864df95cfa (diff) | |
download | busybox-w32-b4133683a46303c624b42e2cf8515e54dfdd87be.tar.gz busybox-w32-b4133683a46303c624b42e2cf8515e54dfdd87be.tar.bz2 busybox-w32-b4133683a46303c624b42e2cf8515e54dfdd87be.zip |
mount: with -vv -f, say what mount() calls we were going to make
782357 728 7476 790561 c1021 busybox_old
782429 728 7476 790633 c1069 busybox_unstripped
-rw-r--r-- | util-linux/mount.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c index cd8fef9ee..8b3230935 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c | |||
@@ -216,7 +216,11 @@ struct globals { | |||
216 | }; | 216 | }; |
217 | #define G (*(struct globals*)&bb_common_bufsiz1) | 217 | #define G (*(struct globals*)&bb_common_bufsiz1) |
218 | #define nfs_mount_version (G.nfs_mount_version) | 218 | #define nfs_mount_version (G.nfs_mount_version) |
219 | #if ENABLE_FEATURE_MOUNT_VERBOSE | ||
219 | #define verbose (G.verbose ) | 220 | #define verbose (G.verbose ) |
221 | #else | ||
222 | #define verbose 0 | ||
223 | #endif | ||
220 | #define fslist (G.fslist ) | 224 | #define fslist (G.fslist ) |
221 | #define getmntent_buf (G.getmntent_buf ) | 225 | #define getmntent_buf (G.getmntent_buf ) |
222 | 226 | ||
@@ -231,9 +235,10 @@ static int verbose_mount(const char *source, const char *target, | |||
231 | errno = 0; | 235 | errno = 0; |
232 | rc = mount(source, target, filesystemtype, mountflags, data); | 236 | rc = mount(source, target, filesystemtype, mountflags, data); |
233 | if (verbose >= 2) | 237 | if (verbose >= 2) |
234 | bb_perror_msg("mount('%s','%s','%s',0x%08lx,'%s'):%d", | 238 | bb_perror_msg("would do mount('%s','%s','%s',0x%08lx,'%s'):%d" |
235 | source, target, filesystemtype, | 239 | + (sizeof("would do ")-1), |
236 | mountflags, (char*)data, rc); | 240 | source, target, filesystemtype, |
241 | mountflags, (char*)data, rc); | ||
237 | return rc; | 242 | return rc; |
238 | } | 243 | } |
239 | #else | 244 | #else |
@@ -274,9 +279,9 @@ static void append_mount_options(char **oldopts, const char *newopts) | |||
274 | 279 | ||
275 | /* Use the mount_options list to parse options into flags. | 280 | /* Use the mount_options list to parse options into flags. |
276 | * Also return list of unrecognized options if unrecognized!=NULL */ | 281 | * Also return list of unrecognized options if unrecognized!=NULL */ |
277 | static int parse_mount_options(char *options, char **unrecognized) | 282 | static long parse_mount_options(char *options, char **unrecognized) |
278 | { | 283 | { |
279 | int flags = MS_SILENT; | 284 | long flags = MS_SILENT; |
280 | 285 | ||
281 | // Loop through options | 286 | // Loop through options |
282 | for (;;) { | 287 | for (;;) { |
@@ -360,11 +365,17 @@ void delete_block_backed_filesystems(void); | |||
360 | 365 | ||
361 | // Perform actual mount of specific filesystem at specific location. | 366 | // Perform actual mount of specific filesystem at specific location. |
362 | // NB: mp->xxx fields may be trashed on exit | 367 | // NB: mp->xxx fields may be trashed on exit |
363 | static int mount_it_now(struct mntent *mp, int vfsflags, char *filteropts) | 368 | static int mount_it_now(struct mntent *mp, long vfsflags, char *filteropts) |
364 | { | 369 | { |
365 | int rc = 0; | 370 | int rc = 0; |
366 | 371 | ||
367 | if (fakeIt) goto mtab; | 372 | if (fakeIt) { |
373 | if (verbose >= 2) | ||
374 | bb_error_msg("would do mount('%s','%s','%s',0x%08lx,'%s')", | ||
375 | mp->mnt_fsname, mp->mnt_dir, mp->mnt_type, | ||
376 | vfsflags, filteropts); | ||
377 | goto mtab; | ||
378 | } | ||
368 | 379 | ||
369 | // Mount, with fallback to read-only if necessary. | 380 | // Mount, with fallback to read-only if necessary. |
370 | for (;;) { | 381 | for (;;) { |
@@ -898,7 +909,7 @@ static void error_msg_rpc(const char *msg) | |||
898 | } | 909 | } |
899 | 910 | ||
900 | // NB: mp->xxx fields may be trashed on exit | 911 | // NB: mp->xxx fields may be trashed on exit |
901 | static int nfsmount(struct mntent *mp, int vfsflags, char *filteropts) | 912 | static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts) |
902 | { | 913 | { |
903 | CLIENT *mclient; | 914 | CLIENT *mclient; |
904 | char *hostname; | 915 | char *hostname; |
@@ -1507,7 +1518,7 @@ static int nfsmount(struct mntent *mp, int vfsflags, char *filteropts) | |||
1507 | #else /* !ENABLE_FEATURE_MOUNT_NFS */ | 1518 | #else /* !ENABLE_FEATURE_MOUNT_NFS */ |
1508 | 1519 | ||
1509 | /* Never called. Call should be optimized out. */ | 1520 | /* Never called. Call should be optimized out. */ |
1510 | int nfsmount(struct mntent *mp, int vfsflags, char *filteropts); | 1521 | int nfsmount(struct mntent *mp, long vfsflags, char *filteropts); |
1511 | 1522 | ||
1512 | #endif /* !ENABLE_FEATURE_MOUNT_NFS */ | 1523 | #endif /* !ENABLE_FEATURE_MOUNT_NFS */ |
1513 | 1524 | ||
@@ -1516,7 +1527,8 @@ int nfsmount(struct mntent *mp, int vfsflags, char *filteropts); | |||
1516 | // NB: mp->xxx fields may be trashed on exit | 1527 | // NB: mp->xxx fields may be trashed on exit |
1517 | static int singlemount(struct mntent *mp, int ignore_busy) | 1528 | static int singlemount(struct mntent *mp, int ignore_busy) |
1518 | { | 1529 | { |
1519 | int rc = -1, vfsflags; | 1530 | int rc = -1; |
1531 | long vfsflags; | ||
1520 | char *loopFile = 0, *filteropts = 0; | 1532 | char *loopFile = 0, *filteropts = 0; |
1521 | llist_t *fl = 0; | 1533 | llist_t *fl = 0; |
1522 | struct stat st; | 1534 | struct stat st; |
@@ -1702,9 +1714,8 @@ int mount_main(int argc, char **argv) | |||
1702 | unsigned opt; | 1714 | unsigned opt; |
1703 | struct mntent mtpair[2], *mtcur = mtpair; | 1715 | struct mntent mtpair[2], *mtcur = mtpair; |
1704 | SKIP_DESKTOP(const int nonroot = 0;) | 1716 | SKIP_DESKTOP(const int nonroot = 0;) |
1705 | USE_DESKTOP( int nonroot = (getuid() != 0);) | ||
1706 | 1717 | ||
1707 | sanitize_env_if_suid(); | 1718 | USE_DESKTOP( int nonroot = ) sanitize_env_if_suid(); |
1708 | 1719 | ||
1709 | // Parse long options, like --bind and --move. Note that -o option | 1720 | // Parse long options, like --bind and --move. Note that -o option |
1710 | // and --option are synonymous. Yes, this means --remount,rw works. | 1721 | // and --option are synonymous. Yes, this means --remount,rw works. |
@@ -1774,7 +1785,7 @@ int mount_main(int argc, char **argv) | |||
1774 | goto clean_up; | 1785 | goto clean_up; |
1775 | } | 1786 | } |
1776 | 1787 | ||
1777 | i = parse_mount_options(cmdopts, 0); | 1788 | i = parse_mount_options(cmdopts, 0); // FIXME: should be "long", not "int" |
1778 | if (nonroot && (i & ~MS_SILENT)) // Non-root users cannot specify flags | 1789 | if (nonroot && (i & ~MS_SILENT)) // Non-root users cannot specify flags |
1779 | bb_error_msg_and_die(must_be_root); | 1790 | bb_error_msg_and_die(must_be_root); |
1780 | 1791 | ||