]>
Commit | Line | Data |
---|---|---|
b35ed553 ZJS |
1 | <?xml version='1.0'?> |
2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" | |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
db9ecf05 | 4 | <!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
b35ed553 ZJS |
5 | |
6 | <refentry id="sd_path_lookup" xmlns:xi="http://www.w3.org/2001/XInclude"> | |
7 | ||
8 | <refentryinfo> | |
9 | <title>sd_path_lookup</title> | |
10 | <productname>systemd</productname> | |
11 | </refentryinfo> | |
12 | ||
13 | <refmeta> | |
14 | <refentrytitle>sd_path_lookup</refentrytitle> | |
15 | <manvolnum>3</manvolnum> | |
16 | </refmeta> | |
17 | ||
18 | <refnamediv> | |
19 | <refname>sd_path_lookup</refname> | |
20 | <refname>sd_path_lookup_strv</refname> | |
21 | ||
22 | <refpurpose>Query well-known file system paths</refpurpose> | |
23 | </refnamediv> | |
24 | ||
25 | <refsynopsisdiv> | |
26 | <funcsynopsis> | |
27 | <funcsynopsisinfo>#include <systemd/sd-path.h></funcsynopsisinfo> | |
28 | ||
29 | <!-- note: individual constants are not added as <refname>s, there's just too many --> | |
30 | ||
31 | <funcsynopsisinfo><token>enum</token> { | |
32 | <constant>SD_PATH_TEMPORARY</constant>, | |
33 | <constant>SD_PATH_TEMPORARY_LARGE</constant>, | |
34 | ||
35 | <constant>SD_PATH_SYSTEM_BINARIES</constant>, | |
36 | <constant>SD_PATH_SYSTEM_INCLUDE</constant>, | |
37 | <constant>SD_PATH_SYSTEM_LIBRARY_PRIVATE</constant>, | |
38 | <constant>SD_PATH_SYSTEM_LIBRARY_ARCH</constant>, | |
39 | <constant>SD_PATH_SYSTEM_SHARED</constant>, | |
40 | <constant>SD_PATH_SYSTEM_CONFIGURATION_FACTORY</constant>, | |
41 | <constant>SD_PATH_SYSTEM_STATE_FACTORY</constant>, | |
42 | ||
43 | <constant>SD_PATH_SYSTEM_CONFIGURATION</constant>, | |
44 | <constant>SD_PATH_SYSTEM_RUNTIME</constant>, | |
45 | <constant>SD_PATH_SYSTEM_RUNTIME_LOGS</constant>, | |
46 | <constant>SD_PATH_SYSTEM_STATE_PRIVATE</constant>, | |
47 | <constant>SD_PATH_SYSTEM_STATE_LOGS</constant>, | |
48 | <constant>SD_PATH_SYSTEM_STATE_CACHE</constant>, | |
49 | <constant>SD_PATH_SYSTEM_STATE_SPOOL</constant>, | |
50 | ||
51 | <constant>SD_PATH_USER_BINARIES</constant>, | |
52 | <constant>SD_PATH_USER_LIBRARY_PRIVATE</constant>, | |
53 | <constant>SD_PATH_USER_LIBRARY_ARCH</constant>, | |
54 | <constant>SD_PATH_USER_SHARED</constant>, | |
55 | ||
56 | <constant>SD_PATH_USER_CONFIGURATION</constant>, | |
57 | <constant>SD_PATH_USER_RUNTIME</constant>, | |
58 | <constant>SD_PATH_USER_STATE_CACHE</constant>, | |
59 | ||
60 | <constant>SD_PATH_USER</constant>, | |
61 | <constant>SD_PATH_USER_DOCUMENTS</constant>, | |
62 | <constant>SD_PATH_USER_MUSIC</constant>, | |
63 | <constant>SD_PATH_USER_PICTURES</constant>, | |
64 | <constant>SD_PATH_USER_VIDEOS</constant>, | |
65 | <constant>SD_PATH_USER_DOWNLOAD</constant>, | |
66 | <constant>SD_PATH_USER_PUBLIC</constant>, | |
67 | <constant>SD_PATH_USER_TEMPLATES</constant>, | |
68 | <constant>SD_PATH_USER_DESKTOP</constant>, | |
69 | ||
70 | <constant>SD_PATH_SEARCH_BINARIES</constant>, | |
71 | <constant>SD_PATH_SEARCH_BINARIES_DEFAULT</constant>, | |
72 | <constant>SD_PATH_SEARCH_LIBRARY_PRIVATE</constant>, | |
73 | <constant>SD_PATH_SEARCH_LIBRARY_ARCH</constant>, | |
74 | <constant>SD_PATH_SEARCH_SHARED</constant>, | |
75 | <constant>SD_PATH_SEARCH_CONFIGURATION_FACTORY</constant>, | |
76 | <constant>SD_PATH_SEARCH_STATE_FACTORY</constant>, | |
77 | <constant>SD_PATH_SEARCH_CONFIGURATION</constant>, | |
9c5bb203 | 78 | |
ccdf03b9 LP |
79 | <constant>SD_PATH_SYSTEMD_UTIL</constant>, |
80 | <constant>SD_PATH_SYSTEMD_SYSTEM_UNIT</constant>, | |
81 | <constant>SD_PATH_SYSTEMD_SYSTEM_PRESET</constant>, | |
82 | <constant>SD_PATH_SYSTEMD_USER_UNIT</constant>, | |
83 | <constant>SD_PATH_SYSTEMD_USER_PRESET</constant>, | |
84 | <constant>SD_PATH_SYSTEMD_SYSTEM_CONF</constant>, | |
85 | <constant>SD_PATH_SYSTEMD_USER_CONF</constant>, | |
86 | <constant>SD_PATH_SYSTEMD_SEARCH_SYSTEM_UNIT</constant>, | |
87 | <constant>SD_PATH_SYSTEMD_SEARCH_USER_UNIT</constant>, | |
88 | <constant>SD_PATH_SYSTEMD_SYSTEM_GENERATOR</constant>, | |
89 | <constant>SD_PATH_SYSTEMD_USER_GENERATOR</constant>, | |
90 | <constant>SD_PATH_SYSTEMD_SEARCH_SYSTEM_GENERATOR</constant>, | |
91 | <constant>SD_PATH_SYSTEMD_SEARCH_USER_GENERATOR</constant>, | |
92 | <constant>SD_PATH_SYSTEMD_SLEEP</constant>, | |
93 | <constant>SD_PATH_SYSTEMD_SHUTDOWN</constant>, | |
94 | ||
95 | <constant>SD_PATH_TMPFILES</constant>, | |
96 | <constant>SD_PATH_SYSUSERS</constant>, | |
97 | <constant>SD_PATH_SYSCTL</constant>, | |
98 | <constant>SD_PATH_BINFMT</constant>, | |
99 | <constant>SD_PATH_MODULES_LOAD</constant>, | |
100 | <constant>SD_PATH_CATALOG</constant>, | |
101 | ||
102 | <constant>SD_PATH_SYSTEMD_SEARCH_NETWORK</constant>, | |
71006538 DT |
103 | |
104 | <constant>SD_PATH_SYSTEMD_SYSTEM_ENVIRONMENT_GENERATOR</constant>, | |
105 | <constant>SD_PATH_SYSTEMD_USER_ENVIRONMENT_GENERATOR</constant>, | |
106 | <constant>SD_PATH_SYSTEMD_SEARCH_SYSTEM_ENVIRONMENT_GENERATOR</constant>, | |
107 | <constant>SD_PATH_SYSTEMD_SEARCH_USER_ENVIRONMENT_GENERATOR</constant>, | |
b35ed553 ZJS |
108 | };</funcsynopsisinfo> |
109 | ||
110 | <funcprototype> | |
111 | <funcdef>int <function>sd_path_lookup</function></funcdef> | |
112 | <paramdef>uint64_t <parameter>type</parameter></paramdef> | |
113 | <paramdef>const char *<parameter>suffix</parameter></paramdef> | |
114 | <paramdef>char **<parameter>paths</parameter></paramdef> | |
115 | </funcprototype> | |
116 | ||
117 | <funcprototype> | |
118 | <funcdef>int <function>sd_path_lookup_strv</function></funcdef> | |
119 | <paramdef>uint64_t <parameter>type</parameter></paramdef> | |
120 | <paramdef>const char *<parameter>suffix</parameter></paramdef> | |
121 | <paramdef>char ***<parameter>paths</parameter></paramdef> | |
122 | </funcprototype> | |
123 | </funcsynopsis> | |
124 | </refsynopsisdiv> | |
125 | ||
126 | <refsect1> | |
127 | <title>Description</title> | |
128 | ||
129 | <para><function>sd_path_lookup()</function> and <function>sd_bus_path_lookup_strv()</function> return a | |
130 | single path or set of file system paths specified by the argument <parameter>type</parameter>. In case of | |
131 | <function>sd_path_lookup()</function> a single <constant>NUL</constant>-terminated string is returned. | |
132 | When <parameter>type</parameter> specifies a set of paths, they are concatenated using | |
133 | <literal>:</literal> as a separator (as is traditionally done for e.g. <varname>$PATH</varname> or | |
134 | <varname>$LD_LIBRARY_PATH</varname>). In case of <function>sd_path_lookup_strv()</function> a | |
135 | <constant>NULL</constant>-terminated array of strings is returned (strv). If suffix | |
136 | <parameter>suffix</parameter> is given, it is concatenated to each of the paths after a slash | |
137 | (<literal>/</literal>). All returned paths are absolute.</para> | |
138 | ||
139 | <para>For paths which refer to user directories, the relevant XDG standard is followed, with support for | |
140 | environment variables like <varname>$XDG_DOCUMENTS_DIR</varname>, <varname>$XDG_DESKTOP_DIR</varname>, | |
141 | ..., and explicit configuration in <filename>/etc/xdg/user-dirs.conf</filename> or | |
142 | <filename>${XDG_CONFIG_HOME}/user-dirs.dirs</filename>. See | |
143 | <ulink url="https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html"> | |
144 | XDG Base Directory Specification</ulink> for details.</para> | |
145 | ||
146 | <para><citerefentry><refentrytitle>systemd-path</refentrytitle><manvolnum>1</manvolnum></citerefentry> is | |
147 | a wrapper around <function>sd_path_lookup()</function> and allows the same set of paths to be queried. | |
148 | </para> | |
149 | </refsect1> | |
150 | ||
151 | <refsect1> | |
152 | <title>Return Value</title> | |
153 | ||
154 | <para>On success, <function>sd_path_lookup()</function> and <function>sd_path_lookup_strv()</function> | |
155 | return a non-negative integer. On failure, a negative errno-style error number is returned by either | |
156 | function.</para> | |
157 | ||
158 | <para>The returned string or string array (strv) must be | |
159 | <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>'d by the | |
160 | caller.</para> | |
161 | ||
162 | <refsect2 id='errors'> | |
163 | <title>Errors</title> | |
164 | ||
165 | <para>Returned errors may indicate the following problems:</para> | |
166 | ||
167 | <variablelist> | |
168 | <varlistentry> | |
169 | <term><constant>-EOPNOTSUPP</constant></term> | |
170 | ||
171 | <listitem><para>Unknown identifier <parameter>type</parameter>.</para></listitem> | |
172 | </varlistentry> | |
173 | ||
174 | <varlistentry> | |
175 | <term><constant>-EINVAL</constant></term> | |
176 | ||
177 | <listitem><para>Output argument is <constant>NULL</constant>.</para></listitem> | |
178 | </varlistentry> | |
179 | ||
2e09fa89 ZJS |
180 | <varlistentry> |
181 | <term><constant>-ENXIO</constant></term> | |
182 | ||
183 | <listitem><para>Query failed because of an undefined environment variable (e.g. for | |
184 | <constant>SD_PATH_USER_RUNTIME</constant> when <varname>$XDG_RUNTIME_DIR</varname> is not | |
185 | defined).</para></listitem> | |
186 | </varlistentry> | |
187 | ||
b35ed553 ZJS |
188 | <varlistentry> |
189 | <term><constant>-ENOMEM</constant></term> | |
190 | ||
191 | <listitem><para>Memory allocation failed.</para></listitem> | |
192 | </varlistentry> | |
193 | </variablelist> | |
194 | </refsect2> | |
195 | </refsect1> | |
196 | ||
197 | <refsect1> | |
198 | <title>Examples</title> | |
199 | ||
200 | <refsect2> | |
201 | <title>Look up the location of ~/Documents</title> | |
202 | ||
203 | <programlisting><xi:include href="path-documents.c" parse="text" /></programlisting> | |
204 | <para>Note that the default answer of <filename index='false'>$HOME/Documents</filename> may be | |
205 | overridden by <filename index='false'>user-dirs.conf</filename> or | |
206 | <varname>$XDG_DOCUMENTS_DIR</varname>.</para> | |
207 | </refsect2> | |
208 | </refsect1> | |
209 | ||
210 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
211 | ||
212 | <refsect1> | |
213 | <title>See Also</title> | |
214 | ||
215 | <para> | |
216 | <citerefentry><refentrytitle>systemd-path</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
217 | </para> | |
218 | </refsect1> | |
219 | ||
220 | </refentry> |