From: Michael Tremer Date: Thu, 29 Apr 2021 08:38:33 +0000 (+0000) Subject: mount: Check list for duplicates to only umount everything once X-Git-Tag: 0.9.28~1285^2~202 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e860d850d7e2a336b5e36f3efd7675ad8818364e;p=pakfire.git mount: Check list for duplicates to only umount everything once Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 08a30a4e2..f8e5931dd 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -139,12 +139,21 @@ static int __mount(Pakfire pakfire, const char* source, const char* target, if (r) return r; - // Store mountpoint so that we can umount it later - struct mountpoint* mp = calloc(1, sizeof(*mp)); + struct mountpoint* mp; + + // Check if the mountpoint is already on the list + STAILQ_FOREACH(mp, &pakfire->mountpoints, nodes) { + if (strcmp(mp->path, target) == 0) + return 0; + } + + // If not, add the mountpoint to the list so that we can umount it later + mp = calloc(1, sizeof(*mp)); if (!mp) return 1; pakfire_string_set(mp->path, target); + STAILQ_INSERT_HEAD(&pakfire->mountpoints, mp, nodes); return 0;