Sean Cross
f68f8215b7
It can create a basic filesystem of arbitrary size. Signed-off-by: Sean Cross <sean@xobs.io>
37 lines
882 B
C
37 lines
882 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"
|
|
|
|
static int make_image(const char *name, uint32_t size) {
|
|
|
|
int fd = open(name, O_WRONLY | O_CREAT, 0777);
|
|
if (-1 == fd) {
|
|
fprintf(stderr, "couldn't open %s: %s\n", name, strerror(errno));
|
|
return 1;
|
|
}
|
|
|
|
if (-1 == fat12_mkfs(fd, size)) {
|
|
fprintf(stderr, "couldn't make fat12 on %s: %s\n", name, strerror(errno));
|
|
close(fd);
|
|
return 1;
|
|
}
|
|
close(fd);
|
|
return 0;
|
|
}
|
|
|
|
int main(int argc, char **argv) {
|
|
int ret = 0;
|
|
|
|
ret += make_image("fat12-1300k.img", 1300 * 1024);
|
|
// ret += make_image("fat12-1800k.img", 1800 * 1024);
|
|
// ret += make_image("fat12-128k.img", 128 * 1024);
|
|
ret += make_image("fat12-16M.img", 16 * 1024 * 1024);
|
|
|
|
return ret;
|
|
} |