Giter VIP home page Giter VIP logo

python-fuse's Introduction

python-fuse's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-fuse's Issues

new python fuse api FUSE function

which function is same as FUSE in new python3 api fuse.Fuse doesn't seem to work where we give filesystem create class object and mount point etc can anyone tell that please?

example Hello.py Don't Works

Hi, actually when we run the example, finish with the next error:

python3 hello.py
fuse: missing mountpoint parameter
Traceback (most recent call last):
  File "hello.py", line 91, in <module>
    main()
  File "hello.py", line 88, in main
    server.main()
  File "/usr/lib/python3/dist-packages/fuse.py", line 754, in main
    main(**d)
fuse.FuseError: filesystem initialization failed

Thx

python3 callbacks should use type 'bytes' instead of 'str' to manipulate data

When using python-fuse with python3, the python callbacks such as write or read, should manipulate objects of type bytes instead of str.

In python3, type str is really for text representation, not raw data. However the C wrapper send str objects to write function and expect str objects are return value for read. With such a limitation, not all kind of data can be write or read throw a python-fuse file system, only text data can be wrote/read.

For python2, API should still send data using type str as in python2 binary data can be represented with such a type.

Here is an example that does not work for me right now. I got error EINVAL "Invalid argument"

$ mkdir /tmp/fioc
$ ./example/fioc.py /tmp/fioc

# Working use case
$ echo hello > /tmp/fioc/fioc

# no working use case
$ echo $'\x80' > /tmp/fioc/fioc

I tested read and write functions, maybe some others functions has similar limitations.

Different results when running `echo && cat` with `bash` and `fish`

I've prepared a toy example based on xmp.py which proofs that there is a bug somewhere:

#!/usr/bin/env python

import fuse
import os
import sys
import time
from fuse import Fuse
from threading import Lock

fuse.fuse_python_api = (0, 2)

fuse.feature_assert('stateful_files', 'has_init')


def flag2mode(flags):
    md = {os.O_RDONLY: 'rb', os.O_WRONLY: 'wb', os.O_RDWR: 'wb+'}
    m = md[flags & (os.O_RDONLY | os.O_WRONLY | os.O_RDWR)]

    if flags | os.O_APPEND:
        m = m.replace('w', 'a', 1)

    return m


class Xmp(Fuse):

    def __init__(self, *args, **kw):
        Fuse.__init__(self, *args, **kw)
        self.root = '/'

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

    def truncate(self, path, len):
        f = open("." + path, "a")
        f.truncate(len)
        f.close()

    def fsinit(self):
        os.chdir(self.root)

    class XmpFile(object):

        def __init__(self, path, flags, *mode):
            self.file = os.fdopen(os.open("." + path, flags, *mode), flag2mode(flags))
            self.fd = self.file.fileno()
            self.iolock = Lock()

        def read(self, length, offset):
            with self.iolock:
                self.file.seek(offset)
                return self.file.read(length)

        def write(self, buf, offset):
            with self.iolock:
                self.file.seek(offset)
                self.file.write(buf)
                return len(buf)

        def release(self, flags):
            self.file.close()

        def _fflush(self):
            if 'w' in self.file.mode or 'a' in self.file.mode:
                self.file.flush()

        def flush(self):
            time.sleep(5)  # simulating network lag
            self._fflush()
            os.close(os.dup(self.fd))

    def main(self, *a, **kw):

        self.file_class = self.XmpFile
        return Fuse.main(self, *a, **kw)


def main():

    usage = Fuse.fusage
    server = Xmp(version="%prog " + fuse.__version__, usage=usage, dash_s_do='setsingle')
    server.parser.add_option(mountopt="root", metavar="PATH", default='/',
                             help="mirror filesystem from under PATH [default: %default]")
    server.parse(values=server, errex=1)

    try:
        server.fuse_args.add('allow_other')
        server.fuse_args.add('attr_timeout=0')   # commenting out this line doesn't help
        server.fuse_args.add('entry_timeout=0')  # commenting out this line doesn't help

        if server.fuse_args.mount_expected():
            os.chdir(server.root)
    except OSError:
        print("can't enter root of underlying filesystem", file=sys.stderr)
        sys.exit(1)

    server.main()


if __name__ == '__main__':
    main()

Notice that there is time.sleep(5) added in flush() method which simulates network lag (if you remove this line, the problem is gone).

Lets mount our toy file system:

python3 ./xmp.py -d -o root=./local/ ./mnt

Test with bash

Now open bash terminal and run:

$ echo 'onetwo' > ./mnt/test-bash.txt && cat ./mnt/test-bash.txt
onetwo
$ cat ./mnt/test-bash.txt
onetwo

Test with fish

Open fish terminal and run:

$ echo 'onetwo' > ./mnt/test-fish.txt && cat ./mnt/test-fish.txt
$ cat ./mnt/test-fish.txt
onetwo

What the heck? Different results for different terminals! I've also checked zsh and csh – they behave same as bash. It seems that only fish is affected.

Log for bash test

unique: 226, opcode: LOOKUP (1), nodeid: 1, insize: 54, pid: 22987
LOOKUP /test-bash.txt
getattr /test-bash.txt
   unique: 226, error: -2 (No such file or directory), outsize: 16
unique: 228, opcode: CREATE (35), nodeid: 1, insize: 70, pid: 22987
create flags: 0x8241 /test-bash.txt 0100644 umask=0022
   create[140680646551824] flags: 0x8241 /test-bash.txt
getattr /test-bash.txt
   NODEID: 2
   unique: 228, success, outsize: 160
unique: 230, opcode: FLUSH (25), nodeid: 2, insize: 64, pid: 22987
flush[140680646551824]
unique: 232, opcode: LOOKUP (1), nodeid: 1, insize: 54, pid: 8140
LOOKUP /test-bash.txt
getattr /test-bash.txt
   NODEID: 2
   unique: 232, success, outsize: 144
unique: 234, opcode: GETATTR (3), nodeid: 2, insize: 56, pid: 8140
getattr /test-bash.txt
   unique: 234, success, outsize: 120                      # after printing this line it sleeps for 5 seconds
unique: 236, opcode: LOOKUP (1), nodeid: 1, insize: 54, pid: 8140
LOOKUP /test-bash.txt
getattr /test-bash.txt
   NODEID: 2
   unique: 236, success, outsize: 144
unique: 238, opcode: GETATTR (3), nodeid: 2, insize: 56, pid: 8140
getattr /test-bash.txt
   unique: 238, success, outsize: 120
   unique: 230, success, outsize: 16
unique: 240, opcode: GETXATTR (22), nodeid: 2, insize: 68, pid: 22987
   unique: 240, error: -38 (Function not implemented), outsize: 16
unique: 242, opcode: WRITE (16), nodeid: 2, insize: 87, pid: 22987
write[140680646551824] 7 bytes to 0 flags: 0x8001
   write[140680646551824] 7 bytes to 0
   unique: 242, success, outsize: 24
unique: 244, opcode: FLUSH (25), nodeid: 2, insize: 64, pid: 22987
flush[140680646551824]                                     # after printing this line it sleeps for 5 seconds
   unique: 244, success, outsize: 16
unique: 246, opcode: RELEASE (18), nodeid: 2, insize: 64, pid: 0
release[140680646551824] flags: 0x8001
   unique: 246, success, outsize: 16
unique: 248, opcode: LOOKUP (1), nodeid: 1, insize: 54, pid: 28882
LOOKUP /test-bash.txt
getattr /test-bash.txt
   NODEID: 2
   unique: 248, success, outsize: 144
unique: 250, opcode: OPEN (14), nodeid: 2, insize: 48, pid: 28882
open flags: 0x8000 /test-bash.txt
   open[140680646551920] flags: 0x8000 /test-bash.txt
   unique: 250, success, outsize: 32
unique: 252, opcode: GETATTR (3), nodeid: 2, insize: 56, pid: 28882
getattr /test-bash.txt
   unique: 252, success, outsize: 120
unique: 254, opcode: GETATTR (3), nodeid: 2, insize: 56, pid: 28882
getattr /test-bash.txt
   unique: 254, success, outsize: 120
unique: 256, opcode: READ (15), nodeid: 2, insize: 80, pid: 28882   # reading the file
read[140680646551920] 4096 bytes from 0 flags: 0x8000
   read[140680646551920] 7 bytes from 0
   unique: 256, success, outsize: 23
unique: 258, opcode: GETATTR (3), nodeid: 2, insize: 56, pid: 28882
getattr /test-bash.txt
   unique: 258, success, outsize: 120
unique: 260, opcode: FLUSH (25), nodeid: 2, insize: 64, pid: 28882
flush[140680646551920]                                     # it prints 'onetwo' to the console and after that, it sleeps for 5 seconds
   unique: 260, success, outsize: 16
unique: 262, opcode: RELEASE (18), nodeid: 2, insize: 64, pid: 0
release[140680646551920] flags: 0x8000
   unique: 262, success, outsize: 16

Log for fish test

unique: 336, opcode: LOOKUP (1), nodeid: 1, insize: 54, pid: 5904
LOOKUP /test-fish.txt
getattr /test-fish.txt
   unique: 336, error: -2 (No such file or directory), outsize: 16
unique: 338, opcode: CREATE (35), nodeid: 1, insize: 70, pid: 5904
create flags: 0x8241 /test-fish.txt 0100644 umask=0022
   create[139889311254944] flags: 0x8241 /test-fish.txt
getattr /test-fish.txt
   NODEID: 2
   unique: 338, success, outsize: 160
unique: 340, opcode: GETXATTR (22), nodeid: 2, insize: 68, pid: 22766
   unique: 340, error: -38 (Function not implemented), outsize: 16
unique: 342, opcode: LOOKUP (1), nodeid: 1, insize: 54, pid: 8140
LOOKUP /test-fish.txt
getattr /test-fish.txt
unique: 344, opcode: WRITE (16), nodeid: 2, insize: 87, pid: 22766
write[139889311254944] 7 bytes to 0 flags: 0x8001
   NODEID: 2
   unique: 342, success, outsize: 144
unique: 346, opcode: GETATTR (3), nodeid: 2, insize: 56, pid: 8140
getattr /test-fish.txt
   write[139889311254944] 7 bytes to 0
   unique: 344, success, outsize: 24
   unique: 346, success, outsize: 120
unique: 348, opcode: FLUSH (25), nodeid: 2, insize: 64, pid: 22766
flush[139889311254944]
unique: 350, opcode: LOOKUP (1), nodeid: 1, insize: 54, pid: 8140
LOOKUP /test-fish.txt
getattr /test-fish.txt
   NODEID: 2
   unique: 350, success, outsize: 144
unique: 352, opcode: GETATTR (3), nodeid: 2, insize: 56, pid: 8140
getattr /test-fish.txt
   unique: 352, success, outsize: 120
unique: 354, opcode: LOOKUP (1), nodeid: 1, insize: 54, pid: 22769
LOOKUP /test-fish.txt
getattr /test-fish.txt
   NODEID: 2
   unique: 354, success, outsize: 144
unique: 356, opcode: OPEN (14), nodeid: 2, insize: 48, pid: 22769
open flags: 0x8000 /test-fish.txt
   open[139889311254800] flags: 0x8000 /test-fish.txt
   unique: 356, success, outsize: 32
unique: 358, opcode: GETATTR (3), nodeid: 2, insize: 56, pid: 22769
getattr /test-fish.txt
   unique: 358, success, outsize: 120
unique: 360, opcode: GETATTR (3), nodeid: 2, insize: 56, pid: 22769
getattr /test-fish.txt
   unique: 360, success, outsize: 120
unique: 362, opcode: READ (15), nodeid: 2, insize: 80, pid: 22769
read[139889311254800] 4096 bytes from 0 flags: 0x8000
   read[139889311254800] 0 bytes from 0
   unique: 362, success, outsize: 16
unique: 364, opcode: FLUSH (25), nodeid: 2, insize: 64, pid: 22769
flush[139889311254800]                                     # after printing this line it sleeps for 5 seconds
   unique: 348, success, outsize: 16
unique: 366, opcode: RELEASE (18), nodeid: 2, insize: 64, pid: 0
release[139889311254944] flags: 0x8001
   unique: 366, success, outsize: 16
   unique: 364, success, outsize: 16
unique: 368, opcode: RELEASE (18), nodeid: 2, insize: 64, pid: 0
release[139889311254800] flags: 0x8000
   unique: 368, success, outsize: 16

Notice that FLUSH (triggered by echo):

unique: 348, opcode: FLUSH (25), nodeid: 2, insize: 64, pid: 22766

returns after READ (triggered by cat) returns:

unique: 362, opcode: READ (15), nodeid: 2, insize: 80, pid: 22769

which is too late because test-fish.txt was not yet saved/flushed when we started reading it! Also notice late RELEASE for both echo and cat(in opposite to bash log).

Caveat: if you run add sleep 5 command between echo and cat, it works even with fish terminal:

$ echo 'onetwo' > ./mnt/test-fish.txt && sleep 5 && cat ./mnt/test-fish.txt
onetwo
$ cat ./mnt/test-fish.txt
onetwo

Do you have any idea where may be the bug?

Update

  • If I add -s flag to mounting options (which disables multi-threaded operation), it works just fine for both fish and bash.
  • I tried out to implement an equivalent code in C (based on fusexmp.c), using original libfuse (ver. 2.9.9) and it works just fine as opposed to the above Python version.
  • If I replace:
    def read(self, length, offset):
        with self.iolock:
            self.file.seek(offset)
            return self.file.read(length)
    
    def write(self, buf, offset):
        with self.iolock:
            self.file.seek(offset)
            self.file.write(buf)
            return len(buf)
    with:
    def read(self, length, offset):
        return os.pread(self.fd, length, offset)
    
    def write(self, buf, offset):
        return os.pwrite(self.fd, buf, offset)
    it works for both fish and bash (maybe it has something to do with #18 @drougge?).
  • I'm trying any luck with:
    PYTHONMALLOC=malloc valgrind --leak-check=full --show-leak-kinds=all --log-file="log.txt" python3 ./xmp.py -d -o root=./local/ ./mnt
    it reports one issue which seems to be a not false positive :
    ==51467== 196 bytes in 3 blocks are definitely lost in loss record 3,146 of 3,994
    ==51467==    at 0x483877F: malloc (vg_replace_malloc.c:307)
    ==51467==    by 0x577828: ??? (in /usr/bin/python3.9)
    ==51467==    by 0x62E51D8: MyString_AsEncodedPath (_fusemodule.c:99)
    ==51467==    by 0x62E59D4: Fuse_main (_fusemodule.c:1411)
    ==51467==    by 0x53F34F: ??? (in /usr/bin/python3.9)
    ==51467==    by 0x53C3C8: PyObject_Call (in /usr/bin/python3.9)
    ==51467==    by 0x517B9A: _PyEval_EvalFrameDefault (in /usr/bin/python3.9)
    ==51467==    by 0x5106EC: ??? (in /usr/bin/python3.9)
    ==51467==    by 0x528D20: _PyFunction_Vectorcall (in /usr/bin/python3.9)
    ==51467==    by 0x513E8A: _PyEval_EvalFrameDefault (in /usr/bin/python3.9)
    ==51467==    by 0x5106EC: ??? (in /usr/bin/python3.9)
    ==51467==    by 0x528D20: _PyFunction_Vectorcall (in /usr/bin/python3.9)
    

exceptions are swallowed

Are python exceptions supposed to show up in some log file? Right now they are swallowed, which make it painful to write a filesystem.

There is no strightforward way to exit the main loop

The fuse API fuse_exit is not wrapped and becuase of that there is no correct way to exit the main loop and move on to the teadown.
There is code at the end of Fuse_main that calls fuse_teardown but it seems like there is no way to get there.
Wrapping the fuse_exit API is required to fix this issue.

I want to maintain the project

Hello. I'm interested in maintaining the project. I'm a big fan of microkernel architecture, so I like the idea that filesystem driver runs in user mode. Also I want to build some filesystems for my personal needs which do not require high performance. For example, I want to implement something like overlayfs which protects some files (SSH and PGP keys, for example) and backups them on change. Interpreted language is the best choice for this. Firstly I decided to write a Ruby interface for libfuse because Ruby is my preferred language. Then I found this project and decided to not reinvent the wheel.

inconsistent fuse write chunk size for different versions of windows

I am using python fuse to intercept my application writes. My application is writing in 4K chunks on file present at fuse mount point and for windows 2008 and 2012 server edition fuse write is comming in 4K chunks but for windows 2003 fuse is receiving 512 and 3546 fuse write requests for each of 4K application write. Why the fuse is behaving differently for windows 2k3?
win2k3 drive details :
bytes per sector : 512
bytes per cluster : 4096
sectors per cluster : 8
bytes per volume : 32201936896
sectors per volume : 7861801
clusters per volume : 982725
initialized mft records : 19504
mft records in use : 19469
mft records percentage : 99
bytes of free space : 27737296896
sectors of free space : 54174408
clusters of free space : 6771801
percentage free space : 86
bytes of user data : 4340850688
sectors of user data : 8478224
clusters of user data : 1059778
percentage user data : 13
bytes of metadata : 123789312
sectors of metadata : 241776
clusters of metadata : 30222
percentage metadata : 0

Please help me in understanding this behavior.

Upload wheels to PyPI

Couldn't install the package with pip. https://pythonwheels.com/ make the process much easier.

# pip install fuse-python==0.2
Collecting fuse-python==0.2
  Downloading https://files.pythonhosted.org/packages/9a/96/63370a31dc504017a110e5d38908f0155d955dfc200499c7ba5b518ab6bc/fuse-python-0.2.tar.gz (53kB)
    100% |████████████████████████████████| 61kB 961kB/s 
    Complete output from command python setup.py egg_info:
    pkg-config unavailable, build terminated
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-pbWYae/fuse-python/

Is Mac OS supported?

I'm having trouble figuring out if / how to use this on Mac OS X. When I've successfully run the docker build, it generates fuse_python-1.0.4-cp39-cp39-linux_x86_64.whl which I'm assuming isn't for Mac OS X.

It doesn't help that pip is completely broken on my system so I can't take shortcuts.

async support

Pretty simple. I'd like to be able to use async def instead of def.

linux coreutils checksums do not work with the example xmp.py filesystem when multithreaded

Hi, I noticed that using coreutils checksumming tools (e.g. sha256sum, cksum, md5sum) produce different results whenever applied to a large file using the xmp.py example without the -s flag

e.g.

> python xmp.py fusedir/ -o root=$PWD/workdir/
> dd if=/dev/urandom of=fusedir/test.out  iflag=fullblock bs=1M  count=1024
   1024+0 records in
   1024+0 records out
   1073741824 bytes (1.1 GB, 1.0 GiB) copied, 14.9743 s, 71.7 MB/s

> sha256sum fusedir/test.out 
   82dfa4d345cb1f5641ff3f2997f36dbf7b4a39b68004fb46de52b774551fd252    fusedir/test.out

> sha256sum fusedir/test.out 
   824d9cdca0ae94b88bc34bcebf6cff448790f186e409ca45f037d817352fd959  fusedir/test.out

> sha256sum fusedir/test.out 
   f43f60248365157de48bbdda686007263bb01c3a39d4162854416a623934288c fusedir/test.out

> sha256sum fusedir/test.out 
   334cc87cc93f3fa5ae0659f5ff4caff59f7e795e8b9cc0c5cdd46041b8210259  fusedir/test.out

when I compute the sha256sum of the file at its actual location, the sha256sum is static. Passing the -s flag to the filesystem appears to solve this issue.

fh is not passed to read()

Hello, I try to inspire me from megaFS (it look like it use the same API version that is write in the wiki).

https://github.com/ju1i3nm/MegaFS/blob/master/megafs.py#L83

So I do the same in my code for open()

    def open(self, path, flags):
        # ~ st = fuse.FuseFileInfo()
        # ~ setattr(st, 'direct_io', True)
        # ~ setattr(st, 'nonseekable', True)
        (tmp_f, tmp_path) = tempfile.mkstemp(prefix='syno_')
        os.close(tmp_f)
        if self.fl.get_file(path, mode='download', output=tmp_path):
            return open(tmp_path, "rb")

And I use that for my read()

    def read(self, path, size, offset, fh):
        fh.seek(offset)
        return fh.read(size)

But python is complaining because fh is required argument.

Did I do something wrong, maybe I missed something in the wiki.

Thanks for your help.

Unicode paths?

Am I correct in thinking that python-fuse uses full unicode for pathnames?

I believe that might work better on Windows and Mac than on Linux. Windows and Mac define an encoding for pathnames, but last I heard Linux didn't.

That's probably convenient for most applications, but for system software like a backup program it's probably not a good idea; there could be filenames that aren't unicode.

EG in this:
https://github.com/libfuse/python-fuse/blob/master/example/hello.py
hello_path = '/hello'

...hello_path probably should be (allowed to be?) b'/hello'

I believe anything in unicode can be serialized to bytes, but not everything that is bytes can be deserialized to unicode.

Compilation fails on OSX

Installing via pip install fuse-python
I receive the following compilation error:

fuseparts/_fusemodule.c:951:23: error: use of undeclared identifier '_IOC_WRITE'; did you mean 'UIO_WRITE'?
            if(!(_IOC_DIR(cmd) & _IOC_WRITE)) {
                                 ^~~~~~~~~~
                                 UIO_WRITE
    /usr/include/sys/uio.h:90:25: note: 'UIO_WRITE' declared here
    enum uio_rw { UIO_READ, UIO_WRITE };
                            ^
    fuseparts/_fusemodule.c:963:21: error: use of undeclared identifier '_IOC_READ'; did you mean 'UIO_READ'?
            if(_IOC_DIR(cmd) & _IOC_READ) {
                               ^~~~~~~~~
                               UIO_READ
    /usr/include/sys/uio.h:90:15: note: 'UIO_READ' declared here
    enum uio_rw { UIO_READ, UIO_WRITE };

Requesting more examples on how to use this package

Hi there, I'm interested in making my own clown of tag-based command line interfaces, such as TMSU, and I think I could achieve something similar in Python with python-fuse plus SQLite.

I would like to ask you if you are aware of usages of python-fuse in the wild, or maybe a blog post with more detailed information, given that going solely from the examples the examples provided in this repository and the source code, I'm not quite sure where to begin.

Additionally, I take the opportunity to ask whether this is the go-to package for implementing a FUSE filesystem in Python or not.
All others packages that I found out seem to be deprecated or unmaintained.

How to prevent overlapping calls to read?

Hi,

I'm a noob in both fuse and python-fuse. I've implemented the read(...) callback, but when I access a file from the outside, the read callback gets executed concurrently more than once, and even though I'm trying to access the data in order, the size and offset arguments passed to read seem to indicate it is getting called out of order (non-sequentially).

How do I prevent this? I don't want another call to read() to be triggered before the first one has fully completed.

Also, the mount options are a bit confusing. How do I pass command line arguments when I'm not creating the Fuse object from the command line? I'd like to let any user, specifically root, be able to access the fuse filesystem even when it's running as a normal user process.

How to enable/disable `writeback_cache`?

I'm looking for a way to enable/disable writeback_cache. pyfuse3 allows to do it by setting:

enable_writeback_cache = False

Is there a way to do the same in python-fuse? Based on what I can see here I assume there is no such a way, but I prefer to make sure.

fuse.py triggers SyntaxWarning: invalid escape sequence

When configuring Debian-packaged python3-fuse python3-fuse (2:1.0.6-1+b1) with python3.12, the following warning messages will pop up:

/usr/lib/python3/dist-packages/fuse.py:72: SyntaxWarning: invalid escape sequence '\d'
  fuse_python_api = __getenv__('FUSE_PYTHON_API', '^[\d.]+$',
/usr/lib/python3/dist-packages/fuse.py:557: SyntaxWarning: invalid escape sequence '\*'
  '*':              '!re:^\*$'}
/usr/lib/python3/dist-packages/fuse.py:572: SyntaxWarning: invalid escape sequence '\s'
  ma = isinstance(fp, str) and re.compile("(!\s*|)re:(.*)").match(fp)
/usr/lib/python3/dist-packages/fuse.py:824: SyntaxWarning: invalid escape sequence '\s'
  ore = re.compile("-o\s+([\w\[\]]+(?:=\w+)?)")

unexpected behavior on direct_io = True

I slightly modified example/hello.py, so that it uses direct_io, and I cannot explain the result. With ./test mountpoint, the command cat ./test/hello works fine with direct_io = False, but enters infinite loop when direct_io = True.

The interesting part: compare output of strace -y cat ./test/hello >/dev/null:

  1. direct_io = False
openat(AT_FDCWD</home/mateusz/Downloads>, "./test/hello", O_RDONLY) = 3</home/mateusz/Downloads/test/hello>
newfstatat(3</home/mateusz/Downloads/test/hello>, "", {st_mode=S_IFREG|0444, st_size=1000, ...}, AT_EMPTY_PATH) = 0
fadvise64(3</home/mateusz/Downloads/test/hello>, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
mmap(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5bf4bdb000
read(3</home/mateusz/Downloads/test/hello>, "ffffffffffffffffffffffffffffffff"..., 131072) = 1000
write(1</dev/null>, "ffffffffffffffffffffffffffffffff"..., 1000) = 1000
read(3</home/mateusz/Downloads/test/hello>, "", 131072) = 0
munmap(0x7f5bf4bdb000, 139264)          = 0
close(3</home/mateusz/Downloads/test/hello>) = 0
  1. direct_io = True
openat(AT_FDCWD</home/mateusz/Downloads>, "./test/hello", O_RDONLY) = 3</home/mateusz/Downloads/test/hello>
newfstatat(3</home/mateusz/Downloads/test/hello>, "", {st_mode=S_IFREG|0444, st_size=1000, ...}, AT_EMPTY_PATH) = 0
fadvise64(3</home/mateusz/Downloads/test/hello>, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
mmap(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f60baa38000
read(3</home/mateusz/Downloads/test/hello>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
write(1</dev/null>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
read(3</home/mateusz/Downloads/test/hello>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
write(1</dev/null>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
read(3</home/mateusz/Downloads/test/hello>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
write(1</dev/null>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
read(3</home/mateusz/Downloads/test/hello>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072
write(1</dev/null>, "ffffffffffffffffffffffffffffffff"..., 131072) = 131072

.... # infinite loop

Ubuntu 22.04
fusermount3 version: 3.10.5

Full reproducer:
hello.py.txt

Migrate FuseArgs away from using Optparse

The current implementation of FuseArgs extends Optparse, which is scheduled to be deprecated in favor of argparse. Although there isn't a schedule for when it would be deprecated, it might be a good idea to reimplement this using argparse.

Furthermore, imho, the current implementation is a bit unwieldy and inflexible. For instance, I have spent way too longer than I expected and yet have not been able to figure out how to implement the command line to support something like:

my_fuse_cmd.py <required parameter> <required path parameter> <mountpoint> [fuse options]

If there is interest in migrating away from optparse, and nobody is already working on it, I would like to attempt doing this.

If it is felt that this isn't a worthwhile effort for any reason, could someone guide me on how to create a Fuse instance such that the command-line above is supported (using FuseArgs, that is -- I obviously could split up the parsing of args I am interested in and those that get passed to the parent Fuse class ...but that would be ugly).

Export Xmp Mountpoint to NFS

Hi there,

was trying to do the following:

  • start xmp so it mirrors another directory in system (lets say /input --> /output)
  • share that mounted directory /output via NFS
    The first part works without a problem, but I am having issues getting the second part to work. I export the mounted directory and get no errors but I cannot see the files from the /input directory
    I know its a bit out of the scope of the xmp example, but would really appreciate any pointers or suggestions

wrong library installed - x86_64 instead of arm64

I have mac m1 arm64.

whenever I do pip install fuse-python (which is btw reversed from this repo name) it installs the library under:
~/opt/miniconda3/lib/python3.9/site-packages/fuseparts/_fuse.cpython-39-darwin.so

however it is the wrong architecture:

file ~/opt/miniconda3/lib/python3.9/site-packages/fuseparts/_fuse.cpython-39-darwin.so
~/opt/miniconda3/lib/python3.9/site-packages/fuseparts/_fuse.cpython-39-darwin.so: Mach-O 64-bit bundle x86_64

I have confirmed other libs are installed properly so it seems isolated to fuse-python.

Debugging a crash

Started using this library:

but it crashes in non-debug mode, and in debug mode no errors. catching exception does not help.

how to get logs out of the problem?

In that example, crash can be avoided by not using any plex server related in section_types method

this still crashes even faulti part is catch'ed:

    @cached_property
    def section_types(self):
        try:
            self.server
        except Exception as e:
            ...
        return {}

tl;dr: crashes on macos in normal mode. does not crash under -f, does not crash under -d, and under -d no known exception is thrown.

Does not install on Python 2.7

Output of pip2 below:

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: colorama in /home/mario/.local/lib/python2.7/site-packages (from -r requirements.txt (line 2)) (0.4.4)
Requirement already satisfied: argparse-color-formatter in /home/mario/.local/lib/python2.7/site-packages (from -r requirements.txt (line 3)) (1.2.2.post2)
Requirement already satisfied: texttable in /home/mario/.local/lib/python2.7/site-packages (from -r requirements.txt (line 4)) (1.6.3)
Collecting fuse-python
  Using cached fuse-python-1.0.1.tar.gz (48 kB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python2 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-SqGZP4/fuse-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-SqGZP4/fuse-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-DPQm1G
         cwd: /tmp/pip-install-SqGZP4/fuse-python/
    Complete output (48 lines):
    Usage:
      pkg-config [OPTION?]
    
    Help Options:
      -h, --help                              Show help options
    
    Application Options:
      --version                               output version of pkg-config
      --modversion                            output version for package
      --atleast-pkgconfig-version=VERSION     require given version of pkg-config
      --libs                                  output all linker flags
      --static                                output linker flags for static linking
      --short-errors                          print short errors
      --libs-only-l                           output -l flags
      --libs-only-other                       output other libs (e.g. -pthread)
      --libs-only-L                           output -L flags
      --cflags                                output all pre-processor and compiler flags
      --cflags-only-I                         output -I flags
      --cflags-only-other                     output cflags not covered by the cflags-only-I option
      --variable=NAME                         get the value of variable named NAME
      --define-variable=NAME=VALUE            set variable NAME to VALUE
      --exists                                return 0 if the module(s) exist
      --print-variables                       output list of variables defined by the module
      --uninstalled                           return 0 if the uninstalled version of one or more module(s) or their dependencies will be used
      --atleast-version=VERSION               return 0 if the module is at least version VERSION
      --exact-version=VERSION                 return 0 if the module is at exactly version VERSION
      --max-version=VERSION                   return 0 if the module is at no newer than version VERSION
      --list-all                              list all known packages
      --debug                                 show verbose debug information
      --print-errors                          show verbose information about missing or conflicting packages (default unless --exists or --atleast/exact/max-version given on the command line)
      --silence-errors                        be silent about errors (default when --exists or --atleast/exact/max-version given on the command line)
      --errors-to-stdout                      print errors from --print-errors to stdout not stderr
      --print-provides                        print which packages the package provides
      --print-requires                        print which packages the package requires
      --print-requires-private                print which packages the package requires for static linking
      --validate                              validate a package's .pc file
      --define-prefix                         try to override the value of prefix for each .pc file found with a guesstimated value based on the location of the .pc file
      --dont-define-prefix                    don't try to override the value of prefix for each .pc file found with a guesstimated value based on the location of the .pc file
      --prefix-variable=PREFIX                set the name of the variable that pkg-config automatically sets
    
    pkg-config could not find fuse:
    you might need to adjust PKG_CONFIG_PATH or your
    FUSE installation is very old (older than 2.1-pre1)
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-SqGZP4/fuse-python/setup.py", line 60, in <module>
        iflags = [x[2:] for x in cflags.split() if x[0:2] == '-I']
    NameError: name 'cflags' is not defined
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Although the error states that my FUSE version is too old, the real problem seems to be a syntax error here:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-SqGZP4/fuse-python/setup.py", line 60, in <module>
        iflags = [x[2:] for x in cflags.split() if x[0:2] == '-I']
    NameError: name 'cflags' is not defined

Additionally, python-fuse works correctly on Python 3:

Python 3.8.5 (default, Jan 27 2021, 15:41:15) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fuse
>>> 

where to and how to specify big_writes option inside python file?

I've implemented GDriveFS and OnedriveFS, I've inherited fuse.Fuse in my defined class, and instance is created like this
if name == 'main':
authed_usr = GDrive()
gdrivefs = GoogleDriveFS(version = '%prog ' + '0.0.1',
usage = 'GoogleDrive Filesystem ' + fuse.Fuse.fusage,
dash_s_do = 'setsingle')
gdrivefs.parse(errex = 1)
gdrivefs.flags = 0
gdrivefs.main()

In this what should I add to make read/write speed faster, (big_writes,max_readahed,max_write,etc),
or
how to add these parameters with exact syntax?

Documentation/Example of server.parser.add_option

I'm trying to find anything to add new mount option.

Nothing useful found from README files, found something in examples/xml.py

    server.parser.add_option(mountopt="root", metavar="PATH", default='/',
                             help="mirror filesystem from under PATH [default: %default]")
    server.parse(values=server, errex=1)

    try:
        if server.fuse_args.mount_expected():
            os.chdir(server.root)
    except OSError:
        print("can't enter root of underlying filesystem", file=sys.stderr)
        sys.exit(1)

tried to replicate that to my program as

    server.parser.add_option(mountopt="cache_path", metavar="PATH", default="cache",
                             help="Cache downloads under PATH [default: %default]")
    server.parse(values=server, errex=1)
    server.main()

class MyFS(fuse.Fuse):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.cache_path = None

    def fsinit(self):
        print("fsinit, cache_path=", self.cache_path)

it appears in --help output as expected:

Options:
    --version              show program's version number and exit
    -h, --help             show this help message and exit
    -o opt,[opt...]        mount options
    -o cache_path=PATH     Cache downloads under PATH [default: cache]

yet cache_path remains None

from reading xml.py code, I understand the parse function adds it as property of object passed as values keyword argument, but in reality it does not seem to have effect.

Add more wheels to pypi

Seems this added some wheel:

where is that executed? could not find github actions workflow, so on developer machine manually?
are you interested of automating this on git tag push instead?

anyway, currently is uploaded:

fuse_python-1.0.7-cp312-cp312-manylinux_2_28_x86_64.whl (186.5 kB view hashes)

yet I'm interested in fuse_python-1.0.7-cp311-cp311-linux_aarch64.whl.

also: can just aarch64 wheel be added regardless of python version?

how to use python-fuse

usually ,libfuse monitor the modification of files in the mount-point dir, and then encrypt the original files。
I want to directly encrypt/decrypt the original files when I write/read the original files, what should i I do with fuse???

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.