mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58:22 +00:00
rename: RENAME_NOREPLACE
This commit is contained in:
@@ -1871,6 +1871,12 @@ static int ext2_rename(vnode_t *sourcedir, vnode_t *source, char *oldname, vnode
|
||||
ext2node_t *ext2_replaced_node = (ext2node_t *)replaced_vnode;
|
||||
|
||||
if (replaced_vnode) {
|
||||
if (flags & RENAME_NOREPLACE) {
|
||||
VOP_UNLOCK(replaced_vnode);
|
||||
VOP_RELEASE(replaced_vnode);
|
||||
return EEXIST;
|
||||
}
|
||||
|
||||
// we are replacing an existing link
|
||||
// do some checks expected by posix
|
||||
if (source->type != V_TYPE_DIR && replaced_vnode->type == V_TYPE_DIR) {
|
||||
|
||||
@@ -738,6 +738,12 @@ static int fatfs_rename(vnode_t *vsource_dir, vnode_t *vsource, char *old_name,
|
||||
target = (fatnode_t *)vtarget;
|
||||
|
||||
if (target) {
|
||||
if (flags & RENAME_NOREPLACE) {
|
||||
VOP_UNLOCK(vtarget);
|
||||
VOP_RELEASE(vtarget);
|
||||
return EEXIST;
|
||||
}
|
||||
|
||||
// we are replacing an existing link
|
||||
// do some checks expected by posix
|
||||
if (vsource->type != V_TYPE_DIR && vtarget->type == V_TYPE_DIR) {
|
||||
|
||||
@@ -352,6 +352,9 @@ static int tmpfs_rename(vnode_t *source, vnode_t *sourcefile, char *oldname, vno
|
||||
oldnode = v;
|
||||
|
||||
if (oldnode) {
|
||||
if (flags & RENAME_NOREPLACE)
|
||||
return EEXIST;
|
||||
|
||||
// we are replacing an existing link
|
||||
// do some checks expected by posix
|
||||
if (sourcefile->type != V_TYPE_DIR && oldnode->type == V_TYPE_DIR)
|
||||
|
||||
@@ -84,6 +84,8 @@ typedef struct {
|
||||
#define AT_SYMLINK_NOFOLLOW 0x100
|
||||
#define AT_EMPTY_PATH 0x1000
|
||||
|
||||
#define RENAME_NOREPLACE 0x1
|
||||
|
||||
#define AF_LOCAL 1
|
||||
#define AF_INET 2
|
||||
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
#include <string.h>
|
||||
#include <logging.h>
|
||||
|
||||
#define RENAMEAT_KNOWN_FLAGS RENAME_NOREPLACE
|
||||
|
||||
syscallret_t syscall_renameat(context_t *context, int olddirfd, char *uoldpath, int newdirfd, char *unewpath, unsigned int flags) {
|
||||
syscallret_t ret = {
|
||||
.ret = -1
|
||||
};
|
||||
|
||||
if (flags)
|
||||
printf("renameat: unknown %x\n", flags);
|
||||
if (flags & ~RENAMEAT_KNOWN_FLAGS)
|
||||
printf("renameat: unknown %x\n", flags & ~RENAMEAT_KNOWN_FLAGS);
|
||||
|
||||
size_t oldpathlen;
|
||||
size_t newpathlen;
|
||||
|
||||
Reference in New Issue
Block a user