Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/puffs/mount_sysctlfs support CTLTYPE_BOOL
details: https://anonhg.NetBSD.org/src/rev/331f3702accf
branches: trunk
changeset: 756866:331f3702accf
user: pooka <pooka%NetBSD.org@localhost>
date: Fri Aug 06 15:26:16 2010 +0000
description:
support CTLTYPE_BOOL
diffstat:
usr.sbin/puffs/mount_sysctlfs/sysctlfs.c | 32 +++++++++++++++++++++++++++++---
1 files changed, 29 insertions(+), 3 deletions(-)
diffs (74 lines):
diff -r 2ef8a25d98f5 -r 331f3702accf usr.sbin/puffs/mount_sysctlfs/sysctlfs.c
--- a/usr.sbin/puffs/mount_sysctlfs/sysctlfs.c Fri Aug 06 15:21:50 2010 +0000
+++ b/usr.sbin/puffs/mount_sysctlfs/sysctlfs.c Fri Aug 06 15:26:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysctlfs.c,v 1.15 2010/08/06 15:04:13 pooka Exp $ */
+/* $NetBSD: sysctlfs.c,v 1.16 2010/08/06 15:26:16 pooka Exp $ */
/*-
* Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: sysctlfs.c,v 1.15 2010/08/06 15:04:13 pooka Exp $");
+__RCSID("$NetBSD: sysctlfs.c,v 1.16 2010/08/06 15:26:16 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
@@ -400,6 +400,20 @@
memset(buf, 0, *bufsize);
switch (SYSCTL_TYPE(sfs->sysctl_flags)) {
+ case CTLTYPE_BOOL: {
+ bool b;
+ sz = sizeof(bool);
+ assert(sz <= *bufsize);
+ if (sysctl(po->po_path, po->po_len, &b, &sz, NULL, 0) == -1) {
+ error = errno;
+ break;
+ }
+ if (rflag)
+ memcpy(buf, &b, sz);
+ else
+ snprintf(buf, *bufsize, "%s", b ? "true" : "false");
+ break;
+ }
case CTLTYPE_INT: {
int i;
sz = sizeof(int);
@@ -458,7 +472,8 @@
break;
}
default:
- snprintf(buf, *bufsize, "invalid sysctl CTLTYPE");
+ snprintf(buf, *bufsize, "invalid sysctl CTLTYPE %d",
+ SYSCTL_TYPE(sfs->sysctl_flags));
break;
}
@@ -722,6 +737,7 @@
struct sfsnode *sfs = pn->pn_data;
long long ll;
int i, rv;
+ bool b;
/*
* I picked the wrong day to ... um, the wrong place to return errors
@@ -744,6 +760,16 @@
return EINVAL;
switch (SYSCTL_TYPE(sfs->sysctl_flags)) {
+ case CTLTYPE_BOOL:
+ if (strcasestr((const char *)buf, "true"))
+ b = true;
+ else if (strcasestr((const char *)buf, "false"))
+ b = false;
+ else
+ return EINVAL;
+ rv = sysctl(PNPATH(pn), PNPLEN(pn), NULL, NULL,
+ &b, sizeof(b));
+ break;
case CTLTYPE_INT:
if (sscanf((const char *)buf, "%d", &i) != 1)
return EINVAL;
Home |
Main Index |
Thread Index |
Old Index