feat: add experimental standalone SMB service for Finder

This commit is contained in:
Meghdad committed 2026-10-16 15:09:41 +03:30
1 parent c9006c11dd
commit b9cb187f0d
55 files changed
+7961 -10

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
package smbserver
import (
"os"
"syscall"
"time"
)
func sysStat(fi os.FileInfo) (sysInfo, bool) {
st, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return sysInfo{}, false
}
return sysInfo{
dev: uint64(st.Dev),
ino: st.Ino,
nlink: uint32(st.Nlink),
alloc: uint64(st.Blocks) * 512,
atime: time.Unix(st.Atimespec.Sec, st.Atimespec.Nsec),
ctime: time.Unix(st.Ctimespec.Sec, st.Ctimespec.Nsec),
btime: time.Unix(st.Birthtimespec.Sec, st.Birthtimespec.Nsec),
}, true
}
// diskSpace reports the capacity of the filesystem holding dir, in units of
// unit bytes: total, free, and free to an unprivileged user.
func diskSpace(dir string) (total, free, avail uint64, unit uint32, err error) {
var st syscall.Statfs_t
if err = syscall.Statfs(dir, &st); err != nil {
return
}
return st.Blocks, st.Bfree, st.Bavail, st.Bsize, nil
}