From: kettenis Date: Fri, 20 Oct 2023 18:53:12 +0000 (+0000) Subject: Avoid forcible mounting a dirty filessystem. Mount such filesystems X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=8a9ff49d785dfa0d133f66af715b210bca964cdb;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. Same change as I committed to powerpc64 a few days ago. ok kn@, deraadt@ --- diff --git a/sys/arch/octeon/stand/rdboot/disk.c b/sys/arch/octeon/stand/rdboot/disk.c index eda089bc34f..847b84551c4 100644 --- a/sys/arch/octeon/stand/rdboot/disk.c +++ b/sys/arch/octeon/stand/rdboot/disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disk.c,v 1.2 2020/05/26 13:30:47 visa Exp $ */ +/* $OpenBSD: disk.c,v 1.3 2023/10/20 18:53:12 kettenis Exp $ */ /* * Copyright (c) 2019 Visa Hankala @@ -180,11 +180,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));