From 037c3d0fb035be10ead8afeed05d6d90fd46021e Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sun, 17 Aug 2003 12:06:19 +0000 Subject: [PATCH] It is not an error to have no devices in the kernel: Return the generation number and start it from one instead of zero. --- sys/kern/subr_devstat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c index f7a52ffebae..6a51745aa26 100644 --- a/sys/kern/subr_devstat.c +++ b/sys/kern/subr_devstat.c @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); #include static int devstat_num_devs; -static long devstat_generation; +static long devstat_generation = 1; static int devstat_version = DEVSTAT_VERSION; static int devstat_current_devnumber; static struct mtx devstat_mutex; @@ -364,9 +364,6 @@ sysctl_devstat(SYSCTL_HANDLER_ARGS) mtx_assert(&devstat_mutex, MA_NOTOWNED); - if (devstat_num_devs == 0) - return(EINVAL); - /* * XXX devstat_generation should really be "volatile" but that * XXX freaks out the sysctl macro below. The places where we @@ -379,6 +376,9 @@ sysctl_devstat(SYSCTL_HANDLER_ARGS) error = SYSCTL_OUT(req, &mygen, sizeof(mygen)); + if (devstat_num_devs == 0) + return(0); + if (error != 0) return (error);