X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fmachine-image.c;h=edf986d4db11801abb0ca47c79b8003793189f3a;hb=4034a06ddb82ec9868cd52496fef2f5faa25575f;hp=c734f148aec6d5f96d0742a8242052f680946955;hpb=2eec67acbb00593e414549a7e5b35eb7dd776b1b;p=elogind.git diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c index c734f148a..edf986d4d 100644 --- a/src/shared/machine-image.c +++ b/src/shared/machine-image.c @@ -163,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; } @@ -369,7 +369,7 @@ int image_remove(Image *i) { return rm_rf_dangerous(i->path, false, true, false); default: - return -ENOTSUP; + return -EOPNOTSUPP; } } @@ -430,7 +430,7 @@ int image_rename(Image *i, const char *new_name) { } default: - return -ENOTSUP; + return -EOPNOTSUPP; } if (!new_path) @@ -440,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) @@ -497,7 +498,7 @@ int image_clone(Image *i, const char *new_name, bool read_only) { break; default: - return -ENOTSUP; + return -EOPNOTSUPP; } if (r < 0) @@ -562,7 +563,7 @@ int image_read_only(Image *i, bool b) { } default: - return -ENOTSUP; + return -EOPNOTSUPP; } return 0; @@ -613,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 -EOPNOTSUPP; + + return btrfs_quota_limit(i->path, referenced_max); +} + int image_name_lock(const char *name, int operation, LockFile *ret) { const char *p;