aboutsummaryrefslogtreecommitdiff
path: root/sysv/ftok.go
diff options
context:
space:
mode:
Diffstat (limited to 'sysv/ftok.go')
-rw-r--r--sysv/ftok.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/sysv/ftok.go b/sysv/ftok.go
new file mode 100644
index 0000000..94d73cf
--- /dev/null
+++ b/sysv/ftok.go
@@ -0,0 +1,16 @@
+package sysv
+
+import (
+ "golang.org/x/sys/unix"
+)
+
+func Ftok(p string, id uint) (uint, error) {
+ fss := &unix.Stat_t{}
+ if err := unix.Stat(p, fss); err != nil {
+ return 0, err
+ }
+
+ return uint((uint(fss.Ino) & 0xffff) |
+ uint((fss.Dev&0xff)<<16) |
+ ((id & 0xff) << 24)), nil
+}

Snix LLC Git Repository Holder Copyright(C) 2022 All Rights Reserved Email To Snix.IR