1SD_DEVICE_GET_SYSPATH(3)     sd_device_get_syspath    SD_DEVICE_GET_SYSPATH(3)
2
3
4

NAME

6       sd_device_get_syspath, sd_device_get_devpath, sd_device_get_sysname,
7       sd_device_get_sysnum, sd_device_get_subsystem, sd_device_get_devtype,
8       sd_device_get_devname, sd_device_get_devnum, sd_device_get_ifindex,
9       sd_device_get_driver, sd_device_get_diskseq - Returns various fields of
10       device objects
11

SYNOPSIS

13       #include <systemd/sd-device.h>
14
15       int sd_device_get_syspath(sd_device *device, const char **ret);
16
17       int sd_device_get_devpath(sd_device *device, const char **ret);
18
19       int sd_device_get_sysname(sd_device *device, const char **ret);
20
21       int sd_device_get_sysnum(sd_device *device, const char **ret);
22
23       int sd_device_get_subsystem(sd_device *device, const char **ret);
24
25       int sd_device_get_devtype(sd_device *device, const char **ret);
26
27       int sd_device_get_devname(sd_device *device, const char **ret);
28
29       int sd_device_get_devnum(sd_device *device, dev_t *ret);
30
31       int sd_device_get_ifindex(sd_device *device, int *ret);
32
33       int sd_device_get_driver(sd_device *device, const char **ret);
34
35       int sd_device_get_diskseq(sd_device *device, uint64_t *ret);
36

DESCRIPTION

38       sd_device_get_syspath() returns the sysfs path of the specified device
39       record, including the /sys prefix. Example:
40       /sys/devices/virtual/tty/tty7
41
42       sd_device_get_devpath() returns the sysfs path of the specified device
43       record, excluding the /sys prefix. Example: /devices/virtual/tty/tty7
44
45       sd_device_get_sysname() returns the sysfs name of the specified device
46       record, i.e. the last component of the sysfs path. Example: "tty7" for
47       the device /sys/devices/virtual/tty/tty7
48
49       sd_device_get_sysnum() returns the sysfs device number of the specified
50       device record, i.e. the numeric suffix of the last component of the
51       sysfs path. Example: "7" for the device /sys/devices/virtual/tty/tty7
52
53       sd_device_get_subsystem() returns the kernel subsystem of the specified
54       device record. This is a short string fitting into a filename, and thus
55       does not contain a slash and cannot be empty. Example: "tty", "block"
56       or "net".
57
58       sd_device_get_devtype() returns the device type of the specified device
59       record, if the subsystem manages multiple types of devices. Example:
60       for devices of the "block" subsystem this can be "disk" or "partition"
61
62       sd_device_get_devname() returns the device node path of the specified
63       device record if the device has a device node. Example: for
64       /sys/devices/virtual/tty/tty7 the string /dev/tty7 is typically
65       returned.
66
67       sd_device_get_devnum() returns the device node major/minor (i.e.
68       dev_t) of the specified device record if the device has a device node
69       (i.e. the one returned by sd_device_get_devname()). For devices
70       belonging to the "block" subsystem this refers to a block device node,
71       in all other cases to a character device node. Example: for the
72       /sys/devices/virtual/tty/tty7 device this typically returns the device
73       number with major/minor "4:7".
74
75       sd_device_get_ifindex() returns the network interface index of the
76       specified device record, if the device encapsulates a network interface
77       device, i.e. belongs to the "net" subsystem. Example: the "lo"
78       interface typically has interface index 1.
79
80       sd_device_get_driver() returns the kernel driver name attached to the
81       device. Note that the driver field is set on the devices consumed by
82       the driver, not on the device created by it. Example: a PCI device
83       /sys/bus/pci/devices/0000:00:1f.6 might be attached to a driver
84       "e1000e".
85
86       sd_device_get_diskseq() returns the kernel disk sequence number of the
87       block device. This number monotonically increases whenever a backing
88       medium of a block device changes without the device name changing, and
89       is relevant for block devices encapsulating devices with changing media
90       (e.g. floppy or CD-ROM), or loopback block devices. Only defined for
91       block devices, i.e. those of subsystem "block".
92

RETURN VALUE

94       On success, these calls return 0 or a positive integer. On failure,
95       they return a negative errno-style error code.
96
97   Errors
98       Returned errors may indicate the following problems:
99
100       -EINVAL
101           A specified parameter is invalid.
102
103       -ENOENT
104           The requested field is not present in the device record.
105

NOTES

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

SEE ALSO

111       systemd(1)
112
113
114
115systemd 251                                           SD_DEVICE_GET_SYSPATH(3)
Impressum