Commit 93d4475e by Christian Brauner

lxcbtrfs.{c,h} rework declarations and definitions

Declare - btrfs_same_fs(); - btrfs_snapshot(); extern instead of static in lxcbtrfs.h. They are defined in lxcbtrfs.c. Forward declare/put - struct bdev; /* defined in bdev.h */ - struct bdev_specs; /* defined in lxccontainer.h */ - struct lxc_conf; /* defined conf.h */ as incomplete types in lxcbtrfs.h so that functions declared and defined in lxcbtrfs.{c,h} have access to it. Declare - dir_new_path(); in lxcbtrfs.c. It is defined in lxccontainer.c. Move definition of struct - struct rsync_data_char; from bdev.c to bdev.h because the functions in lxcbtrfs.{c,h} need to access it. Signed-off-by: 's avatarChristian Brauner <christian.brauner@mailbox.org>
parent f2e50c44
......@@ -77,11 +77,6 @@
lxc_log_define(bdev, lxc);
struct rsync_data_char {
char *src;
char *dest;
};
/* the bulk of this needs to become a common helper */
int do_rsync(const char *src, const char *dest)
{
......@@ -110,7 +105,7 @@ int do_rsync(const char *src, const char *dest)
/* the bulk of this needs to become a common helper */
char *dir_new_path(char *src, const char *oldname, const char *name,
const char *oldpath, const char *lxcpath)
const char *oldpath, const char *lxcpath)
{
char *ret, *p, *p2;
int l1, l2, nlen;
......
......@@ -134,4 +134,9 @@ void detach_block_device(struct lxc_conf *conf);
bool rootfs_is_blockdev(struct lxc_conf *conf);
struct rsync_data_char {
char *src;
char *dest;
};
#endif // __LXC_BDEV_H
......@@ -22,15 +22,29 @@
*/
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "bdev.h"
#include "log.h"
#include "lxcbtrfs.h"
#include "utils.h"
lxc_log_define(btrfs, lxc);
/* defined in lxccontainer.c: needs to become common helper */
extern char *dir_new_path(char *src, const char *oldname, const char *name,
const char *oldpath, const char *lxcpath);
/*
* Return the full path of objid under dirid. Let's say dirid is
* /lxc/c1/rootfs, and objid is /lxc/c1/rootfs/a/b/c. Then we will
......@@ -213,7 +227,7 @@ static int btrfs_subvolume_create(const char *path)
return ret;
}
static int btrfs_same_fs(const char *orig, const char *new)
int btrfs_same_fs(const char *orig, const char *new)
{
int fd_orig = -1, fd_new = -1, ret = -1;
struct btrfs_ioctl_fs_info_args orig_args, new_args;
......@@ -254,7 +268,7 @@ out:
return ret;
}
static int btrfs_snapshot(const char *orig, const char *new)
int btrfs_snapshot(const char *orig, const char *new)
{
int fd = -1, fddst = -1, ret = -1;
struct btrfs_ioctl_vol_args_v2 args;
......
......@@ -24,8 +24,10 @@
#ifndef __LXC_BTRFS_H
#define __LXC_BTRFS_H
#define _GNU_SOURCE
#include <stdbool.h>
#include <stdint.h>
#include <sys/prctl.h>
typedef uint8_t u8;
typedef uint16_t u16;
......@@ -315,6 +317,15 @@ struct btrfs_ioctl_ino_lookup_args {
#define BTRFS_LAST_FREE_OBJECTID -256ULL
#define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
/* defined in bdev.h */
struct bdev;
/* defined in lxccontainer.h */
struct bdev_specs;
/* defined conf.h */
struct lxc_conf;
struct mytree_node {
u64 objid;
u64 parentid;
......@@ -349,5 +360,7 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
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);
int btrfs_same_fs(const char *orig, const char *new);
int btrfs_snapshot(const char *orig, const char *new);
#endif // __LXC_BTRFS_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