This repository has been archived by the owner on Dec 26, 2022. It is now read-only.
forked from dimaryaz/dropbox_ext4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
154 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.o | ||
*.so |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
INSTALL_DIR=/usr/local | ||
|
||
libdropbox_ext4.so: dropbox_ext4.o | ||
$(LD) -shared -ldl -o $@ $^ && strip $@ | ||
|
||
%.o: %.c | ||
$(CC) -fPIC -D_GNU_SOURCE -Wall -Os -o $@ -c $< | ||
|
||
clean: | ||
rm -f *.o *.so | ||
|
||
install: libdropbox_ext4.so | ||
install $^ $(INSTALL_DIR)/lib/ && \ | ||
echo -e "#!/bin/bash\n\nLD_PRELOAD=$(INSTALL_DIR)/lib/$^ exec /usr/bin/dropbox \"\$$@\"" > $(INSTALL_DIR)/bin/dropbox | ||
|
||
uninstall: | ||
rm -f $(INSTALL_DIR)/bin/dropbox && \ | ||
rm -f $(INSTALL_DIR)/lib/libdropbox_ext4.so |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
# dropbox_ext4 | ||
Hack to make Dropbox work on non-ext4 filesystems | ||
# Dropbox ext4 Hack | ||
|
||
Gets around Dropbox dropping support for non-ext4 filesystems by wrapping the `statfs64` function and overwriting the filesystem type. | ||
|
||
## Install the pre-built hack | ||
|
||
Just run: | ||
|
||
sudo ./fix_dropbox.py | ||
dropbox stop | ||
dropbox start | ||
|
||
It will install the hack into `/usr/local/`. You can modify `fix_dropbox.py` to customize that. | ||
|
||
## Install from source | ||
|
||
Make sure you have GCC installed and run the following: | ||
|
||
make | ||
sudo make install |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Wraps statfs64 and changes the filesystem type to EXT4. | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <dlfcn.h> | ||
#include <sys/vfs.h> | ||
#include <linux/magic.h> | ||
|
||
int statfs64(const char *path, struct statfs64 *buf) { | ||
static int (*_orig_statfs64)(const char *path, struct statfs64 *buf) = NULL; | ||
|
||
if (_orig_statfs64 == NULL) { | ||
_orig_statfs64 = dlsym(RTLD_NEXT, "statfs64"); | ||
} | ||
|
||
int retval = _orig_statfs64(path, buf); | ||
if (retval == 0) { | ||
buf->f_type = EXT4_SUPER_MAGIC; | ||
} | ||
return retval; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" | ||
Encodes the shared library so it can be stored inline in `fix_installer.py`. | ||
""" | ||
|
||
import base64 | ||
import gzip | ||
import textwrap | ||
|
||
|
||
INPUT_FILE = 'libdropbox_ext4.so' | ||
|
||
|
||
def main(): | ||
with open(INPUT_FILE, 'rb') as fd: | ||
contents = fd.read() | ||
|
||
encoded_contents = base64.b85encode(gzip.compress(contents)).decode() | ||
|
||
print("ENCODED_LIB_CONTENTS = (") | ||
for line in textwrap.wrap(encoded_contents, 128): | ||
print(" '%s'" % line) | ||
print(")") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import base64 | ||
import gzip | ||
import os | ||
import subprocess | ||
|
||
# Install a wrapper script as /usr/local/bin/dropbox. | ||
# It *should* be in $PATH before /usr/bin/dropbox, and therefore take precedence. | ||
INSTALL_PATH = '/usr/local/' | ||
|
||
# Replace with ~/.local/ if you like - but make sure it's in the $PATH before /usr/bin/! | ||
# INSTALL_PATH = os.path.expanduser('~/.local/') | ||
|
||
# Base85-encoded gzipped libdropbox_ext4.so, generated by `encode_lib.py`, | ||
ENCODED_LIB_CONTENTS = ( | ||
'ABzY8O?7))0{`t;-D}fO6u(K<wR2q-#j&~xMwzh98QRXyq0D`6QRc@s21AjMu9+$HV>apBe3>v5`ylL3@UQTB;Db-1e}VWS=#zra8gJ5bYIC<*Me!*=$UXOb-Fxo2hrq' | ||
'czvkP-P#}R};t`L{o=d1h#$lppe6Dk`eAv#K=)3Xhc#@G`4ln~h)UB6a$T@lt7Wgoo-A+2(LKfZ}y9PE)sz<cq7ooOY%4?OM?^=tWq{kU2lt8unKet2g6db?jCO21?D6' | ||
'nG!AAV1^9*g<4T_StuN_6O1H*+&o9E3i&KBPY3RI+IhZqLL(*t=sF?$OV$gS=)J{85!NyiKeA3OQX7yO+|$anP0d%HLWF;q>`$hkfW#O;G`VPFt6pFY@3^vVc=u1f0)U' | ||
'MlS+5U#5tRxW9O*}I&*o`RegHzIL?Y%`L?W9zAmb}V>hXWl)KeusdH4V?!Iw8zNRK>B{V`cYUQ0;`RsHJ()r{4a#(#OEPp2C_MN*gYX>CcINs00CBkh<TyHcS*`tB?QQ' | ||
'1lQZO{e1NJVK*j9u$&e-L>@#(ORg4)?iN;@Qp6&!l$VT}_J86MjaF?FuuZye-BkKPg5?fB*pk1PBlyK!5-N{vI4dTZq4p#9lQ9{S@|uPeFeK_;H}^XwUX*($9XhUXT4l' | ||
'7-%=H4~E|zr|41>cn5fl_Y3f={Qt=p_OUEp!2a{o)0gD_`5P+(@~Dzf5^^%07>!>{B<21kBO|N2U6r3t4bW!NGA+Ag>uI8xx@8h2vt4jIMvvMhqTDN#l})2$Ws3zLqfu' | ||
'SS$mz;P&L)a&Y|*h)^x90tFtzoPo;SQz^n7-WdKT@fCG9|ovR2IJje`Ae^3l%p>#NK=#1P0)A7Se3D6GLVb%k`Vu8z1mf2^MqpyQc3MLOP~-VvvvrfTu?ei~)sXQ=`;i' | ||
'agdSQn^9=h%v~;6jS#|V|DvQ4>|u--P@3h=e(cF4c=*x&NKe_Zo<BwG|Jy~kR^c+34Yqv<bSgQbIhM4_^HYGv-#5?c7d?(P5yT#f$_)lo3KCopF#t<!Tw0^!yNtby-1c' | ||
'0kC){)VgEQINB^NF`QsYAi7kNtPLuol0dn-cOwben00' | ||
) | ||
|
||
LIBRARY_PATH = os.path.join(INSTALL_PATH, 'lib', 'libdropbox_ext4.so') | ||
SCRIPT_PATH = os.path.join(INSTALL_PATH, 'bin', 'dropbox') | ||
|
||
DROPBOX_WRAPPER_CONTENTS = ''' | ||
#!/bin/bash | ||
LD_PRELOAD=%s exec /usr/bin/dropbox "$@" | ||
'''.lstrip() % LIBRARY_PATH | ||
|
||
|
||
def main(): | ||
# Install the library. | ||
os.makedirs(os.path.join(INSTALL_PATH, 'bin'), exist_ok=True) | ||
|
||
with open(LIBRARY_PATH, 'wb') as fd: | ||
fd.write(gzip.decompress(base64.b85decode(ENCODED_LIB_CONTENTS))) | ||
os.fchmod(fd.fileno(), 0o755) | ||
|
||
# Install the wrapper script. | ||
os.makedirs(os.path.join(INSTALL_PATH, 'lib'), exist_ok=True) | ||
|
||
with open(SCRIPT_PATH, 'w') as fd: | ||
fd.write(DROPBOX_WRAPPER_CONTENTS) | ||
os.fchmod(fd.fileno(), 0o755) | ||
|
||
print("Installed the library and the wrapper script at:\n %s\n %s" % (LIBRARY_PATH, SCRIPT_PATH)) | ||
print("(To uninstall, simply delete them.)") | ||
|
||
# Check that the correct 'dropbox' is in the $PATH. | ||
result = subprocess.check_output(['which', 'dropbox']).decode().rstrip() | ||
if result != SCRIPT_PATH: | ||
print() | ||
print("You will need to fix your $PATH! Currently, %r takes precedence." % result) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |