pang-o-lin/tests/mkfs-simple.c
Sean Cross c018281728 minor reformatting
Signed-off-by: Sean Cross <sean@xobs.io>
2019-06-13 16:12:19 +08:00

41 lines
921 B
C

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include "fat12.h"
#include "io.h"
static int make_image(const char *name, uint32_t size)
{
struct pang_io *io = pang_open(name);
if (!io)
{
fprintf(stderr, "couldn't open %s: %s\n", name, strerror(errno));
return 1;
}
if (-1 == fat12_mkfs(io, size))
{
fprintf(stderr, "couldn't make fat12 on %s: %s\n", name, strerror(errno));
pang_close(&io);
return 1;
}
pang_close(&io);
return 0;
}
int main(int argc, char **argv)
{
int ret = 0;
ret += make_image("build/fat12-1300k.img", 1300 * 1024);
ret += make_image("build/fat12-1800k.img", 1800 * 1024);
ret += make_image("build/fat12-128k.img", 128 * 1024);
ret += make_image("build/fat12-16M.img", 16 * 1024 * 1024);
return ret;
}