1CONFSTR(3) Linux Programmer's Manual CONFSTR(3)
2
3
4
6 confstr - get configuration dependent string variables
7
9 #include <unistd.h>
10
11 size_t confstr(int name, char *buf, size_t len);
12
13 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
14
15 confstr():
16 _POSIX_C_SOURCE >= 2 || _XOPEN_SOURCE
17
19 confstr() gets the value of configuration-dependent string variables.
20
21 The name argument is the system variable to be queried. The following
22 variables are supported:
23
24 _CS_GNU_LIBC_VERSION (GNU C library only; since glibc 2.3.2)
25 A string which identifies the GNU C library version on this sys‐
26 tem (e.g., "glibc 2.3.4").
27
28 _CS_GNU_LIBPTHREAD_VERSION (GNU C library only; since glibc 2.3.2)
29 A string which identifies the POSIX implementation supplied by
30 this C library (e.g., "NPTL 2.3.4" or "linuxthreads-0.10").
31
32 _CS_PATH
33 A value for the PATH variable which indicates where all the
34 POSIX.2 standard utilities can be found.
35
36 If buf is not NULL and len is not zero, confstr() copies the value of
37 the string to buf truncated to len - 1 bytes if necessary, with a null
38 byte ('\0') as terminator. This can be detected by comparing the re‐
39 turn value of confstr() against len.
40
41 If len is zero and buf is NULL, confstr() just returns the value as de‐
42 fined below.
43
45 If name is a valid configuration variable, confstr() returns the number
46 of bytes (including the terminating null byte) that would be required
47 to hold the entire value of that variable. This value may be greater
48 than len, which means that the value in buf is truncated.
49
50 If name is a valid configuration variable, but that variable does not
51 have a value, then confstr() returns 0. If name does not correspond to
52 a valid configuration variable, confstr() returns 0, and errno is set
53 to EINVAL.
54
56 EINVAL The value of name is invalid.
57
59 For an explanation of the terms used in this section, see at‐
60 tributes(7).
61
62 ┌────────────────────────────────────────────┬───────────────┬─────────┐
63 │Interface │ Attribute │ Value │
64 ├────────────────────────────────────────────┼───────────────┼─────────┤
65 │confstr() │ Thread safety │ MT-Safe │
66 └────────────────────────────────────────────┴───────────────┴─────────┘
67
69 POSIX.1-2001, POSIX.1-2008.
70
72 The following code fragment determines the path where to find the
73 POSIX.2 system utilities:
74
75 char *pathbuf;
76 size_t n;
77
78 n = confstr(_CS_PATH, NULL, (size_t) 0);
79 pathbuf = malloc(n);
80 if (pathbuf == NULL)
81 abort();
82 confstr(_CS_PATH, pathbuf, n);
83
85 getconf(1), sh(1), exec(3), fpathconf(3), pathconf(3), sysconf(3), sys‐
86 tem(3)
87
89 This page is part of release 5.13 of the Linux man-pages project. A
90 description of the project, information about reporting bugs, and the
91 latest version of this page, can be found at
92 https://www.kernel.org/doc/man-pages/.
93
94
95
96GNU 2021-03-22 CONFSTR(3)