aboutsummaryrefslogtreecommitdiffstats
path: root/tools/fs_config
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2018-02-27 16:24:21 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-02-27 16:24:21 +0000
commit3d4fb4e33568b76bcec593d89f5ba100b96a2c17 (patch)
treeee5a056fb6c3ea9096d0154be8440924b6c293a6 /tools/fs_config
parent063e6b29391b2395b4581e042ddfe4ebd4a09a2e (diff)
parent440da2d41a3eabae82acf13a9e0763ecd33d1e83 (diff)
downloadplatform_build-3d4fb4e33568b76bcec593d89f5ba100b96a2c17.tar.gz
platform_build-3d4fb4e33568b76bcec593d89f5ba100b96a2c17.tar.bz2
platform_build-3d4fb4e33568b76bcec593d89f5ba100b96a2c17.zip
Merge "Make mksquashfs generate a fs_config-friendly root entry"
Diffstat (limited to 'tools/fs_config')
-rw-r--r--tools/fs_config/fs_config.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/tools/fs_config/fs_config.c b/tools/fs_config/fs_config.c
index 48f300bd8d..2952875f64 100644
--- a/tools/fs_config/fs_config.c
+++ b/tools/fs_config/fs_config.c
@@ -67,17 +67,18 @@ static struct selabel_handle* get_sehnd(const char* context_file) {
}
static void usage() {
- fprintf(stderr, "Usage: fs_config [-D product_out_path] [-S context_file] [-C]\n");
+ fprintf(stderr, "Usage: fs_config [-D product_out_path] [-S context_file] [-R root] [-C]\n");
}
int main(int argc, char** argv) {
char buffer[1024];
const char* context_file = NULL;
const char* product_out_path = NULL;
+ char* root_path = NULL;
struct selabel_handle* sehnd = NULL;
int print_capabilities = 0;
int opt;
- while((opt = getopt(argc, argv, "CS:D:")) != -1) {
+ while((opt = getopt(argc, argv, "CS:R:D:")) != -1) {
switch(opt) {
case 'C':
print_capabilities = 1;
@@ -85,6 +86,9 @@ int main(int argc, char** argv) {
case 'S':
context_file = optarg;
break;
+ case 'R':
+ root_path = optarg;
+ break;
case 'D':
product_out_path = optarg;
break;
@@ -98,6 +102,14 @@ int main(int argc, char** argv) {
sehnd = get_sehnd(context_file);
}
+ if (root_path != NULL) {
+ size_t root_len = strlen(root_path);
+ /* Trim any trailing slashes from the root path. */
+ while (root_len && root_path[--root_len] == '/') {
+ root_path[root_len] = '\0';
+ }
+ }
+
while (fgets(buffer, 1023, stdin) != NULL) {
int is_dir = 0;
int i;
@@ -122,6 +134,10 @@ int main(int argc, char** argv) {
unsigned uid = 0, gid = 0, mode = 0;
uint64_t capabilities;
fs_config(buffer, is_dir, product_out_path, &uid, &gid, &mode, &capabilities);
+ if (root_path != NULL && strcmp(buffer, root_path) == 0) {
+ /* The root of the filesystem needs to be an empty string. */
+ strcpy(buffer, "");
+ }
printf("%s %d %d %o", buffer, uid, gid, mode);
if (sehnd != NULL) {