History log of /haiku/src/system/kernel/disk_device_manager/KDiskDevice.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>


# 9b72c3a0 11-Jul-2019 Simon South <simon@simonsouth.net>

kernel: Specify buffer size in certain ioctl calls.

In cases where scsi_periph checks the size of the buffer supplied to an
ioctl call (functionality added in commit ff4af513e1) this information
needs to be provided by the caller to avoid failure.

Fixes #15094.

Change-Id: I37f2776edbe977e9825ec1837fb763a3b2aa7220
Reviewed-on: https://review.haiku-os.org/c/1584
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# da8f9c86 06-Jan-2018 Jérôme Duval <jerome.duval@gmail.com>

kernel: disk_device_manager: no return in method returning void


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

More 64-bit compilation/safety fixes.


# 51d76425 13-Jan-2011 Axel Dörfler <axeld@pinc-software.de>

* Added a new B_GET_DEVICE_NAME ioctl - this should be implemented by all
drivers in the future, such that NetworkStatus and similar software can show
nice names for the devices. The device manager should implement this and
return the B_DEVICE_PRETTY_NAME of the device (and in turn, new style drivers
should actually set this).
* Implemented handling of this ioctl in the scsi_periph to return the vendor/
product strings.
* Implemented this in the ATA bus manager to return the model from the info
block.
* KDiskDevice now fills in the partition_data::name if the B_GET_DEVICE_NAME
succeeds.
* As a side effect, at least BootManager now shows the drive name; maybe
DriveSetup does as well for the raw device.


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


# b16710b8 12-Jan-2011 Axel Dörfler <axeld@pinc-software.de>

* Replaced one occurence of sprintf() with snprintf().
* Minor cleanup.


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


# 3066f3db 15-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Reverted r33547, this closes bug #4782 - this is obviously a regression in
GCC4.
* Adapted code accordingly.


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


# b74a0983 12-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Got rid of the duplicated functionalities provided by RWLocker.cpp, and
Locker.cpp.
* The services are now using recursive_locks, and rw_locks instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33548 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


# ecb3d008 12-Oct-2008 Michael Lotz <mmlr@mlotz.ch>

If a device reports no media is present, don't try to get the geometry anyway.
This confused some USB card readers, that would stop working if you still
requested the geometry when they reported no media.
Note the case that the B_GET_MEDIA_STATUS fails (because it's not implemented or
an error occured) is still handeld in _GetMediaStatus() and then we still try to
get the geometry to check for media presence.
This should fix that some USB card readers wouldn't work and should also remove
the wrongly reported size in DriveSetup for CD drives that don't actually contain
a media.


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


# 73339925 12-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

On a media change, the KDiskDevice must do a bit more than it did:
* it now updates the partition data,
* the flags,
* and the disk geometry - and that now allows the session add-on to actually
detect a newly inserted CD.


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


# 88ef4111 12-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Added an UninitializeMedia() method to KDiskDevice that also resets the
device geometry.
* If SetTo() reports no media, and GetGeometry() fails, the device geometry
is now reset as well.
* KDiskDeviceManager::_ScanPartition() no longer unmarks the partition busy;
this is now done by the caller, and done independently from the outcome of
_ScanPartition(). This also fixes the problem that devices with no media
were never marked unbusy (and thus were ignored subsequently).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22912 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


# e544dd59 19-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* Fixed a possible dead lock between the kernel daemon and the DDM; the media
status checker now only tries to lock the manager, it won't wait anymore.
* Added MediaChanged() and UpdateMediaStatusIfNeeded() methods to KDiskDevice.
* KDiskDeviceManager::_CheckMediaStatus() now uses these new methods; it should
no longer detect removed media more than once :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22621 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


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

More 64-bit compilation/safety fixes.


# 51d76425033b27609fb4e206c7c9610cd4c4a653 13-Jan-2011 Axel Dörfler <axeld@pinc-software.de>

* Added a new B_GET_DEVICE_NAME ioctl - this should be implemented by all
drivers in the future, such that NetworkStatus and similar software can show
nice names for the devices. The device manager should implement this and
return the B_DEVICE_PRETTY_NAME of the device (and in turn, new style drivers
should actually set this).
* Implemented handling of this ioctl in the scsi_periph to return the vendor/
product strings.
* Implemented this in the ATA bus manager to return the model from the info
block.
* KDiskDevice now fills in the partition_data::name if the B_GET_DEVICE_NAME
succeeds.
* As a side effect, at least BootManager now shows the drive name; maybe
DriveSetup does as well for the raw device.


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


# b16710b81407bd06046b482304a1f701ead12d9a 12-Jan-2011 Axel Dörfler <axeld@pinc-software.de>

* Replaced one occurence of sprintf() with snprintf().
* Minor cleanup.


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


# 3066f3dbf87e3b5a9ea12f7e81ded55f6d6f2bd9 15-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Reverted r33547, this closes bug #4782 - this is obviously a regression in
GCC4.
* Adapted code accordingly.


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


# b74a098352bb66534c12aafafff5ce813fbf905b 12-Oct-2009 Axel Dörfler <axeld@pinc-software.de>

* Got rid of the duplicated functionalities provided by RWLocker.cpp, and
Locker.cpp.
* The services are now using recursive_locks, and rw_locks instead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33548 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


# ecb3d008d625d9657d492978d1053ad6e31a01ee 12-Oct-2008 Michael Lotz <mmlr@mlotz.ch>

If a device reports no media is present, don't try to get the geometry anyway.
This confused some USB card readers, that would stop working if you still
requested the geometry when they reported no media.
Note the case that the B_GET_MEDIA_STATUS fails (because it's not implemented or
an error occured) is still handeld in _GetMediaStatus() and then we still try to
get the geometry to check for media presence.
This should fix that some USB card readers wouldn't work and should also remove
the wrongly reported size in DriveSetup for CD drives that don't actually contain
a media.


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


# 7333992516c6e0e1c62c0fce64863392013507cd 12-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

On a media change, the KDiskDevice must do a bit more than it did:
* it now updates the partition data,
* the flags,
* and the disk geometry - and that now allows the session add-on to actually
detect a newly inserted CD.


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


# 88ef41115466c4ee4900a270ebd5dcdd1be6f730 12-Nov-2007 Axel Dörfler <axeld@pinc-software.de>

* Added an UninitializeMedia() method to KDiskDevice that also resets the
device geometry.
* If SetTo() reports no media, and GetGeometry() fails, the device geometry
is now reset as well.
* KDiskDeviceManager::_ScanPartition() no longer unmarks the partition busy;
this is now done by the caller, and done independently from the outcome of
_ScanPartition(). This also fixes the problem that devices with no media
were never marked unbusy (and thus were ignored subsequently).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22912 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


# e544dd59154d2d123ec74c778176bdb995ae7f08 19-Oct-2007 Axel Dörfler <axeld@pinc-software.de>

* Fixed a possible dead lock between the kernel daemon and the DDM; the media
status checker now only tries to lock the manager, it won't wait anymore.
* Added MediaChanged() and UpdateMediaStatusIfNeeded() methods to KDiskDevice.
* KDiskDeviceManager::_CheckMediaStatus() now uses these new methods; it should
no longer detect removed media more than once :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22621 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