NetBSD Problem Report #58545
From www@netbsd.org Sat Aug 3 07:21:50 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits)
client-signature RSA-PSS (2048 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id A18C11A923E
for <gnats-bugs@gnats.NetBSD.org>; Sat, 3 Aug 2024 07:21:50 +0000 (UTC)
Message-Id: <20240803072149.648891A923F@mollari.NetBSD.org>
Date: Sat, 3 Aug 2024 07:21:49 +0000 (UTC)
From: rvp@SDF.ORG
Reply-To: rvp@SDF.ORG
To: gnats-bugs@NetBSD.org
Subject: e2fsprogs-1.46.4nb2: error updating superblock on raw devices
X-Send-Pr-Version: www-1.0
>Number: 58545
>Category: pkg
>Synopsis: e2fsprogs-1.46.4nb2: error updating superblock on raw devices
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: pkg-manager
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Aug 03 07:25:01 +0000 2024
>Closed-Date: Sat Aug 03 07:33:48 +0000 2024
>Last-Modified: Sat Aug 03 07:35:01 +0000 2024
>Originator: RVP
>Release: pkgsrc-2024Q2
>Organization:
>Environment:
NetBSD/amd64 10.99.11
>Description:
On NetBSD, if you run e2fsck on a raw (ie. char.) disk device, you get
this error:
```
$ ls -l /dev/rdk11
crw-r----- 1 root operator 168, 11 Apr 17 05:53 /dev/rdk11
$ sudo e2fsck -f /dev/rdk11
Password:
e2fsck 1.46.4 (18-Aug-2021)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Error writing file system info: Invalid argument
/dev/rdk11: ***** FILE SYSTEM WAS MODIFIED *****
```
and the modified superblock is not written (try running the command
again and you'll get the same error) because e2fsck tries to write
only the modified bytes at non-block-size offsets and this is not
permitted on raw disk devices.
If you run e2fsck on the block device (/dev/dk11), then there are, of course, no such alignment/block-size write-restrictions and it succeeds.
Alas, however, you don't want to use these as any reads/writes to them
go through the buffer-cache, a) making the checks slow and b) evicting
the more useful stuff in them.
>How-To-Repeat:
e2fsck -f /dev/rdkNN
>Fix:
Teach e2fsprogs that raw devices on NetBSD behave the same as do char. devices on FreeBSD. e2fsprogs will then read/write full blocks.
```
diff -urN e2fsprogs-1.47.1.orig/lib/ext2fs/ext2fsP.h e2fsprogs-1.47.1/lib/ext2fs/ext2fsP.h
--- e2fsprogs-1.47.1.orig/lib/ext2fs/ext2fsP.h 2024-05-21 02:52:47.000000000 +0000
+++ e2fsprogs-1.47.1/lib/ext2fs/ext2fsP.h 2024-07-29 08:00:38.703197642 +0000
@@ -19,7 +19,7 @@
static inline int ext2fsP_is_disk_device(mode_t mode)
{
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
return S_ISBLK(mode) || S_ISCHR(mode);
#else
return S_ISBLK(mode);
diff -urN e2fsprogs-1.47.1.orig/lib/ext2fs/unix_io.c e2fsprogs-1.47.1/lib/ext2fs/unix_io.c
--- e2fsprogs-1.47.1.orig/lib/ext2fs/unix_io.c 2024-05-21 02:52:47.000000000 +0000
+++ e2fsprogs-1.47.1/lib/ext2fs/unix_io.c 2024-07-29 07:56:56.045970673 +0000
@@ -780,7 +780,7 @@
io->align = 512;
#endif
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
if (io->flags & CHANNEL_FLAGS_BLOCK_DEVICE) {
int dio_align = ext2fs_get_dio_alignment(fd);
```
Note that
a) the patch is for the latest e2fsprogs version, and,
b) you'll need to pass `--without-libarchive' to configure to bypass
the lack of a uselocale(3) on NetBSD.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Sat, 03 Aug 2024 07:33:48 +0000
State-Changed-Why:
Committed, thanks.
Please make sure to send these upstream. Thank you!
From: "Thomas Klausner" <wiz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/58545 CVS commit: pkgsrc/sysutils/e2fsprogs
Date: Sat, 3 Aug 2024 07:33:30 +0000
Module Name: pkgsrc
Committed By: wiz
Date: Sat Aug 3 07:33:29 UTC 2024
Modified Files:
pkgsrc/sysutils/e2fsprogs: Makefile distinfo
Added Files:
pkgsrc/sysutils/e2fsprogs/patches: patch-lib_ext2fs_ext2fsP.h
patch-lib_ext2fs_unix__io.c
Log Message:
e2fsprogs: handle character devices on NetBSD like on FreeBSD
From RVP in PR 58545.
Bump PKGREVISION.
To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 pkgsrc/sysutils/e2fsprogs/Makefile
cvs rdiff -u -r1.27 -r1.28 pkgsrc/sysutils/e2fsprogs/distinfo
cvs rdiff -u -r0 -r1.1 \
pkgsrc/sysutils/e2fsprogs/patches/patch-lib_ext2fs_ext2fsP.h \
pkgsrc/sysutils/e2fsprogs/patches/patch-lib_ext2fs_unix__io.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.