diff options
| author | Trey Aspelund <taspelund@cumulusnetworks.com> | 2020-04-01 19:59:32 -0400 |
|---|---|---|
| committer | Trey Aspelund <taspelund@cumulusnetworks.com> | 2020-04-03 00:56:57 -0400 |
| commit | 9fb05a74d2f371a9cf48d8d4aa1b10c663178b4a (patch) | |
| tree | 9bfaaa0ba2bb85b6ef95f73ac3d760f55126e081 | |
| parent | dba3453515d5b3dc8c66944fe30adc4bdae5b449 (diff) | |
vtysh: don't warn when saving conf the first time
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>
| -rw-r--r-- | vtysh/vtysh.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 310acdf37f..a5fa686eb5 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -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); } |
