Sync with upstream r315983.
FreeBSD splits "zfs_context.h" into: "lib/libzpool/common/sys/zfs_context.h" for user space "uts/common/fs/zfs/sys/zfs_context.h" for kernel space Do the same here, move and sync "sys/sys/zfs_context.h" to "dist/lib/libzpool/common/sys/zfs_context.h" and "dist/uts/common/fs/zfs/sys/zfs_context.h". Change "Makefile.zfs" to search includes from "dist/lib" before "dist/uts" so we get the right include file. Adapt "usr.sbin/fstyp/Makefile" to get the right include file.
This commit is contained in:
parent
ed56fb496f
commit
1a12b22735
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile.zfs,v 1.8 2018/06/07 13:21:44 kamil Exp $
|
||||
# $NetBSD: Makefile.zfs,v 1.9 2019/06/22 09:48:39 hannken Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
|
@ -21,10 +21,6 @@ ZFSDIR= ${NETBSDSRCDIR}/external/cddl/osnet
|
|||
CPPFLAGS+= -I${ZFSDIR}
|
||||
CPPFLAGS+= -I${ZFSDIR}/include
|
||||
CPPFLAGS+= -I${ZFSDIR}/sys
|
||||
CPPFLAGS+= -I${ZFSDIR}/dist/uts/common
|
||||
CPPFLAGS+= -I${ZFSDIR}/dist/uts/common/zfs
|
||||
CPPFLAGS+= -I${ZFSDIR}/dist/uts/common/fs/zfs
|
||||
CPPFLAGS+= -I${ZFSDIR}/dist/uts/common/sys
|
||||
|
||||
CPPFLAGS+= -I${ZFSDIR}/dist/common/zfs
|
||||
CPPFLAGS+= -I${ZFSDIR}/dist/head
|
||||
|
@ -39,6 +35,11 @@ CPPFLAGS+= -I${ZFSDIR}/dist/lib/libzpool/common
|
|||
|
||||
CPPFLAGS+= -I${ZFSDIR}/dist/common
|
||||
|
||||
CPPFLAGS+= -I${ZFSDIR}/dist/uts/common
|
||||
CPPFLAGS+= -I${ZFSDIR}/dist/uts/common/zfs
|
||||
CPPFLAGS+= -I${ZFSDIR}/dist/uts/common/fs/zfs
|
||||
CPPFLAGS+= -I${ZFSDIR}/dist/uts/common/sys
|
||||
|
||||
CWARNFLAGS+= -Wno-missing-field-initializers
|
||||
CWARNFLAGS+= -Wno-strict-prototypes
|
||||
CWARNFLAGS+= -Wno-cast-qual
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
/* $NetBSD: zfs_context.h,v 1.22 2019/06/17 08:08:51 hannken Exp $ */
|
||||
|
||||
/*
|
||||
* 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.
|
||||
* Common Development and Distribution License (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.
|
||||
|
@ -22,36 +19,37 @@
|
|||
* CDDL HEADER END
|
||||
*/
|
||||
/*
|
||||
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
|
||||
* Use is subject to license terms.
|
||||
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
|
||||
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
|
||||
*/
|
||||
/*
|
||||
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SYS_ZFS_CONTEXT_H
|
||||
#define _SYS_ZFS_CONTEXT_H
|
||||
|
||||
#pragma ident "%Z%%M% %I% %E% SMI"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifndef _KERNEL
|
||||
|
||||
#define _SYS_MUTEX_H
|
||||
#define _SYS_MUTEX_H_
|
||||
#define _SYS_RWLOCK_H
|
||||
#define _SYS_RWLOCK_H_
|
||||
#define _SYS_CONDVAR_H
|
||||
#define _SYS_CONDVAR_H_
|
||||
#define _SYS_MUTEX_H
|
||||
#define _SYS_RWLOCK_H
|
||||
#define _SYS_CONDVAR_H
|
||||
#define _SYS_SYSTM_H
|
||||
#define _SYS_SYSTM_H_
|
||||
#define _SYS_T_LOCK_H
|
||||
#define _SYS_VNODE_H
|
||||
#define _SYS_VFS_H
|
||||
#define _SYS_SUNDDI_H
|
||||
#define _SYS_CALLB_H
|
||||
#ifndef __NetBSD__
|
||||
#define _SYS_SCHED_H_
|
||||
#else
|
||||
#define _SYS_CONDVAR_H_
|
||||
#define _SYS_MUTEX_H_
|
||||
#define _SYS_RWLOCK_H_
|
||||
#endif
|
||||
|
||||
#include <solaris.h>
|
||||
#include <stdio.h>
|
||||
|
@ -65,6 +63,7 @@ extern "C" {
|
|||
#include <strings.h>
|
||||
#include <thread.h>
|
||||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <time.h>
|
||||
#include <math.h>
|
||||
|
@ -72,42 +71,41 @@ extern "C" {
|
|||
#include <inttypes.h>
|
||||
#include <fsshare.h>
|
||||
#include <pthread.h>
|
||||
#include <paths.h>
|
||||
|
||||
#include <sched.h>
|
||||
#include <sys/debug.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kstat.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stdint.h>
|
||||
#include <sys/note.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/atomic.h>
|
||||
#include <sys/misc.h>
|
||||
#include <sys/sdt.h>
|
||||
#include <sys/list.h>
|
||||
#include <sys/ccompile.h>
|
||||
#include <sys/byteorder.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/cred.h>
|
||||
#include <sys/u8_textprep.h>
|
||||
#include <sys/zone.h>
|
||||
#include <sys/pathname.h>
|
||||
#include <sys/sysevent.h>
|
||||
#include <sys/atomic.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/bitmap.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/byteorder.h>
|
||||
#include <sys/list.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/mntent.h>
|
||||
#include <sys/mnttab.h>
|
||||
#include <sys/zfs_debug.h>
|
||||
#include <sys/cyclic.h>
|
||||
|
||||
extern void panic(const char *, ...);
|
||||
|
||||
#include <sys/cmn_err.h>
|
||||
|
||||
#include <sys/sdt.h>
|
||||
#include <sys/kstat.h>
|
||||
#include <sys/u8_textprep.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/disk.h>
|
||||
#include <sys/sysevent.h>
|
||||
#include <sys/sysevent/eventdefs.h>
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(a) ((a) < 0 ? -(a) : (a))
|
||||
#include <sys/sysevent/dev.h>
|
||||
#ifndef __NetBSD__
|
||||
#include <machine/atomic.h>
|
||||
#else
|
||||
#include <sys/atomic.h>
|
||||
#endif
|
||||
#include <sys/debug.h>
|
||||
#ifdef illumos
|
||||
#include "zfs.h"
|
||||
#endif
|
||||
|
||||
extern int aok;
|
||||
#define ZFS_EXPORTS_PATH "/etc/zfs/exports"
|
||||
|
||||
/*
|
||||
* Debugging
|
||||
|
@ -136,44 +134,98 @@ typedef u_longlong_t rlim64_t;
|
|||
extern void dprintf_setup(int *argc, char **argv);
|
||||
#endif /* ZFS_DEBUG */
|
||||
|
||||
/* extern void cmn_err(int, const char *, ...);
|
||||
extern void vcmn_err(int, const char *, va_list); */
|
||||
/* extern void vpanic(const char *, va_list); */
|
||||
extern void cmn_err(int, const char *, ...);
|
||||
extern void vcmn_err(int, const char *, __va_list);
|
||||
extern void panic(const char *, ...);
|
||||
extern void vpanic(const char *, __va_list);
|
||||
|
||||
#define fm_panic panic
|
||||
|
||||
extern int aok;
|
||||
|
||||
/*
|
||||
* Dtrace SDT probes have different signatures in userland than they do in
|
||||
* kernel. If they're being used in kernel code, re-define them out of
|
||||
* DTrace SDT probes have different signatures in userland than they do in
|
||||
* the kernel. If they're being used in kernel code, re-define them out of
|
||||
* existence for their counterparts in libzpool.
|
||||
*
|
||||
* Here's an example of how to use the set-error probes in userland:
|
||||
* zfs$target:::set-error /arg0 == EBUSY/ {stack();}
|
||||
*
|
||||
* Here's an example of how to use DTRACE_PROBE probes in userland:
|
||||
* If there is a probe declared as follows:
|
||||
* DTRACE_PROBE2(zfs__probe_name, uint64_t, blkid, dnode_t *, dn);
|
||||
* Then you can use it as follows:
|
||||
* zfs$target:::probe2 /copyinstr(arg0) == "zfs__probe_name"/
|
||||
* {printf("%u %p\n", arg1, arg2);}
|
||||
*/
|
||||
|
||||
#ifdef DTRACE_PROBE
|
||||
#undef DTRACE_PROBE
|
||||
#endif /* DTRACE_PROBE */
|
||||
#ifdef illumos
|
||||
#define DTRACE_PROBE(a) \
|
||||
ZFS_PROBE0(#a)
|
||||
#endif
|
||||
|
||||
#ifdef DTRACE_PROBE1
|
||||
#undef DTRACE_PROBE1
|
||||
#define DTRACE_PROBE1(a, b, c) ((void)0)
|
||||
#endif /* DTRACE_PROBE1 */
|
||||
#ifdef illumos
|
||||
#define DTRACE_PROBE1(a, b, c) \
|
||||
ZFS_PROBE1(#a, (unsigned long)c)
|
||||
#endif
|
||||
|
||||
#ifdef DTRACE_PROBE2
|
||||
#undef DTRACE_PROBE2
|
||||
#define DTRACE_PROBE2(a, b, c, d, e) ((void)0)
|
||||
#endif /* DTRACE_PROBE2 */
|
||||
#ifdef illumos
|
||||
#define DTRACE_PROBE2(a, b, c, d, e) \
|
||||
ZFS_PROBE2(#a, (unsigned long)c, (unsigned long)e)
|
||||
#endif
|
||||
|
||||
#ifdef DTRACE_PROBE3
|
||||
#undef DTRACE_PROBE3
|
||||
#define DTRACE_PROBE3(a, b, c, d, e, f, g) ((void)0)
|
||||
#endif /* DTRACE_PROBE3 */
|
||||
#ifdef illumos
|
||||
#define DTRACE_PROBE3(a, b, c, d, e, f, g) \
|
||||
ZFS_PROBE3(#a, (unsigned long)c, (unsigned long)e, (unsigned long)g)
|
||||
#endif
|
||||
|
||||
#ifdef DTRACE_PROBE4
|
||||
#undef DTRACE_PROBE4
|
||||
#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) ((void)0)
|
||||
#endif /* DTRACE_PROBE4 */
|
||||
#ifdef illumos
|
||||
#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) \
|
||||
ZFS_PROBE4(#a, (unsigned long)c, (unsigned long)e, (unsigned long)g, \
|
||||
(unsigned long)i)
|
||||
#endif
|
||||
|
||||
#ifdef illumos
|
||||
/*
|
||||
* We use the comma operator so that this macro can be used without much
|
||||
* additional code. For example, "return (EINVAL);" becomes
|
||||
* "return (SET_ERROR(EINVAL));". Note that the argument will be evaluated
|
||||
* twice, so it should not have side effects (e.g. something like:
|
||||
* "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice).
|
||||
*/
|
||||
#define SET_ERROR(err) (ZFS_SET_ERROR(err), err)
|
||||
#else /* !illumos */
|
||||
|
||||
#define DTRACE_PROBE(a) ((void)0)
|
||||
#define DTRACE_PROBE1(a, b, c) ((void)0)
|
||||
#define DTRACE_PROBE2(a, b, c, d, e) ((void)0)
|
||||
#define DTRACE_PROBE3(a, b, c, d, e, f, g) ((void)0)
|
||||
#define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) ((void)0)
|
||||
|
||||
#define SET_ERROR(err) (err)
|
||||
#endif /* !illumos */
|
||||
|
||||
/*
|
||||
* Threads
|
||||
*/
|
||||
#define curthread ((void *)(uintptr_t)thr_self())
|
||||
|
||||
#define kpreempt(x) yield()
|
||||
#define kpreempt(x) sched_yield()
|
||||
|
||||
typedef struct kthread kthread_t;
|
||||
|
||||
|
@ -202,7 +254,6 @@ extern kthread_t *zk_thread_create(void (*func)(), void *arg);
|
|||
/*
|
||||
* Mutexes
|
||||
*/
|
||||
|
||||
typedef struct kmutex {
|
||||
void *m_owner;
|
||||
boolean_t initialized;
|
||||
|
@ -226,14 +277,13 @@ typedef struct kmutex {
|
|||
|
||||
#define mutex_init(mp, b, c, d) zmutex_init((kmutex_t *)(mp))
|
||||
#define mutex_destroy(mp) zmutex_destroy((kmutex_t *)(mp))
|
||||
#define mutex_enter(mp) zmutex_enter(mp)
|
||||
#define mutex_exit(mp) zmutex_exit(mp)
|
||||
#define mutex_owned(mp) zmutex_owned((kmutex_t *)(mp))
|
||||
|
||||
extern void zmutex_init(kmutex_t *mp);
|
||||
extern void zmutex_destroy(kmutex_t *mp);
|
||||
extern void zmutex_enter(kmutex_t *mp);
|
||||
extern void zmutex_exit(kmutex_t *mp);
|
||||
extern int zmutex_owned(kmutex_t *mp);
|
||||
extern void mutex_enter(kmutex_t *mp);
|
||||
extern void mutex_exit(kmutex_t *mp);
|
||||
extern int mutex_tryenter(kmutex_t *mp);
|
||||
extern void *mutex_owner(kmutex_t *mp);
|
||||
|
||||
|
@ -241,7 +291,7 @@ extern void *mutex_owner(kmutex_t *mp);
|
|||
* RW locks
|
||||
*/
|
||||
typedef struct krwlock {
|
||||
int rw_count;
|
||||
int rw_count;
|
||||
void *rw_owner;
|
||||
boolean_t initialized;
|
||||
rwlock_t rw_lock;
|
||||
|
@ -253,15 +303,12 @@ typedef int krw_t;
|
|||
#define RW_WRITER 1
|
||||
#define RW_DEFAULT USYNC_THREAD
|
||||
|
||||
#define RW_LOCK_HELD(x) rw_lock_held(x)
|
||||
#define RW_WRITE_HELD(x) rw_write_held(x)
|
||||
#define RW_READ_HELD(x) rw_read_held(x)
|
||||
|
||||
#undef RW_READ_HELD
|
||||
#define RW_READ_HELD(x) ((x)->rw_owner == NULL && (x)->rw_count > 0)
|
||||
|
||||
#undef RW_WRITE_HELD
|
||||
#define RW_WRITE_HELD(x) ((x)->rw_owner == curthread)
|
||||
#define RW_LOCK_HELD(x) rw_lock_held(x)
|
||||
|
||||
#undef RW_LOCK_HELD
|
||||
#define RW_LOCK_HELD(x) (RW_READ_HELD(x) || RW_WRITE_HELD(x))
|
||||
|
@ -273,15 +320,14 @@ extern int rw_tryenter(krwlock_t *rwlp, krw_t rw);
|
|||
extern int rw_tryupgrade(krwlock_t *rwlp);
|
||||
extern void rw_exit(krwlock_t *rwlp);
|
||||
extern int rw_lock_held(krwlock_t *rwlp);
|
||||
extern int rw_write_held(krwlock_t *rwlp);
|
||||
extern int rw_read_held(krwlock_t *rwlp);
|
||||
#define rw_downgrade(rwlp) do { } while (0)
|
||||
|
||||
extern uid_t crgetuid(cred_t *cr);
|
||||
extern uid_t crgetruid(cred_t *cr);
|
||||
extern gid_t crgetgid(cred_t *cr);
|
||||
extern int crgetngroups(cred_t *cr);
|
||||
extern gid_t *crgetgroups(cred_t *cr);
|
||||
|
||||
|
||||
/*
|
||||
* Condition variables
|
||||
*/
|
||||
|
@ -319,7 +365,7 @@ extern void cv_broadcast(kcondvar_t *cv);
|
|||
#define kmem_alloc(_s, _f) umem_alloc(_s, _f)
|
||||
#define kmem_zalloc(_s, _f) umem_zalloc(_s, _f)
|
||||
#define kmem_free(_b, _s) umem_free(_b, _s)
|
||||
#define kmem_size() ((uint64_t)physmem * PAGESIZE)
|
||||
#define kmem_size() (physmem * PAGESIZE)
|
||||
#define kmem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i) \
|
||||
umem_cache_create(_a, _b, _c, _d, _e, _f, _g, _h, _i)
|
||||
#define kmem_cache_destroy(_c) umem_cache_destroy(_c)
|
||||
|
@ -328,12 +374,18 @@ extern void cv_broadcast(kcondvar_t *cv);
|
|||
#define kmem_debugging() 0
|
||||
#define kmem_cache_reap_now(_c) /* nothing */
|
||||
#define kmem_cache_set_move(_c, _cb) /* nothing */
|
||||
#define vmem_qcache_reap(_v) /* nothing */
|
||||
#define POINTER_INVALIDATE(_pp) /* nothing */
|
||||
#define POINTER_IS_VALID(_p) 0
|
||||
|
||||
typedef umem_cache_t kmem_cache_t;
|
||||
typedef struct vmem vmem_t;
|
||||
|
||||
typedef enum kmem_cbrc {
|
||||
KMEM_CBRC_YES,
|
||||
KMEM_CBRC_NO,
|
||||
KMEM_CBRC_LATER,
|
||||
KMEM_CBRC_DONT_NEED,
|
||||
KMEM_CBRC_DONT_KNOW
|
||||
} kmem_cbrc_t;
|
||||
|
||||
/*
|
||||
* Task queues
|
||||
|
@ -352,11 +404,11 @@ typedef struct taskq_ent {
|
|||
|
||||
#define TQENT_FLAG_PREALLOC 0x1 /* taskq_dispatch_ent used */
|
||||
|
||||
#define TASKQ_PREPOPULATE 0x0001
|
||||
#define TASKQ_CPR_SAFE 0x0002 /* Use CPR safe protocol */
|
||||
#define TASKQ_DYNAMIC 0x0004 /* Use dynamic thread scheduling */
|
||||
#define TASKQ_THREADS_CPU_PCT 0x0008 /* Scale # threads by # cpus */
|
||||
#define TASKQ_DC_BATCH 0x0010 /* Mark threads as batch */
|
||||
#define TASKQ_PREPOPULATE 0x0001
|
||||
#define TASKQ_CPR_SAFE 0x0002 /* Use CPR safe protocol */
|
||||
#define TASKQ_DYNAMIC 0x0004 /* Use dynamic thread scheduling */
|
||||
#define TASKQ_THREADS_CPU_PCT 0x0008 /* Scale # threads by # cpus */
|
||||
#define TASKQ_DC_BATCH 0x0010 /* Mark threads as batch */
|
||||
|
||||
#define TQ_SLEEP KM_SLEEP /* Can block for memory */
|
||||
#define TQ_NOSLEEP KM_NOSLEEP /* cannot block for memory; may fail */
|
||||
|
@ -366,17 +418,22 @@ typedef struct taskq_ent {
|
|||
|
||||
extern taskq_t *system_taskq;
|
||||
|
||||
extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t);
|
||||
#define taskq_create_proc(a, b, c, d, e, p, f) \
|
||||
(taskq_create(a, b, c, d, e, f))
|
||||
#define taskq_create_sysdc(a, b, d, e, p, dc, f) \
|
||||
(taskq_create(a, b, maxclsyspri, d, e, f))
|
||||
extern taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t);
|
||||
#define taskq_create_proc(a, b, c, d, e, p, f) \
|
||||
(taskq_create(a, b, c, d, e, f))
|
||||
#define taskq_create_sysdc(a, b, d, e, p, dc, f) \
|
||||
(taskq_create(a, b, maxclsyspri, d, e, f))
|
||||
extern taskqid_t taskq_dispatch(taskq_t *, task_func_t, void *, uint_t);
|
||||
extern void taskq_destroy(taskq_t *);
|
||||
extern void taskq_wait(taskq_t *);
|
||||
extern int taskq_member(taskq_t *, void *);
|
||||
extern void system_taskq_init(void);
|
||||
extern void system_taskq_fini(void);
|
||||
extern void taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t,
|
||||
taskq_ent_t *);
|
||||
extern void taskq_destroy(taskq_t *);
|
||||
extern void taskq_wait(taskq_t *);
|
||||
extern int taskq_member(taskq_t *, void *);
|
||||
extern void system_taskq_init(void);
|
||||
extern void system_taskq_fini(void);
|
||||
|
||||
#define taskq_dispatch_safe(tq, func, arg, flags, task) \
|
||||
taskq_dispatch((tq), (func), (arg), (flags))
|
||||
|
||||
#define XVA_MAPSIZE 3
|
||||
#define XVA_MAGIC 0x78766174
|
||||
|
@ -394,48 +451,95 @@ typedef struct vnode {
|
|||
extern char *vn_dumpdir;
|
||||
#define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */
|
||||
|
||||
typedef struct xoptattr {
|
||||
timestruc_t xoa_createtime; /* Create time of file */
|
||||
uint8_t xoa_archive;
|
||||
uint8_t xoa_system;
|
||||
uint8_t xoa_readonly;
|
||||
uint8_t xoa_hidden;
|
||||
uint8_t xoa_nounlink;
|
||||
uint8_t xoa_immutable;
|
||||
uint8_t xoa_appendonly;
|
||||
uint8_t xoa_nodump;
|
||||
uint8_t xoa_settable;
|
||||
uint8_t xoa_opaque;
|
||||
uint8_t xoa_av_quarantined;
|
||||
uint8_t xoa_av_modified;
|
||||
uint8_t xoa_av_scanstamp[AV_SCANSTAMP_SZ];
|
||||
uint8_t xoa_reparse;
|
||||
uint8_t xoa_offline;
|
||||
uint8_t xoa_sparse;
|
||||
} xoptattr_t;
|
||||
|
||||
typedef struct vattr {
|
||||
uint_t va_mask; /* bit-mask of attributes */
|
||||
u_offset_t va_size; /* file size in bytes */
|
||||
} vattr_t;
|
||||
|
||||
#define AT_TYPE 0x0001
|
||||
#define AT_MODE 0x0002
|
||||
#define AT_UID 0x0004
|
||||
#define AT_GID 0x0008
|
||||
#define AT_FSID 0x0010
|
||||
#define AT_NODEID 0x0020
|
||||
#define AT_NLINK 0x0040
|
||||
#define AT_SIZE 0x0080
|
||||
#define AT_ATIME 0x0100
|
||||
#define AT_MTIME 0x0200
|
||||
#define AT_CTIME 0x0400
|
||||
#define AT_RDEV 0x0800
|
||||
#define AT_BLKSIZE 0x1000
|
||||
#define AT_NBLOCKS 0x2000
|
||||
#define AT_SEQ 0x8000
|
||||
|
||||
typedef struct xvattr {
|
||||
vattr_t xva_vattr; /* Embedded vattr structure */
|
||||
uint32_t xva_magic; /* Magic Number */
|
||||
uint32_t xva_mapsize; /* Size of attr bitmap (32-bit words) */
|
||||
uint32_t *xva_rtnattrmapp; /* Ptr to xva_rtnattrmap[] */
|
||||
uint32_t xva_reqattrmap[XVA_MAPSIZE]; /* Requested attrs */
|
||||
uint32_t xva_rtnattrmap[XVA_MAPSIZE]; /* Returned attrs */
|
||||
xoptattr_t xva_xoptattrs; /* Optional attributes */
|
||||
} xvattr_t;
|
||||
|
||||
typedef struct vsecattr {
|
||||
uint_t vsa_mask; /* See below */
|
||||
int vsa_aclcnt; /* ACL entry count */
|
||||
void *vsa_aclentp; /* pointer to ACL entries */
|
||||
int vsa_dfaclcnt; /* default ACL entry count */
|
||||
void *vsa_dfaclentp; /* pointer to default ACL entries */
|
||||
size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */
|
||||
} vsecattr_t;
|
||||
|
||||
#define AT_TYPE 0x00001
|
||||
#define AT_MODE 0x00002
|
||||
#define AT_UID 0x00004
|
||||
#define AT_GID 0x00008
|
||||
#define AT_FSID 0x00010
|
||||
#define AT_NODEID 0x00020
|
||||
#define AT_NLINK 0x00040
|
||||
#define AT_SIZE 0x00080
|
||||
#define AT_ATIME 0x00100
|
||||
#define AT_MTIME 0x00200
|
||||
#define AT_CTIME 0x00400
|
||||
#define AT_RDEV 0x00800
|
||||
#define AT_BLKSIZE 0x01000
|
||||
#define AT_NBLOCKS 0x02000
|
||||
#define AT_SEQ 0x08000
|
||||
#define AT_XVATTR 0x10000
|
||||
|
||||
#define CRCREAT 0
|
||||
|
||||
#define VOP_CLOSE(vp, f, c, o, cr, unk) 0
|
||||
#define VOP_PUTPAGE(vp, of, sz, fl, cr, unk) 0
|
||||
#define VOP_GETATTR(vp, vap, fl, cr, unk) fop_getattr(vp, vap)
|
||||
#define VOP_FSYNC(vp, f, cr, unk) fsync((vp)->v_fd)
|
||||
extern int fop_getattr(vnode_t *vp, vattr_t *vap);
|
||||
|
||||
#define VN_RELE(vp) vn_close(vp)
|
||||
#define VN_RELE_ASYNC(vp) vn_close(vp)
|
||||
#define VOP_CLOSE(vp, f, c, o, cr, ct) 0
|
||||
#define VOP_PUTPAGE(vp, of, sz, fl, cr, ct) 0
|
||||
#ifndef __NetBSD__
|
||||
#define VOP_GETATTR(vp, vap, cr) fop_getattr((vp), (vap));
|
||||
#else
|
||||
#define VOP_GETATTR(vp, vap, fl, cr, ct) fop_getattr((vp), (vap));
|
||||
#endif
|
||||
|
||||
#define vn_lock(vp, type)
|
||||
#define VOP_UNLOCK(vp, type)
|
||||
#define VOP_FSYNC(vp, f, cr, ct) fsync((vp)->v_fd)
|
||||
|
||||
#define VN_RELE(vp) vn_close(vp, 0, NULL, NULL)
|
||||
#define VN_RELE_ASYNC(vp, taskq) vn_close(vp, 0, NULL, NULL)
|
||||
|
||||
#define vn_lock(vp, type)
|
||||
#define VOP_UNLOCK(vp, type)
|
||||
|
||||
extern int vn_open(char *path, int x1, int oflags, int mode, vnode_t **vpp,
|
||||
int x2, int x3);
|
||||
extern int vn_openat(char *path, int x1, int oflags, int mode, vnode_t **vpp,
|
||||
int x2, int x3, vnode_t *vp, int unk);
|
||||
int x2, int x3, vnode_t *vp, int fd);
|
||||
extern int vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len,
|
||||
offset_t offset, int x1, int x2, rlim64_t x3, void *x4, ssize_t *residp);
|
||||
extern void vn_close(vnode_t *vp, int, cred_t *, kthread_t *);
|
||||
extern int vn_getattr(vnode_t *vp, vattr_t *va);
|
||||
extern void vn_close(vnode_t *vp, int openflag, cred_t *cr, kthread_t *td);
|
||||
|
||||
#define vn_remove(path, x1, x2) remove(path)
|
||||
#define vn_rename(from, to, seg) rename((from), (to))
|
||||
|
@ -449,17 +553,20 @@ extern vnode_t *rootdir;
|
|||
/*
|
||||
* Random stuff
|
||||
*/
|
||||
#define lbolt (gethrtime() >> 23)
|
||||
#define lbolt64 (gethrtime() >> 23)
|
||||
#define ddi_get_lbolt() (gethrtime() >> 23)
|
||||
#define ddi_get_lbolt64() (gethrtime() >> 23)
|
||||
#define hz 119 /* frequency when using gethrtime() >> 23 for lbolt */
|
||||
|
||||
extern void delay(clock_t ticks);
|
||||
|
||||
#define SEC_TO_TICK(sec) ((sec) * hz)
|
||||
#define NSEC_TO_TICK(nsec) ((nsec) / (NANOSEC / hz))
|
||||
|
||||
#define gethrestime_sec() time(NULL)
|
||||
#define gethrestime(t) \
|
||||
#define gethrestime(t) \
|
||||
do {\
|
||||
(t)->tv_sec = gethrestime_sec();\
|
||||
(t)->tv_nsec = 0;\
|
||||
(t)->tv_sec = gethrestime_sec();\
|
||||
(t)->tv_nsec = 0;\
|
||||
} while (0);
|
||||
|
||||
#define max_ncpus 64
|
||||
|
@ -472,13 +579,15 @@ extern void delay(clock_t ticks);
|
|||
#define kcred NULL
|
||||
#define CRED() NULL
|
||||
|
||||
#ifdef ptob
|
||||
#undef ptob
|
||||
#endif
|
||||
#ifndef ptob
|
||||
#define ptob(x) ((x) * PAGESIZE)
|
||||
#endif
|
||||
|
||||
extern uint64_t physmem;
|
||||
|
||||
#ifndef __NetBSD__
|
||||
extern int highbit64(uint64_t i);
|
||||
#endif
|
||||
extern int random_get_bytes(uint8_t *ptr, size_t len);
|
||||
extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len);
|
||||
|
||||
|
@ -486,7 +595,7 @@ extern void kernel_init(int);
|
|||
extern void kernel_fini(void);
|
||||
|
||||
struct spa;
|
||||
extern void nicenum(uint64_t, char *);
|
||||
extern void nicenum(uint64_t num, char *buf);
|
||||
extern void show_pool_stats(struct spa *);
|
||||
|
||||
typedef struct callb_cpr {
|
||||
|
@ -513,15 +622,19 @@ typedef struct callb_cpr {
|
|||
#define zone_dataset_visible(x, y) (1)
|
||||
#define INGLOBALZONE(z) (1)
|
||||
|
||||
extern char *kmem_asprintf(const char *fmt, ...);
|
||||
#define strfree(str) kmem_free((str), strlen(str) + 1)
|
||||
|
||||
/*
|
||||
* Hostname information
|
||||
*/
|
||||
extern struct utsname utsname;
|
||||
extern char hw_serial[];
|
||||
extern char hw_serial[]; /* for userland-emulated hostid access */
|
||||
extern int ddi_strtoul(const char *str, char **nptr, int base,
|
||||
unsigned long *result);
|
||||
#define ddi_get_lbolt() (gethrtime() >> 23)
|
||||
#define ddi_get_lbolt64() (gethrtime() >> 23)
|
||||
|
||||
extern int ddi_strtoull(const char *str, char **nptr, int base,
|
||||
u_longlong_t *result);
|
||||
|
||||
/* ZFS Boot Related stuff. */
|
||||
|
||||
|
@ -533,28 +646,37 @@ struct bootstat {
|
|||
uint64_t st_size;
|
||||
};
|
||||
|
||||
extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr);
|
||||
extern int zfs_secpolicy_rename_perms(const char *from, const char *to,
|
||||
cred_t *cr);
|
||||
extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr);
|
||||
typedef struct ace_object {
|
||||
uid_t a_who;
|
||||
uint32_t a_access_mask;
|
||||
uint16_t a_flags;
|
||||
uint16_t a_type;
|
||||
uint8_t a_obj_type[16];
|
||||
uint8_t a_inherit_obj_type[16];
|
||||
} ace_object_t;
|
||||
|
||||
|
||||
#define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05
|
||||
#define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE 0x06
|
||||
#define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07
|
||||
#define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08
|
||||
|
||||
extern struct _buf *kobj_open_file(char *name);
|
||||
extern int kobj_read_file(struct _buf *file, char *buf, unsigned size,
|
||||
unsigned off);
|
||||
extern void kobj_close_file(struct _buf *file);
|
||||
extern int kobj_get_filesize(struct _buf *file, uint64_t *size);
|
||||
|
||||
extern int zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr);
|
||||
extern int zfs_secpolicy_rename_perms(const char *from, const char *to,
|
||||
cred_t *cr);
|
||||
extern int zfs_secpolicy_destroy_perms(const char *name, cred_t *cr);
|
||||
#ifndef __NetBSD__
|
||||
extern zoneid_t getzoneid(void);
|
||||
#endif
|
||||
/* Random compatibility stuff. */
|
||||
#define lbolt (gethrtime() >> 23)
|
||||
#define lbolt64 (gethrtime() >> 23)
|
||||
|
||||
extern uint64_t physmem;
|
||||
|
||||
#define gethrestime_sec() time(NULL)
|
||||
|
||||
#define pwrite64(d, p, n, o) pwrite(d, p, n, o)
|
||||
#define readdir64(d) readdir(d)
|
||||
#define sigispending(td, sig) (0)
|
||||
#define SIGPENDING(td) (0)
|
||||
#define root_mount_wait() do { } while (0)
|
||||
#define root_mounted() (1)
|
||||
|
||||
|
@ -565,14 +687,7 @@ struct file {
|
|||
#define FCREAT O_CREAT
|
||||
#define FOFFMAX 0x0
|
||||
|
||||
/* Errors */
|
||||
|
||||
#ifndef ERESTART
|
||||
#define ERESTART (-1)
|
||||
#endif
|
||||
|
||||
/* SID stuff */
|
||||
|
||||
typedef struct ksiddomain {
|
||||
uint_t kd_ref;
|
||||
uint_t kd_len;
|
||||
|
@ -582,230 +697,145 @@ typedef struct ksiddomain {
|
|||
ksiddomain_t *ksid_lookupdomain(const char *);
|
||||
void ksiddomain_rele(ksiddomain_t *);
|
||||
|
||||
typedef uint32_t idmap_rid_t;
|
||||
|
||||
#define DDI_SLEEP KM_SLEEP
|
||||
#define ddi_log_sysevent(_a, _b, _c, _d, _e, _f, _g) (0)
|
||||
|
||||
typedef struct ace_object {
|
||||
uid_t a_who;
|
||||
uint32_t a_access_mask;
|
||||
uint16_t a_flags;
|
||||
uint16_t a_type;
|
||||
uint8_t a_obj_type[16];
|
||||
uint8_t a_inherit_obj_type[16];
|
||||
} ace_object_t;
|
||||
|
||||
#define ACE_ACCESS_ALLOWED_OBJECT_ACE_TYPE 0x05
|
||||
#define ACE_ACCESS_DENIED_OBJECT_ACE_TYPE 0x06
|
||||
#define ACE_SYSTEM_AUDIT_OBJECT_ACE_TYPE 0x07
|
||||
#define ACE_SYSTEM_ALARM_OBJECT_ACE_TYPE 0x08
|
||||
#define SX_SYSINIT(name, lock, desc)
|
||||
|
||||
/* libzfs_dataset.c */
|
||||
#define priv_allocset() (NULL)
|
||||
#define getppriv(a, b) (0)
|
||||
#define priv_isfullset(a) (B_FALSE)
|
||||
#define priv_freeset(a) (0)
|
||||
|
||||
#define di_devlink_init(a, b) (NULL)
|
||||
#define di_devlink_fini(a) (0)
|
||||
typedef void *di_devlink_handle_t;
|
||||
|
||||
extern char *kmem_asprintf(const char *fmt, ...);
|
||||
#define strfree(str) kmem_free((str), strlen(str)+1)
|
||||
|
||||
#define DEV_PHYS_PATH "phys_path"
|
||||
|
||||
typedef uint32_t idmap_rid_t;
|
||||
|
||||
#define ZFS_EXPORTS_PATH "/etc/zfs/exports"
|
||||
|
||||
#else /* _KERNEL */
|
||||
|
||||
#include <sys/systm.h>
|
||||
#include <sys/syslimits.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/stdint.h>
|
||||
#include <sys/note.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/kstat.h>
|
||||
#include <sys/debug.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/bitmap.h>
|
||||
#include <sys/cmn_err.h>
|
||||
#include <sys/taskq.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/kcondvar.h>
|
||||
#include <sys/list.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/dirent.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/fcntl.h>
|
||||
#include <sys/string.h>
|
||||
#include <sys/buf.h>
|
||||
#include <sys/cred.h>
|
||||
#include <sys/sdt.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/vfs.h>
|
||||
#include <sys/lockf.h>
|
||||
#include <sys/refstr.h>
|
||||
#include <sys/zone.h>
|
||||
#include <sys/misc.h>
|
||||
#include <sys/zfs_debug.h>
|
||||
#include <sys/byteorder.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/random.h>
|
||||
#include <sys/pset.h>
|
||||
#include <sys/u8_textprep.h>
|
||||
#include <sys/sysevent.h>
|
||||
#include <sys/sysevent/eventdefs.h>
|
||||
#include <sys/u8_textprep.h>
|
||||
#include <sys/sunddi.h>
|
||||
#include <sys/cyclic.h>
|
||||
|
||||
#include <miscfs/specfs/specdev.h>
|
||||
#include <uvm/uvm_extern.h>
|
||||
|
||||
#define CPU_SEQID (curcpu()->ci_data.cpu_index)
|
||||
#define lbolt hardclock_ticks
|
||||
#define lbolt64 lbolt
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int zfs_debug_level;
|
||||
extern kmutex_t zfs_debug_mtx;
|
||||
#define ZFS_LOG(lvl, ...) do { \
|
||||
if (((lvl) & 0xff) <= zfs_debug_level) { \
|
||||
mutex_enter(&zfs_debug_mtx); \
|
||||
printf("%s:%u[%d]: ", __func__, __LINE__, (lvl)); \
|
||||
printf(__VA_ARGS__); \
|
||||
printf("\n"); \
|
||||
if ((lvl) & 0x100) \
|
||||
/* XXXNETBSD backtrace */ \
|
||||
mutex_exit(&zfs_debug_mtx); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
extern struct utsname utsname;
|
||||
|
||||
#define makedevice(a, b) makedev(a, b)
|
||||
#define getmajor(a) major(a)
|
||||
#define getminor(a) minor(a)
|
||||
#define issig(x) (sigispending(curlwp, 0))
|
||||
#define ISSIG(thr, why) (sigispending(thr, 0))
|
||||
#define fm_panic panic
|
||||
|
||||
#ifdef ptob
|
||||
#undef ptob
|
||||
#endif
|
||||
#define ptob(x) ((x) * PAGE_SIZE)
|
||||
|
||||
#define strncat(a, b, c) strlcat(a, b, c)
|
||||
#define kmem_debugging() 0
|
||||
|
||||
#define zone_get_hostid(a) 0
|
||||
|
||||
extern char *kmem_asprintf(const char *fmt, ...);
|
||||
#define strfree(str) kmem_free((str), strlen(str)+1)
|
||||
|
||||
static inline void
|
||||
tsd_create(uint_t *keyp, void (*func)(void *))
|
||||
{
|
||||
int error __unused;
|
||||
|
||||
error = lwp_specific_key_create(keyp, func);
|
||||
KASSERT(error == 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
tsd_destroy(uint_t *keyp)
|
||||
{
|
||||
|
||||
lwp_specific_key_delete(*keyp);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
tsd_get(uint_t key)
|
||||
{
|
||||
|
||||
return lwp_getspecific(key);
|
||||
}
|
||||
|
||||
static inline int
|
||||
tsd_set(uint_t key, void *value)
|
||||
{
|
||||
|
||||
lwp_setspecific(key, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define td_ru l_ru
|
||||
|
||||
#define FIGNORECASE 0
|
||||
|
||||
#define DEV_PHYS_PATH "phys_path"
|
||||
|
||||
#define sys_shutdown 0
|
||||
|
||||
static inline int
|
||||
sprintf(char * __restrict buf, const char * __restrict fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int rv;
|
||||
|
||||
va_start(ap, fmt);
|
||||
rv = vsnprintf(buf, 1024, fmt, ap);
|
||||
va_end(ap);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static inline int
|
||||
vsprintf(char * __restrict buf, const char * __restrict fmt, va_list ap)
|
||||
{
|
||||
|
||||
return vsnprintf(buf, 1024, fmt, ap);
|
||||
}
|
||||
#define SYSCTL_HANDLER_ARGS struct sysctl_oid *oidp, void *arg1, \
|
||||
intptr_t arg2, struct sysctl_req *req
|
||||
|
||||
/*
|
||||
* FreeBSD interfaces
|
||||
* This describes the access space for a sysctl request. This is needed
|
||||
* so that we can use the interface from the kernel or from user-space.
|
||||
*/
|
||||
struct sysctl_req {
|
||||
struct thread *td; /* used for access checking */
|
||||
int lock; /* wiring state */
|
||||
void *oldptr;
|
||||
size_t oldlen;
|
||||
size_t oldidx;
|
||||
int (*oldfunc)(struct sysctl_req *, const void *, size_t);
|
||||
void *newptr;
|
||||
size_t newlen;
|
||||
size_t newidx;
|
||||
int (*newfunc)(struct sysctl_req *, void *, size_t);
|
||||
size_t validlen;
|
||||
int flags;
|
||||
};
|
||||
|
||||
void zfs_netbsd_setsize(vnode_t *, off_t);
|
||||
#define vnode_pager_setsize(vp, size) zfs_netbsd_setsize(vp, size)
|
||||
SLIST_HEAD(sysctl_oid_list, sysctl_oid);
|
||||
|
||||
#define getf fd_getfile
|
||||
#define releasef fd_putfile
|
||||
|
||||
#define callout_drain(x) callout_halt(x, NULL)
|
||||
|
||||
#endif /* _KERNEL */
|
||||
/*
|
||||
* This describes one "oid" in the MIB tree. Potentially more nodes can
|
||||
* be hidden behind it, expanded by the handler.
|
||||
*/
|
||||
struct sysctl_oid {
|
||||
struct sysctl_oid_list *oid_parent;
|
||||
SLIST_ENTRY(sysctl_oid) oid_link;
|
||||
int oid_number;
|
||||
u_int oid_kind;
|
||||
void *oid_arg1;
|
||||
intptr_t oid_arg2;
|
||||
const char *oid_name;
|
||||
int (*oid_handler)(SYSCTL_HANDLER_ARGS);
|
||||
const char *oid_fmt;
|
||||
int oid_refcnt;
|
||||
u_int oid_running;
|
||||
const char *oid_descr;
|
||||
};
|
||||
|
||||
#define SYSCTL_DECL(...)
|
||||
#define SYSCTL_NODE(...)
|
||||
#define SYSCTL_INT(...)
|
||||
#define SYSCTL_UINT(...)
|
||||
#define SYSCTL_LONG(...)
|
||||
#define SYSCTL_ULONG(...)
|
||||
#define SYSCTL_PROC(...)
|
||||
#define SYSCTL_QUAD(...)
|
||||
#define SYSCTL_UQUAD(...)
|
||||
#ifdef TUNABLE_INT
|
||||
#undef TUNABLE_INT
|
||||
#undef TUNABLE_ULONG
|
||||
#undef TUNABLE_INT_FETCH
|
||||
#undef TUNABLE_QUAD
|
||||
#endif
|
||||
#define TUNABLE_INT(...)
|
||||
#define TUNABLE_ULONG(...)
|
||||
#define TUNABLE_INT_FETCH(...) 0
|
||||
#define TUNABLE_QUAD(...)
|
||||
|
||||
#define ASSERT_VOP_LOCKED(vp, name) KASSERT(VOP_ISLOCKED(vp) != 0)
|
||||
#define ASSERT_VOP_ELOCKED(vp, name) KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE)
|
||||
int sysctl_handle_64(SYSCTL_HANDLER_ARGS);
|
||||
|
||||
#define UID_NOBODY (-2)
|
||||
#define GID_NOBODY (-2)
|
||||
/* Errors */
|
||||
|
||||
#ifndef ERESTART
|
||||
#define ERESTART (-1)
|
||||
#endif
|
||||
|
||||
#if defined(illumos) || defined(__NetBSD__)
|
||||
/*
|
||||
* Cyclic information
|
||||
*/
|
||||
extern kmutex_t cpu_lock;
|
||||
|
||||
typedef uintptr_t cyclic_id_t;
|
||||
typedef uint16_t cyc_level_t;
|
||||
typedef void (*cyc_func_t)(void *);
|
||||
|
||||
#define CY_LOW_LEVEL 0
|
||||
#define CY_INFINITY INT64_MAX
|
||||
#define CYCLIC_NONE ((cyclic_id_t)0)
|
||||
|
||||
typedef struct cyc_time {
|
||||
hrtime_t cyt_when;
|
||||
hrtime_t cyt_interval;
|
||||
} cyc_time_t;
|
||||
|
||||
typedef struct cyc_handler {
|
||||
cyc_func_t cyh_func;
|
||||
void *cyh_arg;
|
||||
cyc_level_t cyh_level;
|
||||
} cyc_handler_t;
|
||||
|
||||
extern cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *);
|
||||
extern void cyclic_remove(cyclic_id_t);
|
||||
extern int cyclic_reprogram(cyclic_id_t, hrtime_t);
|
||||
#endif /* illumos */
|
||||
|
||||
#ifdef illumos
|
||||
/*
|
||||
* Buf structure
|
||||
*/
|
||||
#define B_BUSY 0x0001
|
||||
#define B_DONE 0x0002
|
||||
#define B_ERROR 0x0004
|
||||
#define B_READ 0x0040 /* read when I/O occurs */
|
||||
#define B_WRITE 0x0100 /* non-read pseudo-flag */
|
||||
|
||||
typedef struct buf {
|
||||
int b_flags;
|
||||
size_t b_bcount;
|
||||
union {
|
||||
caddr_t b_addr;
|
||||
} b_un;
|
||||
|
||||
lldaddr_t _b_blkno;
|
||||
#define b_lblkno _b_blkno._f
|
||||
size_t b_resid;
|
||||
size_t b_bufsize;
|
||||
int (*b_iodone)(struct buf *);
|
||||
int b_error;
|
||||
void *b_private;
|
||||
} buf_t;
|
||||
|
||||
extern void bioinit(buf_t *);
|
||||
extern void biodone(buf_t *);
|
||||
extern void bioerror(buf_t *, int);
|
||||
extern int geterror(buf_t *);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYS_ZFS_CONTEXT_H */
|
|
@ -46,7 +46,9 @@ extern "C" {
|
|||
#include <sys/cmn_err.h>
|
||||
#include <sys/kmem.h>
|
||||
#include <sys/taskq.h>
|
||||
#ifndef __NetBSD__
|
||||
#include <sys/taskqueue.h>
|
||||
#endif
|
||||
#include <sys/systm.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/mutex.h>
|
||||
|
@ -63,38 +65,51 @@ extern "C" {
|
|||
#include <sys/time.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/fcntl.h>
|
||||
#ifndef __NetBSD__
|
||||
#include <sys/limits.h>
|
||||
#else
|
||||
#include <sys/syslimits.h>
|
||||
#endif
|
||||
#include <sys/string.h>
|
||||
#ifndef __NetBSD__
|
||||
#include <sys/bio.h>
|
||||
#endif
|
||||
#include <sys/buf.h>
|
||||
#include <sys/cred.h>
|
||||
#include <sys/sdt.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/vfs.h>
|
||||
#include <sys/sysctl.h>
|
||||
#ifndef __NetBSD__
|
||||
#include <sys/sbuf.h>
|
||||
#include <sys/priv.h>
|
||||
#include <sys/kdb.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/stack.h>
|
||||
#endif
|
||||
#include <sys/lockf.h>
|
||||
#include <sys/pathname.h>
|
||||
#include <sys/policy.h>
|
||||
#include <sys/refstr.h>
|
||||
#include <sys/zone.h>
|
||||
#ifndef __NetBSD__
|
||||
#include <sys/eventhandler.h>
|
||||
#endif
|
||||
#include <sys/extattr.h>
|
||||
#include <sys/misc.h>
|
||||
#ifndef __NetBSD__
|
||||
#include <sys/sig.h>
|
||||
#include <sys/osd.h>
|
||||
#endif
|
||||
#include <sys/sysevent/dev.h>
|
||||
#include <sys/sysevent/eventdefs.h>
|
||||
#include <sys/u8_textprep.h>
|
||||
#include <sys/fm/util.h>
|
||||
#include <sys/sunddi.h>
|
||||
#ifdef illumos
|
||||
#if defined(illumos) || defined(__NetBSD__)
|
||||
#include <sys/cyclic.h>
|
||||
#endif
|
||||
#ifndef __NetBSD__
|
||||
#include <sys/callo.h>
|
||||
#include <sys/disp.h>
|
||||
#include <machine/stdarg.h>
|
||||
|
@ -113,6 +128,14 @@ extern "C" {
|
|||
#endif
|
||||
#include <vm/vm_extern.h>
|
||||
#include <vm/vnode_pager.h>
|
||||
#else /* !__NetBSD__ */
|
||||
#include <sys/callout.h>
|
||||
#include <sys/stdarg.h>
|
||||
|
||||
#include <miscfs/specfs/specdev.h>
|
||||
#endif /* !__NetBSD__ */
|
||||
|
||||
#ifndef __NetBSD__
|
||||
|
||||
#define CPU_SEQID (curcpu)
|
||||
|
||||
|
@ -124,11 +147,106 @@ extern "C" {
|
|||
#define tsd_get(key) osd_thread_get(curthread, (key))
|
||||
#define tsd_set(key, value) osd_thread_set(curthread, (key), (value))
|
||||
|
||||
#else /* !__NetBSD__ */
|
||||
|
||||
#define ASSERT_VOP_LOCKED(vp, name) KASSERT(VOP_ISLOCKED(vp) != 0)
|
||||
#define ASSERT_VOP_ELOCKED(vp, name) KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE)
|
||||
#define callout_drain(x) callout_halt(x, NULL)
|
||||
#define CPU_SEQID (curcpu()->ci_data.cpu_index)
|
||||
#define FIGNORECASE 0
|
||||
#define fm_panic panic
|
||||
#define getf fd_getfile
|
||||
#define getminor(a) minor(a)
|
||||
#define GID_NOBODY (-2)
|
||||
#define issig(x) (sigispending(curlwp, 0))
|
||||
#define kmem_debugging() 0
|
||||
#define releasef fd_putfile
|
||||
#define strfree(str) kmem_free((str), strlen(str)+1)
|
||||
#define td_ru l_ru
|
||||
#define UID_NOBODY (-2)
|
||||
#define vnode_pager_setsize(vp, size) zfs_netbsd_setsize(vp, size)
|
||||
#define zone_get_hostid(a) 0
|
||||
|
||||
extern struct utsname utsname;
|
||||
|
||||
void zfs_netbsd_setsize(vnode_t *, off_t);
|
||||
|
||||
static inline int
|
||||
sprintf(char * __restrict buf, const char * __restrict fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int rv;
|
||||
|
||||
va_start(ap, fmt);
|
||||
rv = vsnprintf(buf, 1024, fmt, ap);
|
||||
va_end(ap);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static inline void
|
||||
tsd_create(uint_t *keyp, void (*func)(void *))
|
||||
{
|
||||
int error __unused;
|
||||
|
||||
error = lwp_specific_key_create(keyp, func);
|
||||
KASSERT(error == 0);
|
||||
}
|
||||
|
||||
static inline void
|
||||
tsd_destroy(uint_t *keyp)
|
||||
{
|
||||
|
||||
lwp_specific_key_delete(*keyp);
|
||||
}
|
||||
|
||||
static inline void *
|
||||
tsd_get(uint_t key)
|
||||
{
|
||||
|
||||
return lwp_getspecific(key);
|
||||
}
|
||||
|
||||
static inline int
|
||||
tsd_set(uint_t key, void *value)
|
||||
{
|
||||
|
||||
lwp_setspecific(key, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
vsprintf(char * __restrict buf, const char * __restrict fmt, va_list ap)
|
||||
{
|
||||
|
||||
return vsnprintf(buf, 1024, fmt, ap);
|
||||
}
|
||||
|
||||
#define SYSCTL_DECL(...)
|
||||
#define SYSCTL_NODE(...)
|
||||
#define SYSCTL_INT(...)
|
||||
#define SYSCTL_UINT(...)
|
||||
#define SYSCTL_LONG(...)
|
||||
#define SYSCTL_ULONG(...)
|
||||
#define SYSCTL_QUAD(...)
|
||||
#define SYSCTL_UQUAD(...)
|
||||
#ifdef TUNABLE_INT
|
||||
#undef TUNABLE_INT
|
||||
#undef TUNABLE_ULONG
|
||||
#undef TUNABLE_INT_FETCH
|
||||
#endif
|
||||
#define TUNABLE_INT(...)
|
||||
#define TUNABLE_ULONG(...)
|
||||
#define TUNABLE_INT_FETCH(...) 0
|
||||
|
||||
#endif /* !__NetBSD__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int zfs_debug_level;
|
||||
#ifndef __NetBSD__
|
||||
|
||||
extern struct mtx zfs_debug_mtx;
|
||||
#define ZFS_LOG(lvl, ...) do { \
|
||||
if (((lvl) & 0xff) <= zfs_debug_level) { \
|
||||
|
@ -144,4 +262,23 @@ extern struct mtx zfs_debug_mtx;
|
|||
|
||||
#define sys_shutdown rebooting
|
||||
|
||||
#else /* !__NetBSD__ */
|
||||
|
||||
extern kmutex_t zfs_debug_mtx;
|
||||
#define ZFS_LOG(lvl, ...) do { \
|
||||
if (((lvl) & 0xff) <= zfs_debug_level) { \
|
||||
mutex_enter(&zfs_debug_mtx); \
|
||||
printf("%s:%u[%d]: ", __func__, __LINE__, (lvl)); \
|
||||
printf(__VA_ARGS__); \
|
||||
printf("\n"); \
|
||||
if ((lvl) & 0x100) \
|
||||
/* XXXNETBSD backtrace */; \
|
||||
mutex_exit(&zfs_debug_mtx); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define sys_shutdown 0
|
||||
|
||||
#endif /* !__NetBSD__ */
|
||||
|
||||
#endif /* _SYS_ZFS_CONTEXT_H */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.3 2018/05/28 21:05:02 chs Exp $
|
||||
# $NetBSD: Makefile,v 1.4 2019/06/22 09:48:39 hannken Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
|
@ -21,6 +21,7 @@ COPTS.zfs.c+= -Wno-strict-prototypes
|
|||
COPTS.zfs.c+= -I${NETBSDSRCDIR}/external
|
||||
COPTS.zfs.c+= -I${NETBSDSRCDIR}/external/cddl/osnet/include
|
||||
COPTS.zfs.c+= -I${NETBSDSRCDIR}/external/cddl/osnet/sys
|
||||
COPTS.zfs.c+= -I${NETBSDSRCDIR}/external/cddl/osnet/dist/lib/libzpool/common
|
||||
COPTS.zfs.c+= -I${NETBSDSRCDIR}/external/cddl/osnet/dist/uts/common
|
||||
COPTS.zfs.c+= -I${NETBSDSRCDIR}/external/cddl/osnet/dist/uts/common/fs/zfs
|
||||
COPTS.zfs.c+= -I${NETBSDSRCDIR}/external/cddl/osnet/dist/lib/libnvpair
|
||||
|
|
Loading…
Reference in New Issue