genhd.c File Reference

Go to the source code of this file.

Classes

struct  blk_major_name

must be unique within the system.

The return value depends on the input parameter.

  • if a major device number was requested in range [1..255] then the function returns zero on success, or a negative error code
  • if any unused major number was requested with =0 parameter then the return value is the allocated major number in range [1..255] or a negative error code otherwise


static struct device_type disk_type
static struct kobj_map * bdev_map
static struct attribute * disk_attrs []
static struct attribute_group disk_attr_group
static struct attribute_group * disk_attr_groups []
struct class block_class
int register_blkdev (unsigned int major, const char *name)
 EXPORT_SYMBOL (register_blkdev)
void unregister_blkdev (unsigned int major, const char *name)
 EXPORT_SYMBOL (unregister_blkdev)
static int blk_mangle_minor (int minor)
 blk_mangle_minor - scatter minor numbers apart : minor number to mangle
int blk_alloc_devt (struct hd_struct *part, dev_t *devt)
 blk_alloc_devt - allocate a dev_t for a partition : partition to allocate dev_t for : out parameter for resulting dev_t
void blk_free_devt (dev_t devt)
 blk_free_devt - free a dev_t : dev_t to free
static char * bdevt_str (dev_t devt, char *buf)
void blk_register_region (dev_t devt, unsigned long range, struct module *module, struct kobject *(*probe)(dev_t, int *, void *), int(*lock)(dev_t, void *), void *data)
 EXPORT_SYMBOL (blk_register_region)
void blk_unregister_region (dev_t devt, unsigned long range)
 EXPORT_SYMBOL (blk_unregister_region)
static struct kobject * exact_match (dev_t devt, int *partno, void *data)
static int exact_lock (dev_t devt, void *data)
void add_disk (struct gendisk *disk)
 add_disk - add partitioning information to kernel list : per-device partitioning information
 EXPORT_SYMBOL (add_disk)
 EXPORT_SYMBOL (del_gendisk)
void unlink_gendisk (struct gendisk *disk)
struct gendisk * get_gendisk (dev_t devt, int *partno)
 get_gendisk - get partitioning information for a given device : device to get partitioning information for : returned partition index
struct block_device * bdget_disk (struct gendisk *disk, int partno)
 bdget_disk - do bdget() by gendisk and partition number : gendisk of interest : partition number
 EXPORT_SYMBOL (bdget_disk)
void __init printk_all_partitions (void)
static struct kobject * base_probe (dev_t devt, int *partno, void *data)
static int __init genhd_device_init (void)
 subsys_initcall (genhd_device_init)
static ssize_t disk_range_show (struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t disk_ext_range_show (struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t disk_removable_show (struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t disk_ro_show (struct device *dev, struct device_attribute *attr, char *buf)
static ssize_t disk_capability_show (struct device *dev, struct device_attribute *attr, char *buf)
static DEVICE_ATTR (range, S_IRUGO, disk_range_show, NULL)
static DEVICE_ATTR (ext_range, S_IRUGO, disk_ext_range_show, NULL)
static DEVICE_ATTR (removable, S_IRUGO, disk_removable_show, NULL)
static DEVICE_ATTR (ro, S_IRUGO, disk_ro_show, NULL)
static DEVICE_ATTR (size, S_IRUGO, part_size_show, NULL)
static DEVICE_ATTR (capability, S_IRUGO, disk_capability_show, NULL)
static DEVICE_ATTR (stat, S_IRUGO, part_stat_show, NULL)
static void disk_free_ptbl_rcu_cb (struct rcu_head *head)
static void disk_replace_part_tbl (struct gendisk *disk, struct disk_part_tbl *new_ptbl)
 disk_replace_part_tbl - replace disk->part_tbl in RCU-safe way : disk to replace part_tbl for : new part_tbl to install
int disk_expand_part_tbl (struct gendisk *disk, int partno)
 disk_expand_part_tbl - expand disk->part_tbl : disk to expand part_tbl for : expand such that this partno can fit in
static void disk_release (struct device *dev)
static void media_change_notify_thread (struct work_struct *work)
dev_t blk_lookup_devt (const char *name, int partno)
 EXPORT_SYMBOL (blk_lookup_devt)
struct gendisk * alloc_disk (int minors)
 EXPORT_SYMBOL (alloc_disk)
struct gendisk * alloc_disk_node (int minors, int node_id)
 EXPORT_SYMBOL (alloc_disk_node)
struct kobject * get_disk (struct gendisk *disk)
 EXPORT_SYMBOL (get_disk)
void put_disk (struct gendisk *disk)
 EXPORT_SYMBOL (put_disk)
void set_device_ro (struct block_device *bdev, int flag)
 EXPORT_SYMBOL (set_device_ro)
void set_disk_ro (struct gendisk *disk, int flag)
 EXPORT_SYMBOL (set_disk_ro)
int bdev_read_only (struct block_device *bdev)
 EXPORT_SYMBOL (bdev_read_only)
int invalidate_partition (struct gendisk *disk, int partno)
 EXPORT_SYMBOL (invalidate_partition)

Defines

#define MAX_EXT_DEVT   (1 << MINORBITS)

Functions

static DEFINE_MUTEX (block_class_lock)
static DEFINE_MUTEX (ext_devt_mutex)
static DEFINE_IDR (ext_devt_idr)
struct hd_struct * disk_get_part (struct gendisk *disk, int partno)
 disk_get_part - get partition : disk to look partition from : partition number
 EXPORT_SYMBOL_GPL (disk_get_part)
void disk_part_iter_init (struct disk_part_iter *piter, struct gendisk *disk, unsigned int flags)
 disk_part_iter_init - initialize partition iterator : iterator to initialize : disk to iterate over : DISK_PITER_* flags
 EXPORT_SYMBOL_GPL (disk_part_iter_init)
struct hd_struct * disk_part_iter_next (struct disk_part_iter *piter)
 disk_part_iter_next - proceed iterator to the next partition and return it : iterator of interest
 EXPORT_SYMBOL_GPL (disk_part_iter_next)
void disk_part_iter_exit (struct disk_part_iter *piter)
 disk_part_iter_exit - finish up partition iteration : iter of interest
 EXPORT_SYMBOL_GPL (disk_part_iter_exit)
static int sector_in_part (struct hd_struct *part, sector_t sector)
struct hd_struct * disk_map_sector_rcu (struct gendisk *disk, sector_t sector)
 disk_map_sector_rcu - map sector to partition : gendisk of interest : sector to map
 EXPORT_SYMBOL_GPL (disk_map_sector_rcu)
static int major_to_index (int major)

Variables

struct kobject * block_depr
static struct blk_major_namemajor_names [BLKDEV_MAJOR_HASH_SIZE]


Define Documentation

#define MAX_EXT_DEVT   (1 << MINORBITS)

Definition at line 33 of file genhd.c.


Function Documentation

void add_disk ( struct gendisk *  disk  ) 

add_disk - add partitioning information to kernel list : per-device partitioning information

This function registers the partitioning information in with the kernel.

FIXME: error handling

Definition at line 516 of file genhd.c.

struct gendisk* alloc_disk ( int  minors  )  [read]

Definition at line 1138 of file genhd.c.

struct gendisk* alloc_disk_node ( int  minors,
int  node_id 
) [read]

Definition at line 1144 of file genhd.c.

static struct kobject* base_probe ( dev_t  devt,
int *  partno,
void *  data 
) [static, read]

Definition at line 787 of file genhd.c.

int bdev_read_only ( struct block_device *  bdev  ) 

Definition at line 1227 of file genhd.c.

static char* bdevt_str ( dev_t  devt,
char *  buf 
) [static]

Definition at line 457 of file genhd.c.

struct block_device* bdget_disk ( struct gendisk *  disk,
int  partno 
) [read]

bdget_disk - do bdget() by gendisk and partition number : gendisk of interest : partition number

Find partition from , do bdget() on it.

CONTEXT: Don't care.

RETURNS: Resulting block_device on success, NULL on failure.

Definition at line 616 of file genhd.c.

int blk_alloc_devt ( struct hd_struct *  part,
dev_t *  devt 
)

blk_alloc_devt - allocate a dev_t for a partition : partition to allocate dev_t for : out parameter for resulting dev_t

Allocate a dev_t for block device.

RETURNS: 0 on success, allocated dev_t is returned in *. -errno on failure.

CONTEXT: Might sleep.

Definition at line 404 of file genhd.c.

void blk_free_devt ( dev_t  devt  ) 

blk_free_devt - free a dev_t : dev_t to free

Free which was allocated using blk_alloc_devt().

CONTEXT: Might sleep.

Definition at line 443 of file genhd.c.

dev_t blk_lookup_devt ( const char *  name,
int  partno 
)

Definition at line 1103 of file genhd.c.

static int blk_mangle_minor ( int  minor  )  [static]

blk_mangle_minor - scatter minor numbers apart : minor number to mangle

Scatter consecutively allocated number apart if MANGLE_DEVT is enabled. Mangling twice gives the original value.

RETURNS: Mangled value.

CONTEXT: Don't care.

Definition at line 371 of file genhd.c.

void blk_register_region ( dev_t  devt,
unsigned long  range,
struct module *  module,
struct kobject *(*)(dev_t, int *, void *)  probe,
int(*)(dev_t, void *)  lock,
void *  data 
)

Definition at line 474 of file genhd.c.

void blk_unregister_region ( dev_t  devt,
unsigned long  range 
)

Definition at line 483 of file genhd.c.

static DEFINE_IDR ( ext_devt_idr   )  [static]

static DEFINE_MUTEX ( ext_devt_mutex   )  [static]

static DEFINE_MUTEX ( block_class_lock   )  [static]

static DEVICE_ATTR ( stat  ,
S_IRUGO  ,
part_stat_show  ,
NULL   
) [static]

static DEVICE_ATTR ( capability  ,
S_IRUGO  ,
disk_capability_show  ,
NULL   
) [static]

static DEVICE_ATTR ( size  ,
S_IRUGO  ,
part_size_show  ,
NULL   
) [static]

static DEVICE_ATTR ( ro  ,
S_IRUGO  ,
disk_ro_show  ,
NULL   
) [static]

static DEVICE_ATTR ( removable  ,
S_IRUGO  ,
disk_removable_show  ,
NULL   
) [static]

static DEVICE_ATTR ( ext_range  ,
S_IRUGO  ,
disk_ext_range_show  ,
NULL   
) [static]

static DEVICE_ATTR ( range  ,
S_IRUGO  ,
disk_range_show  ,
NULL   
) [static]

static ssize_t disk_capability_show ( struct device *  dev,
struct device_attribute *  attr,
char *  buf 
) [static]

Definition at line 850 of file genhd.c.

int disk_expand_part_tbl ( struct gendisk *  disk,
int  partno 
)

disk_expand_part_tbl - expand disk->part_tbl : disk to expand part_tbl for : expand such that this partno can fit in

Expand disk->part_tbl such that can fit in. disk->part_tbl uses RCU to allow unlocked dereferencing for stats and other stuff.

LOCKING: Matching bd_mutex locked, might sleep.

RETURNS: 0 on success, -errno on failure.

Definition at line 951 of file genhd.c.

static ssize_t disk_ext_range_show ( struct device *  dev,
struct device_attribute *  attr,
char *  buf 
) [static]

Definition at line 825 of file genhd.c.

static void disk_free_ptbl_rcu_cb ( struct rcu_head *  head  )  [static]

Definition at line 901 of file genhd.c.

struct hd_struct* disk_get_part ( struct gendisk *  disk,
int  partno 
) [read]

disk_get_part - get partition : disk to look partition from : partition number

Look for partition from . If found, increment reference count and return it.

CONTEXT: Don't care.

RETURNS: Pointer to the found partition on success, NULL if not found.

Definition at line 57 of file genhd.c.

struct hd_struct* disk_map_sector_rcu ( struct gendisk *  disk,
sector_t  sector 
) [read]

disk_map_sector_rcu - map sector to partition : gendisk of interest : sector to map

Find out which partition maps to on . This is primarily used for stats accounting.

CONTEXT: RCU read locked. The returned partition pointer is valid only while preemption is disabled.

RETURNS: Found partition on success, part0 is returned if no partition matches

Definition at line 208 of file genhd.c.

void disk_part_iter_exit ( struct disk_part_iter *  piter  ) 

disk_part_iter_exit - finish up partition iteration : iter of interest

Called when iteration is over. Cleans up .

CONTEXT: Don't care.

Definition at line 180 of file genhd.c.

void disk_part_iter_init ( struct disk_part_iter *  piter,
struct gendisk *  disk,
unsigned int  flags 
)

disk_part_iter_init - initialize partition iterator : iterator to initialize : disk to iterate over : DISK_PITER_* flags

Initialize so that it iterates over partitions of .

CONTEXT: Don't care.

Definition at line 91 of file genhd.c.

struct hd_struct* disk_part_iter_next ( struct disk_part_iter *  piter  )  [read]

disk_part_iter_next - proceed iterator to the next partition and return it : iterator of interest

Proceed to the next partition and return it.

CONTEXT: Don't care.

Definition at line 124 of file genhd.c.

static ssize_t disk_range_show ( struct device *  dev,
struct device_attribute *  attr,
char *  buf 
) [static]

Definition at line 817 of file genhd.c.

static void disk_release ( struct device *  dev  )  [static]

Definition at line 982 of file genhd.c.

static ssize_t disk_removable_show ( struct device *  dev,
struct device_attribute *  attr,
char *  buf 
) [static]

Definition at line 833 of file genhd.c.

static void disk_replace_part_tbl ( struct gendisk *  disk,
struct disk_part_tbl *  new_ptbl 
) [static]

disk_replace_part_tbl - replace disk->part_tbl in RCU-safe way : disk to replace part_tbl for : new part_tbl to install

Replace disk->part_tbl with in RCU-safe way. The original ptbl is freed using RCU callback.

LOCKING: Matching bd_mutx locked.

Definition at line 920 of file genhd.c.

static ssize_t disk_ro_show ( struct device *  dev,
struct device_attribute *  attr,
char *  buf 
) [static]

Definition at line 842 of file genhd.c.

static int exact_lock ( dev_t  devt,
void *  data 
) [static]

Definition at line 497 of file genhd.c.

static struct kobject* exact_match ( dev_t  devt,
int *  partno,
void *  data 
) [static, read]

Definition at line 490 of file genhd.c.

EXPORT_SYMBOL ( invalidate_partition   ) 

EXPORT_SYMBOL ( bdev_read_only   ) 

EXPORT_SYMBOL ( set_disk_ro   ) 

EXPORT_SYMBOL ( set_device_ro   ) 

EXPORT_SYMBOL ( put_disk   ) 

EXPORT_SYMBOL ( get_disk   ) 

EXPORT_SYMBOL ( alloc_disk_node   ) 

EXPORT_SYMBOL ( alloc_disk   ) 

EXPORT_SYMBOL ( blk_lookup_devt   ) 

EXPORT_SYMBOL ( bdget_disk   ) 

EXPORT_SYMBOL ( del_gendisk   ) 

EXPORT_SYMBOL ( add_disk   ) 

EXPORT_SYMBOL ( blk_unregister_region   ) 

EXPORT_SYMBOL ( blk_register_region   ) 

EXPORT_SYMBOL ( unregister_blkdev   ) 

EXPORT_SYMBOL ( register_blkdev   ) 

EXPORT_SYMBOL_GPL ( disk_map_sector_rcu   ) 

EXPORT_SYMBOL_GPL ( disk_part_iter_exit   ) 

EXPORT_SYMBOL_GPL ( disk_part_iter_next   ) 

EXPORT_SYMBOL_GPL ( disk_part_iter_init   ) 

EXPORT_SYMBOL_GPL ( disk_get_part   ) 

static int __init genhd_device_init ( void   )  [static]

Definition at line 795 of file genhd.c.

struct kobject* get_disk ( struct gendisk *  disk  )  [read]

Definition at line 1177 of file genhd.c.

struct gendisk* get_gendisk ( dev_t  devt,
int *  partno 
) [read]

get_gendisk - get partitioning information for a given device : device to get partitioning information for : returned partition index

This function gets the structure containing partitioning information for the given device .

Definition at line 577 of file genhd.c.

int invalidate_partition ( struct gendisk *  disk,
int  partno 
)

Definition at line 1236 of file genhd.c.

static int major_to_index ( int  major  )  [inline, static]

Definition at line 243 of file genhd.c.

static void media_change_notify_thread ( struct work_struct *  work  )  [static]

Definition at line 1080 of file genhd.c.

void __init printk_all_partitions ( void   ) 

Definition at line 635 of file genhd.c.

void put_disk ( struct gendisk *  disk  ) 

Definition at line 1198 of file genhd.c.

int register_blkdev ( unsigned int  major,
const char *  name 
)

Definition at line 278 of file genhd.c.

static int sector_in_part ( struct hd_struct *  part,
sector_t  sector 
) [inline, static]

Definition at line 187 of file genhd.c.

void set_device_ro ( struct block_device *  bdev,
int  flag 
)

Definition at line 1206 of file genhd.c.

void set_disk_ro ( struct gendisk *  disk,
int  flag 
)

Definition at line 1213 of file genhd.c.

subsys_initcall ( genhd_device_init   ) 

void unlink_gendisk ( struct gendisk *  disk  ) 

Definition at line 560 of file genhd.c.

void unregister_blkdev ( unsigned int  major,
const char *  name 
)

Definition at line 334 of file genhd.c.


Variable Documentation

struct kobj_map* bdev_map [static]

Definition at line 356 of file genhd.c.

struct class block_class

Initial value:

 {
        .name           = "block",
}

Definition at line 991 of file genhd.c.

struct kobject* block_depr

Definition at line 29 of file genhd.c.

struct attribute_group disk_attr_group [static]

Initial value:

 {
        .attrs = disk_attrs,
}

Definition at line 892 of file genhd.c.

struct attribute_group* disk_attr_groups[] [static]

Initial value:

 {
        &disk_attr_group,
        NULL
}

Definition at line 896 of file genhd.c.

struct attribute* disk_attrs[] [static]

Initial value:

 {
        &dev_attr_range.attr,
        &dev_attr_ext_range.attr,
        &dev_attr_removable.attr,
        &dev_attr_ro.attr,
        &dev_attr_size.attr,
        &dev_attr_capability.attr,
        &dev_attr_stat.attr,






        NULL
}

Definition at line 875 of file genhd.c.

static struct device_type disk_type [static, read]

Initial value:

 {
        .name           = "disk",
        .groups         = disk_attr_groups,
        .release        = disk_release,
}

Definition at line 41 of file genhd.c.

struct blk_major_name * major_names[BLKDEV_MAJOR_HASH_SIZE] [static]


Generated on Wed Apr 11 06:39:15 2012 for DDE - The L4 Device Driver Environment by  doxygen 1.5.6