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;