Fix fs configuration support
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
parent
5ba1807f75
commit
8597212da1
@ -78,14 +78,13 @@ int load_canned_fs_config(const char* fn) {
|
|||||||
return 0;
|
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) {
|
unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities) {
|
||||||
Path key;
|
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);
|
Path* p = (Path*) bsearch(&key, canned_data, canned_used, sizeof(Path), path_compare);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
fprintf(stderr, "failed to find [%s] in canned fs_config\n", path);
|
return 0;
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
*uid = p->uid;
|
*uid = p->uid;
|
||||||
*gid = p->gid;
|
*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_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);
|
if (c_capabilities != *capabilities) printf("%s capabilities %llx %llx\n", path, *capabilities, c_capabilities);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
int load_canned_fs_config(const char* fn);
|
int load_canned_fs_config(const char* fn);
|
||||||
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);
|
unsigned* uid, unsigned* gid, unsigned* mode, uint64_t* capabilities);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -150,7 +150,7 @@ u64 parse_num(const char *arg);
|
|||||||
void ext4_parse_sb_info(struct ext4_super_block *sb);
|
void ext4_parse_sb_info(struct ext4_super_block *sb);
|
||||||
u16 ext4_crc16(u16 crc_in, const void *buf, int size);
|
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);
|
unsigned *mode, uint64_t *capabilities);
|
||||||
|
|
||||||
struct selabel_handle;
|
struct selabel_handle;
|
||||||
|
@ -151,11 +151,12 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
|
|||||||
unsigned int uid = 0;
|
unsigned int uid = 0;
|
||||||
unsigned int gid = 0;
|
unsigned int gid = 0;
|
||||||
int dir = S_ISDIR(stat.st_mode);
|
int dir = S_ISDIR(stat.st_mode);
|
||||||
fs_config_func(dentries[i].path, dir, &uid, &gid, &mode, &capabilities);
|
if (fs_config_func(dentries[i].path, dir, &uid, &gid, &mode, &capabilities)) {
|
||||||
dentries[i].mode = mode;
|
dentries[i].mode = mode;
|
||||||
dentries[i].uid = uid;
|
dentries[i].uid = uid;
|
||||||
dentries[i].gid = gid;
|
dentries[i].gid = gid;
|
||||||
dentries[i].capabilities = capabilities;
|
dentries[i].capabilities = capabilities;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (S_ISREG(stat.st_mode)) {
|
if (S_ISREG(stat.st_mode)) {
|
||||||
|
Reference in New Issue
Block a user