summaryrefslogtreecommitdiff
path: root/diskio.cc
diff options
context:
space:
mode:
authorsrs5694 <srs5694@users.sourceforge.net>2010-03-21 19:05:49 -0400
committersrs5694 <srs5694@users.sourceforge.net>2010-03-21 19:05:49 -0400
commit8a4ddfc919d5569c68489cf53d9cf5abc94c410c (patch)
tree7ed961f3d10386b896570c185ec3b21d3b4a53ab /diskio.cc
parenta8582cfe6c1aa5e5f80458ac72d881a04ae0ba44 (diff)
downloadsgdisk-8a4ddfc919d5569c68489cf53d9cf5abc94c410c.tar.gz
Bring git up to 0.6.6 release version.
Diffstat (limited to 'diskio.cc')
-rw-r--r--diskio.cc72
1 files changed, 0 insertions, 72 deletions
diff --git a/diskio.cc b/diskio.cc
index d9004f7..d433d3d 100644
--- a/diskio.cc
+++ b/diskio.cc
@@ -87,75 +87,3 @@ int DiskIO::OpenForWrite(const string & filename) {
} // if/else
return retval;
} // DiskIO::OpenForWrite(string filename)
-
-// My original FindAlignment() function (after this one) isn't working, since
-// the BLKPBSZGET ioctl() isn't doing what I expected (it returns 512 even on
-// a WD Advanced Format drive). Therefore, I'm using a simpler function that
-// returns 1-sector alignment for unusual sector sizes and drives smaller than
-// a size defined by SMALLEST_ADVANCED_FORMAT, and 8-sector alignment for
-// larger drives with 512-byte sectors.
-uint32_t DiskIO::FindAlignment(void) {
- int err;
- uint32_t result;
-
- if ((GetBlockSize() == 512) && (DiskSize(&err) >= SMALLEST_ADVANCED_FORMAT)) {
- result = DEFAULT_ALIGNMENT; // play it safe; align for 4096-byte sectors
- } else {
- result = 1; // unusual sector size; assume it's the real physical size
- } // if/else
- return result;
-} // DiskIO::FindAlignment
-
-// Return the partition alignment value in sectors. Right now this works
-// only for Linux 2.6.32 and later, since I can't find equivalent ioctl()s
-// for OS X or FreeBSD, and the Linux ioctl is new
-/* int DiskIO::FindAlignment(int fd) {
- int err = -2, errnum = 0, result = 8, physicalSectorSize = 4096;
- uint64_t diskSize;
-
-#if defined (__linux__) && defined (BLKPBSZGET)
- err = ioctl(fd, BLKPBSZGET, &physicalSectorSize);
- cout << "In FindAlignment(), physicalSectorSize = " << physicalSectorSize
- << ", err = " << err << "\n";
-#else
- err = -1;
-#endif
-
- if (err < 0) { // ioctl didn't work; have to guess....
- if (GetBlockSize(fd) == 512) {
- result = 8; // play it safe; align for 4096-byte sectors
-} else {
- result = 1; // unusual sector size; assume it's the real physical size
-} // if/else
-} else { // ioctl worked; compute alignment
- result = physicalSectorSize / GetBlockSize(fd);
- // Disks with larger physical than logical sectors must theoretically
- // have a total disk size that's a multiple of the physical sector
- // size; however, some such disks have compatibility jumper settings
- // meant for one-partition MBR setups, and these reduce the total
- // number of sectors by 1. If such a setting is used, it'll result
- // in improper alignment, so look for this condition and warn the
- // user if it's found....
- diskSize = disksize(fd, &errnum);
- if ((diskSize % (uint64_t) result) != 0) {
- fprintf(stderr, "\aWarning! Disk size (%I64u) is not a multiple of alignment\n"
- "size (%d), but it should be! Check disk manual and jumper settings!\n",
- (unsigned long long) diskSize, result);
-} // if
-} // if/else
- if (result <= 0) // can happen if physical sector size < logical sector size
- result = 1;
- return result;
-} // DiskIO::FindAlignment(int) */
-
-// The same as FindAlignment(int), but opens and closes a device by filename
-int DiskIO::FindAlignment(const string & filename) {
- int retval = 1;
-
- if (!isOpen)
- OpenForRead(filename);
- if (isOpen) {
- retval = FindAlignment();
- } // if
- return retval;
-} // DiskIO::FindAlignment(char)