Skip to content

Commit

Permalink
Make cluefs a package
Browse files Browse the repository at this point in the history
  • Loading branch information
rfjakob committed Sep 4, 2015
1 parent ffaabc2 commit e88cc4c
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ _testmain.go
*.prof

# This project
cluefs
/cluefs
.DS_Store
*.tar.gz
misc/
2 changes: 1 addition & 1 deletion doc/ToDo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This is the list of items we would like to implement, in no particular order:

* Create a `cluefs` package which could be embedded in other applications
* Create a `cluefs` package which could be embedded in other applications (in progress)
* Develop a proper set of automated tests
* Add support for lock-related operations (see `fcntl(3)`)
* Finish documentation of the few event formats still remaining
Expand Down
2 changes: 1 addition & 1 deletion access.go → lib/cluefs/access.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// +build linux darwin
package main
package cluefs

/*
#include <unistd.h>
Expand Down
2 changes: 1 addition & 1 deletion args.go → lib/cluefs/args.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"flag"
Expand Down
2 changes: 1 addition & 1 deletion config.go → lib/cluefs/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

type Config struct {
entries map[string]string
Expand Down
2 changes: 1 addition & 1 deletion debug.go → lib/cluefs/debug.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion dir.go → lib/cluefs/dir.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion file.go → lib/cluefs/file.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"io"
Expand Down
2 changes: 1 addition & 1 deletion fs.go → lib/cluefs/fs.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion fsops.go → lib/cluefs/fsops.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"encoding/json"
Expand Down
5 changes: 4 additions & 1 deletion globals.go → lib/cluefs/globals.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"fmt"
Expand All @@ -10,6 +10,8 @@ import (
var (
programName string
errlog *log.Logger
// Log destination for errors in main()
ErrlogMain *log.Logger

// The two variables below are set at build time for official releases
// (see Makefile)
Expand All @@ -20,4 +22,5 @@ var (
func init() {
programName = filepath.Base(os.Args[0])
errlog = log.New(os.Stderr, fmt.Sprintf("%s: ", programName), 0)
ErrlogMain = errlog
}
2 changes: 1 addition & 1 deletion group_unix.go → lib/cluefs/group_unix.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// +build linux darwin

package main
package cluefs

/*
#include <unistd.h>
Expand Down
2 changes: 1 addition & 1 deletion handle.go → lib/cluefs/handle.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion node.go → lib/cluefs/node.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion proc_darwin.go → lib/cluefs/proc_darwin.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

// #cgo LDFLAGS: -lproc

Expand Down
2 changes: 1 addition & 1 deletion proc_linux.go → lib/cluefs/proc_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion process.go → lib/cluefs/process.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"path/filepath"
Expand Down
2 changes: 1 addition & 1 deletion stat_darwin.go → lib/cluefs/stat_darwin.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"os"
Expand Down
2 changes: 1 addition & 1 deletion stat_linux.go → lib/cluefs/stat_linux.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"os"
Expand Down
2 changes: 1 addition & 1 deletion tracer.go → lib/cluefs/tracer.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"encoding/csv"
Expand Down
2 changes: 1 addition & 1 deletion user.go → lib/cluefs/user.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package cluefs

import (
"fmt"
Expand Down
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@ package main

import (
"os"
"github.com/rfjakob/cluefs/lib/cluefs"
)

func main() {
// Parse command line arguments
conf, err := ParseArguments()
conf, err := cluefs.ParseArguments()
if err != nil {
os.Exit(1)
}

// Create the tracer
tracer, err := NewTracer(conf.GetOutputFormat(), conf.GetTraceDestination())
tracer, err := cluefs.NewTracer(conf.GetOutputFormat(), conf.GetTraceDestination())
if err != nil {
errlog.Printf("%s", err)
cluefs.ErrlogMain.Printf("%s", err)
os.Exit(2)
}

// Create the file system object
cfs, err := NewClueFS(conf.GetShadowDir(), tracer)
cfs, err := cluefs.NewClueFS(conf.GetShadowDir(), tracer)
if err != nil {
errlog.Printf("could not create file system [%s]", err)
cluefs.ErrlogMain.Printf("could not create file system [%s]", err)
os.Exit(2)
}

// Mount and serve file system requests
if err = cfs.MountAndServe(conf.GetMountPoint(), conf.GetReadOnly()); err != nil {
errlog.Printf("could not mount file system [%s]", err)
cluefs.ErrlogMain.Printf("could not mount file system [%s]", err)
os.Exit(3)
}

Expand Down

0 comments on commit e88cc4c

Please sign in to comment.