Skip to content

Commit d71f0a5

Browse files
committed
fs: _ken_open simplify and improve behavior on O_CREAT
1 parent db8a70f commit d71f0a5

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/system/libroot2/fs/fs.cpp

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,14 @@ _kern_open(int fd, const char* path, int openMode, int perms)
5656
if (path == NULL)
5757
openMode |= AT_EMPTY_PATH;
5858

59-
int ret = openat(fd, path, openMode, perms);
60-
if (ret < 0)
61-
return -errno;
62-
63-
struct stat st;
64-
int err = 0;
65-
66-
if (path == NULL || (openMode & AT_EMPTY_PATH))
67-
err = fstat(ret, &st);
59+
int ret;
60+
if (openMode & O_CREAT)
61+
ret = openat(fd, path, openMode, perms);
6862
else
69-
err = fstatat(fd, path, &st, 0);
63+
ret = openat(fd, path, openMode);
7064

71-
if (err != 0) {
72-
if (!(openMode & O_CREAT)) {
73-
close(ret);
74-
return B_ENTRY_NOT_FOUND;
75-
}
76-
}
65+
if (ret < 0)
66+
return -errno;
7767

7868
return ret;
7969
}

0 commit comments

Comments
 (0)