Add read only sysctl variable user.localbase

The value is provided by the C library as for other sysctl variables in
the user tree. It is compiled in and returns the value of _PATH_LOCALBASE
defined in paths.h.

Reviewed by:	imp, scottl
Differential Revision:	https://reviews.freebsd.org/D27009
This commit is contained in:
Stefan Eßer 2020-10-30 18:48:09 +00:00
parent e0f9cec7d6
commit 147eea393f
3 changed files with 12 additions and 0 deletions

View File

@ -87,6 +87,15 @@ sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp,
if (oldp != NULL)
memmove(oldp, _PATH_STDPATH, sizeof(_PATH_STDPATH));
return (0);
case USER_LOCALBASE:
if (oldp && orig_oldlen < sizeof(_PATH_LOCALBASE)) {
errno = ENOMEM;
return -1;
}
*oldlenp = sizeof(_PATH_LOCALBASE);
if (oldp != NULL)
memmove(oldp, _PATH_LOCALBASE, sizeof(_PATH_LOCALBASE));
return(0);
}
if (oldp && *oldlenp < sizeof(int)) {

View File

@ -652,6 +652,8 @@ SYSCTL_INT(_user, USER_STREAM_MAX, stream_max, CTLFLAG_RD,
SYSCTL_NULL_INT_PTR, 0, "Min Maximum number of streams a process may have open at one time");
SYSCTL_INT(_user, USER_TZNAME_MAX, tzname_max, CTLFLAG_RD,
SYSCTL_NULL_INT_PTR, 0, "Min Maximum number of types supported for timezone names");
SYSCTL_STRING(_user, USER_LOCALBASE, localbase, CTLFLAG_RD,
"", 0, "Prefix used to install and locate add-on packages");
#include <sys/vnode.h>
SYSCTL_INT(_debug_sizeof, OID_AUTO, vnode, CTLFLAG_RD,

View File

@ -1070,6 +1070,7 @@ TAILQ_HEAD(sysctl_ctx_list, sysctl_ctx_entry);
#define USER_POSIX2_UPE 18 /* int: POSIX2_UPE */
#define USER_STREAM_MAX 19 /* int: POSIX2_STREAM_MAX */
#define USER_TZNAME_MAX 20 /* int: POSIX2_TZNAME_MAX */
#define USER_LOCALBASE 21 /* string: _PATH_LOCALBASE */
#define CTL_P1003_1B_ASYNCHRONOUS_IO 1 /* boolean */
#define CTL_P1003_1B_MAPPED_FILES 2 /* boolean */