newfs: warn if newer than kernel

Creating a UFS filesystem with a newfs newer than the running kernel,
and then mounting that filesystem, can lead to interesting failures.

Add a safety belt to explicitly warn when newfs is newer than the
running kernel.

Reviewed by:	gjb, jhb, mckusick
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D12765
This commit is contained in:
emaste 2017-11-15 18:40:40 +00:00
parent 0dfd9255c7
commit fab7d89796

View File

@ -398,6 +398,10 @@ main(int argc, char *argv[])
if (pp != NULL)
pp->p_size *= secperblk;
}
if (getosreldate() < __FreeBSD_version) {
warnx("%s is newer than the running kernel and may not be compatible",
getprogname());
}
mkfs(pp, special);
ufs_disk_close(&disk);
if (!jflag)