]> git.puffer.fish Git - matthieu/frr.git/commitdiff
vtysh: don't warn when saving conf the first time
authorTrey Aspelund <taspelund@cumulusnetworks.com>
Wed, 1 Apr 2020 23:59:32 +0000 (19:59 -0400)
committerTrey Aspelund <taspelund@cumulusnetworks.com>
Fri, 3 Apr 2020 04:56:57 +0000 (00:56 -0400)
This removes a warning when ENOENT is returned while backing up the
config. This also provides strerror when backup fails for other reasons.

Signed-off-by: Trey Aspelund <taspelund@cumulusnetworks.com>
vtysh/vtysh.c

index 310acdf37f741a7a0de7f3316b2ca6caa20864d6..a5fa686eb56d721e36f1328d80f3bb662afcc84e 100644 (file)
@@ -2877,13 +2877,12 @@ static void backup_config_file(const char *fbackup)
        strlcat(integrate_sav, CONF_BACKUP_EXT, integrate_sav_sz);
 
        /* Move current configuration file to backup config file. */
-       if (unlink(integrate_sav) != 0) {
-               vty_out(vty, "Warning: %s unlink failed\n", integrate_sav);
-       }
-       if (rename(fbackup, integrate_sav) != 0) {
-               vty_out(vty, "Error renaming %s to %s\n", fbackup,
-                       integrate_sav);
-       }
+       if (unlink(integrate_sav) != 0 && errno != ENOENT)
+               vty_out(vty, "Unlink failed for %s: %s\n", integrate_sav,
+                       strerror(errno));
+       if (rename(fbackup, integrate_sav) != 0 && errno != ENOENT)
+               vty_out(vty, "Error renaming %s to %s: %s\n", fbackup,
+                       integrate_sav, strerror(errno));
        free(integrate_sav);
 }