git: 54416c6e1379 - stable/14 - Ensure that soft updates are not enabled by default when using mdmfs(8)

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Sat, 12 Oct 2024 22:30:22 UTC
The branch stable/14 has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=54416c6e137980197ee7a3cdc124174642f32af2

commit 54416c6e137980197ee7a3cdc124174642f32af2
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2024-10-03 15:05:42 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2024-10-12 22:30:06 +0000

    Ensure that soft updates are not enabled by default when using mdmfs(8)
    
    When soft updates began being enabled by default that change carried
    over to mdmfs(8) which does not want or need them. This fix ensures
    that they are only enabled in mdmfs(8) when requested with the -U flag.
    
    Reported by: Ivan Rozhuk
    Tested by:   Michael Proto
    PR:          279308
    
    (cherry picked from commit 5b21d4ad060acb06c72e0458daebec9bcbf0cefd)
---
 include/paths.h    | 3 +++
 sbin/mdmfs/mdmfs.c | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/paths.h b/include/paths.h
index 55f7d1175617..0f930ed5c03d 100644
--- a/include/paths.h
+++ b/include/paths.h
@@ -92,6 +92,7 @@
 #define	_PATH_SENDMAIL	"/usr/sbin/sendmail"
 #define	_PATH_SHELLS	"/etc/shells"
 #define	_PATH_TTY	"/dev/tty"
+#define	_PATH_TUNEFS	"/sbin/tunefs"
 #define	_PATH_UNIX	"don't use _PATH_UNIX"
 #define	_PATH_UFSSUSPEND	"/dev/ufssuspend"
 #define	_PATH_VI	"/usr/bin/vi"
@@ -141,6 +142,8 @@ __END_DECLS
 #define	_PATH_REBOOT	"/rescue/reboot"
 #undef	_PATH_RM
 #define	_PATH_RM	"/rescue/rm"
+#undef	_PATH_TUNEFS
+#define	_PATH_TUNEFS	"/rescue/tunefs"
 #undef	_PATH_VI
 #define	_PATH_VI	"/rescue/vi"
 #undef	_PATH_WALL
diff --git a/sbin/mdmfs/mdmfs.c b/sbin/mdmfs/mdmfs.c
index dbd206f953d2..ceb33362e627 100644
--- a/sbin/mdmfs/mdmfs.c
+++ b/sbin/mdmfs/mdmfs.c
@@ -105,7 +105,7 @@ main(int argc, char **argv)
 	bool detach, softdep, autounit, newfs;
 	const char *mtpoint, *size_arg, *skel, *unitstr;
 	char *p;
-	int ch, idx;
+	int ch, idx, rv;
 	void *set;
 	unsigned long ul;
 
@@ -358,6 +358,13 @@ main(int argc, char **argv)
 			do_mdconfig_attach(mdconfig_arg, mdtype);
 		if (newfs)
 			do_newfs(newfs_arg);
+		if (!softdep) {
+			rv = run(NULL, "%s %s /dev/%s%d", _PATH_TUNEFS,
+			    "-n disable", mdname, unit);
+			if (rv)
+				errx(1, "tunefs exited %s %d", run_exitstr(rv),
+				    run_exitnumber(rv));
+		}
 		do_mount_md(mount_arg, mtpoint);
 	}