summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--mapfile.c33
-rw-r--r--mdadm.h3
-rw-r--r--mdmon.c2
-rw-r--r--util.c7
5 files changed, 34 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index 1035ea8..2aafad0 100644
--- a/Makefile
+++ b/Makefile
@@ -63,8 +63,9 @@ CONFFILEFLAGS = -DCONFFILE=\"$(CONFFILE)\" -DCONFFILE2=\"$(CONFFILE2)\"
# If you don't have /lib/init/rw you might want to use /dev/.something
# e.g. make ALT_RUN=/dev/.mdadm
ALT_RUN = /lib/init/rw
+ALT_MAPFILE = map
VAR_RUN = /var/run
-ALTFLAGS = -DALT_RUN=\"$(ALT_RUN)\"
+ALTFLAGS = -DALT_RUN=\"$(ALT_RUN)\" -DALT_MAPFILE=\"$(ALT_MAPFILE)\"
VARFLAGS = -DVAR_RUN=\"$(VAR_RUN)\"
CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(ALTFLAGS) $(VARFLAGS)
diff --git a/mapfile.c b/mapfile.c
index 366ebe3..d47fde1 100644
--- a/mapfile.c
+++ b/mapfile.c
@@ -29,7 +29,7 @@
*/
/* /var/run/mdadm.map is used to track arrays being created in --incremental
- * more. It particularly allows lookup from UUID to array device, but
+ * mode. It particularly allows lookup from UUID to array device, but
* also allows the array device name to be easily found.
*
* The map file is line based with space separated fields. The fields are:
@@ -42,8 +42,8 @@
* However /var/run may not exist or be writable in early boot. And if
* no-one has created /var/run/mdadm, we still want to survive.
* So possible locations are:
- * /var/run/mdadm/map /var/run/mdadm.map /dev/.mdadm.map
- * the last, because udev requires a writable /dev very early.
+ * /var/run/mdadm/map /var/run/mdadm.map /lib/initrw/madam/map
+ * The last can easily be change at compile to e.g. somewhere in /dev.
* We read from the first one that exists and write to the first
* one that we can.
*/
@@ -55,8 +55,9 @@
char *mapname[3][3] = {
mapnames(VAR_RUN "/map"),
mapnames("/var/run/mdadm.map"),
- mapnames(ALT_RUN "/map")
+ mapnames(ALT_RUN "/" ALT_MAPFILE)
};
+char *mapdir[3] = { VAR_RUN, NULL, ALT_RUN };
int mapmode[3] = { O_RDONLY, O_RDWR|O_CREAT, O_RDWR|O_CREAT | O_TRUNC };
char *mapsmode[3] = { "r", "w", "w"};
@@ -64,8 +65,16 @@ char *mapsmode[3] = { "r", "w", "w"};
FILE *open_map(int modenum, int *choice)
{
int i;
+
for (i = 0 ; i < 3 ; i++) {
- int fd = open(mapname[i][modenum], mapmode[modenum], 0600);
+ int fd;
+ if ((mapmode[modenum] & O_CREAT) &&
+ mapdir[modenum])
+ /* Attempt to create directory, don't worry about
+ * failure.
+ */
+ mkdir(mapdir[modenum], 0755);
+ fd = open(mapname[i][modenum], mapmode[modenum], 0600);
if (fd >= 0) {
*choice = i;
return fdopen(fd, mapsmode[modenum]);
@@ -462,12 +471,14 @@ void RebuildMap(void)
}
sysfs_free(sra);
}
- map_write(map);
+ /* Only trigger a change if we wrote a new map file */
+ if (map_write(map))
+ for (md = mdstat ; md ; md = md->next) {
+ struct mdinfo *sra = sysfs_read(-1, md->devnum,
+ GET_VERSION);
+ sysfs_uevent(sra, "change");
+ sysfs_free(sra);
+ }
map_free(map);
- for (md = mdstat ; md ; md = md->next) {
- struct mdinfo *sra = sysfs_read(-1, md->devnum, GET_VERSION);
- sysfs_uevent(sra, "change");
- sysfs_free(sra);
- }
free_mdstat(mdstat);
}
diff --git a/mdadm.h b/mdadm.h
index 362b66b..0386129 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -87,6 +87,9 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
#ifndef ALT_RUN
#define ALT_RUN "/lib/init/rw/mdadm"
#endif /* ALT_RUN */
+#ifndef ALT_MAPFILE
+#define ALT_MAPFILE "map"
+#endif /* ALT_MAPFILE */
#include "md_u.h"
#include "md_p.h"
diff --git a/mdmon.c b/mdmon.c
index 961aa77..69c320e 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -120,7 +120,7 @@ static int make_pidfile(char *devname)
int fd;
int n;
- if (mkdir(pid_dir, 0600) < 0 &&
+ if (mkdir(pid_dir, 0700) < 0 &&
errno != EEXIST)
return -errno;
sprintf(path, "%s/%s.pid", pid_dir, devname);
diff --git a/util.c b/util.c
index d292a66..79d2b0f 100644
--- a/util.c
+++ b/util.c
@@ -425,7 +425,12 @@ char *__fname_from_uuid(int id[4], int swap, char *buf, char sep)
char *fname_from_uuid(struct supertype *st, struct mdinfo *info, char *buf, char sep)
{
- return __fname_from_uuid(info->uuid, st->ss->swapuuid, buf, sep);
+ // dirty hack to work around an issue with super1 superblocks...
+ // super1 superblocks need swapuuid set in order for assembly to
+ // work, but can't have it set if we want this printout to match
+ // all the other uuid printouts in super1.c, so we force swapuuid
+ // to 1 to make our printout match the rest of super1
+ return __fname_from_uuid(info->uuid, (st->ss == &super1) ? 1 : st->ss->swapuuid, buf, sep);
}
#ifndef MDASSEMBLE