[Ocfs2-tools-devel] [PATCH v4] mount.ocfs2: catch -EROFS if file system is readonly

Joseph Qi jiangqi903 at gmail.com
Thu Jan 4 04:00:40 PST 2018



On 18/1/4 14:19, piaojun wrote:
> If metadata is corrupted such as 'invalid inode block', we will get
> -EROFS by calling 'mount()'. In this situation we need notice user to
> fix it by fsck, and mount again rather than doing meaningless retry.
> 
> Signed-off-by: Jun Piao <piaojun at huawei.com>
Applied, thanks.

> ---
>  libocfs2/ocfs2_err.et     |  4 ++--
>  mount.ocfs2/mount.ocfs2.c | 11 +++++++++--
>  2 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/libocfs2/ocfs2_err.et b/libocfs2/ocfs2_err.et
> index 34cefed..3dc0ce2 100644
> --- a/libocfs2/ocfs2_err.et
> +++ b/libocfs2/ocfs2_err.et
> @@ -168,8 +168,8 @@ ec	OCFS2_ET_NO_IONICE,
>  ec	OCFS2_ET_NO_BACKUP_SUPER,
>  	"Backup superblock not found"
> 
> -ec      OCFS2_ET_TOO_MANY_SLOTS,
> -        "Too many slots for slot map"
> +ec	OCFS2_ET_TOO_MANY_SLOTS,
> +	"Too many slots for slot map"
> 
>  ec	OCFS2_ET_CANNOT_INLINE_DATA,
>  	"Unable to write the data inline"
> diff --git a/mount.ocfs2/mount.ocfs2.c b/mount.ocfs2/mount.ocfs2.c
> index e3d8871..5481ae9 100644
> --- a/mount.ocfs2/mount.ocfs2.c
> +++ b/mount.ocfs2/mount.ocfs2.c
> @@ -434,8 +434,15 @@ int main(int argc, char **argv)
>  			o2cb_complete_group_join(&cluster, &desc, errno);
>  		}
>  		block_signals (SIG_UNBLOCK);
> -		com_err(progname, ret, "while mounting %s on %s. Check 'dmesg' "
> -			"for more information on this error.", mo.dev, mo.dir);
> +		if (ret == -EROFS)
> +			com_err(progname, OCFS2_ET_RO_FILESYS, "while mounting %s "
> +				"on %s, please try fixing this by fsck.ocfs2 and then "
> +				"retry mounting", mo.dev, mo.dir);
> +		else
> +			com_err(progname, OCFS2_ET_INTERNAL_FAILURE,
> +				"while mounting %s on %s. Check 'dmesg' for more "
> +				"information on this error %d.", mo.dev, mo.dir,
> +				(int)ret);
>  		goto bail;
>  	}
>  	if (group_join) {
> 



More information about the Ocfs2-tools-devel mailing list