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 <neilb@suse.de>
This commit is contained in:
NeilBrown 2012-05-03 14:16:56 +10:00
parent 5ffdc2dd44
commit 96fd06edce
6 changed files with 23 additions and 45 deletions

View File

@ -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

View File

@ -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 <sys/file.h>
#include <ctype.h>
#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,

View File

@ -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

View File

@ -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

10
mdadm.h
View File

@ -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"

View File

@ -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.