2019-06-09 07:48:07 +00:00
|
|
|
#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"
|
2019-06-12 10:22:12 +00:00
|
|
|
#include "io.h"
|
2019-06-09 07:48:07 +00:00
|
|
|
|
|
|
|
static int make_image(const char *name, uint32_t size) {
|
|
|
|
|
2019-06-12 10:22:12 +00:00
|
|
|
struct pang_io *io = pang_open(name);
|
|
|
|
if (!io) {
|
2019-06-09 07:48:07 +00:00
|
|
|
fprintf(stderr, "couldn't open %s: %s\n", name, strerror(errno));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-06-12 10:22:12 +00:00
|
|
|
if (-1 == fat12_mkfs(io, size)) {
|
2019-06-09 07:48:07 +00:00
|
|
|
fprintf(stderr, "couldn't make fat12 on %s: %s\n", name, strerror(errno));
|
2019-06-12 10:22:12 +00:00
|
|
|
pang_close(&io);
|
2019-06-09 07:48:07 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2019-06-12 10:22:12 +00:00
|
|
|
pang_close(&io);
|
2019-06-09 07:48:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
int ret = 0;
|
|
|
|
|
2019-06-09 07:57:47 +00:00
|
|
|
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);
|
2019-06-09 07:48:07 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|