CVS commit: src/sbin/newfs

2024-05-10 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri May 10 20:36:34 UTC 2024

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
s/superbock/superblock/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2024-05-10 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri May 10 20:36:34 UTC 2024

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
s/superbock/superblock/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.136 src/sbin/newfs/mkfs.c:1.137
--- src/sbin/newfs/mkfs.c:1.136	Thu Feb 22 02:11:29 2024
+++ src/sbin/newfs/mkfs.c	Fri May 10 20:36:34 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.136 2024/02/22 02:11:29 mrg Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.137 2024/05/10 20:36:34 andvar Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.136 2024/02/22 02:11:29 mrg Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.137 2024/05/10 20:36:34 andvar Exp $");
 #endif
 #endif /* not lint */
 
@@ -611,7 +611,7 @@ mkfs(const char *fsys, int fi, int fo,
 
 		/*
 		 * Ensure there is nothing that looks like a filesystem
-		 * superbock anywhere other than where ours will be.
+		 * superblock anywhere other than where ours will be.
 		 * If fsck finds the wrong one all hell breaks loose!
 		 */
 		for (i = 0; ; i++) {



CVS commit: src/sbin/newfs

2024-02-21 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Feb 22 02:11:29 UTC 2024

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
if the window size works but is 0, assume it didn't work and use 80.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2024-02-21 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Feb 22 02:11:29 UTC 2024

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
if the window size works but is 0, assume it didn't work and use 80.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.135 src/sbin/newfs/mkfs.c:1.136
--- src/sbin/newfs/mkfs.c:1.135	Wed Jul  5 10:58:58 2023
+++ src/sbin/newfs/mkfs.c	Thu Feb 22 02:11:29 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.135 2023/07/05 10:58:58 riastradh Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.136 2024/02/22 02:11:29 mrg Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.135 2023/07/05 10:58:58 riastradh Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.136 2024/02/22 02:11:29 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -672,7 +672,8 @@ mkfs(const char *fsys, int fi, int fo,
 	fld_width = verbosity < 4 ? 1 : snprintf(NULL, 0, "%" PRIu64, 
 		(uint64_t)FFS_FSBTODB(, cgsblock(, sblock.fs_ncg-1)));
 	/* Get terminal width */
-	if (ioctl(fileno(stdout), TIOCGWINSZ, ) == 0)
+	if (ioctl(fileno(stdout), TIOCGWINSZ, ) == 0 &&
+	winsize.ws_col != 0)
 		max_cols = winsize.ws_col;
 	else
 		max_cols = 80;



Re: CVS commit: src/sbin/newfs

2023-07-05 Thread Greg Troxel
Taylor R Campbell  writes:

> Well, what happened is:
>
> 1. I was drafting posix_memalign and aligned_alloc for libbsdmalloc in
>response to the thread about static program size yesterday, and
>carefully reading the specs -- POSIX 2018, C11 -- to make sure I
>got all the details right.
>
> 2. I saw a silly restriction in C11, that aligned_alloc(A, S) requires
>A to divide S.
>
> 3. For the sake of encouraging portable code, I figured we should
>enforce that restriction, so I went ahead and did that in both the
>libbsdmalloc front end I was writing and in jemalloc.  (This caused
>a bunch of tests to start failing.)
>
> 4. I audited all the uses of aligned_alloc in tree to make sury they
>meet the restriction (which fixed the tests).
>
> 5. Someone pointed out that the silly restriction that was imposed in
>C11 had actually been lifted in C17:
>
> (C11) The value of alignment shall be a valid alignment
> supported by the implementation and the value of size shall be
> an integral multiple of alignment.
>
> (C17) If the value of alignment is not a valid alignment
> supported by the implementation the function shall fail by
> returning a null pointer.
>
> 6. So I reverted the jemalloc enforcement of the C11 restriction, and
>reverted the fixes made to conform to it, and removed the
>restriction in the new libbsdmalloc code, and we're more or less
>back to where we started.
>
> Except I am now reminded that I updated t_posix_memalign.c to verify
> this silly restriction of aligned_alloc, so I'd better go fix that
> before a bunch of tests start failing again!

Thanks for taking the time to explain so thoroughly.  So we are back to
status quo ante-fixum, which is by definition always ok :-)


Re: CVS commit: src/sbin/newfs

2023-07-05 Thread Taylor R Campbell
> Date: Wed, 05 Jul 2023 07:03:09 -0400
> From: Greg Troxel 
> References: <20230705105858.33080f...@cvs.netbsd.org>
> 
> "Taylor R Campbell"  writes:
> 
> > Revert "newfs(8): Ensure A divides S before aligned_alloc(A, S)."
> >
> > C17 lifted this restriction.
> 
> I know we have only two toolchains maintained in tree, but did we really
> decide to require C17?

Well, what happened is:

1. I was drafting posix_memalign and aligned_alloc for libbsdmalloc in
   response to the thread about static program size yesterday, and
   carefully reading the specs -- POSIX 2018, C11 -- to make sure I
   got all the details right.

2. I saw a silly restriction in C11, that aligned_alloc(A, S) requires
   A to divide S.

3. For the sake of encouraging portable code, I figured we should
   enforce that restriction, so I went ahead and did that in both the
   libbsdmalloc front end I was writing and in jemalloc.  (This caused
   a bunch of tests to start failing.)

4. I audited all the uses of aligned_alloc in tree to make sury they
   meet the restriction (which fixed the tests).

5. Someone pointed out that the silly restriction that was imposed in
   C11 had actually been lifted in C17:

(C11) The value of alignment shall be a valid alignment
supported by the implementation and the value of size shall be
an integral multiple of alignment.

(C17) If the value of alignment is not a valid alignment
supported by the implementation the function shall fail by
returning a null pointer.

6. So I reverted the jemalloc enforcement of the C11 restriction, and
   reverted the fixes made to conform to it, and removed the
   restriction in the new libbsdmalloc code, and we're more or less
   back to where we started.

Except I am now reminded that I updated t_posix_memalign.c to verify
this silly restriction of aligned_alloc, so I'd better go fix that
before a bunch of tests start failing again!


CVS commit: src/sbin/newfs

2023-07-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul  5 10:58:58 UTC 2023

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
Revert "newfs(8): Ensure A divides S before aligned_alloc(A, S)."

C17 lifted this restriction.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.119 -r1.120 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.134 src/sbin/newfs/mkfs.c:1.135
--- src/sbin/newfs/mkfs.c:1.134	Tue Jul  4 20:40:34 2023
+++ src/sbin/newfs/mkfs.c	Wed Jul  5 10:58:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.134 2023/07/04 20:40:34 riastradh Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.135 2023/07/05 10:58:58 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.134 2023/07/04 20:40:34 riastradh Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.135 2023/07/05 10:58:58 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -201,11 +201,9 @@ mkfs(const char *fsys, int fi, int fo,
 			exit(12);
 	}
 #endif
-	__CTASSERT((sizeof(*fsun) % DEV_BSIZE) == 0);
 	if ((fsun = aligned_alloc(DEV_BSIZE, sizeof(*fsun))) == NULL)
 		exit(12);
 	memset(fsun, 0, sizeof(*fsun));
-	__CTASSERT((sizeof(*cgun) % DEV_BSIZE) == 0);
 	if ((cgun = aligned_alloc(DEV_BSIZE, sizeof(*cgun))) == NULL)
 		exit(12);
 	memset(cgun, 0, sizeof(*cgun));

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.119 src/sbin/newfs/newfs.c:1.120
--- src/sbin/newfs/newfs.c:1.119	Tue Jul  4 20:40:34 2023
+++ src/sbin/newfs/newfs.c	Wed Jul  5 10:58:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.119 2023/07/04 20:40:34 riastradh Exp $	*/
+/*	$NetBSD: newfs.c,v 1.120 2023/07/05 10:58:58 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)newfs.c	8.13 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: newfs.c,v 1.119 2023/07/04 20:40:34 riastradh Exp $");
+__RCSID("$NetBSD: newfs.c,v 1.120 2023/07/05 10:58:58 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -624,9 +624,7 @@ main(int argc, char *argv[])
 		} else
 			bufsize = sfs.f_iosize;
 
-		__CTASSERT(powerof2(DEV_BSIZE));
-		if ((buf = aligned_alloc(DEV_BSIZE,
-			roundup2(bufsize, DEV_BSIZE))) == NULL)
+		if ((buf = aligned_alloc(DEV_BSIZE, bufsize)) == NULL)
 			err(1, "can't malloc buffer of %d",
 			bufsize);
 		memset(buf, 0, bufsize);



CVS commit: src/sbin/newfs

2023-07-05 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Jul  5 10:58:58 UTC 2023

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
Revert "newfs(8): Ensure A divides S before aligned_alloc(A, S)."

C17 lifted this restriction.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.119 -r1.120 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2023-07-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul  4 20:40:34 UTC 2023

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
newfs(8): Ensure A divides S before aligned_alloc(A, S).

Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.118 -r1.119 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.133 src/sbin/newfs/mkfs.c:1.134
--- src/sbin/newfs/mkfs.c:1.133	Sat Jan  7 19:41:29 2023
+++ src/sbin/newfs/mkfs.c	Tue Jul  4 20:40:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.133 2023/01/07 19:41:29 chs Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.134 2023/07/04 20:40:34 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.133 2023/01/07 19:41:29 chs Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.134 2023/07/04 20:40:34 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -201,9 +201,11 @@ mkfs(const char *fsys, int fi, int fo,
 			exit(12);
 	}
 #endif
+	__CTASSERT((sizeof(*fsun) % DEV_BSIZE) == 0);
 	if ((fsun = aligned_alloc(DEV_BSIZE, sizeof(*fsun))) == NULL)
 		exit(12);
 	memset(fsun, 0, sizeof(*fsun));
+	__CTASSERT((sizeof(*cgun) % DEV_BSIZE) == 0);
 	if ((cgun = aligned_alloc(DEV_BSIZE, sizeof(*cgun))) == NULL)
 		exit(12);
 	memset(cgun, 0, sizeof(*cgun));

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.118 src/sbin/newfs/newfs.c:1.119
--- src/sbin/newfs/newfs.c:1.118	Thu Nov 17 06:40:39 2022
+++ src/sbin/newfs/newfs.c	Tue Jul  4 20:40:34 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.118 2022/11/17 06:40:39 chs Exp $	*/
+/*	$NetBSD: newfs.c,v 1.119 2023/07/04 20:40:34 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)newfs.c	8.13 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: newfs.c,v 1.118 2022/11/17 06:40:39 chs Exp $");
+__RCSID("$NetBSD: newfs.c,v 1.119 2023/07/04 20:40:34 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -624,7 +624,9 @@ main(int argc, char *argv[])
 		} else
 			bufsize = sfs.f_iosize;
 
-		if ((buf = aligned_alloc(DEV_BSIZE, bufsize)) == NULL)
+		__CTASSERT(powerof2(DEV_BSIZE));
+		if ((buf = aligned_alloc(DEV_BSIZE,
+			roundup2(bufsize, DEV_BSIZE))) == NULL)
 			err(1, "can't malloc buffer of %d",
 			bufsize);
 		memset(buf, 0, bufsize);



CVS commit: src/sbin/newfs

2023-07-04 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Jul  4 20:40:34 UTC 2023

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
newfs(8): Ensure A divides S before aligned_alloc(A, S).

Required by C11 Sec. 7.22.3.1 The aligned_alloc function, para. 2,
p. 348:

   The value of alignment shall be a valid alignment supported by the
   implementation and the value of size shall be an integral multiple
   of alignment.

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.118 -r1.119 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2020-04-17 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 17 09:33:37 UTC 2020

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
align buffers used for I/O to DEV_BSIZE so it's executed more optimally
when run for xbd(4) device


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.115 -r1.116 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2020-04-17 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Fri Apr 17 09:33:37 UTC 2020

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
align buffers used for I/O to DEV_BSIZE so it's executed more optimally
when run for xbd(4) device


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.115 -r1.116 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.128 src/sbin/newfs/mkfs.c:1.129
--- src/sbin/newfs/mkfs.c:1.128	Wed Feb  8 16:11:40 2017
+++ src/sbin/newfs/mkfs.c	Fri Apr 17 09:33:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.128 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.129 2020/04/17 09:33:37 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.128 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.129 2020/04/17 09:33:37 jdolecek Exp $");
 #endif
 #endif /* not lint */
 
@@ -200,10 +200,12 @@ mkfs(const char *fsys, int fi, int fo,
 			exit(12);
 	}
 #endif
-	if ((fsun = calloc(1, sizeof(*fsun))) == NULL)
+	if ((fsun = aligned_alloc(DEV_BSIZE, sizeof(*fsun))) == NULL)
 		exit(12);
-	if ((cgun = calloc(1, sizeof(*cgun))) == NULL)
+	memset(fsun, 0, sizeof(*fsun));
+	if ((cgun = aligned_alloc(DEV_BSIZE, sizeof(*cgun))) == NULL)
 		exit(12);
+	memset(cgun, 0, sizeof(*cgun));
 
 	fsi = fi;
 	fso = fo;
@@ -633,7 +635,7 @@ mkfs(const char *fsys, int fi, int fo,
 
 #ifndef NO_APPLE_UFS
 		if (isappleufs) {
-			struct appleufslabel appleufs;
+			struct appleufslabel appleufs __aligned(DEV_BSIZE);
 			ffs_appleufs_set(, appleufs_volname,
 			tv.tv_sec, 0);
 			wtfs(APPLEUFS_LABEL_OFFSET/sectorsize,
@@ -1034,7 +1036,7 @@ int
 fsinit(const struct timeval *tv, mode_t mfsmode, uid_t mfsuid, gid_t mfsgid)
 {
 	union dinode node;
-	union Buffer buf;
+	union Buffer buf __aligned(DEV_BSIZE);
 	int i;
 	int qblocks = 0;
 	int qinos = 0;
@@ -1584,7 +1586,7 @@ static void
 zap_old_sblock(int sblkoff)
 {
 	static int cg0_data;
-	uint32_t oldfs[SBLOCKSIZE / 4];
+	uint32_t oldfs[SBLOCKSIZE / 4] __aligned(DEV_BSIZE);
 	static const struct fsm {
 		uint32_t	offset;
 		uint32_t	magic;

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.115 src/sbin/newfs/newfs.c:1.116
--- src/sbin/newfs/newfs.c:1.115	Wed Feb  8 16:11:40 2017
+++ src/sbin/newfs/newfs.c	Fri Apr 17 09:33:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.115 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: newfs.c,v 1.116 2020/04/17 09:33:37 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)newfs.c	8.13 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: newfs.c,v 1.115 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: newfs.c,v 1.116 2020/04/17 09:33:37 jdolecek Exp $");
 #endif
 #endif /* not lint */
 
@@ -619,9 +619,10 @@ main(int argc, char *argv[])
 		} else
 			bufsize = sfs.f_iosize;
 
-		if ((buf = calloc(1, bufsize)) == NULL)
+		if ((buf = aligned_alloc(DEV_BSIZE, bufsize)) == NULL)
 			err(1, "can't malloc buffer of %d",
 			bufsize);
+		memset(buf, 0, bufsize);
 		bufrem = fssize * sectorsize;
 		if (verbosity > 0)
 			printf( "Creating file system image in `%s', "



CVS commit: src/sbin/newfs

2017-02-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Feb  8 16:56:56 UTC 2017

Modified Files:
src/sbin/newfs: extern.h

Log Message:
switch to __empty


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sbin/newfs/extern.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2017-02-08 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Feb  8 16:56:56 UTC 2017

Modified Files:
src/sbin/newfs: extern.h

Log Message:
switch to __empty


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sbin/newfs/extern.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/extern.h
diff -u src/sbin/newfs/extern.h:1.16 src/sbin/newfs/extern.h:1.17
--- src/sbin/newfs/extern.h:1.16	Wed Feb  8 16:11:40 2017
+++ src/sbin/newfs/extern.h	Wed Feb  8 16:56:56 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.16 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: extern.h,v 1.17 2017/02/08 16:56:56 rin Exp $	*/
 
 /*
  * Copyright (c) 1997 Christos Zoulas.  All rights reserved.
@@ -59,10 +59,10 @@ extern int	needswap;	/* Filesystem not i
 #else
 /* Disable Endian-Independent FFS support for install media */
 #define		needswap		(0)
-#define		ffs_cg_swap(a, b, c)	do {} while (/*CONSTCOND*/0)
-#define		ffs_csum_swap(a, b, c)	do {} while (/*CONSTCOND*/0)
-#define		ffs_dinode1_swap(a, b)	do {} while (/*CONSTCOND*/0)
-#define		ffs_sb_swap(a, b)	do {} while (/*CONSTCOND*/0)
+#define		ffs_cg_swap(a, b, c)	__empty
+#define		ffs_csum_swap(a, b, c)	__empty
+#define		ffs_dinode1_swap(a, b)	__empty
+#define		ffs_sb_swap(a, b)	__empty
 #endif
 
 #ifndef NO_APPLE_UFS



Re: CVS commit: src/sbin/newfs

2016-09-13 Thread Robert Elz
Date:Tue, 13 Sep 2016 00:50:30 +0100
From:Sevan Janiyan 
Message-ID:  <2d30ad57-2341-3b08-1d78-32b468cd5...@netbsd.org>

  | I can't seem to find the 4.3BSD-Reno release notes at the moment, but
  | the convention is interim releases do not count.
  | There are examples of that where 4.2BSD is being referenced in inherited
  | man pages when in-fact the tools actually showed up in 4.1{a,b,c}.

I think it is reasonable to ignore 4.1a (etc) for this kind of purpose,
but as I recall, 4.3 Reno & Tahoe were really full releases

kre



Re: CVS commit: src/sbin/newfs

2016-09-12 Thread Sevan Janiyan
On 13/09/2016 00:09, matthew green wrote:
> that never stopped them being referenced before.  infact, the macros
> appear know what they mean because it transforms:
> 
>.Bx 4.3 tahoe .
> 
> into:
> 
>The shells file format appeared in 4.3BSD-Tahoe.
> 
> ie, it capitalises and adds the dash.  i think it matter because there
> was a very long time between each of 4.3, reno, tahoe, 4.4 (closed)
> and 4.4-lite (and lite2).

For memfs support, it was actually covered in the 4.4BSD Release notes.
https://groups.google.com/d/msg/comp.unix.bsd/hZYO7xTDqQ8/NE-S-HWH9-wJ

"We  have also added amemory-based filesystem that runs in pageable
memory, allowing  large temporary filesystems without requiring
dedicated physical memory."

I can't seem to find the 4.3BSD-Reno release notes at the moment, but
the convention is interim releases do not count.
There are examples of that where 4.2BSD is being referenced in inherited
man pages when in-fact the tools actually showed up in 4.1{a,b,c}.



Sevan


re: CVS commit: src/sbin/newfs

2016-09-12 Thread matthew green
Sevan Janiyan writes:
> On 12/09/2016 22:02, matthew green wrote:
> > wouldn't "09/06/89" put it in 4.3RENO ?  from bsd-family-tree:
> > 
> > 4.3BSD Reno 1990-06-29 [QCU], [DOC]
> > 
> > 
> > .mrg.
> 
> Reno & Tahoe along with 4.1{a,b,c} were interim/beta releases.

that never stopped them being referenced before.  infact, the macros
appear know what they mean because it transforms:

   .Bx 4.3 tahoe .

into:

   The shells file format appeared in 4.3BSD-Tahoe.

ie, it capitalises and adds the dash.  i think it matter because there
was a very long time between each of 4.3, reno, tahoe, 4.4 (closed)
and 4.4-lite (and lite2).


.mrg.


re: CVS commit: src/sbin/newfs

2016-09-12 Thread matthew green
> Log Message:
> Memory File System support appeared in 4.4BSD, implemented as an extension to
> newfs(8). So while newfs may have appeared in 4.2BSD, MFS support was later.
> https://svnweb.freebsd.org/csrg/sbin/newfs/Makefile?r1=39047=39051
> Adjust HISTORY.
> Bump date.

wouldn't "09/06/89" put it in 4.3RENO ?  from bsd-family-tree:

4.3BSD Reno 1990-06-29 [QCU], [DOC]


.mrg.


CVS commit: src/sbin/newfs

2016-09-11 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Sep 12 04:50:48 UTC 2016

Modified Files:
src/sbin/newfs: mount_mfs.8

Log Message:
Memory File System support appeared in 4.4BSD, implemented as an extension to
newfs(8). So while newfs may have appeared in 4.2BSD, MFS support was later.
https://svnweb.freebsd.org/csrg/sbin/newfs/Makefile?r1=39047=39051
Adjust HISTORY.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sbin/newfs/mount_mfs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mount_mfs.8
diff -u src/sbin/newfs/mount_mfs.8:1.16 src/sbin/newfs/mount_mfs.8:1.17
--- src/sbin/newfs/mount_mfs.8:1.16	Thu Feb 18 14:00:39 2010
+++ src/sbin/newfs/mount_mfs.8	Mon Sep 12 04:50:48 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mount_mfs.8,v 1.16 2010/02/18 14:00:39 wiz Exp $
+.\"	$NetBSD: mount_mfs.8,v 1.17 2016/09/12 04:50:48 sevan Exp $
 .\"
 .\" Copyright (c) 1983, 1987, 1991, 1993, 1994
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)newfs.8	8.6 (Berkeley) 5/3/95
 .\"
-.Dd December 8, 2007
+.Dd September 12, 2016
 .Dt MOUNT_MFS 8
 .Os
 .Sh NAME
@@ -269,7 +269,7 @@ Mount a 32 MB mfs on /tmp:
 The
 .Nm
 command appeared in
-.Bx 4.2 .
+.Bx 4.4 .
 .Sh BUGS
 The
 .Cm async



CVS commit: src/sbin/newfs

2016-09-11 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Mon Sep 12 04:50:48 UTC 2016

Modified Files:
src/sbin/newfs: mount_mfs.8

Log Message:
Memory File System support appeared in 4.4BSD, implemented as an extension to
newfs(8). So while newfs may have appeared in 4.2BSD, MFS support was later.
https://svnweb.freebsd.org/csrg/sbin/newfs/Makefile?r1=39047=39051
Adjust HISTORY.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sbin/newfs/mount_mfs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2016-03-31 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Apr  1 05:23:56 UTC 2016

Modified Files:
src/sbin/newfs: newfs.c

Log Message:
no need to escape


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.113 src/sbin/newfs/newfs.c:1.114
--- src/sbin/newfs/newfs.c:1.113	Sat Jul 25 10:37:22 2015
+++ src/sbin/newfs/newfs.c	Fri Apr  1 05:23:56 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.113 2015/07/25 10:37:22 mlelstv Exp $	*/
+/*	$NetBSD: newfs.c,v 1.114 2016/04/01 05:23:56 ryo Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = "@(#)newfs.c	8.13 (Berkeley) 5/1/95";
 #else
-__RCSID("$NetBSD: newfs.c,v 1.113 2015/07/25 10:37:22 mlelstv Exp $");
+__RCSID("$NetBSD: newfs.c,v 1.114 2016/04/01 05:23:56 ryo Exp $");
 #endif
 #endif /* not lint */
 
@@ -866,7 +866,7 @@ struct help_strings {
 	{ MFS_MOUNT,	"-g groupname\tgroup name of mount point" },
 	{ BOTH,		"-h avgfpdir\taverage files per directory" },
 	{ BOTH,		"-i density\tnumber of bytes per inode" },
-	{ BOTH,		"-m minfree\tminimum free space %%" },
+	{ BOTH,		"-m minfree\tminimum free space %" },
 	{ BOTH,		"-n inodes\tnumber of inodes (overrides -i density)" },
 	{ BOTH,		"-o optim\toptimization preference (`space' or `time')"
 			},



CVS commit: src/sbin/newfs

2016-03-31 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Apr  1 05:23:56 UTC 2016

Modified Files:
src/sbin/newfs: newfs.c

Log Message:
no need to escape


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2016-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  7 15:55:06 UTC 2016

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
PR/50910: David Binderman: Optimize memset.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2016-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  7 15:55:06 UTC 2016

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
PR/50910: David Binderman: Optimize memset.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.126 src/sbin/newfs/mkfs.c:1.127
--- src/sbin/newfs/mkfs.c:1.126	Mon Mar  7 10:09:55 2016
+++ src/sbin/newfs/mkfs.c	Mon Mar  7 10:55:06 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.126 2016/03/07 15:09:55 dholland Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.127 2016/03/07 15:55:06 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.126 2016/03/07 15:09:55 dholland Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.127 2016/03/07 15:55:06 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -735,8 +735,10 @@ mkfs(const char *fsys, int fi, int fo,
 	 * Write out the super-block and zeros until the first cg info
 	 */
 	i = cgsblock(, 0) * sblock.fs_fsize - sblock.fs_sblockloc;
-	memset(iobuf, 0, i);
-	memcpy(iobuf, , sizeof sblock);
+	if ((size_t)i < sizeof(sblock))
+		errx(1, "No space for superblock");
+	memcpy(iobuf, , sizeof(sblock));
+	memset(iobuf + sizeof(sblock), 0, i - sizeof(sblock));
 	if (needswap)
 		ffs_sb_swap(, (struct fs *)iobuf);
 	if ((sblock.fs_old_flags & FS_FLAGS_UPDATED) == 0)



CVS commit: src/sbin/newfs

2016-03-07 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Mar  7 15:09:55 UTC 2016

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Terminate expression with a semicolon, instead of accidentally
splicing to the next line with a comma. Noticed by Christos. Has no
actual effect, fortunately. (Compiler output is unchanged.)


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.125 src/sbin/newfs/mkfs.c:1.126
--- src/sbin/newfs/mkfs.c:1.125	Tue Jun 16 23:18:55 2015
+++ src/sbin/newfs/mkfs.c	Mon Mar  7 15:09:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.125 2015/06/16 23:18:55 christos Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.126 2016/03/07 15:09:55 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
-__RCSID("$NetBSD: mkfs.c,v 1.125 2015/06/16 23:18:55 christos Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.126 2016/03/07 15:09:55 dholland Exp $");
 #endif
 #endif /* not lint */
 
@@ -734,7 +734,7 @@ mkfs(const char *fsys, int fi, int fo,
 	/*
 	 * Write out the super-block and zeros until the first cg info
 	 */
-	i = cgsblock(, 0) * sblock.fs_fsize - sblock.fs_sblockloc,
+	i = cgsblock(, 0) * sblock.fs_fsize - sblock.fs_sblockloc;
 	memset(iobuf, 0, i);
 	memcpy(iobuf, , sizeof sblock);
 	if (needswap)



CVS commit: src/sbin/newfs

2016-03-07 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Mar  7 15:09:55 UTC 2016

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Terminate expression with a semicolon, instead of accidentally
splicing to the next line with a comma. Noticed by Christos. Has no
actual effect, fortunately. (Compiler output is unchanged.)


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2015-04-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 29 01:49:25 UTC 2015

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
- use calloc to zero memory
- pass the proper buffer to mkdir
- fix for apple ufs


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.123 src/sbin/newfs/mkfs.c:1.124
--- src/sbin/newfs/mkfs.c:1.123	Tue Apr 28 11:15:53 2015
+++ src/sbin/newfs/mkfs.c	Tue Apr 28 21:49:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.123 2015/04/28 15:15:53 christos Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.124 2015/04/29 01:49:25 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = @(#)mkfs.c	8.11 (Berkeley) 5/3/95;
 #else
-__RCSID($NetBSD: mkfs.c,v 1.123 2015/04/28 15:15:53 christos Exp $);
+__RCSID($NetBSD: mkfs.c,v 1.124 2015/04/29 01:49:25 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -110,7 +110,8 @@ union dinode {
 
 static void initcg(int, const struct timeval *);
 static int fsinit(const struct timeval *, mode_t, uid_t, gid_t);
-static int makedir(struct direct *, int);
+union Buffer;
+static int makedir(union Buffer *, struct direct *, int);
 static daddr_t alloc(int, int);
 static void iput(union dinode *, ino_t);
 static void rdfs(daddr_t, int, void *);
@@ -199,9 +200,9 @@ mkfs(const char *fsys, int fi, int fo,
 			exit(12);
 	}
 #endif
-	if ((fsun = mkfs_malloc(sizeof(*fsun))) == NULL)
+	if ((fsun = calloc(1, sizeof(*fsun))) == NULL)
 		exit(12);
-	if ((cgun = mkfs_malloc(sizeof(*cgun))) == NULL)
+	if ((cgun = calloc(1, sizeof(*cgun))) == NULL)
 		exit(12);
 
 	fsi = fi;
@@ -1054,12 +1055,12 @@ fsinit(const struct timeval *tv, mode_t 
 	 */
 	memset(node, 0, sizeof(node));
 	if (Oflag == 0) {
-		(void)makedir((struct direct *)olost_found_dir, 2);
+		(void)makedir(buf, (struct direct *)olost_found_dir, 2);
 		for (i = dirblksiz; i  sblock.fs_bsize; i += dirblksiz)
 			copy_dir((struct direct*)olost_found_dir[2],
 (struct direct*)buf[i]);
 	} else {
-		(void)makedir(lost_found_dir, 2);
+		(void)makedir(buf, lost_found_dir, 2);
 		for (i = dirblksiz; i  sblock.fs_bsize; i += dirblksiz)
 			copy_dir(lost_found_dir[2], (struct direct*)buf[i]);
 	}
@@ -1125,10 +1126,10 @@ fsinit(const struct timeval *tv, mode_t 
 		}
 		node.dp1.di_nlink = PREDEFDIR;
 		if (Oflag == 0)
-			node.dp1.di_size = makedir((struct direct *)oroot_dir,
-			PREDEFDIR);
+			node.dp1.di_size = makedir(buf, 
+			(struct direct *)oroot_dir, PREDEFDIR);
 		else
-			node.dp1.di_size = makedir(root_dir, PREDEFDIR);
+			node.dp1.di_size = makedir(buf, root_dir, PREDEFDIR);
 		node.dp1.di_db[0] = alloc(sblock.fs_fsize, node.dp1.di_mode);
 		if (node.dp1.di_db[0] == 0)
 			return (0);
@@ -1155,7 +1156,7 @@ fsinit(const struct timeval *tv, mode_t 
 		node.dp2.di_birthtime = tv-tv_sec;
 		node.dp2.di_birthnsec = tv-tv_usec * 1000;
 		node.dp2.di_nlink = PREDEFDIR;
-		node.dp2.di_size = makedir(root_dir, PREDEFDIR);
+		node.dp2.di_size = makedir(buf, root_dir, PREDEFDIR);
 		node.dp2.di_db[0] = alloc(sblock.fs_fsize, node.dp2.di_mode);
 		if (node.dp2.di_db[0] == 0)
 			return (0);
@@ -1260,18 +1261,17 @@ fsinit(const struct timeval *tv, mode_t 
  * return size of directory.
  */
 int
-makedir(struct direct *protodir, int entries)
+makedir(union Buffer *buf, struct direct *protodir, int entries)
 {
 	char *cp;
-	union Buffer buf;
 	int i, spcleft;
 	int dirblksiz = UFS_DIRBLKSIZ;
 	if (isappleufs)
 		dirblksiz = APPLEUFS_DIRBLKSIZ;
 
-	memset(buf, 0, UFS_DIRBLKSIZ);
+	memset(buf, 0, dirblksiz);
 	spcleft = dirblksiz;
-	for (cp = buf.data, i = 0; i  entries - 1; i++) {
+	for (cp = buf-data, i = 0; i  entries - 1; i++) {
 		protodir[i].d_reclen = UFS_DIRSIZ(Oflag == 0, protodir[i], 0);
 		copy_dir(protodir[i], (struct direct*)cp);
 		cp += protodir[i].d_reclen;



CVS commit: src/sbin/newfs

2015-04-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 29 01:49:25 UTC 2015

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
- use calloc to zero memory
- pass the proper buffer to mkdir
- fix for apple ufs


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2015-04-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 28 15:15:54 UTC 2015

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
reduce bss usage


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.122 src/sbin/newfs/mkfs.c:1.123
--- src/sbin/newfs/mkfs.c:1.122	Sat Apr 26 10:15:08 2014
+++ src/sbin/newfs/mkfs.c	Tue Apr 28 11:15:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.122 2014/04/26 14:15:08 martin Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.123 2015/04/28 15:15:53 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = @(#)mkfs.c	8.11 (Berkeley) 5/3/95;
 #else
-__RCSID($NetBSD: mkfs.c,v 1.122 2014/04/26 14:15:08 martin Exp $);
+__RCSID($NetBSD: mkfs.c,v 1.123 2015/04/28 15:15:53 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -132,13 +132,13 @@ static void *mkfs_malloc(size_t size);
 union {
 	struct fs fs;
 	char data[SBLOCKSIZE];
-} fsun;
-#define	sblock	fsun.fs
+} *fsun;
+#define	sblock	fsun-fs
 
-union {
+union Buffer {
 	struct quota2_header q2h;
 	char data[MAXBSIZE];
-} buf;
+};
 
 struct	csum *fscs_0;		/* first block of cylinder summaries */
 struct	csum *fscs_next;	/* place for next summary */
@@ -149,8 +149,8 @@ uint	fs_csaddr;		/* fragment number to w
 union {
 	struct cg cg;
 	char pad[MAXBSIZE];
-} cgun;
-#define	acg	cgun.cg
+} *cgun;
+#define	acg	cgun-cg
 
 #define DIP(dp, field) \
 	((sblock.fs_magic == FS_UFS1_MAGIC) ? \
@@ -199,6 +199,11 @@ mkfs(const char *fsys, int fi, int fo,
 			exit(12);
 	}
 #endif
+	if ((fsun = mkfs_malloc(sizeof(*fsun))) == NULL)
+		exit(12);
+	if ((cgun = mkfs_malloc(sizeof(*cgun))) == NULL)
+		exit(12);
+
 	fsi = fi;
 	fso = fo;
 	if (Oflag == 0) {
@@ -1024,6 +1029,7 @@ int
 fsinit(const struct timeval *tv, mode_t mfsmode, uid_t mfsuid, gid_t mfsgid)
 {
 	union dinode node;
+	union Buffer buf;
 	int i;
 	int qblocks = 0;
 	int qinos = 0;
@@ -1257,6 +1263,7 @@ int
 makedir(struct direct *protodir, int entries)
 {
 	char *cp;
+	union Buffer buf;
 	int i, spcleft;
 	int dirblksiz = UFS_DIRBLKSIZ;
 	if (isappleufs)



CVS commit: src/sbin/newfs

2015-04-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr 28 15:15:54 UTC 2015

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
reduce bss usage


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2014-10-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct 25 16:47:24 UTC 2014

Modified Files:
src/sbin/newfs: newfs.c

Log Message:
Support wedge names.

before:
newfs dk1- formats /dev/rdk1
newfs rdk1   - cannot open /dev/rrdk1
newfs /dev/dk1   - /dev/dk1 is a block-device, use raw device
newfs /dev/rdk1  - formats /dev/rdk1

now:
newfs dk1- formats /dev/rdk1
newfs rdk1   - cannot open /dev/rrdk1
newfs /dev/dk1   - formats /dev/rdk1 (*)
newfs /dev/rdk1  - formats /dev/rdk1
newfs NAME=wedge - formats /dev/rdk1

(*) getfsspecname() returns the block device which must be translated.
Passing a block device manually cannot be distinguished from this case.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.111 src/sbin/newfs/newfs.c:1.112
--- src/sbin/newfs/newfs.c:1.111	Sat Jun 30 15:34:01 2012
+++ src/sbin/newfs/newfs.c	Sat Oct 25 16:47:23 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.111 2012/06/30 15:34:01 tsutsui Exp $	*/
+/*	$NetBSD: newfs.c,v 1.112 2014/10/25 16:47:23 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)newfs.c	8.13 (Berkeley) 5/1/95;
 #else
-__RCSID($NetBSD: newfs.c,v 1.111 2012/06/30 15:34:01 tsutsui Exp $);
+__RCSID($NetBSD: newfs.c,v 1.112 2014/10/25 16:47:23 mlelstv Exp $);
 #endif
 #endif /* not lint */
 
@@ -242,7 +242,10 @@ main(int argc, char *argv[])
 	struct statvfs *mp;
 	struct stat sb;
 	int ch, fsi, fso, len, n, Fflag, Iflag, Zflag;
-	char *s1, *s2, *special;
+	const char *s1, *special, *raw;
+	char *s2;
+	char specname[MAXPATHLEN];
+	char rawname[MAXPATHLEN];
 	const char *opstring;
 	int byte_sized = 0;
 #ifdef MFS
@@ -490,6 +493,11 @@ main(int argc, char *argv[])
 fso = fsi;
 		}
 	} else {	/* !Fflag  !mfs */
+		special = getfsspecname(specname, sizeof(specname), special);
+		raw = getdiskrawname(rawname, sizeof(rawname), special);
+		if (raw != NULL)
+			special = raw;
+
 		fsi = opendisk(special, O_RDONLY, device, sizeof(device), 0);
 		special = device;
 		if (fsi  0 || fstat(fsi, sb) == -1)



CVS commit: src/sbin/newfs

2014-10-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Oct 25 16:47:24 UTC 2014

Modified Files:
src/sbin/newfs: newfs.c

Log Message:
Support wedge names.

before:
newfs dk1- formats /dev/rdk1
newfs rdk1   - cannot open /dev/rrdk1
newfs /dev/dk1   - /dev/dk1 is a block-device, use raw device
newfs /dev/rdk1  - formats /dev/rdk1

now:
newfs dk1- formats /dev/rdk1
newfs rdk1   - cannot open /dev/rrdk1
newfs /dev/dk1   - formats /dev/rdk1 (*)
newfs /dev/rdk1  - formats /dev/rdk1
newfs NAME=wedge - formats /dev/rdk1

(*) getfsspecname() returns the block device which must be translated.
Passing a block device manually cannot be distinguished from this case.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2014-04-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Apr 26 14:15:08 UTC 2014

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Increase alignement of the global buf variable to cover all pointers it
is casted too. Fixes a crash on arm v5.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.121 src/sbin/newfs/mkfs.c:1.122
--- src/sbin/newfs/mkfs.c:1.121	Sat Apr  5 12:32:27 2014
+++ src/sbin/newfs/mkfs.c	Sat Apr 26 14:15:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.121 2014/04/05 12:32:27 justin Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.122 2014/04/26 14:15:08 martin Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = @(#)mkfs.c	8.11 (Berkeley) 5/3/95;
 #else
-__RCSID($NetBSD: mkfs.c,v 1.121 2014/04/05 12:32:27 justin Exp $);
+__RCSID($NetBSD: mkfs.c,v 1.122 2014/04/26 14:15:08 martin Exp $);
 #endif
 #endif /* not lint */
 
@@ -131,10 +131,15 @@ static void *mkfs_malloc(size_t size);
 
 union {
 	struct fs fs;
-	char pad[SBLOCKSIZE];
+	char data[SBLOCKSIZE];
 } fsun;
 #define	sblock	fsun.fs
 
+union {
+	struct quota2_header q2h;
+	char data[MAXBSIZE];
+} buf;
+
 struct	csum *fscs_0;		/* first block of cylinder summaries */
 struct	csum *fscs_next;	/* place for next summary */
 struct	csum *fscs_end;		/* end of summary buffer */
@@ -1012,7 +1017,7 @@ struct odirect olost_found_dir[] = {
 	{ 0, DIRBLKSIZ, 0, 0 },
 };
 #endif
-char buf[MAXBSIZE];
+
 static void copy_dir(struct direct *, struct direct *);
 
 int
@@ -1124,7 +1129,7 @@ fsinit(const struct timeval *tv, mode_t 
 		node.dp1.di_blocks = btodb(ffs_fragroundup(sblock,
 		node.dp1.di_size));
 		qblocks += node.dp1.di_blocks;
-		wtfs(FFS_FSBTODB(sblock, node.dp1.di_db[0]), sblock.fs_fsize, buf);
+		wtfs(FFS_FSBTODB(sblock, node.dp1.di_db[0]), sblock.fs_fsize, buf);
 	} else {
 		if (mfs) {
 			node.dp2.di_mode = IFDIR | mfsmode;
@@ -1151,7 +1156,7 @@ fsinit(const struct timeval *tv, mode_t 
 		node.dp2.di_blocks = btodb(ffs_fragroundup(sblock,
 		node.dp2.di_size));
 		qblocks += node.dp2.di_blocks;
-		wtfs(FFS_FSBTODB(sblock, node.dp2.di_db[0]), sblock.fs_fsize, buf);
+		wtfs(FFS_FSBTODB(sblock, node.dp2.di_db[0]), sblock.fs_fsize, buf);
 	}
 	qinos++;
 	iput(node, UFS_ROOTINO);
@@ -1177,12 +1182,12 @@ fsinit(const struct timeval *tv, mode_t 
 
 		if ((quotas  FS_Q2_DO_TYPE(i)) == 0)
 			continue;
-		quota2_create_blk0(sblock.fs_bsize, buf, q2h_hash_shift,
+		quota2_create_blk0(sblock.fs_bsize, buf, q2h_hash_shift,
 		i, needswap);
 		/* grab an entry from header for root dir */
-		q2h = (void *)buf;
+		q2h = buf.q2h;
 		offset = ufs_rw64(q2h-q2h_free, needswap);
-		q2e = (void *)((char *)buf + offset);
+		q2e = (void *)((char *)buf + offset);
 		q2h-q2h_free = q2e-q2e_next;
 		memcpy(q2e, q2h-q2h_defentry, sizeof(*q2e));
 		q2e-q2e_uid = ufs_rw32(uid, needswap);
@@ -1213,7 +1218,7 @@ fsinit(const struct timeval *tv, mode_t 
 			node.dp1.di_uid = geteuid();
 			node.dp1.di_gid = getegid();
 			wtfs(FFS_FSBTODB(sblock, node.dp1.di_db[0]),
-			 node.dp1.di_size, buf);
+			 node.dp1.di_size, buf);
 		} else {
 			node.dp2.di_atime = tv-tv_sec;
 			node.dp2.di_atimensec = tv-tv_usec * 1000;
@@ -1235,7 +1240,7 @@ fsinit(const struct timeval *tv, mode_t 
 			node.dp2.di_uid = geteuid();
 			node.dp2.di_gid = getegid();
 			wtfs(FFS_FSBTODB(sblock, node.dp2.di_db[0]),
-			node.dp2.di_size, buf);
+			node.dp2.di_size, buf);
 		}
 		iput(node, nextino);
 		sblock.fs_quotafile[i] = nextino;
@@ -1257,9 +1262,9 @@ makedir(struct direct *protodir, int ent
 	if (isappleufs)
 		dirblksiz = APPLEUFS_DIRBLKSIZ;
 
-	memset(buf, 0, UFS_DIRBLKSIZ);
+	memset(buf, 0, UFS_DIRBLKSIZ);
 	spcleft = dirblksiz;
-	for (cp = buf, i = 0; i  entries - 1; i++) {
+	for (cp = buf.data, i = 0; i  entries - 1; i++) {
 		protodir[i].d_reclen = UFS_DIRSIZ(Oflag == 0, protodir[i], 0);
 		copy_dir(protodir[i], (struct direct*)cp);
 		cp += protodir[i].d_reclen;



CVS commit: src/sbin/newfs

2014-04-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Apr 26 14:15:08 UTC 2014

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Increase alignement of the global buf variable to cover all pointers it
is casted too. Fixes a crash on arm v5.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2013-06-22 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jun 23 04:14:28 UTC 2013

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Revert accidental commit of the change for PR 47911; got rolled into
other stuff by mistake.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.117 src/sbin/newfs/mkfs.c:1.118
--- src/sbin/newfs/mkfs.c:1.117	Sun Jun 23 02:06:05 2013
+++ src/sbin/newfs/mkfs.c	Sun Jun 23 04:14:28 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.117 2013/06/23 02:06:05 dholland Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.118 2013/06/23 04:14:28 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = @(#)mkfs.c	8.11 (Berkeley) 5/3/95;
 #else
-__RCSID($NetBSD: mkfs.c,v 1.117 2013/06/23 02:06:05 dholland Exp $);
+__RCSID($NetBSD: mkfs.c,v 1.118 2013/06/23 04:14:28 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -1257,7 +1257,7 @@ makedir(struct direct *protodir, int ent
 	if (isappleufs)
 		dirblksiz = APPLEUFS_DIRBLKSIZ;
 
-	memset(buf, 0, dirblksiz);
+	memset(buf, 0, UFS_DIRBLKSIZ);
 	spcleft = dirblksiz;
 	for (cp = buf, i = 0; i  entries - 1; i++) {
 		protodir[i].d_reclen = UFS_DIRSIZ(Oflag == 0, protodir[i], 0);



CVS commit: src/sbin/newfs

2013-06-22 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jun 23 04:14:28 UTC 2013

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Revert accidental commit of the change for PR 47911; got rolled into
other stuff by mistake.


To generate a diff of this commit:
cvs rdiff -u -r1.117 -r1.118 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2013-06-09 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jun  9 18:29:41 UTC 2013

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Stick UFS_ in front of these symbols:
   DIRBLKSIZ
   DIRECTSIZ
   DIRSIZ
   OLDDIRFMT
   NEWDIRFMT

Part of PR 47909.

(two stragglers in this commit; oops)


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.114 src/sbin/newfs/mkfs.c:1.115
--- src/sbin/newfs/mkfs.c:1.114	Sun Mar 17 12:25:36 2013
+++ src/sbin/newfs/mkfs.c	Sun Jun  9 18:29:41 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.114 2013/03/17 12:25:36 mlelstv Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.115 2013/06/09 18:29:41 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = @(#)mkfs.c	8.11 (Berkeley) 5/3/95;
 #else
-__RCSID($NetBSD: mkfs.c,v 1.114 2013/03/17 12:25:36 mlelstv Exp $);
+__RCSID($NetBSD: mkfs.c,v 1.115 2013/06/09 18:29:41 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -1253,14 +1253,14 @@ makedir(struct direct *protodir, int ent
 {
 	char *cp;
 	int i, spcleft;
-	int dirblksiz = DIRBLKSIZ;
+	int dirblksiz = UFS_DIRBLKSIZ;
 	if (isappleufs)
 		dirblksiz = APPLEUFS_DIRBLKSIZ;
 
-	memset(buf, 0, DIRBLKSIZ);
+	memset(buf, 0, UFS_DIRBLKSIZ);
 	spcleft = dirblksiz;
 	for (cp = buf, i = 0; i  entries - 1; i++) {
-		protodir[i].d_reclen = DIRSIZ(Oflag == 0, protodir[i], 0);
+		protodir[i].d_reclen = UFS_DIRSIZ(Oflag == 0, protodir[i], 0);
 		copy_dir(protodir[i], (struct direct*)cp);
 		cp += protodir[i].d_reclen;
 		spcleft -= protodir[i].d_reclen;
@@ -1539,7 +1539,7 @@ setblock(struct fs *fs, unsigned char *c
 static void
 copy_dir(struct direct *dir, struct direct *dbuf)
 {
-	memcpy(dbuf, dir, DIRSIZ(Oflag == 0, dir, 0));
+	memcpy(dbuf, dir, UFS_DIRSIZ(Oflag == 0, dir, 0));
 	if (needswap) {
 		dbuf-d_ino = bswap32(dir-d_ino);
 		dbuf-d_reclen = bswap16(dir-d_reclen);



CVS commit: src/sbin/newfs

2013-06-09 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Jun  9 18:29:41 UTC 2013

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Stick UFS_ in front of these symbols:
   DIRBLKSIZ
   DIRECTSIZ
   DIRSIZ
   OLDDIRFMT
   NEWDIRFMT

Part of PR 47909.

(two stragglers in this commit; oops)


To generate a diff of this commit:
cvs rdiff -u -r1.114 -r1.115 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2013-03-17 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Mar 17 12:25:36 UTC 2013

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
For MFS, no longer use heuristic based on rlimit to determine mmap size.
This is no longer functional with current memory allocation routines.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.113 src/sbin/newfs/mkfs.c:1.114
--- src/sbin/newfs/mkfs.c:1.113	Tue Jan 22 09:39:12 2013
+++ src/sbin/newfs/mkfs.c	Sun Mar 17 12:25:36 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.113 2013/01/22 09:39:12 dholland Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.114 2013/03/17 12:25:36 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = @(#)mkfs.c	8.11 (Berkeley) 5/3/95;
 #else
-__RCSID($NetBSD: mkfs.c,v 1.113 2013/01/22 09:39:12 dholland Exp $);
+__RCSID($NetBSD: mkfs.c,v 1.114 2013/03/17 12:25:36 mlelstv Exp $);
 #endif
 #endif /* not lint */
 
@@ -121,7 +121,6 @@ static void setblock(struct fs *, unsign
 static int ilog2(int);
 static void zap_old_sblock(int);
 #ifdef MFS
-static void calc_memfree(void);
 static void *mkfs_malloc(size_t size);
 #endif
 
@@ -191,9 +190,6 @@ mkfs(const char *fsys, int fi, int fo,
 #endif
 #ifdef MFS
 	if (mfs  !Nflag) {
-		calc_memfree();
-		if ((uint64_t)fssize * sectorsize  memleft)
-			fssize = memleft / sectorsize;
 		if ((membase = mkfs_malloc(fssize * sectorsize)) == NULL)
 			exit(12);
 	}
@@ -1625,33 +1621,6 @@ zap_old_sblock(int sblkoff)
 
 #ifdef MFS
 /*
- * XXX!
- * Attempt to guess how much more space is available for process data.  The
- * heuristic we use is
- *
- *	max_data_limit - (sbrk(0) - etext) - 128kB
- *
- * etext approximates that start address of the data segment, and the 128kB
- * allows some slop for both segment gap between text and data, and for other
- * (libc) malloc usage.
- */
-static void
-calc_memfree(void)
-{
-	extern char etext;
-	struct rlimit rlp;
-	u_long base;
-
-	base = (u_long)sbrk(0) - (u_long)etext;
-	if (getrlimit(RLIMIT_DATA, rlp)  0)
-		perror(getrlimit);
-	rlp.rlim_cur = rlp.rlim_max;
-	if (setrlimit(RLIMIT_DATA, rlp)  0)
-		perror(setrlimit);
-	memleft = rlp.rlim_max - base - (128 * 1024);
-}
-
-/*
  * Internal version of malloc that trims the requested size if not enough
  * memory is available.
  */
@@ -1659,20 +1628,36 @@ static void *
 mkfs_malloc(size_t size)
 {
 	u_long pgsz;
-	caddr_t *memory;
+	caddr_t *memory, *extra;
+	size_t exsize = 128 * 1024;
 
 	if (size == 0)
 		return (NULL);
-	if (memleft == 0)
-		calc_memfree();
 
 	pgsz = getpagesize() - 1;
 	size = (size + pgsz) ~ pgsz;
-	if (size  memleft)
-		size = memleft;
-	memleft -= size;
+
+	/* try to map requested size */
 	memory = mmap(0, size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE,
 	-1, 0);
-	return memory != MAP_FAILED ? memory : NULL;
+	if (memory == MAP_FAILED)
+		return NULL;
+
+	/* try to map something extra */
+	extra = mmap(0, exsize, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE,
+	-1, 0);
+	munmap(extra, exsize);
+
+	/* if extra memory couldn't be mapped, reduce original request accordingly */
+	if (extra == MAP_FAILED) {
+		munmap(memory, size);
+		size -= exsize;
+		memory = mmap(0, size, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE,
+		-1, 0);
+		if (memory == MAP_FAILED)
+			return NULL;
+	}
+
+	return memory;
 }
 #endif	/* MFS */



CVS commit: src/sbin/newfs

2012-02-13 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Feb 13 12:59:56 UTC 2012

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
Remove unused variables.
From cppcheck via Henning Petersen in PR 46004.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.109 -r1.110 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.111 src/sbin/newfs/mkfs.c:1.112
--- src/sbin/newfs/mkfs.c:1.111	Tue Feb  7 14:14:45 2012
+++ src/sbin/newfs/mkfs.c	Mon Feb 13 12:59:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.111 2012/02/07 14:14:45 tsutsui Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.112 2012/02/13 12:59:56 wiz Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = @(#)mkfs.c	8.11 (Berkeley) 5/3/95;
 #else
-__RCSID($NetBSD: mkfs.c,v 1.111 2012/02/07 14:14:45 tsutsui Exp $);
+__RCSID($NetBSD: mkfs.c,v 1.112 2012/02/13 12:59:56 wiz Exp $);
 #endif
 #endif /* not lint */
 
@@ -1343,11 +1343,10 @@ static void
 iput(union dinode *ip, ino_t ino)
 {
 	daddr_t d;
-	int c, i;
+	int i;
 	struct ufs1_dinode *dp1;
 	struct ufs2_dinode *dp2;
 
-	c = ino_to_cg(sblock, ino);
 	rdfs(fsbtodb(sblock, cgtod(sblock, 0)), sblock.fs_cgsize, acg);
 	/* fs - host byte order */
 	if (needswap)

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.109 src/sbin/newfs/newfs.c:1.110
--- src/sbin/newfs/newfs.c:1.109	Sun Mar  6 17:08:17 2011
+++ src/sbin/newfs/newfs.c	Mon Feb 13 12:59:56 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.109 2011/03/06 17:08:17 bouyer Exp $	*/
+/*	$NetBSD: newfs.c,v 1.110 2012/02/13 12:59:56 wiz Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@ __COPYRIGHT(@(#) Copyright (c) 1983, 19
 #if 0
 static char sccsid[] = @(#)newfs.c	8.13 (Berkeley) 5/1/95;
 #else
-__RCSID($NetBSD: newfs.c,v 1.109 2011/03/06 17:08:17 bouyer Exp $);
+__RCSID($NetBSD: newfs.c,v 1.110 2012/02/13 12:59:56 wiz Exp $);
 #endif
 #endif /* not lint */
 
@@ -239,7 +239,7 @@ main(int argc, char *argv[])
 	struct statvfs *mp;
 	struct stat sb;
 	int ch, fsi, fso, len, n, Fflag, Iflag, Zflag;
-	char *cp, *s1, *s2, *special;
+	char *s1, *s2, *special;
 	const char *opstring;
 	int byte_sized = 0;
 #ifdef MFS
@@ -255,7 +255,6 @@ main(int argc, char *argv[])
 	gid_t mfsgid = 0;	/* group wheel */
 	mntoptparse_t mo;
 
-	cp = NULL;
 	fsi = fso = -1;
 	Fflag = Iflag = Zflag = 0;
 	verbosity = -1;



CVS commit: src/sbin/newfs

2012-02-13 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Feb 13 12:59:56 UTC 2012

Modified Files:
src/sbin/newfs: mkfs.c newfs.c

Log Message:
Remove unused variables.
From cppcheck via Henning Petersen in PR 46004.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.109 -r1.110 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2012-02-07 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Feb  7 14:14:46 UTC 2012

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Explicitly zap possible Ext2fs magic leftover to prevent
kernel vfs_mountroot() and bootloaders from mis-recognizing
the newfs(8)'ed file system as still Ext2fs.

The problem is reported and the fix is tested by Frank Wille
on current-users@.  Also approved by releng.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.110 src/sbin/newfs/mkfs.c:1.111
--- src/sbin/newfs/mkfs.c:1.110	Thu Aug 25 16:17:58 2011
+++ src/sbin/newfs/mkfs.c	Tue Feb  7 14:14:45 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.110 2011/08/25 16:17:58 joerg Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.111 2012/02/07 14:14:45 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = @(#)mkfs.c	8.11 (Berkeley) 5/3/95;
 #else
-__RCSID($NetBSD: mkfs.c,v 1.110 2011/08/25 16:17:58 joerg Exp $);
+__RCSID($NetBSD: mkfs.c,v 1.111 2012/02/07 14:14:45 tsutsui Exp $);
 #endif
 #endif /* not lint */
 
@@ -152,6 +152,8 @@ union {
 	((sblock.fs_magic == FS_UFS1_MAGIC) ? \
 	(dp)-dp1.di_##field : (dp)-dp2.di_##field)
 
+#define EXT2FS_SBOFF	1024	/* XXX: SBOFF in ufs/ext2fs/ext2fs.h */
+
 char *iobuf;
 int iobufsize;			/* size to end of 2nd inode block */
 int iobuf_memsize;		/* Actual buffer size */
@@ -615,6 +617,12 @@ mkfs(const char *fsys, int fi, int fo,
 			for (sz = SBLOCKSIZE; sz = 0x1; sz = 1)
 zap_old_sblock(roundup(sblkoff, sz));
 		}
+		/*
+		 * Also zap possible Ext2fs magic leftover to prevent
+		 * kernel vfs_mountroot() and bootloaders from mis-recognizing
+		 * this file system as Ext2fs.
+		 */
+		zap_old_sblock(EXT2FS_SBOFF);
 
 		if (isappleufs) {
 			struct appleufslabel appleufs;



CVS commit: src/sbin/newfs

2012-02-07 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Feb  7 14:14:46 UTC 2012

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Explicitly zap possible Ext2fs magic leftover to prevent
kernel vfs_mountroot() and bootloaders from mis-recognizing
the newfs(8)'ed file system as still Ext2fs.

The problem is reported and the fix is tested by Frank Wille
on current-users@.  Also approved by releng.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2011-08-25 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Aug 25 16:17:58 UTC 2011

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Avoid magic manipulation of the format string.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.109 src/sbin/newfs/mkfs.c:1.110
--- src/sbin/newfs/mkfs.c:1.109	Sun Mar  6 17:08:16 2011
+++ src/sbin/newfs/mkfs.c	Thu Aug 25 16:17:58 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.109 2011/03/06 17:08:16 bouyer Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.110 2011/08/25 16:17:58 joerg Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = @(#)mkfs.c	8.11 (Berkeley) 5/3/95;
 #else
-__RCSID($NetBSD: mkfs.c,v 1.109 2011/03/06 17:08:16 bouyer Exp $);
+__RCSID($NetBSD: mkfs.c,v 1.110 2011/08/25 16:17:58 joerg Exp $);
 #endif
 #endif /* not lint */
 
@@ -677,7 +677,7 @@
 			continue;
 		}
 		/* Print superblock numbers */
-		len = printf( %* PRIu64 , + !col, fld_width,
+		len = printf(%s%* PRIu64 ,, col ?   : , fld_width,
 		(uint64_t)fsbtodb(sblock, cgsblock(sblock, cylno)));
 		col += len;
 		if (col + len  max_cols)



CVS commit: src/sbin/newfs

2011-08-25 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Aug 25 16:17:58 UTC 2011

Modified Files:
src/sbin/newfs: mkfs.c

Log Message:
Avoid magic manipulation of the format string.


To generate a diff of this commit:
cvs rdiff -u -r1.109 -r1.110 src/sbin/newfs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2011-03-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Mar  6 17:20:28 UTC 2011

Modified Files:
src/sbin/newfs: newfs.8

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sbin/newfs/newfs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/newfs.8
diff -u src/sbin/newfs/newfs.8:1.80 src/sbin/newfs/newfs.8:1.81
--- src/sbin/newfs/newfs.8:1.80	Sun Mar  6 17:08:17 2011
+++ src/sbin/newfs/newfs.8	Sun Mar  6 17:20:28 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: newfs.8,v 1.80 2011/03/06 17:08:17 bouyer Exp $
+.\	$NetBSD: newfs.8,v 1.81 2011/03/06 17:20:28 wiz Exp $
 .\
 .\ Copyright (c) 1983, 1987, 1991, 1993, 1994
 .\	The Regents of the University of California.  All rights reserved.
@@ -250,7 +250,8 @@
 .Li user
 or
 .Li group
-to enable the specified quota type. Multiple
+to enable the specified quota type.
+Multiple
 .Fl q
 can be used to enable all types at once.
 .It Fl s Ar size



CVS commit: src/sbin/newfs

2011-03-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Mar  6 17:20:28 UTC 2011

Modified Files:
src/sbin/newfs: newfs.8

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sbin/newfs/newfs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2010-08-09 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Aug  9 17:20:57 UTC 2010

Modified Files:
src/sbin/newfs: Makefile mkfs.c newfs.8 newfs.c

Log Message:
Add -G, which turns consistency check errors in warnings.  The
current testing purpose is to create a file system with
block size  MAXPHYS.

(the check doesn't make that much sense anyway in these days of
mobile file systems, since we're interested in MAXPHYS where we
attempt to mount the file system, not where we happen to create it)


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sbin/newfs/Makefile
cvs rdiff -u -r1.107 -r1.108 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.77 -r1.78 src/sbin/newfs/newfs.8
cvs rdiff -u -r1.106 -r1.107 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/Makefile
diff -u src/sbin/newfs/Makefile:1.35 src/sbin/newfs/Makefile:1.36
--- src/sbin/newfs/Makefile:1.35	Sun Dec 20 15:21:13 2009
+++ src/sbin/newfs/Makefile	Mon Aug  9 17:20:57 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.35 2009/12/20 15:21:13 dsl Exp $
+#	$NetBSD: Makefile,v 1.36 2010/08/09 17:20:57 pooka Exp $
 #	@(#)Makefile	8.2 (Berkeley) 3/27/94
 
 .include bsd.own.mk
@@ -12,6 +12,7 @@
 FSCK=${NETBSDSRCDIR}/sbin/fsck
 MOUNT=${NETBSDSRCDIR}/sbin/mount
 CPPFLAGS+=-DMFS -I${.CURDIR} -I${DISKLABEL} -I${FSCK} -I${MOUNT}
+CPPFLAGS+=-DGARBAGE
 
 DPADD+= ${LIBUTIL}
 LDADD+= -lutil

Index: src/sbin/newfs/mkfs.c
diff -u src/sbin/newfs/mkfs.c:1.107 src/sbin/newfs/mkfs.c:1.108
--- src/sbin/newfs/mkfs.c:1.107	Sun Jan 31 16:04:34 2010
+++ src/sbin/newfs/mkfs.c	Mon Aug  9 17:20:57 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.107 2010/01/31 16:04:34 mlelstv Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.108 2010/08/09 17:20:57 pooka Exp $	*/
 
 /*
  * Copyright (c) 1980, 1989, 1993
@@ -73,7 +73,7 @@
 #if 0
 static char sccsid[] = @(#)mkfs.c	8.11 (Berkeley) 5/3/95;
 #else
-__RCSID($NetBSD: mkfs.c,v 1.107 2010/01/31 16:04:34 mlelstv Exp $);
+__RCSID($NetBSD: mkfs.c,v 1.108 2010/08/09 17:20:57 pooka Exp $);
 #endif
 #endif /* not lint */
 
@@ -157,6 +157,18 @@
 
 int	fsi, fso;
 
+static void
+fserr(int num)
+{
+#ifdef GARBAGE
+	extern int Gflag;
+
+	if (Gflag)
+		return;
+#endif
+	exit(num);
+}
+
 void
 mkfs(const char *fsys, int fi, int fo,
 mode_t mfsmode, uid_t mfsuid, gid_t mfsgid)
@@ -207,12 +219,12 @@
 	if (sblock.fs_avgfilesize = 0) {
 		printf(illegal expected average file size %d\n,
 		sblock.fs_avgfilesize);
-		exit(14);
+		fserr(14);
 	}
 	if (sblock.fs_avgfpdir = 0) {
 		printf(illegal expected number of files per directory %d\n,
 		sblock.fs_avgfpdir);
-		exit(15);
+		fserr(15);
 	}
 	/*
 	 * collect and verify the block and fragment sizes
@@ -222,32 +234,32 @@
 	if (!powerof2(sblock.fs_bsize)) {
 		printf(block size must be a power of 2, not %d\n,
 		sblock.fs_bsize);
-		exit(16);
+		fserr(16);
 	}
 	if (!powerof2(sblock.fs_fsize)) {
 		printf(fragment size must be a power of 2, not %d\n,
 		sblock.fs_fsize);
-		exit(17);
+		fserr(17);
 	}
 	if (sblock.fs_fsize  sectorsize) {
 		printf(fragment size %d is too small, minimum is %d\n,
 		sblock.fs_fsize, sectorsize);
-		exit(18);
+		fserr(18);
 	}
 	if (sblock.fs_bsize  MINBSIZE) {
 		printf(block size %d is too small, minimum is %d\n,
 		sblock.fs_bsize, MINBSIZE);
-		exit(19);
+		fserr(19);
 	}
 	if (sblock.fs_bsize  MAXBSIZE) {
 		printf(block size %d is too large, maximum is %d\n,
 		sblock.fs_bsize, MAXBSIZE);
-		exit(19);
+		fserr(19);
 	}
 	if (sblock.fs_bsize  sblock.fs_fsize) {
 		printf(block size (%d) cannot be smaller than fragment size (%d)\n,
 		sblock.fs_bsize, sblock.fs_fsize);
-		exit(20);
+		fserr(20);
 	}
 
 	if (maxbsize  bsize || !powerof2(maxbsize)) {
@@ -282,7 +294,7 @@
 			minimum with block size %d is %d\n,
 		sblock.fs_fsize, sblock.fs_bsize,
 		sblock.fs_bsize / MAXFRAG);
-		exit(21);
+		fserr(21);
 	}
 	sblock.fs_fsbtodb = ilog2(sblock.fs_fsize / sectorsize);
 	sblock.fs_size = dbtofsb(sblock, fssize);
@@ -290,7 +302,7 @@
 		if ((uint64_t)sblock.fs_size = 1ull  31) {
 			printf(Too many fragments (0x% PRIx64
 			) for a FFSv1 filesystem\n, sblock.fs_size);
-			exit(22);
+			fserr(22);
 		}
 		sblock.fs_magic = FS_UFS1_MAGIC;
 		sblock.fs_sblockloc = SBLOCK_UFS1;
@@ -353,7 +365,7 @@
 	if (sblock.fs_size  sblock.fs_iblkno + 3 * sblock.fs_frag) {
 		printf(Filesystem size %lld  minimum size of %d\n,
 		(long long)sblock.fs_size, sblock.fs_iblkno + 3 * sblock.fs_frag);
-		exit(23);
+		fserr(23);
 	}
 	if (num_inodes != 0)
 		inodeblks = howmany(num_inodes, INOPB(sblock));
@@ -420,7 +432,7 @@
 	if ((int)CGSIZE(sblock)  sblock.fs_bsize) {
 		printf(CGSIZE miscalculated %d  %d\n,
 		(int)CGSIZE(sblock), sblock.fs_bsize);
-		exit(24);
+		fserr(24);
 	}
 
 	sblock.fs_dblkno = sblock.fs_iblkno + sblock.fs_ipg / INOPF(sblock);
@@ -574,7 +586,7 @@
 		 */
 		if (fssize = 0) {
 			printf(preposterous size 

CVS commit: src/sbin/newfs

2010-08-09 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Aug  9 20:23:20 UTC 2010

Modified Files:
src/sbin/newfs: newfs.8

Log Message:
Sort option descriptions.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sbin/newfs/newfs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/newfs.8
diff -u src/sbin/newfs/newfs.8:1.78 src/sbin/newfs/newfs.8:1.79
--- src/sbin/newfs/newfs.8:1.78	Mon Aug  9 17:20:57 2010
+++ src/sbin/newfs/newfs.8	Mon Aug  9 20:23:20 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: newfs.8,v 1.78 2010/08/09 17:20:57 pooka Exp $
+.\	$NetBSD: newfs.8,v 1.79 2010/08/09 20:23:20 wiz Exp $
 .\
 .\ Copyright (c) 1983, 1987, 1991, 1993, 1994
 .\	The Regents of the University of California.  All rights reserved.
@@ -155,12 +155,12 @@
 .It \*[Gt]= 1024 MB
 2 KB
 .El
-.It Fl g Ar avgfilesize
-The expected average file size for the file system.
 .It Fl G
 Treat garbage parameters as non-fatal.
 Using this option may result in a file system which causes a kernel
 panic and should only be used for testing.
+.It Fl g Ar avgfilesize
+The expected average file size for the file system.
 .It Fl h Ar avgfpdir
 The expected average number of files per directory on the file system.
 .It Fl I
@@ -268,9 +268,6 @@
 Uses information for the specified disk from
 .Pa /etc/disktab
 instead of trying to get the information from the disk label.
-.It Fl v Ar volname
-This specifies that an Apple UFS filesystem should be created
-with the given volume name.
 .It Fl V Ar verbose
 This controls the amount of information written to stdout:
 .Bl -tag -width 3n -offset indent -compact
@@ -292,6 +289,9 @@
 is specified
 .Nm
 stops before outputting the progress bar.
+.It Fl v Ar volname
+This specifies that an Apple UFS filesystem should be created
+with the given volume name.
 .It Fl Z
 Pre-zeros the file system image created with
 .Fl F .



CVS commit: src/sbin/newfs

2010-08-09 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Aug  9 21:14:26 UTC 2010

Modified Files:
src/sbin/newfs: newfs.c

Log Message:
Add -G to usage, omission pointed out by wiz.  Also, make usage format
nicer on a 80col terminal.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.107 src/sbin/newfs/newfs.c:1.108
--- src/sbin/newfs/newfs.c:1.107	Mon Aug  9 17:20:57 2010
+++ src/sbin/newfs/newfs.c	Mon Aug  9 21:14:26 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.107 2010/08/09 17:20:57 pooka Exp $	*/
+/*	$NetBSD: newfs.c,v 1.108 2010/08/09 21:14:26 pooka Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@
 #if 0
 static char sccsid[] = @(#)newfs.c	8.13 (Berkeley) 5/1/95;
 #else
-__RCSID($NetBSD: newfs.c,v 1.107 2010/08/09 17:20:57 pooka Exp $);
+__RCSID($NetBSD: newfs.c,v 1.108 2010/08/09 21:14:26 pooka Exp $);
 #endif
 #endif /* not lint */
 
@@ -818,10 +818,11 @@
 } const help_strings[] = {
 	{ NEWFS,	-B byteorder\tbyte order (`be' or `le') },
 	{ NEWFS,	-F \t\tcreate file system image in regular file },
+	{ NEWFS,	-G \t\tmake sanity calculations non-fatal (testing only!) },
 	{ NEWFS,	-I \t\tdo not check that the file system type is '4.2BSD' },
 	{ BOTH,		-N \t\tdo not create file system, just print out 
 			parameters },
-	{ NEWFS,	-O N\t\tfilesystem format: 0 == 4.3BSD, 1 == FFSv1, 2 == FFSv2 },
+	{ NEWFS,	-O N\t\tfilesystem format: 0 = 4.3BSD, 1 = FFSv1, 2 = FFSv2 },
 	{ NEWFS,	-S secsize\tsector size },
 #ifdef COMPAT
 	{ NEWFS,	-T disktype\tdisk type },



CVS commit: src/sbin/newfs

2010-08-09 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Aug  9 17:20:57 UTC 2010

Modified Files:
src/sbin/newfs: Makefile mkfs.c newfs.8 newfs.c

Log Message:
Add -G, which turns consistency check errors in warnings.  The
current testing purpose is to create a file system with
block size  MAXPHYS.

(the check doesn't make that much sense anyway in these days of
mobile file systems, since we're interested in MAXPHYS where we
attempt to mount the file system, not where we happen to create it)


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sbin/newfs/Makefile
cvs rdiff -u -r1.107 -r1.108 src/sbin/newfs/mkfs.c
cvs rdiff -u -r1.77 -r1.78 src/sbin/newfs/newfs.8
cvs rdiff -u -r1.106 -r1.107 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2010-08-09 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Aug  9 20:23:20 UTC 2010

Modified Files:
src/sbin/newfs: newfs.8

Log Message:
Sort option descriptions.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sbin/newfs/newfs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2010-08-09 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Mon Aug  9 21:14:26 UTC 2010

Modified Files:
src/sbin/newfs: newfs.c

Log Message:
Add -G to usage, omission pointed out by wiz.  Also, make usage format
nicer on a 80col terminal.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sbin/newfs

2010-02-18 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Feb 18 13:51:45 UTC 2010

Modified Files:
src/sbin/newfs: newfs.8

Log Message:
Pull over some of Jason McIntyre's fixes for newfs_ext2fs.
Suggested by tsutsui.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sbin/newfs/newfs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/newfs.8
diff -u src/sbin/newfs/newfs.8:1.75 src/sbin/newfs/newfs.8:1.76
--- src/sbin/newfs/newfs.8:1.75	Tue Dec  1 10:56:33 2009
+++ src/sbin/newfs/newfs.8	Thu Feb 18 13:51:45 2010
@@ -1,4 +1,4 @@
-.\	$NetBSD: newfs.8,v 1.75 2009/12/01 10:56:33 pooka Exp $
+.\	$NetBSD: newfs.8,v 1.76 2010/02/18 13:51:45 wiz Exp $
 .\
 .\ Copyright (c) 1983, 1987, 1991, 1993, 1994
 .\	The Regents of the University of California.  All rights reserved.
@@ -78,13 +78,13 @@
 Bytes; causes no modification.
 (Default)
 .It k
-Kilo; multiply the argument by 1024
+Kilo; multiply the argument by 1024.
 .It m
-Mega; multiply the argument by 1048576
+Mega; multiply the argument by 1048576.
 .It g
-Giga; multiply the argument by 1073741824
+Giga; multiply the argument by 1073741824.
 .It t
-Tera; multiply the argument by 1099511627776
+Tera; multiply the argument by 1099511627776.
 .El
 .Pp
 The following options define the general layout policies.
@@ -202,7 +202,7 @@
 .Fl n
 takes precedence.
 .It Fl O Ar filesystem-format
-Select the filesystem-format
+Select the filesystem-format.
 .Bl -tag -width 3n -offset indent -compact
 .It 0
 4.3BSD; This option is primarily used to build root file systems that can be
@@ -271,7 +271,7 @@
 This controls the amount of information written to stdout:
 .Bl -tag -width 3n -offset indent -compact
 .It 0
-No output
+No output.
 .It 1
 Overall size and cylinder group details.
 .It 2
@@ -285,7 +285,7 @@
 The default is 3.
 If
 .Fl N
-is specifed
+is specified
 .Nm
 stops before outputting the progress bar.
 .It Fl Z
@@ -318,8 +318,8 @@
 .Sq random
 inode generation numbers to improve NFS security.
 .Pp
-The owner and group ids of the root node of the new file system
-are set to the effective uid and gid of the user initializing
+The owner and group IDs of the root node of the new file system
+are set to the effective UID and GID of the user initializing
 the file system.
 .Pp
 For the
@@ -341,9 +341,9 @@
 utility.
 .Pp
 The partition size is found using
-.Xr fstat 2
-not by inspecting the disklabel.
-The block size and fragment size will be written back to the disklabel
+.Xr fstat 2 ,
+not by inspecting the disk label.
+The block size and fragment size will be written back to the disk label
 only if the last character of
 .Ar special
 references the same partition as the minor device number.



CVS commit: src/sbin/newfs

2009-12-20 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sun Dec 20 15:21:13 UTC 2009

Modified Files:
src/sbin/newfs: Makefile newfs.c

Log Message:
Push the mount path for mount_mfs through realpath().
This matches what other fs do.
Fixes PR/20362


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sbin/newfs/Makefile
cvs rdiff -u -r1.105 -r1.106 src/sbin/newfs/newfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/Makefile
diff -u src/sbin/newfs/Makefile:1.34 src/sbin/newfs/Makefile:1.35
--- src/sbin/newfs/Makefile:1.34	Sat Jun  6 11:09:16 2009
+++ src/sbin/newfs/Makefile	Sun Dec 20 15:21:13 2009
@@ -1,15 +1,17 @@
-#	$NetBSD: Makefile,v 1.34 2009/06/06 11:09:16 haad Exp $
+#	$NetBSD: Makefile,v 1.35 2009/12/20 15:21:13 dsl Exp $
 #	@(#)Makefile	8.2 (Berkeley) 3/27/94
 
 .include bsd.own.mk
 
 PROG=	newfs
 SRCS=	dkcksum.c newfs.c mkfs.c ffs_bswap.c ffs_appleufs.c partutil.c
+SRCS+=	pathadj.c
 MAN=	newfs.8 mount_mfs.8
 
 DISKLABEL=${NETBSDSRCDIR}/sbin/disklabel
 FSCK=${NETBSDSRCDIR}/sbin/fsck
-CPPFLAGS+=-DMFS -I${.CURDIR} -I${DISKLABEL} -I${FSCK}
+MOUNT=${NETBSDSRCDIR}/sbin/mount
+CPPFLAGS+=-DMFS -I${.CURDIR} -I${DISKLABEL} -I${FSCK} -I${MOUNT}
 
 DPADD+= ${LIBUTIL}
 LDADD+= -lutil
@@ -17,7 +19,7 @@
 LDADD+=-lprop
 DPADD+=${LIBPROP}
 
-.PATH:	${DISKLABEL} ${NETBSDSRCDIR}/sys/ufs/ffs ${FSCK}
+.PATH:	${DISKLABEL} ${NETBSDSRCDIR}/sys/ufs/ffs ${FSCK} ${MOUNT}
 
 LINKS=	${BINDIR}/newfs ${BINDIR}/mount_mfs
 MLINKS=	mount_mfs.8 mfs.8

Index: src/sbin/newfs/newfs.c
diff -u src/sbin/newfs/newfs.c:1.105 src/sbin/newfs/newfs.c:1.106
--- src/sbin/newfs/newfs.c:1.105	Thu May  7 06:56:56 2009
+++ src/sbin/newfs/newfs.c	Sun Dec 20 15:21:13 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: newfs.c,v 1.105 2009/05/07 06:56:56 lukem Exp $	*/
+/*	$NetBSD: newfs.c,v 1.106 2009/12/20 15:21:13 dsl Exp $	*/
 
 /*
  * Copyright (c) 1983, 1989, 1993, 1994
@@ -78,7 +78,7 @@
 #if 0
 static char sccsid[] = @(#)newfs.c	8.13 (Berkeley) 5/1/95;
 #else
-__RCSID($NetBSD: newfs.c,v 1.105 2009/05/07 06:56:56 lukem Exp $);
+__RCSID($NetBSD: newfs.c,v 1.106 2009/12/20 15:21:13 dsl Exp $);
 #endif
 #endif /* not lint */
 
@@ -117,6 +117,10 @@
 #include util.h
 #include mntopts.h
 
+#ifdef MFS
+#include mountprog.h
+#endif
+
 #include dkcksum.h
 #include extern.h
 #include partutil.h
@@ -238,6 +242,7 @@
 #ifdef MFS
 	struct mfs_args args;
 	char mountfromname[100];
+	char mounttoname[MAXPATHLEN];
 	pid_t pid, res;
 	struct statvfs sf;
 	int status;
@@ -653,6 +658,7 @@
 #ifdef MFS
 	if (mfs) {
 
+		pathadj(argv[1], mounttoname);
 		switch (pid = fork()) {
 		case -1:
 			perror(mfs);
@@ -676,10 +682,10 @@
  * can mount a filesystem which hides our
  * ramdisk before we see the success.
  */
-if (statvfs(argv[1], sf)  0)
-	err(88, statvfs %s, argv[1]);
+if (statvfs(mounttoname, sf)  0)
+	err(88, statvfs %s, mounttoname);
 if (!strcmp(sf.f_mntfromname, mountfromname) 
-!strncmp(sf.f_mntonname, argv[1],
+!strncmp(sf.f_mntonname, mounttoname,
 	 MNAMELEN) 
 !strcmp(sf.f_fstypename, mfs))
 	exit(0);
@@ -692,7 +698,7 @@
 if (WIFEXITED(status)) {
 	if (WEXITSTATUS(status) == 0)
 		exit(0);
-	errx(1, %s: mount: %s, argv[1],
+	errx(1, %s: mount: %s, mounttoname,
 	 strerror(WEXITSTATUS(status)));
 } else
 	errx(11, abnormal termination);
@@ -708,7 +714,7 @@
 
 		args.base = membase;
 		args.size = fssize * sectorsize;
-		if (mount(MOUNT_MFS, argv[1], mntflags | MNT_ASYNC,
+		if (mount(MOUNT_MFS, mounttoname, mntflags | MNT_ASYNC,
 		args, sizeof args) == -1)
 			exit(errno); /* parent prints message */
 	}



CVS commit: src/sbin/newfs

2009-12-01 Thread Antti Kantee
Module Name:src
Committed By:   pooka
Date:   Tue Dec  1 10:56:33 UTC 2009

Modified Files:
src/sbin/newfs: newfs.8

Log Message:
Add note saying that special must be a raw device.
PR bin/42391


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sbin/newfs/newfs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/newfs.8
diff -u src/sbin/newfs/newfs.8:1.74 src/sbin/newfs/newfs.8:1.75
--- src/sbin/newfs/newfs.8:1.74	Wed Jul  1 02:43:34 2009
+++ src/sbin/newfs/newfs.8	Tue Dec  1 10:56:33 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: newfs.8,v 1.74 2009/07/01 02:43:34 uwe Exp $
+.\	$NetBSD: newfs.8,v 1.75 2009/12/01 10:56:33 pooka Exp $
 .\
 .\ Copyright (c) 1983, 1987, 1991, 1993, 1994
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)newfs.8	8.6 (Berkeley) 5/3/95
 .\
-.Dd May 10, 2009
+.Dd December 1, 2009
 .Dt NEWFS 8
 .Os
 .Sh NAME
@@ -347,6 +347,18 @@
 only if the last character of
 .Ar special
 references the same partition as the minor device number.
+.Pp
+Unless
+.Fl F
+is specified,
+.Ar special
+must be a raw device.
+This means that for example
+.Pa wd0a
+or
+.Pa /dev/rwd0a
+must be specified instead of
+.Pa /dev/wd0a .
 .Sh SEE ALSO
 .Xr fstat 2 ,
 .Xr disktab 5 ,



CVS commit: src/sbin/newfs

2009-06-30 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Wed Jul  1 02:43:35 UTC 2009

Modified Files:
src/sbin/newfs: newfs.8

Log Message:
G/c sentence fragment left over from vinum reference (forgotten in 1.69).
Noticed by bad@ in PR bin/41652


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sbin/newfs/newfs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/newfs.8
diff -u src/sbin/newfs/newfs.8:1.73 src/sbin/newfs/newfs.8:1.74
--- src/sbin/newfs/newfs.8:1.73	Sun May 10 13:28:00 2009
+++ src/sbin/newfs/newfs.8	Wed Jul  1 02:43:34 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: newfs.8,v 1.73 2009/05/10 13:28:00 lukem Exp $
+.\	$NetBSD: newfs.8,v 1.74 2009/07/01 02:43:34 uwe Exp $
 .\
 .\ Copyright (c) 1983, 1987, 1991, 1993, 1994
 .\	The Regents of the University of California.  All rights reserved.
@@ -347,7 +347,6 @@
 only if the last character of
 .Ar special
 references the same partition as the minor device number.
-that provide disk like block and character devices.
 .Sh SEE ALSO
 .Xr fstat 2 ,
 .Xr disktab 5 ,



CVS commit: src/sbin/newfs

2009-06-06 Thread Adam Hamsik
Module Name:src
Committed By:   haad
Date:   Sat Jun  6 11:09:16 UTC 2009

Modified Files:
src/sbin/newfs: Makefile

Log Message:
Remove debuging CFLAGS.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sbin/newfs/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/Makefile
diff -u src/sbin/newfs/Makefile:1.33 src/sbin/newfs/Makefile:1.34
--- src/sbin/newfs/Makefile:1.33	Fri Jun  5 21:52:31 2009
+++ src/sbin/newfs/Makefile	Sat Jun  6 11:09:16 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.33 2009/06/05 21:52:31 haad Exp $
+#	$NetBSD: Makefile,v 1.34 2009/06/06 11:09:16 haad Exp $
 #	@(#)Makefile	8.2 (Berkeley) 3/27/94
 
 .include bsd.own.mk
@@ -11,8 +11,6 @@
 FSCK=${NETBSDSRCDIR}/sbin/fsck
 CPPFLAGS+=-DMFS -I${.CURDIR} -I${DISKLABEL} -I${FSCK}
 
-CFLAGS+= -g -O0
-
 DPADD+= ${LIBUTIL}
 LDADD+= -lutil
 



CVS commit: src/sbin/newfs

2009-05-10 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sun May 10 13:28:00 UTC 2009

Modified Files:
src/sbin/newfs: newfs.8

Log Message:
Note that FFSv1 is also known as FFS, UFS, or UFS1.
Note that FFSv2 is also known as UFS2.
Add a reference to Kirk's BSDcon03 paper on UFS2.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sbin/newfs/newfs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/newfs/newfs.8
diff -u src/sbin/newfs/newfs.8:1.72 src/sbin/newfs/newfs.8:1.73
--- src/sbin/newfs/newfs.8:1.72	Fri Aug  1 15:32:29 2008
+++ src/sbin/newfs/newfs.8	Sun May 10 13:28:00 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: newfs.8,v 1.72 2008/08/01 15:32:29 simonb Exp $
+.\	$NetBSD: newfs.8,v 1.73 2009/05/10 13:28:00 lukem Exp $
 .\
 .\ Copyright (c) 1983, 1987, 1991, 1993, 1994
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\ @(#)newfs.8	8.6 (Berkeley) 5/3/95
 .\
-.Dd December 10, 2007
+.Dd May 10, 2009
 .Dt NEWFS 8
 .Os
 .Sh NAME
@@ -209,9 +209,16 @@
 understood by older boot ROMs.
 .It 1
 FFSv1; normal fast-filesystem (default).
+This is also known as
+.Sq FFS ,
+.Sq UFS ,
+or
+.Sq UFS1 .
 .It 2
 FFSv2; enhanced fast-filesystem (suited for more than 1 Terabyte capacity,
 access control lists).
+This is also known as
+.Sq UFS2 .
 .El
 To create an LFS filesystem see
 .Xr newfs_lfs 8 .
@@ -370,6 +377,13 @@
 .%D August 1984
 .%O (reprinted in the BSD System Manager's Manual)
 .Re
+.Rs
+.%A M. McKusick
+.%T Enhancements to the fast filesystem to support multi-terabyte storage systems
+.%J Proceedings of the BSD Conference 2003
+.%P pp 79-90
+.%D September 2003
+.Re
 .Sh HISTORY
 The
 .Nm