Debian Codegraph @

upstream/debian-unstable/man3/sd_machine_get_class.3

raw
1 '\" t
2 .TH "SD_MACHINE_GET_CLASS" "3" "" "systemd 261~rc3" "sd_machine_get_class"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 sd_machine_get_class, sd_machine_get_ifindices \- Determine the class and network interface indices of a locally running virtual machine or container
24 .SH "SYNOPSIS"
25 .sp
26 .ft B
27 .nf
28 #include <systemd/sd\-login\&.h>
29 .fi
30 .ft
31 .HP \w'int\ sd_machine_get_class('u
32 .BI "int sd_machine_get_class(const\ char*\ " "machine" ", char\ **" "class" ");"
33 .HP \w'int\ sd_machine_get_ifindices('u
34 .BI "int sd_machine_get_ifindices(const\ char*\ " "machine" ", int\ **" "ret_ifindices" ");"
35 .SH "DESCRIPTION"
36 .PP
37 \fBsd_machine_get_class()\fR
38 may be used to determine the class of a locally running virtual machine or container that is registered with
39 \fBsystemd-machined.service\fR(8)\&. The string returned is either
40 "vm"
41 or
42 "container"\&. The returned string needs to be freed with the libc
43 \fBfree\fR(3)
44 call after use\&.
45 .PP
46 \fBsd_machine_get_ifindices()\fR
47 may be used to determine the numeric indices of the network interfaces on the host that are pointing towards the specified locally running virtual machine or container\&. The vm or container must be registered with
48 \fBsystemd-machined.service\fR(8)\&. The output parameter
49 \fIret_ifindices\fR
50 may be passed as
51 \fBNULL\fR
52 when the output value is not needed\&. The returned array needs to be freed with the libc
53 \fBfree\fR(3)
54 call after use\&.
55 .SH "RETURN VALUE"
56 .PP
57 On success, these functions return a non\-negative integer\&.
58 \fBsd_machine_get_ifindices()\fR
59 returns the number of the relevant network interfaces\&. On failure, these calls return a negative errno\-style error code\&.
60 .SS "Errors"
61 .PP
62 Returned errors may indicate the following problems:
63 .PP
64 \fB\-ENXIO\fR
65 .RS 4
66 The specified machine does not exist or is currently not running\&.
67 .RE
68 .PP
69 \fB\-EINVAL\fR
70 .RS 4
71 An input parameter was invalid (out of range, or
72 \fBNULL\fR, where that is not accepted)\&.
73 .RE
74 .PP
75 \fB\-ENOMEM\fR
76 .RS 4
77 Memory allocation failed\&.
78 .RE
79 .SH "NOTES"
80 .PP
81 Functions described here are available as a shared library, which can be compiled against and linked to with the
82 \fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
83 file\&.
84 .PP
85 The code described here uses
86 \fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call
87 \fBsetenv\fR(3)
88 from a parallel thread\&. It is recommended to only do calls to
89 \fBsetenv()\fR
90 from an early phase of the program when no other threads have been started\&.
91 .SH "HISTORY"
92 .PP
93 \fBsd_machine_get_class()\fR
94 and
95 \fBsd_machine_get_ifindices()\fR
96 were added in version 217\&.
97 .SH "SEE ALSO"
98 .PP
99 \fBsystemd\fR(1), \fBsd-login\fR(3), \fBsystemd-machined.service\fR(8), \fBsd_pid_get_machine_name\fR(3)