[lxc-devel] [PATCH] Reduce public API (V2)

2013-12-02 Thread Stéphane Graber
This removes all but the following headers from our includes:
 - attach_options.h
 - lxccontainer.h
 - version.h

This also removes the duplicate lxc_version function (lxc_get_version
has been preferred for a while).

lxclock.h is now considered private.

As a result quite a lot of files needed addition of extra includes
previously inherited from lxclock.h.

Signed-off-by: Stéphane Graber stgra...@ubuntu.com
---
 src/lxc/Makefile.am| 19 +--
 src/lxc/bdev.c |  1 +
 src/lxc/lxc_config.c   |  1 +
 src/lxc/lxc_create.c   |  1 +
 src/lxc/lxc_snapshot.c |  1 +
 src/lxc/lxccontainer.c |  3 ++-
 src/lxc/lxccontainer.h |  7 ---
 src/lxc/version.c  | 29 -
 src/lxc/version.h.in   |  5 -
 src/tests/attach.c |  2 ++
 src/tests/cgpath.c |  2 ++
 src/tests/concurrent.c |  2 ++
 src/tests/console.c|  2 ++
 src/tests/containertests.c |  1 +
 src/tests/get_item.c   |  1 +
 src/tests/list.c   |  1 +
 src/tests/lxcpath.c|  1 +
 src/tests/snapshot.c   |  2 ++
 src/tests/startone.c   |  1 +
 19 files changed, 26 insertions(+), 56 deletions(-)
 delete mode 100644 src/lxc/version.c

diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index bf93baa..5369700 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -1,23 +1,6 @@
 pkginclude_HEADERS = \
-   arguments.h \
-   attach.h \
attach_options.h \
-   bdev.h \
-   caps.h \
-   cgroup.h \
-   conf.h \
-   console.h \
-   error.h \
-   list.h \
-   log.h \
lxccontainer.h \
-   lxc.h \
-   lxclock.h \
-   monitor.h \
-   namespace.h \
-   start.h \
-   state.h \
-   utils.h \
version.h
 
 if IS_BIONIC
@@ -87,7 +70,7 @@ liblxc_so_SOURCES = \
lxcutmp.c lxcutmp.h \
lxclock.h lxclock.c \
lxccontainer.c lxccontainer.h \
-   version.c version.h \
+   version.h \
\
$(LSM_SOURCES)
 
diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c
index 03fecfb..249815e 100644
--- a/src/lxc/bdev.c
+++ b/src/lxc/bdev.c
@@ -47,6 +47,7 @@
 #include namespace.h
 #include parse.h
 #include utils.h
+#include lxclock.h
 
 #ifndef BLKGETSIZE64
 #define BLKGETSIZE64 _IOR(0x12,114,size_t)
diff --git a/src/lxc/lxc_config.c b/src/lxc/lxc_config.c
index 21bde64..8a4114d 100644
--- a/src/lxc/lxc_config.c
+++ b/src/lxc/lxc_config.c
@@ -19,6 +19,7 @@
  */
 
 #include stdio.h
+#include string.h
 #include config.h
 #include lxc/lxccontainer.h
 
diff --git a/src/lxc/lxc_create.c b/src/lxc/lxc_create.c
index 754afbf..7399683 100644
--- a/src/lxc/lxc_create.c
+++ b/src/lxc/lxc_create.c
@@ -23,6 +23,7 @@
 #include libgen.h
 #include unistd.h
 #include ctype.h
+#include fcntl.h
 #include sys/types.h
 
 #include lxc/lxc.h
diff --git a/src/lxc/lxc_snapshot.c b/src/lxc/lxc_snapshot.c
index d80dd39..f80afe5 100644
--- a/src/lxc/lxc_snapshot.c
+++ b/src/lxc/lxc_snapshot.c
@@ -24,6 +24,7 @@
 #include unistd.h
 #include ctype.h
 #include sys/types.h
+#include fcntl.h
 
 #include lxc/lxc.h
 #include lxc/log.h
diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
index 50796ae..7f54f50 100644
--- a/src/lxc/lxccontainer.c
+++ b/src/lxc/lxccontainer.c
@@ -50,6 +50,7 @@
 #include sched.h
 #include arpa/inet.h
 #include libgen.h
+#include lxclock.h
 
 #if HAVE_IFADDRS_H
 #include ifaddrs.h
@@ -2107,7 +2108,7 @@ const char *lxc_get_default_zfs_root(void)
 
 const char *lxc_get_version(void)
 {
-   return lxc_version();
+   return LXC_VERSION;
 }
 
 static int copy_file(char *old, char *new)
diff --git a/src/lxc/lxccontainer.h b/src/lxc/lxccontainer.h
index d57aead..4ad3b66 100644
--- a/src/lxc/lxccontainer.h
+++ b/src/lxc/lxccontainer.h
@@ -22,12 +22,11 @@
 
 #ifndef __LXC_CONTAINER_H
 #define __LXC_CONTAINER_H
-#include lxclock.h
 #include attach_options.h
-#include stdlib.h
 #include malloc.h
-
+#include semaphore.h
 #include stdbool.h
+#include stdlib.h
 
 #define LXC_CLONE_KEEPNAME(1  0) /*! Do not edit the rootfs to 
change the hostname */
 #define LXC_CLONE_COPYHOOKS   (1  1) /*! Copy all hooks into the 
container directory */
@@ -41,6 +40,8 @@ struct bdev_specs;
 
 struct lxc_snapshot;
 
+struct lxc_lock;
+
 /*!
  * An LXC container.
  */
diff --git a/src/lxc/version.c b/src/lxc/version.c
deleted file mode 100644
index bfa34bd..000
--- a/src/lxc/version.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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 

Re: [lxc-devel] [PATCH] Reduce public API (V2)

2013-12-02 Thread Serge Hallyn
Quoting Stéphane Graber (stgra...@ubuntu.com):
 This removes all but the following headers from our includes:
  - attach_options.h
  - lxccontainer.h
  - version.h
 
 This also removes the duplicate lxc_version function (lxc_get_version
 has been preferred for a while).
 
 lxclock.h is now considered private.
 
 As a result quite a lot of files needed addition of extra includes
 previously inherited from lxclock.h.
 
 Signed-off-by: Stéphane Graber stgra...@ubuntu.com

Thanks!

Acked-by: Serge E. Hallyn serge.hal...@ubuntu.com

 ---
  src/lxc/Makefile.am| 19 +--
  src/lxc/bdev.c |  1 +
  src/lxc/lxc_config.c   |  1 +
  src/lxc/lxc_create.c   |  1 +
  src/lxc/lxc_snapshot.c |  1 +
  src/lxc/lxccontainer.c |  3 ++-
  src/lxc/lxccontainer.h |  7 ---
  src/lxc/version.c  | 29 -
  src/lxc/version.h.in   |  5 -
  src/tests/attach.c |  2 ++
  src/tests/cgpath.c |  2 ++
  src/tests/concurrent.c |  2 ++
  src/tests/console.c|  2 ++
  src/tests/containertests.c |  1 +
  src/tests/get_item.c   |  1 +
  src/tests/list.c   |  1 +
  src/tests/lxcpath.c|  1 +
  src/tests/snapshot.c   |  2 ++
  src/tests/startone.c   |  1 +
  19 files changed, 26 insertions(+), 56 deletions(-)
  delete mode 100644 src/lxc/version.c
 
 diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
 index bf93baa..5369700 100644
 --- a/src/lxc/Makefile.am
 +++ b/src/lxc/Makefile.am
 @@ -1,23 +1,6 @@
  pkginclude_HEADERS = \
 - arguments.h \
 - attach.h \
   attach_options.h \
 - bdev.h \
 - caps.h \
 - cgroup.h \
 - conf.h \
 - console.h \
 - error.h \
 - list.h \
 - log.h \
   lxccontainer.h \
 - lxc.h \
 - lxclock.h \
 - monitor.h \
 - namespace.h \
 - start.h \
 - state.h \
 - utils.h \
   version.h
  
  if IS_BIONIC
 @@ -87,7 +70,7 @@ liblxc_so_SOURCES = \
   lxcutmp.c lxcutmp.h \
   lxclock.h lxclock.c \
   lxccontainer.c lxccontainer.h \
 - version.c version.h \
 + version.h \
   \
   $(LSM_SOURCES)
  
 diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c
 index 03fecfb..249815e 100644
 --- a/src/lxc/bdev.c
 +++ b/src/lxc/bdev.c
 @@ -47,6 +47,7 @@
  #include namespace.h
  #include parse.h
  #include utils.h
 +#include lxclock.h
  
  #ifndef BLKGETSIZE64
  #define BLKGETSIZE64 _IOR(0x12,114,size_t)
 diff --git a/src/lxc/lxc_config.c b/src/lxc/lxc_config.c
 index 21bde64..8a4114d 100644
 --- a/src/lxc/lxc_config.c
 +++ b/src/lxc/lxc_config.c
 @@ -19,6 +19,7 @@
   */
  
  #include stdio.h
 +#include string.h
  #include config.h
  #include lxc/lxccontainer.h
  
 diff --git a/src/lxc/lxc_create.c b/src/lxc/lxc_create.c
 index 754afbf..7399683 100644
 --- a/src/lxc/lxc_create.c
 +++ b/src/lxc/lxc_create.c
 @@ -23,6 +23,7 @@
  #include libgen.h
  #include unistd.h
  #include ctype.h
 +#include fcntl.h
  #include sys/types.h
  
  #include lxc/lxc.h
 diff --git a/src/lxc/lxc_snapshot.c b/src/lxc/lxc_snapshot.c
 index d80dd39..f80afe5 100644
 --- a/src/lxc/lxc_snapshot.c
 +++ b/src/lxc/lxc_snapshot.c
 @@ -24,6 +24,7 @@
  #include unistd.h
  #include ctype.h
  #include sys/types.h
 +#include fcntl.h
  
  #include lxc/lxc.h
  #include lxc/log.h
 diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
 index 50796ae..7f54f50 100644
 --- a/src/lxc/lxccontainer.c
 +++ b/src/lxc/lxccontainer.c
 @@ -50,6 +50,7 @@
  #include sched.h
  #include arpa/inet.h
  #include libgen.h
 +#include lxclock.h
  
  #if HAVE_IFADDRS_H
  #include ifaddrs.h
 @@ -2107,7 +2108,7 @@ const char *lxc_get_default_zfs_root(void)
  
  const char *lxc_get_version(void)
  {
 - return lxc_version();
 + return LXC_VERSION;
  }
  
  static int copy_file(char *old, char *new)
 diff --git a/src/lxc/lxccontainer.h b/src/lxc/lxccontainer.h
 index d57aead..4ad3b66 100644
 --- a/src/lxc/lxccontainer.h
 +++ b/src/lxc/lxccontainer.h
 @@ -22,12 +22,11 @@
  
  #ifndef __LXC_CONTAINER_H
  #define __LXC_CONTAINER_H
 -#include lxclock.h
  #include attach_options.h
 -#include stdlib.h
  #include malloc.h
 -
 +#include semaphore.h
  #include stdbool.h
 +#include stdlib.h
  
  #define LXC_CLONE_KEEPNAME(1  0) /*! Do not edit the rootfs to 
 change the hostname */
  #define LXC_CLONE_COPYHOOKS   (1  1) /*! Copy all hooks into the 
 container directory */
 @@ -41,6 +40,8 @@ struct bdev_specs;
  
  struct lxc_snapshot;
  
 +struct lxc_lock;
 +
  /*!
   * An LXC container.
   */
 diff --git a/src/lxc/version.c b/src/lxc/version.c
 deleted file mode 100644
 index bfa34bd..000
 --- a/src/lxc/version.c
 +++ /dev/null
 @@ -1,29 +0,0 @@
 -/*
 - * lxc: linux Container library
 - *
 - * (C) Copyright IBM Corp. 2007, 2008
 - *
 - * Authors:
 - * Daniel Lezcano daniel.lezcano