CVS commit: src/sys/ufs/ext2fs

2024-07-01 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jul  2 05:02:49 UTC 2024

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
ext2fs: Fix copy-paste for PR kern/58388


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.226 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.227
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.226	Mon Jul  1 22:12:56 2024
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Tue Jul  2 05:02:49 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.226 2024/07/01 22:12:56 riastradh Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.227 2024/07/02 05:02:49 rin Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.226 2024/07/01 22:12:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.227 2024/07/02 05:02:49 rin Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -1336,7 +1336,7 @@ ext2fs_cgupdate(struct ufsmount *mp, int
 		fs->e2fs.e2fs_first_dblock +
 		1 /* superblock */ + i), fs->e2fs_bsize, 0, 0);
 		e2fs_cgsave(>e2fs_gd[i *
-			(m_fs->e2fs_bsize >> m_fs->e2fs_group_desc_shift)],
+			(fs->e2fs_bsize >> fs->e2fs_group_desc_shift)],
 		bp->b_data, fs->e2fs_bsize, fs->e2fs_group_desc_shift);
 		if (waitfor == MNT_WAIT)
 			error = bwrite(bp);



CVS commit: src/sys/ufs/ext2fs

2024-07-01 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jul  2 05:02:49 UTC 2024

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
ext2fs: Fix copy-paste for PR kern/58388


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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



CVS commit: src/sys/ufs/ext2fs

2024-07-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul  1 22:12:57 UTC 2024

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
ext2fs: Fix indexing of group descriptors on disk.

XXX Evidently we need some more automatic tests for this!

PR kern/58388


To generate a diff of this commit:
cvs rdiff -u -r1.225 -r1.226 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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



CVS commit: src/sys/ufs/ext2fs

2024-07-01 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Jul  1 22:12:57 UTC 2024

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
ext2fs: Fix indexing of group descriptors on disk.

XXX Evidently we need some more automatic tests for this!

PR kern/58388


To generate a diff of this commit:
cvs rdiff -u -r1.225 -r1.226 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.225 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.226
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.225	Sun Aug 27 16:35:51 2023
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Mon Jul  1 22:12:56 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.225 2023/08/27 16:35:51 christos Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.226 2024/07/01 22:12:56 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.225 2023/08/27 16:35:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.226 2024/07/01 22:12:56 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -653,7 +653,8 @@ ext2fs_reload(struct mount *mp, kauth_cr
 			return error;
 		}
 		e2fs_cgload(bp->b_data,
-		>e2fs_gd[i * fs->e2fs_bsize / sizeof(struct ext2_gd)],
+		>e2fs_gd[i *
+			(fs->e2fs_bsize >> fs->e2fs_group_desc_shift)],
 		fs->e2fs_bsize, fs->e2fs_group_desc_shift);
 		brelse(bp, 0);
 	}
@@ -770,8 +771,8 @@ ext2fs_mountfs(struct vnode *devvp, stru
 		m_fs->e2fs_bsize, 0, );
 		if (error)
 			goto out1;
-		e2fs_cgload(bp->b_data, _fs->e2fs_gd[i * m_fs->e2fs_bsize
-		/ sizeof(struct ext2_gd)],
+		e2fs_cgload(bp->b_data, _fs->e2fs_gd[i *
+			(m_fs->e2fs_bsize >> m_fs->e2fs_group_desc_shift)],
 		m_fs->e2fs_bsize, m_fs->e2fs_group_desc_shift);
 		brelse(bp, 0);
 		bp = NULL;
@@ -1334,8 +1335,8 @@ ext2fs_cgupdate(struct ufsmount *mp, int
 		bp = getblk(mp->um_devvp, EXT2_FSBTODB(fs,
 		fs->e2fs.e2fs_first_dblock +
 		1 /* superblock */ + i), fs->e2fs_bsize, 0, 0);
-		e2fs_cgsave(>e2fs_gd[
-		i * fs->e2fs_bsize / sizeof(struct ext2_gd)],
+		e2fs_cgsave(>e2fs_gd[i *
+			(m_fs->e2fs_bsize >> m_fs->e2fs_group_desc_shift)],
 		bp->b_data, fs->e2fs_bsize, fs->e2fs_group_desc_shift);
 		if (waitfor == MNT_WAIT)
 			error = bwrite(bp);



CVS commit: src/sys/ufs/ext2fs

2024-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 10 17:36:33 UTC 2024

Modified Files:
src/sys/ufs/ext2fs: ext2fs_dir.h

Log Message:
PR/58018: Damir Holovati: ext2fs readdir (d_type conversion error)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/ext2fs/ext2fs_dir.h

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



CVS commit: src/sys/ufs/ext2fs

2024-03-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 10 17:36:33 UTC 2024

Modified Files:
src/sys/ufs/ext2fs: ext2fs_dir.h

Log Message:
PR/58018: Damir Holovati: ext2fs readdir (d_type conversion error)


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/ext2fs/ext2fs_dir.h

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs_dir.h
diff -u src/sys/ufs/ext2fs/ext2fs_dir.h:1.22 src/sys/ufs/ext2fs/ext2fs_dir.h:1.23
--- src/sys/ufs/ext2fs/ext2fs_dir.h:1.22	Sat Aug  6 21:47:11 2016
+++ src/sys/ufs/ext2fs/ext2fs_dir.h	Sun Mar 10 13:36:33 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_dir.h,v 1.22 2016/08/07 01:47:11 kre Exp $	*/
+/*	$NetBSD: ext2fs_dir.h,v 1.23 2024/03/10 17:36:33 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -174,7 +174,7 @@ ext2dt2dt(uint8_t type)
 {
 	switch (type) {
 	case EXT2_FT_REG_FILE:
-		return DT_FIFO;
+		return DT_REG;
 	case EXT2_FT_DIR:
 		return DT_DIR;
 	case EXT2_FT_CHRDEV:



CVS commit: src/sys/ufs/ext2fs

2023-08-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 27 16:35:51 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h ext2fs_vfsops.c

Log Message:
- fix cgload/cgsave inconsistencies
- add a constant for the rev 0 group descriptor size


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/ufs/ext2fs/ext2fs.h
cvs rdiff -u -r1.224 -r1.225 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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



CVS commit: src/sys/ufs/ext2fs

2023-08-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Aug 27 16:35:51 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h ext2fs_vfsops.c

Log Message:
- fix cgload/cgsave inconsistencies
- add a constant for the rev 0 group descriptor size


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/ufs/ext2fs/ext2fs.h
cvs rdiff -u -r1.224 -r1.225 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs.h
diff -u src/sys/ufs/ext2fs/ext2fs.h:1.51 src/sys/ufs/ext2fs/ext2fs.h:1.52
--- src/sys/ufs/ext2fs/ext2fs.h:1.51	Sat Aug 26 01:22:50 2023
+++ src/sys/ufs/ext2fs/ext2fs.h	Sun Aug 27 12:35:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.h,v 1.51 2023/08/26 05:22:50 riastradh Exp $	*/
+/*	$NetBSD: ext2fs.h,v 1.52 2023/08/27 16:35:51 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -444,6 +444,7 @@ struct ext2_gd {
 	uint32_t reserved2_hi[3];
 };
 
+#define	E2FS_REV0_GD_SIZE	(sizeof(struct ext2_gd) / 2)	/* 32 */
 #define E2FS_BG_INODE_UNINIT	0x0001	/* Inode bitmap not used/initialized */
 #define E2FS_BG_BLOCK_UNINIT	0x0002	/* Block bitmap not used/initialized */
 #define E2FS_BG_INODE_ZEROED	0x0004	/* On-disk inode table initialized */

Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.224 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.225
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.224	Sat Aug 26 17:56:23 2023
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Sun Aug 27 12:35:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.224 2023/08/26 21:56:23 christos Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.225 2023/08/27 16:35:51 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.224 2023/08/26 21:56:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.225 2023/08/27 16:35:51 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -179,8 +179,9 @@ e2fs_cgload(const char *ondisk, struct e
 		}
 	} else {
 		for (int i = 0; i < lim; i++, optr++, iptr += sh) {
-			memcpy(optr, iptr, 32);
-			memset((char *)optr + 32, 0, sizeof(*optr) - 32);
+			memcpy(optr, iptr, E2FS_REV0_GD_SIZE);
+			memset((char *)optr + E2FS_REV0_GD_SIZE, 0,
+			sizeof(*optr) - E2FS_REV0_GD_SIZE);
 		}
 	}
 }
@@ -202,11 +203,11 @@ e2fs_cgsave(const struct ext2_gd *inmemo
 	if (shift_cg_entry_size > 6) {
 		for (int i = 0; i < lim; i++, iptr++, optr += sh) {
 			memcpy(optr, iptr, sizeof(*iptr));
-			memset(optr + sizeof(*optr), 0, sh - sizeof(*iptr));
+			memset(optr + sizeof(*iptr), 0, sh - sizeof(*iptr));
 		}
 	} else {
 		for (int i = 0; i < lim; i++, iptr++, optr += sh) {
-			memcpy(optr, iptr, 32);
+			memcpy(optr, iptr, E2FS_REV0_GD_SIZE);
 		}
 	}
 }
@@ -653,7 +654,7 @@ ext2fs_reload(struct mount *mp, kauth_cr
 		}
 		e2fs_cgload(bp->b_data,
 		>e2fs_gd[i * fs->e2fs_bsize / sizeof(struct ext2_gd)],
-		fs->e2fs_bsize, 1 << fs->e2fs_group_desc_shift);
+		fs->e2fs_bsize, fs->e2fs_group_desc_shift);
 		brelse(bp, 0);
 	}
 
@@ -769,7 +770,8 @@ ext2fs_mountfs(struct vnode *devvp, stru
 		m_fs->e2fs_bsize, 0, );
 		if (error)
 			goto out1;
-		e2fs_cgload(bp->b_data, _fs->e2fs_gd[i * sh],
+		e2fs_cgload(bp->b_data, _fs->e2fs_gd[i * m_fs->e2fs_bsize
+		/ sizeof(struct ext2_gd)],
 		m_fs->e2fs_bsize, m_fs->e2fs_group_desc_shift);
 		brelse(bp, 0);
 		bp = NULL;



CVS commit: src/sys/ufs/ext2fs

2023-08-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 26 22:08:22 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs_alloc.c

Log Message:
fix incorrect test


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/ufs/ext2fs/ext2fs_alloc.c

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs_alloc.c
diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.55 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.56
--- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.55	Sat Aug 26 17:37:28 2023
+++ src/sys/ufs/ext2fs/ext2fs_alloc.c	Sat Aug 26 18:08:22 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_alloc.c,v 1.55 2023/08/26 21:37:28 christos Exp $	*/
+/*	$NetBSD: ext2fs_alloc.c,v 1.56 2023/08/26 22:08:22 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.55 2023/08/26 21:37:28 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.56 2023/08/26 22:08:22 christos Exp $");
 
 #include 
 #include 
@@ -448,7 +448,7 @@ ext2fs_nodealloccg(struct inode *ip, int
 	if (ipref == -1)
 		ipref = 0;
 	fs = ip->i_e2fs;
-	if (fs->e2fs_gd[cg].ext2bgd_nifree == 0 ||
+	if (fs->e2fs_gd[cg].ext2bgd_nifree == 0 &&
 	fs->e2fs_gd[cg].ext2bgd_nifree_hi == 0)
 		return 0;
 	error = bread(ip->i_devvp, EXT2_FSBTODB64(fs,



CVS commit: src/sys/ufs/ext2fs

2023-08-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 26 22:08:22 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs_alloc.c

Log Message:
fix incorrect test


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/ufs/ext2fs/ext2fs_alloc.c

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



CVS commit: src/sys/ufs/ext2fs

2023-08-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 26 21:56:23 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
fix kmem_free size for e2fs_gd


To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs_vfsops.c
diff -u src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.223 src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.224
--- src/sys/ufs/ext2fs/ext2fs_vfsops.c:1.223	Sat Aug 26 01:22:50 2023
+++ src/sys/ufs/ext2fs/ext2fs_vfsops.c	Sat Aug 26 17:56:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_vfsops.c,v 1.223 2023/08/26 05:22:50 riastradh Exp $	*/
+/*	$NetBSD: ext2fs_vfsops.c,v 1.224 2023/08/26 21:56:23 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.223 2023/08/26 05:22:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_vfsops.c,v 1.224 2023/08/26 21:56:23 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -767,11 +767,8 @@ ext2fs_mountfs(struct vnode *devvp, stru
 		EXT2_FSBTODB(m_fs, m_fs->e2fs.e2fs_first_dblock +
 		1 /* superblock */ + i),
 		m_fs->e2fs_bsize, 0, );
-		if (error) {
-			kmem_free(m_fs->e2fs_gd,
-			m_fs->e2fs_ngdb * m_fs->e2fs_bsize);
-			goto out;
-		}
+		if (error)
+			goto out1;
 		e2fs_cgload(bp->b_data, _fs->e2fs_gd[i * sh],
 		m_fs->e2fs_bsize, m_fs->e2fs_group_desc_shift);
 		brelse(bp, 0);
@@ -779,10 +776,8 @@ ext2fs_mountfs(struct vnode *devvp, stru
 	}
 
 	error = ext2fs_cg_verify_and_initialize(devvp, m_fs, ronly);
-	if (error) {
-		kmem_free(m_fs->e2fs_gd, m_fs->e2fs_ngdb * m_fs->e2fs_bsize);
-		goto out;
-	}
+	if (error)
+		goto out1;
 
 	mp->mnt_data = ump;
 	mp->mnt_stat.f_fsidx.__fsid_val[0] = (long)dev;
@@ -807,6 +802,8 @@ ext2fs_mountfs(struct vnode *devvp, stru
 	spec_node_setmountedfs(devvp, mp);
 	return 0;
 
+out1:
+	kmem_free(m_fs->e2fs_gd, m_fs->e2fs_ngdb * sh * sizeof(struct ext2_gd));
 out:
 	if (bp != NULL)
 		brelse(bp, 0);
@@ -847,7 +844,8 @@ ext2fs_unmount(struct mount *mp, int mnt
 	error = VOP_CLOSE(ump->um_devvp, fs->e2fs_ronly ? FREAD : FREAD|FWRITE,
 	NOCRED);
 	vput(ump->um_devvp);
-	kmem_free(fs->e2fs_gd, fs->e2fs_ngdb * fs->e2fs_bsize);
+	int32_t sh = fs->e2fs_bsize >> fs->e2fs_group_desc_shift;
+	kmem_free(fs->e2fs_gd, fs->e2fs_ngdb * sh * sizeof(struct ext2_gd));
 	kmem_free(fs, sizeof(*fs));
 	kmem_free(ump, sizeof(*ump));
 	mp->mnt_data = NULL;



CVS commit: src/sys/ufs/ext2fs

2023-08-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 26 21:56:23 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
fix kmem_free size for e2fs_gd


To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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



CVS commit: src/sys/ufs/ext2fs

2023-08-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 26 21:37:28 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs_alloc.c

Log Message:
Fix metadata_cksum (Vladimir Serbinenko)

Current code always assumes that CG uses crc16. Yet when metadata_cksum is
enabled then it uses truncated crc32c. This patch doesn't implement full
metadata_cksum, just allows volumes with metadata_cksum to be mounted
read-only.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/ufs/ext2fs/ext2fs_alloc.c

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs_alloc.c
diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.54 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.55
--- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.54	Sat Aug 26 01:22:50 2023
+++ src/sys/ufs/ext2fs/ext2fs_alloc.c	Sat Aug 26 17:37:28 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_alloc.c,v 1.54 2023/08/26 05:22:50 riastradh Exp $	*/
+/*	$NetBSD: ext2fs_alloc.c,v 1.55 2023/08/26 21:37:28 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.54 2023/08/26 05:22:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.55 2023/08/26 21:37:28 christos Exp $");
 
 #include 
 #include 
@@ -710,6 +710,85 @@ ext2fs_cg_update(struct m_ext2fs *fs, in
 		gd->ext2bgd_checksum = ext2fs_cg_get_csum(fs, cg, gd);
 }
 
+static const uint32_t ext2fs_crc32c_table[256] = {
+	0x, 0xf26b8303, 0xe13b70f7, 0x1350f3f4,
+	0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb,
+	0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b,
+	0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24,
+	0x105ec76f, 0xe235446c, 0xf165b798, 0x030e349b,
+	0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384,
+	0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54,
+	0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b,
+	0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a,
+	0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35,
+	0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5,
+	0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa,
+	0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45,
+	0xf779deae, 0x05125dad, 0x1642ae59, 0xe4292d5a,
+	0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a,
+	0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595,
+	0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48,
+	0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957,
+	0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687,
+	0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198,
+	0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927,
+	0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38,
+	0xdbfc821c, 0x2997011f, 0x3ac7f2eb, 0xc8ac71e8,
+	0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7,
+	0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096,
+	0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789,
+	0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859,
+	0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46,
+	0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9,
+	0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6,
+	0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36,
+	0x3cdb9bdd, 0xceb018de, 0xdde0eb2a, 0x2f8b6829,
+	0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c,
+	0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93,
+	0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043,
+	0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c,
+	0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3,
+	0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc,
+	0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c,
+	0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033,
+	0xa24bb5a6, 0x502036a5, 0x4370c551, 0xb11b4652,
+	0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d,
+	0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d,
+	0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982,
+	0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d,
+	0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622,
+	0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2,
+	0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed,
+	0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530,
+	0x0417b1db, 0xf67c32d8, 0xe52cc12c, 0x1747422f,
+	0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff,
+	0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0,
+	0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f,
+	0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540,
+	0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90,
+	0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f,
+	0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee,
+	0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1,
+	0x69e9f0d5, 0x9b8273d6, 0x88d28022, 0x7ab90321,
+	0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e,
+	0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81,
+	0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e,
+	0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e,
+	0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351,
+};
+
+static uint32_t
+ext2fs_crc32c(uint32_t last, const void *vbuf, size_t len)
+{
+	uint32_t crc = last;
+	const uint8_t *buf = vbuf;
+
+	while (len--)
+		crc = ext2fs_crc32c_table[(crc ^ *buf++) & 0xff] ^ (crc >> 8);
+
+	return crc;
+}
+
 /*
  * 

CVS commit: src/sys/ufs/ext2fs

2023-08-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Aug 26 21:37:28 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs_alloc.c

Log Message:
Fix metadata_cksum (Vladimir Serbinenko)

Current code always assumes that CG uses crc16. Yet when metadata_cksum is
enabled then it uses truncated crc32c. This patch doesn't implement full
metadata_cksum, just allows volumes with metadata_cksum to be mounted
read-only.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/sys/ufs/ext2fs/ext2fs_alloc.c

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



CVS commit: src/sys/ufs/ext2fs

2023-08-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 26 05:22:50 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_bmap.c
ext2fs_bswap.c ext2fs_extents.h ext2fs_extern.h ext2fs_htree.c
ext2fs_inode.c ext2fs_lookup.c ext2fs_rename.c ext2fs_vfsops.c
ext2fs_vnops.c

Log Message:
ext2fs: Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ext2fs/ext2fs.h
cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ext2fs/ext2fs_alloc.c
cvs rdiff -u -r1.30 -r1.31 src/sys/ufs/ext2fs/ext2fs_bmap.c
cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/ext2fs/ext2fs_bswap.c
cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/ext2fs/ext2fs_extents.h
cvs rdiff -u -r1.56 -r1.57 src/sys/ufs/ext2fs/ext2fs_extern.h
cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ext2fs/ext2fs_htree.c
cvs rdiff -u -r1.90 -r1.91 src/sys/ufs/ext2fs/ext2fs_inode.c
cvs rdiff -u -r1.93 -r1.94 src/sys/ufs/ext2fs/ext2fs_lookup.c
cvs rdiff -u -r1.12 -r1.13 src/sys/ufs/ext2fs/ext2fs_rename.c
cvs rdiff -u -r1.222 -r1.223 src/sys/ufs/ext2fs/ext2fs_vfsops.c
cvs rdiff -u -r1.137 -r1.138 src/sys/ufs/ext2fs/ext2fs_vnops.c

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs.h
diff -u src/sys/ufs/ext2fs/ext2fs.h:1.50 src/sys/ufs/ext2fs/ext2fs.h:1.51
--- src/sys/ufs/ext2fs/ext2fs.h:1.50	Sat Aug 26 05:18:17 2023
+++ src/sys/ufs/ext2fs/ext2fs.h	Sat Aug 26 05:22:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.h,v 1.50 2023/08/26 05:18:17 riastradh Exp $	*/
+/*	$NetBSD: ext2fs.h,v 1.51 2023/08/26 05:22:50 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -177,7 +177,7 @@ struct ext2fs {
 	uint8_t   e2fs_prealloc;	/* # of blocks to preallocate */
 	uint8_t   e2fs_dir_prealloc;	/* # of blocks to preallocate for dir */
 	uint16_t  e2fs_reserved_ngdb;	/* # of reserved gd blocks for resize */
-	
+
 	/* Additional fields */
 	char  e3fs_journal_uuid[16];/* uuid of journal superblock */
 	uint32_t  e3fs_journal_inum;	/* inode number of journal file */
@@ -356,7 +356,7 @@ struct m_ext2fs {
  * - EXT2F_ROCOMPAT_SPARSESUPER
  *superblock backups stored only in cg_has_sb(bno) groups
  * - EXT2F_ROCOMPAT_LARGEFILE
- *use e2di_size_high in struct ext2fs_dinode to store 
+ *use e2di_size_high in struct ext2fs_dinode to store
  *upper 32bit of size for >2GB files
  * - EXT2F_INCOMPAT_FTYPE
  *store file type to e2d_type in struct ext2fs_direct
@@ -424,7 +424,7 @@ struct ext2_gd {
 	uint16_t ext2bgd_ndirs;		/* number of directories */
 
 	/*
-	 * Following only valid when either GDT_CSUM (AKA uninit_bg) 
+	 * Following only valid when either GDT_CSUM (AKA uninit_bg)
 	 * or METADATA_CKSUM feature is on
 	 */
 	uint16_t ext2bgd_flags;		/* ext4 bg flags (INODE_UNINIT, ...)*/
@@ -450,7 +450,7 @@ struct ext2_gd {
 
 #define E2FS_HAS_GD_CSUM(fs) \
 	EXT2F_HAS_ROCOMPAT_FEATURE(fs, EXT2F_ROCOMPAT_GDT_CSUM|EXT2F_ROCOMPAT_METADATA_CKSUM) != 0
-	
+
 /*
  * If the EXT2F_ROCOMPAT_SPARSESUPER flag is set, the cylinder group has a
  * copy of the super and cylinder group descriptors blocks only if it's

Index: src/sys/ufs/ext2fs/ext2fs_alloc.c
diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.53 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.54
--- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.53	Fri Aug 25 16:50:23 2023
+++ src/sys/ufs/ext2fs/ext2fs_alloc.c	Sat Aug 26 05:22:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_alloc.c,v 1.53 2023/08/25 16:50:23 christos Exp $	*/
+/*	$NetBSD: ext2fs_alloc.c,v 1.54 2023/08/26 05:22:50 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.53 2023/08/25 16:50:23 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.54 2023/08/26 05:22:50 riastradh Exp $");
 
 #include 
 #include 
@@ -667,7 +667,7 @@ ext2fs_cg_update(struct m_ext2fs *fs, in
 	if (nifree) {
 		uint32_t ext2bgd_nifree = fs2h16(gd->ext2bgd_nifree) |
 		(fs2h16(gd->ext2bgd_nifree_hi) << 16);
-		ext2bgd_nifree += nifree; 
+		ext2bgd_nifree += nifree;
 		gd->ext2bgd_nifree = h2fs16(ext2bgd_nifree);
 		gd->ext2bgd_nifree_hi = h2fs16(ext2bgd_nifree >> 16);
 		/*
@@ -696,7 +696,6 @@ ext2fs_cg_update(struct m_ext2fs *fs, in
 		ext2bgd_nbfree += nbfree;
 		gd->ext2bgd_nbfree = h2fs16(ext2bgd_nbfree);
 		gd->ext2bgd_nbfree_hi = h2fs16(ext2bgd_nbfree >> 16);
-		
 	}
 
 	if (ndirs) {
@@ -821,7 +820,7 @@ ext2fs_cg_verify_and_initialize(struct v
 (int)fs->e2fs_bsize, 0, 0);
 clrbuf(bp);
 			}
-	
+
 			bdwrite(bp);
 		}
 

Index: src/sys/ufs/ext2fs/ext2fs_bmap.c
diff -u src/sys/ufs/ext2fs/ext2fs_bmap.c:1.30 src/sys/ufs/ext2fs/ext2fs_bmap.c:1.31
--- src/sys/ufs/ext2fs/ext2fs_bmap.c:1.30	Sun Aug 14 11:26:35 2016
+++ src/sys/ufs/ext2fs/ext2fs_bmap.c	Sat Aug 26 05:22:50 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_bmap.c,v 1.30 2016/08/14 11:26:35 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs_bmap.c,v 1.31 

CVS commit: src/sys/ufs/ext2fs

2023-08-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 26 05:22:50 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_bmap.c
ext2fs_bswap.c ext2fs_extents.h ext2fs_extern.h ext2fs_htree.c
ext2fs_inode.c ext2fs_lookup.c ext2fs_rename.c ext2fs_vfsops.c
ext2fs_vnops.c

Log Message:
ext2fs: Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ext2fs/ext2fs.h
cvs rdiff -u -r1.53 -r1.54 src/sys/ufs/ext2fs/ext2fs_alloc.c
cvs rdiff -u -r1.30 -r1.31 src/sys/ufs/ext2fs/ext2fs_bmap.c
cvs rdiff -u -r1.24 -r1.25 src/sys/ufs/ext2fs/ext2fs_bswap.c
cvs rdiff -u -r1.4 -r1.5 src/sys/ufs/ext2fs/ext2fs_extents.h
cvs rdiff -u -r1.56 -r1.57 src/sys/ufs/ext2fs/ext2fs_extern.h
cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ext2fs/ext2fs_htree.c
cvs rdiff -u -r1.90 -r1.91 src/sys/ufs/ext2fs/ext2fs_inode.c
cvs rdiff -u -r1.93 -r1.94 src/sys/ufs/ext2fs/ext2fs_lookup.c
cvs rdiff -u -r1.12 -r1.13 src/sys/ufs/ext2fs/ext2fs_rename.c
cvs rdiff -u -r1.222 -r1.223 src/sys/ufs/ext2fs/ext2fs_vfsops.c
cvs rdiff -u -r1.137 -r1.138 src/sys/ufs/ext2fs/ext2fs_vnops.c

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



CVS commit: src/sys/ufs/ext2fs

2023-08-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 26 05:18:17 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h

Log Message:
ext2fs.h: Restore e2fs_cgload/cgsave for libsa and userland use.

Stop-gap until they can be taught to handle the new version that was
moved to ext2fs_vfsops.c, presumably.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/ufs/ext2fs/ext2fs.h

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs.h
diff -u src/sys/ufs/ext2fs/ext2fs.h:1.49 src/sys/ufs/ext2fs/ext2fs.h:1.50
--- src/sys/ufs/ext2fs/ext2fs.h:1.49	Fri Aug 25 16:50:23 2023
+++ src/sys/ufs/ext2fs/ext2fs.h	Sat Aug 26 05:18:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.h,v 1.49 2023/08/25 16:50:23 christos Exp $	*/
+/*	$NetBSD: ext2fs.h,v 1.50 2023/08/26 05:18:17 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -498,6 +498,12 @@ void e2fs_sb_bswap(struct ext2fs *, stru
 #	define e2fs_sbsave(old, new) e2fs_sb_bswap((old), (new))
 #endif
 
+#ifndef _KERNEL		/* XXX */
+/* Group descriptors are not byte swapped */
+#define e2fs_cgload(old, new, size) memcpy((new), (old), (size))
+#define e2fs_cgsave(old, new, size) memcpy((new), (old), (size))
+#endif
+
 /*
  * Turn file system block numbers into disk block addresses.
  * This maps file system blocks to device size blocks.



CVS commit: src/sys/ufs/ext2fs

2023-08-25 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Aug 26 05:18:17 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h

Log Message:
ext2fs.h: Restore e2fs_cgload/cgsave for libsa and userland use.

Stop-gap until they can be taught to handle the new version that was
moved to ext2fs_vfsops.c, presumably.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/ufs/ext2fs/ext2fs.h

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



CVS commit: src/sys/ufs/ext2fs

2023-08-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Aug 25 16:50:23 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_vfsops.c

Log Message:
Support INCOMPAT_64BIT on ext4 (Vladimir 'phcoder' Serbinenko)


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ext2fs/ext2fs.h
cvs rdiff -u -r1.52 -r1.53 src/sys/ufs/ext2fs/ext2fs_alloc.c
cvs rdiff -u -r1.221 -r1.222 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs.h
diff -u src/sys/ufs/ext2fs/ext2fs.h:1.48 src/sys/ufs/ext2fs/ext2fs.h:1.49
--- src/sys/ufs/ext2fs/ext2fs.h:1.48	Sat Aug 20 15:47:44 2016
+++ src/sys/ufs/ext2fs/ext2fs.h	Fri Aug 25 12:50:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.h,v 1.48 2016/08/20 19:47:44 jdolecek Exp $	*/
+/*	$NetBSD: ext2fs.h,v 1.49 2023/08/25 16:50:23 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -252,6 +252,7 @@ struct m_ext2fs {
 	int32_t	e2fs_ngdb;	/* number of group descriptor blocks */
 	int32_t	e2fs_ipb;	/* number of inodes per block */
 	int32_t	e2fs_itpg;	/* number of inode table blocks per group */
+	uint8_t e2fs_group_desc_shift; /* binary log group desc size */
 	struct	ext2_gd *e2fs_gd; /* group descriptors (data not byteswapped) */
 };
 
@@ -370,7 +371,8 @@ struct m_ext2fs {
 	 | EXT2F_ROCOMPAT_GDT_CSUM)
 #define EXT2F_INCOMPAT_SUPP		(EXT2F_INCOMPAT_FTYPE \
 	 | EXT2F_INCOMPAT_EXTENTS \
-	 | EXT2F_INCOMPAT_FLEX_BG)
+	 | EXT2F_INCOMPAT_FLEX_BG \
+	 | EXT2F_INCOMPAT_64BIT)
 
 /*
  * Feature set definitions
@@ -432,10 +434,14 @@ struct ext2_gd {
 	uint16_t ext2bgd_itable_unused_lo;	/* Low unused inode offset */
 	uint16_t ext2bgd_checksum;		/* Group desc checksum */
 
-	/*
-	 * XXX disk32 Further fields only exist if 64BIT feature is on
-	 * and superblock desc_size > 32, not supported for now.
-	 */
+	uint32_t ext2bgd_b_bitmap_hi;	/* blocks bitmap block (high bits) */
+	uint32_t ext2bgd_i_bitmap_hi;	/* inodes bitmap block (high bits) */
+	uint32_t ext2bgd_i_tables_hi;	/* inodes table block (high bits)  */
+	uint16_t ext2bgd_nbfree_hi;	/* number of free blocks (high bits) */
+	uint16_t ext2bgd_nifree_hi;	/* number of free inodes (high bits) */
+	uint16_t ext2bgd_ndirs_hi;	/* number of directories (high bits) */
+	uint16_t reserved_hi;
+	uint32_t reserved2_hi[3];
 };
 
 #define E2FS_BG_INODE_UNINIT	0x0001	/* Inode bitmap not used/initialized */
@@ -492,15 +498,15 @@ void e2fs_sb_bswap(struct ext2fs *, stru
 #	define e2fs_sbsave(old, new) e2fs_sb_bswap((old), (new))
 #endif
 
-/* Group descriptors are not byte swapped */
-#define e2fs_cgload(old, new, size) memcpy((new), (old), (size))
-#define e2fs_cgsave(old, new, size) memcpy((new), (old), (size))
-
 /*
  * Turn file system block numbers into disk block addresses.
  * This maps file system blocks to device size blocks.
  */
 #define EXT2_FSBTODB(fs, b)	((b) << (fs)->e2fs_fsbtodb)
+#define EXT2_FSBTODB64(fs, b, b_hi) \
+(uint64_t)(b_hi)) << 32) | (b)) << (fs)->e2fs_fsbtodb)
+#define EXT2_FSBTODB64OFF(fs, b, b_hi, off) \
+((uint64_t)(b_hi)) << 32) | (b)) + (off)) << (fs)->e2fs_fsbtodb)
 #define EXT2_DBTOFSB(fs, b)	((b) >> (fs)->e2fs_fsbtodb)
 
 /*
@@ -510,9 +516,11 @@ void e2fs_sb_bswap(struct ext2fs *, stru
  *	 inode number to file system block address.
  */
 #define	ino_to_cg(fs, x)	(((x) - 1) / (fs)->e2fs.e2fs_ipg)
-#define	ino_to_fsba(fs, x)		\
-	(fs2h32((fs)->e2fs_gd[ino_to_cg((fs), (x))].ext2bgd_i_tables) +	\
-	(((x) - 1) % (fs)->e2fs.e2fs_ipg) / (fs)->e2fs_ipb)
+#define _e2fs_gd(fs, x) (fs)->e2fs_gd[ino_to_cg((fs), (x))]
+#define	ino_to_fsba(fs, x) \
+(fs2h32(_e2fs_gd(fs, x).ext2bgd_i_tables) + \
+ (((uint64_t)fs2h32(_e2fs_gd(fs, x).ext2bgd_i_tables_hi)) << 32) + \
+ (((x) - 1) % (fs)->e2fs.e2fs_ipg) / (fs)->e2fs_ipb)
 #define	ino_to_fsbo(fs, x)	(((x) - 1) % (fs)->e2fs_ipb)
 
 /*

Index: src/sys/ufs/ext2fs/ext2fs_alloc.c
diff -u src/sys/ufs/ext2fs/ext2fs_alloc.c:1.52 src/sys/ufs/ext2fs/ext2fs_alloc.c:1.53
--- src/sys/ufs/ext2fs/ext2fs_alloc.c:1.52	Sun May 28 12:38:55 2017
+++ src/sys/ufs/ext2fs/ext2fs_alloc.c	Fri Aug 25 12:50:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_alloc.c,v 1.52 2017/05/28 16:38:55 hannken Exp $	*/
+/*	$NetBSD: ext2fs_alloc.c,v 1.53 2023/08/25 16:50:23 christos Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -60,7 +60,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.52 2017/05/28 16:38:55 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_alloc.c,v 1.53 2023/08/25 16:50:23 christos Exp $");
 
 #include 
 #include 
@@ -90,9 +90,11 @@ static u_long	ext2fs_hashalloc(struct in
 		daddr_t (*)(struct inode *, int, daddr_t, int));
 static daddr_t	ext2fs_nodealloccg(struct inode *, int, daddr_t, int);
 static daddr_t	ext2fs_mapsearch(struct m_ext2fs *, char *, daddr_t);
-static __inline void	ext2fs_cg_update(struct m_ext2fs *, 

CVS commit: src/sys/ufs/ext2fs

2023-08-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Aug 25 16:50:23 UTC 2023

Modified Files:
src/sys/ufs/ext2fs: ext2fs.h ext2fs_alloc.c ext2fs_vfsops.c

Log Message:
Support INCOMPAT_64BIT on ext4 (Vladimir 'phcoder' Serbinenko)


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/ufs/ext2fs/ext2fs.h
cvs rdiff -u -r1.52 -r1.53 src/sys/ufs/ext2fs/ext2fs_alloc.c
cvs rdiff -u -r1.221 -r1.222 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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



CVS commit: src/sys/ufs/ext2fs

2022-05-04 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed May  4 07:34:29 UTC 2022

Modified Files:
src/sys/ufs/ext2fs: ext2fs_htree.c

Log Message:
s/entires/entries/ in local variable definition.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ext2fs/ext2fs_htree.c

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

Modified files:

Index: src/sys/ufs/ext2fs/ext2fs_htree.c
diff -u src/sys/ufs/ext2fs/ext2fs_htree.c:1.9 src/sys/ufs/ext2fs/ext2fs_htree.c:1.10
--- src/sys/ufs/ext2fs/ext2fs_htree.c:1.9	Tue Aug 23 06:23:26 2016
+++ src/sys/ufs/ext2fs/ext2fs_htree.c	Wed May  4 07:34:28 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs_htree.c,v 1.9 2016/08/23 06:23:26 christos Exp $	*/
+/*	$NetBSD: ext2fs_htree.c,v 1.10 2022/05/04 07:34:28 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2012 Zheng Liu 
@@ -29,7 +29,7 @@
  * $FreeBSD: head/sys/fs/ext2fs/ext2fs_htree.c 294653 2016-01-24 02:41:49Z pfg $
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.9 2016/08/23 06:23:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ext2fs_htree.c,v 1.10 2022/05/04 07:34:28 andvar Exp $");
 
 #include 
 #include 
@@ -495,7 +495,7 @@ ext2fs_htree_add_entry(struct vnode *dvp
 	char *newidxblock = NULL;
 	struct ext2fs_htree_node *dst_node;
 	struct ext2fs_htree_entry *dst_entries;
-	struct ext2fs_htree_entry *root_entires;
+	struct ext2fs_htree_entry *root_entries;
 	struct buf *dst_bp = NULL;
 	int error, write_bp = 0, write_dst_bp = 0, write_info = 0;
 
@@ -517,7 +517,7 @@ ext2fs_htree_add_entry(struct vnode *dvp
 	ent_num = ext2fs_htree_get_count(entries);
 	if (ent_num == ext2fs_htree_get_limit(entries)) {
 		/* Split the index node. */
-		root_entires = info.h_levels[0].h_entries;
+		root_entries = info.h_levels[0].h_entries;
 		newidxblock = malloc(blksize, M_TEMP, M_WAITOK | M_ZERO);
 		dst_node = (struct ext2fs_htree_node *)newidxblock;
 		dst_entries = dst_node->h_entries;
@@ -543,8 +543,8 @@ ext2fs_htree_add_entry(struct vnode *dvp
 		if (info.h_levels_num == 2) {
 			uint16_t src_ent_num, dst_ent_num;
 
-			if (ext2fs_htree_get_count(root_entires) ==
-			ext2fs_htree_get_limit(root_entires)) {
+			if (ext2fs_htree_get_count(root_entries) ==
+			ext2fs_htree_get_limit(root_entries)) {
 /* Directory index is full */
 error = EIO;
 goto finish;



CVS commit: src/sys/ufs/ext2fs

2022-05-04 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Wed May  4 07:34:29 UTC 2022

Modified Files:
src/sys/ufs/ext2fs: ext2fs_htree.c

Log Message:
s/entires/entries/ in local variable definition.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/ext2fs/ext2fs_htree.c

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



Re: CVS commit: src/sys/ufs/ext2fs

2016-08-24 Thread David Holland
On Tue, Aug 23, 2016 at 02:24:30AM -0400, Christos Zoulas wrote:
 > Modified Files:
 >  src/sys/ufs/ext2fs: ext2fs_vfsops.c
 > 
 > Log Message:
 > CID 1371644: use strlcpy, remove dup copy.

You sure about the dup copy? Those are different string buffers.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/ufs/ext2fs

2016-06-04 Thread Christopher Humphries
Thank you, Hrishikesh!
On Jun 3, 2016 11:35, "Christos Zoulas"  wrote:

> Module Name:src
> Committed By:   christos
> Date:   Fri Jun  3 15:35:48 UTC 2016
>
> Modified Files:
> src/sys/ufs/ext2fs: ext2fs.h ext2fs_bmap.c
> Added Files:
> src/sys/ufs/ext2fs: ext2fs_extents.c ext2fs_extents.h
>
> Log Message:
> Add ext4 extent support from GSoC 2016 (Hrishikesh Goyal), from the FreeBSD
> ext2 code.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.36 -r1.37 src/sys/ufs/ext2fs/ext2fs.h
> cvs rdiff -u -r1.26 -r1.27 src/sys/ufs/ext2fs/ext2fs_bmap.c
> cvs rdiff -u -r0 -r1.1 src/sys/ufs/ext2fs/ext2fs_extents.c \
> src/sys/ufs/ext2fs/ext2fs_extents.h
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
>
>


Re: CVS commit: src/sys/ufs/ext2fs

2015-02-23 Thread Ryota Ozaki
Hi,

On Sun, Feb 22, 2015 at 11:55 PM, Maxime Villard m...@netbsd.org wrote:
 Module Name:src
 Committed By:   maxv
 Date:   Sun Feb 22 14:55:23 UTC 2015

 Modified Files:
 src/sys/ufs/ext2fs: ext2fs_vfsops.c

 Log Message:
 Merge _sbcompute() and _sbcheck() into _sbfill().

 In ext2fs_sbfill(), check more fields of the superblock, to prevent
 several kernel panics when mounting/unmounting a disk.

This change seems to break ATF tests.
http://releng.netbsd.org/b5reports/amd64/commits-2015.02.html#end

Could you check what happens?

  ozaki-r



 To generate a diff of this commit:
 cvs rdiff -u -r1.188 -r1.189 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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



Re: CVS commit: src/sys/ufs/ext2fs

2015-02-23 Thread Maxime Villard
Le 23/02/2015 14:51, Ryota Ozaki a écrit :
 Hi,
 
 On Sun, Feb 22, 2015 at 11:55 PM, Maxime Villard m...@netbsd.org wrote:
 Module Name:src
 Committed By:   maxv
 Date:   Sun Feb 22 14:55:23 UTC 2015

 Modified Files:
 src/sys/ufs/ext2fs: ext2fs_vfsops.c

 Log Message:
 Merge _sbcompute() and _sbcheck() into _sbfill().

 In ext2fs_sbfill(), check more fields of the superblock, to prevent
 several kernel panics when mounting/unmounting a disk.
 
 This change seems to break ATF tests.
 http://releng.netbsd.org/b5reports/amd64/commits-2015.02.html#end
 
 Could you check what happens?
 

Ok, I've switched back to more simple checks.

I tested my changes with a Linux-formatted disk, and fuzzed several
times some fields. It did work.

Thanks for pointing this out.

   ozaki-r
 


 To generate a diff of this commit:
 cvs rdiff -u -r1.188 -r1.189 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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

 



CVS commit: src/sys/ufs/ext2fs

2010-02-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Feb 11 19:50:34 UTC 2010

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
There is no code left that uses disk size data, so don't query it.


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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



CVS commit: src/sys/ufs/ext2fs

2010-01-31 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Jan 31 10:36:20 UTC 2010

Modified Files:
src/sys/ufs/ext2fs: ext2fs_vfsops.c

Log Message:
Replace individual queries for partition information with
new helper function.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/sys/ufs/ext2fs/ext2fs_vfsops.c

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



Re: CVS commit: src/sys/ufs/ext2fs

2009-09-12 Thread Joerg Sonnenberger
On Sat, Sep 12, 2009 at 07:40:41AM +0200, Christoph Egger wrote:
 Izumi Tsutsui wrote:
  Reduce diffs a bit between ext2fs_reload() and ffs_reload().
  It sounds like ext2fs and ffs can share some code.
  
  Many people say ext2fs is a bad mimic of ufs
  and actually both ffs and ext2fs are under sys/ufs/,
  though detailed structures (reinvented by Linux guys?)
  are somewhat different to share vfsops/vnops sources.
 
 This sounds some helpers and higher level functions
 can be shared and that Low level functions and accessors
 to the structures can't be shared.

This sounds like an arm chair philosopher. Please read the code for what
is shared and what not.

Joerg


Re: CVS commit: src/sys/ufs/ext2fs

2009-09-11 Thread Izumi Tsutsui
  Reduce diffs a bit between ext2fs_reload() and ffs_reload().
 
 It sounds like ext2fs and ffs can share some code.

Many people say ext2fs is a bad mimic of ufs
and actually both ffs and ext2fs are under sys/ufs/,
though detailed structures (reinvented by Linux guys?)
are somewhat different to share vfsops/vnops sources.
---
Izumi Tsutsui


Re: CVS commit: src/sys/ufs/ext2fs

2009-09-11 Thread Christoph Egger
Izumi Tsutsui wrote:
 Reduce diffs a bit between ext2fs_reload() and ffs_reload().
 It sounds like ext2fs and ffs can share some code.
 
 Many people say ext2fs is a bad mimic of ufs
 and actually both ffs and ext2fs are under sys/ufs/,
 though detailed structures (reinvented by Linux guys?)
 are somewhat different to share vfsops/vnops sources.

This sounds some helpers and higher level functions
can be shared and that Low level functions and accessors
to the structures can't be shared.

Christoph