X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fmake_ext4fs.git;a=blobdiff_plain;f=canned_fs_config.c;h=a034005a57545079e8dfbab11ace7606550bb9ae;hp=ae1d7bddf399437bfe7a0a3620303f6c515ada0d;hb=7c15bef6c732896d9ffb883fb1480fcd60c94a50;hpb=5ba1807f750e9544eb516904646b0f97051b833b diff --git a/canned_fs_config.c b/canned_fs_config.c index ae1d7bd..a034005 100644 --- a/canned_fs_config.c +++ b/canned_fs_config.c @@ -52,15 +52,19 @@ int load_canned_fs_config(const char* fn) { canned_data = (Path*) realloc(canned_data, canned_alloc * sizeof(Path)); } Path* p = canned_data + canned_used; - p->path = strdup(strtok(line, " ")); - p->uid = atoi(strtok(NULL, " ")); - p->gid = atoi(strtok(NULL, " ")); - p->mode = strtol(strtok(NULL, " "), NULL, 8); // mode is in octal + p->path = strdup(strtok(line, " \t")); + + if (!p->path || !*p->path || *p->path == '#') + continue; + + p->uid = atoi(strtok(NULL, " \t")); + p->gid = atoi(strtok(NULL, " \t")); + p->mode = strtol(strtok(NULL, " \t"), NULL, 8); // mode is in octal p->capabilities = 0; char* token = NULL; do { - token = strtok(NULL, " "); + token = strtok(NULL, " \t"); if (token && strncmp(token, "capabilities=", 13) == 0) { p->capabilities = strtoll(token+13, NULL, 0); break; @@ -78,14 +82,13 @@ int load_canned_fs_config(const char* fn) { return 0; } -void canned_fs_config(const char* path, int dir, +int canned_fs_config(const char* path, int dir, unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities) { Path key; - key.path = path+1; // canned paths lack the leading '/' + key.path = path; Path* p = (Path*) bsearch(&key, canned_data, canned_used, sizeof(Path), path_compare); if (p == NULL) { - fprintf(stderr, "failed to find [%s] in canned fs_config\n", path); - exit(1); + return 0; } *uid = p->uid; *gid = p->gid; @@ -104,4 +107,6 @@ void canned_fs_config(const char* path, int dir, if (c_mode != *mode) printf("%s mode 0%o 0%o\n", path, *mode, c_mode); if (c_capabilities != *capabilities) printf("%s capabilities %llx %llx\n", path, *capabilities, c_capabilities); #endif + + return 1; }