From ddbed2a640efb41585bd649b6c1d4af5f01dcaf9 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 20 Jul 2025 22:02:59 -0400 Subject: oasm: Open and grab fd for binary output file Signed-off-by: Ian Moffett --- usr.bin/oasm/oasm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'usr.bin/oasm') 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 \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; } -- cgit v1.2.3