diff options
author | srs5694 <srs5694@users.sourceforge.net> | 2009-09-21 20:51:47 -0400 |
---|---|---|
committer | srs5694 <srs5694@users.sourceforge.net> | 2009-09-21 20:51:47 -0400 |
commit | 978041ca613dcb881763b36cf53639d924e52a56 (patch) | |
tree | bcb9e01e2c62812085a7195b0e8cc4bc20cc4c2d /support.cc | |
parent | e35eb1beb6381977ff0dd8443d91f4569779cf2d (diff) | |
download | sgdisk-978041ca613dcb881763b36cf53639d924e52a56.tar.gz |
GPT fdisk 0.5.0
Added several features, including a restructuring of the menu system,
GPT-to-MBR conversion, and the ability to re-read the MBR to generate
a fresh GPT from the current on-disk MBR.
Diffstat (limited to 'support.cc')
-rw-r--r-- | support.cc | 22 |
1 files changed, 7 insertions, 15 deletions
@@ -205,7 +205,9 @@ int GetBlockSize(int fd) { result = SECTOR_SIZE; // ENOTTY = inappropriate ioctl; probably being called on a disk image // file, so don't display the warning message.... - if (errno != ENOTTY) { + // 32-bit code returns EINVAL, I don't know why. I know I'm treading on + // thin ice here, but it should be OK in all but very weird cases.... + if ((errno != ENOTTY) && (errno != EINVAL)) { printf("\aError %d when determining sector size! Setting sector size to %d\n", errno, SECTOR_SIZE); } // if @@ -434,8 +436,9 @@ void DiskSync(int fd) { uint64_t disksize(int fd, int *err) { long sz; // Do not delete; needed for Linux long long b; // Do not delete; needed for Linux - uint64_t sectors = 0, bytes = 0; // size in sectors & bytes - struct stat st; + uint64_t sectors = 0; // size in sectors + off_t bytes = 0; // size in bytes + struct stat64 st; // Note to self: I recall testing a simplified version of // this code, similar to what's in the __APPLE__ block, @@ -462,17 +465,6 @@ uint64_t disksize(int fd, int *err) { sectors = (b >> 9); } // if -// if (*err) { -// sz = 0; -// if (errno != EFBIG) -// return sz; -// } -// *err = ioctl(fd, BLKGETSIZE64, &b); -// if (*err || b == 0 || b == sz) -// sectors = sz; -// else -// sectors = (b >> 9); - #endif #endif @@ -480,7 +472,7 @@ uint64_t disksize(int fd, int *err) { // so let's assume it's a regular file (a QEMU image, dd backup, or // what have you) and see what stat() gives us.... if (sectors == 0) { - if (fstat(fd, &st) == 0) { + if (fstat64(fd, &st) == 0) { bytes = (uint64_t) st.st_size; if ((bytes % UINT64_C(512)) != 0) fprintf(stderr, "Warning: File size is not a multiple of 512 bytes!" |