diff options
author | srs5694 <srs5694@users.sourceforge.net> | 2010-02-19 17:19:55 -0500 |
---|---|---|
committer | srs5694 <srs5694@users.sourceforge.net> | 2010-02-19 17:19:55 -0500 |
commit | 08bb0da07953af605b4918e268272de15ac151aa (patch) | |
tree | 401ff14b62ddfda4c4c64b3dfcee817ad8133971 /diskio-unix.cc | |
parent | fad064250bf6c49eb4966bf0f617591a0821808e (diff) | |
download | sgdisk-08bb0da07953af605b4918e268272de15ac151aa.tar.gz |
Version 0.6.4
Diffstat (limited to 'diskio-unix.cc')
-rw-r--r-- | diskio-unix.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/diskio-unix.cc b/diskio-unix.cc index 00ffd99..e955739 100644 --- a/diskio-unix.cc +++ b/diskio-unix.cc @@ -97,7 +97,8 @@ int DiskIO::OpenForWrite(void) { // so the file can be re-opened without specifying the filename. void DiskIO::Close(void) { if (isOpen) - close(fd); + if (close(fd) < 0) + cerr << "Warning! Problem closing file!\n"; isOpen = 0; openForWrite = 0; } // DiskIO::Close() @@ -117,7 +118,7 @@ int DiskIO::GetBlockSize(void) { #ifdef __APPLE__ err = ioctl(fd, DKIOCGETBLOCKSIZE, &blockSize); #endif -#ifdef __FreeBSD__ +#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) err = ioctl(fd, DIOCGSECTORSIZE, &blockSize); #endif #ifdef __linux__ @@ -161,7 +162,7 @@ void DiskIO::DiskSync(void) { i = ioctl(fd, DKIOCSYNCHRONIZECACHE); platformFound++; #endif -#ifdef __FreeBSD__ +#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) sleep(2); i = ioctl(fd, DIOCGFLUSH); cout << "Warning: The kernel may continue to use old or deleted partitions.\n" @@ -295,8 +296,6 @@ int DiskIO::Write(void* buffer, int numBytes) { // greatly since then to enable FreeBSD and MacOS support, as well as to // return correct values for disk image files. uint64_t DiskIO::DiskSize(int *err) { - long sz; // Do not delete; needed for Linux - long long b; // Do not delete; needed for Linux uint64_t sectors = 0; // size in sectors off_t bytes = 0; // size in bytes struct stat64 st; @@ -317,13 +316,15 @@ uint64_t DiskIO::DiskSize(int *err) { *err = ioctl(fd, DKIOCGETBLOCKCOUNT, §ors); platformFound++; #endif -#ifdef __FreeBSD__ +#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) *err = ioctl(fd, DIOCGMEDIASIZE, &bytes); - b = GetBlockSize(); + long long b = GetBlockSize(); sectors = bytes / b; platformFound++; #endif #ifdef __linux__ + long sz; + long long b; *err = ioctl(fd, BLKGETSIZE, &sz); if (*err) { sectors = sz = 0; |