git: 3e750057fbba - stable/12 - makefs: avoid warning when creating FAT filesystem on existing file

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Thu, 12 Dec 2024 22:43:53 UTC
The branch stable/12 has been updated by jrtc27:

URL: https://cgit.FreeBSD.org/src/commit/?id=3e750057fbbab6bbc1075825fb79517af8f94876

commit 3e750057fbbab6bbc1075825fb79517af8f94876
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2019-11-08 14:11:25 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2024-12-12 21:40:40 +0000

    makefs: avoid warning when creating FAT filesystem on existing file
    
    Previously the mkfs_msdos function (from newfs_msdos) emitted warnings
    in the case that an image size is specified and the target is not a
    file, or no size is specified and the target is not a character device.
    The latter warning (not a character device) doesn't make sense when this
    code is used in makefs, regardless of whether an image size is specified
    or not.
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit d9aee13f6fdad3de080ac0f8b9847daf6b9d567b)
---
 sbin/newfs_msdos/mkfs_msdos.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sbin/newfs_msdos/mkfs_msdos.c b/sbin/newfs_msdos/mkfs_msdos.c
index 96080849ca9c..2369a5089fcf 100644
--- a/sbin/newfs_msdos/mkfs_msdos.c
+++ b/sbin/newfs_msdos/mkfs_msdos.c
@@ -291,8 +291,10 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
 	if (!S_ISREG(sb.st_mode))
 	    warnx("warning, %s is not a regular file", fname);
     } else {
+#ifndef MAKEFS
 	if (!S_ISCHR(sb.st_mode))
 	    warnx("warning, %s is not a character device", fname);
+#endif
     }
     if (!o.no_create)
 	if (check_mounted(fname, sb.st_mode) == -1)