Kernel/LibC/Userspace: Implement mkdir and creat

Touch now uses creat insteadd of open with O_CREAT flag
This commit is contained in:
2023-10-25 19:45:18 +03:00
parent e9b7cf332d
commit 6ee4d10651
11 changed files with 83 additions and 10 deletions

View File

@@ -4,18 +4,14 @@
int main(int argc, char** argv)
{
int ret = 0;
for (int i = 1; i < argc; i++)
{
int fd = open(argv[i], O_WRONLY | O_CREAT, 0644);
if (fd == -1)
if (creat(argv[i], 0644) == -1 && errno != EEXIST)
{
if (errno != EEXISTS)
perror(argv[i]);
}
else
{
close(fd);
perror(argv[i]);
ret = 1;
}
}
return 0;
return ret;
}