From 96fd06edce9ae2d41908b9703642dfe50f376ca9 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 3 May 2012 14:16:56 +1000 Subject: [PATCH] Adjust to new standard of /run Now that /run seems to be a good standard, make that the default for storing various run-time files, rather than /var/run or /dev/.mdadm. Signed-off-by: NeilBrown --- Makefile | 13 +++++++------ mapfile.c | 14 +++----------- mdadm.8.in | 27 ++++++--------------------- mdadm.conf-example | 2 +- mdadm.h | 10 +++++----- mdmon.8 | 2 +- 6 files changed, 23 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index b8d363f8..315455ba 100644 --- a/Makefile +++ b/Makefile @@ -66,13 +66,13 @@ MAILCMD =/usr/sbin/sendmail -t CONFFILEFLAGS = -DCONFFILE=\"$(CONFFILE)\" -DCONFFILE2=\"$(CONFFILE2)\" # Both MAP_DIR and MDMON_DIR should be somewhere that persists across the # pivotroot from early boot to late boot. -# /dev is an odd place to put this, but it is the only directory that -# meets the requirements. -MAP_DIR=/dev/.mdadm +# /run is best, but for distros that don't support that, /dev can work. +MAP_DIR=/run/mdadm MAP_FILE = map -MDMON_DIR = /dev/.mdadm +MAP_PATH = $(MAP_DIR)/$(MAP_FILE) +MDMON_DIR = $(MAP_DIR) # place for autoreplace cookies -FAILED_SLOTS_DIR = /dev/.mdadm/failed-slots +FAILED_SLOTS_DIR = /run/mdadm/failed-slots DIRFLAGS = -DMAP_DIR=\"$(MAP_DIR)\" -DMAP_FILE=\"$(MAP_FILE)\" DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\" DIRFLAGS += -DFAILED_SLOTS_DIR=\"$(FAILED_SLOTS_DIR)\" @@ -204,7 +204,8 @@ mdassemble.klibc : $(ASSEMBLE_SRCS) $(INCL) $(KLIBC_GCC) $(ASSEMBLE_FLAGS) -o mdassemble $(ASSEMBLE_SRCS) mdadm.8 : mdadm.8.in - sed -e 's/{DEFAULT_METADATA}/$(DEFAULT_METADATA)/g' mdadm.8.in > mdadm.8 + sed -e 's/{DEFAULT_METADATA}/$(DEFAULT_METADATA)/g' \ + -e 's,{MAP_PATH},$(MAP_PATH),g' mdadm.8.in > mdadm.8 mdadm.man : mdadm.8 nroff -man mdadm.8 > mdadm.man diff --git a/mapfile.c b/mapfile.c index 9e2c8936..b890ed2b 100644 --- a/mapfile.c +++ b/mapfile.c @@ -38,27 +38,19 @@ * UUID - uuid of the array * path - path where device created: /dev/md/home * - * The best place for the mapfile wold be /var/run/mdadm/map. However - * it is needed during initramfs early-boot, and /var/run doesn't exist there - * and certainly doesn't persist through to normal boot. - * So we store it in /dev/.mdadm/map but allow this to be changed at - * compile time. via MAP_DIR and MAP_FILE - * + * The best place for the mapfile is /run/mdadm/map. Distros and users + * which have not switched to /run yet can choose a different location + * at compile time via MAP_DIR and MAP_FILE. */ #include "mdadm.h" #include #include -#ifndef MAP_DIR -#define MAP_DIR "/dev/.mdadm" -#define MAP_FILE "map" -#endif #define MAP_READ 0 #define MAP_NEW 1 #define MAP_LOCK 2 #define MAP_DIRNAME 3 -#define mapnames(dir, base) { \ char *mapname[4] = { MAP_DIR "/" MAP_FILE, diff --git a/mdadm.8.in b/mdadm.8.in index fa4d2f31..c447da25 100644 --- a/mdadm.8.in +++ b/mdadm.8.in @@ -1434,7 +1434,7 @@ if safe-mode handling is disabled. .TP .BR \-\-rebuild\-map ", " \-r Rebuild the map file -.RB ( /var/run/mdadm/map ) +.RB ( {MAP_PATH} ) that .I mdadm uses to help track which arrays are currently being assembled. @@ -1641,7 +1641,7 @@ does not create any entries in but leaves that to .IR udev . It does record information in -.B /var/run/mdadm/map +.B {MAP_PATH} which will allow .I udev to choose the correct name. @@ -2561,11 +2561,7 @@ current host, the device will be rejected. .PP .I mdadm keeps a list of arrays that it has partially assembled in -.B /var/run/mdadm/map -(or -.B /var/run/mdadm.map -if the directory doesn't exist. Or maybe even -.BR /dev/.mdadm.map ). +.BR {MAP_PATH} . If no array exists which matches the metadata on the new device, .I mdadm @@ -2709,12 +2705,12 @@ and assemble .B /dev/md0 out of all such devices with a RAID superblock with a minor number of 0. -.B " mdadm \-\-monitor \-\-scan \-\-daemonise > /var/run/mdadm" +.B " mdadm \-\-monitor \-\-scan \-\-daemonise > /run/mdadm/mon.pid" .br If config file contains a mail address or alert program, run mdadm in the background in monitor mode monitoring all md devices. Also write pid of mdadm daemon to -.BR /var/run/mdadm . +.BR /run/mdadm/mon.pid . .B " mdadm \-Iq /dev/somedevice" .br @@ -2792,21 +2788,10 @@ they contain MD super block, and gives identifying information .BR mdadm.conf (5) for more details. -.SS /var/run/mdadm/map +.SS {MAP_PATH} When .B \-\-incremental mode is used, this file gets a list of arrays currently being created. -If -.B /var/run/mdadm -does not exist as a directory, then -.B /var/run/mdadm.map -is used instead. If -.B /var/run -is not available (as may be the case during early boot), -.B /dev/.mdadm.map -is used on the basis that -.B /dev -is usually available very early in boot. .SH DEVICE NAMES diff --git a/mdadm.conf-example b/mdadm.conf-example index 7bdff671..d9d8d396 100644 --- a/mdadm.conf-example +++ b/mdadm.conf-example @@ -59,7 +59,7 @@ # When used in --follow (aka --monitor) mode, mdadm needs a # mail address and/or a program. This can be given with "mailaddr" # and "program" lines to that monitoring can be started using -# mdadm --follow --scan & echo $! > /var/run/mdadm +# mdadm --follow --scan & echo $! > /run/mdadm/mon.pid # If the lines are not found, mdadm will exit quietly #MAILADDR root@mydomain.tld #PROGRAM /usr/sbin/handle-mdadm-events diff --git a/mdadm.h b/mdadm.h index 0c91a34b..4946d4ea 100644 --- 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" diff --git a/mdmon.8 b/mdmon.8 index a9178b6b..799e3dab 100644 --- a/mdmon.8 +++ b/mdmon.8 @@ -218,7 +218,7 @@ and .B .sock file. The particular filesystem to use is given to mdmon at compile time and defaults to -.BR /dev/.mdadm . +.BR /run/mdadm . This filesystem must persist through to shutdown time. -- 2.39.2