summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor O'Brien <connoro@google.com>2017-02-10 00:01:41 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-02-10 00:01:41 +0000
commitb1ebb81b4679dc56ff37f665361f3c949b36f3d9 (patch)
tree3e60eee73ed8995596090b089d486da5bbc19b63
parenta355220f81348774ed391c77c4e7be042635ba66 (diff)
parent7ba1e209f2c96b32bf023e24ff43a77d4f5341cb (diff)
downloadextras-b1ebb81b4679dc56ff37f665361f3c949b36f3d9.tar.gz
Merge "ext4_utils: allow passing flash block sizes to make_ext4fs_sparse functions"
-rw-r--r--ext4_utils/include/ext4_utils/make_ext4fs.h6
-rw-r--r--ext4_utils/make_ext4fs.c50
2 files changed, 31 insertions, 25 deletions
diff --git a/ext4_utils/include/ext4_utils/make_ext4fs.h b/ext4_utils/include/ext4_utils/make_ext4fs.h
index c558b87f..44e94810 100644
--- a/ext4_utils/include/ext4_utils/make_ext4fs.h
+++ b/ext4_utils/include/ext4_utils/make_ext4fs.h
@@ -37,6 +37,12 @@ int make_ext4fs_sparse_fd(int fd, long long len,
int make_ext4fs_sparse_fd_directory(int fd, long long len,
const char *mountpoint, struct selabel_handle *sehnd,
const char *directory);
+int make_ext4fs_sparse_fd_align(int fd, long long len,
+ const char *mountpoint, struct selabel_handle *sehnd,
+ unsigned eraseblk, unsigned logicalblk);
+int make_ext4fs_sparse_fd_directory_align(int fd, long long len,
+ const char *mountpoint, struct selabel_handle *sehnd,
+ const char *directory, unsigned eraseblk, unsigned logicalblk);
#ifdef __cplusplus
}
diff --git a/ext4_utils/make_ext4fs.c b/ext4_utils/make_ext4fs.c
index ec093f8d..b84db9b3 100644
--- a/ext4_utils/make_ext4fs.c
+++ b/ext4_utils/make_ext4fs.c
@@ -426,15 +426,32 @@ void reset_ext4fs_info() {
int make_ext4fs_sparse_fd(int fd, long long len,
const char *mountpoint, struct selabel_handle *sehnd)
{
- return make_ext4fs_sparse_fd_directory(fd, len, mountpoint, sehnd, NULL);
+ return make_ext4fs_sparse_fd_align(fd, len, mountpoint, sehnd, 0, 0);
+}
+
+int make_ext4fs_sparse_fd_align(int fd, long long len,
+ const char *mountpoint, struct selabel_handle *sehnd,
+ unsigned eraseblk, unsigned logicalblk)
+{
+ return make_ext4fs_sparse_fd_directory_align(fd, len, mountpoint, sehnd, NULL,
+ eraseblk, logicalblk);
}
int make_ext4fs_sparse_fd_directory(int fd, long long len,
const char *mountpoint, struct selabel_handle *sehnd,
const char *directory)
{
+ return make_ext4fs_sparse_fd_directory_align(fd, len, mountpoint, sehnd, directory, 0, 0);
+}
+
+int make_ext4fs_sparse_fd_directory_align(int fd, long long len,
+ const char *mountpoint, struct selabel_handle *sehnd,
+ const char *directory, unsigned eraseblk, unsigned logicalblk)
+{
reset_ext4fs_info();
info.len = len;
+ info.flash_erase_block_size = eraseblk;
+ info.flash_logical_block_size = logicalblk;
return make_ext4fs_internal(fd, directory, NULL, mountpoint, NULL,
0, 1, 0, 0, 0,
@@ -447,6 +464,13 @@ int make_ext4fs(const char *filename, long long len,
return make_ext4fs_directory(filename, len, mountpoint, sehnd, NULL);
}
+int make_ext4fs_directory(const char *filename, long long len,
+ const char *mountpoint, struct selabel_handle *sehnd,
+ const char *directory)
+{
+ return make_ext4fs_directory_align(filename, len, mountpoint, sehnd, directory, 0, 0);
+}
+
int make_ext4fs_directory_align(const char *filename, long long len,
const char *mountpoint, struct selabel_handle *sehnd,
const char *directory, unsigned eraseblk,
@@ -474,30 +498,6 @@ int make_ext4fs_directory_align(const char *filename, long long len,
return status;
}
-int make_ext4fs_directory(const char *filename, long long len,
- const char *mountpoint, struct selabel_handle *sehnd,
- const char *directory)
-{
- int fd;
- int status;
-
- reset_ext4fs_info();
- info.len = len;
-
- 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;
-}
-
/* return a newly-malloc'd string that is a copy of str. The new string
is guaranteed to have a trailing slash. If absolute is true, the new string
is also guaranteed to have a leading slash.