OpenZFS restructuring - libspl

Factor Linux specific pieces out of libspl.

Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Sean Eric Fagan <sef@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Matt Macy <mmacy@FreeBSD.org>
Closes #9336
This commit is contained in:
Matthew Macy
2019-10-02 10:39:48 -07:00
committed by Brian Behlendorf
parent 6360e2779e
commit d31277abb1
65 changed files with 127 additions and 443 deletions
+7 -6
View File
@@ -7,9 +7,6 @@ VPATH = \
SUBDIRS = include $(TARGET_ASM_DIR)
DIST_SUBDIRS = include asm-generic asm-i386 asm-x86_64
DEFAULT_INCLUDES += \
-I$(top_srcdir)/lib/libspl/include
AM_CFLAGS += $(LIBTIRPC_CFLAGS)
AM_CCASFLAGS = \
@@ -18,9 +15,6 @@ AM_CCASFLAGS = \
noinst_LTLIBRARIES = libspl.la
USER_C = \
getexecname.c \
gethostid.c \
getmntany.c \
list.c \
mkdirp.c \
page.c \
@@ -31,6 +25,13 @@ USER_C = \
include/sys/list.h \
include/sys/list_impl.h
if BUILD_LINUX
USER_C += \
os/linux/getexecname.c \
os/linux/gethostid.c \
os/linux/getmntany.c
endif
USER_ASM = atomic.S
nodist_libspl_la_SOURCES = \
-3
View File
@@ -1,8 +1,5 @@
include $(top_srcdir)/config/Rules.am
DEFAULT_INCLUDES += \
-I$(top_srcdir)/lib/libspl/include
atomic_SOURCE = atomic.c
atomic_ASM = atomic.S
+1 -2
View File
@@ -1,10 +1,9 @@
SUBDIRS = ia32 rpc sys util
SUBDIRS = ia32 rpc sys util os
libspldir = $(includedir)/libspl
libspl_HEADERS = \
$(top_srcdir)/lib/libspl/include/assert.h \
$(top_srcdir)/lib/libspl/include/atomic.h \
$(top_srcdir)/lib/libspl/include/devid.h \
$(top_srcdir)/lib/libspl/include/libdevinfo.h \
$(top_srcdir)/lib/libspl/include/libgen.h \
$(top_srcdir)/lib/libspl/include/libshare.h \
-32
View File
@@ -1,32 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _LIBSPL_DEVID_H
#define _LIBSPL_DEVID_H
#include <sys/types.h>
#endif
+3
View File
@@ -0,0 +1,3 @@
if BUILD_LINUX
SUBDIRS = linux
endif
+1
View File
@@ -0,0 +1 @@
SUBDIRS = sys
@@ -0,0 +1,10 @@
libspldir = $(includedir)/libspl/sys
libspl_HEADERS = \
$(top_srcdir)/lib/libspl/include/os/linux/sys/byteorder.h \
$(top_srcdir)/lib/libspl/include/os/linux/sys/file.h \
$(top_srcdir)/lib/libspl/include/os/linux/sys/mnttab.h \
$(top_srcdir)/lib/libspl/include/os/linux/sys/mount.h \
$(top_srcdir)/lib/libspl/include/os/linux/sys/param.h \
$(top_srcdir)/lib/libspl/include/os/linux/sys/stat.h \
$(top_srcdir)/lib/libspl/include/os/linux/sys/sysmacros.h \
$(top_srcdir)/lib/libspl/include/os/linux/sys/uio.h
@@ -67,10 +67,13 @@ struct extmnttab {
uint_t mnt_minor;
};
struct stat64;
struct statfs;
extern int getmntany(FILE *fp, struct mnttab *mp, struct mnttab *mpref);
extern int _sol_getmntent(FILE *fp, struct mnttab *mp);
extern int getextmntent(FILE *fp, struct extmnttab *mp, int len);
extern int getextmntent(const char *path, struct extmnttab *mp,
struct stat64 *statbuf);
static inline char *_sol_hasmntopt(struct mnttab *mnt, char *opt)
{
struct mntent mnt_new;
@@ -40,8 +40,10 @@
#ifndef _LIBSPL_SYS_UIO_H
#define _LIBSPL_SYS_UIO_H
#include <sys/types.h>
#include_next <sys/uio.h>
#include <stdint.h>
typedef struct iovec iovec_t;
typedef enum uio_rw {
@@ -58,11 +60,11 @@ typedef enum uio_seg {
typedef struct uio {
struct iovec *uio_iov; /* pointer to array of iovecs */
int uio_iovcnt; /* number of iovecs */
offset_t uio_loffset; /* file offset */
loff_t uio_loffset; /* file offset */
uio_seg_t uio_segflg; /* address space (kernel or user) */
uint16_t uio_fmode; /* file mode flags */
uint16_t uio_extflg; /* extended flags */
offset_t uio_limit; /* u-limit (maximum byte offset) */
loff_t uio_limit; /* u-limit (maximum byte offset) */
ssize_t uio_resid; /* residual count */
} uio_t;
-9
View File
@@ -5,7 +5,6 @@ libspl_HEADERS = \
$(top_srcdir)/lib/libspl/include/sys/acl.h \
$(top_srcdir)/lib/libspl/include/sys/acl_impl.h \
$(top_srcdir)/lib/libspl/include/sys/bitmap.h \
$(top_srcdir)/lib/libspl/include/sys/byteorder.h \
$(top_srcdir)/lib/libspl/include/sys/callb.h \
$(top_srcdir)/lib/libspl/include/sys/cmn_err.h \
$(top_srcdir)/lib/libspl/include/sys/cred.h \
@@ -14,7 +13,6 @@ libspl_HEADERS = \
$(top_srcdir)/lib/libspl/include/sys/dklabel.h \
$(top_srcdir)/lib/libspl/include/sys/errno.h \
$(top_srcdir)/lib/libspl/include/sys/feature_tests.h \
$(top_srcdir)/lib/libspl/include/sys/file.h \
$(top_srcdir)/lib/libspl/include/sys/int_limits.h \
$(top_srcdir)/lib/libspl/include/sys/int_types.h \
$(top_srcdir)/lib/libspl/include/sys/inttypes.h \
@@ -25,29 +23,22 @@ libspl_HEADERS = \
$(top_srcdir)/lib/libspl/include/sys/list_impl.h \
$(top_srcdir)/lib/libspl/include/sys/mhd.h \
$(top_srcdir)/lib/libspl/include/sys/mkdev.h \
$(top_srcdir)/lib/libspl/include/sys/mnttab.h \
$(top_srcdir)/lib/libspl/include/sys/mount.h \
$(top_srcdir)/lib/libspl/include/sys/param.h \
$(top_srcdir)/lib/libspl/include/sys/policy.h \
$(top_srcdir)/lib/libspl/include/sys/poll.h \
$(top_srcdir)/lib/libspl/include/sys/priv.h \
$(top_srcdir)/lib/libspl/include/sys/processor.h \
$(top_srcdir)/lib/libspl/include/sys/signal.h \
$(top_srcdir)/lib/libspl/include/sys/simd.h \
$(top_srcdir)/lib/libspl/include/sys/stack.h \
$(top_srcdir)/lib/libspl/include/sys/stat.h \
$(top_srcdir)/lib/libspl/include/sys/stdtypes.h \
$(top_srcdir)/lib/libspl/include/sys/strings.h \
$(top_srcdir)/lib/libspl/include/sys/stropts.h \
$(top_srcdir)/lib/libspl/include/sys/sunddi.h \
$(top_srcdir)/lib/libspl/include/sys/sysmacros.h \
$(top_srcdir)/lib/libspl/include/sys/systeminfo.h \
$(top_srcdir)/lib/libspl/include/sys/time.h \
$(top_srcdir)/lib/libspl/include/sys/trace_defs.h \
$(top_srcdir)/lib/libspl/include/sys/types32.h \
$(top_srcdir)/lib/libspl/include/sys/types.h \
$(top_srcdir)/lib/libspl/include/sys/tzfile.h \
$(top_srcdir)/lib/libspl/include/sys/uio.h \
$(top_srcdir)/lib/libspl/include/sys/va_list.h \
$(top_srcdir)/lib/libspl/include/sys/varargs.h \
$(top_srcdir)/lib/libspl/include/sys/vnode.h \
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <string.h>
#include <mntent.h>
#include <sys/errno.h>
#include <sys/mnttab.h>
#include <sys/types.h>
@@ -81,8 +82,8 @@ _sol_getmntent(FILE *fp, struct mnttab *mgetp)
return (MNT_TOOLONG);
}
int
getextmntent(FILE *fp, struct extmnttab *mp, int len)
static int
getextmntent_impl(FILE *fp, struct extmnttab *mp, int len)
{
int ret;
struct stat64 st;
@@ -100,3 +101,65 @@ getextmntent(FILE *fp, struct extmnttab *mp, int len)
return (ret);
}
int
getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
{
struct stat64 st;
FILE *fp;
int match;
if (strlen(path) >= MAXPATHLEN) {
(void) fprintf(stderr, "invalid object; pathname too long\n");
return (-1);
}
/*
* Search for the path in /proc/self/mounts. Rather than looking for the
* specific path, which can be fooled by non-standard paths (i.e. ".."
* or "//"), we stat() the path and search for the corresponding
* (major,minor) device pair.
*/
if (stat64(path, statbuf) != 0) {
(void) fprintf(stderr, "cannot open '%s': %s\n",
path, strerror(errno));
return (-1);
}
#ifdef HAVE_SETMNTENT
if ((fp = setmntent(MNTTAB, "r")) == NULL) {
#else
if ((fp = fopen(MNTTAB, "r")) == NULL) {
#endif
(void) fprintf(stderr, "cannot open %s\n", MNTTAB);
return (-1);
}
/*
* Search for the given (major,minor) pair in the mount table.
*/
match = 0;
while (getextmntent_impl(fp, entry, sizeof (*entry)) == 0) {
if (makedev(entry->mnt_major, entry->mnt_minor) ==
statbuf->st_dev) {
match = 1;
break;
}
}
if (!match) {
(void) fprintf(stderr, "cannot find mountpoint for '%s'\n",
path);
return (-1);
}
if (stat64(entry->mnt_mountp, &st) != 0) {
entry->mnt_major = 0;
entry->mnt_minor = 0;
return (-1);
}
return (0);
}