easyfuse.filesystem

This module implements the classes that map to filesystem objects.

class BaseEntry(name, fs, parent, *, inode=None)[source]

Bases: llfuse.EntryAttributes

The base class that all filesystem classes should subclass.

This is a subclass llfuse.EntryAttributes and its attributes that are required to have a working filesystem are implemented. Most others are not actually implemented currently.

Parameters:
  • name (str) – The name of the entry.
  • fs (dict or dictlike) – This stores the mapping from an inode number to a File or Directory object. The newly created BaseEntry will be added to this as well. It should most likely be the fs attribute of the instance that creates this entry.
  • parent (Directory) – The filesystem parent of this
  • inode (int) – An explicit inode number. If it is None a new number will automatically be generated. Only in rare cases this automatic generation is not sufficient, so use this only when really necassary.
lookup_count = 0[source]

The amount of times this entry has been looked up by the kernel. This is increased by a couple of methodes called on Operations by normal filesystem operations.

deleted = False[source]

Indicates if the entry has been deleted.

inode[source]

The inode number.

This is simply an alias for st_ino with a clearer name.

modified[source]

The moment of last modification of the entry.

This is measured in seconds since the UNIX epoch.

dirty[source]

Indicates if this entry has been changed but not synced.

path[source]

The full path of this entry from the mount directory.

parents[source]

Recursively get the parents of this entry.

depth[source]

The depth of the entry in the directory tree.

This basically counts the number of parents this entry has.

generate_inode_number()[source]

Generate a unique inode number.

By default this is done by taking part of the result of uuid4. This method can be overridden if another method is preferred.

update_modified()[source]

Update the modified time to the current time.

delete()[source]

Basic deletion operations.

Override this when code needs to be executed on deletion. Keep calling this one by using super though, since it does some internal things.

save()[source]

Dummy save method.

Override this when code needs to be executed when a file is saved.

fsync()[source]

Save the entry if it is dirty.

class File(*args, **kwargs)[source]

Bases: easyfuse.filesystem.BaseEntry

A class that represents a filesystem file.

If a file is supposed to be synced, set the content attribute to None after initialization.

Parameters:
  • *args – Positional arguments that are passed to the initialization of BaseEntry.
  • **kwargs – Keyword arguments that are passed to the initialization of BaseEntry.
content[source]

The content of this file in bytes.

class Directory(*args, **kwargs)[source]

Bases: easyfuse.filesystem.BaseEntry

A class that represents a directory in the filesystem.

Parameters:
  • *args – Positional arguments that are passed to the initialization of BaseEntry.
  • **kwargs – Keyword arguments that are passed to the initialization of BaseEntry.
children[source]

A dict of the children of the directory.

path[source]

The full path of this directory from the mount directory.

dirty_children[source]

Indicates if the children need to be synced.

It is set to True if a child of this directory is dirty or has dirty_children itself.

refresh_children()[source]

Initialize children as an empty dict.

This method should be overloaded by every implementing class, since the actual children should obviously be added as well. This method should still be called using super though.

fsync()[source]

Save this entry and fsync its children.

Saving is only done if this entry is dirty and syncing the children is only done if dirty_children is True.