kern/79575: [PATCH] Fixes order of disks in 'mdconfig -l' output
Wojciech A. Koszek
dunstan at freebsd.czest.pl
Tue Apr 5 15:20:04 PDT 2005
>Number: 79575
>Category: kern
>Synopsis: [PATCH] Fixes order of disks in 'mdconfig -l' output
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Tue Apr 05 22:20:03 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: Wojciech A. Koszek
>Release: FreeBSD 5.4-PRERELEASE i386
>Organization:
>Environment:
System: FreeBSD dunstan.freebsd.czest.pl 5.4-PRERELEASE FreeBSD 5.4-PRERELEASE #6: Mon Apr 4 21:06:12 CEST 2005 dunstan at dunstan.freebsd.czest.pl:/usr/obj/usr/src/sys/HOME8 i386
Also -CURRENT.
>Description:
While listing memory disks, their order is reversed, which makes reading
harder. I was informed that old implementation ordered disks
correctly.
>How-To-Repeat:
mdconfig -a -t malloc -s 10m
mdconfig -a -t malloc -s 10m
mdconfig -a -t malloc -s 10m
And result:
mdconfig -l
md2 md1 md0
>Fix:
This patch [diff.0.md.c] causes that result will be:
mdconfig -l
md0 md1 md2
--- diff.0.md.c begins here ---
(c) 2005 <Wojciech A. Koszek dunstan^freebsd.czest.pl>
Patch against FreeBSD 5.4-PRERELEASE, kern.osreldate: 503105.
diff -uprP /usr/src/sys/dev/md/md.c src/sys/dev/md/md.c
--- /usr/src/sys/dev/md/md.c Tue Mar 1 22:49:18 2005
+++ src/sys/dev/md/md.c Tue Apr 5 22:31:28 2005
@@ -63,6 +63,7 @@
#include <sys/fcntl.h>
#include <sys/kernel.h>
#include <sys/kthread.h>
+#include <sys/libkern.h>
#include <sys/linker.h>
#include <sys/lock.h>
#include <sys/malloc.h>
@@ -685,6 +686,12 @@ mdfind(int unit)
return (sc);
}
+static int
+mdunitcmp (void *a, void *b)
+{
+ return (*(int *)a - *(int *)b);
+}
+
static struct md_s *
mdnew(int unit)
{
@@ -1160,6 +1167,8 @@ mdctlioctl(struct cdev *dev, u_long cmd,
mdio->md_pad[i++] = sc->unit;
}
mdio->md_pad[0] = i - 1;
+ qsort(&mdio->md_pad[1], i - 1, sizeof(mdio->md_pad[1]),
+ mdunitcmp);
return (0);
default:
return (ENOIOCTL);
--- diff.0.md.c ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list