Skip to content

Instantly share code, notes, and snippets.

@jeffniblack
Created September 18, 2012 15:59
Show Gist options
  • Save jeffniblack/3743906 to your computer and use it in GitHub Desktop.
Save jeffniblack/3743906 to your computer and use it in GitHub Desktop.
fstab check for jailbroken iOS devices
#include <sys/stat.h>
static inline int
fstab_check(void)
__attribute__((always_inline));
int fstab_check(void) {
struct stat sb;
int result = 1;
#if TARGET_IPHONE_SIMULATOR
NSLog(@"fstab_check -> Running on the simulator!");
result = 0;
#else
stat("/etc/fstab", &sb);
long long size = sb.st_size;
if ([[[UIDevice currentDevice] systemVersion] compare:@"6.0" options:NSNumericSearch] == NSOrderedSame) {
if (size == 80) {
result = 0;
}
} else {
}
if ([[[UIDevice currentDevice] systemVersion] compare:@"5.0" options:NSNumericSearch] == NSOrderedSame) {
if (size == 80) {
result = 0;
}
}
if ([[[UIDevice currentDevice] systemVersion] compare:@"5.1" options:NSNumericSearch] == NSOrderedSame) {
if (size == 80) {
result = 0;
}
}
if ([[[UIDevice currentDevice] systemVersion] compare:@"5.1.1" options:NSNumericSearch] == NSOrderedSame) {
if (size == 80) {
result = 0;
}
}
#endif
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment