summaryrefslogtreecommitdiff
path: root/config.c
Commit message (Collapse)AuthorAgeFilesLines
* Define _POSIX_C_SOURCE if undefinedKhem Raj2016-01-151-0/+3
| | | | | | | | | config.c uses _POSIX_C_SOURCE which is defined in features.h when glibc/uclibc is used, but isn't defined when musl is used. So provide a reasonable default. Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: NeilBrown <neilb@suse.com>
* Merge branch 'cluster'NeilBrown2015-07-271-1/+26
|\ | | | | | | | | | | Now that 3.3.3 is out, it is time to include the cluster-support code. Signed-off-by: NeilBrown <neilb@suse.com>
| * Set home-cluster while creating an arrayGuoqing Jiang2015-06-171-1/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The home-cluster is stored in the bitmap super block of the array. The device can be assembled on a cluster with the cluster name same as the one recorded in the bitmap. If home-cluster is not specified, this is auto-detected using dlopen corosync cmap library. neilb: allow code to compile when corosync-devel is not installed. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.de>
* | mdstat: discard 'dev' field, just use 'devnm'NeilBrown2015-07-021-2/+2
|/ | | | | | | | These both have the same value, and have done since the 'devnm' concept was introduced. So discard the pointless duplicate. Signed-off-by: NeilBrown <neilb@suse.de>
* Don't break long strings onto multiple lines.NeilBrown2015-02-121-12/+6
| | | | | | | | | | | | | | | | | It is best to keep strings all together so that they are easier to search for in the source code. If a string is so long that it looks ugly one line, them maybe it should be broken into multiple lines for display too. Only strings which contain a newline can be broken into multiple lines: "It is OK to\n" "break this string\n" Signed-off-by: NeilBrown <neilb@suse.de>
* config: new option to suppress adding bad block lists.NeilBrown2014-08-071-0/+5
| | | | | | | | | | | | | | CREATE bbl=no in mdadm.conf will cause any devices added to an array to not have a bad block list. By default they do for 1.x metadata. This is useful if you are suspicious of the bad-block-list implementation. Reported-by: Ethan Wilson <ethan.wilson@shiftmail.org> Signed-off-by: NeilBrown <neilb@suse.de>
* config: set "auto_seen" after processing the auto line.NeilBrown2013-09-101-0/+1
| | | | | | | | Otherwise when we process an empty autoline (to be sure to capture the MDADM_CONF_AUTO environment variable) we can end up setting everything to 'yes' which over-rides 'no'. Signed-off-by: NeilBrown <neilb@suse.de>
* config: support MDADM_CONF_AUTO= env var.NeilBrown2013-09-031-0/+27
| | | | | | | | | | | | | If a distribution allows the choice between using mdadm and dmraid for DDF and IMSM to be made by some config file (/etc/defaults/ /sys/sysconfig/ etc) which is queried by /etc/init.d scripts, then the fact that mdadm implements this choce through the config file is not very helpful. So allow the "AUTO" line to be specified in part using MDADM_CONF_AUTO in environment. Signed-off-by: NeilBrown <neilb@suse.de>
* config: refactor load_conffile() to have a single exit.NeilBrown2013-09-031-29/+24
| | | | | | | This will make next patch cleaner. No functional change. Signed-off-by: NeilBrown <neilb@suse.de>
* Config: multiple occurences of lines is not an error.NeilBrown2013-09-031-17/+5
| | | | | | | | | As we now support config directories it is helpful if lines are allowed to occur multiple times with one over-riding the other. So stop giving warnings when later lines are ignored. Signed-off-by: NeilBrown <neilb@suse.de>
* config: read /etc/mdadm.conf.d as well as /etc/mdadm.confNeilBrown2013-09-031-11/+22
| | | | | | | | | | | | | If a configfile is explicitly given, just that file or directory is read. Otherwise we now read both a file /etc/mdadm.conf and a directory /etc/mdadm.conf.d This allows a transition to directory based config, which in turn allows easy control from scripts. Signed-off-by: NeilBrown <neilb@suse.de>
* Conf: allow conf file to be a directory.NeilBrown2013-09-031-1/+62
| | | | | | | | If config file is a directory, process each file within with a name ending in ".conf" that doesn't start with ".". Files are processed in lexical order. Signed-off-by: NeilBrown <neilb@suse.de>
* Config: factor reading of file out into separate function.NeilBrown2013-09-031-36/+41
| | | | | | This will make it easier to read multiple files in a conf.d/ Signed-off-by: NeilBrown <neilb@suse.de>
* Don't set 'hold' option for mdstat_read if not needed.NeilBrown2013-07-101-1/+1
| | | | | | | | We only need 'hold' if we want to mdstat_wait for a change. These two callers don't care about a change, so they shouldn't use the 'hold' flag. Signed-off-by: NeilBrown <neilb@suse.de>
* Config: use better device names for "DEVICES container"NeilBrown2013-07-021-1/+6
| | | | | | | | | | When "containers" appears on the "DEVICES" line (which is does by default), use names from the mdadm map file instead of kernel names, when possible. This mean that the name will be more likely to appear in mdadm.conf and so more likely to match "container=" tags. Signed-off-by: NeilBrown <neilb@suse.de>
* Move conf_line and free_line from conf.c to lib.cNeilBrown2013-07-021-39/+0
| | | | | | | | | As they are uses for mdstat as well as mdadm.conf, they don't really belong in conf.c This removes a dependency between mdmon and conf.c Signed-off-by: NeilBrown <neilb@suse.de>
* Remove lots of unnecessary white space.NeilBrown2013-06-191-4/+1
| | | | | | | Now that I am using white-space mode in Emacs I can see all of this, and I don't like it :-) Signed-off-by: NeilBrown <neilb@suse.de>
* create_mddev: add support for /dev/md_XXX non-numeric names.NeilBrown2013-05-151-0/+5
| | | | | | | | | | With the 'devnm' infrastructure fixed, it is quite easy to support names like "md_home" for md arrays. The currently defaults to "off" and can be enabled in mdadm.conf with CREATE names=yes This is incase other tools get confused by the new names. Signed-off-by: NeilBrown <neilb@suse.de>
* Ensure mddev_dev struct always zeroed on allocation.NeilBrown2013-03-051-3/+3
| | | | | | | | There are a number of fields which should not be left uninitialised. e.g. attempt_re_add can get confused if ->writemostly is not set correctly. Signed-off-by: NeilBrown <neilb@suse.de>
* Discard devnum in favour of devnmNeilBrown2013-02-211-1/+1
| | | | | | | | | | | | | | We widely use a "devnum" which is 0 or +ve for md%d devices and -ve for md_d%d devices. But I want to be able to use md_%s device names. So get rid of devnum (a number) and use devnm (a 32char string). eg. md0 md_d2 md_home Signed-off-by: NeilBrown <neilb@suse.de>
* conf: allow multiple arrays to be <ignore>dNeilBrown2012-11-221-0/+2
| | | | | | | | | | | We currently complain if mdadm.conf contains multiple definitions for the same name. Unfortunately this stops multiple arrays from being <ignored>d. So exclude "<ignore>" from the duplicate-names test. Reported-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: NeilBrown <neilb@suse.de>
* Replace a lot of leading spaces with tabs.NeilBrown2012-10-101-21/+21
| | | | Signed-off-by: NeilBrown <neilb@suse.de>
* Remove scattered checks for malloc success.NeilBrown2012-07-091-22/+20
| | | | | | | | | | | | | | malloc should never fail, and if it does it is unlikely that anything else useful can be done. Best approach is to abort and let some super-daemon restart. So define xmalloc, xcalloc, xrealloc, xstrdup which don't fail but just print a message and exit. Then use those removing all the tests for failure. Also replace all "malloc;memset" sequences with 'xcalloc'. Signed-off-by: NeilBrown <neilb@suse.de>
* Introduce pr_err for printing error messages.NeilBrown2012-07-091-58/+50
| | | | | | | 'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": ' cont_err() is also available. Signed-off-by: NeilBrown <neilb@suse.de>
* config: conf_match should ignore devname when not set.NeilBrown2012-02-161-1/+1
| | | | | | | | mapfile:RebuildMap calls conf_match with no devname, so we must be careful not to use it. Reported-by: Arkadiusz Miśkiewicz <arekm@maven.pl> Signed-off-by: NeilBrown <neilb@suse.de>
* config: fix handing of 'homehost' in AUTO line.NeilBrown2012-02-091-5/+5
| | | | | | | We should be looking for the policy "auto=homehost", not "auto=auto". Signed-off-by: NeilBrown <neilb@suse.de>
* fix: Allowed to assemble 2 volumes with the same names from config file.Lukasz Orlowski2011-11-071-0/+33
| | | | | | | | | | | | | mdadm allowes to assemble 2 volumes with the same names based on the config file. The issue is fixed by iterating over the list of md device identifiers and comparing the names of md devices against each other, detecting identical names and blocking the assembly should the same names be found. Now having detected duplicate names, mdadm terminates without assembling the container, displaying appropriate prompt. Signed-off-by: Lukasz Orlowski <lukasz.orlowski@intel.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Remove duplicated code: search_mdstat and conf_matchNeilBrown2011-11-011-9/+17
| | | | | | | | | search_mdstat and conf_match are almost identical. Put all the functionality in conf_match, and remove search_mdstat. Reported-by: Jes.Sorensen@redhat.com Signed-off-by: NeilBrown <neilb@suse.de>
* Fix small memory leakThomas Jarosch2011-09-071-0/+2
| | | | | | | Found by cppcheck Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com> Signed-off-by: NeilBrown <neilb@suse.de>
* config: restore the possibility of a NULL homehostNeilBrown2011-05-101-3/+6
| | | | | | | | | | | | | As homehost defaults to the system name it is not possible to specify a NULL homehost. This patch restored this ability with either --homehost="" or --homehost="<none>". This allows the creation of v1.x arrays without a "hostname:" prefix in the name. Signed-off-by: NeilBrown <neilb@suse.de>
* Split some of util.c into a new lib.cNeilBrown2011-04-051-78/+0
| | | | | | | | | Some of util.c is dependent on lots of other code, some of it is stand-alone. Move some of the stand-alone stuff into a new lib.c so it can be used by smaller utilities. Signed-off-by: NeilBrown <neilb@suse.de>
* Remove content from mddev_devNeilBrown2010-11-221-3/+0
| | | | | | | | Now that the next_member loop is much smaller it is easy to just use 'content' rather than stashing it in 'tmpdev->content'. So we can remove the 'content' field from 'struct mddev_dev'. Signed-off-by: NeilBrown <neilb@suse.de>
* Improve type names for mddev_devNeilBrown2010-11-221-11/+11
| | | | | | | | | Remove the _t pointer typedef and remove the _s suffix for the structure, These things do not help readability. Signed-off-by: NeilBrown <neilb@suse.de>
* Improve mddev_ident type definitions.NeilBrown2010-11-221-9/+9
| | | | | | | | Remove the _t typedef and remove the _s suffix from the struct name. These things do not help readability. Signed-off-by: NeilBrown <neilb@suse.de>
* Convert 'auto' config line to policy statementsNeilBrown2010-09-061-61/+115
|
* Add policy framework.NeilBrown2010-09-061-1/+9
| | | | | | | | | | | | | | | | | | Policy can be stated as lines in mdadm.conf like: POLICY type=disk path=pci-0000:00:1f.2-* action=ignore domain=onboard This defines two distinct policies which apply to any disk (but not partition) device reached through the pci device 0000:00:1f.2. The policies are "action=ignore" which means certain actions will ignore the device, and "domain=onboard" which means all such devices as treated as being united under the name 'onboard'. This patch just adds data structures and code to read and manipulate them. Future patches will actually use them. Signed-off-by: NeilBrown <neilb@suse.de>
* Compile with -Wextra by defaultNeilBrown2010-08-051-4/+5
| | | | | | This produced lots of warning, some of which pointed to actual bugs. Signed-off-by: NeilBrown <neilb@suse.de>
* config: add 'homehost' option to 'AUTO' line.NeilBrown2010-03-031-2/+16
| | | | | | This allows basing auto-assembly decisions on whether the array is recorded as belonging to this host or not. Signed-off-by: NeilBrown <neilb@suse.de>
* Fix segfault when the AUTO keyword is used in the config fileDoug Ledford2010-01-191-1/+10
| | | | | Signed-off-by: Doug Ledford <dledford@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
* Update copyright dates and remove references to @cse.unsw.edu.auNeilBrown2009-06-021-7/+2
| | | | | | Also removed 'paper' addresses. Signed-off-by: NeilBrown <neilb@suse.de>
* mapfile - when rebuilding, choose an appropriate name is none is found.NeilBrown2009-05-111-0/+70
| | | | | | | | When rebuilding the mapfile (mdadm -Ir), if not appropriate name is found in /dev/md/, try to find an appropriate name, either by looking in mdadm.conf or by using the name in the metadata. Signed-off-by: NeilBrown <neilb@suse.de>
* config: enhance name matching in conf_get_ident.NeilBrown2009-05-111-1/+1
| | | | | | | | | | Use when searching mdadm.conf for a device, use more flexible matching that e.g. ignores leading /dev/md/ or /dev/ As mdadm now accepts both "/dev/md/foo" and "foo" is many places as equivalent, they should compare as the same. Signed-off-by: NeilBrown <neilb@suse.de>
* Allow homehost to be largely ignored when assembling arrays.NeilBrown2009-05-111-2/+62
| | | | | | | | | | | | | | | | | | | | | | | | If mdadm.conf contains HOMEHOST <ignore> or commandline contains --homehost=<ignore> then the check that array metadata mentions the given homehost is replace by a check that the name recorded in the metadata is not already used by some other array mentioned in mdadm.conf. This allows more arrays to use their native name rather than having an _NN suffix added. This should only be used during boot time if all arrays required for normal boot are listed in mdadm.conf. If auto-assembly is used to find all array during boot, then the HOMEHOST feature should be used to ensure there is no room for confusion in choosing array names, and so it should not be set to <ignore>. Signed-off-by: NeilBrown <neilb@suse.de>
* config: allow Array line to contain array name without /dev/md/ prefix.NeilBrown2009-05-111-5/+40
| | | | | | | | | | | | | | | For consistency with --create and --assemble, allow the array name given in mdadm.conf to exclude the "/dev/md/" prefix. So e.g. ARRAY home uuid=whatever is treated like ARRAY /dev/md/home uuid=whatever Also exclude names which create_mddev will reject. Signed-off-by: NeilBrown <neilb@suse.de>
* Fix tests on ->container and ->memberNeilBrown2009-05-111-1/+1
| | | | | | | | For container= and member= to be effective in an mdadm.conf line they must both be present. So when checking for their absence we need container != NULL || member != NULL. Signed-off-by: NeilBrown <neilb@suse.de>
* conf/assemble: new config line "auto".NeilBrown2009-05-111-2/+63
| | | | | | | | | | | | | | | | | | | The line 'auto' in mdadm.conf can be used to disable assembly of specific metadata types, or of all arrays. This does not affect assembly of arrays listed in mdadm.conf or on command line. auto -all will disable all auto-assembly. auto -ddf will cause mdadm to ignore ddf arrays that are not explicitly mentioned, and auto assemble anything else it finds. Signed-off-by: NeilBrown <neilb@suse.de>
* config: support "ARRAY <ignore> ..." lines in mdadm.confNeilBrown2009-05-111-1/+1
| | | | | | | | | | | | | | Sometimes we want to ensure particular arrays are never assembled automatically. This might include an array made of devices that are shared between hosts. To support this, allow ARRAY lines in mdadm.conf to use the word "ignore" rather than a device name. Arrays which match such lines are never automatically assembled (though they can still be assembled by explicitly giving identification information on the mdadm command line. Signed-off-by: NeilBrown <neilb@suse.de>
* config: treat "container=" and "member=" and providing the required identity ↵NeilBrown2009-04-061-1/+3
| | | | | | information. Signed-off-by: NeilBrown <neilb@suse.de>
* Merge branch 'master' into scratch-3.0NeilBrown2009-01-081-1/+1
|\ | | | | | | | | | | | | Conflicts: Assemble.c config.c
| * Fail overtly when asprintf fails to allocate memoryDustin Kirkland2009-01-081-1/+1
| | | | | | | | | | | | .. rather that causing a less-obvious violation of segments. Signed-off-by: NeilBrown <neilb@suse.de>