-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allowing file overwrite Reducing race conditions by passing around inodes instead of file structures Xattrs can be modified and removed
- Loading branch information
Showing
37 changed files
with
2,651 additions
and
1,525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
main | ||
__pycache__ | ||
ENV | ||
cmd_results.txt | ||
cmd_results.txt | ||
diff.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/go/bin/dxfuse : $(wildcard *.go) | ||
go build -o /go/bin/dxfuse /go/src/github.com/dnanexus/dxfuse/cli/main.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package dxfuse | ||
|
||
import ( | ||
"fmt" | ||
"net/rpc" | ||
"os" | ||
) | ||
|
||
type CmdClient struct { | ||
} | ||
|
||
// Sending commands with a client | ||
// | ||
func NewCmdClient() *CmdClient { | ||
return &CmdClient{} | ||
} | ||
|
||
func (client *CmdClient) Sync() { | ||
rpcClient, err := rpc.Dial("tcp", fmt.Sprintf(":%d", CmdPort)) | ||
if err != nil { | ||
fmt.Printf("could not connect to the dxfuse server: %s", err.Error()) | ||
os.Exit(1) | ||
} | ||
defer rpcClient.Close() | ||
|
||
// Synchronous call | ||
var reply bool | ||
err = rpcClient.Call("CmdServerBox.GetLine", "sync", &reply) | ||
if err != nil { | ||
fmt.Printf("sync error: %s", err.Error()) | ||
os.Exit(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* Accept commands from the dxfuse_tools program. The only command | ||
* right now is sync, but this is the place to implement additional | ||
* ones to come in the future. | ||
*/ | ||
package dxfuse | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net" | ||
"net/rpc" | ||
) | ||
|
||
const ( | ||
// A port number for accepting commands | ||
CmdPort = 7205 | ||
) | ||
|
||
type CmdServer struct { | ||
options Options | ||
sybx *SyncDbDx | ||
inbound *net.TCPListener | ||
} | ||
|
||
// A separate structure used for exporting through RPC | ||
type CmdServerBox struct { | ||
cmdSrv *CmdServer | ||
} | ||
|
||
func NewCmdServer(options Options, sybx *SyncDbDx) *CmdServer { | ||
cmdServer := &CmdServer{ | ||
options: options, | ||
sybx : sybx, | ||
inbound : nil, | ||
} | ||
return cmdServer | ||
} | ||
|
||
// write a log message, and add a header | ||
func (cmdSrv *CmdServer) log(a string, args ...interface{}) { | ||
LogMsg("CmdServer", a, args...) | ||
} | ||
|
||
func (cmdSrv *CmdServer) Init() { | ||
addy, err := net.ResolveTCPAddr("tcp", fmt.Sprintf(":%d", CmdPort)) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
inbound, err := net.ListenTCP("tcp", addy) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
cmdSrv.inbound = inbound | ||
|
||
cmdSrvBox := &CmdServerBox{ | ||
cmdSrv : cmdSrv, | ||
} | ||
rpc.Register(cmdSrvBox) | ||
go rpc.Accept(inbound) | ||
|
||
cmdSrv.log("started command server, accepting external commands") | ||
} | ||
|
||
func (cmdSrv *CmdServer) Close() { | ||
cmdSrv.inbound.Close() | ||
} | ||
|
||
// Note: all export functions from this module have to have this format. | ||
// Nothing else will work with the RPC package. | ||
func (box *CmdServerBox) GetLine(arg string, reply *bool) error { | ||
cmdSrv := box.cmdSrv | ||
cmdSrv.log("Received line %s", arg) | ||
switch arg { | ||
case "sync": | ||
cmdSrv.sybx.CmdSync() | ||
default: | ||
cmdSrv.log("Unknown command") | ||
} | ||
|
||
*reply = true | ||
return nil | ||
} |
Oops, something went wrong.