module

Fuse::Bridge

Bridges the raw C callbacks from the libfuse shim to the active FileSystem instance. Each _op method translates C pointers/ints into Crystal types, dispatches to the instance, and marshals the result back for libfuse.

Constants

UTIME_NOW = (1_i64 << 30) - 1

FUSE encodes these in a timespec's tv_nsec to mean "set to now" and "leave unchanged" respectively (see utimensat(2)).

UTIME_OMIT = (1_i64 << 30) - 2

Class methods

_access(path_ptr, mask) : Int32
Source
_bmap(path_ptr, blocksize, idx) : Int32
Source
_chmod(path_ptr, mode, fi) : Int32
Source
_chown(path_ptr, uid, gid, fi) : Int32
Source
_copy_file_range(in_ptr, fi_in, off_in, out_ptr, fi_out, off_out, size, flags) : Int64
Source
_create(path_ptr, mode, fi) : Int32
Source
_destroy
Source
_fallocate(path_ptr, mode, offset, length, fi) : Int32
Source
_flock(path_ptr, fi, op) : Int32
Source
_flush(path_ptr, fi) : Int32
Source
_fsync(path_ptr, datasync, fi) : Int32
Source
_fsyncdir(path_ptr, datasync, fi) : Int32
Source
_getattr(path_ptr, stat_ptr, fi) : Int32
Source
_getxattr(path_ptr, name_ptr, value_ptr, size) : Int32

getxattr/listxattr use a two-call protocol: when size is 0 the caller is asking for the required buffer size; otherwise fill the buffer (or -ERANGE if it's too small). The binding handles that here so the fs just returns the value/names.

Source
_init
Source
_ioctl(path_ptr, cmd, arg, fi, flags, data) : Int32
Source
_listxattr(path_ptr, list_ptr, size) : Int32
Source
_lock(path_ptr, fi, cmd, lock_ptr) : Int32
Source
_lseek(path_ptr, offset, whence, fi) : Int64
Source
_mkdir(path_ptr, mode) : Int32
Source
_mknod(path_ptr, mode, rdev) : Int32
Source
_open(path_ptr, fi) : Int32
Source
_opendir(path_ptr, fi) : Int32
Source
_poll(path_ptr, fi, ph, reventsp) : Int32
Source
_read(path_ptr, buf, size, offset, fi) : Int32
Source
_readdir(path_ptr, buf, filler, offset, fi, flags) : Int32
Source
_release(path_ptr, fi) : Int32
Source
_releasedir(path_ptr, fi) : Int32
Source
_removexattr(path_ptr, name_ptr) : Int32
Source
_rename(from_ptr, to_ptr, flags) : Int32
Source
_rmdir(path_ptr) : Int32
Source
_setxattr(path_ptr, name_ptr, value_ptr, size, flags) : Int32
Source
_statfs(path_ptr, st_ptr) : Int32
Source
_truncate(path_ptr, size, fi) : Int32
Source
_utimens(path_ptr, tv_ptr, fi) : Int32
Source
_write(path_ptr, buf, size, offset, fi) : Int32
Source
guard

Run a bridge operation, turning any uncaught exception into -EIO. Without this, an exception raised in a user's filesystem method would unwind into C and abort the whole process (or wedge the mount). yield is inlined, so the enclosing proc stays a plain C function pointer.

Source
guard64

Like guard, for operations that return an off_t/ssize_t (Int64).

Source
instance
Source
register_callbacks

Wire every C operation to the corresponding bridge method, each wrapped in guard. The procs are closure-free (they reference only module methods), so they convert to plain C function pointers.

Source
report(ex : Exception) : Nil

Log an exception that escaped a user's filesystem method. Writes straight to fd 2 rather than via STDERR — Crystal's buffered IO can reach into the fiber scheduler, which isn't safe on a libfuse worker thread.

Source
set_instance(fs : Fuse::FileSystem)
Source
timespec_to_time(ts : LibC::Timespec) : Time | Nil

Decode a struct timespec, honoring FUSE's UTIME_NOW / UTIME_OMIT sentinels (encoded in tv_nsec). Returns nil for "leave unchanged".

Source