Abhinav
Abhinav

Reputation: 31

fuse-python xmp.py - Not able to create a file

I am writing a Network File System, and I have started by trying to understand the xmp.py provided with python-fuse.

Well basically I'm sending all the calls over the network, executing it on the server-side and sending the result to the client and returning it to the user. These parts are working perfectly fine.

The problem I am facing is that, the xmp.py is not able to create a file and hence the problem is showing up in my Network File System too.

The steps I have followed are:

  1. Installed fuse-python by:

    sudo apt-get install python-fuse 
    
  2. Then I go into the directory where xmp.py is located:

    cd /usr/share/doc/python-fuse/examples/
    
  3. I ran the xmp.py program with the following command-line arguments

    python xmp.py -o root=/home/user /tmp/fuse
    

    where /home/user will be replicated or mounted on /tmp/fuse

  4. Then I cd into the /tmp/fuse directory and try to make a file with cat, like:

    cd /tmp/fuse
    cat > temp.txt
    

    I get the error

    bash: temp.txt: Invalid argument
    

After a lot of poking around, I believe that this is due to the function

def getattr(self, path):
    return os.lstat("." + path)

When I do a cat > temp.txt, os.lstat("./temp.txt") is called and an error is thrown as the file /home/user/temp.txt is not found. After this the program gets stuck for a while and slows down my computer.

Please help me figure out what I'm doing wrong.

Thanks.

Upvotes: 1

Views: 839

Answers (1)

Abhinav
Abhinav

Reputation: 31

I think i have figured it out, the problem that i saw was once os.lstat("./temp.txt") fails, the file class's __init__ method is called and then immediately truncate is called and the program returns.

One solution that i followed was to not use the file class at all, and to implement the Fuse class' open/create to make the file.

This approach worked for me. If anyone has a better suggestion please let me know. I would like to use the object-oriented approach and use the file class.

Upvotes: 2

Related Questions