[prev in list] [next in list] [prev in thread] [next in thread]
List: haiku-commits
Subject: [Haiku-commits] r31332 - haiku/trunk/src/tools/fs_shell
From: axeld at BerliOS <axeld () mail ! berlios ! de>
Date: 2009-06-30 15:16:51
Message-ID: 200906301516.n5UFGplW031340 () sheep ! berlios ! de
[Download RAW message or body]
Author: axeld
Date: 2009-06-30 17:16:50 +0200 (Tue, 30 Jun 2009)
New Revision: 31332
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31332&view=rev
Modified:
haiku/trunk/src/tools/fs_shell/partition_support.cpp
haiku/trunk/src/tools/fs_shell/unistd.cpp
Log:
* The fs_shell is now always using BLKGETSIZE64 on Linux, and only if that fails
it will fall back to HDIO_GETGEO.
* This fixes incorrectly reported disk sizes for a number of disks I have here.
Please open a bug report if this change causes problems for you (we would then
have to check the kernel version to choose the preferred method).
Modified: haiku/trunk/src/tools/fs_shell/partition_support.cpp
===================================================================
--- haiku/trunk/src/tools/fs_shell/partition_support.cpp 2009-06-30 14:35:00 UTC (rev 31331)
+++ haiku/trunk/src/tools/fs_shell/partition_support.cpp 2009-06-30 15:16:50 UTC (rev 31332)
@@ -26,11 +26,12 @@
struct FileRestriction {
FileRestriction(fssh_dev_t device, fssh_ino_t node, fssh_off_t startOffset,
- fssh_off_t endOffset)
- : device(device),
- node(node),
- startOffset(startOffset),
- endOffset(endOffset)
+ fssh_off_t endOffset)
+ :
+ device(device),
+ node(node),
+ startOffset(startOffset),
+ endOffset(endOffset)
{
}
@@ -50,8 +51,7 @@
find_file_restriction(fssh_dev_t device, fssh_ino_t node)
{
for (FileRestrictionList::iterator it = sFileRestrictions.begin();
- it != sFileRestrictions.end();
- ++it) {
+ it != sFileRestrictions.end(); ++it) {
FileRestriction* restriction = *it;
if (restriction->device == device && restriction->node == node)
return restriction;
Modified: haiku/trunk/src/tools/fs_shell/unistd.cpp
===================================================================
--- haiku/trunk/src/tools/fs_shell/unistd.cpp 2009-06-30 14:35:00 UTC (rev 31331)
+++ haiku/trunk/src/tools/fs_shell/unistd.cpp 2009-06-30 15:16:50 UTC (rev 31332)
@@ -164,28 +164,26 @@
error = errno;
#elif defined(HAIKU_HOST_PLATFORM_LINUX)
- struct hd_geometry hdGeometry;
- // BLKGETSIZE and BLKGETSIZE64 don't seem to work for
- // partitions. So we get the device geometry (there only seems
- // to be HDIO_GETGEO, which is kind of obsolete, BTW), and
+ // If BLKGETSIZE64 don't work for us, we will fall back to
+ // HDIO_GETGEO (which is kind of obsolete, BTW), and
// get the partition size via binary search.
- if (ioctl(fd, HDIO_GETGEO, &hdGeometry) == 0) {
- int blockSize = 512;
- if (hdGeometry.heads == 0) {
- off_t size;
- if (ioctl(fd, BLKGETSIZE64, &size) == 0) {
- off_t blocks = size / blockSize;
- uint32_t heads = (blocks + ULONG_MAX - 1)
- / ULONG_MAX;
- if (heads == 0)
- heads = 1;
+ struct hd_geometry hdGeometry;
+ int blockSize = 512;
+ off_t size;
+ if (ioctl(fd, BLKGETSIZE64, &size) == 0 && size > 0) {
+ off_t blocks = size / blockSize;
+ uint32_t heads = (blocks + ULONG_MAX - 1)
+ / ULONG_MAX;
+ if (heads == 0)
+ heads = 1;
- geometry->head_count = heads;
- geometry->cylinder_count = blocks / heads;
- geometry->sectors_per_track = 1;
- error = B_OK;
- } else
- error = errno;
+ geometry->head_count = heads;
+ geometry->cylinder_count = blocks / heads;
+ geometry->sectors_per_track = 1;
+ error = B_OK;
+ } else if (ioctl(fd, HDIO_GETGEO, &hdGeometry) == 0) {
+ if (hdGeometry.heads == 0) {
+ error = B_ERROR;
} else {
off_t bytesPerCylinder = (off_t)hdGeometry.heads
* hdGeometry.sectors * 512;
@@ -240,8 +238,7 @@
disklabel.d_secperunit = mediaSize / disklabel.d_secsize;
disklabel.d_ncylinders = mediaSize / disklabel.d_secsize
- / disklabel.d_nsectors
- / disklabel.d_ntracks;
+ / disklabel.d_nsectors / disklabel.d_ntracks;
geometry->head_count = disklabel.d_ntracks;
geometry->cylinder_count = disklabel.d_ncylinders;
_______________________________________________
Haiku-commits mailing list
Haiku-commits@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/haiku-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic