-
MemoryCardManager.cpp/ThreadedMemoryCardWorker::DoHeartbeat
-
MemoryCardDriver::DoOneUpdate
-
MemoryCardDriverThreaded_Linux::GetUSBStorageDevices
-
ThreadedMemoryCardWorker inherits RageWorkerThread, which seems to be timeout-able thread worker
- It runs heartbeat every 0.1 seconds it seems?
- It waits 0.1 seconds from when the last heartbeat function has finished
- Running heartbeat means running DoHeartbeat method
- In DoHeartbeat, it runs DoOneUpdate with fresh aStorageDevices vector
- In DoOneUpdate, it checks NeedUpdate to determine if testing is needed
- NeedUpdate checks either one of the devices have a state of CHEKING. if not, it runs USBStorageDevicesChanged
- USBStorageDevicesChanged iterates through every device in /sys/block, runs stat() on it to check if it's valid, and appends its inode in
$i,
format to a string. It then compares that string with previous devices to detect device changes in /sys/block.
- Then DoOneUpdate finally runs GetUSBStorageDevices, with a vector initialized in #1 as arg
- It iterates through the devices available in /sys/block/, where it has
/removable
value set to 0 it skips the device, filtering non-USB devices - it checks
/queue
sysfs directory, which dictates that the partition table has been scanned. WE THINK THIS MIGHT BE FALSE!- It repeats the check every 0.01 seconds for 5 seconds. After that, it throws timeout and leaves the loop.
- If sysfs folder disappears, it means the device is gone before the scan was done. Throws warning and leaves the loop.
- If the queue folder is accessible, the scan must've been done! Hooray! Leaves the loop like a champ.
- It runs
udevadm settle
to wait for device node creation to complete. - Then it determines if
/sys/{dev}/{dev}1
folder (first partition) is a thing. If so, they set the device mountpoint to/dev/{dev}1
, else/dev/{dev}
. Nice job writing a log that is not ambiguous at all, 2005 Stepmania team... This piece of code is almost older than me and it shows. - Then it reads information like bus/port/level, vender and stuff... We don't need to know about this, just check that everything looks as it should be.
- then these guys open up the fstab, see if there's a mountpoint corresponding to the device. by-path are just symlinks to their
/dev/{device}
mountpoints, so if there's a match they should know the OS mountpath for it. - They check and weed out the devices that stepmania doesn't know its OsMountDir. Then it's done!
- It iterates through the devices available in /sys/block/, where it has
- Then it iterates through the devices freshly received from the function above. Judging by the behaviour of Stepmania, anything from this line is unrelated to the actual issue.
- If the device is not in the known list of devices, set its state to CHECKING so that the main thread is aware about it? Idk what this part is for
- If we've seen it already (state set to CHECKING) and the method was invoked with bMount==True which allows mounting, try mounting. if fails, throw error and continue iterating.
- Check if the device is writeable, read the profile name then unmount it.