block: detect: use current mp as value of target option
authorYousong Zhou <yszhou4tech@gmail.com>
Sun, 3 Nov 2019 03:06:32 +0000 (03:06 +0000)
committerYousong Zhou <yszhou4tech@gmail.com>
Sun, 3 Nov 2019 04:01:40 +0000 (04:01 +0000)
Move down the function so that no declaration of find_mount_point() is
not needed

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
block.c

diff --git a/block.c b/block.c
index 1972c5092a9b14203de416fe1cb7a7ddad64b326..b6d49a8543117bb91fa53bd7c8b1fad5f1e2dbdb 100644 (file)
--- a/block.c
+++ b/block.c
@@ -575,23 +575,6 @@ static void cache_load(int mtd)
 }
 
 
-static int print_block_uci(struct probe_info *pr)
-{
-       if (!strcmp(pr->type, "swap")) {
-               printf("config 'swap'\n");
-       } else {
-               printf("config 'mount'\n");
-               printf("\toption\ttarget\t'/mnt/%s'\n", basename(pr->dev));
-       }
-       if (pr->uuid)
-               printf("\toption\tuuid\t'%s'\n", pr->uuid);
-       else
-               printf("\toption\tdevice\t'%s'\n", pr->dev);
-       printf("\toption\tenabled\t'0'\n\n");
-
-       return 0;
-}
-
 static struct device* find_block_device(char *uuid, char *label, char *path)
 {
        struct device *dev;
@@ -704,6 +687,30 @@ static char* find_mount_point(char *block)
        return point;
 }
 
+static int print_block_uci(struct probe_info *pr)
+{
+       if (!strcmp(pr->type, "swap")) {
+               printf("config 'swap'\n");
+       } else {
+               char *mp = find_mount_point(pr->dev);
+
+               printf("config 'mount'\n");
+               if (mp) {
+                       printf("\toption\ttarget\t'%s'\n", mp);
+                       free(mp);
+               } else {
+                       printf("\toption\ttarget\t'/mnt/%s'\n", basename(pr->dev));
+               }
+       }
+       if (pr->uuid)
+               printf("\toption\tuuid\t'%s'\n", pr->uuid);
+       else
+               printf("\toption\tdevice\t'%s'\n", pr->dev);
+       printf("\toption\tenabled\t'0'\n\n");
+
+       return 0;
+}
+
 static int print_block_info(struct probe_info *pr)
 {
        static char *mp;