CVS commit: src/sbin/fsck_ffs

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

Modified Files:
src/sbin/fsck_ffs: inode.c setup.c utilities.c

Log Message:
Revert "fsck_ffs(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.77 -r1.78 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.108 -r1.109 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.70 -r1.71 src/sbin/fsck_ffs/utilities.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/fsck_ffs/inode.c
diff -u src/sbin/fsck_ffs/inode.c:1.77 src/sbin/fsck_ffs/inode.c:1.78
--- src/sbin/fsck_ffs/inode.c:1.77	Tue Jul  4 20:40:53 2023
+++ src/sbin/fsck_ffs/inode.c	Wed Jul  5 10:59:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.c,v 1.77 2023/07/04 20:40:53 riastradh Exp $	*/
+/*	$NetBSD: inode.c,v 1.78 2023/07/05 10:59:08 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)inode.c	8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: inode.c,v 1.77 2023/07/04 20:40:53 riastradh Exp $");
+__RCSID("$NetBSD: inode.c,v 1.78 2023/07/05 10:59:08 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -462,10 +462,8 @@ setinodebuf(ino_t inum)
 		partialcnt = fullcnt;
 		partialsize = inobufsize;
 	}
-	__CTASSERT(powerof2(DEV_BSIZE));
 	if (inodebuf == NULL &&
-	(inodebuf = aligned_alloc(DEV_BSIZE,
-		roundup2((unsigned)inobufsize, DEV_BSIZE))) == NULL)
+	(inodebuf = aligned_alloc(DEV_BSIZE, (unsigned)inobufsize)) == NULL)
 		errexit("Cannot allocate space for inode buffer");
 }
 

Index: src/sbin/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.108 src/sbin/fsck_ffs/setup.c:1.109
--- src/sbin/fsck_ffs/setup.c:1.108	Tue Jul  4 20:40:53 2023
+++ src/sbin/fsck_ffs/setup.c	Wed Jul  5 10:59:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.108 2023/07/04 20:40:53 riastradh Exp $	*/
+/*	$NetBSD: setup.c,v 1.109 2023/07/05 10:59:08 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setup.c	8.10 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: setup.c,v 1.108 2023/07/04 20:40:53 riastradh Exp $");
+__RCSID("$NetBSD: setup.c,v 1.109 2023/07/05 10:59:08 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -127,7 +127,6 @@ setup(const char *dev, const char *origd
 	lfdir = 0;
 	initbarea();
 	initbarea();
-	__CTASSERT((SBLOCKSIZE % DEV_BSIZE) == 0);
 	sblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
 	sblock = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
 	asblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
@@ -460,9 +459,8 @@ setup(const char *dev, const char *origd
 	 * read in the summary info.
 	 */
 	asked = 0;
-	__CTASSERT(powerof2(DEV_BSIZE));
 	sblock->fs_csp = (struct csum *)aligned_alloc(DEV_BSIZE,
-	roundup2(sblock->fs_cssize, DEV_BSIZE));
+	sblock->fs_cssize);
 	if (sblock->fs_csp == NULL) {
 		pwarn("cannot alloc %u bytes for summary info\n",
 		sblock->fs_cssize);
@@ -497,9 +495,7 @@ setup(const char *dev, const char *origd
 	 * allocate and initialize the necessary maps
 	 */
 	bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));
-	__CTASSERT(powerof2(DEV_BSIZE));
-	blockmap = aligned_alloc(DEV_BSIZE,
-	roundup2((unsigned)bmapsize, DEV_BSIZE));
+	blockmap = aligned_alloc(DEV_BSIZE, (unsigned)bmapsize);
 	if (blockmap == NULL) {
 		pwarn("cannot alloc %u bytes for blockmap\n",
 		(unsigned)bmapsize);
@@ -534,9 +530,7 @@ setup(const char *dev, const char *origd
 		(unsigned)(numdirs * sizeof(struct inoinfo *)));
 		goto badsblabel;
 	}
-	__CTASSERT(powerof2(DEV_BSIZE));
-	cgrp = aligned_alloc(DEV_BSIZE,
-	roundup2(sblock->fs_cgsize, DEV_BSIZE));
+	cgrp = aligned_alloc(DEV_BSIZE, sblock->fs_cgsize);
 	if (cgrp == NULL) {
 		pwarn("cannot alloc %u bytes for cylinder group\n",
 		sblock->fs_cgsize);

Index: src/sbin/fsck_ffs/utilities.c
diff -u src/sbin/fsck_ffs/utilities.c:1.70 src/sbin/fsck_ffs/utilities.c:1.71
--- src/sbin/fsck_ffs/utilities.c:1.70	Tue Jul  4 20:40:53 2023
+++ src/sbin/fsck_ffs/utilities.c	Wed Jul  5 10:59:08 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: utilities.c,v 1.70 2023/07/04 20:40:53 riastradh Exp $	*/
+/*	$NetBSD: utilities.c,v 1.71 2023/07/05 10:59:08 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utilities.c	8.6 (Berkeley) 5/19/95";
 #else
-__RCSID("$NetBSD: utilities.c,v 1.70 2023/07/04 20:40:53 riastradh Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.71 2023/07/05 10:59:08 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -135,15 +135,12 @@ bufinit(void)
 	char *bufp;
 
 	pbp = pdirbp = (struct bufarea *)0;
-	__CTASSERT(powerof2(DEV_BSIZE));
-	bufp = aligned_alloc(DEV_BSIZE,
-	roundup2((unsigned int)sblock->fs_bsize, DEV_BSIZE));
+	bufp = aligned_alloc(DEV_BSIZE, (unsigned int)sblock->fs_bsize);
 	if (bufp == 0)
 		

CVS commit: src/sbin/fsck_ffs

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

Modified Files:
src/sbin/fsck_ffs: inode.c setup.c utilities.c

Log Message:
Revert "fsck_ffs(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.77 -r1.78 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.108 -r1.109 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.70 -r1.71 src/sbin/fsck_ffs/utilities.c

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



CVS commit: src/sbin/fsck_ffs

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

Modified Files:
src/sbin/fsck_ffs: dir.c extern.h fsck.h inode.c main.c pass1.c pass2.c
pass4.c pass5.c pass6.c quota2.c setup.c utilities.c

Log Message:
fsck_ffs(8): Fix whitespace issues.

- Nix trailing whitespace.
- Omit excessive blank lines.
- Insert missing blank lines between $NetBSD$ and copyright.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/fsck_ffs/dir.c
cvs rdiff -u -r1.28 -r1.29 src/sbin/fsck_ffs/extern.h
cvs rdiff -u -r1.57 -r1.58 src/sbin/fsck_ffs/fsck.h src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.76 -r1.77 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.91 -r1.92 src/sbin/fsck_ffs/main.c
cvs rdiff -u -r1.63 -r1.64 src/sbin/fsck_ffs/pass1.c
cvs rdiff -u -r1.52 -r1.53 src/sbin/fsck_ffs/pass2.c
cvs rdiff -u -r1.30 -r1.31 src/sbin/fsck_ffs/pass4.c
cvs rdiff -u -r1.4 -r1.5 src/sbin/fsck_ffs/pass6.c
cvs rdiff -u -r1.7 -r1.8 src/sbin/fsck_ffs/quota2.c
cvs rdiff -u -r1.107 -r1.108 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.69 -r1.70 src/sbin/fsck_ffs/utilities.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/fsck_ffs/dir.c
diff -u src/sbin/fsck_ffs/dir.c:1.61 src/sbin/fsck_ffs/dir.c:1.62
--- src/sbin/fsck_ffs/dir.c:1.61	Sun May  5 14:59:06 2019
+++ src/sbin/fsck_ffs/dir.c	Tue Jul  4 20:40:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.61 2019/05/05 14:59:06 christos Exp $	*/
+/*	$NetBSD: dir.c,v 1.62 2023/07/04 20:40:53 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)dir.c	8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: dir.c,v 1.61 2019/05/05 14:59:06 christos Exp $");
+__RCSID("$NetBSD: dir.c,v 1.62 2023/07/04 20:40:53 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -230,7 +230,7 @@ dirscan(struct inodesc *idesc)
 			dirty(bp);
 			sbdirty();
 		}
-		if (n & STOP) 
+		if (n & STOP)
 			return (n);
 	}
 	return (idesc->id_filesize > 0 ? KEEPON : STOP);
@@ -265,7 +265,7 @@ fsck_readdir(struct inodesc *idesc)
 		dp->d_name[0] = '\0';
 		if (fix)
 			dirty(bp);
-		else 
+		else
 			markclean = 0;
 		idesc->id_loc += dirblksiz;
 		idesc->id_filesize -= dirblksiz;
@@ -294,7 +294,7 @@ dpok:
 		dp->d_reclen = iswap16(iswap16(dp->d_reclen) + size);
 		if (fix)
 			dirty(bp);
-		else 
+		else
 			markclean = 0;
 	}
 	return (dp);
@@ -308,7 +308,7 @@ dpok:
  *	0: bad
  */
 static int
-dircheck(struct inodesc *idesc, struct direct *dp, struct bufarea *bp) 
+dircheck(struct inodesc *idesc, struct direct *dp, struct bufarea *bp)
 {
 	uint8_t namlen, type;
 	uint16_t reclen;
@@ -497,7 +497,7 @@ adjust(struct inodesc *idesc, int lcnt)
 		if (preen || reply("ADJUST") == 1) {
 			DIP_SET(dp, nlink, iswap16(nlink - lcnt));
 			inodirty();
-		} else 
+		} else
 			markclean = 0;
 	}
 }
@@ -715,7 +715,7 @@ makeentry(ino_t parent, ino_t ino, const
 	union dinode *dp;
 	struct inodesc idesc;
 	char pathbuf[MAXPATHLEN + 1];
-	
+
 	if (parent < UFS_ROOTINO || parent >= maxino ||
 	ino < UFS_ROOTINO || ino >= maxino)
 		return (0);

Index: src/sbin/fsck_ffs/extern.h
diff -u src/sbin/fsck_ffs/extern.h:1.28 src/sbin/fsck_ffs/extern.h:1.29
--- src/sbin/fsck_ffs/extern.h:1.28	Thu Nov 17 06:40:38 2022
+++ src/sbin/fsck_ffs/extern.h	Tue Jul  4 20:40:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: extern.h,v 1.28 2022/11/17 06:40:38 chs Exp $	*/
+/*	$NetBSD: extern.h,v 1.29 2023/07/04 20:40:53 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1994 James A. Jegers
@@ -88,7 +88,6 @@ void		remove_uquot(struct uquot_hash *,s
 void		update_uquot(ino_t, uid_t, gid_t, int64_t, int64_t);
 int		is_quota_inode(ino_t);
 
-
 int		check_wapbl(void);
 void		replay_wapbl(void);
 void		cleanup_wapbl(void);

Index: src/sbin/fsck_ffs/fsck.h
diff -u src/sbin/fsck_ffs/fsck.h:1.57 src/sbin/fsck_ffs/fsck.h:1.58
--- src/sbin/fsck_ffs/fsck.h:1.57	Sat Jan 14 12:12:50 2023
+++ src/sbin/fsck_ffs/fsck.h	Tue Jul  4 20:40:53 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fsck.h,v 1.57 2023/01/14 12:12:50 christos Exp $	*/
+/*	$NetBSD: fsck.h,v 1.58 2023/07/04 20:40:53 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -101,7 +101,6 @@ extern struct inostatlist {
 	struct inostat *il_stat;/* inostat info for this cylinder group */
 } *inostathead;
 
-
 /*
  * buffer cache structure.
  */
@@ -205,14 +204,14 @@ struct inodesc {
 
 /*
  * Linked list of duplicate blocks.
- * 
+ *
  * The list is composed of two parts. The first part of the
  * list (from duplist through the node pointed to by muldup)
- * contains a single copy of each duplicate block that has been 
+ * contains a single copy of each duplicate block that has been
  * found. The second part of the list (from muldup to the end)
  * contains duplicate blocks that have been found more than once.
  * To check if a block has been found as a duplicate it is only
- * necessary to 

CVS commit: src/sbin/fsck_ffs

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

Modified Files:
src/sbin/fsck_ffs: dir.c extern.h fsck.h inode.c main.c pass1.c pass2.c
pass4.c pass5.c pass6.c quota2.c setup.c utilities.c

Log Message:
fsck_ffs(8): Fix whitespace issues.

- Nix trailing whitespace.
- Omit excessive blank lines.
- Insert missing blank lines between $NetBSD$ and copyright.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/fsck_ffs/dir.c
cvs rdiff -u -r1.28 -r1.29 src/sbin/fsck_ffs/extern.h
cvs rdiff -u -r1.57 -r1.58 src/sbin/fsck_ffs/fsck.h src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.76 -r1.77 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.91 -r1.92 src/sbin/fsck_ffs/main.c
cvs rdiff -u -r1.63 -r1.64 src/sbin/fsck_ffs/pass1.c
cvs rdiff -u -r1.52 -r1.53 src/sbin/fsck_ffs/pass2.c
cvs rdiff -u -r1.30 -r1.31 src/sbin/fsck_ffs/pass4.c
cvs rdiff -u -r1.4 -r1.5 src/sbin/fsck_ffs/pass6.c
cvs rdiff -u -r1.7 -r1.8 src/sbin/fsck_ffs/quota2.c
cvs rdiff -u -r1.107 -r1.108 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.69 -r1.70 src/sbin/fsck_ffs/utilities.c

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



CVS commit: src/sbin/fsck_ffs

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

Modified Files:
src/sbin/fsck_ffs: inode.c setup.c utilities.c

Log Message:
fsck_ffs(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.75 -r1.76 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.106 -r1.107 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.68 -r1.69 src/sbin/fsck_ffs/utilities.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/fsck_ffs/inode.c
diff -u src/sbin/fsck_ffs/inode.c:1.75 src/sbin/fsck_ffs/inode.c:1.76
--- src/sbin/fsck_ffs/inode.c:1.75	Sat Jan 14 17:01:10 2023
+++ src/sbin/fsck_ffs/inode.c	Tue Jul  4 20:40:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.c,v 1.75 2023/01/14 17:01:10 kre Exp $	*/
+/*	$NetBSD: inode.c,v 1.76 2023/07/04 20:40:22 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)inode.c	8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: inode.c,v 1.75 2023/01/14 17:01:10 kre Exp $");
+__RCSID("$NetBSD: inode.c,v 1.76 2023/07/04 20:40:22 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -462,8 +462,10 @@ setinodebuf(ino_t inum)
 		partialcnt = fullcnt;
 		partialsize = inobufsize;
 	}
+	__CTASSERT(powerof2(DEV_BSIZE));
 	if (inodebuf == NULL &&
-	(inodebuf = aligned_alloc(DEV_BSIZE, (unsigned)inobufsize)) == NULL)
+	(inodebuf = aligned_alloc(DEV_BSIZE,
+		roundup2((unsigned)inobufsize, DEV_BSIZE))) == NULL)
 		errexit("Cannot allocate space for inode buffer");
 }
 

Index: src/sbin/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.106 src/sbin/fsck_ffs/setup.c:1.107
--- src/sbin/fsck_ffs/setup.c:1.106	Sun Jan  8 05:25:24 2023
+++ src/sbin/fsck_ffs/setup.c	Tue Jul  4 20:40:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs Exp $	*/
+/*	$NetBSD: setup.c,v 1.107 2023/07/04 20:40:22 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setup.c	8.10 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs Exp $");
+__RCSID("$NetBSD: setup.c,v 1.107 2023/07/04 20:40:22 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -127,6 +127,7 @@ setup(const char *dev, const char *origd
 	lfdir = 0;
 	initbarea();
 	initbarea();
+	__CTASSERT((SBLOCKSIZE % DEV_BSIZE) == 0);
 	sblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
 	sblock = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
 	asblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
@@ -459,8 +460,9 @@ setup(const char *dev, const char *origd
 	 * read in the summary info.
 	 */
 	asked = 0;
+	__CTASSERT(powerof2(DEV_BSIZE));
 	sblock->fs_csp = (struct csum *)aligned_alloc(DEV_BSIZE,
-	sblock->fs_cssize);
+	roundup2(sblock->fs_cssize, DEV_BSIZE));
 	if (sblock->fs_csp == NULL) {
 		pwarn("cannot alloc %u bytes for summary info\n",
 		sblock->fs_cssize);	
@@ -495,7 +497,9 @@ setup(const char *dev, const char *origd
 	 * allocate and initialize the necessary maps
 	 */
 	bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));
-	blockmap = aligned_alloc(DEV_BSIZE, (unsigned)bmapsize);
+	__CTASSERT(powerof2(DEV_BSIZE));
+	blockmap = aligned_alloc(DEV_BSIZE,
+	roundup2((unsigned)bmapsize, DEV_BSIZE));
 	if (blockmap == NULL) {
 		pwarn("cannot alloc %u bytes for blockmap\n",
 		(unsigned)bmapsize);
@@ -530,7 +534,9 @@ setup(const char *dev, const char *origd
 		(unsigned)(numdirs * sizeof(struct inoinfo *)));
 		goto badsblabel;
 	}
-	cgrp = aligned_alloc(DEV_BSIZE, sblock->fs_cgsize);
+	__CTASSERT(powerof2(DEV_BSIZE));
+	cgrp = aligned_alloc(DEV_BSIZE,
+	roundup2(sblock->fs_cgsize, DEV_BSIZE));
 	if (cgrp == NULL) {
 		pwarn("cannot alloc %u bytes for cylinder group\n",
 		sblock->fs_cgsize);

Index: src/sbin/fsck_ffs/utilities.c
diff -u src/sbin/fsck_ffs/utilities.c:1.68 src/sbin/fsck_ffs/utilities.c:1.69
--- src/sbin/fsck_ffs/utilities.c:1.68	Sat Jan 14 12:12:50 2023
+++ src/sbin/fsck_ffs/utilities.c	Tue Jul  4 20:40:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: utilities.c,v 1.68 2023/01/14 12:12:50 christos Exp $	*/
+/*	$NetBSD: utilities.c,v 1.69 2023/07/04 20:40:22 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utilities.c	8.6 (Berkeley) 5/19/95";
 #else
-__RCSID("$NetBSD: utilities.c,v 1.68 2023/01/14 12:12:50 christos Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.69 2023/07/04 20:40:22 riastradh Exp $");
 #endif
 #endif /* not lint */
 
@@ -135,12 +135,15 @@ bufinit(void)
 	char *bufp;
 
 	pbp = pdirbp = (struct bufarea *)0;
-	bufp = aligned_alloc(DEV_BSIZE, 

CVS commit: src/sbin/fsck_ffs

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

Modified Files:
src/sbin/fsck_ffs: inode.c setup.c utilities.c

Log Message:
fsck_ffs(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.75 -r1.76 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.106 -r1.107 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.68 -r1.69 src/sbin/fsck_ffs/utilities.c

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



CVS commit: src/sbin/fsck_ffs

2023-03-27 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Mar 27 22:53:37 UTC 2023

Modified Files:
src/sbin/fsck_ffs: pass2.c

Log Message:
Apply this commit from FreeBSD:

  commit 6bae6625e0e06816c80ac4971dfccf0643abe3f0
  Author: Kirk McKusick 
  Date:   Wed Aug 17 14:19:59 2022 -0700

Improve handling of missing '.' and '..' in UFS directories.

The UFS filesystem expects to find '.' and '..' as the first two entries
in a directory. The kernel's UFS name cache can become quite confused
when these two entries are not present as the first two entries.

Prior to this change, when the fsck_ffs(8) utility detected that
'.' and/or '..' were missing, it would report them, but only offered
to replace them if the space at the beginning of the directory was
available. Otherwise it was left to the system administrator to
move the offending file(s) out of the way and then rerun fsck_ffs(8)
to create the '.' and '..' entries.

With this change, fsck_ffs(8) will always be able to create the '.'
and/or '..' entries. It moves any files in the way elsewhere in the
directory block. If there is no room in the directory block to which
to move them, they are placed in the lost+found directory.

Reported by:  Peter Holm
Sponsored by: The FreeBSD Foundation


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sbin/fsck_ffs/pass2.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/fsck_ffs/pass2.c
diff -u src/sbin/fsck_ffs/pass2.c:1.51 src/sbin/fsck_ffs/pass2.c:1.52
--- src/sbin/fsck_ffs/pass2.c:1.51	Wed Feb  8 16:11:40 2017
+++ src/sbin/fsck_ffs/pass2.c	Mon Mar 27 22:53:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass2.c,v 1.51 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: pass2.c,v 1.52 2023/03/27 22:53:37 chs Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pass2.c	8.9 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: pass2.c,v 1.51 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: pass2.c,v 1.52 2023/03/27 22:53:37 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -271,11 +271,9 @@ pass2(void)
 		info = inoinfo(inp->i_parent);
 		if (inp->i_dotdot == 0) {
 			inp->i_dotdot = inp->i_parent;
-			fileerror(inp->i_parent, inp->i_number, "MISSING '..'");
-			if (reply("FIX") == 0) {
-markclean = 0;
-continue;
-			}
+			if (debug)
+fileerror(inp->i_parent, inp->i_number,
+"DEFERRED MISSING '..' FIX");
 			(void)makeentry(inp->i_number, inp->i_parent, "..");
 			info->ino_linkcnt--;
 			continue;
@@ -331,7 +329,7 @@ pass2check(struct inodesc *idesc)
 	int n, entrysize, ret = 0;
 	union dinode *dp;
 	const char *errmsg;
-	struct direct proto;
+	struct direct proto, *newdirp;
 	char namebuf[MAXPATHLEN + 1];
 	char pathbuf[MAXPATHLEN + 1];
 
@@ -351,23 +349,22 @@ pass2check(struct inodesc *idesc)
 	if (dirp->d_ino != 0 && strcmp(dirp->d_name, ".") == 0) {
 		if (iswap32(dirp->d_ino) != idesc->id_number) {
 			direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'");
-			dirp->d_ino = iswap32(idesc->id_number);
-			if (reply("FIX") == 1)
+			if (reply("FIX") == 1) {
+dirp->d_ino = iswap32(idesc->id_number);
 ret |= ALTERED;
-			else
+			} else
 markclean = 0;
 		}
 		if (newinofmt && dirp->d_type != DT_DIR) {
 			direrror(idesc->id_number, "BAD TYPE VALUE FOR '.'");
-			dirp->d_type = DT_DIR;
-			if (reply("FIX") == 1)
+			if (reply("FIX") == 1) {
+dirp->d_type = DT_DIR;
 ret |= ALTERED;
-			else
+			} else
 markclean = 0;
 		}
 		goto chk1;
 	}
-	direrror(idesc->id_number, "MISSING '.'");
 	proto.d_ino = iswap32(idesc->id_number);
 	if (newinofmt)
 		proto.d_type = DT_DIR;
@@ -387,33 +384,33 @@ pass2check(struct inodesc *idesc)
 			proto.d_namlen = tmp;
 		}
 	entrysize = UFS_DIRSIZ(0, , 0);
-	if (dirp->d_ino != 0 && strcmp(dirp->d_name, "..") != 0) {
-		pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
-			dirp->d_name);
-		markclean = 0;
-	} else if (iswap16(dirp->d_reclen) < entrysize) {
-		pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n");
-		markclean = 0;
-	} else if (iswap16(dirp->d_reclen) < 2 * entrysize) {
+	direrror(idesc->id_number, "MISSING '.'");
+	errmsg = "ADD '.' ENTRY";
+	if (iswap16(dirp->d_reclen) < entrysize + UFS_DIRSIZ(0, dirp, 0)) {
+		/* Not enough space to add '.', replace first entry with '.' */
+		if (dirp->d_ino != 0) {
+			pwarn("\nFIRST ENTRY IN DIRECTORY CONTAINS %s\n",
+			 dirp->d_name);
+			errmsg = "REPLACE WITH '.'";
+		}
+		if (reply(errmsg) == 0)
+			goto chk1;
 		proto.d_reclen = dirp->d_reclen;
 		memmove(dirp, , (size_t)entrysize);
-		if (reply("FIX") == 1)
-			ret |= ALTERED;
-		else
-			markclean = 0;
+		ret |= ALTERED;
 	} else {
-		n = iswap16(dirp->d_reclen) - entrysize;
+		/* Move over first entry and add '.' entry */
+		if (reply(errmsg) == 0)
+			goto chk1;
+		newdirp = (struct direct *)((char 

CVS commit: src/sbin/fsck_ffs

2023-03-27 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Mon Mar 27 22:53:37 UTC 2023

Modified Files:
src/sbin/fsck_ffs: pass2.c

Log Message:
Apply this commit from FreeBSD:

  commit 6bae6625e0e06816c80ac4971dfccf0643abe3f0
  Author: Kirk McKusick 
  Date:   Wed Aug 17 14:19:59 2022 -0700

Improve handling of missing '.' and '..' in UFS directories.

The UFS filesystem expects to find '.' and '..' as the first two entries
in a directory. The kernel's UFS name cache can become quite confused
when these two entries are not present as the first two entries.

Prior to this change, when the fsck_ffs(8) utility detected that
'.' and/or '..' were missing, it would report them, but only offered
to replace them if the space at the beginning of the directory was
available. Otherwise it was left to the system administrator to
move the offending file(s) out of the way and then rerun fsck_ffs(8)
to create the '.' and '..' entries.

With this change, fsck_ffs(8) will always be able to create the '.'
and/or '..' entries. It moves any files in the way elsewhere in the
directory block. If there is no room in the directory block to which
to move them, they are placed in the lost+found directory.

Reported by:  Peter Holm
Sponsored by: The FreeBSD Foundation


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sbin/fsck_ffs/pass2.c

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



CVS commit: src/sbin/fsck_ffs

2023-01-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Jan 14 17:01:11 UTC 2023

Modified Files:
src/sbin/fsck_ffs: inode.c

Log Message:
Use %zu rather than %lu to print a size_t (should fix i386 build).

But, philosophical question, shouldn't the product of two size_t
variables really be an area_t, or something like that?


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sbin/fsck_ffs/inode.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/fsck_ffs/inode.c
diff -u src/sbin/fsck_ffs/inode.c:1.74 src/sbin/fsck_ffs/inode.c:1.75
--- src/sbin/fsck_ffs/inode.c:1.74	Sat Jan 14 12:12:50 2023
+++ src/sbin/fsck_ffs/inode.c	Sat Jan 14 17:01:10 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.c,v 1.74 2023/01/14 12:12:50 christos Exp $	*/
+/*	$NetBSD: inode.c,v 1.75 2023/01/14 17:01:10 kre Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)inode.c	8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: inode.c,v 1.74 2023/01/14 12:12:50 christos Exp $");
+__RCSID("$NetBSD: inode.c,v 1.75 2023/01/14 17:01:10 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -737,7 +737,7 @@ allocino(ino_t request, int type)
 			MAX(2 * inostathead[cg].il_numalloced, 10));
 		info = calloc(newalloced, sizeof(*info));
 		if (info == NULL) {
-			pwarn("cannot alloc %lu bytes to extend inoinfo\n",
+			pwarn("cannot alloc %zu bytes to extend inoinfo\n",
 sizeof(struct inostat) * newalloced);
 			return 0;
 		}



CVS commit: src/sbin/fsck_ffs

2023-01-14 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Jan 14 17:01:11 UTC 2023

Modified Files:
src/sbin/fsck_ffs: inode.c

Log Message:
Use %zu rather than %lu to print a size_t (should fix i386 build).

But, philosophical question, shouldn't the product of two size_t
variables really be an area_t, or something like that?


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sbin/fsck_ffs/inode.c

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



CVS commit: src/sbin/fsck_ffs

2023-01-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 14 12:12:50 UTC 2023

Modified Files:
src/sbin/fsck_ffs: fsck.h inode.c pass4.c utilities.c

Log Message:
catch up with sign changes in the fs.h


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sbin/fsck_ffs/fsck.h
cvs rdiff -u -r1.73 -r1.74 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.29 -r1.30 src/sbin/fsck_ffs/pass4.c
cvs rdiff -u -r1.67 -r1.68 src/sbin/fsck_ffs/utilities.c

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



CVS commit: src/sbin/fsck_ffs

2023-01-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 14 12:12:50 UTC 2023

Modified Files:
src/sbin/fsck_ffs: fsck.h inode.c pass4.c utilities.c

Log Message:
catch up with sign changes in the fs.h


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sbin/fsck_ffs/fsck.h
cvs rdiff -u -r1.73 -r1.74 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.29 -r1.30 src/sbin/fsck_ffs/pass4.c
cvs rdiff -u -r1.67 -r1.68 src/sbin/fsck_ffs/utilities.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/fsck_ffs/fsck.h
diff -u src/sbin/fsck_ffs/fsck.h:1.56 src/sbin/fsck_ffs/fsck.h:1.57
--- src/sbin/fsck_ffs/fsck.h:1.56	Thu Nov 17 01:40:38 2022
+++ src/sbin/fsck_ffs/fsck.h	Sat Jan 14 07:12:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: fsck.h,v 1.56 2022/11/17 06:40:38 chs Exp $	*/
+/*	$NetBSD: fsck.h,v 1.57 2023/01/14 12:12:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -97,7 +97,7 @@ struct inostat {
  * which are described by the following structure.
  */
 extern struct inostatlist {
-	longil_numalloced;  /* number of inodes allocated in this cg */
+	size_t  il_numalloced;  /* number of inodes allocated in this cg */
 	struct inostat *il_stat;/* inostat info for this cylinder group */
 } *inostathead;
 

Index: src/sbin/fsck_ffs/inode.c
diff -u src/sbin/fsck_ffs/inode.c:1.73 src/sbin/fsck_ffs/inode.c:1.74
--- src/sbin/fsck_ffs/inode.c:1.73	Fri Apr 17 05:42:27 2020
+++ src/sbin/fsck_ffs/inode.c	Sat Jan 14 07:12:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.c,v 1.73 2020/04/17 09:42:27 jdolecek Exp $	*/
+/*	$NetBSD: inode.c,v 1.74 2023/01/14 12:12:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)inode.c	8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: inode.c,v 1.73 2020/04/17 09:42:27 jdolecek Exp $");
+__RCSID("$NetBSD: inode.c,v 1.74 2023/01/14 12:12:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -731,11 +731,11 @@ allocino(ino_t request, int type)
 		return (0);
 	cg = ino_to_cg(sblock, ino);
 	/* If necessary, extend the inoinfo array. grow exponentially */
-	if ((ino % sblock->fs_ipg) >= (uint64_t)inostathead[cg].il_numalloced) {
-		unsigned long newalloced, i;
+	if ((ino % sblock->fs_ipg) >= inostathead[cg].il_numalloced) {
+		size_t newalloced, i;
 		newalloced = MIN(sblock->fs_ipg,
 			MAX(2 * inostathead[cg].il_numalloced, 10));
-		info = calloc(newalloced, sizeof(struct inostat));
+		info = calloc(newalloced, sizeof(*info));
 		if (info == NULL) {
 			pwarn("cannot alloc %lu bytes to extend inoinfo\n",
 sizeof(struct inostat) * newalloced);

Index: src/sbin/fsck_ffs/pass4.c
diff -u src/sbin/fsck_ffs/pass4.c:1.29 src/sbin/fsck_ffs/pass4.c:1.30
--- src/sbin/fsck_ffs/pass4.c:1.29	Sat Jan  7 14:41:29 2023
+++ src/sbin/fsck_ffs/pass4.c	Sat Jan 14 07:12:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass4.c,v 1.29 2023/01/07 19:41:29 chs Exp $	*/
+/*	$NetBSD: pass4.c,v 1.30 2023/01/14 12:12:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pass4.c	8.4 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: pass4.c,v 1.29 2023/01/07 19:41:29 chs Exp $");
+__RCSID("$NetBSD: pass4.c,v 1.30 2023/01/14 12:12:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -62,7 +62,8 @@ pass4(void)
 	struct zlncnt *zlnp;
 	union dinode *dp;
 	struct inodesc idesc;
-	int n, i;
+	int n;
+	size_t i;
 	uint32_t cg;
 	struct inostat *info;
 

Index: src/sbin/fsck_ffs/utilities.c
diff -u src/sbin/fsck_ffs/utilities.c:1.67 src/sbin/fsck_ffs/utilities.c:1.68
--- src/sbin/fsck_ffs/utilities.c:1.67	Thu Nov 17 01:40:38 2022
+++ src/sbin/fsck_ffs/utilities.c	Sat Jan 14 07:12:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: utilities.c,v 1.67 2022/11/17 06:40:38 chs Exp $	*/
+/*	$NetBSD: utilities.c,v 1.68 2023/01/14 12:12:50 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utilities.c	8.6 (Berkeley) 5/19/95";
 #else
-__RCSID("$NetBSD: utilities.c,v 1.67 2022/11/17 06:40:38 chs Exp $");
+__RCSID("$NetBSD: utilities.c,v 1.68 2023/01/14 12:12:50 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -590,7 +590,7 @@ inoinfo(ino_t inum)
 {
 	static struct inostat unallocated = { USTATE, 0, 0 };
 	struct inostatlist *ilp;
-	int iloff;
+	size_t iloff;
 
 	if (inum > maxino)
 		errexit("inoinfo: inumber %llu out of range",



CVS commit: src/sbin/fsck_ffs

2023-01-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Jan  8 05:25:25 UTC 2023

Modified Files:
src/sbin/fsck_ffs: pass5.c setup.c

Log Message:
ufs: more signed/unsigned fixes

Fix the previous signed/unsigned fixes to build on 32-bit,
including applying this commit from FreeBSD:

  commit 2d34afcd04207cf3fa3d5b7f467a890eae75da41
  Author: Kirk McKusick 
  Date:   Sun Oct 25 21:04:07 2020 +

Use proper type (ino_t) for inode numbers to avoid improper sign extention
in the Pass 5 checks. The manifestation was fsck_ffs exiting with this 
error:

  ** Phase 5 - Check Cyl groups
  fsck_ffs: inoinfo: inumber 18446744071562087424 out of range

The error only manifests itself for filesystems bigger than about 100Tb.

Reported by:  Nikita Grechikhin 
MFC after:2 weeks
Sponsored by: Netflix


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.105 -r1.106 src/sbin/fsck_ffs/setup.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/fsck_ffs/pass5.c
diff -u src/sbin/fsck_ffs/pass5.c:1.56 src/sbin/fsck_ffs/pass5.c:1.57
--- src/sbin/fsck_ffs/pass5.c:1.56	Sat Jan  7 19:41:29 2023
+++ src/sbin/fsck_ffs/pass5.c	Sun Jan  8 05:25:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass5.c,v 1.56 2023/01/07 19:41:29 chs Exp $	*/
+/*	$NetBSD: pass5.c,v 1.57 2023/01/08 05:25:24 chs Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pass5.c	8.9 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: pass5.c,v 1.56 2023/01/07 19:41:29 chs Exp $");
+__RCSID("$NetBSD: pass5.c,v 1.57 2023/01/08 05:25:24 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -60,12 +60,15 @@ void
 pass5(void)
 {
 	int blk, frags, basesize, sumsize, mapsize, cssize;
-	int inomapsize, blkmapsize;
+	uint32_t inomapsize, blkmapsize;
 	uint32_t c;
 	struct fs *fs = sblock;
 	daddr_t dbase, dmax;
 	daddr_t d;
-	long i, j, k;
+	uint32_t i;
+	int32_t j;
+	int k;
+	ino_t inum;
 	struct csum *cs;
 	struct csum_total cstotal;
 	struct inodesc idesc[4];
@@ -317,9 +320,9 @@ pass5(void)
 		if (!is_ufs2 && ((fs->fs_old_flags & FS_FLAGS_UPDATED) == 0) &&
 		fs->fs_old_postblformat == FS_42POSTBLFMT)
 			ocg->cg_magic = CG_MAGIC;
-		j = fs->fs_ipg * c;
-		for (i = 0; i < fs->fs_ipg; j++, i++) {
-			info = inoinfo(j);
+		inum = fs->fs_ipg * c;
+		for (i = 0; i < fs->fs_ipg; inum++, i++) {
+			info = inoinfo(inum);
 			switch (info->ino_state) {
 
 			case USTATE:
@@ -338,14 +341,14 @@ pass5(void)
 break;
 
 			default:
-if ((ino_t)j < UFS_ROOTINO)
+if (inum < UFS_ROOTINO)
 	break;
-errexit("BAD STATE %d FOR INODE I=%ld",
-info->ino_state, (long)j);
+errexit("BAD STATE %d FOR INODE I=%ju",
+info->ino_state, (uintmax_t)inum);
 			}
 		}
 		if (c == 0)
-			for (i = 0; i < (long)UFS_ROOTINO; i++) {
+			for (i = 0; i < UFS_ROOTINO; i++) {
 setbit(cg_inosused(newcg, 0), i);
 newcg->cg_cs.cs_nifree--;
 			}
@@ -450,7 +453,7 @@ pass5(void)
 		continue;
 	if (cg_inosused(cg, 0)[i] & (1 << k))
 		continue;
-	pwarn("ALLOCATED INODE %ld "
+	pwarn("ALLOCATED INODE %u "
 	"MARKED FREE\n",
 	c * fs->fs_ipg + i * 8 + k);
 }
@@ -464,7 +467,7 @@ pass5(void)
 		continue;
 	if (cg_inosused(cg, 0)[i] & (1 << k))
 		continue;
-	pwarn("ALLOCATED FRAG %ld "
+	pwarn("ALLOCATED FRAG %u "
 	"MARKED FREE\n",
 	c * fs->fs_fpg + i * 8 + k);
 }

Index: src/sbin/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.105 src/sbin/fsck_ffs/setup.c:1.106
--- src/sbin/fsck_ffs/setup.c:1.105	Sat Jan  7 19:41:29 2023
+++ src/sbin/fsck_ffs/setup.c	Sun Jan  8 05:25:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.105 2023/01/07 19:41:29 chs Exp $	*/
+/*	$NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setup.c	8.10 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: setup.c,v 1.105 2023/01/07 19:41:29 chs Exp $");
+__RCSID("$NetBSD: setup.c,v 1.106 2023/01/08 05:25:24 chs Exp $");
 #endif
 #endif /* not lint */
 
@@ -85,7 +85,8 @@ int16_t sblkpostbl[256];
 int
 setup(const char *dev, const char *origdev)
 {
-	long cg, size, asked, i, j;
+	uint32_t cg;
+	long size, asked, i, j;
 	long bmapsize;
 	struct disk_geom geo;
 	struct dkwedge_info dkw;



CVS commit: src/sbin/fsck_ffs

2023-01-07 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Jan  8 05:25:25 UTC 2023

Modified Files:
src/sbin/fsck_ffs: pass5.c setup.c

Log Message:
ufs: more signed/unsigned fixes

Fix the previous signed/unsigned fixes to build on 32-bit,
including applying this commit from FreeBSD:

  commit 2d34afcd04207cf3fa3d5b7f467a890eae75da41
  Author: Kirk McKusick 
  Date:   Sun Oct 25 21:04:07 2020 +

Use proper type (ino_t) for inode numbers to avoid improper sign extention
in the Pass 5 checks. The manifestation was fsck_ffs exiting with this 
error:

  ** Phase 5 - Check Cyl groups
  fsck_ffs: inoinfo: inumber 18446744071562087424 out of range

The error only manifests itself for filesystems bigger than about 100Tb.

Reported by:  Nikita Grechikhin 
MFC after:2 weeks
Sponsored by: Netflix


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.105 -r1.106 src/sbin/fsck_ffs/setup.c

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



CVS commit: src/sbin/fsck_ffs

2022-11-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov 18 07:41:31 UTC 2022

Modified Files:
src/sbin/fsck_ffs: pass1.c

Log Message:
Fix clearing of permissions when finding unexpected extended attributs
for swapped endian file systems. Ok: chs


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/fsck_ffs/pass1.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/fsck_ffs/pass1.c
diff -u src/sbin/fsck_ffs/pass1.c:1.61 src/sbin/fsck_ffs/pass1.c:1.62
--- src/sbin/fsck_ffs/pass1.c:1.61	Thu Nov 17 18:57:16 2022
+++ src/sbin/fsck_ffs/pass1.c	Fri Nov 18 07:41:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass1.c,v 1.61 2022/11/17 18:57:16 martin Exp $	*/
+/*	$NetBSD: pass1.c,v 1.62 2022/11/18 07:41:31 martin Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pass1.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: pass1.c,v 1.61 2022/11/17 18:57:16 martin Exp $");
+__RCSID("$NetBSD: pass1.c,v 1.62 2022/11/18 07:41:31 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -437,7 +437,7 @@ checkinode(ino_t inumber, struct inodesc
 		dp->dp2.di_extsize = iswap32(0);
 		dp->dp2.di_extb[0] = iswap64(0);
 		dp->dp2.di_extb[1] = iswap64(0);
-		dp->dp2.di_mode &= ~0;
+		dp->dp2.di_mode &= iswap16(IFMT);
 		inodirty();
 	}
 	if (is_ufs2ea && iswap32(dp->dp2.di_extsize) > 0) {



CVS commit: src/sbin/fsck_ffs

2022-11-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Nov 18 07:41:31 UTC 2022

Modified Files:
src/sbin/fsck_ffs: pass1.c

Log Message:
Fix clearing of permissions when finding unexpected extended attributs
for swapped endian file systems. Ok: chs


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sbin/fsck_ffs/pass1.c

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



CVS commit: src/sbin/fsck_ffs

2022-11-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Nov 17 18:57:16 UTC 2022

Modified Files:
src/sbin/fsck_ffs: pass1.c

Log Message:
Make the "non-zero exattr fields" message show the inode number.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sbin/fsck_ffs/pass1.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/fsck_ffs/pass1.c
diff -u src/sbin/fsck_ffs/pass1.c:1.60 src/sbin/fsck_ffs/pass1.c:1.61
--- src/sbin/fsck_ffs/pass1.c:1.60	Thu Nov 17 06:40:38 2022
+++ src/sbin/fsck_ffs/pass1.c	Thu Nov 17 18:57:16 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass1.c,v 1.60 2022/11/17 06:40:38 chs Exp $	*/
+/*	$NetBSD: pass1.c,v 1.61 2022/11/17 18:57:16 martin Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pass1.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: pass1.c,v 1.60 2022/11/17 06:40:38 chs Exp $");
+__RCSID("$NetBSD: pass1.c,v 1.61 2022/11/17 18:57:16 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -427,7 +427,8 @@ checkinode(ino_t inumber, struct inodesc
 	(iswap32(dp->dp2.di_extsize) != 0 ||
 	 iswap64(dp->dp2.di_extb[0]) != 0 ||
 	 iswap64(dp->dp2.di_extb[1]) != 0)) {
-		pfatal("NON-ZERO EXTATTR FIELDS");
+		pfatal("NON-ZERO EXTATTR FIELDS I=%llu",
+		(unsigned long long)inumber);
 		if (!reply("CLEAR EXTATTR FIELDS AND SET PERMS TO 0")) {
 			markclean = 0;
 			return;



CVS commit: src/sbin/fsck_ffs

2022-11-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Nov 17 18:57:16 UTC 2022

Modified Files:
src/sbin/fsck_ffs: pass1.c

Log Message:
Make the "non-zero exattr fields" message show the inode number.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sbin/fsck_ffs/pass1.c

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



CVS commit: src/sbin/fsck_ffs

2022-07-24 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jul 25 05:15:08 UTC 2022

Modified Files:
src/sbin/fsck_ffs: wapbl.c

Log Message:
Fix misleading fsck_ffs messages about wapbl journal replay.

Apparently fsck doesn't have a way to replay it to its internal memory
only. (Someone(TM) should implement this...)

This means that if you use -n, it can't replay the journal. But the
sequence of prints is such that it looks like it did. This is quite
misleading. Add an additional specific warning.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/fsck_ffs/wapbl.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/fsck_ffs/wapbl.c
diff -u src/sbin/fsck_ffs/wapbl.c:1.5 src/sbin/fsck_ffs/wapbl.c:1.6
--- src/sbin/fsck_ffs/wapbl.c:1.5	Sat Mar  6 11:31:40 2010
+++ src/sbin/fsck_ffs/wapbl.c	Mon Jul 25 05:15:08 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: wapbl.c,v 1.5 2010/03/06 11:31:40 mlelstv Exp $	*/
+/*	$NetBSD: wapbl.c,v 1.6 2022/07/25 05:15:08 dholland Exp $	*/
 
 /*-
  * Copyright (c) 2005,2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #define WAPBL_INTERNAL
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wapbl.c,v 1.5 2010/03/06 11:31:40 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wapbl.c,v 1.6 2022/07/25 05:15:08 dholland Exp $");
 
 #include 
 #include 
@@ -92,7 +92,16 @@ replay_wapbl(void)
 {
 	int error;
 
-	if (!nflag) {
+	if (nflag) {
+		/*
+		 * XXX: we ought to have a mode where we can replay
+		 * the journal to memory, similar to what happens in
+		 * the kernel with a readonly mount. For now though
+		 * just print that we aren't doing it so as to avoid
+		 * lying to the user.
+		 */
+		pwarn("CANNOT REPLAY JOURNAL IN -n MODE; continuing anyway\n");
+	} else {
 		error = wapbl_replay_write(wapbl_replay, 0);
 		if (error) {
 			pfatal("UNABLE TO REPLAY JOURNAL BLOCKS");



CVS commit: src/sbin/fsck_ffs

2022-07-24 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Jul 25 05:15:08 UTC 2022

Modified Files:
src/sbin/fsck_ffs: wapbl.c

Log Message:
Fix misleading fsck_ffs messages about wapbl journal replay.

Apparently fsck doesn't have a way to replay it to its internal memory
only. (Someone(TM) should implement this...)

This means that if you use -n, it can't replay the journal. But the
sequence of prints is such that it looks like it did. This is quite
misleading. Add an additional specific warning.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/fsck_ffs/wapbl.c

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



CVS commit: src/sbin/fsck_ffs

2020-04-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr 19 19:37:07 UTC 2020

Modified Files:
src/sbin/fsck_ffs: pass1.c

Log Message:
Enable the code to clean the extattr blocks


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sbin/fsck_ffs/pass1.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/fsck_ffs/pass1.c
diff -u src/sbin/fsck_ffs/pass1.c:1.58 src/sbin/fsck_ffs/pass1.c:1.59
--- src/sbin/fsck_ffs/pass1.c:1.58	Tue Feb 13 06:20:08 2018
+++ src/sbin/fsck_ffs/pass1.c	Sun Apr 19 15:37:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass1.c,v 1.58 2018/02/13 11:20:08 hannken Exp $	*/
+/*	$NetBSD: pass1.c,v 1.59 2020/04/19 19:37:06 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pass1.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: pass1.c,v 1.58 2018/02/13 11:20:08 hannken Exp $");
+__RCSID("$NetBSD: pass1.c,v 1.59 2020/04/19 19:37:06 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -423,7 +423,6 @@ checkinode(ino_t inumber, struct inodesc
 	else
 		idesc->id_type = ADDR;
 	(void)ckinode(dp, idesc);
-#ifdef notyet
 	if (is_ufs2 && iswap32(dp->dp2.di_extsize) > 0) {
 		int ret, offset;
 		idesc->id_type = ADDR;
@@ -443,7 +442,6 @@ checkinode(ino_t inumber, struct inodesc
 break;
 		}
 	}
-#endif
 	idesc->id_entryno *= btodb(sblock->fs_fsize);
 	if (is_ufs2)
 		blocks = iswap64(dp->dp2.di_blocks);



CVS commit: src/sbin/fsck_ffs

2020-04-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Apr 19 19:37:07 UTC 2020

Modified Files:
src/sbin/fsck_ffs: pass1.c

Log Message:
Enable the code to clean the extattr blocks


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sbin/fsck_ffs/pass1.c

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



CVS commit: src/sbin/fsck_ffs

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

Modified Files:
src/sbin/fsck_ffs: inode.c setup.c utilities.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.102 -r1.103 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.65 -r1.66 src/sbin/fsck_ffs/utilities.c

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



CVS commit: src/sbin/fsck_ffs

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

Modified Files:
src/sbin/fsck_ffs: inode.c setup.c utilities.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sbin/fsck_ffs/inode.c
cvs rdiff -u -r1.102 -r1.103 src/sbin/fsck_ffs/setup.c
cvs rdiff -u -r1.65 -r1.66 src/sbin/fsck_ffs/utilities.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/fsck_ffs/inode.c
diff -u src/sbin/fsck_ffs/inode.c:1.72 src/sbin/fsck_ffs/inode.c:1.73
--- src/sbin/fsck_ffs/inode.c:1.72	Wed Feb  8 16:11:40 2017
+++ src/sbin/fsck_ffs/inode.c	Fri Apr 17 09:42:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.c,v 1.72 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: inode.c,v 1.73 2020/04/17 09:42:27 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)inode.c	8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: inode.c,v 1.72 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: inode.c,v 1.73 2020/04/17 09:42:27 jdolecek Exp $");
 #endif
 #endif /* not lint */
 
@@ -463,7 +463,7 @@ setinodebuf(ino_t inum)
 		partialsize = inobufsize;
 	}
 	if (inodebuf == NULL &&
-	(inodebuf = malloc((unsigned)inobufsize)) == NULL)
+	(inodebuf = aligned_alloc(DEV_BSIZE, (unsigned)inobufsize)) == NULL)
 		errexit("Cannot allocate space for inode buffer");
 }
 

Index: src/sbin/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.102 src/sbin/fsck_ffs/setup.c:1.103
--- src/sbin/fsck_ffs/setup.c:1.102	Fri Oct  5 09:49:23 2018
+++ src/sbin/fsck_ffs/setup.c	Fri Apr 17 09:42:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.102 2018/10/05 09:49:23 hannken Exp $	*/
+/*	$NetBSD: setup.c,v 1.103 2020/04/17 09:42:27 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setup.c	8.10 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: setup.c,v 1.102 2018/10/05 09:49:23 hannken Exp $");
+__RCSID("$NetBSD: setup.c,v 1.103 2020/04/17 09:42:27 jdolecek Exp $");
 #endif
 #endif /* not lint */
 
@@ -126,10 +126,10 @@ setup(const char *dev, const char *origd
 	lfdir = 0;
 	initbarea();
 	initbarea();
-	sblk.b_un.b_buf = malloc(SBLOCKSIZE);
-	sblock = malloc(SBLOCKSIZE);
-	asblk.b_un.b_buf = malloc(SBLOCKSIZE);
-	altsblock = malloc(SBLOCKSIZE);
+	sblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
+	sblock = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
+	asblk.b_un.b_buf = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
+	altsblock = aligned_alloc(DEV_BSIZE, SBLOCKSIZE);
 	if (sblk.b_un.b_buf == NULL || asblk.b_un.b_buf == NULL ||
 		sblock == NULL || altsblock == NULL)
 		errexit("Cannot allocate space for superblock");
@@ -458,12 +458,14 @@ setup(const char *dev, const char *origd
 	 * read in the summary info.
 	 */
 	asked = 0;
-	sblock->fs_csp = (struct csum *)calloc(1, sblock->fs_cssize);
+	sblock->fs_csp = (struct csum *)aligned_alloc(DEV_BSIZE,
+	sblock->fs_cssize);
 	if (sblock->fs_csp == NULL) {
 		pwarn("cannot alloc %u bytes for summary info\n",
 		sblock->fs_cssize);	
 		goto badsblabel;
 	}
+	memset(sblock->fs_csp, 0, sblock->fs_cssize);
 	for (i = 0, j = 0; i < sblock->fs_cssize; i += sblock->fs_bsize, j++) {
 		size = sblock->fs_cssize - i < sblock->fs_bsize ?
 		sblock->fs_cssize - i : sblock->fs_bsize;
@@ -492,12 +494,13 @@ setup(const char *dev, const char *origd
 	 * allocate and initialize the necessary maps
 	 */
 	bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));
-	blockmap = calloc((unsigned)bmapsize, sizeof (char));
+	blockmap = aligned_alloc(DEV_BSIZE, (unsigned)bmapsize);
 	if (blockmap == NULL) {
 		pwarn("cannot alloc %u bytes for blockmap\n",
 		(unsigned)bmapsize);
 		goto badsblabel;
 	}
+	memset(blockmap, 0, bmapsize);
 	inostathead = calloc((unsigned)(sblock->fs_ncg),
 	sizeof(struct inostatlist));
 	if (inostathead == NULL) {
@@ -526,7 +529,7 @@ setup(const char *dev, const char *origd
 		(unsigned)(numdirs * sizeof(struct inoinfo *)));
 		goto badsblabel;
 	}
-	cgrp = malloc(sblock->fs_cgsize);
+	cgrp = aligned_alloc(DEV_BSIZE, sblock->fs_cgsize);
 	if (cgrp == NULL) {
 		pwarn("cannot alloc %u bytes for cylinder group\n",
 		sblock->fs_cgsize);

Index: src/sbin/fsck_ffs/utilities.c
diff -u src/sbin/fsck_ffs/utilities.c:1.65 src/sbin/fsck_ffs/utilities.c:1.66
--- src/sbin/fsck_ffs/utilities.c:1.65	Wed Feb  8 16:11:40 2017
+++ src/sbin/fsck_ffs/utilities.c	Fri Apr 17 09:42:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: utilities.c,v 1.65 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: utilities.c,v 1.66 2020/04/17 09:42:27 jdolecek Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)utilities.c	8.6 (Berkeley) 5/19/95";
 #else
-__RCSID("$NetBSD: utilities.c,v 1.65 

CVS commit: src/sbin/fsck_ffs

2020-04-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr  6 09:54:24 UTC 2020

Modified Files:
src/sbin/fsck_ffs: main.c

Log Message:
Sync "common" declarations with ifdefs in header.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sbin/fsck_ffs/main.c

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



CVS commit: src/sbin/fsck_ffs

2020-04-06 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr  6 09:54:24 UTC 2020

Modified Files:
src/sbin/fsck_ffs: main.c

Log Message:
Sync "common" declarations with ifdefs in header.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sbin/fsck_ffs/main.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/fsck_ffs/main.c
diff -u src/sbin/fsck_ffs/main.c:1.88 src/sbin/fsck_ffs/main.c:1.89
--- src/sbin/fsck_ffs/main.c:1.88	Mon Apr  6 06:41:34 2020
+++ src/sbin/fsck_ffs/main.c	Mon Apr  6 09:54:24 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.88 2020/04/06 06:41:34 mrg Exp $	*/
+/*	$NetBSD: main.c,v 1.89 2020/04/06 09:54:24 martin Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.6 (Berkeley) 5/14/95";
 #else
-__RCSID("$NetBSD: main.c,v 1.88 2020/04/06 06:41:34 mrg Exp $");
+__RCSID("$NetBSD: main.c,v 1.89 2020/04/06 09:54:24 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -117,12 +117,14 @@ int	rerun;
 char	resolved;
 #ifndef NO_FFS_EI
 int	endian;
-#endif
 int	doswap;
 int	needswap;
 int	do_blkswap;
 int	do_dirswap;
+#endif
+#ifndef NO_APPLE_UFS
 int	isappleufs;
+#endif
 daddr_t maxfsblock;
 char	*blockmap;
 ino_t	maxino;



CVS commit: src/sbin/fsck_ffs

2020-04-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Apr  6 06:41:34 UTC 2020

Modified Files:
src/sbin/fsck_ffs: main.c

Log Message:
dion't define endian as well as try to declare it as a variable.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sbin/fsck_ffs/main.c

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



CVS commit: src/sbin/fsck_ffs

2020-04-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Apr  6 06:41:34 UTC 2020

Modified Files:
src/sbin/fsck_ffs: main.c

Log Message:
dion't define endian as well as try to declare it as a variable.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/sbin/fsck_ffs/main.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/fsck_ffs/main.c
diff -u src/sbin/fsck_ffs/main.c:1.87 src/sbin/fsck_ffs/main.c:1.88
--- src/sbin/fsck_ffs/main.c:1.87	Sun Apr  5 15:25:40 2020
+++ src/sbin/fsck_ffs/main.c	Mon Apr  6 06:41:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.87 2020/04/05 15:25:40 joerg Exp $	*/
+/*	$NetBSD: main.c,v 1.88 2020/04/06 06:41:34 mrg Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.6 (Berkeley) 5/14/95";
 #else
-__RCSID("$NetBSD: main.c,v 1.87 2020/04/05 15:25:40 joerg Exp $");
+__RCSID("$NetBSD: main.c,v 1.88 2020/04/06 06:41:34 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -115,7 +115,9 @@ int	fsreadfd;
 int	fswritefd;
 int	rerun;
 char	resolved;
+#ifndef NO_FFS_EI
 int	endian;
+#endif
 int	doswap;
 int	needswap;
 int	do_blkswap;



CVS commit: src/sbin/fsck_ffs

2019-05-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May  5 14:59:07 UTC 2019

Modified Files:
src/sbin/fsck_ffs: dir.c fsck.h fsck_ffs.8 main.c

Log Message:
Add a -z flag to zero out the up to 4 bytes of padding in directory entry
names (including the terminating NUL), as well as directory entries with
extra free space (d->d_reclen > UFS_DIRSIZ(d)).

Inspired from FreeBSD:
https://svnweb.freebsd.org/base?view=revision=347066

While the kernel has been fixed to deal with the padding bytes (new
kernels will correctly zero out all the padding after the name), it
appears that there is still an issue with directory entries with extra
free space, since a newly created and populated filesystem gets modified
with "fsck_ffs -z".


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sbin/fsck_ffs/dir.c
cvs rdiff -u -r1.52 -r1.53 src/sbin/fsck_ffs/fsck.h
cvs rdiff -u -r1.50 -r1.51 src/sbin/fsck_ffs/fsck_ffs.8
cvs rdiff -u -r1.84 -r1.85 src/sbin/fsck_ffs/main.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/fsck_ffs/dir.c
diff -u src/sbin/fsck_ffs/dir.c:1.60 src/sbin/fsck_ffs/dir.c:1.61
--- src/sbin/fsck_ffs/dir.c:1.60	Sun May  5 09:24:19 2019
+++ src/sbin/fsck_ffs/dir.c	Sun May  5 10:59:06 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.60 2019/05/05 13:24:19 christos Exp $	*/
+/*	$NetBSD: dir.c,v 1.61 2019/05/05 14:59:06 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)dir.c	8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: dir.c,v 1.60 2019/05/05 13:24:19 christos Exp $");
+__RCSID("$NetBSD: dir.c,v 1.61 2019/05/05 14:59:06 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -85,7 +85,7 @@ struct	odirtemplate odirhead = {
 };
 
 static int chgino(struct  inodesc *);
-static int dircheck(struct inodesc *, struct direct *);
+static int dircheck(struct inodesc *, struct direct *, struct bufarea *);
 static int expanddir(union dinode *, char *);
 static void freedir(ino_t, ino_t);
 static struct direct *fsck_readdir(struct inodesc *);
@@ -251,7 +251,7 @@ fsck_readdir(struct inodesc *idesc)
 	if (idesc->id_loc % dirblksiz == 0 && idesc->id_filesize > 0 &&
 	idesc->id_loc < blksiz) {
 		dp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc);
-		if (dircheck(idesc, dp))
+		if (dircheck(idesc, dp, bp))
 			goto dpok;
 		if (idesc->id_fix == IGNORE)
 			return (0);
@@ -282,7 +282,7 @@ dpok:
 		return (dp);
 	ndp = (struct direct *)(bp->b_un.b_buf + idesc->id_loc);
 	if (idesc->id_loc < blksiz && idesc->id_filesize > 0 &&
-	dircheck(idesc, ndp) == 0) {
+	dircheck(idesc, ndp, bp) == 0) {
 		size = dirblksiz - (idesc->id_loc % dirblksiz);
 		idesc->id_loc += size;
 		idesc->id_filesize -= size;
@@ -303,24 +303,25 @@ dpok:
 /*
  * Verify that a directory entry is valid.
  * This is a superset of the checks made in the kernel.
+ * Returns:
+ *	1: good
+ *	0: bad
  */
 static int
-dircheck(struct inodesc *idesc, struct direct *dp)
+dircheck(struct inodesc *idesc, struct direct *dp, struct bufarea *bp) 
 {
-	int size;
+	uint8_t namlen, type;
+	uint16_t reclen;
+	uint32_t ino;
 	char *cp;
-	u_char namlen, type;
-	int spaceleft;
+	int size, spaceleft, modified, unused, i;
 
+	modified = 0;
 	spaceleft = dirblksiz - (idesc->id_loc % dirblksiz);
-	if (iswap32(dp->d_ino) >= maxino ||
-	dp->d_reclen == 0 ||
-	iswap16(dp->d_reclen) > spaceleft ||
-	(iswap16(dp->d_reclen) & 0x3) != 0) 
-		return (0);
-	if (dp->d_ino == 0)
-		return (1);
-	size = UFS_DIRSIZ(!newinofmt, dp, needswap);
+
+	/* fill in the correct info for our fields */
+	ino = iswap32(dp->d_ino);
+	reclen = iswap16(dp->d_reclen);
 	if (!newinofmt && NEEDSWAP) {
 		type = dp->d_namlen;
 		namlen = dp->d_type;
@@ -328,17 +329,84 @@ dircheck(struct inodesc *idesc, struct d
 		namlen = dp->d_namlen;
 		type = dp->d_type;
 	}
-	if (iswap16(dp->d_reclen) < size ||
-	idesc->id_filesize < size ||
+
+	if (ino >= maxino ||
+	reclen == 0 || reclen > spaceleft || (reclen & 0x3) != 0)
+		goto bad;
+
+	size = UFS_DIRSIZ(!newinofmt, dp, needswap);
+	if (ino == 0) {
+		/*
+		 * Special case of an unused directory entry. Normally
+		 * the kernel would coalesce unused space with the previous
+		 * entry by extending its d_reclen, but there are situations
+		 * (e.g. fsck) where that doesn't occur.
+		 * If we're clearing out directory cruft (-z flag), then make
+		 * sure this entry gets fully cleared as well.
+		 */
+		if (!zflag || fswritefd < 0)
+			return 1;
+
+		if (dp->d_type != 0) {
+			dp->d_type = 0;
+			modified = 1;
+		}
+		if (dp->d_namlen != 0) {
+			dp->d_namlen = 0;
+			modified = 1;
+		}
+		if (dp->d_name[0] != '\0') {
+			dp->d_name[0] = '\0';
+			modified = 1;
+		}
+		goto good;
+	}
+
+	if (reclen < size || idesc->id_filesize < size ||
 	/* namlen > MAXNAMLEN || */
 	type > 15)
-		return (0);
-	for (cp = dp->d_name, size = 0; size < 

CVS commit: src/sbin/fsck_ffs

2019-05-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May  5 14:59:07 UTC 2019

Modified Files:
src/sbin/fsck_ffs: dir.c fsck.h fsck_ffs.8 main.c

Log Message:
Add a -z flag to zero out the up to 4 bytes of padding in directory entry
names (including the terminating NUL), as well as directory entries with
extra free space (d->d_reclen > UFS_DIRSIZ(d)).

Inspired from FreeBSD:
https://svnweb.freebsd.org/base?view=revision=347066

While the kernel has been fixed to deal with the padding bytes (new
kernels will correctly zero out all the padding after the name), it
appears that there is still an issue with directory entries with extra
free space, since a newly created and populated filesystem gets modified
with "fsck_ffs -z".


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sbin/fsck_ffs/dir.c
cvs rdiff -u -r1.52 -r1.53 src/sbin/fsck_ffs/fsck.h
cvs rdiff -u -r1.50 -r1.51 src/sbin/fsck_ffs/fsck_ffs.8
cvs rdiff -u -r1.84 -r1.85 src/sbin/fsck_ffs/main.c

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



CVS commit: src/sbin/fsck_ffs

2019-05-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May  5 13:24:19 UTC 2019

Modified Files:
src/sbin/fsck_ffs: dir.c

Log Message:
simplify the endian byte-swapping code.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sbin/fsck_ffs/dir.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/fsck_ffs/dir.c
diff -u src/sbin/fsck_ffs/dir.c:1.59 src/sbin/fsck_ffs/dir.c:1.60
--- src/sbin/fsck_ffs/dir.c:1.59	Thu Nov  8 01:34:40 2018
+++ src/sbin/fsck_ffs/dir.c	Sun May  5 09:24:19 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.59 2018/11/08 06:34:40 msaitoh Exp $	*/
+/*	$NetBSD: dir.c,v 1.60 2019/05/05 13:24:19 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)dir.c	8.8 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: dir.c,v 1.59 2018/11/08 06:34:40 msaitoh Exp $");
+__RCSID("$NetBSD: dir.c,v 1.60 2019/05/05 13:24:19 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -144,6 +144,23 @@ reparent(ino_t inumber, ino_t parent)
 	propagate(inumber);
 }
 
+#if (BYTE_ORDER == LITTLE_ENDIAN)
+# define NEEDSWAP	(!needswap)
+#else
+# define NEEDSWAP	(needswap)
+#endif
+
+static void
+dirswap(void *dbuf)
+{
+	struct direct *tdp = (struct direct *)dbuf;
+	u_char tmp;
+
+	tmp = tdp->d_namlen;
+	tdp->d_namlen = tdp->d_type;
+	tdp->d_type = tmp;
+}
+
 /*
  * Scan each entry in a directory block.
  */
@@ -201,33 +218,12 @@ dirscan(struct inodesc *idesc)
 		if (dsize > (int)sizeof dbuf)
 			dsize = sizeof dbuf;
 		memmove(dbuf, dp, (size_t)dsize);
-#		if (BYTE_ORDER == LITTLE_ENDIAN)
-			if (!newinofmt && !needswap) {
-#		else
-			if (!newinofmt && needswap) {
-#		endif
-struct direct *tdp = (struct direct *)dbuf;
-u_char tmp;
-
-tmp = tdp->d_namlen;
-tdp->d_namlen = tdp->d_type;
-tdp->d_type = tmp;
-			}
+		if (!newinofmt && NEEDSWAP)
+			dirswap(dbuf);
 		idesc->id_dirp = (struct direct *)dbuf;
 		if ((n = (*idesc->id_func)(idesc)) & ALTERED) {
-#			if (BYTE_ORDER == LITTLE_ENDIAN)
-if (!newinofmt && !doinglevel2 && !needswap) {
-#			else
-if (!newinofmt && !doinglevel2 && needswap) {
-#			endif
-	struct direct *tdp;
-	u_char tmp;
-
-	tdp = (struct direct *)dbuf;
-	tmp = tdp->d_namlen;
-	tdp->d_namlen = tdp->d_type;
-	tdp->d_type = tmp;
-}
+			if (!newinofmt && !doinglevel2 && NEEDSWAP)
+dirswap(dbuf);
 			bp = getdirblk(idesc->id_blkno, blksiz);
 			memmove(bp->b_un.b_buf + idesc->id_loc - dsize, dbuf,
 			(size_t)dsize);
@@ -325,17 +321,13 @@ dircheck(struct inodesc *idesc, struct d
 	if (dp->d_ino == 0)
 		return (1);
 	size = UFS_DIRSIZ(!newinofmt, dp, needswap);
-#	if (BYTE_ORDER == LITTLE_ENDIAN)
-		if (!newinofmt && !needswap) {
-#	else
-		if (!newinofmt && needswap) {
-#	endif
-			type = dp->d_namlen;
-			namlen = dp->d_type;
-		} else {
-			namlen = dp->d_namlen;
-			type = dp->d_type;
-		}
+	if (!newinofmt && NEEDSWAP) {
+		type = dp->d_namlen;
+		namlen = dp->d_type;
+	} else {
+		namlen = dp->d_namlen;
+		type = dp->d_type;
+	}
 	if (iswap16(dp->d_reclen) < size ||
 	idesc->id_filesize < size ||
 	/* namlen > MAXNAMLEN || */
@@ -469,23 +461,14 @@ mkentry(struct inodesc *idesc)
 		dirp->d_type = 0;
 	dirp->d_namlen = newent.d_namlen;
 	memmove(dirp->d_name, idesc->id_name, (size_t)newent.d_namlen + 1);
-#	if (BYTE_ORDER == LITTLE_ENDIAN)
-		/*
-		 * If the entry was split, dirscan() will only reverse the byte
-		 * order of the original entry, and not the new one, before
-		 * writing it back out.  So, we reverse the byte order here if
-		 * necessary.
-		 */
-		if (oldlen != 0 && !newinofmt && !doinglevel2 && !needswap) {
-#	else
-		if (oldlen != 0 && !newinofmt && !doinglevel2 && needswap) {
-#	endif
-			u_char tmp;
-
-			tmp = dirp->d_namlen;
-			dirp->d_namlen = dirp->d_type;
-			dirp->d_type = tmp;
-		}
+	/*
+	 * If the entry was split, dirscan() will only reverse the byte
+	 * order of the original entry, and not the new one, before
+	 * writing it back out.  So, we reverse the byte order here if
+	 * necessary.
+	 */
+	if (oldlen != 0 && !newinofmt && !doinglevel2 && NEEDSWAP)
+		dirswap(dirp);
 	return (ALTERED|STOP);
 }
 



CVS commit: src/sbin/fsck_ffs

2019-05-05 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun May  5 13:24:19 UTC 2019

Modified Files:
src/sbin/fsck_ffs: dir.c

Log Message:
simplify the endian byte-swapping code.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sbin/fsck_ffs/dir.c

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



CVS commit: src/sbin/fsck_ffs

2018-10-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct  5 09:49:23 UTC 2018

Modified Files:
src/sbin/fsck_ffs: setup.c

Log Message:
Add a test for duplicate inodes on the persistent snapshot list.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sbin/fsck_ffs/setup.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/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.101 src/sbin/fsck_ffs/setup.c:1.102
--- src/sbin/fsck_ffs/setup.c:1.101	Wed Feb  8 16:11:40 2017
+++ src/sbin/fsck_ffs/setup.c	Fri Oct  5 09:49:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.101 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: setup.c,v 1.102 2018/10/05 09:49:23 hannken Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)setup.c	8.10 (Berkeley) 5/9/95";
 #else
-__RCSID("$NetBSD: setup.c,v 1.101 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: setup.c,v 1.102 2018/10/05 09:49:23 hannken Exp $");
 #endif
 #endif /* not lint */
 
@@ -73,6 +73,7 @@ static int readsb(int);
 #ifndef NO_APPLE_UFS
 static int readappleufs(void);
 #endif
+static int check_snapinum(void);
 
 int16_t sblkpostbl[256];
 
@@ -341,6 +342,14 @@ setup(const char *dev, const char *origd
 			dirty();
 		}
 	}
+	if (check_snapinum()) {
+		if (preen)
+			printf(" (FIXED)\n");
+		if (preen || reply("FIX") == 1) {
+			sbdirty();
+			dirty();
+		}
+	}
 	if (is_ufs2 || sblock->fs_old_inodefmt >= FS_44INODEFMT) {
 		if (sblock->fs_maxfilesize != maxfilesize) {
 			pwarn("INCORRECT MAXFILESIZE=%lld IN SUPERBLOCK",
@@ -1094,3 +1103,42 @@ calcsb(const char *dev, int devfd, struc
 	}
 	return (1);
 }
+
+/*
+ * Test the list of snapshot inode numbers for duplicates and repair.
+ */
+static int
+check_snapinum(void)
+{
+	int loc, loc2, res;
+	int *snapinum = >fs_snapinum[0];
+
+	res = 0;
+ 
+	if (isappleufs)
+		return 0;
+
+	for (loc = 0; loc < FSMAXSNAP; loc++) {
+		if (snapinum[loc] == 0)
+			break;
+		for (loc2 = loc + 1; loc2 < FSMAXSNAP; loc2++) {
+			if (snapinum[loc2] == 0 ||
+			snapinum[loc2] == snapinum[loc])
+break;
+		}
+		if (loc2 >= FSMAXSNAP || snapinum[loc2] == 0)
+			continue;
+		pwarn("SNAPSHOT INODE %u ALREADY ON LIST%s", snapinum[loc2],
+		(res ? "" : "\n"));
+		res = 1;
+		for (loc2 = loc + 1; loc2 < FSMAXSNAP; loc2++) {
+			if (snapinum[loc2] == 0)
+break;
+			snapinum[loc2 - 1] = snapinum[loc2];
+		}
+		snapinum[loc2 - 1] = 0;
+		loc--;
+	}
+
+	return res;
+}



CVS commit: src/sbin/fsck_ffs

2018-10-05 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Fri Oct  5 09:49:23 UTC 2018

Modified Files:
src/sbin/fsck_ffs: setup.c

Log Message:
Add a test for duplicate inodes on the persistent snapshot list.


To generate a diff of this commit:
cvs rdiff -u -r1.101 -r1.102 src/sbin/fsck_ffs/setup.c

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



CVS commit: src/sbin/fsck_ffs

2018-02-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Feb 13 11:20:08 UTC 2018

Modified Files:
src/sbin/fsck_ffs: pass1.c

Log Message:
Treat an inode with "mode == 0" and "blocks != 0" as partially allocated
and clear it as ffs_newvnode() tests for "blocks == 0".


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sbin/fsck_ffs/pass1.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/fsck_ffs/pass1.c
diff -u src/sbin/fsck_ffs/pass1.c:1.57 src/sbin/fsck_ffs/pass1.c:1.58
--- src/sbin/fsck_ffs/pass1.c:1.57	Wed Feb  8 16:11:40 2017
+++ src/sbin/fsck_ffs/pass1.c	Tue Feb 13 11:20:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass1.c,v 1.57 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: pass1.c,v 1.58 2018/02/13 11:20:08 hannken Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)pass1.c	8.6 (Berkeley) 4/28/95";
 #else
-__RCSID("$NetBSD: pass1.c,v 1.57 2017/02/08 16:11:40 rin Exp $");
+__RCSID("$NetBSD: pass1.c,v 1.58 2018/02/13 11:20:08 hannken Exp $");
 #endif
 #endif /* not lint */
 
@@ -253,8 +253,9 @@ checkinode(ino_t inumber, struct inodesc
 		(memcmp(dp->dp1.di_db, ufs1_zino.di_db,
 			UFS_NDADDR * sizeof(int32_t)) ||
 		memcmp(dp->dp1.di_ib, ufs1_zino.di_ib,
-			UFS_NIADDR * sizeof(int32_t ||
-		mode || size) {
+			UFS_NIADDR * sizeof(int32_t
+		||
+		mode || size || DIP(dp, blocks)) {
 			pfatal("PARTIALLY ALLOCATED INODE I=%llu",
 			(unsigned long long)inumber);
 			if (reply("CLEAR") == 1) {



CVS commit: src/sbin/fsck_ffs

2018-02-13 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Tue Feb 13 11:20:08 UTC 2018

Modified Files:
src/sbin/fsck_ffs: pass1.c

Log Message:
Treat an inode with "mode == 0" and "blocks != 0" as partially allocated
and clear it as ffs_newvnode() tests for "blocks == 0".


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sbin/fsck_ffs/pass1.c

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



CVS commit: src/sbin/fsck_ffs

2017-02-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  8 16:23:24 UTC 2017

Modified Files:
src/sbin/fsck_ffs: fsck.h

Log Message:
use __empty


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sbin/fsck_ffs/fsck.h

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



CVS commit: src/sbin/fsck_ffs

2017-02-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  8 16:23:24 UTC 2017

Modified Files:
src/sbin/fsck_ffs: fsck.h

Log Message:
use __empty


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sbin/fsck_ffs/fsck.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/fsck_ffs/fsck.h
diff -u src/sbin/fsck_ffs/fsck.h:1.50 src/sbin/fsck_ffs/fsck.h:1.51
--- src/sbin/fsck_ffs/fsck.h:1.50	Wed Feb  8 11:11:40 2017
+++ src/sbin/fsck_ffs/fsck.h	Wed Feb  8 11:23:24 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: fsck.h,v 1.50 2017/02/08 16:11:40 rin Exp $	*/
+/*	$NetBSD: fsck.h,v 1.51 2017/02/08 16:23:24 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -307,11 +307,11 @@ int	do_dirswap;		/* need to do dir entry
 #define	needswap 		(0)
 #define	do_blkswap		(0)
 #define	do_dirswap		(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_sb_swap(a, b)	do {} while (/*CONSTCOND*/0)
-#define	swap_dinode1(a, b)	do {} while (/*CONSTCOND*/0)
-#define	swap_dinode2(a, b)	do {} while (/*CONSTCOND*/0)
+#define	ffs_cg_swap(a, b, c)	__empty
+#define	ffs_csum_swap(a, b, c)	__empty
+#define	ffs_sb_swap(a, b)	__empty
+#define	swap_dinode1(a, b)	__empty
+#define	swap_dinode2(a, b)	__empty
 #endif
 
 #ifndef NO_APPLE_UFS



CVS commit: src/sbin/fsck_ffs

2017-02-07 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb  7 16:14:48 UTC 2017

Modified Files:
src/sbin/fsck_ffs: Makefile

Log Message:
Do not compile in progress.c when SMALLPROG is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sbin/fsck_ffs/Makefile

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



CVS commit: src/sbin/fsck_ffs

2017-02-07 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Feb  7 16:14:48 UTC 2017

Modified Files:
src/sbin/fsck_ffs: Makefile

Log Message:
Do not compile in progress.c when SMALLPROG is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sbin/fsck_ffs/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/fsck_ffs/Makefile
diff -u src/sbin/fsck_ffs/Makefile:1.46 src/sbin/fsck_ffs/Makefile:1.47
--- src/sbin/fsck_ffs/Makefile:1.46	Wed Mar 23 21:43:33 2016
+++ src/sbin/fsck_ffs/Makefile	Tue Feb  7 16:14:47 2017
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.46 2016/03/23 21:43:33 christos Exp $
+#	$NetBSD: Makefile,v 1.47 2017/02/07 16:14:47 rin Exp $
 #	@(#)Makefile	8.2 (Berkeley) 4/27/95
 
 .include 
@@ -14,8 +14,8 @@ DUMP=	${NETBSDSRCDIR}/sbin/dump
 CPPFLAGS+=-I${FSCK} -I${DUMP}
 .ifndef  SMALLPROG
 CPPFLAGS+=-DPROGRESS
-.endif
 SRCS+=	progress.c
+.endif
 .PATH:	${FSCK}
 
 .PATH:	${NETBSDSRCDIR}/sys/ufs/ffs ${NETBSDSRCDIR}/sys/ufs/ufs ${FSCK} ${DUMP}



CVS commit: src/sbin/fsck_ffs

2016-09-10 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Sep 11 04:07:38 UTC 2016

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

Log Message:
Document the version fsck_ffs first appeared.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sbin/fsck_ffs/fsck_ffs.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/fsck_ffs/fsck_ffs.8
diff -u src/sbin/fsck_ffs/fsck_ffs.8:1.49 src/sbin/fsck_ffs/fsck_ffs.8:1.50
--- src/sbin/fsck_ffs/fsck_ffs.8:1.49	Tue Mar  6 10:30:20 2012
+++ src/sbin/fsck_ffs/fsck_ffs.8	Sun Sep 11 04:07:38 2016
@@ -1,4 +1,4 @@
-.\"	$NetBSD: fsck_ffs.8,v 1.49 2012/03/06 10:30:20 wiz Exp $
+.\"	$NetBSD: fsck_ffs.8,v 1.50 2016/09/11 04:07:38 sevan Exp $
 .\"
 .\" Copyright (c) 1980, 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	@(#)fsck.8	8.3 (Berkeley) 11/29/94
 .\"
-.Dd March 6, 2012
+.Dd September 11, 2016
 .Dt FSCK_FFS 8
 .Os
 .Sh NAME
@@ -375,3 +375,14 @@ are fully enumerated and explained in Ap
 .Xr newfs 8 ,
 .Xr reboot 8 ,
 .Xr scan_ffs 8
+.Sh HISTORY
+A
+.Nm fsck
+utility appeared in
+.Bx 4.0 .
+It was renamed to
+.Nm
+in
+.Nx 1.3
+with the introduction of a filesystem independent wrapper as
+.Nm fsck .



CVS commit: src/sbin/fsck_ffs

2016-09-10 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Sep 11 04:07:38 UTC 2016

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

Log Message:
Document the version fsck_ffs first appeared.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sbin/fsck_ffs/fsck_ffs.8

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



CVS commit: src/sbin/fsck_ffs

2013-12-02 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Dec  2 18:46:52 UTC 2013

Modified Files:
src/sbin/fsck_ffs: inode.c

Log Message:
Fix pasto in the !ufs2 case (use dp-dp1 and not of dp-dp2).
This would be a problem only when allocating a new data block and the
indir block is already allocated, which explains why automated tests didn't
find it.
Problem reported on tech-kern@ and fix tested by manu@.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sbin/fsck_ffs/inode.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/fsck_ffs/inode.c
diff -u src/sbin/fsck_ffs/inode.c:1.69 src/sbin/fsck_ffs/inode.c:1.70
--- src/sbin/fsck_ffs/inode.c:1.69	Sun Jun 23 22:03:34 2013
+++ src/sbin/fsck_ffs/inode.c	Mon Dec  2 18:46:52 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: inode.c,v 1.69 2013/06/23 22:03:34 dholland Exp $	*/
+/*	$NetBSD: inode.c,v 1.70 2013/12/02 18:46:52 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)inode.c	8.8 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: inode.c,v 1.69 2013/06/23 22:03:34 dholland Exp $);
+__RCSID($NetBSD: inode.c,v 1.70 2013/12/02 18:46:52 bouyer Exp $);
 #endif
 #endif /* not lint */
 
@@ -993,7 +993,7 @@ expandfile(union dinode *dp)
 			dp-dp1.di_ib[ilevel - 1] = iswap32(newblk);
 	} else {
 		ibp = getdatablk(is_ufs2 ? iswap64(dp-dp2.di_ib[ilevel - 1]) :
-		iswap32(dp-dp2.di_ib[ilevel - 1]), sblock-fs_bsize);
+		iswap32(dp-dp1.di_ib[ilevel - 1]), sblock-fs_bsize);
 	}
 	/* walk indirect blocks up to the data block */
 	for (; ilevel 0 ; ilevel--) {



CVS commit: src/sbin/fsck_ffs

2013-12-02 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Mon Dec  2 18:46:52 UTC 2013

Modified Files:
src/sbin/fsck_ffs: inode.c

Log Message:
Fix pasto in the !ufs2 case (use dp-dp1 and not of dp-dp2).
This would be a problem only when allocating a new data block and the
indir block is already allocated, which explains why automated tests didn't
find it.
Problem reported on tech-kern@ and fix tested by manu@.


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/sbin/fsck_ffs/inode.c

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



CVS commit: src/sbin/fsck_ffs

2013-01-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan  6 22:06:00 UTC 2013

Modified Files:
src/sbin/fsck_ffs: pass1.c

Log Message:
Show pass1 SIGINFO output on stderr like other passes, not on stdout.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sbin/fsck_ffs/pass1.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/fsck_ffs/pass1.c
diff -u src/sbin/fsck_ffs/pass1.c:1.49 src/sbin/fsck_ffs/pass1.c:1.50
--- src/sbin/fsck_ffs/pass1.c:1.49	Sun Aug 14 12:32:01 2011
+++ src/sbin/fsck_ffs/pass1.c	Sun Jan  6 22:06:00 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass1.c,v 1.49 2011/08/14 12:32:01 christos Exp $	*/
+/*	$NetBSD: pass1.c,v 1.50 2013/01/06 22:06:00 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)pass1.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: pass1.c,v 1.49 2011/08/14 12:32:01 christos Exp $);
+__RCSID($NetBSD: pass1.c,v 1.50 2013/01/06 22:06:00 riastradh Exp $);
 #endif
 #endif /* not lint */
 
@@ -109,7 +109,8 @@ pass1(void)
 		else
 			inosused = sblock-fs_ipg;
 		if (got_siginfo) {
-			printf(%s: phase 1: cyl group %d of %d (%d%%)\n,
+			fprintf(stderr,
+			%s: phase 1: cyl group %d of %d (%d%%)\n,
 			cdevname(), c, sblock-fs_ncg,
 			c * 100 / sblock-fs_ncg);
 			got_siginfo = 0;



CVS commit: src/sbin/fsck_ffs

2013-01-06 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Jan  6 22:06:00 UTC 2013

Modified Files:
src/sbin/fsck_ffs: pass1.c

Log Message:
Show pass1 SIGINFO output on stderr like other passes, not on stdout.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sbin/fsck_ffs/pass1.c

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



CVS commit: src/sbin/fsck_ffs

2012-08-26 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 26 09:33:42 UTC 2012

Modified Files:
src/sbin/fsck_ffs: pass5.c

Log Message:
stdlib.h, not malloc.h


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sbin/fsck_ffs/pass5.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/fsck_ffs/pass5.c
diff -u src/sbin/fsck_ffs/pass5.c:1.49 src/sbin/fsck_ffs/pass5.c:1.50
--- src/sbin/fsck_ffs/pass5.c:1.49	Sun Aug 14 12:32:01 2011
+++ src/sbin/fsck_ffs/pass5.c	Sun Aug 26 09:33:42 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass5.c,v 1.49 2011/08/14 12:32:01 christos Exp $	*/
+/*	$NetBSD: pass5.c,v 1.50 2012/08/26 09:33:42 dholland Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)pass5.c	8.9 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: pass5.c,v 1.49 2011/08/14 12:32:01 christos Exp $);
+__RCSID($NetBSD: pass5.c,v 1.50 2012/08/26 09:33:42 dholland Exp $);
 #endif
 #endif /* not lint */
 
@@ -48,7 +48,7 @@ __RCSID($NetBSD: pass5.c,v 1.49 2011/08
 
 #include err.h
 #include string.h
-#include malloc.h
+#include stdlib.h
 
 #include fsutil.h
 #include fsck.h



CVS commit: src/sbin/fsck_ffs

2012-08-26 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 26 09:34:17 UTC 2012

Modified Files:
src/sbin/fsck_ffs: pass6.c

Log Message:
stdlib.h, not malloc.h


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/fsck_ffs/pass6.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/fsck_ffs/pass6.c
diff -u src/sbin/fsck_ffs/pass6.c:1.3 src/sbin/fsck_ffs/pass6.c:1.4
--- src/sbin/fsck_ffs/pass6.c:1.3	Tue Jun  7 14:56:12 2011
+++ src/sbin/fsck_ffs/pass6.c	Sun Aug 26 09:34:17 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: pass6.c,v 1.3 2011/06/07 14:56:12 bouyer Exp $ */
+/* $NetBSD: pass6.c,v 1.4 2012/08/26 09:34:17 dholland Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -35,7 +35,7 @@
 
 #include err.h
 #include string.h
-#include malloc.h
+#include stdlib.h
 #include ufs/ufs/quota2.h
 
 #include fsutil.h



CVS commit: src/sbin/fsck_ffs

2012-08-26 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 26 09:34:43 UTC 2012

Modified Files:
src/sbin/fsck_ffs: quota2.c

Log Message:
stdlib.h, not malloc.h


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/fsck_ffs/quota2.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/fsck_ffs/quota2.c
diff -u src/sbin/fsck_ffs/quota2.c:1.5 src/sbin/fsck_ffs/quota2.c:1.6
--- src/sbin/fsck_ffs/quota2.c:1.5	Tue Mar 20 18:50:31 2012
+++ src/sbin/fsck_ffs/quota2.c	Sun Aug 26 09:34:42 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: quota2.c,v 1.5 2012/03/20 18:50:31 matt Exp $ */
+/* $NetBSD: quota2.c,v 1.6 2012/08/26 09:34:42 dholland Exp $ */
 /*-
   * Copyright (c) 2010 Manuel Bouyer
   * All rights reserved.
@@ -35,7 +35,7 @@
 
 #include err.h
 #include string.h
-#include malloc.h
+#include stdlib.h
 #include ufs/ufs/quota2.h
 
 #include fsutil.h



CVS commit: src/sbin/fsck_ffs

2012-08-26 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 26 09:33:42 UTC 2012

Modified Files:
src/sbin/fsck_ffs: pass5.c

Log Message:
stdlib.h, not malloc.h


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sbin/fsck_ffs/pass5.c

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



CVS commit: src/sbin/fsck_ffs

2012-08-26 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 26 09:34:17 UTC 2012

Modified Files:
src/sbin/fsck_ffs: pass6.c

Log Message:
stdlib.h, not malloc.h


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/fsck_ffs/pass6.c

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



CVS commit: src/sbin/fsck_ffs

2012-08-26 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Aug 26 09:34:43 UTC 2012

Modified Files:
src/sbin/fsck_ffs: quota2.c

Log Message:
stdlib.h, not malloc.h


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sbin/fsck_ffs/quota2.c

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



CVS commit: src/sbin/fsck_ffs

2012-03-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Mar  6 10:30:20 UTC 2012

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

Log Message:
Mention scan_ffs -b.
Based on a patch by Matthew Mondor mm_li...@pulsar-zone.net on
tech-userlevel.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sbin/fsck_ffs/fsck_ffs.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/fsck_ffs/fsck_ffs.8
diff -u src/sbin/fsck_ffs/fsck_ffs.8:1.48 src/sbin/fsck_ffs/fsck_ffs.8:1.49
--- src/sbin/fsck_ffs/fsck_ffs.8:1.48	Sat May 14 19:46:10 2011
+++ src/sbin/fsck_ffs/fsck_ffs.8	Tue Mar  6 10:30:20 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: fsck_ffs.8,v 1.48 2011/05/14 19:46:10 dholland Exp $
+.\	$NetBSD: fsck_ffs.8,v 1.49 2012/03/06 10:30:20 wiz Exp $
 .\
 .\ Copyright (c) 1980, 1989, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\	@(#)fsck.8	8.3 (Berkeley) 11/29/94
 .\
-.Dd May 14, 2011
+.Dd March 6, 2012
 .Dt FSCK_FFS 8
 .Os
 .Sh NAME
@@ -163,6 +163,12 @@ Use the block number
 .Ar block
 as the super block for the file system.
 Block 32 is usually an alternative super block.
+The
+.Fl b
+option of the
+.Xr scan_ffs 8
+utility can also be used to find the offset of other super block backups
+in a file system.
 .It Fl c Ar level
 Convert the FFSv1 file system to the level
 .Ar level .
@@ -367,4 +373,5 @@ are fully enumerated and explained in Ap
 .Xr fsck 8 ,
 .Xr fsdb 8 ,
 .Xr newfs 8 ,
-.Xr reboot 8
+.Xr reboot 8 ,
+.Xr scan_ffs 8



CVS commit: src/sbin/fsck_ffs

2012-03-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Mar  6 10:30:20 UTC 2012

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

Log Message:
Mention scan_ffs -b.
Based on a patch by Matthew Mondor mm_li...@pulsar-zone.net on
tech-userlevel.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sbin/fsck_ffs/fsck_ffs.8

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



CVS commit: src/sbin/fsck_ffs

2011-08-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 14 12:32:02 UTC 2011

Modified Files:
src/sbin/fsck_ffs: Makefile pass1.c pass2.c pass5.c quota2.c setup.c

Log Message:
WARNS=4


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sbin/fsck_ffs/Makefile
cvs rdiff -u -r1.48 -r1.49 src/sbin/fsck_ffs/pass1.c \
src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.47 -r1.48 src/sbin/fsck_ffs/pass2.c
cvs rdiff -u -r1.3 -r1.4 src/sbin/fsck_ffs/quota2.c
cvs rdiff -u -r1.93 -r1.94 src/sbin/fsck_ffs/setup.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/fsck_ffs/Makefile
diff -u src/sbin/fsck_ffs/Makefile:1.42 src/sbin/fsck_ffs/Makefile:1.43
--- src/sbin/fsck_ffs/Makefile:1.42	Mon Jun 20 03:44:00 2011
+++ src/sbin/fsck_ffs/Makefile	Sun Aug 14 08:32:01 2011
@@ -1,8 +1,6 @@
-#	$NetBSD: Makefile,v 1.42 2011/06/20 07:44:00 mrg Exp $
+#	$NetBSD: Makefile,v 1.43 2011/08/14 12:32:01 christos Exp $
 #	@(#)Makefile	8.2 (Berkeley) 4/27/95
 
-WARNS?=	3	# XXX: sign-compare issues
-
 .include bsd.own.mk
 
 PROG=	fsck_ffs

Index: src/sbin/fsck_ffs/pass1.c
diff -u src/sbin/fsck_ffs/pass1.c:1.48 src/sbin/fsck_ffs/pass1.c:1.49
--- src/sbin/fsck_ffs/pass1.c:1.48	Thu Jun  9 15:57:52 2011
+++ src/sbin/fsck_ffs/pass1.c	Sun Aug 14 08:32:01 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass1.c,v 1.48 2011/06/09 19:57:52 christos Exp $	*/
+/*	$NetBSD: pass1.c,v 1.49 2011/08/14 12:32:01 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)pass1.c	8.6 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: pass1.c,v 1.48 2011/06/09 19:57:52 christos Exp $);
+__RCSID($NetBSD: pass1.c,v 1.49 2011/08/14 12:32:01 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -66,7 +66,7 @@
 void
 pass1(void)
 {
-	ino_t inumber, inosused, ninosused;
+	ino_t inumber, inosused, ninosused, ii;
 	size_t inospace;
 	int c;
 	daddr_t i, cgd;
@@ -169,7 +169,7 @@
 		/*
 		 * Scan the allocated inodes.
 		 */
-		for (i = 0; i  inosused; i++, inumber++) {
+		for (ii = 0; ii  inosused; ii++, inumber++) {
 			if (inumber  ROOTINO) {
 (void)getnextinode(inumber);
 continue;
@@ -177,7 +177,7 @@
 			checkinode(inumber, idesc);
 		}
 		lastino += 1;
-		if (inosused  sblock-fs_ipg || inumber == lastino)
+		if (inosused  (ino_t)sblock-fs_ipg || inumber == lastino)
 			continue;
 		/*
 		 * If we were not able to determine in advance which inodes
@@ -185,7 +185,7 @@
 		 * to the size necessary to describe the inodes that we
 		 * really found.
 		 */
-		if (lastino  (c * sblock-fs_ipg))
+		if (lastino  (c * (ino_t)sblock-fs_ipg))
 			ninosused = 0;
 		else
 			ninosused = lastino - (c * sblock-fs_ipg);
@@ -328,7 +328,7 @@
 		 * will detect any garbage after symlink string.
 		 */
 		if ((sblock-fs_maxsymlinklen  0) ||
-		(size  sblock-fs_maxsymlinklen) ||
+		(size  (uint64_t)sblock-fs_maxsymlinklen) ||
 		(isappleufs  (size  APPLEUFS_MAXSYMLINKLEN)) ||
 		(sblock-fs_maxsymlinklen == 0  DIP(dp, blocks) == 0)) {
 			if (is_ufs2)
Index: src/sbin/fsck_ffs/pass5.c
diff -u src/sbin/fsck_ffs/pass5.c:1.48 src/sbin/fsck_ffs/pass5.c:1.49
--- src/sbin/fsck_ffs/pass5.c:1.48	Sat Feb 23 16:41:48 2008
+++ src/sbin/fsck_ffs/pass5.c	Sun Aug 14 08:32:01 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pass5.c,v 1.48 2008/02/23 21:41:48 christos Exp $	*/
+/*	$NetBSD: pass5.c,v 1.49 2011/08/14 12:32:01 christos Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)pass5.c	8.9 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: pass5.c,v 1.48 2008/02/23 21:41:48 christos Exp $);
+__RCSID($NetBSD: pass5.c,v 1.49 2011/08/14 12:32:01 christos Exp $);
 #endif
 #endif /* not lint */
 
@@ -101,7 +101,7 @@
 i = fs-fs_contigsumsize;
 fs-fs_contigsumsize =
 MIN(fs-fs_maxcontig, FS_MAXCONTIG);
-if (CGSIZE(fs)  fs-fs_bsize) {
+if (CGSIZE(fs)  (uint32_t)fs-fs_bsize) {
 	pwarn(CANNOT %s CLUSTER MAPS\n, doit);
 	fs-fs_contigsumsize = i;
 } else if (preen ||
@@ -298,7 +298,7 @@
 		if (!is_ufs2) {
 			newcg-cg_initediblk = 0;
 		} else {
-			if ((unsigned)cg-cg_initediblk  fs-fs_ipg)
+			if ((unsigned)cg-cg_initediblk  (unsigned)fs-fs_ipg)
 newcg-cg_initediblk = fs-fs_ipg;
 			else
 newcg-cg_initediblk = cg-cg_initediblk;
@@ -330,14 +330,14 @@
 break;
 
 			default:
-if (j  ROOTINO)
+if ((ino_t)j  ROOTINO)
 	break;
 errexit(BAD STATE %d FOR INODE I=%ld,
 info-ino_state, (long)j);
 			}
 		}
 		if (c == 0)
-			for (i = 0; i  ROOTINO; i++) {
+			for (i = 0; i  (long)ROOTINO; i++) {
 setbit(cg_inosused(newcg, 0), i);
 newcg-cg_cs.cs_nifree--;
 			}
@@ -497,9 +497,9 @@
 }
 
 void 
-print_bmap(u_char *map, u_int32_t size)
+print_bmap(u_char *map, uint32_t size)
 {
-	int i, j;
+	uint32_t i, j;
 
 	i = 0;
 	while (i  size) {

Index: src/sbin/fsck_ffs/pass2.c
diff -u src/sbin/fsck_ffs/pass2.c:1.47 

CVS commit: src/sbin/fsck_ffs

2011-08-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 14 12:32:02 UTC 2011

Modified Files:
src/sbin/fsck_ffs: Makefile pass1.c pass2.c pass5.c quota2.c setup.c

Log Message:
WARNS=4


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sbin/fsck_ffs/Makefile
cvs rdiff -u -r1.48 -r1.49 src/sbin/fsck_ffs/pass1.c \
src/sbin/fsck_ffs/pass5.c
cvs rdiff -u -r1.47 -r1.48 src/sbin/fsck_ffs/pass2.c
cvs rdiff -u -r1.3 -r1.4 src/sbin/fsck_ffs/quota2.c
cvs rdiff -u -r1.93 -r1.94 src/sbin/fsck_ffs/setup.c

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



CVS commit: src/sbin/fsck_ffs

2011-04-29 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Apr 29 10:34:52 UTC 2011

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

Log Message:
Re-add -q description that got lost when -x was added.
Sort descriptions.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sbin/fsck_ffs/fsck_ffs.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/fsck_ffs/fsck_ffs.8
diff -u src/sbin/fsck_ffs/fsck_ffs.8:1.46 src/sbin/fsck_ffs/fsck_ffs.8:1.47
--- src/sbin/fsck_ffs/fsck_ffs.8:1.46	Thu May  7 08:27:14 2009
+++ src/sbin/fsck_ffs/fsck_ffs.8	Fri Apr 29 10:34:52 2011
@@ -1,4 +1,4 @@
-.\	$NetBSD: fsck_ffs.8,v 1.46 2009/05/07 08:27:14 wiz Exp $
+.\	$NetBSD: fsck_ffs.8,v 1.47 2011/04/29 10:34:52 wiz Exp $
 .\
 .\ Copyright (c) 1980, 1989, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\	@(#)fsck.8	8.3 (Berkeley) 11/29/94
 .\
-.Dd May 7, 2009
+.Dd April 29, 2011
 .Dt FSCK_FFS 8
 .Os
 .Sh NAME
@@ -255,6 +255,14 @@
 Specify
 .Dq preen
 mode, described above.
+.It Fl q
+Quiet mode, do not output any messages for clean filesystems.
+.It Fl U
+Resolve user ids to usernames.
+.It Fl X
+Similar to
+.Fl x
+but uses a file system internal snapshot on the file system to be checked.
 .It Fl x Ar snap-backup
 Use a snapshot with
 .Ar snap-backup
@@ -267,12 +275,6 @@
 The point is to check an internally-consistent version of the
 filesystem to find out if it is damaged; on failure one should unmount
 the filesystem and repair it.
-.It Fl U
-Resolve user ids to usernames.
-.It Fl X
-Similar to
-.Fl x
-but uses a file system internal snapshot on the file system to be checked.
 .It Fl y
 Assume a yes response to all questions asked by
 .Nm ;



CVS commit: src/sbin/fsck_ffs

2011-04-29 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Apr 29 10:34:52 UTC 2011

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

Log Message:
Re-add -q description that got lost when -x was added.
Sort descriptions.
Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sbin/fsck_ffs/fsck_ffs.8

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



CVS commit: src/sbin/fsck_ffs

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 11:41:25 UTC 2011

Modified Files:
src/sbin/fsck_ffs: setup.c

Log Message:
initialise memory allocated for uquot_user_hash  uquot_group_hash.
Pointed out by Nicolas Joly.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sbin/fsck_ffs/setup.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/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.91 src/sbin/fsck_ffs/setup.c:1.92
--- src/sbin/fsck_ffs/setup.c:1.91	Sun Mar  6 17:08:16 2011
+++ src/sbin/fsck_ffs/setup.c	Sun Mar 20 11:41:24 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.91 2011/03/06 17:08:16 bouyer Exp $	*/
+/*	$NetBSD: setup.c,v 1.92 2011/03/20 11:41:24 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)setup.c	8.10 (Berkeley) 5/9/95;
 #else
-__RCSID($NetBSD: setup.c,v 1.91 2011/03/06 17:08:16 bouyer Exp $);
+__RCSID($NetBSD: setup.c,v 1.92 2011/03/20 11:41:24 bouyer Exp $);
 #endif
 #endif /* not lint */
 
@@ -565,9 +565,9 @@
 			q2h_hash_mask);
 		}
 		uquot_user_hash =
-		malloc((1  q2h_hash_shift) * sizeof(struct uquot_hash));
+		calloc((1  q2h_hash_shift), sizeof(struct uquot_hash));
 		uquot_group_hash =
-		malloc((1  q2h_hash_shift) * sizeof(struct uquot_hash));
+		calloc((1  q2h_hash_shift), sizeof(struct uquot_hash));
 		if (uquot_user_hash == NULL || uquot_group_hash == NULL)
 			errexit(Cannot allocate space for quotas hash\n);
 	} else {



CVS commit: src/sbin/fsck_ffs

2011-03-20 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Mar 20 11:41:25 UTC 2011

Modified Files:
src/sbin/fsck_ffs: setup.c

Log Message:
initialise memory allocated for uquot_user_hash  uquot_group_hash.
Pointed out by Nicolas Joly.


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sbin/fsck_ffs/setup.c

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



CVS commit: src/sbin/fsck_ffs

2011-02-06 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Sun Feb  6 12:02:59 UTC 2011

Modified Files:
src/sbin/fsck_ffs: main.c

Log Message:
Do Skip device checks, which ends up parsing fstab, when working on a
filesystem image with -F option set.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sbin/fsck_ffs/main.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/fsck_ffs/main.c
diff -u src/sbin/fsck_ffs/main.c:1.76 src/sbin/fsck_ffs/main.c:1.77
--- src/sbin/fsck_ffs/main.c:1.76	Sun Apr 11 08:23:51 2010
+++ src/sbin/fsck_ffs/main.c	Sun Feb  6 12:02:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.76 2010/04/11 08:23:51 hannken Exp $	*/
+/*	$NetBSD: main.c,v 1.77 2011/02/06 12:02:59 njoly Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = @(#)main.c	8.6 (Berkeley) 5/14/95;
 #else
-__RCSID($NetBSD: main.c,v 1.76 2010/04/11 08:23:51 hannken Exp $);
+__RCSID($NetBSD: main.c,v 1.77 2011/02/06 12:02:59 njoly Exp $);
 #endif
 #endif /* not lint */
 
@@ -216,7 +216,12 @@
 
 	while (argc--  0) {
 		int nret;
-		char *path = strdup(blockcheck(*argv));
+		char *path;
+
+		if (!forceimage)
+			path = strdup(blockcheck(*argv));
+		else
+			path = strdup(*argv);
 
 		if (path == NULL)
 			pfatal(Can't check %s\n, *argv);



CVS commit: src/sbin/fsck_ffs

2011-02-06 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Sun Feb  6 12:02:59 UTC 2011

Modified Files:
src/sbin/fsck_ffs: main.c

Log Message:
Do Skip device checks, which ends up parsing fstab, when working on a
filesystem image with -F option set.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sbin/fsck_ffs/main.c

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



CVS commit: src/sbin/fsck_ffs

2010-03-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar  6 11:31:40 UTC 2010

Modified Files:
src/sbin/fsck_ffs: wapbl.c

Log Message:
When clearing a log on failure, not only ask the kernel to ignore an
existing log but to remove it on next mount.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/fsck_ffs/wapbl.c

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



CVS commit: src/sbin/fsck_ffs

2010-03-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar  6 11:31:40 UTC 2010

Modified Files:
src/sbin/fsck_ffs: wapbl.c

Log Message:
When clearing a log on failure, not only ask the kernel to ignore an
existing log but to remove it on next mount.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/fsck_ffs/wapbl.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/fsck_ffs/wapbl.c
diff -u src/sbin/fsck_ffs/wapbl.c:1.4 src/sbin/fsck_ffs/wapbl.c:1.5
--- src/sbin/fsck_ffs/wapbl.c:1.4	Sun Sep 13 14:25:28 2009
+++ src/sbin/fsck_ffs/wapbl.c	Sat Mar  6 11:31:40 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: wapbl.c,v 1.4 2009/09/13 14:25:28 bouyer Exp $	*/
+/*	$NetBSD: wapbl.c,v 1.5 2010/03/06 11:31:40 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2005,2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #define WAPBL_INTERNAL
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: wapbl.c,v 1.4 2009/09/13 14:25:28 bouyer Exp $);
+__KERNEL_RCSID(0, $NetBSD: wapbl.c,v 1.5 2010/03/06 11:31:40 mlelstv Exp $);
 
 #include sys/stat.h
 #include sys/time.h
@@ -170,6 +170,7 @@
 			}
 			pwarn(CLEARING EXISTING JOURNAL\n);
 			sblock-fs_flags = ~FS_DOWAPBL;
+			sblock-fs_journal_flags = UFS_WAPBL_FLAGS_CLEAR_LOG;
 			sbdirty();
 			ret = FSCK_EXIT_CHECK_FAILED;
 		} else {
@@ -198,6 +199,7 @@
 }
 pwarn(CLEARING EXISTING JOURNAL\n);
 sblock-fs_flags = ~FS_DOWAPBL;
+sblock-fs_journal_flags = UFS_WAPBL_FLAGS_CLEAR_LOG;
 sblock-fs_journal_location =
 UFS_WAPBL_JOURNALLOC_NONE;
 sbdirty();
@@ -215,6 +217,7 @@
 	}
 	pwarn(CLEARING EXISTING JOURNAL\n);
 	sblock-fs_flags = ~FS_DOWAPBL;
+	sblock-fs_journal_flags = UFS_WAPBL_FLAGS_CLEAR_LOG;
 	sbdirty();
 	ret = FSCK_EXIT_CHECK_FAILED;
 }



CVS commit: src/sbin/fsck_ffs

2009-09-27 Thread Manuel Bouyer
Module Name:src
Committed By:   bouyer
Date:   Sun Sep 27 17:13:37 UTC 2009

Modified Files:
src/sbin/fsck_ffs: setup.c

Log Message:
Restore changes from 1.86 and 1.87 after commit of 1.88.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sbin/fsck_ffs/setup.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/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.88 src/sbin/fsck_ffs/setup.c:1.89
--- src/sbin/fsck_ffs/setup.c:1.88	Sun Sep 13 14:25:28 2009
+++ src/sbin/fsck_ffs/setup.c	Sun Sep 27 17:13:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.88 2009/09/13 14:25:28 bouyer Exp $	*/
+/*	$NetBSD: setup.c,v 1.89 2009/09/27 17:13:37 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)setup.c	8.10 (Berkeley) 5/9/95;
 #else
-__RCSID($NetBSD: setup.c,v 1.88 2009/09/13 14:25:28 bouyer Exp $);
+__RCSID($NetBSD: setup.c,v 1.89 2009/09/27 17:13:37 bouyer Exp $);
 #endif
 #endif /* not lint */
 
@@ -181,7 +181,7 @@
 			doskipclean = 0;
 		}
 		if (sblock-fs_flags  FS_DOWAPBL) {
-			if (preen) {
+			if (preen  skipclean) {
 if (!quiet)
 	pwarn(file system is journaled; 
 	not checking\n);



Re: CVS commit: src/sbin/fsck_ffs

2009-05-11 Thread M. Warner Losh
In message: 87r5yv4rqn@snark.cb.piermont.com
Perry E. Metzger pe...@piermont.com writes:
: 
: M. Warner Losh i...@bsdimp.com writes:
:  What I didn't glean from the discussion is what, exactly, you were
:  going to do about it and what, exactly, you'd like to harmonize with
:  FreeBSD on.  It may have been there, but I just missed it.
: 
: Documentation. It would involve making all man pages refer consistently
: to FFS, FFSv1, FFSv2, and not to mix in the references to UFS.

Documentation is easy, and I'll be happy to bring over the changes.

Output of programs and/or input via config file changes is harder...

I wasn't sure which of these two classes you were asking...

Warner


Re: CVS commit: src/sbin/fsck_ffs

2009-05-10 Thread Joerg Sonnenberger
On Sun, May 10, 2009 at 04:31:34AM +, YAMAMOTO Takashi wrote:
 have you tried to convince freebsd guys to use your preferred name?
 being different creates another layer of confusion.

We had a short discussion about this during BSDCan. Kirk didn't mind and
if it should be reasonable to get consistent.

Joerg


Re: CVS commit: src/sbin/fsck_ffs

2009-05-10 Thread M. Warner Losh
In message: 20090510220227.gd16...@britannica.bec.de
Joerg Sonnenberger jo...@britannica.bec.de writes:
: On Sun, May 10, 2009 at 04:31:34AM +, YAMAMOTO Takashi wrote:
:  have you tried to convince freebsd guys to use your preferred name?
:  being different creates another layer of confusion.
: 
: We had a short discussion about this during BSDCan. Kirk didn't mind and
: if it should be reasonable to get consistent.

I think that this sort of decision can't be made by just Kirk since
FreeBSD has deployed ufs2 for several releases now.

I've missed much of the discussion, can someone recap exactly what
you'd like to see changed?  That would be the starting point for any
user-visisble changes to FreeBSD...

Warner


Re: CVS commit: src/sbin/fsck_ffs

2009-05-10 Thread Joerg Sonnenberger
On Sun, May 10, 2009 at 07:51:41PM -0600, M. Warner Losh wrote:
 I've missed much of the discussion, can someone recap exactly what
 you'd like to see changed?  That would be the starting point for any
 user-visisble changes to FreeBSD...

There is currently a mixed naming convention when refering to FFS
filesystems (v1 and v2). Sometimes, it is FFS, FFS2, UFS, UFS2 etc.
The consensus in NetBSD was to consistently use FFS and FFSv2.
UFS2 is bad, as it changes the underlaying inode format, but still has
FFS on top.

Joerg


Re: CVS commit: src/sbin/fsck_ffs

2009-05-10 Thread M. Warner Losh
In message: 20090511015855.gd16...@britannica.bec.de
Joerg Sonnenberger jo...@britannica.bec.de writes:
: On Sun, May 10, 2009 at 07:51:41PM -0600, M. Warner Losh wrote:
:  I've missed much of the discussion, can someone recap exactly what
:  you'd like to see changed?  That would be the starting point for any
:  user-visisble changes to FreeBSD...
: 
: There is currently a mixed naming convention when refering to FFS
: filesystems (v1 and v2). Sometimes, it is FFS, FFS2, UFS, UFS2 etc.
: The consensus in NetBSD was to consistently use FFS and FFSv2.
: UFS2 is bad, as it changes the underlaying inode format, but still has
: FFS on top.

Right, I gleaned that from the discussion.

What I didn't glean from the discussion is what, exactly, you were
going to do about it and what, exactly, you'd like to harmonize with
FreeBSD on.  It may have been there, but I just missed it.

Warner


Re: CVS commit: src/sbin/fsck_ffs

2009-05-08 Thread Greg Troxel

  (or just use FFSv2 (UFS2) etc.) in some man pages and related docs.
  (and also add the UFS2 paper into the SEE ALSO section?)

I see both points, and think this is an excellent way to address both of
them.



pgpV50T6scYJU.pgp
Description: PGP signature


Re: CVS commit: src/sbin/fsck_ffs

2009-05-07 Thread Izumi Tsutsui
lu...@netbsd.org wrote:

 Modified Files:
   src/sbin/fsck_ffs: fsck_ffs.8
 
 Log Message:
 Use FFSv2 instead of UFS2.

There was a related comment around PR/38192:
http://mail-index.NetBSD.org/source-changes/2008/03/09/msg003309.html

 do we really want to call it FFSv2?
 we call it UFS2 in various places, and
 it's the name the upstream (freebsd) uses.

FFSv2 seems used only in NetBSD world (derived from lfsv2 or libsa?)
---
Izumi Tsutsui


Re: CVS commit: src/sbin/fsck_ffs

2009-05-07 Thread Luke Mewburn
On Thu, May 07, 2009 at 08:52:40PM +0900, Izumi Tsutsui wrote:
  | lu...@netbsd.org wrote:
  | 
  |  Modified Files:
  |src/sbin/fsck_ffs: fsck_ffs.8
  |  
  |  Log Message:
  |  Use FFSv2 instead of UFS2.
  | 
  | There was a related comment around PR/38192:
  | http://mail-index.NetBSD.org/source-changes/2008/03/09/msg003309.html
  | 
  |  do we really want to call it FFSv2?
  |  we call it UFS2 in various places, and
  |  it's the name the upstream (freebsd) uses.
  | 
  | FFSv2 seems used only in NetBSD world (derived from lfsv2 or libsa?)

I initiated a discussion related to the inconsistent use of
FFS (and FFSv#) versus UFS (and UFS#) in late March:
http://mail-index.netbsd.org/tech-userlevel/2009/03/31/msg002003.html

I think it is confusing to end users to use the terms FFS
and UFS interchangebly in program output and documentation.

The names of our tools have ffs in them (not ufs).
We generally use FFS (instead of UFS) in various documentation.

As for FreeBSD; I don't think that they're a paragon of consistency
in their command names, command output, and documentation.  They
use ffs in command names, have an ffs(7) manual page, but
inconsistently use UFS and FFS in their command documentation.

cheers,
Luke.


pgpvcEa7Myums.pgp
Description: PGP signature


CVS commit: src/sbin/fsck_ffs

2009-05-07 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Thu May  7 06:54:23 UTC 2009

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

Log Message:
Use FFSv2 instead of UFS2.
Expand the description of -c.
Xref dumpfs.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sbin/fsck_ffs/fsck_ffs.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/fsck_ffs/fsck_ffs.8
diff -u src/sbin/fsck_ffs/fsck_ffs.8:1.44 src/sbin/fsck_ffs/fsck_ffs.8:1.45
--- src/sbin/fsck_ffs/fsck_ffs.8:1.44	Thu Oct  9 16:56:23 2008
+++ src/sbin/fsck_ffs/fsck_ffs.8	Thu May  7 06:54:23 2009
@@ -1,4 +1,4 @@
-.\	$NetBSD: fsck_ffs.8,v 1.44 2008/10/09 16:56:23 christos Exp $
+.\	$NetBSD: fsck_ffs.8,v 1.45 2009/05/07 06:54:23 lukem Exp $
 .\
 .\ Copyright (c) 1980, 1989, 1991, 1993
 .\	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\
 .\	@(#)fsck.8	8.3 (Berkeley) 11/29/94
 .\
-.Dd October 9, 2008
+.Dd May 7, 2009
 .Dt FSCK_FFS 8
 .Os
 .Sh NAME
@@ -164,7 +164,7 @@
 as the super block for the file system.
 Block 32 is usually an alternative super block.
 .It Fl c Ar level
-Convert the file system to the level
+Convert the FFSv1 file system to the level
 .Ar level .
 Note that the level of a file system can only be raised.
 There are currently five levels defined:
@@ -182,7 +182,7 @@
 build the free segment maps to aid in finding contiguous sets of blocks.
 If maxcontig is equal to one, delete any existing segment maps.
 .It 4
-Rearrange the super block to the same layout as UFS2;
+Rearrange the super block to the same layout as FFSv2;
 disable the rotational layout tables and per cylinder group
 block totals.
 .El
@@ -198,9 +198,15 @@
 possible without user interaction.
 Conversion in preen mode is best used when all the file systems
 are being converted at once.
-The format of a file system can be determined from the
-third line of output from
-.Xr dumpfs 8 .
+.Pp
+The output of
+.Xr dumpfs 8
+can be examined to determine the format of the file system
+.Dq ( format
+in the second line)
+and the file system level
+.Dq ( fslevel
+in the sixth line).
 .It Fl d
 Print debugging output.
 .It Fl F
@@ -340,6 +346,7 @@
 .Xr fss 4 ,
 .Xr fs 5 ,
 .Xr fstab 5 ,
+.Xr dumpfs 8 ,
 .Xr fsck 8 ,
 .Xr fsdb 8 ,
 .Xr newfs 8 ,



CVS commit: src/sbin/fsck_ffs

2009-04-11 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Apr 11 07:31:21 UTC 2009

Modified Files:
src/sbin/fsck_ffs: dir.c

Log Message:
fix sign-compare issues


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sbin/fsck_ffs/dir.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/fsck_ffs/dir.c
diff -u src/sbin/fsck_ffs/dir.c:1.51 src/sbin/fsck_ffs/dir.c:1.52
--- src/sbin/fsck_ffs/dir.c:1.51	Tue Jul  8 08:14:37 2008
+++ src/sbin/fsck_ffs/dir.c	Sat Apr 11 07:31:21 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.51 2008/07/08 08:14:37 simonb Exp $	*/
+/*	$NetBSD: dir.c,v 1.52 2009/04/11 07:31:21 lukem Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)dir.c	8.8 (Berkeley) 4/28/95;
 #else
-__RCSID($NetBSD: dir.c,v 1.51 2008/07/08 08:14:37 simonb Exp $);
+__RCSID($NetBSD: dir.c,v 1.52 2009/04/11 07:31:21 lukem Exp $);
 #endif
 #endif /* not lint */
 
@@ -198,7 +198,7 @@
 	idesc-id_loc = 0;
 	for (dp = fsck_readdir(idesc); dp != NULL; dp = fsck_readdir(idesc)) {
 		dsize = iswap16(dp-d_reclen);
-		if (dsize  sizeof dbuf)
+		if (dsize  (int)sizeof dbuf)
 			dsize = sizeof dbuf;
 		memmove(dbuf, dp, (size_t)dsize);
 #		if (BYTE_ORDER == LITTLE_ENDIAN)
@@ -727,7 +727,7 @@
 		btodb(sblock-fs_bsize));
 		dirblk = iswap32(dp1-di_db[lastbn + 1]);
 	}
-	bp = getdirblk(dirblk, sblksize(sblock, DIP(dp, size), lastbn + 1));
+	bp = getdirblk(dirblk, sblksize(sblock, (daddr_t)DIP(dp, size), lastbn + 1));
 	if (bp-b_errs)
 		goto bad;
 	memmove(firstblk, bp-b_un.b_buf, dirblksiz);
@@ -741,7 +741,7 @@
 	 cp += dirblksiz)
 		memmove(cp, emptydir, sizeof emptydir);
 	dirty(bp);
-	bp = getdirblk(dirblk, sblksize(sblock, DIP(dp, size), lastbn + 1));
+	bp = getdirblk(dirblk, sblksize(sblock, (daddr_t)DIP(dp, size), lastbn + 1));
 	if (bp-b_errs)
 		goto bad;
 	memmove(bp-b_un.b_buf, emptydir, sizeof emptydir);



CVS commit: src/sbin/fsck_ffs

2009-04-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Tue Apr  7 05:50:11 UTC 2009

Modified Files:
src/sbin/fsck_ffs: setup.c

Log Message:
fix a logic error in the previous, as point out by frank kardel.


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sbin/fsck_ffs/setup.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/fsck_ffs/setup.c
diff -u src/sbin/fsck_ffs/setup.c:1.86 src/sbin/fsck_ffs/setup.c:1.87
--- src/sbin/fsck_ffs/setup.c:1.86	Wed Mar 25 03:42:41 2009
+++ src/sbin/fsck_ffs/setup.c	Tue Apr  7 05:50:11 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: setup.c,v 1.86 2009/03/25 03:42:41 mrg Exp $	*/
+/*	$NetBSD: setup.c,v 1.87 2009/04/07 05:50:11 mrg Exp $	*/
 
 /*
  * Copyright (c) 1980, 1986, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = @(#)setup.c	8.10 (Berkeley) 5/9/95;
 #else
-__RCSID($NetBSD: setup.c,v 1.86 2009/03/25 03:42:41 mrg Exp $);
+__RCSID($NetBSD: setup.c,v 1.87 2009/04/07 05:50:11 mrg Exp $);
 #endif
 #endif /* not lint */
 
@@ -174,7 +174,7 @@
 		pwarn(USING ALTERNATE SUPERBLOCK AT %d\n, bflag);
 	}
 	if (sblock-fs_flags  FS_DOWAPBL) {
-		if (preen  !skipclean) {
+		if (preen  skipclean) {
 			if (!quiet)
 pwarn(file system is journaled; not checking\n);
 			return (-1);