display.h   display.h 
skipping to change at line 12 skipping to change at line 12
* Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH. * Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved. * All rights reserved.
* *
* See file LICENSE at the top of this source tree for license information. * See file LICENSE at the top of this source tree for license information.
*/ */
#ifndef _DISPLAY_H_ #ifndef _DISPLAY_H_
#define _DISPLAY_H_ #define _DISPLAY_H_
enum dev_type { enum dev_type {
DEVICE = 0x01, /* ALL devices */ DEVICE = 0x01, /* ALL devices */
RAID = 0x02, /* RAID devices */ RAID = 0x02, /* RAID devices */
NATIVE = 0x04, /* Native metadata of RAID devices */ NATIVE = 0x04, /* Native metadata of RAID devices */
SET = 0x08, /* RAID sets */ SET = 0x08, /* RAID sets */
}; };
enum active_type { enum active_type {
D_ALL = 0x01, /* All devices */ D_ALL = 0x01, /* All devices */
D_ACTIVE = 0x02, /* Active devices only */ D_ACTIVE = 0x02, /* Active devices only */
D_INACTIVE = 0x04, /* Inactive devices only */ D_INACTIVE = 0x04, /* Inactive devices only */
}; };
extern void display_devices(struct lib_context *lc, enum dev_type type); extern void display_devices(struct lib_context *lc, enum dev_type type);
extern void display_set(struct lib_context *lc, void *rs, extern void display_set(struct lib_context *lc, void *rs,
enum active_type active, int top); enum active_type active, int top);
extern void display_table(struct lib_context *lc, char *rs_name, char *tabl e); extern void display_table(struct lib_context *lc, char *rs_name, char *tabl e);
extern int list_formats(struct lib_context *lc, int arg); extern int list_formats(struct lib_context *lc, int arg);
#endif #endif
 End of changes. 2 change blocks. 
6 lines changed or deleted 6 lines changed or added


 dmraid.h   dmraid.h 
/* /*
* Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH. * Copyright (C) 2004-2008 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved. * All rights reserved.
* *
* Copyright (C) 2007 Intel Corporation. All rights reserved.
* November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
*
* See file LICENSE at the top of this source tree for license information. * See file LICENSE at the top of this source tree for license information.
*/ */
#ifndef _DMRAID_H_ #ifndef _DMRAID_H_
#define _DMRAID_H_ #define _DMRAID_H_
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
skipping to change at line 59 skipping to change at line 62
/* /*
* Erase ondisk metadata. * Erase ondisk metadata.
*/ */
extern int erase_metadata(struct lib_context *lc); extern int erase_metadata(struct lib_context *lc);
/* /*
* Dealing with RAID sets. * Dealing with RAID sets.
*/ */
extern const char *get_set_type(struct lib_context *lc, void *rs); extern const char *get_set_type(struct lib_context *lc, void *rs);
extern const char *get_set_name(struct lib_context *lc, void *rs); extern const char *get_set_name(struct lib_context *lc, void *rs);
extern int group_set(struct lib_context *lc, char *name); extern int group_set(struct lib_context *lc, char **name);
extern char *libdmraid_make_table(struct lib_context *lc, struct raid_set * rs); extern char *libdmraid_make_table(struct lib_context *lc, struct raid_set * rs);
enum activate_type { enum activate_type {
A_ACTIVATE, A_ACTIVATE,
A_DEACTIVATE, A_DEACTIVATE,
}; };
extern void process_sets(struct lib_context *lc, extern void process_sets(struct lib_context *lc,
int (*func)(struct lib_context *lc, void *rs, int a int (*func) (struct lib_context * lc, void *rs,
rg), int arg), int arg, enum set_type type)
int arg, enum set_type type); ;
extern int change_set(struct lib_context *lc, enum activate_type what, extern int change_set(struct lib_context *lc, enum activate_type what,
void *rs); void *rs);
/* /*
* Memory allocation * Memory allocation
*/ */
#ifdef DEBUG_MALLOC #ifdef DEBUG_MALLOC
extern void *_dbg_malloc(size_t size, struct lib_context *lc, extern void *_dbg_malloc(size_t size, struct lib_context *lc,
const char *who, unsigned int line); const char *who, unsigned int line);
 End of changes. 4 change blocks. 
5 lines changed or deleted 8 lines changed or added


 format.h   format.h 
/* /*
* Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH. * Copyright (C) 2004-2008 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved. * All rights reserved.
* *
* Copyright (C) 2007 Intel Corporation. All rights reserved.
* November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
*
* See file LICENSE at the top of this source tree for license information. * See file LICENSE at the top of this source tree for license information.
*/ */
#ifndef _FORMAT_H_ #ifndef _FORMAT_H_
#define _FORMAT_H_ #define _FORMAT_H_
#ifdef FORMAT_HANDLER #ifdef FORMAT_HANDLER
#undef FORMAT_HANDLER #undef FORMAT_HANDLER
#include <sys/types.h> #include <sys/types.h>
skipping to change at line 43 skipping to change at line 46
/* Event: RAID device add/remove */ /* Event: RAID device add/remove */
enum rd_action { enum rd_action {
rd_add, rd_add,
rd_remove, rd_remove,
}; };
struct event_rd { struct event_rd {
struct raid_set *rs; struct raid_set *rs;
struct raid_dev *rd; struct raid_dev *rd;
enum rd_action action; enum rd_action action;
}; };
/* /*
* List of event handler functions to call for the metadata format handler. * List of event handler functions to call for the metadata format handler.
* *
* Return 1 for event taken, RAID device write necessary. * Return 1 for event taken, RAID device write necessary.
* Return 0 for error and/or write unnecessary. * Return 0 for error and/or write unnecessary.
*/ */
struct event_handlers { struct event_handlers {
/* Handle IO error */ /* Handle IO error */
int (*io)(struct lib_context *lc, struct event_io *e_io); int (*io) (struct lib_context * lc, struct event_io * e_io);
/* Handle RAID device add/remove. */ /* Handle RAID device add/remove. */
int (*rd)(struct lib_context *lc, struct event_rd *e_rd); int (*rd) (struct lib_context * lc, struct event_rd * e_rd);
};
/*
* Hot-spare search types list: it can be searched locally/globally
*/
enum scope {
t_scope_local = 0x01,
t_scope_global = 0x02
};
/* Metadata Handler commands */
enum handler_commands {
UPDATE_REBUILD_STATE,
GET_REBUILD_STATE,
GET_REBUILD_DRIVE,
GET_REBUILD_DRIVE_NO,
CHECK_HOT_SPARE,
/* ... */
};
/* Union to return metadata_handler information. */
struct handler_info {
unsigned short size;
union {
char *str;
void *ptr;
int8_t i8;
int16_t i16;
int32_t i32;
int64_t i64;
uint8_t u8;
uint16_t u16;
uint32_t u32;
uint64_t u64;
} data;
}; };
/* /*
* Virtual interface definition of a metadata format handler. * Virtual interface definition of a metadata format handler.
*/ */
struct dmraid_format { struct dmraid_format {
const char *name; /* Format name */ const char *name; /* Format name */
const char *descr; /* Format description */ const char *descr; /* Format description */
const char *caps; /* Capabilities (RAID levels supported) */ const char *caps; /* Capabilities (RAID levels supported) */
enum fmt_type format; /* Format type (RAID, partition) */ enum fmt_type format; /* Format type (RAID, partition) */
/* /*
* Read RAID metadata off a device and unify it. * Read RAID metadata off a device and unify it.
*/ */
struct raid_dev* (*read)(struct lib_context *lc, struct dev_info* di struct raid_dev *(*read) (struct lib_context * lc,
); struct dev_info * di);
/* /*
* Write RAID metadata to a device deunifying it * Write RAID metadata to a device deunifying it
* or erase ondisk metadata if erase != 0. * or erase ondisk metadata if erase != 0.
*/ */
int (*write)(struct lib_context *lc, struct raid_dev* rd, int erase) int (*write) (struct lib_context * lc, struct raid_dev * rd, int era
; se);
/*
* delete RAID metadata to devices.
*/
int (*c_delete) (struct lib_context * lc, struct raid_set * rs);
/*
* create RAID metadata to devices.
*/
int (*create) (struct lib_context * lc, struct raid_set * rs);
/* /*
* Group a RAID device into a set. * Group a RAID device into a set.
*/ */
struct raid_set* (*group)(struct lib_context *lc, struct raid_dev *r struct raid_set *(*group) (struct lib_context * lc,
d); struct raid_dev * rd);
/* /*
* Check consistency of the RAID set metadata. * Check consistency of the RAID set metadata.
*/ */
int (*check)(struct lib_context *lc, struct raid_set *rs); int (*check) (struct lib_context * lc, struct raid_set * rs);
/* Metadata handler. */
int (*metadata_handler) (struct lib_context * lc,
enum handler_commands command,
struct handler_info * info, void *ptr);
/* /*
* Event handlers (eg, I/O error). * Event handlers (eg, I/O error).
*/ */
struct event_handlers *events; struct event_handlers *events;
/* /*
* Hot-spare disk search scope
*/
enum scope scope;
/*
* Display RAID disk metadata native. * Display RAID disk metadata native.
*/ */
void (*log)(struct lib_context *lc, struct raid_dev *rd); void (*log) (struct lib_context * lc, struct raid_dev * rd);
}; };
/* Chain of registered format handlers (needed for library context). */ /* Chain of registered format handlers (needed for library context). */
struct format_list { struct format_list {
struct list_head list; struct list_head list;
struct dmraid_format *fmt; struct dmraid_format *fmt;
}; };
int register_format_handlers(struct lib_context *lc); int register_format_handlers(struct lib_context *lc);
extern void unregister_format_handlers(struct lib_context *lc); extern void unregister_format_handlers(struct lib_context *lc);
/* /*
* Format core function used by (all) metadata format handlers. * Format core function used by (all) metadata format handlers.
*/ */
#define NO_CHECK_RD NULL #define NO_CHECK_RD NULL
extern int check_raid_set(struct lib_context *lc, struct raid_set *rs, extern int check_raid_set(struct lib_context *lc, struct raid_set *rs,
unsigned int (*f_devices)(struct raid_dev *rd, unsigned int (*f_devices) (struct raid_dev * rd,
void *context), void *context),
void *f_devices_context, void *f_devices_context,
int (*f_check)(struct lib_context *lc, int (*f_check) (struct lib_context * lc,
struct raid_set *rs, struct raid_set * rs,
struct raid_dev *rd, void *context) struct raid_dev * rd, void *contex
, t),
void *f_check_context, void *f_check_context, const char *handler);
const char *handler);
extern int check_valid_format(struct lib_context *lc, char *fmt); extern int check_valid_format(struct lib_context *lc, char *fmt);
extern int init_raid_set(struct lib_context *lc, struct raid_set *rs, extern int init_raid_set(struct lib_context *lc, struct raid_set *rs,
struct raid_dev *rd, unsigned int stride, struct raid_dev *rd, unsigned int stride,
unsigned int type, const char *handler); unsigned int type, const char *handler);
extern const char **get_format_caps(struct lib_context *lc, extern const char **get_format_caps(struct lib_context *lc,
struct dmraid_format *fmt); struct dmraid_format *fmt);
extern void free_format_caps(struct lib_context *lc, const char **caps); extern void free_format_caps(struct lib_context *lc, const char **caps);
union read_info { union read_info {
void *ptr; void *ptr;
uint32_t u32; uint32_t u32;
uint64_t u64; uint64_t u64;
}; };
struct raid_dev *read_raid_dev( struct raid_dev *read_raid_dev(struct lib_context *lc,
struct lib_context *lc, struct dev_info *di,
struct dev_info *di, void *(*f_read_metadata) (struct lib_context
void* (*f_read_metadata)(struct lib_context *lc, struct dev_info *di *
, lc,
size_t *size, uint64_t *offset, struct dev_info * d
union read_info *info), i,
size_t size, uint64_t offset, size_t * size,
void (*f_to_cpu)(void *meta), uint64_t * offset,
int (*f_is_meta)(struct lib_context *lc, struct dev_info *di, union read_info *
void *meta), info), size_t size,
void (*f_file_metadata)(struct lib_context *lc, struct dev_info *di, uint64_t offset, void (*f_to_cpu) (void *meta
void *meta), ),
int (*f_setup_rd)(struct lib_context *lc, struct raid_dev *rd, int (*f_is_meta) (struct lib_context * lc,
struct dev_info *di, void *meta, struct dev_info * di,
union read_info *info), void *meta),
const char *handler); void (*f_file_metadata) (struct lib_context *
lc,
struct dev_info * di
,
void *meta),
int (*f_setup_rd) (struct lib_context * lc,
struct raid_dev * rd,
struct dev_info * di,
void *meta,
union read_info * info),
const char *handler);
extern void *alloc_meta_areas(struct lib_context *lc, struct raid_dev *rd, extern void *alloc_meta_areas(struct lib_context *lc, struct raid_dev *rd,
const char *who, unsigned int n); const char *who, unsigned int n);
extern void *alloc_private(struct lib_context *lc, const char *who, extern void *alloc_private(struct lib_context *lc, const char *who,
size_t size); size_t size);
extern void *alloc_private_and_read(struct lib_context *lc, const char *who , extern void *alloc_private_and_read(struct lib_context *lc, const char *who ,
size_t size, char *path, loff_t offset); size_t size, char *path, loff_t offset);
extern struct raid_set *join_superset( extern struct raid_set *join_superset(struct lib_context *lc,
struct lib_context *lc, char *(*f_name) (struct lib_context *
char *(*f_name)(struct lib_context *lc, struct raid_dev *rd, lc,
unsigned int subset), struct raid_dev * rd,
void (*f_create)(struct raid_set *super, void *c_private), unsigned int subset),
int (*f_set_sort)(struct list_head *pos, struct list_head *c_new), void (*f_create) (struct raid_set *
struct raid_set *rs, struct raid_dev *rd super, void *c_priva
); te),
int (*f_set_sort) (struct list_head *
pos,
struct list_head *
c_new),
struct raid_set *rs, struct raid_dev *
rd);
extern int register_format_handler(struct lib_context *lc, extern int register_format_handler(struct lib_context *lc,
struct dmraid_format *fmt); struct dmraid_format *fmt);
extern int write_metadata(struct lib_context *lc, const char *handler, extern int write_metadata(struct lib_context *lc, const char *handler,
struct raid_dev *rd, int meta_index, int erase); struct raid_dev *rd, int meta_index, int erase);
extern int log_zero_sectors(struct lib_context *lc, char *path, extern int log_zero_sectors(struct lib_context *lc, char *path,
const char *handler); const char *handler);
#define to_disk to_cpu #define to_disk to_cpu
#define struct_offset(s, member) ((unsigned short) &((struct s *) 0)->membe r) #define struct_offset(s, member) ((size_t) &((struct s *) 0)->member)
/* Print macros used in log methods. */ /* Print macros used in log methods. */
/* Undefine this to avoid offsets in metadata logging. */ /* Undefine this to avoid offsets in metadata logging. */
#define NATIVE_LOG_OFFSET #define NATIVE_LOG_OFFSET
#ifdef NATIVE_LOG_OFFSET #ifdef NATIVE_LOG_OFFSET
#define P_FMT "0x%03x " #define P_FMT "0x%03x "
#define P_OFF(x, basevar, y...) \ #define P_OFF(x, basevar, y...) \
((unsigned long) &x - (unsigned long) basevar), y ((unsigned long) &x - (unsigned long) basevar), y
#else #else
 End of changes. 16 change blocks. 
46 lines changed or deleted 119 lines changed or added


 lib_context.h   lib_context.h 
/* /*
* Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH. * Copyright (C) 2004-2008 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved. * All rights reserved.
* *
* Copyright (C) 2007 Intel Corporation. All rights reserved.
* November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
*
* See file LICENSE at the top of this source tree for license information. * See file LICENSE at the top of this source tree for license information.
*/ */
#ifndef _LIB_CONTEXT_H_ #ifndef _LIB_CONTEXT_H_
#define _LIB_CONTEXT_H_ #define _LIB_CONTEXT_H_
#include <dmraid/list.h> #include <dmraid/list.h>
#include <dmraid/locking.h> #include <dmraid/locking.h>
#include <dmraid/misc.h> #include <dmraid/misc.h>
enum lc_lists { enum lc_lists {
LC_FORMATS = 0, /* Metadata format handlers. */ LC_FORMATS = 0, /* Metadata format handlers. */
LC_DISK_INFOS, /* Disks discovered. */ LC_DISK_INFOS, /* Disks discovered. */
LC_RAID_DEVS, /* Raid devices discovered. */ LC_RAID_DEVS, /* Raid devices discovered. */
LC_RAID_SETS, /* Raid sets grouped. */ LC_RAID_SETS, /* Raid sets grouped. */
/* Add new lists below here ! */ /* Add new lists below here ! */
LC_LISTS_SIZE, /* Must be the last enumerator. */ LC_LISTS_SIZE, /* Must be the last enumerator. */
}; };
/* List access macros. */ /* List access macros. */
#define LC_FMT(lc) (lc_list((lc), LC_FORMATS)) #define LC_FMT(lc) (lc_list((lc), LC_FORMATS))
#define LC_DI(lc) (lc_list((lc), LC_DISK_INFOS)) #define LC_DI(lc) (lc_list((lc), LC_DISK_INFOS))
#define LC_RD(lc) (lc_list((lc), LC_RAID_DEVS)) #define LC_RD(lc) (lc_list((lc), LC_RAID_DEVS))
#define LC_RS(lc) (lc_list((lc), LC_RAID_SETS)) #define LC_RS(lc) (lc_list((lc), LC_RAID_SETS))
enum lc_options { enum lc_options {
LC_COLUMN = 0, LC_COLUMN = 0,
LC_DEBUG, LC_DEBUG,
LC_DUMP, LC_DUMP,
LC_FORMAT, LC_FORMAT,
LC_GROUP, LC_GROUP,
LC_SETS, LC_SETS,
LC_TEST, LC_TEST,
LC_VERBOSE, LC_VERBOSE,
LC_IGNORELOCKING, LC_IGNORELOCKING,
LC_SEPARATOR, LC_SEPARATOR,
LC_DEVICES, /* Add new options below this one ! */ LC_DEVICES,
LC_OPTIONS_SIZE, /* Must be the last enumerator. */ LC_PARTCHAR,
LC_CREATE,
LC_REBUILD_SET,
LC_REBUILD_DISK,
LC_HOT_SPARE_SET, /* Add new options below this one ! */
LC_OPTIONS_SIZE, /* Must be the last enumerator. */
}; };
/* Options access macros. */ /* Options access macros. */
/* Return option counter. */ /* Return option counter. */
#define OPT_COLUMN(lc) (lc_opt(lc, LC_COLUMN)) #define OPT_COLUMN(lc) (lc_opt(lc, LC_COLUMN))
#define OPT_DEBUG(lc) (lc_opt(lc, LC_DEBUG)) #define OPT_DEBUG(lc) (lc_opt(lc, LC_DEBUG))
#define OPT_DEVICES(lc) (lc_opt(lc, LC_DEVICES)) #define OPT_DEVICES(lc) (lc_opt(lc, LC_DEVICES))
#define OPT_DUMP(lc) (lc_opt(lc, LC_DUMP)) #define OPT_DUMP(lc) (lc_opt(lc, LC_DUMP))
#define OPT_GROUP(lc) (lc_opt(lc, LC_GROUP)) #define OPT_GROUP(lc) (lc_opt(lc, LC_GROUP))
#define OPT_FORMAT(lc) (lc_opt(lc, LC_FORMAT)) #define OPT_FORMAT(lc) (lc_opt(lc, LC_FORMAT))
#define OPT_IGNORELOCKING(lc) (lc_opt(lc, LC_IGNORELOCKING)) #define OPT_IGNORELOCKING(lc) (lc_opt(lc, LC_IGNORELOCKING))
#define OPT_SEPARATOR(lc) (lc_opt(lc, LC_SEPARATOR)) #define OPT_SEPARATOR(lc) (lc_opt(lc, LC_SEPARATOR))
#define OPT_SETS(lc) (lc_opt(lc, LC_SETS)) #define OPT_SETS(lc) (lc_opt(lc, LC_SETS))
#define OPT_TEST(lc) (lc_opt(lc, LC_TEST)) #define OPT_TEST(lc) (lc_opt(lc, LC_TEST))
#define OPT_VERBOSE(lc) (lc_opt(lc, LC_VERBOSE)) #define OPT_VERBOSE(lc) (lc_opt(lc, LC_VERBOSE))
#define OPT_PARTCHAR(lc) (lc_opt(lc, LC_PARTCHAR))
#define OPT_CREATE(lc) (lc_opt(lc, LC_CREATE))
#define OPT_HOT_SPARE_SET(lc) (lc_opt(lc, LC_HOT_SPARE_SET))
#define OPT_REBUILD_DISK(lc) (lc_opt(lc, LC_REBUILD_DISK))
/* Return option value. */ /* Return option value. */
#define OPT_STR(lc, o) (lc->options[o].arg.str) #define OPT_STR(lc, o) (lc->options[o].arg.str)
#define OPT_STR_COLUMN(lc) OPT_STR(lc, LC_COLUMN) #define OPT_STR_COLUMN(lc) OPT_STR(lc, LC_COLUMN)
#define OPT_STR_FORMAT(lc) OPT_STR(lc, LC_FORMAT) #define OPT_STR_FORMAT(lc) OPT_STR(lc, LC_FORMAT)
#define OPT_STR_SEPARATOR(lc) OPT_STR(lc, LC_SEPARATOR) #define OPT_STR_SEPARATOR(lc) OPT_STR(lc, LC_SEPARATOR)
#define OPT_STR_PARTCHAR(lc) OPT_STR(lc, LC_PARTCHAR)
#define OPT_STR_HOT_SPARE_SET(lc) OPT_STR(lc, LC_HOT_SPARE_SET)
#define OPT_STR_REBUILD_DISK(lc) OPT_STR(lc, LC_REBUILD_DISK)
struct lib_version { struct lib_version {
const char *text; const char *text;
const char *date; const char *date;
struct { struct {
unsigned int major; unsigned int major;
unsigned int minor; unsigned int minor;
unsigned int sub_minor; unsigned int sub_minor;
const char *suffix; const char *suffix;
} v; } v;
skipping to change at line 95 skipping to change at line 110
struct lib_context { struct lib_context {
struct lib_version version; struct lib_version version;
char *cmd; char *cmd;
/* Option counters used throughout the library. */ /* Option counters used throughout the library. */
struct lib_options options[LC_OPTIONS_SIZE]; struct lib_options options[LC_OPTIONS_SIZE];
/* /*
* Lists for: * Lists for:
* *
* o metadata format handlers the library supports * o metadata format handlers the library supports
* o block devices discovered * o block devices discovered
* o RAID devices discovered * o RAID devices discovered
* o RAID sets grouped * o RAID sets grouped
*/ */
struct list_head lists[LC_LISTS_SIZE]; struct list_head lists[LC_LISTS_SIZE];
char *locking_name; /* Locking mechanism selector. */ char *locking_name; /* Locking mechanism selector. */
struct locking *lock; /* Resource locking. */ struct locking *lock; /* Resource locking. */
mode_t mode; /* File/directrory create modes. */ mode_t mode; /* File/directrory create modes. */
struct { struct {
const char *error; /* For error mappings. */ const char *error; /* For error mappings. */
} path; } path;
}; };
/* Options actions dmraid performs. */
enum action {
UNDEF = 0x0,
ACTIVATE = 0x1,
DEACTIVATE = 0x2,
FORMAT = 0x4,
#ifndef DMRAID_MINI
BLOCK_DEVICES = 0x8,
COLUMN = 0x10,
DBG = 0x20,
DUMP = 0x40,
DMERASE = 0x80,
GROUP = 0x100,
#endif
HELP = 0x200,
#ifndef DMRAID_MINI
LIST_FORMATS = 0x400,
# ifdef DMRAID_NATIVE_LOG
NATIVE_LOG = 0x800,
# endif
#endif
NOPARTITIONS = 0x1000,
#ifndef DMRAID_MINI
RAID_DEVICES = 0x2000,
RAID_SETS = 0x4000,
TEST = 0x8000,
VERBOSE = 0x10000,
ACTIVE = 0x20000,
INACTIVE = 0x40000,
SEPARATOR = 0x80000,
#endif
VERSION = 0x100000,
IGNORELOCKING = 0x200000,
#ifndef DMRAID_MINI
DEL_SETS = 0x400000,
CREATE = 0x800000,
REBUILD = 0x1000000,
SPARE = 0x2000000,
MEDIA = 0x4000000,
END_REBUILD = 0x8000000,
GET_MEMBERS = 0x10000000,
PARTCHAR = 0x20000000,
#endif
};
/* Arguments allowed ? */
enum args {
NO_ARGS,
ARGS,
};
/* Define which metadata is needed before we can call post functions. */
enum metadata_need {
M_NONE = 0x00,
M_DEVICE = 0x01,
M_RAID = 0x02,
M_SET = 0x04,
};
enum id {
ROOT,
ANY_ID,
};
enum lock {
LOCK,
NO_LOCK,
};
/*
* Pre and Post functions to perform for an option.
*/
struct prepost {
enum action action;
enum metadata_need metadata;
enum id id;
enum lock lock;
int (*pre) (int arg);
int arg;
int (*post) (struct lib_context * lc, int arg);
};
extern struct lib_context *alloc_lib_context(char **argv); extern struct lib_context *alloc_lib_context(char **argv);
extern void free_lib_context(struct lib_context *lc); extern void free_lib_context(struct lib_context *lc);
extern int lc_opt(struct lib_context *lc, enum lc_options o); extern int lc_opt(struct lib_context *lc, enum lc_options o);
const char *lc_opt_arg(struct lib_context *lc, enum lc_options o); const char *lc_opt_arg(struct lib_context *lc, enum lc_options o);
const char *lc_stralloc_opt(struct lib_context *lc, enum lc_options o, const char *lc_stralloc_opt(struct lib_context *lc, enum lc_options o,
char *arg); char *arg);
const char *lc_strcat_opt(struct lib_context *lc, enum lc_options o, const char *lc_strcat_opt(struct lib_context *lc, enum lc_options o,
char *arg, const char delim); char *arg, const char delim);
extern int lc_inc_opt(struct lib_context *lc, int o); extern int lc_inc_opt(struct lib_context *lc, int o);
extern struct list_head *lc_list(struct lib_context *lc, int l); extern struct list_head *lc_list(struct lib_context *lc, int l);
extern const char *libdmraid_date(struct lib_context *lc); extern const char *libdmraid_date(struct lib_context *lc);
extern const char *libdmraid_version(struct lib_context *lc); extern const char *libdmraid_version(struct lib_context *lc);
#endif #endif
 End of changes. 12 change blocks. 
16 lines changed or deleted 114 lines changed or added


 list.h   list.h 
/* /*
* Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH. * Copyright (C) 2004-2008 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved. * All rights reserved.
* *
* Copyright (C) 2007 Intel Corporation. All rights reserved.
* November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
*
* See file LICENSE at the top of this source tree for license information. * See file LICENSE at the top of this source tree for license information.
*/ */
#ifndef _LIST_H #ifndef _LIST_H
#define _LIST_H #define _LIST_H
/* /*
* Double-linked list definitons and macros. * Double-linked list definitons and macros.
*/ */
skipping to change at line 26 skipping to change at line 29
struct list_head *next; struct list_head *next;
struct list_head *prev; struct list_head *prev;
}; };
#define INIT_LIST_HEAD(a) do { (a)->next = (a)->prev = a; } while(0) #define INIT_LIST_HEAD(a) do { (a)->next = (a)->prev = a; } while(0)
#define LIST_HEAD(a) struct list_head a = { .next = &a, .prev = & a } #define LIST_HEAD(a) struct list_head a = { .next = &a, .prev = & a }
#define list_empty(pos) ((pos)->next == pos) #define list_empty(pos) ((pos)->next == pos)
static inline void __list_add(struct list_head *c_new, static inline void
struct list_head *prev, __list_add(struct list_head *c_new,
struct list_head *next) struct list_head *prev, struct list_head *next)
{ {
next->prev = c_new; next->prev = c_new;
c_new->next = next; c_new->next = next;
c_new->prev = prev; c_new->prev = prev;
prev->next = c_new; prev->next = c_new;
} }
/* Add an element 'new' after position 'pos' to a list. */ /* Add an element 'new' after position 'pos' to a list. */
#define list_add(c_new, pos) __list_add(c_new, pos, (pos)->next) #define list_add(c_new, pos) __list_add(c_new, pos, (pos)->next)
skipping to change at line 77 skipping to change at line 80
/* /*
* Walk a list using a temporary pointer, * Walk a list using a temporary pointer,
* so that elements can be deleted safely. * so that elements can be deleted safely.
*/ */
#define list_for_each_safe(pos, n, head) \ #define list_for_each_safe(pos, n, head) \
for (pos = (head)->next, n = pos->next; \ for (pos = (head)->next, n = pos->next; \
pos != (head); \ pos != (head); \
pos = n, n = pos->next) pos = n, n = pos->next)
#define list_for_each_entry_safe(pos, n, head, member) \
for (pos = list_entry((head)->next, typeof(*pos), member),\
n = list_entry(pos->member.next, typeof(*pos), member); \
&pos->member != (head); \
pos = n, n = list_entry(pos->member.next, typeof(*pos), member))
#endif #endif
 End of changes. 4 change blocks. 
4 lines changed or deleted 13 lines changed or added


 locking.h   locking.h 
skipping to change at line 20 skipping to change at line 20
/* I want to be prepared for finer grained locking... */ /* I want to be prepared for finer grained locking... */
struct resource { struct resource {
char *name; char *name;
}; };
/* Locking abstraction. */ /* Locking abstraction. */
struct lib_context; struct lib_context;
struct locking { struct locking {
const char *name; const char *name;
int (*lock)(struct lib_context *lc, struct resource *res); int (*lock) (struct lib_context * lc, struct resource * res);
void (*unlock)(struct lib_context *lc, struct resource *res); void (*unlock) (struct lib_context * lc, struct resource * res);
void *c_private; /* Private context. */ void *c_private; /* Private context. */
}; };
extern int init_locking(struct lib_context *lc); extern int init_locking(struct lib_context *lc);
extern int lock_resource(struct lib_context *lc, struct resource *res); extern int lock_resource(struct lib_context *lc, struct resource *res);
extern void unlock_resource(struct lib_context *lc, struct resource *res); extern void unlock_resource(struct lib_context *lc, struct resource *res);
#endif #endif
 End of changes. 1 change blocks. 
3 lines changed or deleted 3 lines changed or added


 metadata.h   metadata.h 
/* /*
* Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH. * Copyright (C) 2004-2008 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved. * All rights reserved.
* *
* Copyright (C) 2007 Intel Corporation. All rights reserved.
* November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
*
* See file LICENSE at the top of this source tree for license information. * See file LICENSE at the top of this source tree for license information.
*/ */
#ifndef _META_H_ #ifndef _META_H_
#define _META_H_ #define _META_H_
#include <dmraid/list.h> #include <dmraid/list.h>
#include <stdint.h> #include <stdint.h>
/* /*
* Unified RAID set types. * Unified RAID set types.
*/ */
enum type { enum type {
t_undef = 0x01, t_undef = 0x01,
t_group = 0x02, /* To group subsets (eg, Intel Software RAID). * t_group = 0x02, /* To group subsets (eg, Intel Software RAID
/ ). */
t_partition = 0x04, /* FIXME: remove in favour of kpartx ? */ t_partition = 0x04, /* FIXME: remove in favour of kpartx ? */
t_spare = 0x08, t_spare = 0x08,
t_linear = 0x10, t_linear = 0x10,
t_raid0 = 0x20, t_raid0 = 0x20,
t_raid1 = 0x40, t_raid1 = 0x40,
/* /*
* Higher RAID types below not supported (yet) * Higher RAID types below not supported (yet)
* because of device-mapper constraints. * because of device-mapper constraints.
*/ */
t_raid4 = 0x80, t_raid4 = 0x80,
t_raid5_ls = 0x100, t_raid5_ls = 0x100,
t_raid5_rs = 0x200, t_raid5_rs = 0x200,
t_raid5_la = 0x400, t_raid5_la = 0x400,
t_raid5_ra = 0x800, t_raid5_ra = 0x800,
t_raid6 = 0x1000, t_raid6 = 0x1000,
}; };
/* Check macros for types. */ /* Check macros for types. */
#define T_UNDEF(r) ((r)->type & t_undef) #define T_UNDEF(r) ((r)->type & t_undef)
#define T_GROUP(r) ((r)->type & t_group) #define T_GROUP(r) ((r)->type & t_group)
#define T_PARTITION(r) ((r)->type & t_partition) #define T_PARTITION(r) ((r)->type & t_partition)
#define T_SPARE(r) ((r)->type & t_spare) #define T_SPARE(r) ((r)->type & t_spare)
#define T_LINEAR(r) ((r)->type & t_linear) #define T_LINEAR(r) ((r)->type & t_linear)
#define T_RAID0(r) ((r)->type & t_raid0) #define T_RAID0(r) ((r)->type & t_raid0)
#define T_RAID1(r) ((r)->type & t_raid1) #define T_RAID1(r) ((r)->type & t_raid1)
skipping to change at line 66 skipping to change at line 69
ct_spare, ct_spare,
}; };
/* /*
* Mapping struct for RAID type unification. * Mapping struct for RAID type unification.
* *
* Format handler allocates an array and inserts mappings * Format handler allocates an array and inserts mappings
* from format specific types to the unified ones above. * from format specific types to the unified ones above.
*/ */
struct types { struct types {
unsigned int type; /* Must be long enough for vendor definition. */ unsigned int type; /* Must be long enough for vendor definition
enum type unified_type; . */
enum type unified_type;
}; };
/* RAID disk/set status. */ /* RAID disk/set status. */
enum status { enum status {
s_undef = 0x01, s_undef = 0x01,
s_broken = 0x02, /* Completely broken (not accessible). */ s_broken = 0x02, /* Completely broken (not accessible). */
s_inconsistent = 0x04, /* RAID disk/set inconsistent (needs s_inconsistent = 0x04, /* RAID disk/set inconsistent (needs
synchronization or reconfiguration). */ synchronization or reconfiguration). */
/* FIXME: is s_nosync sufficient or do I need s_upgrade (eg, NVidia) */ /* FIXME: is s_nosync sufficient or do I need s_upgrade (eg, NVidia) */
s_nosync = 0x08, /* RAID disk/set *not* in sync s_nosync = 0x08, /* RAID disk/set *not* in sync
(needs synchronization). */ (needs synchronization). */
s_ok = 0x10, /* Fully operational. */ s_ok = 0x10, /* Fully operational. */
s_setup = 0x20, /* Only during RAID setup transition. */ s_setup = 0x20, /* Only during RAID setup transition. */
s_init = 0x40, /* RAID set to be created */
s_config = 0x80, /* RAID set hasn't been configured */
}; };
/* /*
* Mapping struct for RAID status unification. * Mapping struct for RAID status unification.
* *
* Format handler allocates an array and inserts mappings * Format handler allocates an array and inserts mappings
* from format specific status to the unified ones above. * from format specific status to the unified ones above.
*/ */
enum compare { AND, EQUAL }; enum compare { AND, EQUAL };
struct states { struct states {
skipping to change at line 105 skipping to change at line 110
/* Check macros for states. */ /* Check macros for states. */
#define S_UNDEF(status) ((status) & s_undef) #define S_UNDEF(status) ((status) & s_undef)
#define S_BROKEN(status) ((status) & s_broken) #define S_BROKEN(status) ((status) & s_broken)
#define S_INCONSISTENT(status) ((status) & s_inconsistent) #define S_INCONSISTENT(status) ((status) & s_inconsistent)
#define S_NOSYNC(status) ((status) & s_nosync) #define S_NOSYNC(status) ((status) & s_nosync)
#define S_OK(status) ((status) & s_ok) #define S_OK(status) ((status) & s_ok)
#define S_SETUP(status) ((status) & s_setup) #define S_SETUP(status) ((status) & s_setup)
/* find_*() function enums */ /* find_*() function enums */
enum find { enum find {
FIND_TOP, /* Search top level RAID sets only. */ FIND_TOP, /* Search top level RAID sets only. */
FIND_ALL, /* Decend all RAID set trees. */ FIND_ALL, /* Decend all RAID set trees. */
}; };
/* Device information. */ /* Device information. */
struct dev_info { struct dev_info {
struct list_head list; /* Global chain of discovered devices. */ struct list_head list; /* Global chain of discovered devices. */
char *path; /* Actual device node path. */ char *path; /* Actual device node path. */
char *serial; /* ATA/SCSI serial number. */ char *serial; /* ATA/SCSI serial number. */
uint64_t sectors; /* Device size. */ uint64_t sectors; /* Device size. */
}; };
/* Metadata areas and size stored on a RAID device. */ /* Metadata areas and size stored on a RAID device. */
struct meta_areas { struct meta_areas {
uint64_t offset; /* on disk metadata offset in sectors. */ uint64_t offset; /* on disk metadata offset in sectors. */
size_t size; /* on disk metadata size in bytes. */ size_t size; /* on disk metadata size in bytes. */
void *area; /* pointer to format specific metadata. */ void *area; /* pointer to format specific metadata. */
}; };
/* /*
* Abstracted RAID device. * Abstracted RAID device.
* *
* A RAID device is a member of a RAID set and can only * A RAID device is a member of a RAID set and can only
* exist at the lowest level of a RAID set stack (eg, for RAID10). * exist at the lowest level of a RAID set stack (eg, for RAID10).
*/ */
struct raid_dev { struct raid_dev {
struct list_head list; /* Global chain of RAID devices. */ struct list_head list; /* Global chain of RAID devices. */
struct list_head devs; /* Chain of devices belonging to set struct list_head devs; /* Chain of devices belonging to set. */
. */
char *name; /* Metadata format handler generated char *name; /* Metadata format handler generated
name of set this device belongs t name of set this device belongs to. */
o.*/
struct dev_info *di; /* Pointer to dev_info. */ struct dev_info *di; /* Pointer to dev_info. */
struct dmraid_format *fmt; /* Format handler for this device. * / struct dmraid_format *fmt; /* Format handler for this device. * /
enum status status; /* Status of device. */ enum status status; /* Status of device. */
enum type type; /* Type of device. */ enum type type; /* Type of device. */
uint64_t offset; /* Data offset on device. */ uint64_t offset; /* Data offset on device. */
uint64_t sectors; /* Length of the segment to map. */ uint64_t sectors; /* Length of the segment to map. */
unsigned int areas; /* # of metadata areas on the device . */ unsigned int areas; /* # of metadata areas on the device. */
struct meta_areas *meta_areas; /* Dynamic array of metadata areas. */ struct meta_areas *meta_areas; /* Dynamic array of metadata areas. */
/* /*
* For format handler use (eg, to keep references between calls). * For format handler use (eg, to keep references between calls).
* *
* WARNING: non pointer members need to get zeroed before exit, * WARNING: non pointer members need to get zeroed before exit,
* because the metadata layer frees c_private->ptr on clean up. * because the metadata layer frees c_private->ptr on clean up.
*/ */
union { union {
void *ptr; void *ptr;
uint32_t n32; uint32_t n32;
uint64_t n64; uint64_t n64;
} c_private; } c_private;
}; };
/* /*
* Abstracted (hierarchical) RAID set. * Abstracted (hierarchical) RAID set.
* *
* Can be used to form a tree of subsets with arbitrary depths. * Can be used to form a tree of subsets with arbitrary depths.
* Defines RAID attributes for the set as a whole (eg: RAID0, Status). * Defines RAID attributes for the set as a whole (eg: RAID0, Status).
*/ */
enum flags { enum flags {
f_maximize = 0x01, /* If set, maximize set capacity, f_maximize = 0x01, /* If set, maximize set capacity,
if not set, limit to smallest device. */ if not set, limit to smallest device. */
f_partitions = 0x02, /* Set has partitions. */ f_partitions = 0x02, /* Set has partitions. */
}; };
#define F_MAXIMIZE(rs) ((rs)->flags & f_maximize) #define F_MAXIMIZE(rs) ((rs)->flags & f_maximize)
#define F_PARTITIONS(rs) ((rs)->flags & f_partitions) #define F_PARTITIONS(rs) ((rs)->flags & f_partitions)
struct raid_set { struct raid_set {
struct list_head list; /* Chain of independent sets. */ struct list_head list; /* Chain of independent sets. */
/* /*
* List of subsets (eg, RAID10) which make up RAID set stacks. * List of subsets (eg, RAID10) which make up RAID set stacks.
* *
* Lowest level identified by list_empty() here. * Lowest level identified by list_empty() here.
*/ */
struct list_head sets; struct list_head sets;
/* /*
* List of RAID devices making up a set. * List of RAID devices making up a set.
* *
* Higher RAID sets in a stack will have list_empty() here. * Higher RAID sets in a stack will have list_empty() here.
* *
* Lowest level will hold device definitions * Lowest level will hold device definitions
* for arbitrary block devices here. * for arbitrary block devices here.
*/ */
struct list_head devs; struct list_head devs;
unsigned int total_devs; /* The number of devices expected */ unsigned int total_devs; /* The number of devices expected */
unsigned int found_devs; /* The number of devices found */ unsigned int found_devs; /* The number of devices found */
char *name; /* Name of the set. */ char *name; /* Name of the set. */
unsigned int stride; /* Stride size. */ uint64_t size; /* size of a raid set */
enum type type; /* Unified raid type. */ unsigned int stride; /* Stride size. */
enum flags flags; /* Set flags. */ enum type type; /* Unified raid type. */
enum status status; /* Status of set. */ enum flags flags; /* Set flags. */
enum status status; /* Status of set. */
}; };
extern struct raid_set *get_raid_set(struct lib_context *lc, extern struct raid_set *get_raid_set(struct lib_context *lc,
struct raid_dev *rd); struct raid_dev *rd);
extern struct dmraid_format *get_format(struct raid_set *rs); extern struct dmraid_format *get_format(struct raid_set *rs);
extern const char *get_type(struct lib_context *lc, enum type type); extern const char *get_type(struct lib_context *lc, enum type type);
extern const char *get_dm_type(struct lib_context *lc, enum type type); extern const char *get_dm_type(struct lib_context *lc, enum type type);
extern const char *get_set_type(struct lib_context *lc, void *rs); extern const char *get_set_type(struct lib_context *lc, void *rs);
extern const char *get_status(struct lib_context *lc, enum status status); extern const char *get_status(struct lib_context *lc, enum status status);
extern uint64_t total_sectors(struct lib_context *lc, struct raid_set *rs); extern uint64_t total_sectors(struct lib_context *lc, struct raid_set *rs);
extern struct dev_info *alloc_dev_info(struct lib_context *lc, char *path); extern struct dev_info *alloc_dev_info(struct lib_context *lc, char *path);
extern void free_dev_info(struct lib_context *lc, struct dev_info *di); extern void free_dev_info(struct lib_context *lc, struct dev_info *di);
extern struct raid_dev *alloc_raid_dev(struct lib_context *lc, const char * who); extern struct raid_dev *alloc_raid_dev(struct lib_context *lc, const char * who);
extern void free_raid_dev(struct lib_context *lc, struct raid_dev **rd); extern void free_raid_dev(struct lib_context *lc, struct raid_dev **rd);
extern void list_add_sorted(struct lib_context *lc, extern void list_add_sorted(struct lib_context *lc,
struct list_head *to, struct list_head *c_new, struct list_head *to, struct list_head *c_new,
int (*sort)(struct list_head *pos, int (*sort) (struct list_head * pos,
struct list_head *c_new)); struct list_head * c_new));
extern struct raid_set *alloc_raid_set(struct lib_context *lc, const char * who); extern struct raid_set *alloc_raid_set(struct lib_context *lc, const char * who);
extern unsigned int count_sets(struct lib_context *lc, struct list_head *li st); extern unsigned int count_sets(struct lib_context *lc, struct list_head *li st);
extern unsigned int count_devs(struct lib_context *lc, struct raid_set *rs, extern unsigned int count_devs(struct lib_context *lc, struct raid_set *rs,
enum count_type type); enum count_type type);
extern void free_raid_set(struct lib_context *lc, struct raid_set *rs); extern void free_raid_set(struct lib_context *lc, struct raid_set *rs);
extern struct raid_set *find_set(struct lib_context *lc, struct list_head * extern struct raid_set *find_set(struct lib_context *lc,
list, struct list_head *list, const char *name,
const char *name, enum find where); enum find where);
extern struct raid_set *find_or_alloc_raid_set(struct lib_context *lc, extern struct raid_set *find_or_alloc_raid_set(struct lib_context *lc,
char *name, enum find where, char *name, enum find where,
struct raid_dev *rd, struct raid_dev *rd,
struct list_head *list, struct list_head *list,
void (*create) (struct raid_set *sup void (*create) (struct raid_s
er, et
void *c_private), * super,
void *c_private); void *c_priva
te),
void *c_private);
#define NO_RD NULL #define NO_RD NULL
#define NO_LIST NULL #define NO_LIST NULL
#define NO_CREATE NULL #define NO_CREATE NULL
#define NO_CREATE_ARG NULL #define NO_CREATE_ARG NULL
extern const char *get_set_name(struct lib_context *lc, void *rs); extern const char *get_set_name(struct lib_context *lc, void *rs);
extern int group_set(struct lib_context *lc, char *name); extern int group_set(struct lib_context *lc, char **name);
enum set_type { enum set_type {
SETS, SETS,
PARTITIONS, PARTITIONS,
}; };
extern void process_sets(struct lib_context *lc, extern void process_sets(struct lib_context *lc,
int (*func)(struct lib_context *lc, void *rs, int arg), int (*func) (struct lib_context * lc, void *rs,
int arg, enum set_type type); int arg), int arg, enum set_type type)
;
extern int write_set(struct lib_context *lc, void *rs); extern int write_set(struct lib_context *lc, void *rs);
extern int partitioned_set(struct lib_context *lc, void *rs); extern int partitioned_set(struct lib_context *lc, void *rs);
extern int base_partitioned_set(struct lib_context *lc, void *rs); extern int base_partitioned_set(struct lib_context *lc, void *rs);
extern void discover_raid_devices(struct lib_context *lc, char **devices); extern void discover_raid_devices(struct lib_context *lc, char **devices);
extern void discover_partitions(struct lib_context *lc); extern void discover_partitions(struct lib_context *lc);
extern unsigned int count_devices(struct lib_context *lc, enum dev_type typ e); extern unsigned int count_devices(struct lib_context *lc, enum dev_type typ e);
extern enum status rd_status(struct states *states, unsigned int status, extern enum status rd_status(struct states *states, unsigned int status,
enum compare cmp); enum compare cmp);
extern enum type rd_type(struct types *types, unsigned int type); extern enum type rd_type(struct types *types, unsigned int type);
extern void file_metadata(struct lib_context *lc, const char *handler, extern void file_metadata(struct lib_context *lc, const char *handler,
char *path, void *data, size_t size, uint64_t offset); char *path, void *data, size_t size, uint64_t offs et);
extern void file_dev_size(struct lib_context *lc, const char *handler, extern void file_dev_size(struct lib_context *lc, const char *handler,
struct dev_info *di); struct dev_info *di);
extern int write_dev(struct lib_context *lc, struct raid_dev *rd, int erase ); extern int write_dev(struct lib_context *lc, struct raid_dev *rd, int erase );
extern int erase_metadata(struct lib_context *lc); extern int erase_metadata(struct lib_context *lc);
extern int delete_raidsets(struct lib_context *lc);
extern int lib_perform(struct lib_context *lc, enum action action,
struct prepost *p, char **argv);
#endif #endif
 End of changes. 32 change blocks. 
72 lines changed or deleted 82 lines changed or added


 misc.h   misc.h 
/* /*
* Copyright (C) 2004,2005 Heinz Mauelshagen, Red Hat GmbH. * Copyright (C) 2004-2005 Heinz Mauelshagen, Red Hat GmbH.
* All rights reserved. * All rights reserved.
* *
* Copyright (C) 2007 Intel Corporation. All rights reserved.
* November, 2007 - additions for Create, Delete, Rebuild & Raid 10.
*
* See file LICENSE at the top of this source tree for license information. * See file LICENSE at the top of this source tree for license information.
*/ */
#ifndef _MISC_H_ #ifndef _MISC_H_
#define _MISC_H_ #define _MISC_H_
#define DM_ASSERT(__cond) do { if (!(__cond)) { printf("ASSERT file:%s line
:%d fuction:%s cond: %s\n", __FILE__, __LINE__, __FUNCTION__, #__cond); } }
while(0);
extern struct lib_context *libdmraid_init(int argc, char **argv); extern struct lib_context *libdmraid_init(int argc, char **argv);
extern void libdmraid_exit(struct lib_context *lc); extern void libdmraid_exit(struct lib_context *lc);
extern void sysfs_workaround(struct lib_context *lc); extern void sysfs_workaround(struct lib_context *lc);
extern void mk_alpha(struct lib_context *lc, char *str, size_t len); extern void mk_alpha(struct lib_context *lc, char *str, size_t len);
extern char *get_basename(struct lib_context *lc, char *str); extern char *get_basename(struct lib_context *lc, char *str);
extern char *get_dirname(struct lib_context *lc, char *str); extern char *get_dirname(struct lib_context *lc, char *str);
extern char *remove_white_space(struct lib_context *lc, char *str, size_t l en); extern char *remove_white_space(struct lib_context *lc, char *str, size_t l en);
extern void remove_tail_space(char *str);
extern char *remove_delimiter(char *ptr, char c); extern char *remove_delimiter(char *ptr, char c);
extern void add_delimiter(char **ptr, char c); extern void add_delimiter(char **ptr, char c);
extern char *replace_delimiter(char *str, char delim, char c);
extern int mk_dir(struct lib_context *lc, const char *dir); extern int mk_dir(struct lib_context *lc, const char *dir);
extern int read_file(struct lib_context *lc, const char *who, char *path, extern int read_file(struct lib_context *lc, const char *who, char *path,
void *buffer, size_t size, loff_t offset); void *buffer, size_t size, loff_t offset);
extern int write_file(struct lib_context *lc, const char *who, char *path, extern int write_file(struct lib_context *lc, const char *who, char *path,
void *buffer, size_t size, loff_t offset); void *buffer, size_t size, loff_t offset);
extern int yes_no_prompt(struct lib_context *lc, const char *prompt, ...); extern int yes_no_prompt(struct lib_context *lc, const char *prompt, ...);
extern void free_string(struct lib_context *lc, char **string); extern void free_string(struct lib_context *lc, char **string);
extern int p_fmt(struct lib_context *lc, char **string, const char *fmt, .. .); extern int p_fmt(struct lib_context *lc, char **string, const char *fmt, .. .);
static inline uint64_t round_down(uint64_t what, unsigned int by) static inline uint64_t
round_down(uint64_t what, unsigned int by)
{ {
return what & ~((uint64_t) by - 1); return what & ~((uint64_t) by - 1);
} }
static inline uint64_t round_up(uint64_t what, unsigned int by) static inline uint64_t
round_up(uint64_t what, unsigned int by)
{ {
uint64_t t = round_down(what, by); uint64_t t = round_down(what, by);
return t == what ? t : t + by; return t == what ? t : t + by;
} }
static inline uint64_t div_up(uint64_t what, unsigned int by) static inline uint64_t
div_up(uint64_t what, unsigned int by)
{ {
return round_up(what, by) / by; return round_up(what, by) / by;
} }
#ifdef DMRAID_LED
/* Definitions for LED support */
#define LED_OFF 0
#define LED_REBUILD 1
int led(char *rd, int status);
#endif
#endif #endif
 End of changes. 9 change blocks. 
4 lines changed or deleted 24 lines changed or added


 reconfig.h   reconfig.h 
/* /*
* Copyright (C) 2006 Darrick Wong, IBM. * Copyright (C) 2006 Darrick Wong, IBM.
* All rights reserved. * All rights reserved.
* *
* Copyright (C) 2006 Heinz Mauelshagen Red Hat GmbH. * Copyright (C) 2006-2008 Heinz Mauelshagen Red Hat GmbH.
* All rights reserved. * All rights reserved.
* *
* See the file LICENSE at the top of this source tree for license informat ion. * See the file LICENSE at the top of this source tree for license informat ion.
*/ */
#ifndef _RECONFIG_H_ #ifndef _RECONFIG_H_
#define _RECONFIG_H_ #define _RECONFIG_H_
#include <dmraid/metadata.h> #include <dmraid/metadata.h>
#include <dmraid/list.h> #include <dmraid/list.h>
skipping to change at line 53 skipping to change at line 53
char *name; char *name;
}; };
extern int add_dev_to_set(struct lib_context *lc, struct raid_set *rs, extern int add_dev_to_set(struct lib_context *lc, struct raid_set *rs,
struct raid_dev *rd); struct raid_dev *rd);
extern int del_dev_in_set(struct lib_context *lc, struct raid_set *rs, extern int del_dev_in_set(struct lib_context *lc, struct raid_set *rs,
struct raid_dev *rd); struct raid_dev *rd);
extern void end_log(struct lib_context *lc, struct list_head *log); extern void end_log(struct lib_context *lc, struct list_head *log);
extern int revert_log(struct lib_context *lc, struct list_head *log); extern int revert_log(struct lib_context *lc, struct list_head *log);
extern int hot_spare_add(struct lib_context *lc, struct raid_set *rs);
extern struct raid_set *find_group(struct lib_context *lc,
struct raid_set *sub_rs);
extern int rebuild_raidset(struct lib_context *lc, char *set_name);
#endif #endif
 End of changes. 2 change blocks. 
2 lines changed or deleted 6 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/