Merge "Allow passing flash block sizes to libext4_utils" am: de893939ec am: 8018614aab
am: fa83cde440

Change-Id: I1ed0a7fae86ca6c4e8bfa499ba145c3631093cf1
diff --git a/ext4_utils/include/ext4_utils/make_ext4fs.h b/ext4_utils/include/ext4_utils/make_ext4fs.h
index 4498e62..c558b87 100644
--- a/ext4_utils/include/ext4_utils/make_ext4fs.h
+++ b/ext4_utils/include/ext4_utils/make_ext4fs.h
@@ -25,6 +25,10 @@
 
 int make_ext4fs(const char *filename, long long len,
                 const char *mountpoint, struct selabel_handle *sehnd);
+int make_ext4fs_directory_align(const char *filename, long long len,
+		const char *mountpoint, struct selabel_handle *sehnd,
+		const char *directory, unsigned eraseblk,
+		unsigned logicalblk);
 int make_ext4fs_directory(const char *filename, long long len,
                 const char *mountpoint, struct selabel_handle *sehnd,
                 const char *directory);
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
index b59000d..ec093f8 100644
--- a/ext4_utils/make_ext4fs.c
+++ b/ext4_utils/make_ext4fs.c
@@ -447,6 +447,33 @@
 	return make_ext4fs_directory(filename, len, mountpoint, sehnd, NULL);
 }
 
+int make_ext4fs_directory_align(const char *filename, long long len,
+						  const char *mountpoint, struct selabel_handle *sehnd,
+						  const char *directory, unsigned eraseblk,
+						  unsigned logicalblk)
+{
+	int fd;
+	int status;
+
+	reset_ext4fs_info();
+	info.len = len;
+	info.flash_erase_block_size = eraseblk;
+	info.flash_logical_block_size = logicalblk;
+
+	fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
+	if (fd < 0) {
+		error_errno("open");
+		return EXIT_FAILURE;
+	}
+
+	status = make_ext4fs_internal(fd, directory, NULL, mountpoint, NULL,
+								  0, 0, 0, 1, 0,
+								  sehnd, 0, -1, NULL, NULL, NULL);
+	close(fd);
+
+	return status;
+}
+
 int make_ext4fs_directory(const char *filename, long long len,
 						  const char *mountpoint, struct selabel_handle *sehnd,
 						  const char *directory)