SD_PATH_LOOKUP - Online Linux Manual PageSection : 3
Updated :
Source : systemd 250
Note : sd_path_lookup

NAMEsd_path_lookup, sd_path_lookup_strv − Query well−known file system paths

SYNOPSIS#include <systemd/sd−path​.h>enum { SD_PATH_TEMPORARY, SD_PATH_TEMPORARY_LARGE, SD_PATH_SYSTEM_BINARIES, SD_PATH_SYSTEM_INCLUDE, SD_PATH_SYSTEM_LIBRARY_PRIVATE, SD_PATH_SYSTEM_LIBRARY_ARCH, SD_PATH_SYSTEM_SHARED, SD_PATH_SYSTEM_CONFIGURATION_FACTORY, SD_PATH_SYSTEM_STATE_FACTORY, SD_PATH_SYSTEM_CONFIGURATION, SD_PATH_SYSTEM_RUNTIME, SD_PATH_SYSTEM_RUNTIME_LOGS, SD_PATH_SYSTEM_STATE_PRIVATE, SD_PATH_SYSTEM_STATE_LOGS, SD_PATH_SYSTEM_STATE_CACHE, SD_PATH_SYSTEM_STATE_SPOOL, SD_PATH_USER_BINARIES, SD_PATH_USER_LIBRARY_PRIVATE, SD_PATH_USER_LIBRARY_ARCH, SD_PATH_USER_SHARED, SD_PATH_USER_CONFIGURATION, SD_PATH_USER_RUNTIME, SD_PATH_USER_STATE_CACHE, SD_PATH_USER, SD_PATH_USER_DOCUMENTS, SD_PATH_USER_MUSIC, SD_PATH_USER_PICTURES, SD_PATH_USER_VIDEOS, SD_PATH_USER_DOWNLOAD, SD_PATH_USER_PUBLIC, SD_PATH_USER_TEMPLATES, SD_PATH_USER_DESKTOP, SD_PATH_SEARCH_BINARIES, SD_PATH_SEARCH_BINARIES_DEFAULT, SD_PATH_SEARCH_LIBRARY_PRIVATE, SD_PATH_SEARCH_LIBRARY_ARCH, SD_PATH_SEARCH_SHARED, SD_PATH_SEARCH_CONFIGURATION_FACTORY, SD_PATH_SEARCH_STATE_FACTORY, SD_PATH_SEARCH_CONFIGURATION, SD_PATH_SYSTEMD_UTIL, SD_PATH_SYSTEMD_SYSTEM_UNIT, SD_PATH_SYSTEMD_SYSTEM_PRESET, SD_PATH_SYSTEMD_USER_UNIT, SD_PATH_SYSTEMD_USER_PRESET, SD_PATH_SYSTEMD_SYSTEM_CONF, SD_PATH_SYSTEMD_USER_CONF, SD_PATH_SYSTEMD_SEARCH_SYSTEM_UNIT, SD_PATH_SYSTEMD_SEARCH_USER_UNIT, SD_PATH_SYSTEMD_SYSTEM_GENERATOR, SD_PATH_SYSTEMD_USER_GENERATOR, SD_PATH_SYSTEMD_SEARCH_SYSTEM_GENERATOR, SD_PATH_SYSTEMD_SEARCH_USER_GENERATOR, SD_PATH_SYSTEMD_SLEEP, SD_PATH_SYSTEMD_SHUTDOWN, SD_PATH_TMPFILES, SD_PATH_SYSUSERS, SD_PATH_SYSCTL, SD_PATH_BINFMT, SD_PATH_MODULES_LOAD, SD_PATH_CATALOG, SD_PATH_SYSTEMD_SEARCH_NETWORK, };int sd_path_lookup(uint64_t type, const char *suffix, char **paths); int sd_path_lookup_strv(uint64_t type, const char *suffix, char ***paths);

DESCRIPTIONsd_path_lookup() and sd_bus_path_lookup_strv() return a single path or set of file system paths specified by the argument type​. In case of sd_path_lookup() a single NUL−terminated string is returned​. When type specifies a set of paths, they are concatenated using ":" as a separator (as is traditionally done for e​.g​. $PATH or $LD_LIBRARY_PATH)​. In case of sd_path_lookup_strv() a NULL−terminated array of strings is returned (strv)​. If suffix suffix is given, it is concatenated to each of the paths after a slash ("/")​. All returned paths are absolute​. For paths which refer to user directories, the relevant XDG standard is followed, with support for environment variables like $XDG_DOCUMENTS_DIR, $XDG_DESKTOP_DIR, ​.​.​., and explicit configuration in /etc/xdg/user−dirs​.conf or ${XDG_CONFIG_HOME}/user−dirs​.dirs​. See XDG Base Directory Specification[1] for details​. systemd-path(1) is a wrapper around sd_path_lookup() and allows the same set of paths to be queried​.

RETURN VALUEOn success, sd_path_lookup() and sd_path_lookup_strv() return a non−negative integer​. On failure, a negative errno−style error number is returned by either function​. The returned string or string array (strv) must be free(3)'d by the caller​.

ErrorsReturned errors may indicate the following problems: −EOPNOTSUPP Unknown identifier type​. −EINVAL Output argument is NULL​. −ENXIO Query failed because of an undefined environment variable (e​.g​. for SD_PATH_USER_RUNTIME when $XDG_RUNTIME_DIR is not defined)​. −ENOMEM Memory allocation failed​.

EXAMPLES

Look up the location of ~/Documents/* SPDX−License−Identifier: CC0−1​.0 */ #include <stdio​.h> #include <stdlib​.h> #include <sd−path​.h> int main(void) { int r; char *t; r = sd_path_lookup(SD_PATH_USER_DOCUMENTS, NULL, &t); if (r < 0) return EXIT_FAILURE; printf("~/Documents: %s\n", t); free(t); return EXIT_SUCCESS; }Note that the default answer of $HOME/Documents may be overridden by user−dirs​.conf or $XDG_DOCUMENTS_DIR​.

NOTESThese APIs are implemented as a shared library, which can be compiled and linked to with the libsystemd ​pkg-config(1) file​.

SEE ALSOsystemd-path(1)

NOTES 1. XDG Base Directory Specification ­https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
0
Johanes Gumabo
Data Size   :   20,893 byte
man-sd_path_lookup_strv.3Build   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 183,544
Visitor ID   :     :  
Visitor IP   :   3.147.6.122   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.