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
+2
View File
@@ -15,3 +15,5 @@ int ext2_initialize();
/// @brief De-initializes the EXT2 drivers.
/// @return 0 on success, 1 on error.
int ext2_finalize();
void ext2_test();
+8
View File
@@ -112,6 +112,14 @@ int vfs_mkdir(const char *path, mode_t mode);
/// @return Returns a negative value on failure.
int vfs_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)
vfs_file_t *vfs_creat(const char *path, mode_t mode);
/// @brief Stat the file at the given path.
/// @param path Path to the file for which we are retrieving the statistics.
/// @param buf Buffer where we are storing the statistics.
+4
View File
@@ -23,6 +23,8 @@ typedef struct vfs_file_t vfs_file_t;
typedef int (*vfs_mkdir_callback)(const char *, mode_t);
/// Function used to remove a directory.
typedef int (*vfs_rmdir_callback)(const char *);
/// Function used to open a file (or directory).
typedef vfs_file_t *(*vfs_creat_callback)(const char *, mode_t);
/// Function used to read the entries of a directory.
typedef int (*vfs_getdents_callback)(vfs_file_t *, dirent_t *, off_t, size_t);
/// Function used to open a file (or directory).
@@ -62,6 +64,8 @@ typedef struct vfs_sys_operations_t {
vfs_rmdir_callback rmdir_f;
/// Stat function.
vfs_stat_callback stat_f;
/// File creation function.
vfs_creat_callback creat_f;
} vfs_sys_operations_t;
/// @brief Set of functions used to perform operations on files.
+8
View File
@@ -208,6 +208,14 @@ int sys_mkdir(const char *path, mode_t mode);
/// @return Returns a negative value on failure.
int sys_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 sys_creat(const char *path, mode_t mode);
/// Provide access to the directory entries.
/// @param fd The file descriptor of the directory for which we accessing
/// the entries.