[haiku-development] Re: 64 bit problem, boot/loader/partitions.cpp using its pointer as partion id

  • From: Ingo Weinhold <ingo_weinhold@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 07 Sep 2013 19:38:11 +0200

On 09/07/2013 03:54 PM, Fredrik Holmqvist wrote:
In the bootloader we use the pointer to the Partition the partition id
which makes looking up a Partition from id a simple cast. However the
id is 32-bit and from a public header so it doesn't work for 64 bit
bootloaders.

We have a linked list of partitions gPartitions, which gets added /
removed from while scanning and such. Perhaps I can move add / remove
to constructor / destructor of Partition instead and use an atomic
counter for id? Looking up a partition from id would then work by
scanning gPartitions for that id.

To me it even seems to be the proper place for it, but I've just
scanned the code as there are a lot of

   gPartitions.Remove(partition);
   delete partition;

Mmh, I see only two occurrences.

What do you think?

gPartitions doesn't seem to contain all partitions (e.g. not immediately after a create_child_partition()).

Please note that the public C functions are a simplified implementation of the disk device manager API (headers/os/drivers/disk_device_manager.h) and should behave the same way.

Another solution would be a simple lookup table.

Yes, a simple hash table that the Partition constructor and destructor update would work.

CU, Ingo


Other related posts: