podman
45 строк · 1.2 Кб
1//go:build !linux
2// +build !linux
3
4package netns
5
6// NsHandle is a handle to a network namespace. It can only be used on Linux,
7// but provides stub methods on other platforms.
8type NsHandle int
9
10// Equal determines if two network handles refer to the same network
11// namespace. It is only implemented on Linux.
12func (ns NsHandle) Equal(_ NsHandle) bool {
13return false
14}
15
16// String shows the file descriptor number and its dev and inode.
17// It is only implemented on Linux, and returns "NS(none)" on other
18// platforms.
19func (ns NsHandle) String() string {
20return "NS(none)"
21}
22
23// UniqueId returns a string which uniquely identifies the namespace
24// associated with the network handle. It is only implemented on Linux,
25// and returns "NS(none)" on other platforms.
26func (ns NsHandle) UniqueId() string {
27return "NS(none)"
28}
29
30// IsOpen returns true if Close() has not been called. It is only implemented
31// on Linux and always returns false on other platforms.
32func (ns NsHandle) IsOpen() bool {
33return false
34}
35
36// Close closes the NsHandle and resets its file descriptor to -1.
37// It is only implemented on Linux.
38func (ns *NsHandle) Close() error {
39return nil
40}
41
42// None gets an empty (closed) NsHandle.
43func None() NsHandle {
44return NsHandle(-1)
45}
46