- sprintf(tmpname, "%s/bands", ctx.pathname);
- if (mkdir(tmpname, 0777) == -1) {
+ snprintf(tmpname, tmplen + 1, "%s/Info.bckup", ctx.pathname);
+ if ((int)strlen(tmpname) == tmplen) { /* Only update backup if we get the full path */
+ /* Failure to create a backup is not fatal */
+ fp = fopen(tmpname, "w");
+ if (fp) {
+ if ((fprintf(fp, bundlePrototype, kBandSize, devp->size) < 0) ||
+ (fclose(fp) < 0)) {
+ unlink(tmpname);
+ }
+ }
+ } else {
+ warn("Cannot create backup bundle information file in %s", tmpname);
+ }
+ if ((snprintf(tmpname, tmplen + 1, "%s/bands", ctx.pathname) > tmplen) ||
+ (mkdir(tmpname, 0777) == -1)) {