Files
nfs/internal/nfsfs/mknod_freebsd.go
T
petrbalvin a9b8039ef7
Test / test (push) Successful in 2m4s
Release / gates (push) Successful in 2m5s
Release / build (amd64, freebsd) (push) Successful in 1m27s
Release / build (amd64, linux) (push) Successful in 1m22s
Release / build (amd64, netbsd) (push) Successful in 1m19s
Release / build (amd64, openbsd) (push) Successful in 1m20s
Release / build (arm64, darwin) (push) Successful in 1m21s
Release / build (arm64, freebsd) (push) Successful in 1m26s
Release / build (arm64, linux) (push) Successful in 1m25s
Release / build (arm64, netbsd) (push) Successful in 1m31s
Release / build (arm64, openbsd) (push) Successful in 1m27s
Release / build (loong64, linux) (push) Successful in 1m37s
Release / build (riscv64, linux) (push) Successful in 1m21s
Release / release (push) Successful in 40s
feat: full NFSv4.2 server and client in pure Go
Assisted-by: GLM 5.3 Flash
2026-09-21 18:51:17 +02:00

33 lines
1.2 KiB
Go

// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: MIT
//go:build freebsd
package nfsfs
import "syscall"
// mknod creates a device node. It needs the superuser on FreeBSD, and a
// failure of permission is reported as such rather than as an io error.
// The kind is picked before the single call: a second mknod over an
// existing node fails EEXIST and leaves the wrong kind behind.
func mknod(path string, spec CreateSpec, perm uint32) error {
dev := makedev(spec.Major, spec.Minor)
kind := uint32(syscall.S_IFCHR)
if spec.Kind == KindBlk {
kind = syscall.S_IFBLK
}
return syscall.Mknod(path, perm|kind, dev)
}
// makedev assembles a device number the way the kernel expects it: the
// encoding of makedev in sys/sys/types.h, where the low byte of the
// major number sits at bits eight to fifteen with the rest of it above
// the thirty-second bit, and the minor number keeps its low byte at bit
// zero with the byte at bits eight to fifteen lifted above the
// thirty-second bit.
func makedev(major, minor uint32) uint64 {
return uint64(major&0xffffff00)<<32 | uint64(major&0xff)<<8 |
uint64(minor&0xff00)<<24 | uint64(minor&0xffff00ff)
}