+2023-04-04 Pádraig Brady <P@draigBrady.com>
+
+ backupfile: fix bug when renaming from subdirectory
+ * lib/backupfile.c (backup_internal): Ensure we use the
+ appropriate offset if operating on a subdirectory,
+ i.e., on an updated sdir.
+ Fixes https://bugs.gnu.org/62607
+
2023-04-04 Bruno Haible <bruno@clisp.org>
c32rtomb: Fix an autoconf test.
/* backupfile.c -- make Emacs style backup file names
- Copyright (C) 1990-2006, 2009-2022 Free Software Foundation, Inc.
+ Copyright (C) 1990-2006, 2009-2023 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
return s;
DIR *dirp = NULL;
- int sdir = dir_fd;
+ int sdir = -1;
idx_t base_max = 0;
while (true)
{
if (! rename)
break;
- idx_t offset = backup_type == simple_backups ? 0 : base_offset;
+ dir_fd = sdir < 0 ? dir_fd : sdir;
+ idx_t offset = sdir < 0 ? 0 : base_offset;
unsigned flags = backup_type == simple_backups ? 0 : RENAME_NOREPLACE;
- if (renameatu (sdir, file + offset, sdir, s + offset, flags) == 0)
+ if (renameatu (dir_fd, file + offset, dir_fd, s + offset, flags) == 0)
break;
int e = errno;
if (! (e == EEXIST && extended))