Programmatically issue commands in FUSE?

I am trying to implement something similar to dropbox with FUSE and python (specifically fusepy). I have thought of two different approaches. I prefer approach 1, if it can be done.

  1. I want to have a client/server model, where the client sends command-line requests over HTTP to the server (e.g. the client sends the string 'ls' or 'cd', ... etc). The server, which implements FUSE, should process the command-line request when it is received, and send the result back to the client.

In order to accomplish this, I need to be able to programmatically issue commands such as "ls" to the FUSE implementation at the server. Is there a way to do this? Can I bind the server's FUSE implementation to treat some file/stream/input as the terminal/command-line?

  1. I was thinking of alternatively implementing FUSE on the client as well, and sending only system call requests over HTTP (e.g. the client send the string 'chmod' or 'read' over HTTP, with the appropriate arguments in the request as well). This approach seems less efficient, as one request is made per system call, as opposed to batching system calls in command-line requests in the first approach. However, from what I've seen, it seems like it is not hard to programmatically call system calls in the FUSE implementation at the server. If the first approach cannot be done, how exactly can I programmatically call system calls in a FUSE implementation?

Lastly, is this done a completely different way? These were just my two ideas of solving the problem, but maybe something else exists that can implement a client/server FS better. (How does dropbox do this?)

Answers

Turns out, what I really should be doing is calling subprocess.check_output(...). Fuse deals with system calls, not terminals commands. Converting from command-line to system calls should be done through the OS's kernel. In this case, I ask the OS for the output, and return that string to the client.

Posted on by Pedro Cattori

Relevant tags