vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
Build the tree for Windows and name the platform seams
215f8aebc38e69e621eb6f739e0cfea2ba07fd9a · Keenan Nemetz · 2d ago · parent 416739b1
Build the tree for Windows and name the platform seams `go build` for windows/amd64 failed on five unix syscall uses, and the tree had nowhere to say what a platform can and cannot do. Each unix-only site now lives in a `_unix.go` file with a Windows counterpart: disk capacity through GetDiskFreeSpaceEx, allocated bytes through GetCompressedFileSize, hard-link identity through GetFileInformationByHandle, the runner's cache lock through LockFileEx, a liveness probe through OpenProcess, and a command's process group through a helper that has no group to signal yet. Two sites cannot be ported without weakening them, so they refuse rather than pretend. File modes are a unix control and Windows needs ACLs instead, so `internal/secure` will not create or accept a secret there, and `internal/audit` will not verify a log it cannot check. The front door says the same about exec, which Windows does not have: sshd gets an explanation instead of a process that returns EWINDOWS. A CI step cross-compiles windows/amd64 and vets it, and `go vet` is what type-checks the test files that `go build` skips, so a unix-only call fails a push instead of a port nobody can start. Part of 01M8S9B86B36PE0MY8MMCRCMYA.
internal/storage/stat_unix.go +46
| @@ -0,0 +1,46 @@ | |||
| 1 | //go:build unix | ||
| 2 | |||
| 3 | package storage | ||
| 4 | |||
| 5 | import ( | ||
| 6 | "io/fs" | ||
| 7 | "syscall" | ||
| 8 | ) | ||
| 9 | |||
| 10 | // fileKey identifies a file by the device and inode the filesystem gave it, which | ||
| 11 | // is how a hard link is measured once per inode rather than once per name. | ||
| 12 | func fileKeyFor(_ string, info fs.FileInfo) (fileKey, bool) { | ||
| 13 | st, ok := info.Sys().(*syscall.Stat_t) | ||
| 14 | if !ok { | ||
| 15 | return fileKey{}, false | ||
| 16 | } | ||
| 17 | return fileKey{dev: uint64(st.Dev), ino: st.Ino}, true | ||
| 18 | } | ||
| 19 | |||
| 20 | // allocatedBytes is the space the file actually costs. Blocks is in 512-byte | ||
| 21 | // units, regardless of the filesystem's block size, so a sparse file does not | ||
| 22 | // claim space it does not use. | ||
| 23 | func allocatedBytes(_ string, info fs.FileInfo) int64 { | ||
| 24 | if st, ok := info.Sys().(*syscall.Stat_t); ok && st.Blocks > 0 { | ||
| 25 | return st.Blocks * 512 | ||
| 26 | } | ||
| 27 | return info.Size() | ||
| 28 | } | ||
| 29 | |||
| 30 | // diskUsage is the capacity of the filesystem holding root. Available is what an | ||
| 31 | // unprivileged process can still write, which is the number an operator cares | ||
| 32 | // about; Used is the whole filesystem's usage, not just Vole's. | ||
| 33 | func diskUsage(root string) (Disk, error) { | ||
| 34 | var st syscall.Statfs_t | ||
| 35 | if err := syscall.Statfs(root, &st); err != nil { | ||
| 36 | return Disk{}, err | ||
| 37 | } | ||
| 38 | // Bsize is int64 on Linux and uint32 on Darwin, so it is converted here | ||
| 39 | // rather than used directly; this file is built for both when a release | ||
| 40 | // produces a macOS binary. | ||
| 41 | blockSize := int64(st.Bsize) | ||
| 42 | total := int64(st.Blocks) * blockSize | ||
| 43 | free := int64(st.Bfree) * blockSize | ||
| 44 | available := int64(st.Bavail) * blockSize | ||
| 45 | return Disk{Total: total, Used: total - free, Available: available}, nil | ||
| 46 | } | ||