summaryrefslogtreecommitdiffstats
path: root/fastboot/fs.c
diff options
context:
space:
mode:
authorDmitry Grinberg <dmitrygr@google.com>2014-03-11 18:28:15 -0700
committerDmitry Grinberg <dmitrygr@google.com>2014-03-13 15:55:11 -0700
commit0d4a4cb8aa16fdb3897eaa89a62cb055d8dcbdf9 (patch)
treecf9c186047ea4ad790657b1059d4b78294656212 /fastboot/fs.c
parent93412622859014cc8bd39c30101096d03300845c (diff)
downloadsystem_core-0d4a4cb8aa16fdb3897eaa89a62cb055d8dcbdf9.zip
system_core-0d4a4cb8aa16fdb3897eaa89a62cb055d8dcbdf9.tar.gz
system_core-0d4a4cb8aa16fdb3897eaa89a62cb055d8dcbdf9.tar.bz2
fastboot: allow format on devices with small buffers
Formatting large partitions on devices with small transfer buffers did not work before since format used a strange path through the code to send data. It now uses the normal path. Also cleaned up a bit. FS code now lives in a separate file and the custom path for format is gone. Change-Id: If4e01cabc2e250b7c02ca7ce8c268e51d49e1529
Diffstat (limited to 'fastboot/fs.c')
-rw-r--r--fastboot/fs.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/fastboot/fs.c b/fastboot/fs.c
new file mode 100644
index 0000000..6a1f9e6
--- /dev/null
+++ b/fastboot/fs.c
@@ -0,0 +1,56 @@
+#include "fastboot.h"
+#include "make_ext4fs.h"
+#include "fs.h"
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sparse/sparse.h>
+#include <unistd.h>
+
+#ifdef USE_MINGW
+#include <fcntl.h>
+#else
+#include <sys/mman.h>
+#endif
+
+
+
+static int generate_ext4_image(int fd, long long partSize)
+{
+ make_ext4fs_sparse_fd(fd, partSize, NULL, NULL);
+
+ return 0;
+}
+
+static const struct fs_generator {
+
+ char *fs_type; //must match what fastboot reports for partition type
+ int (*generate)(int fd, long long partSize); //returns 0 or error value
+
+} generators[] = {
+
+ { "ext4", generate_ext4_image}
+
+};
+
+const struct fs_generator* fs_get_generator(const char* name)
+{
+ unsigned i;
+
+ for (i = 0; i < sizeof(generators) / sizeof(*generators); i++)
+ if (!strcmp(generators[i].fs_type, name))
+ return generators + i;
+
+ return NULL;
+}
+
+int fs_generator_generate(const struct fs_generator* gen, int tmpFileNo, long long partSize)
+{
+ return gen->generate(tmpFileNo, partSize);
+}