History log of /haiku/src/system/kernel/disk_device_manager/KPartition.cpp
Revision Date Author Comments
# 688acf41 15-Sep-2022 Jérôme Duval <jerome.duval@gmail.com>

add physical_block_size field where applicable

only scsi_disk checks the actual value, other drivers take the logical block size.

This change reports the physical block size from the disk rather than the block
size used by IDE/SATA/SCSI commands. On typical modern SATA disks, the SATA
commands will use 512 byte blocks, but the disk will actually read and write
4K blocks internally. This is only of importance for partition alignment for DriveSetup,
and is independant of file systems or partitioning systems. This could also influence
the recommended block size for some file systems.

Change-Id: Id0f2e22659e89fcef64c1f8d04f81cd68995e01f
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5667
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>


# 4ed39e6a 28-Oct-2014 Adrien Destugues <pulkomandy@gmail.com>

disk device manager: check that partitions are unmounted before uninitializing.

when uninitializing a partition or a disk (removing the partition
table), check that all partitions from that table are unmounted, as they
are about to become invalid.

Fixes #8827.


# 294711f9 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changed {,u}int64 to be long rather than long long on x86_64.


# 4be4fc6b 15-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

More 64-bit compilation/safety fixes.


# 29aa1beb 09-Jan-2010 Michael Lotz <mmlr@mlotz.ch>

Add missing error return.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34970 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 14429e89 08-Jan-2010 Michael Lotz <mmlr@mlotz.ch>

Reverted the part of r31520 that made devfs_unpublish_partition() take a raw
device path + child partition name. When a "raw" device is unpublished the node
removal notification triggers the partition and child partitions to be
unpublished/removed. Since in that case the "raw" node is already unpublished
trying to resolve it in devfs_unpublish_partition() again to unpublish the child
partitions would fail, leaving the child partition nodes behind. When a new raw
device would then become available publishing its partitions would fail because
of these left behind nodes, causing bug #4587. Seeing that this code is more
compact and straight forward anyway I don't quite see why it was changed in the
first place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34967 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7945b229 01-Sep-2009 Axel Dörfler <axeld@pinc-software.de>

* Quick fix to send notifications on mount/unmount/initialize.
* This closes #2081.

+alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32891 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a2bb3414 01-Sep-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.

+ alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32890 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a365e1cf 11-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Patch by Bryce Groff, some changes by myself:
* devfs:
- devfs_[un]publish_partition(): They no longer get the partition path as
parameter, but rather the device path and the partition name.
- Added devfs_rename_partition(), which renames an already published
partition node.
* KPartition/KDiskDevice:
- Replaced the fPublished flag by fPublishedName, the name under which the
partition is published. This simplifies UnpublishDevice() and makes it
practically infallible.
- Added GetFileName(), which only returns the partition's file name.
Simplified GetPath() by using it.
- When a partition is added/removed the subsequent sibling partitions get a
new index. Now we also rename their published device nodes (and those of
their descendents). When something goes wrong we unpublish the concerned
partition's device to be on the safe side. Would be a shame to accidentally
format the wrong partition, eh? :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31520 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1cc5e469 08-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added offset and size parameters to create_child_partition() and
KPartition::CreateChild(). CreateChild() calls AddChild(), which publishes
the new partition, though at that point offset and size were not set, so that
the published devices would not be usable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31463 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4dceabd7 07-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Publish the newly added child partition, not the (already published) parent
partition.
* Don't fail, if publishing failed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31460 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34bc7f03 07-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Patch by Bryce Groff:
* SetBusy(): Use AddFlags() instead of SetFlags() so that the other flags
aren't cleared.
* AddChild(): Publish the newly added child partition. Otherwise no-one can do
anything with it without rebooting first. Other children may need to be
republished under a new name, if their index changes, which doesn't happen
yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31444 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8531599a 30-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* KDiskDeviceManager::RescanDiskSystems() now also rescans all partitions with
the newly found disk systems.
* _ScanPartition() now allows to restrict the disk systems to a predefined set.
* _ScanPartition() now even scans partitions that already have a disk system
assigned; if a better one is found, the existing one is replaced. It will
ignore mounted or partitions with children, though.
* KPartition now also stores the priority of the disk system assigned to it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26177 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0b26e0b1 06-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* When removing a media, only the device was unmounted if needed, not its child partitions.
Not sure if this is the right place, Ingo might want to review that one.
* This fixes unmounting sessions of a multi-session CD, ie. the BeOS CD (it currently panics
when trying to access a device that's not there anymore - for debugging only, of course :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23894 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b3a5629b 12-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
* Unmount when uninitializing a partition.
* Finished the media checker implementation, i.e. we rescan when a media
was inserted and uninitialize when ejected.
* Turned the disk device media checker from a kernel daemon into a thread.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22909 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2128ea4f 04-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added IsBusy(bool) version, which optionally also checks the
descendants.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22831 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53715fe0 01-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Got rid of the B_PARTITION_DESCENDANT_BUSY flag.
* Added CheckAndMarkBusy() and UnmarkBusy() methods to KPartition.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22801 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8354dac7 01-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Folded KPhysicalPartition into KPartition. Removed the notion of shadow
partitions from the disk device manager.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22800 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf95c9ae 07-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* The shadow_changed() FS and partitioning system hooks take an
additional partition_data* child parameter now.
* _user_get_partitionable_spaces() doesn't need to copy the buffer into
the kernel, since it is no input parameter. It also copies back the
actual partitionable spaces count on error, now -- B_BUFFER_OVERFLOW
is returned when the buffer was too small, but then the count must be
returned too.
* Fixed several instances of syscall implementations that unloaded a disk
system, although they didn't load it in the first place. This screwed
up the load count with undesirable consequences.
* _user_create_child_partition() would set the size to the supplied
offset.
* Fixed broken loop in KPhysicalPartition::CreateShadowPartition().
* KPartition::RemoveChild() notified the listeners about the wrong
event.
* Intel partitioning module:
- The *_get_partitionable_spaces() correctly return B_BUFFER_OVERFLOW
now, if the supplied buffer is too small.
- Implemented a part of pm_shadow_changed(), which creates and updates
the PartitionMap, so that the validate_*() hooks have a chance to
work at all.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22475 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6b6f6b72 06-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Partitions do now know whether they have already been published and
avoid attempts to publish a second time.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22198 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d690920 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed system/core to system/kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12360 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4ed39e6a62d82721004656c5a1ecf19cb8e73e75 28-Oct-2014 Adrien Destugues <pulkomandy@gmail.com>

disk device manager: check that partitions are unmounted before uninitializing.

when uninitializing a partition or a disk (removing the partition
table), check that all partitions from that table are unmounted, as they
are about to become invalid.

Fixes #8827.


# 294711f98c107cf2d9d05b7fc34cd863e87bd358 27-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

Changed {,u}int64 to be long rather than long long on x86_64.


# 4be4fc6b1faddbd037146214a0011d320842b4f3 15-Jun-2012 Alex Smith <alex@alex-smith.me.uk>

More 64-bit compilation/safety fixes.


# 29aa1bebefbd3aed14396011c3266234e37af3b6 09-Jan-2010 Michael Lotz <mmlr@mlotz.ch>

Add missing error return.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34970 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 14429e896e713224e2c0773523ef3c132df02c0d 08-Jan-2010 Michael Lotz <mmlr@mlotz.ch>

Reverted the part of r31520 that made devfs_unpublish_partition() take a raw
device path + child partition name. When a "raw" device is unpublished the node
removal notification triggers the partition and child partitions to be
unpublished/removed. Since in that case the "raw" node is already unpublished
trying to resolve it in devfs_unpublish_partition() again to unpublish the child
partitions would fail, leaving the child partition nodes behind. When a new raw
device would then become available publishing its partitions would fail because
of these left behind nodes, causing bug #4587. Seeing that this code is more
compact and straight forward anyway I don't quite see why it was changed in the
first place.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34967 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 7945b229623f7d10bb55c4f318f0b0816e30332d 01-Sep-2009 Axel Dörfler <axeld@pinc-software.de>

* Quick fix to send notifications on mount/unmount/initialize.
* This closes #2081.

+alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32891 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a2bb34144733cba83af0ebd940df23802af2f237 01-Sep-2009 Axel Dörfler <axeld@pinc-software.de>

* Cleanup, no functional change.

+ alphabranch


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32890 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a365e1cfbb80d7d2ee91e6515fa7090906cd5a4e 11-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Patch by Bryce Groff, some changes by myself:
* devfs:
- devfs_[un]publish_partition(): They no longer get the partition path as
parameter, but rather the device path and the partition name.
- Added devfs_rename_partition(), which renames an already published
partition node.
* KPartition/KDiskDevice:
- Replaced the fPublished flag by fPublishedName, the name under which the
partition is published. This simplifies UnpublishDevice() and makes it
practically infallible.
- Added GetFileName(), which only returns the partition's file name.
Simplified GetPath() by using it.
- When a partition is added/removed the subsequent sibling partitions get a
new index. Now we also rename their published device nodes (and those of
their descendents). When something goes wrong we unpublish the concerned
partition's device to be on the safe side. Would be a shame to accidentally
format the wrong partition, eh? :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31520 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 1cc5e46925a7e64708d7565fe2c1ac3f448c9d58 08-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Added offset and size parameters to create_child_partition() and
KPartition::CreateChild(). CreateChild() calls AddChild(), which publishes
the new partition, though at that point offset and size were not set, so that
the published devices would not be usable.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31463 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4dceabd7074518143a82e950d2027afd82b30a98 07-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

* Publish the newly added child partition, not the (already published) parent
partition.
* Don't fail, if publishing failed.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31460 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 34bc7f03ed6f30ee840524c5b7b8f20ac91d9ade 07-Jul-2009 Ingo Weinhold <ingo_weinhold@gmx.de>

Patch by Bryce Groff:
* SetBusy(): Use AddFlags() instead of SetFlags() so that the other flags
aren't cleared.
* AddChild(): Publish the newly added child partition. Otherwise no-one can do
anything with it without rebooting first. Other children may need to be
republished under a new name, if their index changes, which doesn't happen
yet.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31444 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8531599a27883696031d0ab3358dc3e78a3b29ce 30-Jun-2008 Axel Dörfler <axeld@pinc-software.de>

* KDiskDeviceManager::RescanDiskSystems() now also rescans all partitions with
the newly found disk systems.
* _ScanPartition() now allows to restrict the disk systems to a predefined set.
* _ScanPartition() now even scans partitions that already have a disk system
assigned; if a better one is found, the existing one is replaced. It will
ignore mounted or partitions with children, though.
* KPartition now also stores the priority of the disk system assigned to it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26177 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 0b26e0b1d457a46c70e64a27713270fa6790e7bd 06-Feb-2008 Axel Dörfler <axeld@pinc-software.de>

* When removing a media, only the device was unmounted if needed, not its child partitions.
Not sure if this is the right place, Ingo might want to review that one.
* This fixes unmounting sessions of a multi-session CD, ie. the BeOS CD (it currently panics
when trying to access a device that's not there anymore - for debugging only, of course :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23894 a95241bf-73f2-0310-859d-f6bbb57e9c96


# b3a5629b9ed3f11caee172635987ea531ae73d35 12-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
* Unmount when uninitializing a partition.
* Finished the media checker implementation, i.e. we rescan when a media
was inserted and uninitialize when ejected.
* Turned the disk device media checker from a kernel daemon into a thread.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22909 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2128ea4f31e90c6ee53abab1637540b81a3e381a 04-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Added IsBusy(bool) version, which optionally also checks the
descendants.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22831 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 53715fe060e108eb46185d16a710bce4f0cbaa61 01-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* Got rid of the B_PARTITION_DESCENDANT_BUSY flag.
* Added CheckAndMarkBusy() and UnmarkBusy() methods to KPartition.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22801 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 8354dac78e2ce5da2e5ee1826c37dbc12cacbd18 01-Nov-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Folded KPhysicalPartition into KPartition. Removed the notion of shadow
partitions from the disk device manager.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22800 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf95c9aee6c36516e5e98a4f8953659c402bbf74 07-Oct-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

* The shadow_changed() FS and partitioning system hooks take an
additional partition_data* child parameter now.
* _user_get_partitionable_spaces() doesn't need to copy the buffer into
the kernel, since it is no input parameter. It also copies back the
actual partitionable spaces count on error, now -- B_BUFFER_OVERFLOW
is returned when the buffer was too small, but then the count must be
returned too.
* Fixed several instances of syscall implementations that unloaded a disk
system, although they didn't load it in the first place. This screwed
up the load count with undesirable consequences.
* _user_create_child_partition() would set the size to the supplied
offset.
* Fixed broken loop in KPhysicalPartition::CreateShadowPartition().
* KPartition::RemoveChild() notified the listeners about the wrong
event.
* Intel partitioning module:
- The *_get_partitionable_spaces() correctly return B_BUFFER_OVERFLOW
now, if the supplied buffer is too small.
- Implemented a part of pm_shadow_changed(), which creates and updates
the PartitionMap, so that the validate_*() hooks have a chance to
work at all.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22475 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6b6f6b7240b30efa3f52b6c4a93e63e049ba5508 06-Sep-2007 Ingo Weinhold <ingo_weinhold@gmx.de>

Partitions do now know whether they have already been published and
avoid attempts to publish a second time.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22198 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2d690920ac4d0cd27eb3c118fb2b0862615869e0 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed system/core to system/kernel.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12360 a95241bf-73f2-0310-859d-f6bbb57e9c96