]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.h
Add 'supertype' arg to almost all metadata methods.
[thirdparty/mdadm.git] / mdadm.h
diff --git a/mdadm.h b/mdadm.h
index bfc2138884d2bca6b467a391de32b65ea40f69be..bf583b41e9ce347fa4d54b0c7be1fbe4847345ec 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
 
 #define        _GNU_SOURCE
 #include       <unistd.h>
-#ifndef __dietlibc__
+#if !defined(__dietlibc__) && !defined(__KLIBC__)
 extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
+#else
+# if defined(__NO_STAT64) || __WORDSIZE != 32
+# define lseek64 lseek
+# endif
 #endif
 
 #include       <sys/types.h>
@@ -93,6 +97,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
                     ((x) & 0x00000000ff000000ULL) << 8 | \
                     ((x) & 0x000000ff00000000ULL) >> 8)
 
+#if !defined(__KLIBC__)
 #if BYTE_ORDER == LITTLE_ENDIAN
 #define        __cpu_to_le16(_x) (_x)
 #define __cpu_to_le32(_x) (_x)
@@ -110,6 +115,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 #else
 #  error "unknown endianness."
 #endif
+#endif /* __KLIBC__ */
 
 
 
@@ -146,13 +152,17 @@ enum mode {
        MISC,
        MONITOR,
        GROW,
+       INCREMENTAL,
+       AUTODETECT,
 };
 
 extern char short_options[];
+extern char short_bitmap_options[];
 extern char short_bitmap_auto_options[];
 extern struct option long_options[];
 extern char Version[], Usage[], Help[], OptionHelp[],
        Help_create[], Help_build[], Help_assemble[], Help_grow[],
+       Help_incr[],
        Help_manage[], Help_misc[], Help_monitor[], Help_config[];
 
 /* for option that don't have short equivilents, we assign arbitrary
@@ -169,6 +179,7 @@ enum special_options {
        HomeHost,
        AutoHomeHost,
        Symlinks,
+       AutoDetect,
 };
 
 /* structures read from config file */
@@ -184,7 +195,7 @@ enum special_options {
 #define UnSet (0xfffe)
 typedef struct mddev_ident_s {
        char    *devname;
-       
+
        int     uuid_set;
        int     uuid[4];
        char    name[33];
@@ -238,6 +249,24 @@ struct mdstat_ent {
 extern struct mdstat_ent *mdstat_read(int hold, int start);
 extern void free_mdstat(struct mdstat_ent *ms);
 extern void mdstat_wait(int seconds);
+extern int mddev_busy(int devnum);
+
+struct map_ent {
+       struct map_ent *next;
+       int     devnum;
+       int     major,minor;
+       int     uuid[4];
+       char    *path;
+};
+extern int map_update(struct map_ent **mpp, int devnum, int major, int minor,
+                     int uuid[4], char *path);
+extern struct map_ent *map_by_uuid(struct map_ent **map, int uuid[4]);
+extern void map_read(struct map_ent **melp);
+extern int map_write(struct map_ent *mel);
+extern void map_delete(struct map_ent **mapp, int devnum);
+extern void map_free(struct map_ent *map);
+extern void map_add(struct map_ent **melp,
+                   int devnum, int major, int minor, int uuid[4], char *path);
 
 /* Data structure for holding info read from sysfs */
 struct sysdev {
@@ -258,6 +287,8 @@ struct sysarray {
        int     level;
        int     spares;
        int     cache_size;
+       int     mismatch_cnt;
+       int     major_version, minor_version;
 };
 /* various details can be requested */
 #define        GET_LEVEL       1
@@ -265,6 +296,8 @@ struct sysarray {
 #define        GET_COMPONENT   4
 #define        GET_CHUNK       8
 #define GET_CACHE      16
+#define        GET_MISMATCH    32
+#define        GET_VERSION     64
 
 #define        GET_DEVS        1024 /* gets role, major, minor */
 #define        GET_OFFSET      2048
@@ -275,6 +308,7 @@ struct sysarray {
 /* If fd >= 0, get the array it is open on,
  * else use devnum. >=0 -> major9. <0.....
  */
+extern void sysfs_free(struct sysarray *sra);
 extern struct sysarray *sysfs_read(int fd, int devnum, unsigned long options);
 extern int sysfs_set_str(struct sysarray *sra, struct sysdev *dev,
                         char *name, char *val);
@@ -307,18 +341,20 @@ extern char *map_dev(int major, int minor, int create);
 
 
 extern struct superswitch {
-       void (*examine_super)(void *sbv, char *homehost);
-       void (*brief_examine_super)(void *sbv);
-       void (*detail_super)(void *sbv, char *homehost);
-       void (*brief_detail_super)(void *sbv);
-       void (*uuid_from_super)(int uuid[4], void *sbv);
-       void (*getinfo_super)(struct mdinfo *info, void *sbv);
-       int (*match_home)(void *sbv, char *homehost);
-       int (*update_super)(struct mdinfo *info, void *sbv, char *update,
+       void (*examine_super)(struct supertype *st, void *sbv, char *homehost);
+       void (*brief_examine_super)(struct supertype *st, void *sbv);
+       void (*detail_super)(struct supertype *st, void *sbv, char *homehost);
+       void (*export_super)(struct supertype *st, void *sbv);
+       void (*brief_detail_super)(struct supertype *st, void *sbv);
+       void (*uuid_from_super)(struct supertype *st, int uuid[4], void *sbv);
+       void (*getinfo_super)(struct supertype *st, struct mdinfo *info, void *sbv);
+       int (*match_home)(struct supertype *st, void *sbv, char *homehost);
+       int (*update_super)(struct supertype *st, struct mdinfo *info,
+                           void *sbv, char *update,
                            char *devname, int verbose,
                            int uuid_set, char *homehost);
-       int (*init_super)(struct supertype *st, void **sbp, mdu_array_info_t *info, unsigned long long size, char *name, char *homehost);
-       void (*add_to_super)(void *sbv, mdu_disk_info_t *dinfo);
+       int (*init_super)(struct supertype *st, void **sbp, mdu_array_info_t *info, unsigned long long size, char *name, char *homehost, int *uuid);
+       void (*add_to_super)(struct supertype *st, void *sbv, mdu_disk_info_t *dinfo);
        int (*store_super)(struct supertype *st, int fd, void *sbv);
        int (*write_init_super)(struct supertype *st, void *sbv, mdu_disk_info_t *dinfo, char *devname);
        int (*compare_super)(void **firstp, void *secondv);
@@ -330,6 +366,7 @@ extern struct superswitch {
                                   unsigned long long size, int may_change, int major);
        void (*locate_bitmap)(struct supertype *st, int fd, void *sbv);
        int (*write_bitmap)(struct supertype *st, int fd, void *sbv);
+       void (*free_super)(struct supertype *st, void *super);
        int major;
        int swapuuid; /* true if uuid is bigending rather than hostendian */
 } super0, super1, *superlist[];
@@ -342,6 +379,9 @@ struct supertype {
 
 extern struct supertype *super_by_version(int vers, int minor);
 extern struct supertype *guess_super(int fd);
+extern int get_dev_size(int fd, char *dname, unsigned long long *sizep);
+extern void get_one_disk(int mdfd, mdu_array_info_t *ainf,
+                        mdu_disk_info_t *disk);
 
 #if __GNUC__ < 3
 struct stat64;
@@ -362,6 +402,11 @@ struct stat64;
 # undef HAVE_NFTW
 #endif
 
+#if defined(__KLIBC__)
+# undef HAVE_NFTW
+# undef HAVE_FTW
+#endif
+
 #ifndef HAVE_NFTW
 # define FTW_PHYS 1
 # ifndef HAVE_FTW
@@ -382,6 +427,7 @@ extern int Manage_resize(char *devname, int fd, long long size, int raid_disks);
 extern int Manage_reconfig(char *devname, int fd, int layout);
 extern int Manage_subdevs(char *devname, int fd,
                          mddev_dev_t devlist, int verbose);
+extern int autodetect(void);
 extern int Grow_Add_device(char *devname, int fd, char *newdev);
 extern int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int write_behind, int force);
 extern int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
@@ -406,12 +452,12 @@ extern int Build(char *mddev, int mdfd, int chunk, int level, int layout,
 
 extern int Create(struct supertype *st, char *mddev, int mdfd,
                  int chunk, int level, int layout, unsigned long long size, int raiddisks, int sparedisks,
-                 char *name, char *homehost,
+                 char *name, char *homehost, int *uuid,
                  int subdevs, mddev_dev_t devlist,
                  int runstop, int verbose, int force, int assume_clean,
                  char *bitmap_file, int bitmap_chunk, int write_behind, int delay);
 
-extern int Detail(char *dev, int brief, int test, char *homehost);
+extern int Detail(char *dev, int brief, int export, int test, char *homehost);
 extern int Query(char *dev);
 extern int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust,
                   struct supertype *forcest, char *homehost);
@@ -421,6 +467,12 @@ extern int Monitor(mddev_dev_t devlist,
                   int dosyslog, int test, char *pidfile);
 
 extern int Kill(char *dev, int force, int quiet);
+extern int Wait(char *dev);
+
+extern int Incremental(char *devname, int verbose, int runstop,
+                      struct supertype *st, char *homehost, int autof);
+extern void RebuildMap(void);
+extern int IncrementalScan(int verbose);
 
 extern int CreateBitmap(char *filename, int force, char uuid[16],
                        unsigned long chunksize, unsigned long daemon_sleep,
@@ -428,7 +480,7 @@ extern int CreateBitmap(char *filename, int force, char uuid[16],
                        unsigned long long array_size,
                        int major);
 extern int ExamineBitmap(char *filename, int brief, struct supertype *st);
-extern int bitmap_update_uuid(int fd, int *uuid);
+extern int bitmap_update_uuid(int fd, int *uuid, int swap);
 
 extern int md_get_version(int fd);
 extern int get_linux_version(void);
@@ -444,6 +496,7 @@ extern int is_standard(char *dev, int *nump);
 extern int parse_auto(char *str, char *msg, int config);
 extern mddev_ident_t conf_get_ident(char *dev);
 extern mddev_dev_t conf_get_devs(void);
+extern int conf_test_dev(char *devname);
 extern struct createinfo *conf_get_create_info(void);
 extern void set_conffile(char *file);
 extern char *conf_get_mailaddr(void);
@@ -456,6 +509,7 @@ extern void free_line(char *line);
 extern int match_oneof(char *devices, char *devname);
 extern void uuid_from_super(int uuid[4], mdp_super_t *super);
 extern int same_uuid(int a[4], int b[4], int swapuuid);
+extern void copy_uuid(void *a, int b[4], int swapuuid);
 /* extern int compare_super(mdp_super_t *first, mdp_super_t *second);*/
 extern unsigned long calc_csum(void *super, int bytes);
 extern int enough(int level, int raid_disks, int layout, int clean,
@@ -474,6 +528,8 @@ extern char *get_md_name(int dev);
 extern char DefaultConfFile[];
 
 extern int open_mddev(char *dev, int autof);
+extern int open_mddev_devnum(char *devname, int devnum, char *name,
+                            char *chosen_name);
 
 
 #define        LEVEL_MULTIPATH         (-4)