Skip to content

Commit

Permalink
Merge pull request #182 from flaviojs/warn-file-rename-failure-vm_ren…
Browse files Browse the repository at this point in the history
…ame_instance

Warn when a file rename fails while renaming a vm.
  • Loading branch information
grossmj authored Mar 23, 2024
2 parents 37e438f + b2f5634 commit 42dc388
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion stable/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,9 @@ int vm_rename_instance(vm_instance_t *vm, char *name)
if ((filename = dyn_sprintf("%s_%s_%s",vm_get_type(vm),vm->name,globbuf.gl_pathv[i] + strlen(pattern) - 1)) == NULL)
break; /* out of memory */

rename(globbuf.gl_pathv[i], filename);
if (rename(globbuf.gl_pathv[i], filename) != 0) {
fprintf(stderr, "Warning: vm_rename_instance: rename(\"%s\",\"%s\"): %s\n", globbuf.gl_pathv[i], filename, strerror(errno));
}
free(filename);
}
globfree(&globbuf);
Expand Down
4 changes: 3 additions & 1 deletion unstable/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,9 @@ int vm_rename_instance(vm_instance_t *vm, char *name)
if ((filename = dyn_sprintf("%s_%s_%s",vm_get_type(vm),vm->name,globbuf.gl_pathv[i] + strlen(pattern) - 1)) == NULL)
break; /* out of memory */

rename(globbuf.gl_pathv[i], filename);
if (rename(globbuf.gl_pathv[i], filename) != 0) {
fprintf(stderr, "Warning: vm_rename_instance: rename(\"%s\",\"%s\"): %s\n", globbuf.gl_pathv[i], filename, strerror(errno));
}
free(filename);
}
globfree(&globbuf);
Expand Down

0 comments on commit 42dc388

Please sign in to comment.