Bug 89335 - Detect fake devices when formatting
Summary: Detect fake devices when formatting
Status: NEW
Alias: None
Product: udisks
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: Martin Pitt
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-26 10:31 UTC by Bastien Nocera
Modified: 2015-03-07 19:59 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Bastien Nocera 2015-02-26 10:31:57 UTC
As gnome-multiwriter's probe helper does, udisks should check for fake devices when formatting SD cards. The tests are quick enough to be run even when doing quick formatting.
Comment 1 Richard Hughes 2015-02-26 10:45:14 UTC
The main complication being that you have to reset the device after doing the first set of probing. Some sneaky devices keep a runtime list of changed sectors which isn't saved to flash. For USB device it's easy as you can just reset the port and let the device re-enumerate, but for sata disks and SD cards I don't know if the same thing is possible.

The code I'm using is here: https://git.gnome.org/browse/gnome-multi-writer/tree/src/gmw-probe.c -- I'm happy to relicence to basically whatever if required.
Comment 2 Martin Pitt 2015-02-26 12:41:09 UTC
Can you please elaborate what "fake" devices are? Something like the scsi_debug kernel module with a few extra udev properties to make it look like an SD card? Formatting that should work just fine, though. So I'm afraid I don't know what this is all about?

Also, udisks doesn't do anything special on SD cards for formatting, mounting etc, other than advertising an SD card icon for these drives/volumes. Do you have some more details on what you are trying to do and what fails?

Thanks!
Comment 3 Richard Hughes 2015-02-26 14:03:11 UTC
Lots of details here: http://blogs.gnome.org/hughsie/

tl;dr: Fake flash is where the drive is much smaller than the size it reports, so for instance a 16GB drive is actually a 2GB drive, and writing to anything past 2BG either goes to /dev/null or wraps around to the first sector. :/
Comment 4 Richard Hughes 2015-02-26 14:03:38 UTC
Gahh, URL was meant to be: http://blogs.gnome.org/hughsie/2015/01/28/detecting-fake-flash/
Comment 5 Bastien Nocera 2015-02-26 14:06:40 UTC
(In reply to Martin Pitt from comment #2)
> Can you please elaborate what "fake" devices are? Something like the
> scsi_debug kernel module with a few extra udev properties to make it look
> like an SD card? Formatting that should work just fine, though. So I'm
> afraid I don't know what this is all about?

http://www.hadess.net/2015/02/another-fake-flash-story.html
http://blogs.gnome.org/hughsie/2015/01/28/detecting-fake-flash/
http://fake-electronics.blogspot.fr/2013/12/fake-samsung-64gb-microsd-card.html
etc.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.