X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fmachine-image.c;h=00337e7c9fe03a6c208e0e16034d45cc5b9bcc71;hb=f85ef957e647c5182acf5e64298f68e4b7fbfe8f;hp=8d61507e8494c55ed1257de34c07690456085302;hpb=63c372cb9df3bee01e3bf8cd7f96f336bddda846;p=elogind.git diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c index 8d61507e8..00337e7c9 100644 --- a/src/shared/machine-image.c +++ b/src/shared/machine-image.c @@ -23,7 +23,6 @@ #include #include -#include "strv.h" #include "utf8.h" #include "btrfs-util.h" #include "path-util.h" @@ -164,10 +163,10 @@ static int image_make( r = btrfs_subvol_get_quota_fd(fd, "a); if (r >= 0) { - (*ret)->usage = quota.referred; + (*ret)->usage = quota.referenced; (*ret)->usage_exclusive = quota.exclusive; - (*ret)->limit = quota.referred_max; + (*ret)->limit = quota.referenced_max; (*ret)->limit_exclusive = quota.exclusive_max; } @@ -441,8 +440,9 @@ int image_rename(Image *i, const char *new_name) { if (!nn) return -ENOMEM; - if (renameat2(AT_FDCWD, i->path, AT_FDCWD, new_path, RENAME_NOREPLACE) < 0) - return -errno; + r = rename_noreplace(AT_FDCWD, i->path, AT_FDCWD, new_path); + if (r < 0) + return r; /* Restore the immutable bit, if it was set before */ if (file_attr & FS_IMMUTABLE_FL) @@ -614,6 +614,19 @@ int image_path_lock(const char *path, int operation, LockFile *global, LockFile return 0; } +int image_set_limit(Image *i, uint64_t referenced_max) { + assert(i); + + if (path_equal(i->path, "/") || + path_startswith(i->path, "/usr")) + return -EROFS; + + if (i->type != IMAGE_SUBVOLUME) + return -ENOTSUP; + + return btrfs_quota_limit(i->path, referenced_max); +} + int image_name_lock(const char *name, int operation, LockFile *ret) { const char *p;