]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
Merge pull request #421 from brauner/2020-07-06/fixes
authorStéphane Graber <stgraber@stgraber.org>
Mon, 6 Jul 2020 10:26:47 +0000 (06:26 -0400)
committerGitHub <noreply@github.com>
Mon, 6 Jul 2020 10:26:47 +0000 (06:26 -0400)
bindings: provide lxcfs_clone() as wrapper around lxcfs_raw_clone()

.travis.yml
src/bindings.h
src/lxcfs.c
src/proc_fuse.c

index 1425555b124fd38a0c2b6324b384d60afff51818..234edb2d95bd12382d252839e442f1ea0d7389db 100644 (file)
@@ -22,7 +22,7 @@ before_install:
 
 script:
  - ./bootstrap.sh
- - ./configure --prefix=/usr
+ - CFLAGS='-g -O0 -std=c11 -DDEBUG -DVERBOSE -DRESOLVE_NOW -Wall -Werror' ./configure --prefix=/usr
  - make -j4
  - (cd tests && make tests)
  - echo 1 | sudo tee /sys/fs/cgroup/cpuset/cgroup.clone_children || true
index 4ab4f721aa8d06f85199baf4cb5abf5729dc0b42..e26090296e22a87be3c4eceda935caf359e7ce5a 100644 (file)
@@ -104,6 +104,20 @@ static inline int install_signal_handler(int signo,
        return sigaction(signo, &action, NULL);
 }
 
-extern pid_t lxcfs_clone(int (*fn)(void *), void *arg, int flags);
+extern pid_t lxcfs_raw_clone(unsigned long flags, int *pidfd);
+
+static inline pid_t lxcfs_clone(int (*fn)(void *), void *arg, int flags)
+{
+       pid_t pid;
+
+       pid = lxcfs_raw_clone(flags, NULL);
+       if (pid < 0)
+               return -1;
+
+       if (pid == 0)
+               _exit(fn(arg));
+
+       return pid;
+}
 
 #endif /* __LXCFS_BINDINGS_H */
index a6b458371ba8299c6a8a7414aebb95d2e9874e44..94256d43acb173bd295ee7e3e934a960ffa9f039 100644 (file)
@@ -127,7 +127,11 @@ static void do_reload(void)
        }
 
        /* First try loading using ld.so */
+#ifdef RESOLVE_NOW
+       dlopen_handle = dlopen("liblxcfs.so", RTLD_NOW);
+#else
        dlopen_handle = dlopen("liblxcfs.so", RTLD_LAZY);
+#endif
        if (dlopen_handle) {
                lxcfs_debug("Opened liblxcfs.so");
                goto good;
index 21bed1edca16cde99ff680473cb50a80b0c94880..a99162c31afee5d8bb667575cae295223e517d74 100644 (file)
@@ -244,8 +244,7 @@ static inline bool startswith(const char *line, const char *pref)
 static int proc_swaps_read(char *buf, size_t size, off_t offset,
                           struct fuse_file_info *fi)
 {
-       __do_free char *cgroup = NULL, *memswlimit_str = NULL, *memusage_str = NULL,
-                      *memswusage_str = NULL;
+       __do_free char *cgroup = NULL, *memusage_str = NULL, *memswusage_str = NULL;
        struct fuse_context *fc = fuse_get_context();
        struct lxcfs_opts *opts = (struct lxcfs_opts *)fuse_get_context()->private_data;
        bool wants_swap = opts && !opts->swap_off && liblxcfs_can_use_swap();