Add test for creating a new file and add openc macro to use openat with the mode option

This commit is contained in:
2025-04-27 02:19:47 -04:00
parent eda1bbca23
commit faab7a9622
2 changed files with 22 additions and 3 deletions

View File

@@ -28,9 +28,14 @@ int main() {
// Test the read syscall
#define INPUT_BUFFER_LEN 4096
char input_buffer[INPUT_BUFFER_LEN] = {0};
int32_t fout = openc("outfile", O_RDWR | O_CREAT | O_TRUNC, 0664);
write(STDOUT, "Enter some text:", 16);
intptr_t n_read = read(STDIN, input_buffer, INPUT_BUFFER_LEN);
write(STDOUT, input_buffer, n_read);
if(fout > 0) {
write(fout, input_buffer, n_read);
}
// Test the open syscall
int32_t file = open("/proc/version", O_RDONLY);