Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

osrg/hookfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HookFS: A Usermode Hookable Filesystem Library

GoDoc

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.

Install

$ go get github.com/osrg/hookfs/hookfs

Running an Example

$ cd example/ex01
$ go build
$ ./ex01 "/mnt/hookfs" "/original"
^C
$ 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.

Related Projects

How to Contribute

We welcome your contribution to HookFS. Please feel free to send your pull requests on github!

Copyright

Copyright (C) 2015 Nippon Telegraph and Telephone Corporation.

Released under Apache License 2.0.

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages