From 436e75e7368d5ceb7ab1e4e617b5b2c6e04fa350 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Fri, 22 Feb 2008 05:19:25 +0000 Subject: [PATCH] Add a varsym(2) manual page (documenting varsym_{get,set,list}()). --- bin/varsym/varsym.1 | 3 +- lib/libc/sys/Makefile.inc | 11 +-- lib/libc/sys/varsym.2 | 143 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 152 insertions(+), 5 deletions(-) create mode 100644 lib/libc/sys/varsym.2 diff --git a/bin/varsym/varsym.1 b/bin/varsym/varsym.1 index e52670e22a..b3dac30389 100644 --- a/bin/varsym/varsym.1 +++ b/bin/varsym/varsym.1 @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $DragonFly: src/bin/varsym/varsym.1,v 1.9 2007/05/13 18:33:55 swildner Exp $ +.\" $DragonFly: src/bin/varsym/varsym.1,v 1.10 2008/02/22 05:19:25 swildner Exp $ .\" .Dd November 5, 2003 .Dt VARSYM 1 @@ -80,4 +80,5 @@ A requested variable could not be set .El .Sh SEE ALSO .Xr ln 1 , +.Xr varsym 2 , .Xr varsym.conf 5 diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index 756ceaf306..e32bfefd9f 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,6 +1,6 @@ # @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 # $FreeBSD: src/lib/libc/sys/Makefile.inc,v 1.75.2.7 2003/04/22 17:31:18 trhodes Exp $ -# $DragonFly: src/lib/libc/sys/Makefile.inc,v 1.31 2008/02/09 00:10:29 swildner Exp $ +# $DragonFly: src/lib/libc/sys/Makefile.inc,v 1.32 2008/02/22 05:19:25 swildner Exp $ # sys sources .PATH: ${.CURDIR}/../libc/${MACHINE_ARCH}/sys ${.CURDIR}/../libc/sys @@ -82,7 +82,7 @@ MAN+= _exit.2 accept.2 access.2 acct.2 adjtime.2 \ modfind.2 modnext.2 modstat.2 \ mount.2 mountctl.2 mprotect.2 msync.2 munmap.2 nanosleep.2 \ nfssvc.2 ntp_adjtime.2 ntp_gettime.2 \ - open.2 pathconf.2 pipe.2 poll.2 profil.2 ptrace.2 quotactl.2 \ + open.2 pathconf.2 pipe.2 poll.2 profil.2 pselect.2 ptrace.2 quotactl.2 \ read.2 readlink.2 reboot.2 recv.2 rename.2 revoke.2 rfork.2 rmdir.2 \ rtprio.2 select.2 semctl.2 semget.2 semop.2 send.2 sendfile.2 \ setgroups.2 setpgid.2 setregid.2 setresuid.2 setreuid.2 setsid.2 \ @@ -91,8 +91,8 @@ MAN+= _exit.2 accept.2 access.2 acct.2 adjtime.2 \ sigstack.2 sigsuspend.2 socket.2 socketpair.2 stat.2 statfs.2 \ swapon.2 symlink.2 sync.2 sysarch.2 syscall.2 syslink.2 \ truncate.2 tls.2 umask.2 umtx.2 undelete.2 \ - unlink.2 utimes.2 upc_register.2 usched_set.2 uuidgen.2 vfork.2 \ - wait.2 write.2 pselect.2 + unlink.2 utimes.2 upc_register.2 usched_set.2 uuidgen.2 \ + varsym.2 vfork.2 wait.2 write.2 .if !defined(NO_P1003_1B) MAN+= sched_get_priority_max.2 sched_setparam.2 \ @@ -142,6 +142,9 @@ MLINKS+=syscall.2 __syscall.2 MLINKS+=truncate.2 ftruncate.2 MLINKS+=upc_register.2 upc_control.2 MLINKS+=utimes.2 futimes.2 utimes.2 lutimes.2 +MLINKS+=varsym.2 varsym_get.2 \ + varsym.2 varsym_list.2 \ + varsym.2 varsym_set.2 MLINKS+=wait.2 wait3.2 wait.2 wait4.2 wait.2 waitpid.2 MLINKS+=write.2 pwrite.2 write.2 pwritev.2 write.2 writev.2 .if !defined(NO_P1003_1B) diff --git a/lib/libc/sys/varsym.2 b/lib/libc/sys/varsym.2 new file mode 100644 index 0000000000..af87f18088 --- /dev/null +++ b/lib/libc/sys/varsym.2 @@ -0,0 +1,143 @@ +.\" +.\" Copyright (c) 2008 +.\" The DragonFly Project. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in +.\" the documentation and/or other materials provided with the +.\" distribution. +.\" 3. Neither the name of The DragonFly Project nor the names of its +.\" contributors may be used to endorse or promote products derived +.\" from this software without specific, prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, +.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $DragonFly: src/lib/libc/sys/varsym.2,v 1.1 2008/02/22 05:19:25 swildner Exp $ +.\" +.Dd February 21, 2008 +.Os +.Dt VARSYM 2 +.Sh NAME +.Nm varsym_get , +.Nm varsym_set , +.Nm varsym_list +.Nd variant symlink variables +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In sys/varsym.h +.Ft int +.Fn varsym_get "int mask" "const char *wild" "char *buf" "int bufsize" +.Ft int +.Fn varsym_set "int level" "const char *name" "const char *data" +.Ft int +.Fn varsym_list "int level" "char *buf" "int maxsize" "int *marker" +.Sh DESCRIPTION +The +.Fn varsym_get +system call retrieves the value of the first variable whose left side matches +.Fa wild +and return the value in +.Fa buf . +.Fa Bufsize +specifies the length of the buffer and +.Fa mask +can be used to further restrict the search to variables of certain type. +A value of +.Dv VARSYM_ALL_MASK +will search all variables (see below for other mask definitions). +.Pp +.Fn Varsym_set +sets the variable +.Fa name +of type +.Fa level +to the value pointed to by +.Fa data . +.Pp +The +.Fn varsym_list +system call fills the buffer +.Fa buf +with variable settings for the specified +.Fa level . +A maximum of +.Fa maxsize +bytes of settings are returned and +.Fa marker +is set to the actual number of name/value pairs read, or -1 if no more +remain. +.Fn Varsym_list +must be called repeatedly until +.Fa marker +is -1 if all settings are to be retrieved. +The format of the buffer is +.Dq \e000name\e000value\e000name\e000value... . +.Pp +The following +.Nm varsym +levels (and masks) are defined in +.In sys/varsym.h : +.Bl -tag -width indent +.It Dv VARSYM_PROC Pq Dv VARSYM_PROC_MASK +Per-process variables. +.\".It Dv VARSYM_USER Pq Dv VARSYM_USER_MASK +.\"Per-user variables. +.It Dv VARSYM_SYS Pq Dv VARSYM_SYS_MASK +System wide variables. +.It Dv VARSYM_PRISON +Used internally. +.El +.Sh RETURN VALUES +Upon successful completion, the +.Fn varsym_list +function returns the number of bytes read; +otherwise the value -1 is returned and the global variable +.Fa errno +is set to indicate the error. +.Sh ERRORS +The +.Fn varsym_list +function will fail when one of the following occurs: +.Bl -tag -width Er +.It Bq Er EINVAL +An invalid +.Fa level +was specified. +.It Bq Er ENOENT +A variable could not be found. +.It Bq Er EOVERFLOW +Insufficient space for storing variable values was specified. +.El +.Sh SEE ALSO +.Xr varsym 1 +.Sh HISTORY +The +.Nm +system calls first appeared in +.Dx 1.0 . +.Sh AUTHORS +.An -nosplit +The +.Nm +system calls were written by +.An Matthew Dillon +and this manual page was written by +.An Sascha Wildner . -- 2.41.0