Skip to content

Instantly share code, notes, and snippets.

@zzeroo
Forked from dimaryaz/dropbox_ext4.c
Created February 5, 2019 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zzeroo/bcc8b4e72a567232f03a6d36086a9b4a to your computer and use it in GitHub Desktop.
Save zzeroo/bcc8b4e72a567232f03a6d36086a9b4a 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