@@ -386,16 +386,24 @@ int blockdev_partscan_enabled(int fd) {
386386 * With https://github.com/torvalds/linux/commit/e81cd5a983bb35dabd38ee472cf3fea1c63e0f23 (v6.3),
387387 * the 'capability' sysfs attribute is deprecated, hence we cannot check the flag from it.
388388 *
389- * To support both old and new kernels, we need to do the following: first check 'ext_range' sysfs
390- * attribute, and if '1' we can conclude partition scanning is disabled, otherwise check 'capability'
391- * sysattr for older version. */
389+ * With https://github.com/torvalds/linux/commit/a4217c6740dc64a3eb6815868a9260825e8c68c6
390+ * (backported to v6.9), the partscan status is directly exposed as 'partscan' sysattr.
391+ *
392+ * To support both old and new kernels, we need to do the following: first check 'partscan' attr
393+ * where the information is made directly available; then, fall back to 'ext_range' sysfs attribute,
394+ * and if '1' we can conclude partition scanning is disabled; otherwise check 'capability' sysattr
395+ * for ancient version. */
392396
393397 assert (fd >= 0 );
394398
395399 r = block_device_new_from_fd (fd , 0 , & dev );
396400 if (r < 0 )
397401 return r ;
398402
403+ r = device_get_sysattr_bool (dev , "partscan" );
404+ if (r != - ENOENT )
405+ return r ;
406+
399407 r = device_get_sysattr_int (dev , "ext_range" , & ext_range );
400408 if (r == - ENOENT ) /* If the ext_range file doesn't exist then we are most likely looking at a
401409 * partition block device, not the whole block device. And that means we have no
0 commit comments