diff options
-rw-r--r-- | NEWS | 11 | ||||
-rw-r--r-- | diskio-unix.cc | 13 | ||||
-rw-r--r-- | diskio-windows.cc | 2 | ||||
-rw-r--r-- | diskio.cc | 1 | ||||
-rw-r--r-- | diskio.h | 2 | ||||
-rw-r--r-- | gpt.cc | 7 | ||||
-rw-r--r-- | support.h | 2 |
7 files changed, 32 insertions, 6 deletions
@@ -1,11 +1,18 @@ -1.0.2 (?/??/2017): +1.0.2 (7/26/2017): ------------------ +- On Linux, the p/-p/--print command now shows the disk's model name, as + reported in /sys/block/sda/device/model (or equivalent filenames for other + disks). This feature does not yet work on other platforms, on which the + model name line is omitted from the output. This line is also not shown + when accessing disk image files, even on Linux. + - GPT fdisk can now report both the physical and logical sector sizes of disks, but only on 2.6.32 and later Linux kernels. The verify feature now uses the larger of the set alignment and physical/logical block sizes for testing alignment, and setting alignment to something other than an exact - multiple of the physical/logical block size results in a warning. + multiple of the ratio of the physical to logical block size results in a + warning. - Addition of new verification checks, mostly (but not exclusively) related to the new j/-j/--move-main-table option. diff --git a/diskio-unix.cc b/diskio-unix.cc index a7c4724..d9f8b8d 100644 --- a/diskio-unix.cc +++ b/diskio-unix.cc @@ -30,6 +30,8 @@ #endif #include <iostream> +#include <fstream> +#include <sstream> #include "diskio.h" @@ -66,6 +68,7 @@ int DiskIO::OpenForRead(void) { cerr << "The specified file does not exist!\n"; realFilename = ""; userFilename = ""; + modelName = ""; isOpen = 0; openForWrite = 0; } else { @@ -86,6 +89,16 @@ int DiskIO::OpenForRead(void) { else isOpen = 1; } // if (fstat64()...) +#if defined(__linux__) && !defined(EFI) + if (isOpen && realFilename.substr(0,4) == "/dev") { + ostringstream modelNameFilename; + modelNameFilename << "/sys/block" << realFilename.substr(4,512) << "/device/model"; + ifstream modelNameFile(modelNameFilename.str().c_str()); + if (modelNameFile.is_open()) { + getline(modelNameFile, modelName); + } // if + } // if +#endif } // if/else } // if diff --git a/diskio-windows.cc b/diskio-windows.cc index 9cff0d7..80cd7f2 100644 --- a/diskio-windows.cc +++ b/diskio-windows.cc @@ -147,7 +147,7 @@ int DiskIO::GetBlockSize(void) { // In theory, returns the physical block size. In practice, this is only // supported in Linux, as of yet. // TODO: Get this working in Windows. -int DiskIO:GetPhysBlockSize(void) { +int DiskIO::GetPhysBlockSize(void) { return 0; } // DiskIO::GetPhysBlockSize() @@ -41,6 +41,7 @@ using namespace std; DiskIO::DiskIO(void) { userFilename = ""; realFilename = ""; + modelName = ""; isOpen = 0; openForWrite = 0; } // constructor @@ -49,6 +49,7 @@ class DiskIO { protected: string userFilename; string realFilename; + string modelName; int isOpen; int openForWrite; #ifdef _WIN32 @@ -72,6 +73,7 @@ class DiskIO { int DiskSync(void); // resync disk caches to use new partitions int GetBlockSize(void); int GetPhysBlockSize(void); + string GetModel(void) {return modelName;} uint32_t GetNumHeads(void); uint32_t GetNumSecsPerTrack(void); int IsOpen(void) {return isOpen;} @@ -1486,9 +1486,12 @@ void GPTData::DisplayGPTData(void) { cout << "Disk " << device << ": " << diskSize << " sectors, " << BytesToIeee(diskSize, blockSize) << "\n"; - cout << "Logical sector size: " << blockSize << " bytes\n"; + if (myDisk.GetModel() != "") + cout << "Model: " << myDisk.GetModel() << "\n"; if (physBlockSize > 0) - cout << "Physical sector size: " << physBlockSize << " bytes\n"; + cout << "Sector size (logical/physical): " << blockSize << "/" << physBlockSize << " bytes\n"; + else + cout << "Sector size (logical): " << blockSize << " bytes\n"; cout << "Disk identifier (GUID): " << mainHeader.diskGUID << "\n"; cout << "Partition table holds up to " << numParts << " entries\n"; cout << "Main partition table begins at sector " << mainHeader.partitionEntriesLBA @@ -8,7 +8,7 @@ #ifndef __GPTSUPPORT #define __GPTSUPPORT -#define GPTFDISK_VERSION "1.0.1.1" +#define GPTFDISK_VERSION "1.0.2" #if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__) // Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64 |