[Midnightbsd-cvs] src [11103] trunk/sbin/newfs: add j flag

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Tue Jun 19 14:20:22 EDT 2018


Revision: 11103
          http://svnweb.midnightbsd.org/src/?rev=11103
Author:   laffer1
Date:     2018-06-19 14:20:22 -0400 (Tue, 19 Jun 2018)
Log Message:
-----------
add j flag

Modified Paths:
--------------
    trunk/sbin/newfs/Makefile
    trunk/sbin/newfs/mkfs.c
    trunk/sbin/newfs/newfs.8
    trunk/sbin/newfs/newfs.c
    trunk/sbin/newfs/newfs.h

Property Changed:
----------------
    trunk/sbin/newfs/newfs.8

Modified: trunk/sbin/newfs/Makefile
===================================================================
--- trunk/sbin/newfs/Makefile	2018-06-19 18:15:28 UTC (rev 11102)
+++ trunk/sbin/newfs/Makefile	2018-06-19 18:20:22 UTC (rev 11103)
@@ -1,5 +1,6 @@
+# $MidnightBSD$
 #	@(#)Makefile	8.2 (Berkeley) 3/27/94
-# $MidnightBSD$
+# $FreeBSD: stable/10/sbin/newfs/Makefile 204654 2010-03-03 19:25:28Z sobomax $
 
 .PATH: ${.CURDIR}/../../sys/geom
 

Modified: trunk/sbin/newfs/mkfs.c
===================================================================
--- trunk/sbin/newfs/mkfs.c	2018-06-19 18:15:28 UTC (rev 11102)
+++ trunk/sbin/newfs/mkfs.c	2018-06-19 18:20:22 UTC (rev 11103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
  * All rights reserved.
@@ -42,7 +43,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/newfs/mkfs.c 322860 2017-08-24 21:44:23Z mckusick $");
 
 #include <sys/param.h>
 #include <sys/disklabel.h>
@@ -121,6 +122,7 @@
 	ino_t maxinum;
 	int minfragsperinode;	/* minimum ratio of frags to inodes */
 	char tmpbuf[100];	/* XXX this will break in about 2,500 years */
+	struct fsrecovery fsr;
 	union {
 		struct fs fdummy;
 		char cdummy[SBLOCKSIZE];
@@ -619,6 +621,25 @@
 			sblock.fs_cssize - i : sblock.fs_bsize,
 			((char *)fscs) + i);
 	/*
+	 * Read the last sector of the boot block, replace the last
+	 * 20 bytes with the recovery information, then write it back.
+	 * The recovery information only works for UFS2 filesystems.
+	 */
+	if (sblock.fs_magic == FS_UFS2_MAGIC) {
+		i = bread(&disk,
+		    part_ofs + (SBLOCK_UFS2 - sizeof(fsr)) / disk.d_bsize,
+		    (char *)&fsr, sizeof(fsr));
+		if (i == -1)
+			err(1, "can't read recovery area: %s", disk.d_error);
+		fsr.fsr_magic = sblock.fs_magic;
+		fsr.fsr_fpg = sblock.fs_fpg;
+		fsr.fsr_fsbtodb = sblock.fs_fsbtodb;
+		fsr.fsr_sblkno = sblock.fs_sblkno;
+		fsr.fsr_ncg = sblock.fs_ncg;
+		wtfs((SBLOCK_UFS2 - sizeof(fsr)) / disk.d_bsize, sizeof(fsr),
+		    (char *)&fsr);
+	}
+	/*
 	 * Update information about this partition in pack
 	 * label, to that it may be updated on disk.
 	 */
@@ -811,7 +832,7 @@
  */
 #define ROOTLINKCNT 3
 
-struct direct root_dir[] = {
+static struct direct root_dir[] = {
 	{ ROOTINO, sizeof(struct direct), DT_DIR, 1, "." },
 	{ ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." },
 	{ ROOTINO + 1, sizeof(struct direct), DT_DIR, 5, ".snap" },
@@ -819,7 +840,7 @@
 
 #define SNAPLINKCNT 2
 
-struct direct snap_dir[] = {
+static struct direct snap_dir[] = {
 	{ ROOTINO + 1, sizeof(struct direct), DT_DIR, 1, "." },
 	{ ROOTINO, sizeof(struct direct), DT_DIR, 2, ".." },
 };
@@ -1010,7 +1031,8 @@
 	sblock.fs_cstotal.cs_nifree--;
 	fscs[0].cs_nifree--;
 	if (ino >= (unsigned long)sblock.fs_ipg * sblock.fs_ncg) {
-		printf("fsinit: inode value out of range (%d).\n", ino);
+		printf("fsinit: inode value out of range (%ju).\n",
+		    (uintmax_t)ino);
 		exit(32);
 	}
 	d = fsbtodb(&sblock, ino_to_fsba(&sblock, ino));

Modified: trunk/sbin/newfs/newfs.8
===================================================================
--- trunk/sbin/newfs/newfs.8	2018-06-19 18:15:28 UTC (rev 11102)
+++ trunk/sbin/newfs/newfs.8	2018-06-19 18:20:22 UTC (rev 11103)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
 .\" Copyright (c) 1983, 1987, 1991, 1993, 1994
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -26,9 +27,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)newfs.8	8.6 (Berkeley) 5/3/95
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/sbin/newfs/newfs.8 293692 2016-01-11 20:10:14Z trasz $
 .\"
-.Dd June 22, 2011
+.Dd October 1, 2013
 .Dt NEWFS 8
 .Os
 .Sh NAME
@@ -226,7 +227,7 @@
 for more details on how to set this option.
 .It Fl p Ar partition
 The partition name (a..h) you want to use in case the underlying image
-is a file, so you don't have access to individual partitions through the
+is a file, so you do not have access to individual partitions through the
 filesystem.
 Can also be used with a device, e.g.
 .Nm
@@ -285,10 +286,10 @@
 The size of a sector in bytes (almost never anything but 512).
 .El
 .Sh EXAMPLES
-.Dl newfs /dev/ad3s1a
+.Dl newfs /dev/ada3s1a
 .Pp
 Creates a new ufs file system on
-.Pa ad3s1a .
+.Pa ada3s1a .
 The
 .Nm
 utility will use a block size of 32768 bytes, a fragment size of 4096 bytes
@@ -303,11 +304,11 @@
 .Xr geom 4 ,
 .Xr disktab 5 ,
 .Xr fs 5 ,
-.Xr bsdlabel 8 ,
 .Xr camcontrol 8 ,
 .Xr dump 8 ,
 .Xr dumpfs 8 ,
 .Xr fsck 8 ,
+.Xr gpart 8 ,
 .Xr gjournal 8 ,
 .Xr growfs 8 ,
 .Xr makefs 8 ,


Property changes on: trunk/sbin/newfs/newfs.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sbin/newfs/newfs.c
===================================================================
--- trunk/sbin/newfs/newfs.c	2018-06-19 18:15:28 UTC (rev 11102)
+++ trunk/sbin/newfs/newfs.c	2018-06-19 18:20:22 UTC (rev 11103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
  * All rights reserved.
@@ -48,7 +49,7 @@
 #endif /* not lint */
 #endif
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sbin/newfs/newfs.c 322860 2017-08-24 21:44:23Z mckusick $");
 
 /*
  * newfs: friendly front end to mkfs
@@ -117,11 +118,9 @@
 static int	is_file;		/* work on a file, not a device */
 static char	*dkname;
 static char	*disktype;
-static int	unlabeled;
 
 static void getfssize(intmax_t *, const char *p, intmax_t, intmax_t);
 static struct disklabel *getdisklabel(char *s);
-static void rewritelabel(char *s, struct disklabel *lp);
 static void usage(void);
 static int expand_number_int(const char *buf, int *num);
 
@@ -153,7 +152,8 @@
 		case 'L':
 			volumelabel = optarg;
 			i = -1;
-			while (isalnum(volumelabel[++i]));
+			while (isalnum(volumelabel[++i]) ||
+			    volumelabel[i] == '_');
 			if (volumelabel[i] != '\0') {
 				errx(1, "bad volume label. Valid characters are alphanumerics.");
 			}
@@ -402,12 +402,6 @@
 			pp->p_size *= secperblk;
 	}
 	mkfs(pp, special);
-	if (!unlabeled) {
-		if (realsectorsize != DEV_BSIZE)
-			pp->p_size /= realsectorsize / DEV_BSIZE;
-		if (!Nflag && bcmp(pp, &oldpartition, sizeof(oldpartition)))
-			rewritelabel(special, lp);
-	}
 	ufs_disk_close(&disk);
 	if (!jflag)
 		exit(0);
@@ -451,9 +445,6 @@
 		return &lab;
 	}
 
-	if (ioctl(disk.d_fd, DIOCGDINFO, (char *)&lab) != -1)
-		return (&lab);
-	unlabeled++;
 	if (disktype) {
 		lp = getdiskbyname(disktype);
 		if (lp != NULL)
@@ -462,25 +453,6 @@
 	return (NULL);
 }
 
-void
-rewritelabel(char *s, struct disklabel *lp)
-{
-	if (unlabeled)
-		return;
-	lp->d_checksum = 0;
-	lp->d_checksum = dkcksum(lp);
-	if (is_file) {
-		bsd_disklabel_le_enc(bootarea + 0 /* labeloffset */ +
-			1 /* labelsoffset */ * sectorsize, lp);
-		lseek(disk.d_fd, 0, SEEK_SET);
-		if (write(disk.d_fd, bootarea, BBSIZE) != BBSIZE)
-			errx(1, "cannot write label");
-		return;
-	}
-	if (ioctl(disk.d_fd, DIOCWDINFO, (char *)lp) == -1)
-		warn("ioctl (WDINFO): %s: can't rewrite disk label", s);
-}
-
 static void
 usage()
 {

Modified: trunk/sbin/newfs/newfs.h
===================================================================
--- trunk/sbin/newfs/newfs.h	2018-06-19 18:15:28 UTC (rev 11102)
+++ trunk/sbin/newfs/newfs.h	2018-06-19 18:20:22 UTC (rev 11103)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
  * All rights reserved.
@@ -35,7 +36,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sbin/newfs/newfs.h 248623 2013-03-22 21:45:28Z mckusick $
  */
 
 #include <libufs.h>
@@ -81,6 +82,7 @@
 extern int	Oflag;		/* build UFS1 format file system */
 extern int	Rflag;		/* regression test */
 extern int	Uflag;		/* enable soft updates for file system */
+extern int	jflag;		/* enable soft updates journaling for filesys */
 extern int	Xflag;		/* exit in middle of newfs for testing */
 extern int	Jflag;		/* enable gjournal for file system */
 extern int	lflag;		/* enable multilabel MAC for file system */



More information about the Midnightbsd-cvs mailing list