blob: cd4b8806b580296a751115d2ca97427f86f82fc1 [file] [log] [blame]
Dmitry Grinberge6f3e9b2014-03-11 18:28:15 -07001#include "fastboot.h"
2#include "make_ext4fs.h"
3#include "fs.h"
4
5#include <errno.h>
6#include <stdio.h>
7#include <stdlib.h>
8#include <stdarg.h>
9#include <stdbool.h>
10#include <string.h>
11#include <sys/stat.h>
12#include <sys/types.h>
13#include <sparse/sparse.h>
14#include <unistd.h>
15
16#ifdef USE_MINGW
17#include <fcntl.h>
18#else
19#include <sys/mman.h>
20#endif
21
22
23
24static int generate_ext4_image(int fd, long long partSize)
25{
26 make_ext4fs_sparse_fd(fd, partSize, NULL, NULL);
27
28 return 0;
29}
30
31static const struct fs_generator {
32
33 char *fs_type; //must match what fastboot reports for partition type
34 int (*generate)(int fd, long long partSize); //returns 0 or error value
35
36} generators[] = {
37
38 { "ext4", generate_ext4_image}
39
40};
41
JP Abgrall7e859742014-05-06 15:14:15 -070042const struct fs_generator* fs_get_generator(const char *fs_type)
Dmitry Grinberge6f3e9b2014-03-11 18:28:15 -070043{
44 unsigned i;
45
46 for (i = 0; i < sizeof(generators) / sizeof(*generators); i++)
JP Abgrall7e859742014-05-06 15:14:15 -070047 if (!strcmp(generators[i].fs_type, fs_type))
Dmitry Grinberge6f3e9b2014-03-11 18:28:15 -070048 return generators + i;
49
50 return NULL;
51}
52
53int fs_generator_generate(const struct fs_generator* gen, int tmpFileNo, long long partSize)
54{
55 return gen->generate(tmpFileNo, partSize);
56}