mknod.go 784 B

12345678910111213141516171819202122
  1. // +build !windows
  2. package system
  3. import (
  4. "syscall"
  5. )
  6. // Mknod creates a filesystem node (file, device special file or named pipe) named path
  7. // with attributes specified by mode and dev.
  8. func Mknod(path string, mode uint32, dev int) error {
  9. return syscall.Mknod(path, mode, dev)
  10. }
  11. // Mkdev is used to build the value of linux devices (in /dev/) which specifies major
  12. // and minor number of the newly created device special file.
  13. // Linux device nodes are a bit weird due to backwards compat with 16 bit device nodes.
  14. // They are, from low to high: the lower 8 bits of the minor, then 12 bits of the major,
  15. // then the top 12 bits of the minor.
  16. func Mkdev(major int64, minor int64) uint32 {
  17. return uint32(((minor & 0xfff00) << 12) | ((major & 0xfff) << 8) | (minor & 0xff))
  18. }