From: kettenis Date: Wed, 18 Oct 2023 22:44:42 +0000 (+0000) Subject: Avoid forcible mounting a dirty filessystem. Mount such filesystems X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1a98aacbe5b16fbc9d44ae470c7928a7f5277549;p=openbsd Avoid forcible mounting a dirty filessystem. Mount such filesystems read-only instead. This means that writing to the filesystem will fail. As a consequence chmod'ing of files in the bootloader will fail, but that will fix itself on the next clean boot. ok kn@ --- diff --git a/sys/arch/powerpc64/stand/rdboot/disk.c b/sys/arch/powerpc64/stand/rdboot/disk.c index 767f070bfda..6dc70badd6a 100644 --- a/sys/arch/powerpc64/stand/rdboot/disk.c +++ b/sys/arch/powerpc64/stand/rdboot/disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disk.c,v 1.3 2020/08/29 11:46:54 kettenis Exp $ */ +/* $OpenBSD: disk.c,v 1.4 2023/10/18 22:44:42 kettenis Exp $ */ /* * Copyright (c) 2019 Visa Hankala @@ -195,11 +195,13 @@ disk_open(const char *path) memset(&ffs_args, 0, sizeof(ffs_args)); ffs_args.fspec = devpath; - if (mount(MOUNT_FFS, "/mnt", MNT_FORCE | MNT_NOATIME, - &ffs_args) == -1) { - fprintf(stderr, "failed to mount %s: %s\n", devpath, - strerror(errno)); - return NULL; + if (mount(MOUNT_FFS, "/mnt", MNT_NOATIME, &ffs_args) == -1) { + if (mount(MOUNT_FFS, "/mnt", MNT_RDONLY, &ffs_args) == -1) { + fprintf(stderr, "failed to mount %s: %s\n", devpath, + strerror(errno)); + return NULL; + } + fprintf(stderr, "%s: mounted read-only\n", devpath); } if (chroot("/mnt") == -1) { fprintf(stderr, "failed to chroot: %s\n", strerror(errno));