summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-20 22:02:59 -0400
committerIan Moffett <ian@osmora.org>2025-07-20 22:05:01 -0400
commitddbed2a640efb41585bd649b6c1d4af5f01dcaf9 (patch)
tree05b85d0d9dbe0f3b39d22907b557e6be8f0b39dd
parent890dd98ceb61de168b20acfd0aef1ddeb2cc1f39 (diff)
oasm: Open and grab fd for binary output file
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--usr.bin/oasm/oasm.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/oasm/oasm.c b/usr.bin/oasm/oasm.c
index 844f004..6c37778 100644
--- a/usr.bin/oasm/oasm.c
+++ b/usr.bin/oasm/oasm.c
@@ -47,7 +47,7 @@ oasm_start(struct oasm_state *state)
int
main(int argc, char **argv)
{
- if (argc < 2) {
+ if (argc < 3) {
printf("oasm: usage: oasm <file> <output>\n");
return -1;
}
@@ -58,8 +58,16 @@ main(int argc, char **argv)
return -1;
}
+ g_state.out_fd = open(argv[2], O_CREAT | O_WRONLY);
+ if (g_state.out_fd < 0) {
+ printf("could not open output \"%s\"\n", argv[2]);
+ close(g_state.in_fd);
+ return -1;
+ }
+
g_state.filename = argv[1];
oasm_start(&g_state);
close(g_state.in_fd);
+ close(g_state.out_fd);
return 0;
}