btrfs-util.h revision 0d6e763b48cabe8899a20823b015c9a988e38659
d29201dd5328b88140ce050100693c501852657dChristian Maeder/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder/***
7165a916d2fa1bf87c4741ec63b253413eebbf69Karl Luc This file is part of systemd.
cacbb5e3100fb85d23d1614cace3a8662801f2e6Eugen Kuksa
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu Copyright 2014 Lennart Poettering
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder
cacbb5e3100fb85d23d1614cace3a8662801f2e6Eugen Kuksa systemd is free software; you can redistribute it and/or modify it
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder under the terms of the GNU Lesser General Public License as published by
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder the Free Software Foundation; either version 2.1 of the License, or
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder (at your option) any later version.
7165a916d2fa1bf87c4741ec63b253413eebbf69Karl Luc
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder systemd is distributed in the hope that it will be useful, but
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder WITHOUT ANY WARRANTY; without even the implied warranty of
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder Lesser General Public License for more details.
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder You should have received a copy of the GNU Lesser General Public License
75067b1beba1380cde707c30e7fc050d86f6927fKarl Luc along with systemd; If not, see <http://www.gnu.org/licenses/>.
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder***/
7165a916d2fa1bf87c4741ec63b253413eebbf69Karl Luc
7165a916d2fa1bf87c4741ec63b253413eebbf69Karl Luc#include <stdbool.h>
6342ef8f9f785e79c91f217c30b3ba2b6fa0ad4fEugen Kuksa#include <sys/types.h>
75067b1beba1380cde707c30e7fc050d86f6927fKarl Luc
de03ed90ff6efbbc4751301bcf6b50d9790c1afbKarl Luc#include "time-util.h"
52c81e62d4a3797b926fb3392369b45a9fef336cSoeren D. Schulze
52c81e62d4a3797b926fb3392369b45a9fef336cSoeren D. Schulzetypedef struct BtrfsSubvolInfo {
d386b61802c70e3d220d4520d9fcdefbd9c469f4Soeren D. Schulze uint64_t subvol_id;
66977d201b3ff7ee9c1f992c0f3f701b69eac2c9Karl Luc usec_t otime;
0ac66bed6456d7900a657269e36107ca7bec4756Iulia Ignatov
0ac66bed6456d7900a657269e36107ca7bec4756Iulia Ignatov sd_id128_t uuid;
0ac66bed6456d7900a657269e36107ca7bec4756Iulia Ignatov sd_id128_t parent_uuid;
99a1bfbb82c875580410b4745617fea2297fdc2bEugen Kuksa
a35bacbc16daf5c10f9accfdfadc4971e9d6f648Iulia Ignatov bool read_only;
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder} BtrfsSubvolInfo;
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maedertypedef struct BtrfsQuotaInfo {
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder uint64_t referred;
e16b3696b2c173aac14200321868ed81b8f7dc69Christian Maeder uint64_t exclusive;
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder uint64_t referred_max;
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder uint64_t exclusive_max;
51846950b4b1f31342008cf17f667859a5f21949Christian Maeder} BtrfsQuotaInfo;
3831cf8a3b0ea144a80d13fe0314cc2752e32107Christian Maeder
51846950b4b1f31342008cf17f667859a5f21949Christian Maederint btrfs_is_snapshot(int fd);
75067b1beba1380cde707c30e7fc050d86f6927fKarl Luc
75067b1beba1380cde707c30e7fc050d86f6927fKarl Lucint btrfs_subvol_make(const char *path);
75067b1beba1380cde707c30e7fc050d86f6927fKarl Lucint btrfs_subvol_make_label(const char *path);
75067b1beba1380cde707c30e7fc050d86f6927fKarl Lucint btrfs_subvol_remove(const char *path);
75067b1beba1380cde707c30e7fc050d86f6927fKarl Lucint btrfs_subvol_snapshot(const char *old_path, const char *new_path, bool read_only, bool fallback_copy);
75067b1beba1380cde707c30e7fc050d86f6927fKarl Luc
75067b1beba1380cde707c30e7fc050d86f6927fKarl Lucint btrfs_subvol_set_read_only_fd(int fd, bool b);
75067b1beba1380cde707c30e7fc050d86f6927fKarl Lucint btrfs_subvol_set_read_only(const char *path, bool b);
75067b1beba1380cde707c30e7fc050d86f6927fKarl Lucint btrfs_subvol_get_read_only_fd(int fd);
7165a916d2fa1bf87c4741ec63b253413eebbf69Karl Lucint btrfs_subvol_get_id_fd(int fd, uint64_t *ret);
1ea7fb6b0f66210bc0d3cb995f1b655277b33884Eugen Kuksaint btrfs_subvol_get_info_fd(int fd, BtrfsSubvolInfo *info);
d6ce032cac688f3698be7133d27f53d3967e6749Christian Maederint btrfs_subvol_get_quota_fd(int fd, BtrfsQuotaInfo *quota);
7165a916d2fa1bf87c4741ec63b253413eebbf69Karl Luc
de03ed90ff6efbbc4751301bcf6b50d9790c1afbKarl Lucint btrfs_reflink(int infd, int outfd);
75067b1beba1380cde707c30e7fc050d86f6927fKarl Lucint btrfs_clone_range(int infd, uint64_t in_offset, int ofd, uint64_t out_offset, uint64_t sz);
551f1476dea3f969775527cb15fd512e86279307Karl Luc
9e5811a3323b00d6ff8d3fe91a185de1ab31150bChristian Maederint btrfs_get_block_device(const char *path, dev_t *dev);
75067b1beba1380cde707c30e7fc050d86f6927fKarl Luc
75067b1beba1380cde707c30e7fc050d86f6927fKarl Lucint btrfs_defrag_fd(int fd);
75067b1beba1380cde707c30e7fc050d86f6927fKarl Lucint btrfs_defrag(const char *p);
59ec6aa4da4c93d0d4ef53ed74fdf866d0654539Eugen Kuksa