| #include <sparse/sparse.h> |
| static int generate_ext4_image(int fd, long long partSize) |
| make_ext4fs_sparse_fd(fd, partSize, NULL, NULL); |
| static int generate_f2fs_image(int fd, long long partSize) |
| return make_f2fs_sparse_fd(fd, partSize, NULL, NULL); |
| static const struct fs_generator { |
| const char* fs_type; //must match what fastboot reports for partition type |
| int (*generate)(int fd, long long partSize); //returns 0 or error value |
| { "ext4", generate_ext4_image}, |
| { "f2fs", generate_f2fs_image}, |
| const struct fs_generator* fs_get_generator(const std::string& fs_type) { |
| for (size_t i = 0; i < sizeof(generators) / sizeof(*generators); i++) { |
| if (fs_type == generators[i].fs_type) { |
| int fs_generator_generate(const struct fs_generator* gen, int tmpFileNo, long long partSize) |
| return gen->generate(tmpFileNo, partSize); |