bootloader: Make Partition::Size return the partition's size.
Partition::ReadAt() and WriteAt() already do bounds-checking based on the size, but Size() was returning the underlying FD size, which might be that of the entire disk, not just this partition. So, move initialization around a bit, and return the actual size. Should fix the bootloader menu displaying the wrong sizes for boot partitions.
This commit is contained in:
@@ -216,11 +216,7 @@ Partition::WriteAt(void *cookie, off_t position, const void *buffer,
|
||||
off_t
|
||||
Partition::Size() const
|
||||
{
|
||||
struct stat stat;
|
||||
if (fstat(fFD, &stat) == B_OK)
|
||||
return stat.st_size;
|
||||
|
||||
return Node::Size();
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
@@ -452,7 +448,10 @@ add_partitions_for(int fd, bool mountFileSystems, bool isBootDevice)
|
||||
|
||||
// set some magic/default values
|
||||
partition->block_size = 512;
|
||||
partition->size = partition->Size();
|
||||
|
||||
struct stat stat;
|
||||
if (fstat(fd, &stat) == B_OK)
|
||||
partition->size = stat.st_size;
|
||||
|
||||
// add this partition to the list of partitions
|
||||
// temporarily for Lookup() to work
|
||||
|
||||
Reference in New Issue
Block a user