Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USB drives with identical serial numbers (again!) #1271

Open
BreakingSiam opened this issue Apr 21, 2024 · 2 comments
Open

USB drives with identical serial numbers (again!) #1271

BreakingSiam opened this issue Apr 21, 2024 · 2 comments

Comments

@BreakingSiam
Copy link

I am trying to resolve a situation with udisks2 and inserting multiple USB disks with identical serial numbers. I am not using udev.

I have written my own daemon which creates a GDBusObjectManager and uses g_signal_connect(manager,"object-added",...) to receive events directly via dbus.

Now consider the following situation:

I have a number of USB ports, and I plug in microSD to USB adapters into each port. Every adapter has an identical serial number, and they all map to the same identifier:

/org/freedesktop/UDisks2/drives/Generic__SD_2fMMC_2009081519810

The problem is I never see a drive event when plugging in a second USB drive with an identical serial number. I get disk events (the sd? block device being added/removed), but not drive events. These are subtly different things which I am tracking at different places for different purposes, and my code relies on being able to match them one for one.

So I am left with a challenge. How do I get the kernel to tell me about duplicate drives being inserted/removed? I understand from reading previous issues dealing with this topic that the issue is with multipath. I don't need multipath for my application, and would prefer to figure out how to disable it entirely on the USB bus. In any case, I am stuck right now because the event is never even reported to me. Is there something I can configure to change how this is handled?

Alternatively, can anyone explain exactly how udisks/dbus/systemd actually receives events from the linux kernel, and what sources I will need to patch in order to get object_added/object_removed events for every USB drive inserted (not only the creation of the block devices), even if they all have identical serial numbers?

I apologize if this is not the appropriate venue for this question. I have tried to understand the source code but genuinely don't know where to begin. Any advice is appreciated.

@tbzatek
Copy link
Member

tbzatek commented May 2, 2024

I am not using udev.

UDisks relies on udev to receive and process uevents, perform additional probing, before the information get to UDisks. What do you mean by not using udev?

I have a number of USB ports, and I plug in microSD to USB adapters into each port. Every adapter has an identical serial number, and they all map to the same identifier:

/org/freedesktop/UDisks2/drives/Generic__SD_2fMMC_2009081519810

That's likely another occurrence of #1225 - multiple block devices treated as multipath or, rather, the calculated VPD ID being equal. The rest of your questions only point to this single bug. This is a bug that needs to be fixed.

@BreakingSiam
Copy link
Author

BreakingSiam commented May 2, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants