Fix fs configuration support

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
Jo-Philipp Wich 2015-04-04 23:37:00 +02:00
parent 5ba1807f75
commit 8597212da1
4 changed files with 14 additions and 12 deletions

View 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;
}

View 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

View 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;

View 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)) {