Skip to content

Instantly share code, notes, and snippets.

@sanmai
Forked from dimaryaz/dropbox_ext4.c
Created August 15, 2018 07:34
Show Gist options
  • Save sanmai/ae1f3c156c3dadd3b3ceec113a370a98 to your computer and use it in GitHub Desktop.
Save sanmai/ae1f3c156c3dadd3b3ceec113a370a98 to your computer and use it in GitHub Desktop.
Dropbox ext4 hack
/*
* dropbox_ext4.c
*
* Compile like this:
* gcc -shared -fPIC -ldl -o libdropbox_ext4.so dropbox_ext4.c
*
* Run Dropbox like this:
* LD_PRELOAD=./libdropbox_ext4.so ~/.dropbox-dist/dropboxd
*/
#define _GNU_SOURCE
#include <stdlib.h>
#include <sys/vfs.h>
#include <linux/magic.h>
#include <dlfcn.h>
int (*orig_statfs)(const char *path, struct statfs64 *buf) = NULL;
int statfs64(const char *path, struct statfs64 *buf) {
if (orig_statfs == NULL) {
orig_statfs = dlsym(RTLD_NEXT, "statfs64");
}
int retval = orig_statfs(path, buf);
if (retval == 0) {
buf->f_type = EXT4_SUPER_MAGIC;
}
return retval;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment