I noticed a bug in "block" tool behavior. It was providing inconsistent
UUIDs for my disks with NTFS partitions.

Please check UUID of /dev/sda1 in following examples:

root@OpenWrt:/# block info
/dev/mtdblock4: UUID="8463a403-99b3cf92-d2b7996f-c4ede4f4" VERSION="4.0" MOUNT="/rom" 
TYPE="squashfs"
/dev/mtdblock5: MOUNT="/overlay" TYPE="jffs2"
/dev/sda1: UUID="6AA9873636CA5409" TYPE="ntfs"
/dev/sda2: UUID="0000001800000030" TYPE="ntfs"
/dev/sdb1: UUID="0000001800000030" TYPE="ntfs"

root@OpenWrt:/# block detect
config 'global'
       option  anon_swap       '0'
       option  anon_mount      '0'
       option  auto_swap       '1'
       option  auto_mount      '1'
       option  delay_root      '5'
       option  check_fs        '0'

config 'mount'
       option  target  '/mnt/sda1'
       option  uuid    '0000001800000030'
       option  enabled '0'

config 'mount'
       option  target  '/mnt/sda2'
       option  uuid    '0000001800000030'
       option  enabled '0'

config 'mount'
       option  target  '/mnt/sdb1'
       option  uuid    '0000001800000030'
       option  enabled '0'

That bug was exposed by cache_load(0) vs. cache_load(1). Those calls
result in different order of buffer allocation in the
blkid_probe_get_buffer().

This problem is caused by:
1) blkid_probe_get_buffer() resuing buffer when possible
2) __probe_ntfs() reading multiple blocks

As you can probably guess any subsequent block ready can overwrite a
content of previously returned block content buffer. In __probe_ntfs()
case it's something like:

ns = blkid_probe_get_sb(...);
buf_mft = blkid_probe_get_buffer(...);
buf_mft = blkid_probe_get_buffer(...);
ns->volume_serial

If you take a look at blkid_probe_get_buffer() in the original project
(util-linux's libblkid) it's a bit more complicated:
https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/libblkid/src/probe.c#n640

Any idea/hint how to resolve it in some simple way?

--
Rafał

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to