1 //go:build !linux 2 // +build !linux 3 4 package 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. 8 type NsHandle int 9 10 // Equal determines if two network handles refer to the same network 11 // namespace. It is only implemented on Linux. 12 func (ns NsHandle) Equal(_ NsHandle) bool { 13 return 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. 19 func (ns NsHandle) String() string { 20 return "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. 26 func (ns NsHandle) UniqueId() string { 27 return "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. 32 func (ns NsHandle) IsOpen() bool { 33 return false 34 } 35 36 // Close closes the NsHandle and resets its file descriptor to -1. 37 // It is only implemented on Linux. 38 func (ns *NsHandle) Close() error { 39 return nil 40 } 41 42 // None gets an empty (closed) NsHandle. 43 func None() NsHandle { 44 return NsHandle(-1) 45 } 46