How to change the icon of a volume/drive?

Is there a way to identify a specific USB port? Do all USB ports on a computer/laptop have specific, static (unchanging) information that can be referenced, or does it change from boot to boot?

Obviously, identifying/using a USB floppy drive (vs USB thumb drives) in Haiku has been somewhat elusive, as I cannot find any posts/tickets stating it works yet. But why? Doesn’t the host (Haiku) just care about the USB side of things and the chip inside the device handles the other end (flash chip/floppy drive)? Or is the “language” of a USB mass storage device (USB thumb drive) different than a USB floppy drive?

If the driver is what tells Tracker what to identify a USB device as, then if a driver were written/modified to assign a specific USB port as a USB floppy (even if it wasn’t), wouldn’t that work? In other words, it looks for a device on a specific USB port and tells Tracker it’s a USB floppy. Tracker is only going to believe what the driver tells it, so if it “lies”, Tracker doesn’t care.

So, assuming this would actually work, you rewrite the USB driver to look out for activity on a specific USB port and it tells Tracker, “it’s a USB floppy” (even though the USB thumb drive tells the driver it’s a mass storage device), while all other USB ports are treated normally.

But that assumes each USB port on a laptop or computer has consistent, identifiable information that can be used to do this.

Tickets confirming that it works? Why would there be tickets when it works?

It worked when I wrote the driâer on the two usb floppy drives I own. Now both drives are broken (due to trying to read old, rotten floppies) and I can’t test it anymore. No one else owns usb floppy drives.

And, yes, they do speak different languages than other usb storage devices, and need different handling. Mainly because floppies are slow, and, ifthey used the same protocol as other mass storage devices, they would block usage of the usb ports by anything else while a floppy operation is running.

Yes, writing a modified driver to send different icons, based on the usb ports or the usb device vendor and product id, is possible. The driver has this information and “just” needs to have and send different icons in different cases.

When I said “tickets to see if it worked”, I meant “closed ticket”, not open, obviously. :grin:

This one, specifically: #9109 (usb_floppy doesn't function and causes kdl when unplugged) – Haiku

So, is your USB Floppy driver still in the current build (R1/Beta4; not nightly)/source tree of Haiku? If I buy one on eBay (I assume ANY one will work, regardless of brand/model) you’re saying it will work? I have floppies I can test it with.

So what unique information am I looking for, per USB port, to identify it? Can I see that under the “Devices” app? Have several USB 2.0 and 3.0 ports on my current PC. I assume that specific, static information is only shown when a USB thumb drive is inserted? Remember, I’m not trying to identify the USB device (I.e. thumb drive), I’m trying to identify the USB port it’s in. That information should remain the same, regardless if you plug in a keyboard, mouse, WiFi dongle, hard drive, thumb drive, etc.

In Windows 11, on my Asus laptop, I have been able to identify each of the three USB-A ports (regardless of device). The USB-A port on the left side of my laptop is Port #0002 Hub #0002. This remains consistent, whether it’s my corded USB trackball or a USB thumb drive attached to it. But I see no easy to identify info in Haiku via “Devices”, like this. Is it worded differently?

Screenshot 2024-07-12 165138

I don’t know is anything is shown in the gui anywhere, but listusb soould give you the usb device path. If you plug different devices to the same port, you will see that at least a part of that path does not change. (I thik it’s something like /dev/usb/… )

The driver is enabled, and any floppy drive should work. But given the low amount of testing (only my two drives and the one in that ticket) and the fact that this all was a while ago, some fixes to the driver may be needed. If you are ready to spend some time taking pictures of KDL and sending them to me, this should be fine, I can try to fix the issues

1 Like

Ok, that helped. Here is a screenshot of my listusb Terminal window. My front USB port is dev/bus/usb/0/3, because it pops up the same every time. And one of my rear USB ports was dev/bus/usb/0/7 with the same device. So, knowing this, how would you alter the USB mass storage driver to report a specific port, like 3 or 7, as something like a USB floppy, instead of a USB thumb drive?

The USB floppy driver expects to report a USB floppy for the icon (as it’s written specifically for that purpose), but aren’t the two drivers similar on the back (USB) end? It’s just the front (device) end that they differ, don’t they? If we simply alter the normal USB mass storage driver to report differently (a different icon) to a device on a specific USB port, wouldn’t that work? It would handle the USB thumb drive exactly the same as any other USB thumb drive, it’s only SAYING it’s a different device, icon-wise, on that specific USB port.

I mean, there’s no sense going down the USB floppy driver road (which I figured we might need to, to get the Tracker to present a USB thumb drive as a USB floppy), if all we need to do is alter the USB mass storage driver to report a specific USB port as something other than a USB thumb drive or other mass storage device. This, obviously, would be a very customized (and otherwise useless to anyone else) version of said driver.

But if we were to modify the USB floppy driver… we have to make it handle a USB thumb drive as usual, which would mean adding code that already exists in the current USB mass storage driver! A waste of effort, when we only want the icon image to be faked (on a specific USB port), but the device handling to be the same.

The functions to change would be B_GET_ICON_NAME and B_GET_VECTOR_ICON in usb_disk.cpp « usb_disk « usb « disk « drivers « kernel « add-ons « src - haiku - Haiku's main repository

You can see the icon is already modified in some cases:

  • If the device is an usb_floppy (checking for is_ufi)
  • If the device is “optical” or a CD (checking the device_type reported by the device)
  • Finally by using “kIconMatches”, which allows to detect some known devices (based on the name reported by the device), and use specific icons for them (this is used mainly for some SD card readers).

This can be extended with additional checks, for example using the usb_device struct available in device->device, I think you can locate the path to the USB device (and thus the corresponging physical USB port).

Ok, after re-reading the ticket, I now realize you merged your floppy driver with usb_disk.cpp, so there is no separate usb_floppy driver anymore. Somehow I didn’t notice that. So, the question is, what area of usb_disk.cpp needs to be amended, to find a specific USB port, and what code needs to be added/changed?

Ahoy @Luposian,

Haiku changes dinamically the numbers in dev paths - especially in case USB - related to where you plug in your USB install drive (where the Live image or the installed Haiku was plugged in.)

Also Haiku does discovering devices at every boot.

The “aasigned” /dev/disk/usb//X are changing, so won’t be the same surely.

I used dd command to create an installer USB drive.
I just plugged in a secondary thumbdrive, replaced a flaky one, into the same USB port, meanwhile I left the usb attached backup/media storage harddisk attached.
I had to do a restart due to the flaky thumbdrive finally. After force reboot and checkfs, I used
dd command
to copy the Live ISO to the secondary thumbdrive,

I had not checked the actual paths, so I got a sorrow and painful lesson - Haiku can give a different or a previously used path for other drive’s drivepath - it does not matter if the same USB port used.
Install drive and the secondary thumbdrive was on the same root hub in the laptop, so the secondary got the backup disk’s drivepath and the backup got the drivepath of the target device of my previous dd command, that I reused in Terminal after the reboot, as I assumed also, that plugged drives, ports and device paths remains.
This way I overwritten the backup drive NTFS partition and now I am waiting to be able to buy a bigger disk to recover the 1.2 - 1.4 TB minus the 1.4 GB of the live image overwritten.

The two functions that I linked in the post right above yours, tha return different icons for different types of devices already.

Ok, I’m trying to make sense of what you said. This is the first area I think you mean (for getting the Icon Name). I’ve bolded the specific area I assume needs to be changed (but HOW to change is the question):

Screenshot 2024-07-19 165239