Add creat function call. Fix direntry iteration in EXT2. Fix open of directories in EXT2. Fix re-utilization of unlinked direntries in EXT2.

This commit is contained in:
Enrico Fraccaroli
2021-12-27 17:41:35 +01:00
parent 7c4a4ac0ba
commit 1ebc74f31f
14 changed files with 330 additions and 144 deletions
+1
View File
@@ -84,6 +84,7 @@ add_library(
${PROJECT_SOURCE_DIR}/src/sys/errno.c
${PROJECT_SOURCE_DIR}/src/sys/utsname.c
${PROJECT_SOURCE_DIR}/src/sys/ioctl.c
${PROJECT_SOURCE_DIR}/src/unistd/creat.c
${PROJECT_SOURCE_DIR}/src/unistd/getppid.c
${PROJECT_SOURCE_DIR}/src/unistd/getpid.c
${PROJECT_SOURCE_DIR}/src/unistd/exit.c
+9 -1
View File
@@ -32,4 +32,12 @@ int mkdir(const char *path, mode_t mode);
/// @brief Removes the given directory.
/// @param path The path to the directory to remove.
/// @return Returns a negative value on failure.
int rmdir(const char *path);
int rmdir(const char *path);
/// @brief Creates a new file or rewrite an existing one.
/// @param path path to the file.
/// @param mode mode for file creation.
/// @return file descriptor number, -1 otherwise and errno is set to indicate the error.
/// @details
/// It is equivalent to: open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)
int creat(const char *path, mode_t mode);
+4 -7
View File
@@ -28,14 +28,11 @@ ssize_t read(int fd, void *buf, size_t nbytes);
/// @return The number of written bytes.
ssize_t write(int fd, void *buf, size_t nbytes);
/// @brief Opens the file specified by pathname.
/// @brief Opens the file specified by pathname.
/// @param pathname A pathname for a file.
/// @param flags Used to set the file status flags and file access modes
/// of the open file description.
/// @param mode Specifies the file mode bits be applied when a new file
/// is created.
/// @return Returns a file descriptor, a small, nonnegative integer for
/// use in subsequent system calls.
/// @param flags file status flags and file access modes of the open file description.
/// @param mode the file mode bits be applied when a new file is created.
/// @return file descriptor number, -1 otherwise and errno is set to indicate the error.
int open(const char *pathname, int flags, mode_t mode);
/// @brief Close a file descriptor.
+11
View File
@@ -0,0 +1,11 @@
/// MentOS, The Mentoring Operating system project
/// @file creat.c
/// @brief
/// @copyright (c) 2014-2021 This file is distributed under the MIT License.
/// See LICENSE.md for details.
#include "sys/unistd.h"
#include "system/syscall_types.h"
#include "sys/errno.h"
_syscall2(int, creat, const char *, pathname, mode_t, mode)