Fix fs configuration support
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 4 Apr 2015 21:37:00 +0000 (23:37 +0200)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 8 Apr 2015 05:51:39 +0000 (07:51 +0200)
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
canned_fs_config.c
canned_fs_config.h
ext4_utils.h
make_ext4fs.c

index ae1d7bddf399437bfe7a0a3620303f6c515ada0d..6bd1b226cbe47199ae985ca6c435da09a465931a 100644 (file)
@@ -78,14 +78,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 +103,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;
 }
index aec923bd4182b52bba1f5678af36c2307faad5a0..bf20aa2bdea2927fcc7c9b5b2b39db89132ef942 100644 (file)
@@ -20,7 +20,7 @@
 #include <inttypes.h>
 
 int load_canned_fs_config(const char* fn);
-void canned_fs_config(const char* path, int dir,
-                      unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities);
+int canned_fs_config(const char* path, int dir,
+                     unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities);
 
 #endif
index b6915bdb92b9ff5d939fd2e9014eacb8dc7ff2b8..97eebc48f68063cff3c6a68e4157f32691228bdf 100644 (file)
@@ -150,7 +150,7 @@ u64 parse_num(const char *arg);
 void ext4_parse_sb_info(struct ext4_super_block *sb);
 u16 ext4_crc16(u16 crc_in, const void *buf, int size);
 
-typedef void (*fs_config_func_t)(const char *path, int dir, unsigned *uid, unsigned *gid,
+typedef int (*fs_config_func_t)(const char *path, int dir, unsigned *uid, unsigned *gid,
                unsigned *mode, uint64_t *capabilities);
 
 struct selabel_handle;
index b9f653c8ed97b7c0b2dc93463d45b280c1ca0a7f..bc6323647e60d5543ee10f17a2ef124a38cd1631 100644 (file)
@@ -151,11 +151,12 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
                        unsigned int uid = 0;
                        unsigned int gid = 0;
                        int dir = S_ISDIR(stat.st_mode);
-                       fs_config_func(dentries[i].path, dir, &uid, &gid, &mode, &capabilities);
-                       dentries[i].mode = mode;
-                       dentries[i].uid = uid;
-                       dentries[i].gid = gid;
-                       dentries[i].capabilities = capabilities;
+                       if (fs_config_func(dentries[i].path, dir, &uid, &gid, &mode, &capabilities)) {
+                               dentries[i].mode = mode;
+                               dentries[i].uid = uid;
+                               dentries[i].gid = gid;
+                               dentries[i].capabilities = capabilities;
+                       }
                }
 
                if (S_ISREG(stat.st_mode)) {