Opened 12 years ago

Closed 11 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)

ds.png (36.1 KB ) - added by dsjonny 11 years ago.
ds2.png (37.6 KB ) - added by dsjonny 11 years ago.
bm.png (16.2 KB ) - added by dsjonny 11 years ago.
0001-Added-disk-device-s-name.patch (2.0 KB ) - added by dsjonny 11 years ago.
ds3.png (33.8 KB ) - added by dsjonny 11 years ago.
0001-Added-disk-name-to-the-DiskView.-The-disk-device-nam.patch (1.0 KB ) - added by dsjonny 11 years ago.
bm2.png (17.2 KB ) - added by dsjonny 11 years ago.

Download all attachments as: .zip

Change History (19)

comment:1 by dsjonny, 12 years ago

For USB drives the device's strings can be use:

    Manufacturer String .... "JMicron"
    Product String ......... "Samsung M2 Portable"

(For example)

comment:2 by dsjonny, 11 years ago

Version: R1/alpha3R1/Development

comment:3 by dsjonny, 11 years ago

And the device's flags (as the df's output) also can be usefull in the DriveSetup window.

comment:4 by dsjonny, 11 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 dsjonny, 11 years ago

Attachment: ds.png added

comment:5 by mmlr, 11 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.

comment:6 by dsjonny, 11 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 dsjonny, 11 years ago

Attachment: ds2.png added

by dsjonny, 11 years ago

Attachment: bm.png added

in reply to:  6 ; comment:7 by mmlr, 11 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?

This was #7926, yes. I fixed it in hrev44924.

comment:8 by dsjonny, 11 years ago

I have added the patch for my changes.

comment:9 by axeld, 11 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 dsjonny, 11 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).

This change will affect this:

I also created a new patch for this. I hope this is a usable solution. :)

by dsjonny, 11 years ago

Attachment: ds3.png added

in reply to:  7 comment:11 by dsjonny, 11 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?

This was #7926, yes. I fixed it in hrev44924.

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 dsjonny, 11 years ago

Attachment: bm2.png added

comment:12 by axeld, 11 years ago

Resolution: fixed
Status: newclosed

Applied in hrev45190, thanks a lot, and sorry for the delay!

Note: See TracTickets for help on using tickets.