Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

genhd: expose AN to user space

Allow user space to determine if a disk supports Asynchronous Notification of
media changes. This is done by adding a new sysfs file "capability_flags",
which is documented in (insert file name). This sysfs file will export all
disk capabilities flags to user space. We also define a new flag to define
the media change notification capability.

Signed-off-by: Kristen Carlson Accardi <kristen.c.accardi@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Kristen Carlson Accardi and committed by
Linus Torvalds
86ce18d7 35282316

+25 -1
+15
Documentation/block/capability.txt
··· 1 + Generic Block Device Capability 2 + =============================================================================== 3 + This file documents the sysfs file block/<disk>/capability 4 + 5 + capability is a hex word indicating which capabilities a specific disk 6 + supports. For more information on bits not listed here, see 7 + include/linux/genhd.h 8 + 9 + Capability Value 10 + ------------------------------------------------------------------------------- 11 + GENHD_FL_MEDIA_CHANGE_NOTIFY 4 12 + When this bit is set, the disk supports Asynchronous Notification 13 + of media change events. These events will be broadcast to user 14 + space via kernel uevent. 15 +
+9 -1
block/genhd.c
··· 423 423 { 424 424 return sprintf(page, "%llu\n", (unsigned long long)get_capacity(disk)); 425 425 } 426 - 426 + static ssize_t disk_capability_read(struct gendisk *disk, char *page) 427 + { 428 + return sprintf(page, "%x\n", disk->flags); 429 + } 427 430 static ssize_t disk_stats_read(struct gendisk * disk, char *page) 428 431 { 429 432 preempt_disable(); ··· 469 466 .attr = {.name = "size", .mode = S_IRUGO }, 470 467 .show = disk_size_read 471 468 }; 469 + static struct disk_attribute disk_attr_capability = { 470 + .attr = {.name = "capability", .mode = S_IRUGO }, 471 + .show = disk_capability_read 472 + }; 472 473 static struct disk_attribute disk_attr_stat = { 473 474 .attr = {.name = "stat", .mode = S_IRUGO }, 474 475 .show = disk_stats_read ··· 513 506 &disk_attr_removable.attr, 514 507 &disk_attr_size.attr, 515 508 &disk_attr_stat.attr, 509 + &disk_attr_capability.attr, 516 510 #ifdef CONFIG_FAIL_MAKE_REQUEST 517 511 &disk_attr_fail.attr, 518 512 #endif
+1
include/linux/genhd.h
··· 94 94 95 95 #define GENHD_FL_REMOVABLE 1 96 96 #define GENHD_FL_DRIVERFS 2 97 + #define GENHD_FL_MEDIA_CHANGE_NOTIFY 4 97 98 #define GENHD_FL_CD 8 98 99 #define GENHD_FL_UP 16 99 100 #define GENHD_FL_SUPPRESS_PARTITION_INFO 32