Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passthrough example for ext fs #96

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions examples/passthroughfs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
'''
ext filesystem compatibility checked by https://github.com/zfsonlinux/fstest.git
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is rather a remark or property of this implementation, but nothing the description of this should start with, so move it a bit lower, please.

passthroughfs.py - Example file system for pyfuse3

This file system mirrors the contents of a specified directory tree.
Expand Down Expand Up @@ -312,6 +313,14 @@ async def setattr(self, inode, attr, fields, fh, ctx):
if fields.update_gid:
chown(path_or_fh, -1, attr.st_gid, follow_symlinks=False)

if fields.update_mode is False and \
fields.update_uid is False and \
fields.update_gid is False:
if chown == os.chown:
chown(path_or_fh, -1, -1, follow_symlinks=False)
if chown == os.fchown:
chown(path_or_fh, -1, -1)
Comment on lines +316 to +322
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this is rather strange:

  • why is chown called at all if neither uid nor gid shall be set (both are -1)?
  • is the x is False really wanted / correct instead of the usual boolean evaluation using not x? consider x == 0 or x == None, for example.
  • in 311/314 chown is always called with follow_symlinks=False, no matter whether path or fh is used, so 320/322 look inconsistent with these.


if fields.update_atime and fields.update_mtime:
if fh is None:
os.utime(path_or_fh, None, follow_symlinks=False,
Expand Down Expand Up @@ -393,6 +402,8 @@ async def create(self, inode_p, name, mode, flags, ctx):
path = os.path.join(self._inode_to_path(inode_p), fsdecode(name))
try:
fd = os.open(path, flags | os.O_CREAT | os.O_TRUNC)
os.fchmod(fd, mode)
os.fchown(fd, ctx.uid, ctx.gid)
except OSError as exc:
raise FUSEError(exc.errno)
attr = self._getattr(fd=fd)
Expand Down Expand Up @@ -463,6 +474,9 @@ def main():
log.debug('Mounting...')
fuse_options = set(pyfuse3.default_options)
fuse_options.add('fsname=passthroughfs')
fuse_options.add('allow_other')
fuse_options.add('suid')
fuse_options.add('dev')
if options.debug_fuse:
fuse_options.add('debug')
pyfuse3.init(operations, options.mountpoint, fuse_options)
Expand All @@ -479,3 +493,4 @@ def main():

if __name__ == '__main__':
main()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accidental change?

Loading