Module Name:    src
Committed By:   tsutsui
Date:           Wed May 15 12:47:22 UTC 2024

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

Log Message:
Fix an old bug in NATIVELABEL_ONLY case in PR/50729 by me. (sigh)

'disklabel -r -w' writes a disklabel at a wrong sector in
NATIVELABEL_ONLY && !LABELUSESMBR && LABELSECTOR != 0 case
if the target disk doesn't have a valid disklabel, due to
incorrect LABEL_OFFSET value.

Found and investigated on NetBSD/hp300 bootable CD tests.
Maybe this affects ports that use distrib/utils/x_disklabel
but have no MBR support, i.e. only NetBSD/hp300 10.0 and
NetBSD/ews4800mips 9.0 and later.

Should be pulled up to netbsd-10 and netbsd-9.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sbin/disklabel/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/disklabel/main.c
diff -u src/sbin/disklabel/main.c:1.57 src/sbin/disklabel/main.c:1.58
--- src/sbin/disklabel/main.c:1.57	Wed Nov  3 14:25:39 2021
+++ src/sbin/disklabel/main.c	Wed May 15 12:47:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.57 2021/11/03 14:25:39 nia Exp $	*/
+/*	$NetBSD: main.c,v 1.58 2024/05/15 12:47:22 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -76,7 +76,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 19
 static char sccsid[] = "@(#)disklabel.c	8.4 (Berkeley) 5/4/95";
 /* from static char sccsid[] = "@(#)disklabel.c	1.2 (Symmetric) 11/28/85"; */
 #else
-__RCSID("$NetBSD: main.c,v 1.57 2021/11/03 14:25:39 nia Exp $");
+__RCSID("$NetBSD: main.c,v 1.58 2024/05/15 12:47:22 tsutsui Exp $");
 #endif
 #endif	/* not lint */
 
@@ -352,7 +352,7 @@ static const struct arch_endian {
 #define labelsector	LABELSECTOR
 #define labelusesmbr	LABELUSESMBR
 #define maxpartitions	MAXPARTITIONS
-#define LABEL_OFFSET	LABELOFFSET
+#define LABEL_OFFSET	(LABELSECTOR * DEV_BSIZE + LABELOFFSET)
 #endif /* !NATIVELABEL_ONLY */
 
 /*

Reply via email to