+ if (fstat(fd_current, &sb) == 0 && S_ISREG(sb.st_mode)) {
+ /* if any part of flash_open_tempfile() fails we fall
+ * back to in-place writes
+ */
+ fd_target = flash_open_tempfile(&dname, &target_temp);
+ }
+ dev_target = dev_current;
+ if (fd_target == -1)
+ fd_target = fd_current;
+ }
+
+ rc = flash_write(fd_current, fd_target, dev_target);
+
+ if (fsync(fd_current) && !(errno == EINVAL || errno == EROFS)) {
+ fprintf(stderr,
+ "fsync failed on %s: %s\n",
+ DEVNAME(dev_current), strerror(errno));
+ }