Commit f2e50c44 by Christian Brauner

Split bdev into modules: btrfs

Create a module for btrfs: lxcbtrfs.{c,h}. The functions: - get_btrfs_subvol_path() - btrfs_list_get_path_rootid() - is_btrfs_fs() - btrfs_detect() - btrfs_mount() - btrfs_umount() - btrfs_subvolume_create() - btrfs_same_fs() - btrfs_snapshot() - btrfs_snapshot_wrapper() - btrfs_clonepaths() - btrfs_do_destroy_subvol() - get_btrfs_tree_idx() - my_btrfs_tree *create_my_btrfs_tree() - update_tree_node() - add_btrfs_tree_node() - free_btrfs_tree() - do_remove_btrfs_children() - btrfs_recursive_destroy() - btrfs_try_remove_subvol() - btrfs_destroy() - btrfs_create() and the structs: - struct mytree_node - struct my_btrfs_tree move from bdev.{c,h} to lxcbtrfs.{c,h}. Rename the header file - lxc-btrfs.h --> lxcbtrfs.h Adapt Makefile.am to include lxcbtrfs.{c,h} and remove lxc-btrfs.h. Signed-off-by: 's avatarChristian Brauner <christian.brauner@mailbox.org>
parent 364d54c9
...@@ -7,8 +7,8 @@ noinst_HEADERS = \ ...@@ -7,8 +7,8 @@ noinst_HEADERS = \
arguments.h \ arguments.h \
attach.h \ attach.h \
bdev/bdev.h \ bdev/bdev.h \
bdev/lxc-btrfs.h \ bdev/lxcbtrfs.h \
bdev/overlay.h \ bdev/lxcoverlay.h \
caps.h \ caps.h \
cgroup.h \ cgroup.h \
conf.h \ conf.h \
...@@ -61,7 +61,10 @@ endif ...@@ -61,7 +61,10 @@ endif
liblxc_so_SOURCES = \ liblxc_so_SOURCES = \
arguments.c arguments.h \ arguments.c arguments.h \
bdev/bdev.c bdev/bdev.h bdev/overlay.c bdev/overlay.h bdev/lxc-btrfs.h \ bdev/bdev.c bdev/bdev.h \
bdev/lxcbtrfs.c bdev/lxcbtrfs.h \
bdev/lxcoverlay.c bdev/lxcoverlay.h \
bdev/lxcrsync.c bdev/lxcrsync.h \
commands.c commands.h \ commands.c commands.h \
start.c start.h \ start.c start.h \
execute.c \ execute.c \
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
* aufs, dir, raw, btrfs, overlayfs, aufs, lvm, loop, zfs, nbd (qcow2, raw, vdi, qed) * aufs, dir, raw, btrfs, overlayfs, aufs, lvm, loop, zfs, nbd (qcow2, raw, vdi, qed)
*/ */
#include <stdint.h>
#include <lxc/lxccontainer.h> #include <lxc/lxccontainer.h>
#include <stdint.h>
#include <sys/mount.h> #include <sys/mount.h>
#include "config.h" #include "config.h"
...@@ -133,4 +133,5 @@ bool attach_block_device(struct lxc_conf *conf); ...@@ -133,4 +133,5 @@ bool attach_block_device(struct lxc_conf *conf);
void detach_block_device(struct lxc_conf *conf); void detach_block_device(struct lxc_conf *conf);
bool rootfs_is_blockdev(struct lxc_conf *conf); bool rootfs_is_blockdev(struct lxc_conf *conf);
#endif
#endif // __LXC_BDEV_H
/*
* lxc: linux Container library
*
* (C) Copyright IBM Corp. 2007, 2008
*
* Authors:
* Daniel Lezcano <daniel.lezcano at free.fr>
*
* This library is free software; you can redistribute it and/or
* modify it 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.
*
* This library 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 this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __LXC_BTRFS_H
#define __LXC_BTRFS_H
#include <stdbool.h>
#include <stdint.h>
typedef uint8_t u8; typedef uint8_t u8;
typedef uint16_t u16; typedef uint16_t u16;
typedef uint32_t u32; typedef uint32_t u32;
...@@ -12,7 +41,7 @@ struct btrfs_ioctl_space_info { ...@@ -12,7 +41,7 @@ struct btrfs_ioctl_space_info {
struct btrfs_ioctl_space_args { struct btrfs_ioctl_space_args {
unsigned long long space_slots; unsigned long long space_slots;
unsigned long long total_spaces; unsigned long long total_spaces;
struct btrfs_ioctl_space_info spaces[0]; struct btrfs_ioctl_space_info spaces[];
}; };
#define BTRFS_IOCTL_MAGIC 0x94 #define BTRFS_IOCTL_MAGIC 0x94
...@@ -285,3 +314,40 @@ struct btrfs_ioctl_ino_lookup_args { ...@@ -285,3 +314,40 @@ struct btrfs_ioctl_ino_lookup_args {
#define BTRFS_FIRST_FREE_OBJECTID 256ULL #define BTRFS_FIRST_FREE_OBJECTID 256ULL
#define BTRFS_LAST_FREE_OBJECTID -256ULL #define BTRFS_LAST_FREE_OBJECTID -256ULL
#define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL #define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
struct mytree_node {
u64 objid;
u64 parentid;
char *name;
char *dirname;
};
struct my_btrfs_tree {
struct mytree_node *nodes;
int num;
};
/*
* Functions associated with a btrfs bdev struct.
*/
int btrfs_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
const char *cname, const char *oldpath,
const char *lxcpath, int snap, uint64_t newsize,
struct lxc_conf *conf);
int btrfs_create(struct bdev *bdev, const char *dest, const char *n,
struct bdev_specs *specs);
int btrfs_destroy(struct bdev *orig);
int btrfs_detect(const char *path);
int btrfs_mount(struct bdev *bdev);
int btrfs_umount(struct bdev *bdev);
/*
* Helper functions
*/
char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
int name_len);
int btrfs_list_get_path_rootid(int fd, u64 *treeid);
bool is_btrfs_fs(const char *path);
bool btrfs_try_remove_subvol(const char *path);
#endif // __LXC_BTRFS_H
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include "confile.h" #include "confile.h"
#include "log.h" #include "log.h"
#include "lxccontainer.h" #include "lxccontainer.h"
#include "overlay.h" #include "lxcoverlay.h"
#include "utils.h" #include "utils.h"
lxc_log_define(overlay, lxc); lxc_log_define(overlay, lxc);
......
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
#include "log.h" #include "log.h"
#include "caps.h" /* for lxc_caps_last_cap() */ #include "caps.h" /* for lxc_caps_last_cap() */
#include "bdev/bdev.h" #include "bdev/bdev.h"
#include "bdev/overlay.h" #include "bdev/lxcoverlay.h"
#include "cgroup.h" #include "cgroup.h"
#include "lxclock.h" #include "lxclock.h"
#include "namespace.h" #include "namespace.h"
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include "attach.h" #include "attach.h"
#include "bdev/bdev.h" #include "bdev/bdev.h"
#include "bdev/overlay.h" #include "bdev/lxcoverlay.h"
#include "cgroup.h" #include "cgroup.h"
#include "conf.h" #include "conf.h"
#include "config.h" #include "config.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment