- Fault Injection (Example: Namazu)
- Cache
- Malware Detection
and so on..
HookFS was originally developed for Namazu, but we believe HookFS can be also used for other purposes.
$ go get github.com/osrg/hookfs/hookfs
$ cd example/ex01
$ go build
$ ./ex01 "/mnt/hookfs" "/original"
^C
$ fusermount -u "/mnt/hookfs"
You have to implement HookXXX
(e.g. HookOnOpen
, HookOnRead
, HookOnWrite
, ..) interfaces.
type HookOnRead interface {
// if hooked is true, the real read() would not be called
PreRead(path string, length int64, offset int64) (buf []byte, hooked bool, ctx HookContext, err error)
PostRead(realRetCode int32, realBuf []byte, prehookCtx HookContext) (buf []byte, hooked bool, err error)
}
Then, regist your hook implementation to the HookFS server.
fs, err := NewHookFs("/original", "/mnt/hookfs", &YourHook{})
if err != nil { .. }
err = fs.Serve()
See hook.go
for further information. GoDoc is also your friend.
We welcome your contribution to HookFS. Please feel free to send your pull requests on github!
Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.
Released under Apache License 2.0.