From: Michael Tremer Date: Thu, 20 May 2021 11:31:47 +0000 (+0000) Subject: snapshot: Do not archive any mountpoints X-Git-Tag: 0.9.28~1285^2~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=457db6215d281a0def6d7d16cb114e928277a956;p=pakfire.git snapshot: Do not archive any mountpoints Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/include/pakfire/pakfire.h b/src/libpakfire/include/pakfire/pakfire.h index c2f49941e..a6f6ca8c6 100644 --- a/src/libpakfire/include/pakfire/pakfire.h +++ b/src/libpakfire/include/pakfire/pakfire.h @@ -92,6 +92,7 @@ int pakfire_read_makefile(PakfireParser* parser, Pakfire pakfire, const char* pa #include struct pakfire_config* pakfire_get_config(Pakfire pakfire); +int pakfire_is_mountpoint(Pakfire pakfire, const char* path); const char* pakfire_get_distro_name(Pakfire pakfire); const char* pakfire_get_distro_id(Pakfire pakfire); diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 38fc1a600..1045aeb54 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -156,16 +156,12 @@ static int __mount(Pakfire pakfire, const char* source, const char* target, if (r) return r; - 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; - } + // Skip if the mountpoint is already on the list + if (pakfire_is_mountpoint(pakfire, target)) + return 0; // If not, add the mountpoint to the list so that we can umount it later - mp = calloc(1, sizeof(*mp)); + struct mountpoint* mp = calloc(1, sizeof(*mp)); if (!mp) return 1; @@ -251,6 +247,18 @@ RETRY: return 0; } +int pakfire_is_mountpoint(Pakfire pakfire, const char* path) { + struct mountpoint* mp; + + // Check if path is on this list + STAILQ_FOREACH(mp, &pakfire->mountpoints, nodes) { + if (strcmp(mp->path, path) == 0) + return 1; + } + + return 0; +} + static const struct pakfire_devnode { const char* path; int major; diff --git a/src/libpakfire/snapshot.c b/src/libpakfire/snapshot.c index 5207df832..e238890de 100644 --- a/src/libpakfire/snapshot.c +++ b/src/libpakfire/snapshot.c @@ -165,14 +165,22 @@ PAKFIRE_EXPORT int pakfire_snapshot_create(Pakfire pakfire, FILE* f) { goto ERROR; } + const char* full_path = archive_entry_pathname(entry); + // Compute the relative path - const char* path = pakfire_path_relpath(root, archive_entry_pathname(entry)); + const char* path = pakfire_path_relpath(root, full_path); if (!path) continue; + // Skip mountpoints + if (pakfire_is_mountpoint(pakfire, full_path)) { + DEBUG(pakfire, "Skipping mountpoint %s...", path); + continue; + } + // Skip excludes if (pakfire_snapshot_path_is_excluded(path)) { - DEBUG(pakfire, "Skipping %s...\n", path); + DEBUG(pakfire, "Skipping excluded path %s...\n", path); continue; }