mount: support "nofail" option. Closes 8551

function                                             old     new   delta
singlemount                                         1045    1060     +15
mount_option_str                                     338     345      +7
mount_it_now                                         355     361      +6
mount_options                                        172     176      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 32/0)               Total: 32 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2015-12-30 20:11:34 +01:00
parent ce4bc1ed04
commit 911d265faf

View File

@ -259,9 +259,11 @@ static struct mntent *getmntent_r(FILE* stream, struct mntent* result,
// Not real flags, but we want to be able to check for this. // Not real flags, but we want to be able to check for this.
enum { enum {
MOUNT_USERS = (1 << 28) * ENABLE_DESKTOP, MOUNT_USERS = (1 << 27) * ENABLE_DESKTOP,
MOUNT_NOFAIL = (1 << 28) * ENABLE_DESKTOP,
MOUNT_NOAUTO = (1 << 29), MOUNT_NOAUTO = (1 << 29),
MOUNT_SWAP = (1 << 30), MOUNT_SWAP = (1 << 30),
MOUNT_FAKEFLAGS = MOUNT_USERS | MOUNT_NOFAIL | MOUNT_NOAUTO | MOUNT_SWAP
}; };
@ -326,6 +328,7 @@ static const int32_t mount_options[] = {
/* "swap" */ MOUNT_SWAP, /* "swap" */ MOUNT_SWAP,
IF_DESKTOP(/* "user" */ MOUNT_USERS,) IF_DESKTOP(/* "user" */ MOUNT_USERS,)
IF_DESKTOP(/* "users" */ MOUNT_USERS,) IF_DESKTOP(/* "users" */ MOUNT_USERS,)
IF_DESKTOP(/* "nofail" */ MOUNT_NOFAIL,)
/* "_netdev" */ 0, /* "_netdev" */ 0,
IF_DESKTOP(/* "comment=" */ 0,) /* systemd uses this in fstab */ IF_DESKTOP(/* "comment=" */ 0,) /* systemd uses this in fstab */
) )
@ -385,6 +388,7 @@ static const char mount_option_str[] =
"swap\0" "swap\0"
IF_DESKTOP("user\0") IF_DESKTOP("user\0")
IF_DESKTOP("users\0") IF_DESKTOP("users\0")
IF_DESKTOP("nofail\0")
"_netdev\0" "_netdev\0"
IF_DESKTOP("comment=\0") /* systemd uses this in fstab */ IF_DESKTOP("comment=\0") /* systemd uses this in fstab */
) )
@ -672,6 +676,8 @@ static int mount_it_now(struct mntent *mp, unsigned long vfsflags, char *filtero
{ {
int rc = 0; int rc = 0;
vfsflags &= ~(unsigned long)MOUNT_FAKEFLAGS;
if (FAKE_IT) { if (FAKE_IT) {
if (verbose >= 2) if (verbose >= 2)
bb_error_msg("would do mount('%s','%s','%s',0x%08lx,'%s')", bb_error_msg("would do mount('%s','%s','%s',0x%08lx,'%s')",
@ -2061,6 +2067,8 @@ static int singlemount(struct mntent *mp, int ignore_busy)
if (errno == EBUSY && ignore_busy) if (errno == EBUSY && ignore_busy)
return 0; return 0;
if (errno == ENOENT && (vfsflags & MOUNT_NOFAIL))
return 0;
if (rc != 0) if (rc != 0)
bb_perror_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir); bb_perror_msg("mounting %s on %s failed", mp->mnt_fsname, mp->mnt_dir);
return rc; return rc;