2014-11-13 15:00:04 -05:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
2015-03-31 04:03:31 -04:00
|
|
|
// Mknod creates a filesystem node (file, device special file or named pipe) named path
|
2015-07-28 12:13:12 -04:00
|
|
|
// with attributes specified by mode and dev.
|
2014-11-13 15:00:04 -05:00
|
|
|
func Mknod(path string, mode uint32, dev int) error {
|
|
|
|
return syscall.Mknod(path, mode, dev)
|
|
|
|
}
|
|
|
|
|
2015-07-28 12:13:12 -04: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.
|
2014-11-13 15:00:04 -05:00
|
|
|
// 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,
|
2015-07-28 12:13:12 -04:00
|
|
|
// then the top 12 bits of the minor.
|
2014-11-13 15:00:04 -05:00
|
|
|
func Mkdev(major int64, minor int64) uint32 {
|
|
|
|
return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff))
|
|
|
|
}
|