test-btrfs.c revision 3ffd4af22052963e7a29431721ee204e634bea75
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2014 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <fcntl.h>
#include "btrfs-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "log.h"
#include "string-util.h"
#include "util.h"
int r, fd;
if (fd < 0)
else {
if (r < 0)
log_error_errno(r, "Failed to get subvolume info: %m");
else {
}
if (r < 0)
log_error_errno(r, "Failed to get quota info: %m");
else {
}
if (r < 0)
log_error_errno(r, "Failed to get read only flag: %m");
else
safe_close(fd);
}
r = btrfs_subvol_make("/xxxtest");
if (r < 0)
log_error_errno(r, "Failed to make subvolume: %m");
if (r < 0)
log_error_errno(r, "Failed to write file: %m");
if (r < 0)
log_error_errno(r, "Failed to make snapshot: %m");
if (r < 0)
log_error_errno(r, "Failed to make snapshot: %m");
if (r < 0)
log_error_errno(r, "Failed to remove subvolume: %m");
if (r < 0)
log_error_errno(r, "Failed to remove subvolume: %m");
if (r < 0)
log_error_errno(r, "Failed to remove subvolume: %m");
if (r < 0)
log_error_errno(r, "Failed to make snapshot: %m");
if (r < 0)
log_error_errno(r, "Failed to remove subvolume: %m");
r = btrfs_subvol_make("/xxxrectest");
if (r < 0)
log_error_errno(r, "Failed to make subvolume: %m");
r = btrfs_subvol_make("/xxxrectest/xxxrectest2");
if (r < 0)
log_error_errno(r, "Failed to make subvolume: %m");
r = btrfs_subvol_make("/xxxrectest/xxxrectest3");
if (r < 0)
log_error_errno(r, "Failed to make subvolume: %m");
r = btrfs_subvol_make("/xxxrectest/xxxrectest3/sub");
if (r < 0)
log_error_errno(r, "Failed to make subvolume: %m");
r = btrfs_subvol_make("/xxxrectest/dir/xxxrectest4");
if (r < 0)
log_error_errno(r, "Failed to make subvolume: %m");
r = btrfs_subvol_make("/xxxrectest/dir/xxxrectest4/dir/xxxrectest5");
if (r < 0)
log_error_errno(r, "Failed to make subvolume: %m");
if (r < 0)
log_error_errno(r, "Failed to snapshot subvolume: %m");
if (r < 0)
log_error_errno(r, "Failed to recursively remove subvolume: %m");
if (r < 0)
log_error_errno(r, "Failed to recursively remove subvolume: %m");
r = btrfs_subvol_make("/xxxquotatest");
if (r < 0)
log_error_errno(r, "Failed to make subvolume: %m");
r = btrfs_subvol_auto_qgroup("/xxxquotatest", 0, true);
if (r < 0)
log_error_errno(r, "Failed to set up auto qgroup: %m");
r = btrfs_subvol_make("/xxxquotatest/beneath");
if (r < 0)
log_error_errno(r, "Failed to make subvolume: %m");
r = btrfs_subvol_auto_qgroup("/xxxquotatest/beneath", 0, false);
if (r < 0)
log_error_errno(r, "Failed to set up auto qgroup: %m");
if (r < 0)
log_error_errno(r, "Failed to set up quota limit: %m");
if (r < 0)
log_error_errno(r, "Failed to set up quota limit: %m");
r = btrfs_subvol_snapshot("/xxxquotatest", "/xxxquotatest2", BTRFS_SNAPSHOT_RECURSIVE|BTRFS_SNAPSHOT_QUOTA);
if (r < 0)
log_error_errno(r, "Failed to setup snapshot: %m");
if (r < 0)
log_error_errno(r, "Failed to query quota: %m");
if (r < 0)
log_error_errno(r, "Failed to query quota: %m");
if (r < 0)
log_error_errno(r, "Failed remove subvolume: %m");
if (r < 0)
log_error_errno(r, "Failed remove subvolume: %m");
return 0;
}