@@ -416,16 +416,24 @@ int blockdev_partscan_enabled(int fd) {
416416 * With https://github.com/torvalds/linux/commit/e81cd5a983bb35dabd38ee472cf3fea1c63e0f23 (v6.3),
417417 * the 'capability' sysfs attribute is deprecated, hence we cannot check the flag from it.
418418 *
419- * To support both old and new kernels, we need to do the following: first check 'ext_range' sysfs
420- * attribute, and if '1' we can conclude partition scanning is disabled, otherwise check 'capability'
421- * sysattr for older version. */
419+ * With https://github.com/torvalds/linux/commit/a4217c6740dc64a3eb6815868a9260825e8c68c6
420+ * (backported to v6.9), the partscan status is directly exposed as 'partscan' sysattr.
421+ *
422+ * To support both old and new kernels, we need to do the following: first check 'partscan' attr
423+ * where the information is made directly available; then, fall back to 'ext_range' sysfs attribute,
424+ * and if '1' we can conclude partition scanning is disabled; otherwise check 'capability' sysattr
425+ * for ancient version. */
422426
423427 assert (fd >= 0 );
424428
425429 r = block_device_new_from_fd (fd , 0 , & dev );
426430 if (r < 0 )
427431 return r ;
428432
433+ r = device_get_sysattr_bool (dev , "partscan" );
434+ if (r != - ENOENT )
435+ return r ;
436+
429437 r = device_get_sysattr_int (dev , "ext_range" , & ext_range );
430438 if (r == - ENOENT ) /* If the ext_range file doesn't exist then we are most likely looking at a
431439 * partition block device, not the whole block device. And that means we have no
0 commit comments