diff options
author | Neil Blakey-Milner <nbm@FreeBSD.org> | 2000-06-22 11:44:43 +0000 |
---|---|---|
committer | Neil Blakey-Milner <nbm@FreeBSD.org> | 2000-06-22 11:44:43 +0000 |
commit | 445572c1ed9c672d070026a05ae738799ecd4067 (patch) | |
tree | 782c46adc7ae80e0858ebce96de49667493da73f /sys/kern/subr_disk.c | |
parent | 728a64be3fc1381fa2726f2cbbf1aca724a65458 (diff) | |
download | src-445572c1ed9c672d070026a05ae738799ecd4067.tar.gz src-445572c1ed9c672d070026a05ae738799ecd4067.zip |
Add 'kern.disks', a sysctl which returns the list of disks from
disk_enumerate(), space delimited. This allows non-root users to get a
list of disks and will simplify libdisk's Disk_Names().
Reviewed by: phk
Notes
Notes:
svn path=/head/; revision=61953
Diffstat (limited to 'sys/kern/subr_disk.c')
-rw-r--r-- | sys/kern/subr_disk.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 5e18163df5fb..01cfcf26b1c5 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -18,6 +18,7 @@ #include <sys/conf.h> #include <sys/disk.h> #include <sys/malloc.h> +#include <sys/sysctl.h> #include <machine/md_var.h> MALLOC_DEFINE(M_DISK, "disk", "disk data"); @@ -114,6 +115,34 @@ disk_enumerate(struct disk *disk) return (LIST_NEXT(disk, d_list)); } +static int +sysctl_disks SYSCTL_HANDLER_ARGS +{ + struct disk *disk; + int error, first; + + disk = NULL; + first = 1; + + while ((disk = disk_enumerate(disk))) { + if (!first) { + error = SYSCTL_OUT(req, " ", 1); + if (error) + return error; + } else { + first = 0; + } + error = SYSCTL_OUT(req, disk->d_dev->si_name, strlen(disk->d_dev->si_name)); + if (error) + return error; + } + error = SYSCTL_OUT(req, "", 1); + return error; +} + +SYSCTL_PROC(_kern, OID_AUTO, disks, CTLTYPE_STRING | CTLFLAG_RD, 0, NULL, + sysctl_disks, "A", "names of available disks"); + /* * The cdevsw functions */ |