From 31ff1ee3d4b344a5c17fb04f5cf100db6222ecf0 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 28 Apr 2019 20:44:34 +0200 Subject: diskfs: Fix rename_dir(excl=1) for source directories Starting from coreutils 8.30 which uses renameat2(flag=RENAME_NOREPLACE), we need to have excl=1 to behave correctly, notably in this case: $ mkdir a $ mkdir b $ touch b/t $ mv b a diskfs_rename("b", "a", excl=1) called by mv shall return EEXIST. * libdiskfs/diskfs.h (diskfs_rename_dir): Add `excl' parameter. * doc/hurd.texi (diskfs_rename_dir): Document `excl' parameter. * libdiskfs/dir-renamed.c (diskfs_rename_dir): Add `excl' parameter. Return EEXIST when target exists and `excl' is not 0. * libdiskfs/dir-rename.c (diskfs_S_dir_rename): Pass `excl' to diskfs_rename_dir. --- libdiskfs/diskfs.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libdiskfs/diskfs.h') diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h index 40af37a9..f04b163a 100644 --- a/libdiskfs/diskfs.h +++ b/libdiskfs/diskfs.h @@ -1017,14 +1017,15 @@ struct node *diskfs_check_lookup_cache (struct node *dir, const char *name); upon return. This routine is serialized, so it doesn't have to be reentrant. Directories will never be renamed except by this routine. FROMCRED and TOCRED are the users responsible for - FDP/FNP and TDP respectively. This routine assumes the usual + FDP/FNP and TDP respectively. If EXCL is set, then fail if TONAME + already exists inside directory TDP. This routine assumes the usual convention where `.' and `..' are represented by ordinary links; if that is not true for your format, you have to redefine this function.*/ error_t diskfs_rename_dir (struct node *fdp, struct node *fnp, const char *fromname, struct node *tdp, const char *toname, - struct protid *fromcred, struct protid *tocred); + struct protid *fromcred, struct protid *tocred, int excl); /* Clear the `.' and `..' entries from directory DP. Its parent is PDP, and the user responsible for this is identified by CRED. Both -- cgit v1.2.3