]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxcbtrfs.{c,h} rework declarations and definitions
authorChristian Brauner <christian.brauner@mailbox.org>
Thu, 17 Dec 2015 20:14:30 +0000 (21:14 +0100)
committerChristian Brauner <christian.brauner@mailbox.org>
Mon, 28 Dec 2015 08:49:33 +0000 (09:49 +0100)
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: Christian Brauner <christian.brauner@mailbox.org>
src/lxc/bdev/bdev.c
src/lxc/bdev/bdev.h
src/lxc/bdev/lxcbtrfs.c
src/lxc/bdev/lxcbtrfs.h

index 97cba40a65860eef1528bb47b64be781fdb8fa42..4688d96cd481d66714d1a6f34eff473eb3705df1 100644 (file)
 
 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;
index 233ff636c08d59cfb24a3a5f24cea64f1c91c06e..c11e6f87d41bcf7994e5f6c5e2fd1d64998bd72a 100644 (file)
@@ -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
index cbaebd9283cad7a3163da66982913cddf551a4a8..229bf5f8e3740248e0c29d24da4f7b3c34a12401 100644 (file)
  */
 
 #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;
index 7c47956eb61f089014d43ddfdb78ada55887b6ed..40e45210b5e767e9883cb45b7bb6aa7cb1b2cff6 100644 (file)
 #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