• Andrew Morton's avatar
    [PATCH] fix blockdev --getro for sr, sd, ide-floppy · 2b0bcc8b
    Andrew Morton authored
    From: John McKell <mckellj@iomega.com>
    
    This 2.6.1 patch works by setting gendisk->policy to the correct value
    during initialization as the various drivers decide whether or not the disk
    is writeable.  This patch persuades "blockdev --getro ..." to correctly
    report the read-only state of a newly inserted disk.  This patch applies to
    sr.c, sd.c and ide-floppy.c.  ide-cd.c already has this functionality built
    into it.
    
    Using an Iomega Zip drive as the test case...
    
    Without the patch, I always see:
    
    $ sudo blockdev --getro /dev/sda
    0
    $
    
    That's only correct for writeable disks though.  Only when the patch
    is applied do I see a write-protected disk described correctly:
    
    $ sudo blockdev --getro /dev/sda
    1
    $
    2b0bcc8b
sr.c 22.8 KB