summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-02-24 18:43:37 +0100
committerLennart Poettering <lennart@poettering.net>2015-02-24 18:46:49 +0100
commit754061ce7173fd8cb66ade1a48381e2cead35522 (patch)
tree5db2ea3f26d7c19a82b3af2f725ba2900dc4a7cb /src/shared
parent160e3793adf2da2bd9ae3fe6b8881bb937e6e71b (diff)
importd: enable btrfs quota in /var/lib/machines, if necessary
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/btrfs-util.c23
-rw-r--r--src/shared/btrfs-util.h3
2 files changed, 26 insertions, 0 deletions
diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c
index 2a70dfea45..980963b748 100644
--- a/src/shared/btrfs-util.c
+++ b/src/shared/btrfs-util.c
@@ -646,3 +646,26 @@ int btrfs_defrag(const char *p) {
return btrfs_defrag_fd(fd);
}
+
+int btrfs_quota_enable_fd(int fd, bool b) {
+ struct btrfs_ioctl_quota_ctl_args args = {
+ .cmd = b ? BTRFS_QUOTA_CTL_ENABLE : BTRFS_QUOTA_CTL_DISABLE,
+ };
+
+ assert(fd >= 0);
+
+ if (ioctl(fd, BTRFS_IOC_QUOTA_CTL, &args) < 0)
+ return -errno;
+
+ return 0;
+}
+
+int btrfs_quota_enable(const char *path, bool b) {
+ _cleanup_close_ int fd = -1;
+
+ fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
+ if (fd < 0)
+ return -errno;
+
+ return btrfs_quota_enable_fd(fd, b);
+}
diff --git a/src/shared/btrfs-util.h b/src/shared/btrfs-util.h
index 1b9c142e5c..93c3f13ed5 100644
--- a/src/shared/btrfs-util.h
+++ b/src/shared/btrfs-util.h
@@ -64,3 +64,6 @@ int btrfs_get_block_device(const char *path, dev_t *dev);
int btrfs_defrag_fd(int fd);
int btrfs_defrag(const char *p);
+
+int btrfs_quota_enable_fd(int fd, bool b);
+int btrfs_quota_enable(const char *path, bool b);