diff options
author | gnezdo <gnezdo@cvs.openbsd.org> | 2020-11-17 03:23:11 +0000 |
---|---|---|
committer | gnezdo <gnezdo@cvs.openbsd.org> | 2020-11-17 03:23:11 +0000 |
commit | 7fe67faab8fecba247c1c8263f0523664f1021fa (patch) | |
tree | d52c9e48184ab6b8edd3f23c77734be040dd863c /sys | |
parent | f8f36d7e638ea53055bdedf51537409569453de8 (diff) |
Convert fusefs_sysctl to sysctl_bounded_args
OK millert@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/miscfs/fuse/fuse_vfsops.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/sys/miscfs/fuse/fuse_vfsops.c b/sys/miscfs/fuse/fuse_vfsops.c index 561c77f9aa4..3e2af8960af 100644 --- a/sys/miscfs/fuse/fuse_vfsops.c +++ b/sys/miscfs/fuse/fuse_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fuse_vfsops.c,v 1.43 2019/12/26 13:28:49 bluhm Exp $ */ +/* $OpenBSD: fuse_vfsops.c,v 1.44 2020/11/17 03:23:10 gnezdo Exp $ */ /* * Copyright (c) 2012-2013 Sylvestre Gallon <ccna.syl@gmail.com> * @@ -353,30 +353,21 @@ fusefs_init(struct vfsconf *vfc) return (0); } +extern int stat_fbufs_in, stat_fbufs_wait, stat_opened_fusedev; + +const struct sysctl_bounded_args fusefs_vars[] = { + { FUSEFS_OPENDEVS, &stat_opened_fusedev, 1, 0 }, + { FUSEFS_INFBUFS, &stat_fbufs_in, 1, 0 }, + { FUSEFS_WAITFBUFS, &stat_fbufs_wait, 1, 0 }, + { FUSEFS_POOL_NBPAGES, &fusefs_fbuf_pool.pr_npages, 1, 0 }, +}; + int fusefs_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen, struct proc *p) { - extern int stat_fbufs_in, stat_fbufs_wait, stat_opened_fusedev; - - /* all sysctl names at this level are terminal */ - if (namelen != 1) - return (ENOTDIR); /* overloaded */ - - switch (name[0]) { - case FUSEFS_OPENDEVS: - return (sysctl_rdint(oldp, oldlenp, newp, - stat_opened_fusedev)); - case FUSEFS_INFBUFS: - return (sysctl_rdint(oldp, oldlenp, newp, stat_fbufs_in)); - case FUSEFS_WAITFBUFS: - return (sysctl_rdint(oldp, oldlenp, newp, stat_fbufs_wait)); - case FUSEFS_POOL_NBPAGES: - return (sysctl_rdint(oldp, oldlenp, newp, - fusefs_fbuf_pool.pr_npages)); - default: - return (EOPNOTSUPP); - } + return sysctl_bounded_arr(fusefs_vars, nitems(fusefs_vars), name, + namelen, oldp, oldlenp, newp, newlen); } int |