ポイントマウントのマウントヒューズにPythonコードを書きました。常に無効な引数エラーが発生します。Cで同じプログラムを試してみましたが、うまくいきました。問題が何であるかを見つけるのに役立つpython Guruのいずれかを使用できますか。ここにコードを貼り付けました。
#!/usr/bin/python
import stat
import os
import ctypes
from ctypes.util import find_library
libc = ctypes.CDLL (find_library ("c"))
def fuse_mount_sys (mountpoint, fsname):
fd = file.fileno (file ("/dev/fuse", 'w+'))
if fd < 0:
raise OSError("Could not open /dev/fuse")
mnt_param = "%s,fd=%i,rootmode=%o,user_id=%i,group_id=%i" \
% ("allow_other,default_permissions,max_read=131072", \
fd, stat.S_IFDIR, os.getuid(), os.getgid())
ret = libc.mount ("fuse", "/mount", "fuse", 0, mnt_param)
if ret < 0:
raise OSError("mount failed with code " + str(ret))
return fd
fds = fuse_mount_sys ("/mount", "fuse")
マウント構文は次のとおりです。
int mount(const char *source, const char *target,
const char *filesystemtype, unsigned long mountflags,
const void *data);
私は swig を使用してみましたが、C でプログラムを作成し、それから .so を作成したところ、うまくいきました。しかし、私は純粋な python で書くことに興味があります。前もって感謝します。
strace の出力:
$ strace -s 100 -v -e mount python fuse-mount.py
mount("fuse", "/mount", "fuse", 0, "allow_other,default_permissions,max_read=131072,fd=3,rootmode=40000,user_id=0,group_id=0") = -1 EINVAL (Invalid argument)
$ strace -s 100 -v -e mount ./a.out
mount("fuse", "/mount", "fuse", 0, "allow_other,default_permissions,max_read=131072,fd=3,rootmode=40000,user_id=0,group_id=0") = 0