NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/59650: ccdconfig -g shows incorrect date when cgd > 0



>Number:         59650
>Category:       kern
>Synopsis:       ccdconfig -g shows incorrect date when cgd > 0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 12 12:50:00 +0000 2025
>Originator:     Matthias Petermann
>Release:        NetBSD/amd64 10.1
>Organization:
>Environment:
NetBSD northstar.lan 10.1_STABLE NetBSD 10.1_STABLE (XEN3_DOM0) #0: Thu Sep 11 04:53:19 CEST 2025  mpeterma%x230.lan@localhost:/u/northstar/obj/sys/arch/amd64/compile/XEN3_DOM0 amd64
>Description:
Given the case I have configured more than one ccd device, ccdconfig -g doesn't print out the actual configuration but something like this:

```
northstar# ccdconfig -g
ccd0            0       0x0     429496729600    /dev/wedges/db...
ccd0            0       0x0     429496729600    /dev/wedges/db...
ccd0            0       0x0     429496729600    /dev/wedges/db...
ccd0            0       0x0     429496729600    /dev/wedges/db...
```

While the number of rows reflects the total number of configured rows, but doesn't show up with the correct device number. 
>How-To-Repeat:
Configure more than two ccd devices on NetBSD 10.1, call ccdconfig -g
>Fix:
Patch shared by mlestv in IRC: https://cdn.netbsd.org/pub/NetBSD/misc/mlelstv/ccd.c.diff

The patch is for NetBSD current. On NetBSD 10.1 (netbsd-10 branch) I was successful by applying its essential parts:

diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c
index b2397bace496..9aba276be665 100644
--- a/sys/dev/ccd.c
+++ b/sys/dev/ccd.c
@@ -1,4 +1,4 @@
-/*     $NetBSD: ccd.c,v 1.189.4.1 2024/04/18 18:24:31 martin Exp $     */
+/*     $NetBSD: ccd.c,v 1.192 2025/01/08 08:24:07 andvar Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -1750,17 +1750,17 @@ ccd_units_sysctl(SYSCTLFN_ARGS)
                LIST_FOREACH(sc, &ccds, sc_link) {
                        if (i >= nccd)
                                break;
-                       units[i] = sc->sc_unit;
+                       units[i++] = sc->sc_unit;
                }
+               nccd = i;
                mutex_exit(&ccd_lock);
        } else {
                units = NULL;
-               size = 0;
        }
 
        node = *rnode;
        node.sysctl_data = units;
-       node.sysctl_size = size;
+       node.sysctl_size = nccd * sizeof(*units);
 
        error = sysctl_lookup(SYSCTLFN_CALL(&node));
        if (units)
 



Home | Main Index | Thread Index | Old Index