]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Move find_free_devnum to mdopen.c
authorNeilBrown <neilb@suse.de>
Tue, 2 Jul 2013 00:24:50 +0000 (10:24 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 2 Jul 2013 00:24:50 +0000 (10:24 +1000)
There is only one called to find_free_devnum and it is in mdopen.c

The removes a dependency between util.c and config.c which allows
us to now drop config.o from mdmon.

Signed-off-by: NeilBrown <neilb@suse.de>
Makefile
mdopen.c
util.c

index b4c3b24f6dfcaf3a48c12db4e5d6029f411cdbd6..86d94f11c94cd4da5d2f13ab3edd4d097c459982 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -127,7 +127,7 @@ SRCS =  $(patsubst %.o,%.c,$(OBJS))
 INCL = mdadm.h part.h bitmap.h
 
 MON_OBJS = mdmon.o monitor.o managemon.o util.o maps.o mdstat.o sysfs.o \
-       config.o policy.o lib.o \
+       policy.o lib.o \
        Kill.o sg_io.o dlink.o ReadMe.o super0.o super1.o super-intel.o \
        super-mbr.o super-gpt.o \
        super-ddf.o sha1.o crc32.o msg.o bitmap.o xmalloc.o \
index fc118840f15dd2790b9b5b2888f8ec0b2583e008..814d73290ccf33f8ec4d5864d36a80e9699ef623 100644 (file)
--- a/mdopen.c
+++ b/mdopen.c
@@ -438,3 +438,36 @@ int open_mddev(char *dev, int report_errors)
        }
        return mdfd;
 }
+
+char *find_free_devnm(int use_partitions)
+{
+       static char devnm[32];
+       int devnum;
+       for (devnum = 127; devnum != 128;
+            devnum = devnum ? devnum-1 : (1<<20)-1) {
+
+               if (use_partitions)
+                       sprintf(devnm, "md_d%d", devnum);
+               else
+                       sprintf(devnm, "md%d", devnum);
+               if (mddev_busy(devnm))
+                       continue;
+               if (!conf_name_is_free(devnm))
+                       continue;
+               if (!use_udev()) {
+                       /* make sure it is new to /dev too, at least as a
+                        * non-standard */
+                       int devid = devnm2devid(devnm);
+                       if (devid) {
+                               char *dn = map_dev(major(devid),
+                                                  minor(devid), 0);
+                               if (dn && ! is_standard(dn, NULL))
+                                       continue;
+                       }
+               }
+               break;
+       }
+       if (devnum == 128)
+               return NULL;
+       return devnm;
+}
diff --git a/util.c b/util.c
index a9aaea48d7644565228958f236d3a028c752b72f..f019d3d0a673ec7ef134bf4814e0331eda2bbeb2 100644 (file)
--- a/util.c
+++ b/util.c
@@ -868,39 +868,6 @@ void put_md_name(char *name)
        if (strncmp(name, "/dev/.tmp.md", 12) == 0)
                unlink(name);
 }
-
-char *find_free_devnm(int use_partitions)
-{
-       static char devnm[32];
-       int devnum;
-       for (devnum = 127; devnum != 128;
-            devnum = devnum ? devnum-1 : (1<<20)-1) {
-
-               if (use_partitions)
-                       sprintf(devnm, "md_d%d", devnum);
-               else
-                       sprintf(devnm, "md%d", devnum);
-               if (mddev_busy(devnm))
-                       continue;
-               if (!conf_name_is_free(devnm))
-                       continue;
-               if (!use_udev()) {
-                       /* make sure it is new to /dev too, at least as a
-                        * non-standard */
-                       int devid = devnm2devid(devnm);
-                       if (devid) {
-                               char *dn = map_dev(major(devid),
-                                                  minor(devid), 0);
-                               if (dn && ! is_standard(dn, NULL))
-                                       continue;
-                       }
-               }
-               break;
-       }
-       if (devnum == 128)
-               return NULL;
-       return devnm;
-}
 #endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
 
 int dev_open(char *dev, int flags)