Skip to content

Instantly share code, notes, and snippets.

@dossy
Created November 27, 2015 18:43
Show Gist options
  • Save dossy/334365239ec83b67b746 to your computer and use it in GitHub Desktop.
Save dossy/334365239ec83b67b746 to your computer and use it in GitHub Desktop.
Running CrashPlan on older Linux
/*
* $ gcc -Wall -shared -fPIC -o patch_inotify_init1.so patch_inotify_init1.c
*
* LD_PRELOAD=patch_inotify_init1.so java ...
*
* [11.27.15 12:43:37.040 ERROR main .service.backup.BackupController] Exception setting up BackupController! , java.lang.UnsatisfiedLinkError: Error looking up function 'inotify_init1': /usr/local/crashplan/jre/bin/java: undefined symbol: inotify_init1
* STACKTRACE:: java.lang.UnsatisfiedLinkError: Error looking up function 'inotify_init1': /usr/local/crashplan/jre/bin/java: undefined symbol: inotify_init1
* at com.sun.jna.Function.<init>(Function.java:208)
* at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:536)
* at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:513)
* at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:499)
* at com.sun.jna.Library$Handler.invoke(Library.java:199)
* at com.sun.proxy.$Proxy35.inotify_init1(Unknown Source)
* at com.code42.jna.LinuxPlatform.inotifyInit1(LinuxPlatform.java:292)
* at com.code42.jna.inotify.InotifyManager.start(InotifyManager.java:207)
* at com.code42.jna.inotify.JNAInotifyFileWatcherDriver.<init>(JNAInotifyFileWatcherDriver.java:61)
* at com.code42.backup.path.BackupSetsManager.initFileWatcherDriver(BackupSetsManager.java:417)
* at com.code42.backup.path.BackupSetsManager.setUp(BackupSetsManager.java:153)
* at com.code42.backup.BackupManager.setUp(BackupManager.java:141)
* at com.backup42.service.backup.BackupController.setUp(BackupController.java:467)
* at com.backup42.service.CPService.start(CPService.java:665)
* at com.backup42.service.CPService.main(CPService.java:2239)
*
* [11.27.15 12:43:37.040 INFO main .service.backup.BackupController] BackupController.setup(): EXIT
*
* If you get "Unable to add watch for path ..., errno: , 28" in service.log.0, then:
*
* $ echo 1048576 > /proc/sys/fs/inotify/max_user_watches
* sysctl.conf: fs.inotify.max_user_watches=1048576
*
* bin/CrashPlanEngine:
*
* nice -n 19 env LD_PRELOAD=$TARGETDIR/patch_inotify_init1.so $JAVACOMMON $SRV_JAVA_OPTS -classpath $FULL_CP com.backup42.service.CPService > $TARGETDIR/log/engine_output.log 2> $TARGETDIR/log/engine_error.log &
*/
#include <stdio.h>
#include <sys/inotify.h>
int inotify_init1(int flags)
{
if (flags != 0) {
fprintf(stderr, "inotify_init1(%d) -- BEWARE! Ignoring flags.\n", flags);
}
return inotify_init();
}
@dynek
Copy link

dynek commented Dec 30, 2015

Very very smart solution! I went the hard way, cross building a version of glibc that includes inotify_init1 for QNAP devices :-)

@mr-salty
Copy link

mr-salty commented Mar 4, 2016

thanks - this is awesome! (I'm also using QNAP so I have to thank @dynek as well!)

@chriskalmar
Copy link

awesome!
finally a working solution.
thank u so much

@mmelvin-ch
Copy link

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment