Skip to content
  • Mike Fleetwood's avatar
    Pre-populate BlockSpecial cache while reading /proc/partitions (#767842) · 571304d2
    Mike Fleetwood authored and Curtis Gedak's avatar Curtis Gedak committed
    GParted is already reading /proc/partitions to get whole disk device
    names.  The file also contains the major, minor device number of every
    partition.  Use this information to pre-populate the cache in the
    BlockSpecial class.
    
        # cat /proc/partitions
        major minor  #blocks  name
    
           8        0   20971520 sda
           8        1     512000 sda1
           8        2   20458496 sda2
        ...
           9        3    1047552 md3
         259        2     262144 md3p1
         259        3     262144 md3p2
        ...
         253        0   18317312 dm-0
         253        1    2097152 dm-1
         253        2    8383872 dm-2
         253        3    1048576 dm-3
    
    Note that for Device-Mapper names (dm-*) the kernel is not using the
    canonical user space names (mapper/*).  There is no harm in
    pre-populating the cache with these names and will help if tools report
    them too.  It is just that for DMRaid, LVM and LUKS, GParted uses the
    canonical /dev/mapper/* names so will still have to call stat() once for
    each such name.
    
    For plain disks (sd*) and Linux Software RAID arrays (md*) the kernel
    name is the common user space name too, therefore matches what GParted
    uses and pre-populating does avoid calling stat() at all for these
    names.
    
    Bug 767842 - File system usage missing when tools report alternate block
                 device names
    571304d2