Skip to content

Commit

Permalink
Merge pull request #487 from brauner/2021-10-14.fixes
Browse files Browse the repository at this point in the history
tree-wide: build fixes
  • Loading branch information
stgraber authored Oct 14, 2021
2 parents f4ee7eb + 71c055b commit d7195f5
Show file tree
Hide file tree
Showing 34 changed files with 57 additions and 185 deletions.
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ foreach ident : [
conf.set10('HAVE_' + ident[0].to_upper(), have)
endforeach

conf.set('_GNU_SOURCE', true)
conf.set('_FILE_OFFSET_BITS', 64)
conf.set('__STDC_FORMAT_MACROS', true)

libfuse = dependency('fuse3', required : false)
if libfuse.found()
Expand Down
4 changes: 2 additions & 2 deletions src/api_extensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#ifndef __LXCFS_API_EXTENSIONS_H
#define __LXCFS_API_EXTENSIONS_H

#include "config.h"

#include <stdio.h>
#include <stdlib.h>

#include "config.h"

/*
* api_extensions is the list of all API extensions in the order they were
* added.
Expand Down
4 changes: 0 additions & 4 deletions src/bindings.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include "config.h"

#include <dirent.h>
Expand Down
6 changes: 1 addition & 5 deletions src/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
#include <sys/types.h>
#include <unistd.h>

#if HAVE_FUSE3
#include <fuse3/fuse.h>
#else
#include <fuse.h>
#endif
#include "lxcfs_fuse.h"

#include "cgroup_fuse.h"
#include "macro.h"
Expand Down
5 changes: 0 additions & 5 deletions src/cgroup_fuse.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1+ */

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include "config.h"

#define __STDC_FORMAT_MACROS
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
Expand Down
6 changes: 1 addition & 5 deletions src/cgroup_fuse.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@
#include <sys/types.h>
#include <unistd.h>

#if HAVE_FUSE3
#include <fuse3/fuse.h>
#else
#include <fuse.h>
#endif
#include "lxcfs_fuse.h"

#include "macro.h"

Expand Down
4 changes: 0 additions & 4 deletions src/cgroups/cgfsng.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
* a comma-separated list of controllers.
*/

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include "config.h"

#include <ctype.h>
Expand Down
4 changes: 0 additions & 4 deletions src/cgroups/cgroup.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include "config.h"

#include <dirent.h>
Expand Down
11 changes: 1 addition & 10 deletions src/cgroups/cgroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@
#ifndef __LXC_CGROUP_H
#define __LXC_CGROUP_H

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif

#define _FILE_OFFSET_BITS 64
#include "config.h"

#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <sys/types.h>

#include "../config.h"
#include "../macro.h"
#include "../memory_utils.h"

Expand Down
4 changes: 0 additions & 4 deletions src/cgroups/cgroup2_devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

/* Parts of this taken from systemd's implementation. */

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include "config.h"

#include <errno.h>
Expand Down
10 changes: 1 addition & 9 deletions src/cgroups/cgroup2_devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,7 @@
#ifndef __LXC_CGROUP2_DEVICES_H
#define __LXC_CGROUP2_DEVICES_H

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif

#define _FILE_OFFSET_BITS 64
#include "config.h"

#include <errno.h>
#include <fcntl.h>
Expand Down
4 changes: 0 additions & 4 deletions src/cgroups/cgroup_utils.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include "config.h"

#include <fcntl.h>
Expand Down
11 changes: 1 addition & 10 deletions src/cgroups/cgroup_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@
#ifndef __LXC_CGROUP_UTILS_H
#define __LXC_CGROUP_UTILS_H

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif

#define _FILE_OFFSET_BITS 64
#include "config.h"

#include <fcntl.h>
#include <stdarg.h>
Expand All @@ -25,7 +17,6 @@
#include <sys/vfs.h>
#include <unistd.h>

#include "../config.h"
#include "../macro.h"
#include "../memory_utils.h"

Expand Down
8 changes: 0 additions & 8 deletions src/cpuset_parse.c
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1+ */

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include "config.h"

#define _FILE_OFFSET_BITS 64

#define __STDC_FORMAT_MACROS

#include <stdio.h>
#include <string.h>
#include <stdbool.h>
Expand Down
6 changes: 1 addition & 5 deletions src/cpuset_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
#ifndef __LXCFS_CPUSET_PARSE_H
#define __LXCFS_CPUSET_PARSE_H

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#define _FILE_OFFSET_BITS 64
#include "config.h"

#include <stdbool.h>
#include <stdio.h>
Expand Down
34 changes: 13 additions & 21 deletions src/lxcfs.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1+ */

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include "config.h"

#include <alloca.h>
Expand All @@ -28,11 +24,7 @@
#include <sys/socket.h>
#include <linux/limits.h>

#if HAVE_FUSE3
#include <fuse3/fuse.h>
#else
#include <fuse.h>
#endif
#include "lxcfs_fuse.h"

#include "bindings.h"
#include "lxcfs_fuse_compat.h"
Expand Down Expand Up @@ -607,7 +599,7 @@ static int do_sys_releasedir(const char *path, struct fuse_file_info *fi)
return __sys_releasedir(path, fi);
}

#ifdef HAVE_FUSE3
#if HAVE_FUSE3
static int lxcfs_getattr(const char *path, struct stat *sb, struct fuse_file_info *fi)
#else
static int lxcfs_getattr(const char *path, struct stat *sb)
Expand Down Expand Up @@ -678,7 +670,7 @@ static int lxcfs_opendir(const char *path, struct fuse_file_info *fi)
return -ENOENT;
}

#ifdef HAVE_FUSE3
#if HAVE_FUSE3
static int lxcfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *fi, enum fuse_readdir_flags flags)
#else
Expand Down Expand Up @@ -926,7 +918,7 @@ int lxcfs_mkdir(const char *path, mode_t mode)
return -EPERM;
}

#ifdef HAVE_FUSE3
#if HAVE_FUSE3
int lxcfs_chown(const char *path, uid_t uid, gid_t gid, struct fuse_file_info *fi)
#else
int lxcfs_chown(const char *path, uid_t uid, gid_t gid)
Expand Down Expand Up @@ -955,7 +947,7 @@ int lxcfs_chown(const char *path, uid_t uid, gid_t gid)
* really make sense for cgroups. So just return 0 always but do
* nothing.
*/
#ifdef HAVE_FUSE3
#if HAVE_FUSE3
int lxcfs_truncate(const char *path, off_t newsize, struct fuse_file_info *fi)
#else
int lxcfs_truncate(const char *path, off_t newsize)
Expand Down Expand Up @@ -984,7 +976,7 @@ int lxcfs_rmdir(const char *path)
return -EPERM;
}

#ifdef HAVE_FUSE3
#if HAVE_FUSE3
int lxcfs_chmod(const char *path, mode_t mode, struct fuse_file_info *fi)
#else
int lxcfs_chmod(const char *path, mode_t mode)
Expand All @@ -1008,7 +1000,7 @@ int lxcfs_chmod(const char *path, mode_t mode)
return -ENOENT;
}

#ifdef HAVE_FUSE3
#if HAVE_FUSE3
static void *lxcfs_init(struct fuse_conn_info *conn, struct fuse_config *cfg)
#else
static void *lxcfs_init(struct fuse_conn_info *conn)
Expand Down Expand Up @@ -1048,11 +1040,11 @@ const struct fuse_operations lxcfs_ops = {

.create = NULL,
.destroy = NULL,
#ifndef HAVE_FUSE3
#if !HAVE_FUSE3
.fgetattr = NULL,
#endif
.fsyncdir = NULL,
#ifndef HAVE_FUSE3
#if !HAVE_FUSE3
.ftruncate = NULL,
.getdir = NULL,
#endif
Expand All @@ -1066,7 +1058,7 @@ const struct fuse_operations lxcfs_ops = {
.statfs = NULL,
.symlink = NULL,
.unlink = NULL,
#ifndef HAVE_FUSE3
#if !HAVE_FUSE3
.utime = NULL,
#endif
};
Expand Down Expand Up @@ -1181,7 +1173,7 @@ int main(int argc, char *argv[])
char *pidfile = NULL, *token = NULL;
char pidfile_buf[STRLITERALLEN(RUNTIME_PATH) + STRLITERALLEN("/lxcfs.pid") + 1] = {};
bool debug = false, foreground = false;
#ifndef HAVE_FUSE3
#if !HAVE_FUSE3
bool nonempty = false;
#endif
bool load_use = false;
Expand Down Expand Up @@ -1307,7 +1299,7 @@ int main(int argc, char *argv[])

/* default with fuse3 */
if (strcmp(token, "nonempty") == 0) {
#ifndef HAVE_FUSE3
#if !HAVE_FUSE3
nonempty = true;
#endif
continue;
Expand All @@ -1327,7 +1319,7 @@ int main(int argc, char *argv[])
goto out;
}

#ifndef HAVE_FUSE3
#if !HAVE_FUSE3
if (nonempty) {
if (append_comma_separate(&new_fuse_opts, "nonempty")) {
lxcfs_error("Failed to copy fuse argument \"nonempty\"");
Expand Down
16 changes: 16 additions & 0 deletions src/lxcfs_fuse.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* SPDX-License-Identifier: LGPL-2.1+ */

#ifndef __LXCFS_FUSE_H
#define __LXCFS_FUSE_H

#include "config.h"

#include "lxcfs_fuse_compat.h"

#if HAVE_FUSE3
#include <fuse3/fuse.h>
#else
#include <fuse.h>
#endif

#endif /* __LXCFS_FUSE_H */
7 changes: 3 additions & 4 deletions src/lxcfs_fuse_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
#ifndef __LXCFS_FUSE_COMPAT_H
#define __LXCFS_FUSE_COMPAT_H

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "config.h"

#ifdef HAVE_FUSE3
#if HAVE_FUSE3
#define DIR_FILLER(F,B,N,S,O) F(B,N,S,O,FUSE_FILL_DIR_PLUS)
#else
#define DIR_FILLER(F,B,N,S,O) F(B,N,S,O)
#endif

#endif /* __LXCFS_FUSE_COMPAT_H */
12 changes: 1 addition & 11 deletions src/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,10 @@
#ifndef __LXCFS_MACRO_H
#define __LXCFS_MACRO_H

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#ifndef FUSE_USE_VERSION
#define FUSE_USE_VERSION 26
#endif

#define _FILE_OFFSET_BITS 64
#include "config.h"

#include <stdio.h>

#include "config.h"

#define BATCH_SIZE 50

/* filesystem magic values */
Expand Down
Loading

0 comments on commit d7195f5

Please sign in to comment.