platform_system_core/fastboot/fs.c
JP Abgrall 7e85974fc2 fastboot: support for overriding format fs-type and size
This changes allows overriding the fs-type and size that
are normally returned by the booloader.

This is in preparation for supporting other FSes.

Change-Id: I8d141a0d4d14df9fe84d3b131484e9696fcd8870
Signed-off-by: JP Abgrall <jpa@google.com>
2014-05-06 15:14:15 -07:00

56 lines
1.1 KiB
C

#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 *fs_type)
{
unsigned i;
for (i = 0; i < sizeof(generators) / sizeof(*generators); i++)
if (!strcmp(generators[i].fs_type, fs_type))
return generators + i;
return NULL;
}
int fs_generator_generate(const struct fs_generator* gen, int tmpFileNo, long long partSize)
{
return gen->generate(tmpFileNo, partSize);
}