Modetc: Move your dotfiles from kernel space
3 months ago
- #dotfiles
- #Linux
- #kernel-module
- modetc is a Linux kernel module that rewrites paths in file operations, allowing users to move files while keeping programs unaware of the changes.
- Main use case: moving dotfiles from the home directory to comply with XDG basedir standards, e.g., moving ~/.ssh to ~/var/lib/ssh.
- Configuration is done via module parameters: homedir, default_rule, rules_file, and debug.
- Rules are simple text search and replace operations, applied in order, with a maximum of 16 rules supported.
- Runtime commands can be sent to modetc via /proc/modetc, such as pausing rewriting or reloading rules.
- Building instructions include using Nix or a basic toolchain with make.
- Installation varies by distribution, with specific instructions for NixOS and others.
- Works by inserting kprobes in VFS layer functions to modify file paths in kernel space.
- Advantages over alternatives (libetc, rewritefs): works with statically linked programs, minimal overhead, and quick toggling.
- Licensed under GNU GPL v3 or later.