newfs_msdos: Improve error messages
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run

- Report overly long OEM string as too long, not just "bad".

- Use warn instead of warnx for open or ftruncate failure to report the
error string.

Reviewed by:	se
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D53649
This commit is contained in:
Ed Maste 2025-11-09 14:43:50 -05:00
parent 80ca573fc4
commit dbb34d4967

View file

@ -264,7 +264,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
goto done;
}
if (o.OEM_string && strlen(o.OEM_string) > 8) {
warnx("%s: bad OEM string", o.OEM_string);
warnx("%s: OEM string too long", o.OEM_string);
goto done;
}
if (o.create_size) {
@ -274,11 +274,11 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
}
fd = open(fname, O_RDWR | O_CREAT | O_TRUNC, 0644);
if (fd == -1) {
warnx("failed to create %s", fname);
warn("failed to create %s", fname);
goto done;
}
if (ftruncate(fd, o.create_size)) {
warnx("failed to initialize %jd bytes", (intmax_t)o.create_size);
warn("failed to initialize %jd bytes", (intmax_t)o.create_size);
goto done;
}
} else if ((fd = open(fname, o.no_create ? O_RDONLY : O_RDWR)) == -1) {