]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/import/export-tar.c
util-lib: split our string related calls from util.[ch] into its own file string...
[thirdparty/systemd.git] / src / import / export-tar.c
index c27bab46b0be5d3064c0c15e0a255762ec47fc8e..93f2fdbd44bd98f50ed09c97c975eac5c4471d2a 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include <sys/sendfile.h>
-
 #include "sd-daemon.h"
-#include "util.h"
-#include "ratelimit.h"
+
 #include "btrfs-util.h"
 #include "import-common.h"
+#include "process-util.h"
+#include "ratelimit.h"
+#include "string-util.h"
+#include "util.h"
 #include "export-tar.h"
 
 #define COPY_BUFFER_SIZE (16*1024)
@@ -77,7 +78,7 @@ TarExport *tar_export_unref(TarExport *e) {
         }
 
         if (e->temp_path) {
-                (void) btrfs_subvol_remove(e->temp_path);
+                (void) btrfs_subvol_remove(e->temp_path, BTRFS_REMOVE_QUOTA);
                 free(e->temp_path);
         }
 
@@ -135,7 +136,7 @@ static void tar_export_report_progress(TarExport *e) {
         unsigned percent;
         assert(e);
 
-        /* Do we have any quota info? I fnot, we don't know anything about the progress */
+        /* Do we have any quota info? Inot, we don't know anything about the progress */
         if (e->quota_referenced == (uint64_t) -1)
                 return;
 
@@ -282,23 +283,21 @@ int tar_export_start(TarExport *e, const char *path, int fd, ImportCompressType
         if (e->st.st_ino == 256) { /* might be a btrfs subvolume? */
                 BtrfsQuotaInfo q;
 
-                r = btrfs_subvol_get_quota_fd(sfd, &q);
+                r = btrfs_subvol_get_subtree_quota_fd(sfd, 0, &q);
                 if (r >= 0)
                         e->quota_referenced = q.referenced;
 
-                free(e->temp_path);
-                e->temp_path = NULL;
+                e->temp_path = mfree(e->temp_path);
 
-                r = tempfn_random(path, &e->temp_path);
+                r = tempfn_random(path, NULL, &e->temp_path);
                 if (r < 0)
                         return r;
 
                 /* Let's try to make a snapshot, if we can, so that the export is atomic */
-                r = btrfs_subvol_snapshot_fd(sfd, e->temp_path, true, false);
+                r = btrfs_subvol_snapshot_fd(sfd, e->temp_path, BTRFS_SNAPSHOT_READ_ONLY|BTRFS_SNAPSHOT_RECURSIVE);
                 if (r < 0) {
                         log_debug_errno(r, "Couldn't create snapshot %s of %s, not exporting atomically: %m", e->temp_path, path);
-                        free(e->temp_path);
-                        e->temp_path = NULL;
+                        e->temp_path = mfree(e->temp_path);
                 }
         }