summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2013-01-23 18:42:52 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2013-01-23 18:42:52 -0800
commit4ea0ecda33379735259b1eb2b5d137ade5851109 (patch)
treecb9bb726d313b77b154335de5780766a1391fb4a
parent30ea356ee447785c2098a815e0f7d3623692b068 (diff)
parentf52abf4ca2ce307e7d4056e02c9e22075ab65459 (diff)
downloadextras-4ea0ecda33379735259b1eb2b5d137ade5851109.tar.gz
am f52abf4c: Merge "Add verbose option to make_ext4 command"
# By William Roberts # Via Colin Cross (1) and Gerrit Code Review (1) * commit 'f52abf4ca2ce307e7d4056e02c9e22075ab65459': Add verbose option to make_ext4 command
-rw-r--r--ext4_utils/ext4_utils.h2
-rw-r--r--ext4_utils/make_ext4fs.c20
-rw-r--r--ext4_utils/make_ext4fs_main.c10
3 files changed, 17 insertions, 15 deletions
diff --git a/ext4_utils/ext4_utils.h b/ext4_utils/ext4_utils.h
index 520b3567..26952c0d 100644
--- a/ext4_utils/ext4_utils.h
+++ b/ext4_utils/ext4_utils.h
@@ -175,7 +175,7 @@ struct selabel_handle;
int make_ext4fs_internal(int fd, const char *directory,
const char *mountpoint, fs_config_func_t fs_config_func, int gzip,
int sparse, int crc, int wipe, int init_itabs,
- struct selabel_handle *sehnd);
+ struct selabel_handle *sehnd, int verbose);
#ifdef __cplusplus
}
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
index e69b473a..5c1003d3 100644
--- a/ext4_utils/make_ext4fs.c
+++ b/ext4_utils/make_ext4fs.c
@@ -109,7 +109,7 @@ static u32 build_default_directory_structure()
if the image were mounted at the specified mount point */
static u32 build_directory_structure(const char *full_path, const char *dir_path,
u32 dir_inode, fs_config_func_t fs_config_func,
- struct selabel_handle *sehnd)
+ struct selabel_handle *sehnd, int verbose)
{
int entries = 0;
struct dentry *dentries;
@@ -183,11 +183,9 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
if (selabel_lookup(sehnd, &dentries[i].secon, dentries[i].path, stat.st_mode) < 0) {
error("cannot lookup security context for %s", dentries[i].path);
}
-#if 0
- // TODO make this a debug flag
- if (dentries[i].secon)
+
+ if (dentries[i].secon && verbose)
printf("Labeling %s as %s\n", dentries[i].path, dentries[i].secon);
-#endif
}
#endif
@@ -256,7 +254,7 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
if (ret < 0)
critical_error_errno("asprintf");
entry_inode = build_directory_structure(subdir_full_path,
- subdir_dir_path, inode, fs_config_func, sehnd);
+ subdir_dir_path, inode, fs_config_func, sehnd, verbose);
free(subdir_full_path);
free(subdir_dir_path);
} else if (dentries[i].file_type == EXT4_FT_SYMLINK) {
@@ -363,7 +361,7 @@ int make_ext4fs_sparse_fd(int fd, long long len,
reset_ext4fs_info();
info.len = len;
- return make_ext4fs_internal(fd, NULL, mountpoint, NULL, 0, 1, 0, 0, 0, sehnd);
+ return make_ext4fs_internal(fd, NULL, mountpoint, NULL, 0, 1, 0, 0, 0, sehnd, 0);
}
int make_ext4fs(const char *filename, long long len,
@@ -381,7 +379,7 @@ int make_ext4fs(const char *filename, long long len,
return EXIT_FAILURE;
}
- status = make_ext4fs_internal(fd, NULL, mountpoint, NULL, 0, 0, 0, 1, 0, sehnd);
+ status = make_ext4fs_internal(fd, NULL, mountpoint, NULL, 0, 0, 0, 1, 0, sehnd, 0);
close(fd);
return status;
@@ -447,7 +445,7 @@ static char *canonicalize_rel_slashes(const char *str)
int make_ext4fs_internal(int fd, const char *_directory,
const char *_mountpoint, fs_config_func_t fs_config_func, int gzip,
int sparse, int crc, int wipe, int init_itabs,
- struct selabel_handle *sehnd)
+ struct selabel_handle *sehnd, int verbose)
{
u32 root_inode_num;
u16 root_mode;
@@ -555,7 +553,7 @@ int make_ext4fs_internal(int fd, const char *_directory,
#else
if (directory)
root_inode_num = build_directory_structure(directory, mountpoint, 0,
- fs_config_func, sehnd);
+ fs_config_func, sehnd, verbose);
else
root_inode_num = build_default_directory_structure();
#endif
@@ -570,7 +568,7 @@ int make_ext4fs_internal(int fd, const char *_directory,
if (selabel_lookup(sehnd, &secontext, mountpoint, S_IFDIR) < 0) {
error("cannot lookup security context for %s", mountpoint);
}
- if (secontext) {
+ if (secontext && verbose) {
printf("Labeling %s as %s\n", mountpoint, secontext);
inode_set_selinux(root_inode_num, secontext);
}
diff --git a/ext4_utils/make_ext4fs_main.c b/ext4_utils/make_ext4fs_main.c
index 71fc3c18..739c4a16 100644
--- a/ext4_utils/make_ext4fs_main.c
+++ b/ext4_utils/make_ext4fs_main.c
@@ -53,7 +53,7 @@ static void usage(char *path)
fprintf(stderr, " [ -g <blocks per group> ] [ -i <inodes> ] [ -I <inode size> ]\n");
fprintf(stderr, " [ -L <label> ] [ -f ] [ -a <android mountpoint> ]\n");
fprintf(stderr, " [ -S file_contexts ]\n");
- fprintf(stderr, " [ -z | -s ] [ -t ] [ -w ] [ -c ] [ -J ]\n");
+ fprintf(stderr, " [ -z | -s ] [ -t ] [ -w ] [ -c ] [ -J ] [ -v ]\n");
fprintf(stderr, " <filename> [<directory>]\n");
}
@@ -71,12 +71,13 @@ int main(int argc, char **argv)
int init_itabs = 0;
int fd;
int exitcode;
+ int verbose = 0;
struct selabel_handle *sehnd = NULL;
#ifndef USE_MINGW
struct selinux_opt seopts[] = { { SELABEL_OPT_PATH, "" } };
#endif
- while ((opt = getopt(argc, argv, "l:j:b:g:i:I:L:a:fwzJsctS:")) != -1) {
+ while ((opt = getopt(argc, argv, "l:j:b:g:i:I:L:a:S:fwzJsctv")) != -1) {
switch (opt) {
case 'l':
info.len = parse_num(optarg);
@@ -140,6 +141,9 @@ int main(int argc, char **argv)
}
#endif
break;
+ case 'v':
+ verbose = 1;
+ break;
default: /* '?' */
usage(argv[0]);
exit(EXIT_FAILURE);
@@ -198,7 +202,7 @@ int main(int argc, char **argv)
}
exitcode = make_ext4fs_internal(fd, directory, mountpoint, fs_config_func, gzip,
- sparse, crc, wipe, init_itabs, sehnd);
+ sparse, crc, wipe, init_itabs, sehnd, verbose);
close(fd);
return exitcode;