libc: Add mknod()
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-03-18 09:13:31 +01:00
parent 7173c05a22
commit 8c831a6906
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 11 additions and 2 deletions

View File

@ -10,7 +10,7 @@ int main()
printf("Hello world!\n");
mkdir("/dev", 0755);
if (syscall(SYS_mknod, "/dev/console", 0666, makedev(1, 0)) < 0)
if (mknod("/dev/console", 0666, makedev(1, 0)) < 0)
{
perror("mknod");
return 1;
@ -19,6 +19,6 @@ int main()
const char* str = "Hello from /dev!";
FILE* f = fopen("/dev/console", "r+");
fwrite(str, 1, strlen(str), f);
if (f) fwrite(str, 1, strlen(str), f);
if (f) fclose(f);
}

View File

@ -14,6 +14,9 @@ extern "C"
/* Create a directory. */
int mkdir(const char* path, mode_t mode);
/* Create a special file. */
int mknod(const char* path, mode_t mode, dev_t dev);
#ifdef __cplusplus
}
#endif

View File

@ -10,4 +10,10 @@ extern "C"
long rc = syscall(SYS_mkdir, path, mode);
__errno_return(rc, int);
}
int mknod(const char* path, mode_t mode, dev_t dev)
{
long rc = syscall(SYS_mknod, path, mode, dev);
__errno_return(rc, int);
}
}