diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 7df61cde1d0e8148527eb399b20f374ea6946394..f4124dfda4eb55082d586bd1aabf76bfa27341e0 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -1050,8 +1050,8 @@ static struct diskType const disk_types[] = { int -virStorageBackendUpdateVolTargetFormatFD(virStorageVolTargetPtr target, - int fd) +virStorageBackendDetectBlockVolFormatFD(virStorageVolTargetPtr target, + int fd) { int i; off_t start; diff --git a/src/storage/storage_backend.h b/src/storage/storage_backend.h index 766f374902a2cbe5b4d9a650c5fc3336d3b64c7d..907c4bc29a70f84855bb68f2bb5a541ef2635d10 100644 --- a/src/storage/storage_backend.h +++ b/src/storage/storage_backend.h @@ -92,8 +92,8 @@ int virStorageBackendUpdateVolTargetInfoFD(virStorageVolTargetPtr target, unsigned long long *allocation, unsigned long long *capacity); int -virStorageBackendUpdateVolTargetFormatFD(virStorageVolTargetPtr target, - int fd); +virStorageBackendDetectBlockVolFormatFD(virStorageVolTargetPtr target, + int fd); char *virStorageBackendStablePath(virStoragePoolObjPtr pool, const char *devpath); diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c index 78d6b31913d9334210c0a8dba53bad1478dbe5e5..8d0a92a4107cb9d0076a478ce56247999e6ee2f1 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -59,7 +59,7 @@ virStorageBackendMpathUpdateVolTargetInfo(virStorageVolTargetPtr target, capacity) < 0) goto out; - if (virStorageBackendUpdateVolTargetFormatFD(target, fd) < 0) + if (virStorageBackendDetectBlockVolFormatFD(target, fd) < 0) goto out; ret = 0; diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index cd01f933c3afb75b199122cade98d63eaeb53bb6..40f4fd83cab0c16b5a7e81e8fc9d9c14619cb02b 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -135,10 +135,7 @@ virStorageBackendSCSIUpdateVolTargetInfo(virStorageVolTargetPtr target, unsigned long long *allocation, unsigned long long *capacity) { - int fd, i, ret = -1; - off_t start; - unsigned char buffer[1024]; - ssize_t bytes; + int fd, ret = -1; if ((fd = open(target->path, O_RDONLY)) < 0) { virReportSystemError(errno, @@ -153,33 +150,8 @@ virStorageBackendSCSIUpdateVolTargetInfo(virStorageVolTargetPtr target, capacity) < 0) goto cleanup; - /* make sure to set the target format "unknown" to begin with */ - target->format = VIR_STORAGE_POOL_DISK_UNKNOWN; - - start = lseek(fd, 0, SEEK_SET); - if (start < 0) { - virReportSystemError(errno, - _("cannot seek to beginning of file '%s'"), - target->path); - goto cleanup; - } - bytes = saferead(fd, buffer, sizeof(buffer)); - if (bytes < 0) { - virReportSystemError(errno, - _("cannot read beginning of file '%s'"), - target->path); + if (virStorageBackendDetectBlockVolFormatFD(target, fd) < 0) goto cleanup; - } - - for (i = 0; disk_types[i].part_table_type != -1; i++) { - if (disk_types[i].offset + disk_types[i].length > bytes) - continue; - if (memcmp(buffer+disk_types[i].offset, &disk_types[i].magic, - disk_types[i].length) == 0) { - target->format = disk_types[i].part_table_type; - break; - } - } ret = 0;