blob: 6a1f9e61e3924cfd9e32059c03c6b7ce368ac6a5 [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
42const struct fs_generator* fs_get_generator(const char* name)
43{
44 unsigned i;
45
46 for (i = 0; i < sizeof(generators) / sizeof(*generators); i++)
47 if (!strcmp(generators[i].fs_type, name))
48 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}