]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Allow symlink creation to be disabled from command line or mdadm.conf
authorNeil Brown <neilb@suse.de>
Fri, 11 Aug 2006 08:00:05 +0000 (18:00 +1000)
committerNeil Brown <neilb@suse.de>
Fri, 11 Aug 2006 08:00:05 +0000 (18:00 +1000)
ChangeLog
ReadMe.c
config.c
mdadm.8
mdadm.c
mdadm.conf.5
mdadm.h
mdopen.c

index c1e1b7da8b0b00a92a1f1289c5e59c7d150802ba..154c2b420497459a485f72e1798ee558de6580f1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Changes Priot to this release
+    -   When creating devices in /dev/md/ create matching symlinks
+       from /dev.  e.g. /dev/md0 -> /dev/md/0.
+       Allow this to be disabled in mdadm.conf or on command line.
+
 Changes Prior to 2.5.3 release
     -   Document v0.91 superblocks in md.4
     -   Make GPL explicit in man pages.
index c9e64cd5ff3b73acba277ec1d94ef125af4a936a..f1b3ee3eeeabc8d7980591ee774083375445c46b 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
@@ -139,6 +139,7 @@ struct option long_options[] = {
     {"re-add",    0, 0,  ReAdd},
     {"homehost",  1, 0,  HomeHost},
     {"auto-update-homehost", 0, 0, AutoHomeHost},
+    {"symlinks",  1, 0,  Symlinks},
 
     /* For assemble */
     {"uuid",      1, 0, 'u'},
index b43e79c7eb5a6192d4e2120659d1dc97e088bf67..219308dc703740f715cba595c285ba1464ed480a 100644 (file)
--- a/config.c
+++ b/config.c
@@ -255,6 +255,7 @@ mddev_dev_t load_partitions(void)
 }
 
 struct createinfo createinfo = {
+       .symlinks = 1,
 #ifdef DEBIAN
        .gid = 6, /* disk */
        .mode = 0660,
@@ -364,8 +365,11 @@ static void createline(char *line)
                        if (!createinfo.supertype)
                                fprintf(stderr, Name ": metadata format %s unknown, ignoring\n",
                                        w+9);
-
-               } else {
+               } else if (strncasecmp(w, "symlinks=yes", 12) == 0)
+                       createinfo.symlinks = 1;
+               else if  (strncasecmp(w, "symlinks=no", 11) == 0)
+                       createinfo.symlinks = 0;
+               else {
                        fprintf(stderr, Name ": unrecognised word on CREATE line: %s\n",
                                w);
                }
diff --git a/mdadm.8 b/mdadm.8
index 1508c58651d9e4e9b17222d179b7f7fffa16f89e..3ebef842b3934f0e88d99f07b5acee1b50cb1b01 100644 (file)
--- a/mdadm.8
+++ b/mdadm.8
@@ -594,6 +594,28 @@ number will be considered unused if there is no active array for that
 number, and there is no entry in /dev for that number and with a
 non-standard name.
 
+.TP
+.BR --symlink = no
+Normally when
+.B --auto
+causes
+.I mdadm
+to create devices in
+.B /dev/md/
+it will also create symlinks from
+.B /dev/
+with names starting with
+.B md
+or
+.BR md_ .
+Use
+.B --symlink=no
+to suppress this, or
+.B --symlink=yes
+to enforce this even if it is suppressing
+.IR mdadm.conf .
+
+
 .SH For assemble:
 
 .TP
diff --git a/mdadm.c b/mdadm.c
index 9fe56abe6c084a76c5b3d7660a8590933ae9b855..bc8aac877000d342c48c6b2340b4cb6604390166 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -75,6 +75,7 @@ int main(int argc, char *argv[])
        int force = 0;
        int test = 0;
        int assume_clean = 0;
+       char *symlinks = NULL;
        /* autof indicates whether and how to create device node.
         * bottom 3 bits are style.  Rest (when shifted) are number of parts
         * 0  - unset
@@ -499,6 +500,12 @@ int main(int argc, char *argv[])
                        autof = parse_auto(optarg, "--auto flag", 0);
                        continue;
 
+               case O(CREATE,Symlinks):
+               case O(BUILD,Symlinks):
+               case O(ASSEMBLE,Symlinks): /* auto creation of symlinks in /dev to /dev/md */
+                       symlinks = optarg;
+                       continue;
+
                case O(BUILD,'f'): /* force honouring '-n 1' */
                case O(GROW,'f'): /* ditto */
                case O(CREATE,'f'): /* force honouring of device list */
@@ -858,6 +865,19 @@ int main(int argc, char *argv[])
                fputs(Usage, stderr);
                exit(2);
        }
+
+       if (symlinks) {
+               struct createinfo *ci = conf_get_create_info();
+
+               if (strcasecmp(symlinks, "yes") == 0)
+                       ci->symlinks = 1;
+               else if (strcasecmp(symlinks, "no") == 0)
+                       ci->symlinks = 0;
+               else {
+                       fprintf(stderr, Name ": option --symlinks must be 'no' or 'yes'\n");
+                       exit(2);
+               }
+       }
        /* Ok, got the option parsing out of the way
         * hopefully it's mostly right but there might be some stuff
         * missing
index 7df36d9effc1e6f4bb80853ee80b966ed5f048ae..f2cb35f4b045e960df42007617260de6ef6ca90f 100644 (file)
@@ -273,6 +273,20 @@ missing device entries should be created.
 The name of the metadata format to use if none is explicitly given.
 This can be useful to impose a system-wide default of version-1 superblocks.
 
+.TP
+.B symlinks=no
+Normally when creating devices in
+.B /dev/md/
+.I mdadm
+will create a matching symlink from
+.B /dev/
+with a name starting
+.B md
+or
+.BR md_ .
+Give
+.B symlinked=no
+to suppress this symlink creation.
 .RE
 
 
diff --git a/mdadm.h b/mdadm.h
index 420e6a34bb5b2b0f462ecb05b0fbe793d1e66bef..29fc7c8823030e27520be8e9a42309e00ec7be39 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -132,6 +132,7 @@ struct createinfo {
        int     gid;
        int     autof;
        int     mode;
+       int     symlinks;
        struct supertype *supertype;
 };
 
@@ -167,6 +168,7 @@ enum special_options {
        BackupFile,
        HomeHost,
        AutoHomeHost,
+       Symlinks,
 };
 
 /* structures read from config file */
index 488956cfbfd9fdc16889abb92e6fcf273bc31aac..0c049a03e01568b4427102c12b0e32e1b8c4047b 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -48,7 +48,7 @@ void make_dev_symlink(char *dev)
 }
 
 
-void make_parts(char *dev, int cnt)
+void make_parts(char *dev, int cnt, int symlinks)
 {
        /* make 'cnt' partition devices for 'dev'
         * We use the major/minor from dev and add 1..cnt
@@ -88,7 +88,7 @@ void make_parts(char *dev, int cnt)
                        perror("chown");
                if (chmod(name, stb2.st_mode & 07777))
                        perror("chmod");
-               if (strncmp(name, "/dev/md/", 8) == 0)
+               if (symlinks && strncmp(name, "/dev/md/", 8) == 0)
                        make_dev_symlink(name);
                stat(name, &stb2);
                add_dev(name, &stb2, 0, NULL);
@@ -192,7 +192,7 @@ int open_mddev(char *dev, int autof)
                                return -1;
                        } else {
                                if (major != MD_MAJOR && parts > 0)
-                                       make_parts(dev, parts);
+                                       make_parts(dev, parts, ci->symlinks);
                                return mdfd;
                        }
                }
@@ -279,10 +279,10 @@ int open_mddev(char *dev, int autof)
                        }
                        stat(dev, &stb);
                        add_dev(dev, &stb, 0, NULL);
-                       if (strncmp(dev, "/dev/md/", 8) == 0)
+                       if (ci->symlinks && strncmp(dev, "/dev/md/", 8) == 0)
                                make_dev_symlink(dev);
                        if (major != MD_MAJOR)
-                               make_parts(dev,parts);
+                               make_parts(dev,parts, ci->symlinks);
                }
        }
        mdfd = open(dev, O_RDWR, 0);