2008年12月29日 星期一

linux type

linux/types.h
sector_t 

block device driver header

linux/fs.h
struct block_device:

scsi/scsi_device.h
struct scsi_device

2008年12月27日 星期六

linux list

defined in /include/linux/list.h

struct list_head {
struct list_head *next, *prev;
};

#define LIST_HEAD_INIT(name) { &(name), &(name) }

#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)

INIT_LIST_HEAD: when list_head is first created, its next & prev point to itself
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
list->prev = list;
}

list_add: add new element A to B, if B's next is C, then final sequence is B, A, C
static inline void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}

static inline void __list_add(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
next->prev = new;
new->next = next;
new->prev = prev;
prev->next = new;
}


#define list_for_each(pos, head) \
for (pos = (head)->next; prefetch(pos->next), pos != (head); \
pos = pos->next)

/* list_entry - get the struct for this entry
@ptr: the &struct list_head pointer.

@type: the type of the struct this is embedded in.
@member: the name of the list_struct within the struct.
*/
#define
list_entry(ptr, type, member) \
container_of(ptr, type, member)

/* container_of - cast a member of a structure out to the containing structure
@ptr: the pointer to the member.
@type: the type of the container struct this is embedded in.
@member: the name of the member within the struct.
*/
#define
container_of(ptr, type, member) ({ \
const
typeof( ((type *)0)->member ) *__mptr = (ptr); \
(
type *)( (char *)__mptr - offsetof(type,member) );})

2008年12月25日 星期四

multipath-tools

get source:
http://christophe.varoqui.free.fr/



compile:
(1) install device-mapper-devel-1.02.13-6.14.x86_64.rpm
(2) install readline-devel-5.1-24.19.x86_64.rpm.rpm
(3) cd multipathd
(4) make