2016-11-22 19:32:10 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
2017-09-12 23:29:24 +00:00
|
|
|
"golang.org/x/sys/unix"
|
2016-11-22 19:32:10 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Mknod creates a filesystem node (file, device special file or named pipe) named path
|
|
|
|
// with attributes specified by mode and dev.
|
|
|
|
func Mknod(path string, mode uint32, dev int) error {
|
2017-09-12 23:29:24 +00:00
|
|
|
return unix.Mknod(path, mode, dev)
|
2016-11-22 19:32:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mkdev is used to build the value of linux devices (in /dev/) which specifies major
|
|
|
|
// and minor number of the newly created device special file.
|
|
|
|
// Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes.
|
|
|
|
// They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major,
|
|
|
|
// then the top 12 bits of the minor.
|
|
|
|
func Mkdev(major int64, minor int64) uint32 {
|
|
|
|
return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff))
|
|
|
|
}
|