The branch main has been updated by rew:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=03ad449f6cbd17995111891b438fdc97c50f0f51

commit 03ad449f6cbd17995111891b438fdc97c50f0f51
Author:     Robert Wing <r...@freebsd.org>
AuthorDate: 2025-06-03 16:47:11 +0000
Commit:     Robert Wing <r...@freebsd.org>
CommitDate: 2025-06-03 16:47:11 +0000

    newfs: enable newfs to run on plain files without a bsdlabel
    
    For awhile now it's been possible to newfs a plain file...however, newfs
    errors out when the file doesn't have a bsdlabel - this commit changes
    that.
    
    Reviewed by:    mckusick
    Differential Revision:  https://reviews.freebsd.org/D50562
---
 sbin/newfs/newfs.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sbin/newfs/newfs.c b/sbin/newfs/newfs.c
index 9c45c9150955..78a297e6074a 100644
--- a/sbin/newfs/newfs.c
+++ b/sbin/newfs/newfs.c
@@ -342,6 +342,11 @@ main(int argc, char *argv[])
        }
        pp = NULL;
        lp = getdisklabel();
+       /*
+        * set filesystem size from file size when a bsdlabel isn't present
+        */
+       if (lp == NULL && is_file)
+               fssize = mediasize / sectorsize;
        if (lp != NULL) {
                if (!is_file) /* already set for files */
                        part_name = special[strlen(special) - 1];
@@ -431,7 +436,7 @@ getdisklabel(void)
                    bootarea + (0 /* labeloffset */ +
                                1 /* labelsoffset */ * sectorsize),
                    &lab, MAXPARTITIONS))
-                       errx(1, "no valid label found");
+                       return (NULL);
 
                lp = &lab;
                return &lab;

Reply via email to