Comment 12 for bug 912522

Revision history for this message
Jeff Lane  (bladernr) wrote :

So if it encounters a usb device with say... 3 partitions and two of those partitions are not writable and one IS, it will complete testing ALL partitions, then fail overall by saying "Completed X iterations of testing, but there were errors."

And the script output will tell you which partitions failed.

The problem is, you can't necessarily determine a non-writable partition. For example, this is my test drive

bladernr@klaatu:~/development/fix-usb-time-limit/scripts$ mount
...
/dev/sdb1 on /media/6e2ec127-1f1e-4035-8b9e-9b9d31b31425 type ext2 (rw,nosuid,nodev,uhelper=udisks)
/dev/sdb3 on /media/69C4EBBA125CC3B7 type fuseblk (rw,nosuid,nodev,allow_other,blksize=4096,default_permissions)
/dev/sdb2 on /media/1297-8992_ type vfat (rw,nosuid,nodev,uid=1000,gid=1000,shortname=mixed,dmask=0077,utf8=1,showexec,flush,uhelper=udisks)

Three partitions... one was ext2, one vfat and one ntfs... they're all mounted RW automatically by udev, however, default udev rules apparently differ by filesystem type... here's what the user sees:

drwx------ 2 bladernr bladernr 4096 2012-01-19 09:52 1297-8992_
drwx------ 1 bladernr bladernr 4096 2012-01-19 09:52 69C4EBBA125CC3B7
drwxr-xr-x 3 root root 4096 2012-01-18 17:01 6e2ec127-1f1e-4035-8b9e-9b9d31b31425

So even though 9b9d31b31425 is moutned as read-write, the non-rot user can not write to it at all. but how do you determine that at run time, without creating overly complicated hueristics that read the permissions on the directory or something? No way that I know of...

So the simpler, cleaner method was to simply create a fail if we can't write data to the drive, note that and move on. That way, if we notice that 3 of 4 partitions pass, but one did not, it's probably a false positive, but if the device has only one partition and that failed, we may be more interested.

Another way around it would simply be to run the test as root, but I don't like running potentially destructive tests as the root user...

Also, having a usb drive with multiple partitions is not a common use case... I'd guess that probably 85 - 90% of all people would never format their usb key, or usb hard disk into multiple partitions. Consider how long this test has been around and used and no one mentioned this issue before... it's taken a good while for someone to hit the right combo to hit this bug...