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. --- doc/hurd.texi | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'doc') diff --git a/doc/hurd.texi b/doc/hurd.texi index 7ad798a9..e74ad2d4 100644 --- a/doc/hurd.texi +++ b/doc/hurd.texi @@ -4442,14 +4442,16 @@ file data) is used. If it returns any other error, it is returned to the user. @end deftypefn -@deftypefun error_t diskfs_rename_dir (@w{struct node *@var{fdp}}, @w{struct node *@var{fnp}}, @w{char *@var{fromname}}, @w{struct node *@var{tdp}}, @w{char *@var{toname}}, @w{struct protid *@var{fromcred}}, @w{struct protid *@var{tocred}}) +@deftypefun error_t diskfs_rename_dir (@w{struct node *@var{fdp}}, @w{struct node *@var{fnp}}, @w{char *@var{fromname}}, @w{struct node *@var{tdp}}, @w{char *@var{toname}}, @w{struct protid *@var{fromcred}}, @w{struct protid *@var{tocred}}, @w{int @var{excl}}) Rename directory node @var{fnp} (whose parent is @var{fdp}, and which has name @var{fromname} in that directory) to have name @var{toname} inside directory @var{tdp}. None of these nodes are locked, and none should be locked upon return. This routine is serialized, so it doesn't have to be reentrant. Directories will never be renamed except by this routine. @var{fromcred} is the user responsible for @var{fdp} and -@var{fnp}. @var{tocred} is the user responsible for @var{tdp}. This +@var{fnp}. @var{tocred} is the user responsible for @var{tdp}. +If @var{excl} is set, then fail if @var{toname} already exists inside +directory @var{tdp}. This routine assumes the usual convention where @file{.} and @file{..} are represented by ordinary links; if that is not true for your format, you have to redefine this function. -- cgit v1.2.3