Skip to content

Commit aa78175

Browse files
authored
Merge pull request openzfs#80 from ctuffli/linux-build
Fix build on Linux
2 parents 5b6b257 + 38cc9db commit aa78175

File tree

12 files changed

+38
-25
lines changed

12 files changed

+38
-25
lines changed
File renamed without changes.

config/kernel.m4

+2-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ AC_DEFUN([ZFS_AC_KERNEL], [
223223
224224
AC_MSG_CHECKING([kernel source directory])
225225
AS_IF([test -z "$kernelsrc"], [
226-
AS_IF([BUILD_FREEBSD], [
226+
AS_IF([test "$BUILD_FREEBSD"], [
227227
sourcelink="/usr/src/sys"
228228
], [test -e "/lib/modules/$(uname -r)/source"], [
229229
headersdir="/lib/modules/$(uname -r)/source"
@@ -260,7 +260,7 @@ AC_DEFUN([ZFS_AC_KERNEL], [
260260
261261
AC_MSG_CHECKING([kernel build directory])
262262
AS_IF([test -z "$kernelbuild"], [
263-
AS_IF([BUILD_FREEBSD], [
263+
AS_IF([test "$BUILD_FREEBSD"], [
264264
kernelbuild="/usr/obj/${kernelsrc}"
265265
], [test x$withlinux != xyes -a -e "/lib/modules/$(uname -r)/build"], [
266266
kernelbuild=`readlink -f /lib/modules/$(uname -r)/build`

configure.ac

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ ZFS_AC_DEBUG_KMEM_TRACKING
6565
AM_COND_IF([BUILD_LINUX], [AC_CONFIG_FILES([
6666
udev/Makefile
6767
udev/rules.d/Makefile
68+
include/spl/Makefile
69+
include/spl/sys/Makefile
6870
include/linux/Makefile
6971
etc/systemd/Makefile
7072
etc/systemd/system/Makefile

include/sys/fs/zfs.h

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ typedef enum {
117117
ZFS_PROP_READONLY,
118118
ZFS_PROP_ZONED,
119119
ZFS_PROP_SNAPDIR,
120+
ZFS_PROP_PRIVATE, /* not exposed to the user, temporary */
120121
ZFS_PROP_ACLMODE,
121122
ZFS_PROP_ACLINHERIT,
122123
ZFS_PROP_CREATETXG,

lib/Makefile.am

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# NB: GNU Automake Manual, Chapter 8.3.5: Libtool Convenience Libraries
22
# These six libraries are intermediary build components.
3-
SUBDIRS = libavl libicp libshare libspl libtpool libzutil libunicode
3+
SUBDIRS = libavl libicp libshare libspl libtpool
44

55
if BUILD_LINUX
66
SUBDIRS+= libefi
77
endif
88

9+
# libzutil depends on libefi if present
10+
SUBDIRS+= libzutil libunicode
11+
912
# These four libraries, which are installed as the final build product,
1013
# incorporate the six convenience libraries given above.
1114
SUBDIRS += libuutil libnvpair libzpool libzfs_core libzfs

lib/libspl/linux_getmntany.c

+13-11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <stdio.h>
3232
#include <string.h>
3333
#include <mntent.h>
34+
#include <sys/errno.h>
3435
#include <sys/mnttab.h>
3536

3637
#include <sys/types.h>
@@ -82,7 +83,7 @@ _sol_getmntent(FILE *fp, struct mnttab *mgetp)
8283
}
8384

8485
static int
85-
_linux_getextmntent(FILE *fp, struct extmnttab *mp, int len)
86+
linux_getextmntent(FILE *fp, struct extmnttab *mp, int len)
8687
{
8788
int ret;
8889
struct stat64 st;
@@ -104,10 +105,11 @@ _linux_getextmntent(FILE *fp, struct extmnttab *mp, int len)
104105
int
105106
getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
106107
{
107-
int ret;
108108
struct stat64 st;
109+
FILE *fp;
110+
int match;
109111

110-
if (strlen(fullpath) >= MAXPATHLEN) {
112+
if (strlen(path) >= MAXPATHLEN) {
111113
(void) fprintf(stderr, "invalid object; pathname too long\n");
112114
return (-1);
113115
}
@@ -118,9 +120,9 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
118120
* or "//"), we stat() the path and search for the corresponding
119121
* (major,minor) device pair.
120122
*/
121-
if (stat64(fullpath, statbuf) != 0) {
123+
if (stat64(path, statbuf) != 0) {
122124
(void) fprintf(stderr, "cannot open '%s': %s\n",
123-
fullpath, strerror(errno));
125+
path, strerror(errno));
124126
return (-1);
125127
}
126128

@@ -139,22 +141,22 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
139141
*/
140142

141143
match = 0;
142-
while (linux_getextmntent(fp, &mp, sizeof (mp)) == 0) {
143-
if (makedev(mp.mnt_major, mp.mnt_minor) == statbuf->st_dev) {
144+
while (linux_getextmntent(fp, entry, sizeof (*entry)) == 0) {
145+
if (makedev(entry->mnt_major, entry->mnt_minor) == statbuf->st_dev) {
144146
match = 1;
145147
break;
146148
}
147149
}
148150

149151
if (!match) {
150152
(void) fprintf(stderr, "cannot find mountpoint for '%s'\n",
151-
fullpath);
153+
path);
152154
return (-1);
153155
}
154156

155-
if (stat64(mp->mnt_mountp, &st) != 0) {
156-
mp->mnt_major = 0;
157-
mp->mnt_minor = 0;
157+
if (stat64(entry->mnt_mountp, &st) != 0) {
158+
entry->mnt_major = 0;
159+
entry->mnt_minor = 0;
158160
return (-1);
159161
}
160162

lib/libzfs/libzfs_mount.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1119,10 +1119,10 @@ zfs_share_proto(zfs_handle_t *zhp, zfs_share_proto_t *proto)
11191119
char shareopts[ZFS_MAXPROPLEN];
11201120
char sourcestr[ZFS_MAXPROPLEN];
11211121
libzfs_handle_t *hdl = zhp->zfs_hdl;
1122-
sa_share_t share __unused;
1122+
sa_share_t share __attribute__((unused));
11231123
zfs_share_proto_t *curr_proto;
11241124
zprop_source_t sourcetype;
1125-
int err, ret __unused;
1125+
int err, ret __attribute__((unused));
11261126

11271127
if (!zfs_is_mountable(zhp, mountpoint, sizeof (mountpoint), NULL))
11281128
return (0);

lib/libzpool/Makefile.am

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ AM_CFLAGS += $(FRAME_LARGER_THAN)
1515

1616
AM_CFLAGS += -DLIB_ZPOOL_BUILD
1717

18+
if BUILD_LINUX
19+
# To pick up files like qat.h
20+
AM_CFLAGS += -I$(top_srcdir)/module/os/linux/zfs
21+
endif
22+
1823
DEFAULT_INCLUDES += \
1924
-I$(top_srcdir)/include \
2025
-I$(top_srcdir)/lib/libspl/include

lib/libzutil/Makefile.am

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ include $(top_srcdir)/config/Rules.am
33
# Suppress unused but set variable warnings often due to ASSERTs
44
AM_CFLAGS += $(NO_UNUSED_BUT_SET_VARIABLE)
55

6+
AM_CFLAGS += -DLIBZUTIL_PRIVATE
7+
68
DEFAULT_INCLUDES += \
79
-I$(top_srcdir)/include \
810
-I$(top_srcdir)/lib/libspl/include
@@ -19,8 +21,6 @@ if BUILD_FREEBSD
1921
USER_C += \
2022
freebsd_mnttab.c \
2123
freebsd_zutil_import.c
22-
23-
AM_CFLAGS += -DLIBZUTIL_PRIVATE
2424
endif
2525

2626
nodist_libzutil_la_SOURCES = $(USER_C)

lib/libzutil/zutil_device_path.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ zfs_dev_is_dm(const char *dev_name)
307307
int
308308
zfs_dev_is_whole_disk(const char *dev_name)
309309
{
310-
struct dk_gpt *label __unused;
310+
struct dk_gpt *label __attribute__((unused));
311311
int fd;
312312

313313
if ((fd = open(dev_name, O_RDONLY | O_DIRECT)) < 0)

lib/libzutil/zutil_import.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,7 @@ zpool_find_import_scan(libpc_handle_t *hdl, pthread_mutex_t *lock,
18931893
return (error);
18941894
}
18951895

1896-
static char *
1896+
char *
18971897
zpool_default_import_path[DEFAULT_IMPORT_PATH_SIZE] = {
18981898
"/dev/disk/by-vdev", /* Custom rules, use first if they exist */
18991899
"/dev/mapper", /* Use multipath devices before components */

module/zcommon/zfs_prop.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ typedef void *(*parse_url_t)(const char *);
5050
#endif
5151
#endif
5252

53-
int zcommon_init(void);
54-
void zcommon_fini(void);
55-
5653
static zprop_desc_t zfs_prop_table[ZFS_NUM_PROPS];
5754

5855
/* Note this is indexed by zfs_userquota_prop_t, keep the order the same */
@@ -885,6 +882,7 @@ zfs_prop_align_right(zfs_prop_t prop)
885882

886883
#endif
887884

885+
#if defined(_KERNEL)
888886
int __init
889887
zcommon_init(void)
890888
{
@@ -898,7 +896,7 @@ zcommon_fini(void)
898896
fletcher_4_fini();
899897
}
900898

901-
#if defined(_KERNEL) && defined(__linux__)
899+
#if defined(__linux__)
902900
module_init(zcommon_init);
903901
module_exit(zcommon_fini);
904902

@@ -932,4 +930,6 @@ EXPORT_SYMBOL(zfs_prop_string_to_index);
932930
EXPORT_SYMBOL(zfs_prop_valid_for_type);
933931
EXPORT_SYMBOL(zfs_prop_written);
934932

935-
#endif
933+
#endif /* __linux__ */
934+
935+
#endif /* _KERNEL */

0 commit comments

Comments
 (0)