From: Yousong Zhou Date: Sun, 3 Nov 2019 03:06:32 +0000 (+0000) Subject: block: detect: use current mp as value of target option X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f438552ec8e777c271f5c2ec6713d9567eafa5b6;p=oweals%2Ffstools.git block: detect: use current mp as value of target option Move down the function so that no declaration of find_mount_point() is not needed Signed-off-by: Yousong Zhou --- diff --git a/block.c b/block.c index 1972c50..b6d49a8 100644 --- 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;