aboutsummaryrefslogtreecommitdiffstats
path: root/man2/sysctl.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/sysctl.2')
-rw-r--r--man2/sysctl.266
1 files changed, 33 insertions, 33 deletions
diff --git a/man2/sysctl.2 b/man2/sysctl.2
index 0b4d4a04f6..51f7ada216 100644
--- a/man2/sysctl.2
+++ b/man2/sysctl.2
@@ -70,39 +70,6 @@ a directory tree under
.IR /proc/sys ,
and if the requested item is found calls some appropriate routine
to read or modify the value.
-.SH EXAMPLE
-.nf
-#include <linux/unistd.h>
-#include <linux/types.h>
-#include <linux/sysctl.h>
-
-_syscall1(int, _sysctl, struct __sysctl_args *, args);
-int sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
- void *newval, size_t newlen)
-{
- struct __sysctl_args args = { name, nlen, oldval, oldlenp,
- newval, newlen };
- return _sysctl(&args);
-}
-
-#define SIZE(x) sizeof(x)/sizeof(x[0])
-#define OSNAMESZ 100
-
-char osname[OSNAMESZ];
-int osnamelth;
-int name[] = { CTL_KERN, KERN_OSTYPE };
-
-int
-main(void)
-{
- osnamelth = sizeof(osname);
- if (sysctl(name, SIZE(name), osname, &osnamelth, 0, 0))
- perror("sysctl");
- else
- printf("This machine is running %*s\en", osnamelth, osname);
- exit(EXIT_SUCCESS);
-}
-.fi
.SH "RETURN VALUE"
Upon successful completion,
.BR _sysctl ()
@@ -154,5 +121,38 @@ Not all available objects are properly documented.
.PP
It is not yet possible to change operating system by writing to
.IR /proc/sys/kernel/ostype .
+.SH EXAMPLE
+.nf
+#include <linux/unistd.h>
+#include <linux/types.h>
+#include <linux/sysctl.h>
+
+_syscall1(int, _sysctl, struct __sysctl_args *, args);
+int sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
+ void *newval, size_t newlen)
+{
+ struct __sysctl_args args = { name, nlen, oldval, oldlenp,
+ newval, newlen };
+ return _sysctl(&args);
+}
+
+#define SIZE(x) sizeof(x)/sizeof(x[0])
+#define OSNAMESZ 100
+
+char osname[OSNAMESZ];
+int osnamelth;
+int name[] = { CTL_KERN, KERN_OSTYPE };
+
+int
+main(void)
+{
+ osnamelth = sizeof(osname);
+ if (sysctl(name, SIZE(name), osname, &osnamelth, 0, 0))
+ perror("sysctl");
+ else
+ printf("This machine is running %*s\en", osnamelth, osname);
+ exit(EXIT_SUCCESS);
+}
+.fi
.SH "SEE ALSO"
.BR proc (5)