nvme_show_status(err);
else {
printf("Success formatting namespace:%x\n", cfg.namespace_id);
- if (cfg.lbaf != prev_lbaf && ioctl(fd, BLKRRPART) < 0) {
- fprintf(stderr, "failed to re-read partition table\n");
- err = -errno;
- goto close_fd;
+ if (cfg.lbaf != prev_lbaf){
+ if (S_ISCHR(nvme_stat.st_mode)) {
+ if(ioctl(fd, NVME_IOCTL_RESCAN) < 0){
+ fprintf(stderr, "failed to rescan namespaces\n");
+ err = -errno;
+ goto close_fd;
+ }
+ } else {
+ if(ioctl(fd, BLKRRPART) < 0) {
+ fprintf(stderr, "failed to re-read partition table\n");
+ err = -errno;
+ goto close_fd;
+ }
+ }
}
-
if (cfg.reset && S_ISCHR(nvme_stat.st_mode))
nvme_reset_controller(fd);
}