]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.h
Create: support --readonly flag.
[thirdparty/mdadm.git] / mdadm.h
diff --git a/mdadm.h b/mdadm.h
index e60a7066cc481f2c6a04881b6367ab0dcc761212..564b5105c186da5dde80bde0169bf0dc4256b8d0 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -71,10 +71,10 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 
 /* MAP_DIR should be somewhere that persists across the pivotroot
  * from early boot to late boot.
- * Currently /dev seems to be the only option on most distros.
+ * /run  seems to have emerged as the best standard.
  */
 #ifndef MAP_DIR
-#define MAP_DIR "/dev/.mdadm"
+#define MAP_DIR "/run/mdadm"
 #endif /* MAP_DIR */
 /* MAP_FILE is what we name the map file we put in MAP_DIR, in case you
  * want something other than the default of "map"
@@ -83,7 +83,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
 #define MAP_FILE "map"
 #endif /* MAP_FILE */
 /* MDMON_DIR is where pid and socket files used for communicating
- * with mdmon normally live.  It *should* be /var/run, but when
+ * with mdmon normally live.  Best is /var/run/mdadm as
  * mdmon is needed at early boot then it needs to write there prior
  * to /var/run being mounted read/write, and it also then needs to
  * persist beyond when /var/run is mounter read-only.  So, to be
@@ -91,7 +91,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
  * boot process and stays up as long as possible during shutdown.
  */
 #ifndef MDMON_DIR
-#define MDMON_DIR "/dev/.mdadm/"
+#define MDMON_DIR "/run/mdadm"
 #endif /* MDMON_DIR */
 
 /* FAILED_SLOTS is where to save files storing recent removal of array
@@ -99,7 +99,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
  * slot for array recovery
  */
 #ifndef FAILED_SLOTS_DIR
-#define FAILED_SLOTS_DIR "/dev/.mdadm/failed-slots"
+#define FAILED_SLOTS_DIR "/run/mdadm/failed-slots"
 #endif /* FAILED_SLOTS */
 
 #include       "md_u.h"
@@ -264,6 +264,7 @@ enum mode {
        GROW,
        INCREMENTAL,
        AUTODETECT,
+       mode_count
 };
 
 extern char short_options[];
@@ -271,6 +272,7 @@ extern char short_bitmap_options[];
 extern char short_bitmap_auto_options[];
 extern struct option long_options[];
 extern char Version[], Usage[], Help[], OptionHelp[],
+       *mode_help[],
        Help_create[], Help_build[], Help_assemble[], Help_grow[],
        Help_incr[],
        Help_manage[], Help_misc[], Help_monitor[], Help_config[];
@@ -323,6 +325,7 @@ enum special_options {
        Continue,
        OffRootOpt,
        Prefer,
+       KillOpt,
 };
 
 /* structures read from config file */
@@ -374,11 +377,11 @@ struct mddev_ident {
 /* List of device names - wildcards expanded */
 struct mddev_dev {
        char *devname;
-       int disposition;        /* 'a' for add, 'r' for remove, 'f' for fail.
+       int disposition;        /* 'a' for add, 'r' for remove, 'f' for fail,
+                                * 'A' for re_add.
                                 * Not set for names read from .config
                                 */
        char writemostly;       /* 1 for 'set writemostly', 2 for 'clear writemostly' */
-       char re_add;
        char used;              /* set when used */
        struct mddev_dev *next;
 };
@@ -473,6 +476,8 @@ extern int sysfs_set_str(struct mdinfo *sra, struct mdinfo *dev,
                         char *name, char *val);
 extern int sysfs_set_num(struct mdinfo *sra, struct mdinfo *dev,
                         char *name, unsigned long long val);
+extern int sysfs_set_num_signed(struct mdinfo *sra, struct mdinfo *dev,
+                               char *name, long long val);
 extern int sysfs_uevent(struct mdinfo *sra, char *event);
 extern int sysfs_get_fd(struct mdinfo *sra, struct mdinfo *dev,
                        char *name);
@@ -1080,10 +1085,12 @@ extern int Build(char *mddev, int chunk, int level, int layout,
 
 
 extern int Create(struct supertype *st, char *mddev,
-                 int chunk, int level, int layout, unsigned long long size, int raiddisks, int sparedisks,
+                 int chunk, int level, int layout, unsigned long long size,
+                 int raiddisks, int sparedisks,
                  char *name, char *homehost, int *uuid,
                  int subdevs, struct mddev_dev *devlist,
-                 int runstop, int verbose, int force, int assume_clean,
+                 int runstop, int readonly, int verbose,
+                 int force, int assume_clean,
                  char *bitmap_file, int bitmap_chunk, int write_behind, int delay, int autof);
 
 extern int Detail(char *dev, int brief, int export, int test, char *homehost, char *prefer);
@@ -1188,6 +1195,7 @@ extern int flush_metadata_updates(struct supertype *st);
 extern void append_metadata_update(struct supertype *st, void *buf, int len);
 extern int assemble_container_content(struct supertype *st, int mdfd,
                                      struct mdinfo *content, int runstop,
+                                     int readonly,
                                      char *chosen_name, int verbose,
                                      char *backup_file, int freeze_reshape);
 extern struct mdinfo *container_choose_spares(struct supertype *st,
@@ -1305,6 +1313,14 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
        return ret;
 }
 
+#define pr_err(fmt ...) fprintf(stderr, Name ": " fmt)
+#define cont_err(fmt ...) fprintf(stderr, "       " fmt)
+
+void *xmalloc(size_t len);
+void *xrealloc(void *ptr, size_t len);
+void *xcalloc(size_t num, size_t size);
+char *xstrdup(const char *str);
+
 #define        LEVEL_MULTIPATH         (-4)
 #define        LEVEL_LINEAR            (-1)
 #define        LEVEL_FAULTY            (-5)
@@ -1391,8 +1407,10 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
 #define PATH_MAX       4096
 #endif
 
-#define PROCESS_DELAYED -2
-#define PROCESS_PENDING -3
+#define RESYNC_NONE -1
+#define RESYNC_DELAYED -2
+#define RESYNC_PENDING -3
+#define RESYNC_UNKNOWN -4
 
 /* When using "GET_DISK_INFO" it isn't certain how high
  * we need to check.  So we impose an absolute limit of