Opened 12 years ago
Closed 12 years ago
#9012 closed enhancement (fixed)
Add disk device name
Reported by: | dsjonny | Owned by: | stippi |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | Applications/DriveSetup | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
It would be usefull if in the DriveSetup application the user can see the device's name too. Like in the BootManager application. So, if the user has more than one disk drive, than maybe it is not easy to identify those by the path (like /dev/disk/scsi/...). But if the user can see the disk's name too (like SAMSUNG SSD 830).
For example: /dev/disk/scsi/0/5/0/raw - SAMSUNG SSD 830 64GB ... /dev/disk/usb/0/0/raw - KINGSTON DataTraveller 8GB ...
Attachments (7)
Change History (19)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Version: | R1/alpha3 → R1/Development |
---|
comment:3 by , 12 years ago
And the device's flags (as the df's output) also can be usefull in the DriveSetup window.
comment:4 by , 12 years ago
A have tried it myself:
PartitionList.cpp
#include <USBKit.h> ... PartitionListRow::PartitionListRow(BPartition* partition) ... if (partition->IsDevice()) { if (partition->Name() != NULL && partition->Name()[0]) SetField(new BStringField(partition->Name()), kVolumeNameColumn); else if (strstr(path.Path(), "usb") != NULL) SetField(new BStringField(BUSBDevice(path.Path()).ProductString()), kVolumeNameColumn); else SetField(new BStringField(B_TRANSLATE_COMMENT("Hard Drive", "Default disk name")), kVolumeNameColumn); } ...
I have included the USBKit.h and added the other lines after line 231. I got this:
Unfortunatelly I cannot get the USB device's ProductString(), because I cannot get the bus path for the device.
by , 12 years ago
comment:5 by , 12 years ago
For the USB disk handling this is not the way to go, as you can't possibly map the usb_disk path to the usb_raw path (as you already figured out).
The "KINGSTON SMS..." name of the disk comes from the disk device manager and it in turn gets it from the scsi_periph driver via B_GET_DEVICE_NAME. To get the same for USB devices, one only needs to implement this ioctl in usb_disk to return the vendor/product strings. As that is pretty straight forward, I've implemented it in hrev44920. You should therefore not have to handle USB disks in a special way.
follow-up: 7 comment:6 by , 12 years ago
Thank you! This works fine, and not not only for the DriveSetup, but for the BootManager too.
I have changed this in the source: DiskView.cpp at line 203
virtual bool Visit(BDiskDevice* device) { if (device->Name() != NULL && device->Name()[0]) { PartitionView* view = new PartitionView(device->Name(), 1.0, device->Offset(), 0, device->ID()); fViewMap.Put(device->ID(), view); fView->GetLayout()->AddView(view); _AddSpaces(device, view); } else { PartitionView* view = new PartitionView(B_TRANSLATE("Device"), 1.0, device->Offset(), 0, device->ID()); fViewMap.Put(device->ID(), view); fView->GetLayout()->AddView(view); _AddSpaces(device, view); } return false; }
PartitionList.cpp at line 237
if (partition->IsDevice()) { if (partition->Name() != NULL && partition->Name()[0]) SetField(new BStringField(partition->Name()), kVolumeNameColumn); }
But there is another problem: I have change the SATA type to AHCI from IDE in the BIOS, and the device name's chars are "randomized". For USB device that is still correct. Can you fix it?
by , 12 years ago
by , 12 years ago
follow-up: 11 comment:7 by , 12 years ago
Replying to dsjonny:
Thank you! This works fine, and not not only for the DriveSetup, but for the BootManager too.
Yes that was expected, as they use the same interface.
I have changed this in the source:
Please make a patch, ideally using git format-patch with a proper commit message. See SubmittingPatches for further hints.
But there is another problem: I have change the SATA type to AHCI from IDE in the BIOS, and the device name's chars are "randomized". For USB device that is still correct. Can you fix it?
by , 12 years ago
Attachment: | 0001-Added-disk-device-s-name.patch added |
---|
comment:9 by , 12 years ago
Thanks for the patch, dsjonny -- as you might have noticed already, a part of it made it into hrev44929 by accident. That part of your original patch was not correct, as you would have overwritten the actual volume in case the raw device contained a file system directly.
Also, the '{' go to the end of the line, not in a new line. It's always a good idea not to let your code additions stick out in any way. It's an even better idea to read our coding style guide, though, and make your code follow that one :-)
Anyway, the other part of your patch duplicates a lot of lines that shouldn't be duplicated: only the name changed, the rest of the code stays the same.
Ie. the code could look like this instead:
const char* name; if (partition->Name() != NULL && partition->Name()[0] != '\0') name = partition->Name(); else name = B_TRANSLATE("Device");
comment:10 by , 12 years ago
Sorry for the coding style.
I have changed the code:
DiskView.cpp line 203:
virtual bool Visit(BDiskDevice* device) { > const char* name; > if (device->Name() != NULL && device->Name()[0] != '\0') > name = device->Name(); > else > name = B_TRANSLATE("Device"); > PartitionView* view = new PartitionView(name, 1.0, device->Offset(), 0, device->ID()); fViewMap.Put(device->ID(), view); fView->GetLayout()->AddView(view); _AddSpaces(device, view); return false; }
Thel ines started with ">" are my modification in the code. With these changes the disk device name will shown only on the disk map. So this will not make any problem if we have a raw device with FS (I think).
I also created a new patch for this. I hope this is a usable solution. :)
by , 12 years ago
by , 12 years ago
Attachment: | 0001-Added-disk-name-to-the-DiskView.-The-disk-device-nam.patch added |
---|
comment:11 by , 12 years ago
But there is another problem: I have change the SATA type to AHCI from IDE in the BIOS, and the device name's chars are "randomized". For USB device that is still correct. Can you fix it?
Width the AHCI fix now all of my drive's name shows correct in the DriveSetup in the BootManager and in the Devices too :)
Thank you!
by , 12 years ago
comment:12 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Applied in hrev45190, thanks a lot, and sorry for the delay!
For USB drives the device's strings can be use:
(For example)