Make mksquashfs generate a fs_config-friendly root entry
This change adds a flag so that the mksquashfs wrapper scripts generate an entry that is fs_config-friendly for the root inode. Namely, the root entry is expected to have an empty filename. Bug: 72745016 Test: m -j100 dist Change-Id: Iebdf79c5af0b9d999b7e5f5fe240abfe52cbadda
This commit is contained in:
@@ -2342,7 +2342,7 @@ endif
|
|||||||
# $1: root directory
|
# $1: root directory
|
||||||
# $2: add prefix
|
# $2: add prefix
|
||||||
define fs_config
|
define fs_config
|
||||||
(cd $(1); find . -type d | sed 's,$$,/,'; find . \! -type d) | cut -c 3- | sort | sed 's,^,$(2),' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC)
|
(cd $(1); find . -type d | sed 's,$$,/,'; find . \! -type d) | cut -c 3- | sort | sed 's,^,$(2),' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) -R "$(2)"
|
||||||
endef
|
endef
|
||||||
|
|
||||||
# Depending on the various images guarantees that the underlying
|
# Depending on the various images guarantees that the underlying
|
||||||
|
@@ -67,17 +67,18 @@ static struct selabel_handle* get_sehnd(const char* context_file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void usage() {
|
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) {
|
int main(int argc, char** argv) {
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
const char* context_file = NULL;
|
const char* context_file = NULL;
|
||||||
const char* product_out_path = NULL;
|
const char* product_out_path = NULL;
|
||||||
|
char* root_path = NULL;
|
||||||
struct selabel_handle* sehnd = NULL;
|
struct selabel_handle* sehnd = NULL;
|
||||||
int print_capabilities = 0;
|
int print_capabilities = 0;
|
||||||
int opt;
|
int opt;
|
||||||
while((opt = getopt(argc, argv, "CS:D:")) != -1) {
|
while((opt = getopt(argc, argv, "CS:R:D:")) != -1) {
|
||||||
switch(opt) {
|
switch(opt) {
|
||||||
case 'C':
|
case 'C':
|
||||||
print_capabilities = 1;
|
print_capabilities = 1;
|
||||||
@@ -85,6 +86,9 @@ int main(int argc, char** argv) {
|
|||||||
case 'S':
|
case 'S':
|
||||||
context_file = optarg;
|
context_file = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'R':
|
||||||
|
root_path = optarg;
|
||||||
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
product_out_path = optarg;
|
product_out_path = optarg;
|
||||||
break;
|
break;
|
||||||
@@ -98,6 +102,14 @@ int main(int argc, char** argv) {
|
|||||||
sehnd = get_sehnd(context_file);
|
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) {
|
while (fgets(buffer, 1023, stdin) != NULL) {
|
||||||
int is_dir = 0;
|
int is_dir = 0;
|
||||||
int i;
|
int i;
|
||||||
@@ -122,6 +134,10 @@ int main(int argc, char** argv) {
|
|||||||
unsigned uid = 0, gid = 0, mode = 0;
|
unsigned uid = 0, gid = 0, mode = 0;
|
||||||
uint64_t capabilities;
|
uint64_t capabilities;
|
||||||
fs_config(buffer, is_dir, product_out_path, &uid, &gid, &mode, &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);
|
printf("%s %d %d %o", buffer, uid, gid, mode);
|
||||||
|
|
||||||
if (sehnd != NULL) {
|
if (sehnd != NULL) {
|
||||||
|
Reference in New Issue
Block a user