]> git.ipfire.org Git - pakfire.git/commitdiff
mount: Check list for duplicates to only umount everything once
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 29 Apr 2021 08:38:33 +0000 (08:38 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 29 Apr 2021 08:38:33 +0000 (08:38 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/pakfire.c

index 08a30a4e25d26828a7e8d42df84f855e135a9f44..f8e5931dd7de467caf128826a5a1926d5a1b1ee9 100644 (file)
@@ -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;