v0.3.0 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2019 License: Apache-2.0


HookFS: A Usermode Hookable Filesystem Library


Possible Recipes

  • 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

Running an Example

$ cd example/ex01
$ go build
$ ./ex01 "/mnt/hookfs" "/original"
$ fusermount -u "/mnt/hookfs"

API Design

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.

How to Contribute

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.


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL