static int statvfs_works (void) { #if ! (__linux__ && (__GLIBC__ || __UCLIBC__)) return 1; #else static int statvfs_works_cache = -1; struct utsname name; if (statvfs_works_cache < 0) statvfs_works_cache = (uname (&name) == 0 && 0 <= str_verscmp (name.release, "2.6.36")); return statvfs_works_cache; #endif }
int sort_vers (file_entry_t * a, file_entry_t * b) { int ad = MY_ISDIR (a); int bd = MY_ISDIR (b); if (ad == bd || panels_options.mix_all_files) { return str_verscmp (a->fname, b->fname) * reverse; } else { return bd - ad; } }
static int condition_test_kernel_version(Condition *c) { enum { /* Listed in order of checking. Note that some comparators are prefixes of others, hence the longest * should be listed first. */ LOWER_OR_EQUAL, GREATER_OR_EQUAL, LOWER, GREATER, EQUAL, _ORDER_MAX, }; static const char *const prefix[_ORDER_MAX] = { [LOWER_OR_EQUAL] = "<=", [GREATER_OR_EQUAL] = ">=", [LOWER] = "<", [GREATER] = ">", [EQUAL] = "=", }; const char *p = NULL; struct utsname u; size_t i; int k; assert(c); assert(c->parameter); assert(c->type == CONDITION_KERNEL_VERSION); assert_se(uname(&u) >= 0); for (i = 0; i < _ORDER_MAX; i++) { p = startswith(c->parameter, prefix[i]); if (p) break; } /* No prefix? Then treat as glob string */ if (!p) return fnmatch(skip_leading_chars(c->parameter, NULL), u.release, 0) == 0; k = str_verscmp(u.release, skip_leading_chars(p, NULL)); switch (i) { case LOWER: return k < 0; case LOWER_OR_EQUAL: return k <= 0; case EQUAL: return k == 0; case GREATER_OR_EQUAL: return k >= 0; case GREATER: return k > 0; default: assert_not_reached("Can't compare"); } }