pang-o-lin/tests/mkfs-simple.c
Sean Cross aa387e176d pang-io: rework api for memory-mapped io
On real hardwareit will use memory-mapped io.  Rework pang-io so that it
more closely aligns with this paradigm.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-06-12 18:22:12 +08:00

38 lines
914 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;
}