Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/lib/libcasper/services/cap_sysctl/cap_sysctl.h
48261 views
1
/*-
2
* Copyright (c) 2013 The FreeBSD Foundation
3
*
4
* This software was developed by Pawel Jakub Dawidek under sponsorship from
5
* the FreeBSD Foundation.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
20
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
* SUCH DAMAGE.
27
*/
28
29
#ifndef _CAP_SYSCTL_H_
30
#define _CAP_SYSCTL_H_
31
32
#ifdef HAVE_CASPER
33
#define WITH_CASPER
34
#endif
35
36
#include <sys/cdefs.h>
37
38
#define CAP_SYSCTL_READ 0x01
39
#define CAP_SYSCTL_WRITE 0x02
40
#define CAP_SYSCTL_RDWR (CAP_SYSCTL_READ | CAP_SYSCTL_WRITE)
41
#define CAP_SYSCTL_RECURSIVE 0x04
42
43
struct cap_sysctl_limit;
44
typedef struct cap_sysctl_limit cap_sysctl_limit_t;
45
46
#ifdef WITH_CASPER
47
48
__BEGIN_DECLS
49
50
int cap_sysctl(cap_channel_t *chan, const int *name, u_int namelen, void *oldp,
51
size_t *oldlenp, const void *newp, size_t newlen);
52
int cap_sysctlbyname(cap_channel_t *chan, const char *name, void *oldp,
53
size_t *oldlenp, const void *newp, size_t newlen);
54
int cap_sysctlnametomib(cap_channel_t *chan, const char *name, int *mibp,
55
size_t *sizep);
56
57
cap_sysctl_limit_t *cap_sysctl_limit_init(cap_channel_t *);
58
cap_sysctl_limit_t *cap_sysctl_limit_name(cap_sysctl_limit_t *limit,
59
const char *name, int flags);
60
cap_sysctl_limit_t *cap_sysctl_limit_mib(cap_sysctl_limit_t *limit,
61
const int *mibp, u_int miblen, int flags);
62
int cap_sysctl_limit(cap_sysctl_limit_t *limit);
63
64
__END_DECLS
65
66
#else /* !WITH_CASPER */
67
static inline int
68
cap_sysctl(cap_channel_t *chan __unused, const int *name, u_int namelen,
69
void *oldp, size_t *oldlenp, const void *newp, size_t newlen)
70
{
71
72
return (sysctl(name, namelen, oldp, oldlenp, newp, newlen));
73
}
74
75
static inline int
76
cap_sysctlbyname(cap_channel_t *chan __unused, const char *name,
77
void *oldp, size_t *oldlenp, const void *newp, size_t newlen)
78
{
79
80
return (sysctlbyname(name, oldp, oldlenp, newp, newlen));
81
}
82
83
static inline int
84
cap_sysctlnametomib(cap_channel_t *chan __unused, const char *name, int *mibp,
85
size_t *sizep)
86
{
87
88
return (sysctlnametomib(name, mibp, sizep));
89
}
90
91
static inline cap_sysctl_limit_t *
92
cap_sysctl_limit_init(cap_channel_t *limit __unused)
93
{
94
95
return (NULL);
96
}
97
98
static inline cap_sysctl_limit_t *
99
cap_sysctl_limit_name(cap_sysctl_limit_t *limit __unused,
100
const char *name __unused, int flags __unused)
101
{
102
103
return (NULL);
104
}
105
106
static inline cap_sysctl_limit_t *
107
cap_sysctl_limit_mib(cap_sysctl_limit_t *limit __unused,
108
const int *mibp __unused, u_int miblen __unused,
109
int flags __unused)
110
{
111
112
return (NULL);
113
}
114
115
static inline int
116
cap_sysctl_limit(cap_sysctl_limit_t *limit __unused)
117
{
118
119
return (0);
120
}
121
#endif /* WITH_CASPER */
122
123
#endif /* !_CAP_SYSCTL_H_ */
124
125