#else
+#include <selinux/selinux.h>
+#include <selinux/label.h>
+#include <selinux/android.h>
+
#define O_BINARY 0
#endif
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;
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
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) {
- entry_inode = make_link(dentries[i].full_path, dentries[i].link);
+ entry_inode = make_link(dentries[i].link);
} else {
error("unknown file type on %s", dentries[i].path);
entry_inode = 0;
}
}
-int make_ext4fs_sparse_fd(int fd, s64 len,
+int make_ext4fs_sparse_fd(int fd, long long len,
const char *mountpoint, struct selabel_handle *sehnd)
{
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, sehnd, 0);
}
-int make_ext4fs(const char *filename, s64 len,
+int make_ext4fs(const char *filename, long long len,
const char *mountpoint, struct selabel_handle *sehnd)
{
int fd;
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, sehnd, 0);
close(fd);
return status;
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)
+ int sparse, int crc, int wipe,
+ struct selabel_handle *sehnd, int verbose)
{
u32 root_inode_num;
u16 root_mode;
char *mountpoint;
char *directory = NULL;
- int ret;
if (setjmp(setjmp_env))
return EXIT_FAILURE; /* Handle a call to longjmp() */
info.feat_ro_compat |=
EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER |
- EXT4_FEATURE_RO_COMPAT_LARGE_FILE;
+ EXT4_FEATURE_RO_COMPAT_LARGE_FILE |
+ EXT4_FEATURE_RO_COMPAT_GDT_CSUM;
info.feat_incompat |=
EXT4_FEATURE_INCOMPAT_EXTENTS |
#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
error("cannot lookup security context for %s", mountpoint);
}
if (secontext) {
- printf("Labeling %s as %s\n", mountpoint, secontext);
+ if (verbose) {
+ printf("Labeling %s as %s\n", mountpoint, secontext);
+ }
inode_set_selinux(root_inode_num, secontext);
}
freecon(secontext);
ext4_update_free();
- if (init_itabs)
- init_unused_inode_tables();
-
ext4_queue_sb();
printf("Created filesystem with %d/%d inodes and %d/%d blocks\n",