-/* $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
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));