[PATCH 2/5] dpkg: (K)eep conffile: split rename into link + unlink
When backing up the .dpkg-new file, make a hardlink backup and
then fall through to the "deleting .dpkg-new because it is not to
be used" case. This is messier than a true rename, but it
creates some flexibility by allowing us to perform some
operations between the two steps in the future.
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
src/configure.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/configure.c b/src/configure.c
index 6c9b7da..2764729 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -170,12 +170,17 @@ deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff)
warning(_("%s: failed to remove old backup '%.250s': %s"),
pkg->name, cdr2.buf, strerror(errno));
strcpy(cdrrest, DPKGDISTEXT);
+ if (unlink(cdr.buf) && errno != ENOENT)
+ warning(_("%s: failed to remove '%.250s' "
+ "(before overwrite): %s"),
+ pkg->name, cdr.buf, strerror(errno));
trig_file_activate(usenode, pkg);
strcpy(cdr2rest, DPKGNEWEXT);
- if (rename(cdr2.buf, cdr.buf))
- warning(_("%s: failed to rename '%.250s' to '%.250s': %s"),
+ if (link(cdr2.buf, cdr.buf))
+ warning(_("%s: failed to link '%.250s' "
+ "to '%.250s': %s"),
pkg->name, cdr2.buf, cdr.buf, strerror(errno));
- break;
+ /* Fall through. */
case cfo_keep:
strcpy(cdr2rest, DPKGNEWEXT);
if (unlink(cdr2.buf))
--
1.6.5.2
Reply to: