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>
This commit is contained in:
2019-06-12 18:22:12 +08:00
parent 03e268f710
commit aa387e176d
7 changed files with 70 additions and 49 deletions

View File

@ -7,21 +7,22 @@
#include <string.h>
#include "fat12.h"
#include "io.h"
static int make_image(const char *name, uint32_t size) {
int fd = open(name, O_WRONLY | O_CREAT, 0777);
if (-1 == fd) {
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(fd, size)) {
if (-1 == fat12_mkfs(io, size)) {
fprintf(stderr, "couldn't make fat12 on %s: %s\n", name, strerror(errno));
close(fd);
pang_close(&io);
return 1;
}
close(fd);
pang_close(&io);
return 0;
}

View File

@ -7,21 +7,22 @@
#include <string.h>
#include "fat12.h"
#include "io.h"
static int make_image(const char *name, uint32_t size) {
int fd = open(name, O_WRONLY | O_CREAT, 0777);
if (-1 == fd) {
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(fd, size)) {
if (-1 == fat12_mkfs(io, size)) {
fprintf(stderr, "couldn't make fat12 on %s: %s\n", name, strerror(errno));
close(fd);
pang_close(&io);
return 1;
}
close(fd);
pang_close(&io);
return 0;
}