Created
May 17, 2024 22:46
-
-
Save DownrightNifty/fbfdf50cac60c6d973ebef10438d7ee5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Patches statfs() syscall* to make programs think that NFS filesystems are actually ext4. | |
Temporary fix for KDE Dolphin bug #452924. | |
More info: https://bugs.kde.org/show_bug.cgi?id=452924#c28 | |
Compile with: | |
cc -fPIC -shared -ldl -o mask_statfs_nfs_as_ext4.so mask_statfs_nfs_as_ext4.c | |
Run Dolphin like so: | |
LD_PRELOAD=./mask_statfs_nfs_as_ext4.so dolphin | |
*technically just patches the libc wrapper for the syscall but most programs will use that instead | |
*/ | |
#include <sys/vfs.h> | |
#ifndef _GNU_SOURCE | |
#define _GNU_SOURCE | |
#endif | |
#include <dlfcn.h> | |
int statfs(const char *path, struct statfs *buf) { | |
// the original statfs | |
int (*o_statfs)(const char *, struct statfs *) = dlsym(RTLD_NEXT, "statfs"); | |
int rc = o_statfs(path, buf); | |
if (rc < 0) { return rc; } | |
// if the filesystem is NFS, pretend that it's actually ext4 | |
if (buf->f_type == 0x6969) { // NFS magic | |
buf->f_type = 0xef53; // ext4 magic | |
} | |
return rc; | |
} |
Author
DownrightNifty
commented
May 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment