diff options
| author | Gabriel Dalimonte <gabriel.dalimonte@gmail.com> | 2025-02-17 13:26:43 -0500 |
|---|---|---|
| committer | Tom Rini <trini@konsulko.com> | 2025-03-07 11:50:22 -0600 |
| commit | d9c149664fa7a0c2eabfc046dcf89637f655364b (patch) | |
| tree | 27e286a935fa3778fe894a6b3b6ed169a6fbe0c5 /include/fs.h | |
| parent | 1742b8484e797c56c720c24fa7b923a6d7275cc6 (diff) | |
fs: add rename infrastructure
The selection for *rename as the name for the rename/move operation
derives from the POSIX specification where they name the function
rename/renameat. [1] This aligns with Linux where the syscalls for
renaming/moving also use the rename/renameat naming.
[1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/rename.html
Signed-off-by: Gabriel Dalimonte <gabriel.dalimonte@gmail.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'include/fs.h')
| -rw-r--r-- | include/fs.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/include/fs.h b/include/fs.h index 2474880385d..5b272eb9f5e 100644 --- a/include/fs.h +++ b/include/fs.h @@ -86,7 +86,7 @@ int fs_set_blk_dev_with_part(struct blk_desc *desc, int part); * * Many file functions implicitly call fs_close(), e.g. fs_closedir(), * fs_exist(), fs_ln(), fs_ls(), fs_mkdir(), fs_read(), fs_size(), fs_write(), - * fs_unlink(). + * fs_unlink(), fs_rename(). */ void fs_close(void); @@ -270,6 +270,18 @@ int fs_unlink(const char *filename); */ int fs_mkdir(const char *filename); +/** + * fs_rename - rename/move a file or directory + * + * @old_path: existing path of the file/directory to rename + * @new_path: new path of the file/directory. If this points to an existing + * file or empty directory, the existing file/directory will be unlinked. + * If this points to a non-empty directory, the rename will fail. + * + * Return: 0 on success, -1 on error conditions + */ +int fs_rename(const char *old_path, const char *new_path); + /* * Common implementation for various filesystem commands, optionally limited * to a specific filesystem type via the fstype parameter. |
