diff --git a/external/cddl/osnet/Makefile.inc b/external/cddl/osnet/Makefile.inc new file mode 100644 index 000000000000..6b0eec30cfa9 --- /dev/null +++ b/external/cddl/osnet/Makefile.inc @@ -0,0 +1,6 @@ +# $FreeBSD: src/cddl/Makefile.inc,v 1.6.2.1 2009/08/03 08:13:06 kensmith Exp $ + +OSNETDIR= ${NETBSDSRCDIR}/external/cddl/osnet + +OPENSOLARIS_USR_DISTDIR=${OSNETDIR}/dist +OPENSOLARIS_SYS_DISTDIR=${OSNETDIR}/dist diff --git a/external/cddl/osnet/dev/cyclic/amd64/cyclic_machdep.c b/external/cddl/osnet/dev/cyclic/amd64/cyclic_machdep.c index c8bda85d7655..25a94f234076 100644 --- a/external/cddl/osnet/dev/cyclic/amd64/cyclic_machdep.c +++ b/external/cddl/osnet/dev/cyclic/amd64/cyclic_machdep.c @@ -1,3 +1,5 @@ +/* $NetBSD: cyclic_machdep.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /*- * Copyright 2007 John Birrell * diff --git a/external/cddl/osnet/dev/cyclic/cyclic.c b/external/cddl/osnet/dev/cyclic/cyclic.c index 5d6fae21fafe..7d3d05e20ebd 100644 --- a/external/cddl/osnet/dev/cyclic/cyclic.c +++ b/external/cddl/osnet/dev/cyclic/cyclic.c @@ -1,3 +1,5 @@ +/* $NetBSD: cyclic.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/cyclic/cyclic_test.c b/external/cddl/osnet/dev/cyclic/cyclic_test.c index 4dee17a3b8c1..3cce8d0db62c 100644 --- a/external/cddl/osnet/dev/cyclic/cyclic_test.c +++ b/external/cddl/osnet/dev/cyclic/cyclic_test.c @@ -1,3 +1,5 @@ +/* $NetBSD: cyclic_test.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /*- * Copyright 2007 John Birrell * diff --git a/external/cddl/osnet/dev/cyclic/i386/cyclic_machdep.c b/external/cddl/osnet/dev/cyclic/i386/cyclic_machdep.c index 9a2d9cb4eb41..d1f127bf2e14 100644 --- a/external/cddl/osnet/dev/cyclic/i386/cyclic_machdep.c +++ b/external/cddl/osnet/dev/cyclic/i386/cyclic_machdep.c @@ -1,3 +1,5 @@ +/* $NetBSD: cyclic_machdep.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /*- * Copyright 2006-2008 John Birrell * diff --git a/external/cddl/osnet/dev/dtmalloc/dtmalloc.c b/external/cddl/osnet/dev/dtmalloc/dtmalloc.c index 3c055d41ae23..ef751b5b9741 100644 --- a/external/cddl/osnet/dev/dtmalloc/dtmalloc.c +++ b/external/cddl/osnet/dev/dtmalloc/dtmalloc.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtmalloc.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/dtrace/amd64/dis_tables.c b/external/cddl/osnet/dev/dtrace/amd64/dis_tables.c index 5e8ef95d41b8..80775e92be38 100644 --- a/external/cddl/osnet/dev/dtrace/amd64/dis_tables.c +++ b/external/cddl/osnet/dev/dtrace/amd64/dis_tables.c @@ -1,3 +1,5 @@ +/* $NetBSD: dis_tables.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/dtrace/amd64/dis_tables.h b/external/cddl/osnet/dev/dtrace/amd64/dis_tables.h index 2ff1fb860f97..0f5858a53c88 100644 --- a/external/cddl/osnet/dev/dtrace/amd64/dis_tables.h +++ b/external/cddl/osnet/dev/dtrace/amd64/dis_tables.h @@ -1,3 +1,5 @@ +/* $NetBSD: dis_tables.h,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S b/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S index f1d3667dee49..816b05006b60 100644 --- a/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S +++ b/external/cddl/osnet/dev/dtrace/amd64/dtrace_asm.S @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_asm.S,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c b/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c index ad04ef5daf9b..25f253265e49 100644 --- a/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c +++ b/external/cddl/osnet/dev/dtrace/amd64/dtrace_isa.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_isa.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c b/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c index 131be4068b87..f894fe1dfa67 100644 --- a/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c +++ b/external/cddl/osnet/dev/dtrace/amd64/dtrace_subr.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_subr.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/dtrace/amd64/instr_size.c b/external/cddl/osnet/dev/dtrace/amd64/instr_size.c index 57d796370c37..5d40f9d61017 100644 --- a/external/cddl/osnet/dev/dtrace/amd64/instr_size.c +++ b/external/cddl/osnet/dev/dtrace/amd64/instr_size.c @@ -1,3 +1,5 @@ +/* $NetBSD: instr_size.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/dtrace/dtrace_anon.c b/external/cddl/osnet/dev/dtrace/dtrace_anon.c index 9445b857ff5f..5bc64e1b02af 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_anon.c +++ b/external/cddl/osnet/dev/dtrace/dtrace_anon.c @@ -1,3 +1,4 @@ +/* $NetBSD: dtrace_anon.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/dtrace/dtrace_cddl.h b/external/cddl/osnet/dev/dtrace/dtrace_cddl.h index 7af94a720bd9..16b64c946541 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_cddl.h +++ b/external/cddl/osnet/dev/dtrace/dtrace_cddl.h @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_cddl.h,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * @@ -84,25 +86,25 @@ typedef struct kdtrace_thread { * that the separation on FreeBSD is a licensing constraint designed to * keep the GENERIC kernel BSD licensed. */ -#define t_dtrace_vtime td_dtrace->td_dtrace_vtime -#define t_dtrace_start td_dtrace->td_dtrace_start -#define t_dtrace_stop td_dtrace->td_dtrace_stop -#define t_dtrace_sig td_dtrace->td_dtrace_sig -#define t_predcache td_dtrace->td_predcache +#define t_dtrace_vtime l_dtrace->td_dtrace_vtime +#define t_dtrace_start l_dtrace->td_dtrace_start +#define t_dtrace_stop l_dtrace->td_dtrace_stop +#define t_dtrace_sig l_dtrace->td_dtrace_sig +#define t_predcache l_dtrace->td_predcache #define p_dtrace_helpers p_dtrace->p_dtrace_helpers /* * Definitions for fields in struct proc which are named differntly in FreeBSD. */ -#define p_cred p_ucred +//#define p_cred p_ucred #define p_parent p_pptr /* - * Definitions for fields in struct thread which are named differntly in FreeBSD. + * Definitions for fields in struct thread which are named differntly in NetBSD. */ -#define t_procp td_proc -#define t_tid td_tid -#define t_did td_tid +#define t_procp l_proc +#define t_tid l_lid +#define t_did l_lid int priv_policy(const cred_t *, int, boolean_t, int, const char *); diff --git a/external/cddl/osnet/dev/dtrace/dtrace_clone.c b/external/cddl/osnet/dev/dtrace/dtrace_clone.c index 81529c7f45cc..9f500cb2ffcc 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_clone.c +++ b/external/cddl/osnet/dev/dtrace/dtrace_clone.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_clone.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /*- * Copyright (C) 2006 John Birrell . * All rights reserved. diff --git a/external/cddl/osnet/dev/dtrace/dtrace_debug.c b/external/cddl/osnet/dev/dtrace/dtrace_debug.c index 812b3013b302..cc7099cf5af1 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_debug.c +++ b/external/cddl/osnet/dev/dtrace/dtrace_debug.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_debug.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /*- * Copyright (C) 2008 John Birrell . * All rights reserved. @@ -29,6 +31,9 @@ * */ +static char const hex2ascii_data[] = "0123456789abcdefghijklmnopqrstuvwxyz"; +#define hex2ascii(hex) (hex2ascii_data[hex]) + #ifdef DEBUG #if defined(__amd64__) @@ -82,11 +87,11 @@ struct dtrace_debug_data { char *first; char *last; char *next; -} dtrace_debug_data[MAXCPU]; +} dtrace_debug_data[MAXCPUS]; static char dtrace_debug_bufr[DTRACE_DEBUG_BUFR_SIZE]; -static volatile u_long dtrace_debug_flag[MAXCPU]; +static volatile u_long dtrace_debug_flag[MAXCPUS]; static void dtrace_debug_lock(int cpu) @@ -107,12 +112,11 @@ dtrace_debug_init(void *dummy) { int i; struct dtrace_debug_data *d; + CPU_INFO_ITERATOR cpuind; + struct cpu_info *cinfo; - for (i = 0; i <= mp_maxid; i++) { - if (pcpu_find(i) == NULL) - continue; - - d = &dtrace_debug_data[i]; + for (CPU_INFO_FOREACH(cpuind, cinfo)) { + d = &dtrace_debug_data[cpu_index(cinfo)]; if (d->first == NULL) { d->first = d->bufr; @@ -123,24 +127,25 @@ dtrace_debug_init(void *dummy) } } -SYSINIT(dtrace_debug_init, SI_SUB_KDTRACE, SI_ORDER_ANY, dtrace_debug_init, NULL); -SYSINIT(dtrace_debug_smpinit, SI_SUB_SMP, SI_ORDER_ANY, dtrace_debug_init, NULL); +//SYSINIT(dtrace_debug_init, SI_SUB_KDTRACE, SI_ORDER_ANY, dtrace_debug_init, NULL); +//SYSINIT(dtrace_debug_smpinit, SI_SUB_SMP, SI_ORDER_ANY, dtrace_debug_init, NULL); static void dtrace_debug_output(void) { char *p; - int i; struct dtrace_debug_data *d; uintptr_t count; + CPU_INFO_ITERATOR cpuind; + struct cpu_info *cinfo; + cpuid_t cpuid; - for (i = 0; i <= mp_maxid; i++) { - if (pcpu_find(i) == NULL) - continue; + for (CPU_INFO_FOREACH(cpuind, cinfo)) { + cpuid = cpu_index(cinfo); - dtrace_debug_lock(i); + dtrace_debug_lock(cpuid); - d = &dtrace_debug_data[i]; + d = &dtrace_debug_data[cpuid]; count = 0; @@ -168,7 +173,7 @@ dtrace_debug_output(void) d->first = d->bufr; d->next = d->bufr; - dtrace_debug_unlock(i); + dtrace_debug_unlock(cpuid); if (count > 0) { char *last = dtrace_debug_bufr + count; @@ -199,7 +204,7 @@ dtrace_debug_output(void) static __inline void dtrace_debug__putc(char c) { - struct dtrace_debug_data *d = &dtrace_debug_data[curcpu]; + struct dtrace_debug_data *d = &dtrace_debug_data[cpu_number()]; *d->next++ = c; @@ -218,24 +223,24 @@ dtrace_debug__putc(char c) static void __used dtrace_debug_putc(char c) { - dtrace_debug_lock(curcpu); + dtrace_debug_lock(cpu_number()); dtrace_debug__putc(c); - dtrace_debug_unlock(curcpu); + dtrace_debug_unlock(cpu_number()); } static void __used dtrace_debug_puts(const char *s) { - dtrace_debug_lock(curcpu); + dtrace_debug_lock(cpu_number()); while (*s != '\0') dtrace_debug__putc(*s++); dtrace_debug__putc('\0'); - dtrace_debug_unlock(curcpu); + dtrace_debug_unlock(cpu_number()); } /* @@ -576,7 +581,7 @@ dtrace_debug_printf(const char *fmt, ...) { va_list ap; - dtrace_debug_lock(curcpu); + dtrace_debug_lock(cpu_number()); va_start(ap, fmt); @@ -584,7 +589,7 @@ dtrace_debug_printf(const char *fmt, ...) va_end(ap); - dtrace_debug_unlock(curcpu); + dtrace_debug_unlock(cpu_number()); } #else diff --git a/external/cddl/osnet/dev/dtrace/dtrace_hacks.c b/external/cddl/osnet/dev/dtrace/dtrace_hacks.c index d7f9c7e20167..f260ec60a53d 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_hacks.c +++ b/external/cddl/osnet/dev/dtrace/dtrace_hacks.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_hacks.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* $FreeBSD: src/sys/cddl/dev/dtrace/dtrace_hacks.c,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ */ /* XXX Hacks.... */ @@ -6,6 +8,8 @@ dtrace_cacheid_t dtrace_predcache_id; int panic_quiesce; char panic_stack[PANICSTKSIZE]; +cpu_core_t cpu_core[MAXCPUS]; + boolean_t priv_policy_only(const cred_t *a, int b, boolean_t c) { diff --git a/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c b/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c index 291cea1e1349..14eb66997e7c 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c +++ b/external/cddl/osnet/dev/dtrace/dtrace_ioctl.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_ioctl.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * @@ -22,23 +24,18 @@ * */ -static int dtrace_verbose_ioctl; -SYSCTL_INT(_debug_dtrace, OID_AUTO, verbose_ioctl, CTLFLAG_RW, &dtrace_verbose_ioctl, 0, ""); +static int dtrace_verbose_ioctl=0; +//SYSCTL_INT(_debug_dtrace, OID_AUTO, verbose_ioctl, CTLFLAG_RW, &dtrace_verbose_ioctl, 0, ""); #define DTRACE_IOCTL_PRINTF(fmt, ...) if (dtrace_verbose_ioctl) printf(fmt, ## __VA_ARGS__ ) /* ARGSUSED */ static int -dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, - int flags __unused, struct thread *td) +dtrace_ioctl(struct file *fp, u_long cmd, void *addr) { -#if __FreeBSD_version < 800039 - dtrace_state_t *state = dev->si_drv1; -#else - dtrace_state_t *state; - devfs_get_cdevpriv((void **) &state); -#endif + dtrace_state_t *state = (dtrace_state_t *)fp->f_data; int error = 0; + if (state == NULL) return (EINVAL); @@ -168,11 +165,9 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, __func__,__LINE__, cmd == DTRACEIOC_AGGSNAP ? "DTRACEIOC_AGGSNAP":"DTRACEIOC_BUFSNAP", - curcpu, desc.dtbd_cpu); + cpu_number(), desc.dtbd_cpu); - if (desc.dtbd_cpu < 0 || desc.dtbd_cpu >= NCPU) - return (ENOENT); - if (pcpu_find(desc.dtbd_cpu) == NULL) + if (desc.dtbd_cpu < 0 || desc.dtbd_cpu >= ncpu) return (ENOENT); mutex_enter(&dtrace_lock); @@ -366,7 +361,7 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, return (EBUSY); } - if (dtrace_dof_slurp(dof, vstate, td->td_ucred, &enab, 0, B_TRUE) != 0) { + if (dtrace_dof_slurp(dof, vstate, curlwp->l_cred, &enab, 0, B_TRUE) != 0) { mutex_exit(&dtrace_lock); mutex_exit(&cpu_lock); dtrace_dof_destroy(dof); @@ -610,7 +605,7 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, pkey.dtpk_id = DTRACE_IDNONE; } - dtrace_cred2priv(td->td_ucred, &priv, &uid, &zoneid); + dtrace_cred2priv(curlwp->l_cred, &priv, &uid, &zoneid); mutex_enter(&dtrace_lock); @@ -696,8 +691,10 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, case DTRACEIOC_STATUS: { dtrace_status_t *stat = (dtrace_status_t *) addr; dtrace_dstate_t *dstate; - int i, j; + int j; uint64_t nerrs; + CPU_INFO_ITERATOR cpuind; + struct cpu_info *cinfo; DTRACE_IOCTL_PRINTF("%s(%d): DTRACEIOC_STATUS\n",__func__,__LINE__); @@ -725,28 +722,25 @@ dtrace_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, nerrs = state->dts_errors; dstate = &state->dts_vstate.dtvs_dynvars; - for (i = 0; i < NCPU; i++) { -#if !defined(sun) - if (pcpu_find(i) == NULL) - continue; -#endif - dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[i]; + for (CPU_INFO_FOREACH(cpuind, cinfo)) { + int ci = cpu_index(cinfo); + dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[ci]; stat->dtst_dyndrops += dcpu->dtdsc_drops; stat->dtst_dyndrops_dirty += dcpu->dtdsc_dirty_drops; stat->dtst_dyndrops_rinsing += dcpu->dtdsc_rinsing_drops; - if (state->dts_buffer[i].dtb_flags & DTRACEBUF_FULL) + if (state->dts_buffer[ci].dtb_flags & DTRACEBUF_FULL) stat->dtst_filled++; - nerrs += state->dts_buffer[i].dtb_errors; + nerrs += state->dts_buffer[ci].dtb_errors; for (j = 0; j < state->dts_nspeculations; j++) { dtrace_speculation_t *spec; dtrace_buffer_t *buf; spec = &state->dts_speculations[j]; - buf = &spec->dtsp_buffer[i]; + buf = &spec->dtsp_buffer[ci]; stat->dtst_specdrops += buf->dtb_xamot_drops; } } diff --git a/external/cddl/osnet/dev/dtrace/dtrace_load.c b/external/cddl/osnet/dev/dtrace/dtrace_load.c index 15fa8c51baf9..f268e0b4e32d 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_load.c +++ b/external/cddl/osnet/dev/dtrace/dtrace_load.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_load.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * @@ -22,30 +24,25 @@ * */ -static void -dtrace_ap_start(void *dummy) -{ - int i; +static void dtrace_debug_init(void *); +static void dtrace_anon_init(void *dummy); +void dtrace_gethrtime_init(void *); - mutex_enter(&cpu_lock); +int dtrace_helptrace_size=0; - /* Setup the rest of the CPUs. */ - for (i = 1; i <= mp_maxid; i++) { - if (pcpu_find(i) == NULL) - continue; - - (void) dtrace_cpu_setup(CPU_CONFIG, i); - } - - mutex_exit(&cpu_lock); -} - -SYSINIT(dtrace_ap_start, SI_SUB_SMP, SI_ORDER_ANY, dtrace_ap_start, NULL); +#ifndef mutex_init +#define mutex_init(a, b, c, d) mutex_init(a, c, IPL_NONE) +#endif static void dtrace_load(void *dummy) { dtrace_provider_id_t id; + CPU_INFO_ITERATOR cpuind; + struct cpu_info *cinfo; + + dtrace_debug_init(NULL); + dtrace_gethrtime_init(NULL); /* Hook into the trap handler. */ dtrace_trap_func = dtrace_trap; @@ -81,7 +78,8 @@ dtrace_load(void *dummy) ASSERT(MUTEX_HELD(&cpu_lock)); - dtrace_arena = new_unrhdr(1, INT_MAX, &dtrace_unr_mtx); + dtrace_arena = vmem_create("dtrace", 1, INT_MAX, 1, + NULL, NULL, NULL, 0, VM_SLEEP, IPL_NONE); dtrace_state_cache = kmem_cache_create("dtrace_state_cache", sizeof (dtrace_dstate_percpu_t) * NCPU, DTRACE_STATE_ALIGN, @@ -142,6 +140,7 @@ dtrace_load(void *dummy) dtrace_helptrace_buffer = kmem_zalloc(dtrace_helptrace_bufsize, KM_SLEEP); dtrace_helptrace_next = 0; + dtrace_helptrace_size = dtrace_helptrace_bufsize; } mutex_exit(&dtrace_lock); @@ -149,18 +148,15 @@ dtrace_load(void *dummy) mutex_enter(&cpu_lock); - /* Setup the boot CPU */ - (void) dtrace_cpu_setup(CPU_CONFIG, 0); + /* Setup the CPUs */ + for (CPU_INFO_FOREACH(cpuind, cinfo)) { + (void) dtrace_cpu_setup(CPU_CONFIG, cpu_index(cinfo)); + } mutex_exit(&cpu_lock); -#if __FreeBSD_version < 800039 - /* Enable device cloning. */ - clone_setup(&dtrace_clones); - - /* Setup device cloning events. */ - eh_tag = EVENTHANDLER_REGISTER(dev_clone, dtrace_clone, 0, 1000); -#else + dtrace_anon_init(NULL); +#if 0 dtrace_dev = make_dev(&dtrace_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "dtrace/dtrace"); #endif diff --git a/external/cddl/osnet/dev/dtrace/dtrace_modevent.c b/external/cddl/osnet/dev/dtrace/dtrace_modevent.c index 60b2c17a774b..15b0e1fe7d40 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_modevent.c +++ b/external/cddl/osnet/dev/dtrace/dtrace_modevent.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_modevent.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * @@ -24,24 +26,20 @@ /* ARGSUSED */ static int -dtrace_modevent(module_t mod __unused, int type, void *data __unused) +dtrace_modcmd(modcmd_t cmd, void *data) { + int bmajor = -1, cmajor = -1; int error = 0; - switch (type) { - case MOD_LOAD: - break; - - case MOD_UNLOAD: - break; - - case MOD_SHUTDOWN: - break; - + switch (cmd) { + case MODULE_CMD_INIT: + dtrace_load(NULL); + return devsw_attach("dtrace", NULL, &bmajor, + &dtrace_cdevsw, &cmajor); + case MODULE_CMD_FINI: + dtrace_unload(); + return devsw_detach(NULL, &dtrace_cdevsw); default: - error = EOPNOTSUPP; - break; - + return ENOTTY; } - return (error); } diff --git a/external/cddl/osnet/dev/dtrace/dtrace_sysctl.c b/external/cddl/osnet/dev/dtrace/dtrace_sysctl.c index 6bc1e9040989..f28432f6f498 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_sysctl.c +++ b/external/cddl/osnet/dev/dtrace/dtrace_sysctl.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_sysctl.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * @@ -23,9 +25,12 @@ */ int dtrace_debug = 0; +#if 0 TUNABLE_INT("debug.dtrace.debug", &dtrace_debug); SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RW, &dtrace_debug, 0, ""); +#endif +#if 0 /* XXX TBD sysctl */ /* Report registered DTrace providers. */ static int sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS) @@ -79,4 +84,4 @@ sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS) SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, CTLTYPE_STRING | CTLFLAG_RD, 0, 0, sysctl_dtrace_providers, "A", ""); - +#endif diff --git a/external/cddl/osnet/dev/dtrace/dtrace_test.c b/external/cddl/osnet/dev/dtrace/dtrace_test.c index 5c77b8d84ccc..213996b4d885 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_test.c +++ b/external/cddl/osnet/dev/dtrace/dtrace_test.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_test.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /*- * Copyright 2008 John Birrell * diff --git a/external/cddl/osnet/dev/dtrace/dtrace_unload.c b/external/cddl/osnet/dev/dtrace/dtrace_unload.c index daf20a2dd543..c64d3aa3dffb 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_unload.c +++ b/external/cddl/osnet/dev/dtrace/dtrace_unload.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_unload.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * @@ -22,29 +24,15 @@ * */ +extern int dtrace_probes_size; +extern int dtrace_helptrace_size; + static int dtrace_unload() { dtrace_state_t *state; int error = 0; -#if __FreeBSD_version < 800039 - /* - * Check if there is still an event handler callback - * registered. - */ - if (eh_tag != 0) { - /* De-register the device cloning event handler. */ - EVENTHANDLER_DEREGISTER(dev_clone, eh_tag); - eh_tag = 0; - - /* Stop device cloning. */ - clone_cleanup(&dtrace_clones); - } -#else - destroy_dev(dtrace_dev); -#endif - mutex_enter(&dtrace_provider_lock); mutex_enter(&dtrace_lock); mutex_enter(&cpu_lock); @@ -82,12 +70,12 @@ dtrace_unload() mutex_exit(&cpu_lock); if (dtrace_helptrace_enabled) { - kmem_free(dtrace_helptrace_buffer, 0); + kmem_free(dtrace_helptrace_buffer, dtrace_helptrace_size); dtrace_helptrace_buffer = NULL; } if (dtrace_probes != NULL) { - kmem_free(dtrace_probes, 0); + kmem_free(dtrace_probes, dtrace_probes_size); dtrace_probes = NULL; dtrace_nprobes = 0; } @@ -101,7 +89,7 @@ dtrace_unload() kmem_cache_destroy(dtrace_state_cache); - delete_unrhdr(dtrace_arena); + vmem_destroy(dtrace_arena); if (dtrace_toxrange != NULL) { kmem_free(dtrace_toxrange, 0); diff --git a/external/cddl/osnet/dev/dtrace/dtrace_vtime.c b/external/cddl/osnet/dev/dtrace/dtrace_vtime.c index 2e61a6a0e976..0866f5daea76 100644 --- a/external/cddl/osnet/dev/dtrace/dtrace_vtime.c +++ b/external/cddl/osnet/dev/dtrace/dtrace_vtime.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_vtime.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/dtrace/i386/dis_tables.c b/external/cddl/osnet/dev/dtrace/i386/dis_tables.c index 40b3963c58ae..ed744a0b1ab7 100644 --- a/external/cddl/osnet/dev/dtrace/i386/dis_tables.c +++ b/external/cddl/osnet/dev/dtrace/i386/dis_tables.c @@ -1,3 +1,5 @@ +/* $NetBSD: dis_tables.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/dtrace/i386/dis_tables.h b/external/cddl/osnet/dev/dtrace/i386/dis_tables.h index a72d5d663253..9e4632c4936e 100644 --- a/external/cddl/osnet/dev/dtrace/i386/dis_tables.h +++ b/external/cddl/osnet/dev/dtrace/i386/dis_tables.h @@ -1,3 +1,5 @@ +/* $NetBSD: dis_tables.h,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S b/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S index af2a2bcbf4d3..4d1139b9fe46 100644 --- a/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S +++ b/external/cddl/osnet/dev/dtrace/i386/dtrace_asm.S @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_asm.S,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * @@ -28,14 +30,10 @@ #define _ASM -#include #include #include +#include -#include "assym.s" - - .globl calltrap - .type calltrap,@function ENTRY(dtrace_invop_start) pushl %eax /* push %eax -- may be return value */ @@ -56,7 +54,7 @@ * those values. */ addl $12, %esp - ALTENTRY(dtrace_invop_callsite) +// ALTENTRY(dtrace_invop_callsite) cmpl $DTRACE_INVOP_PUSHL_EBP, %eax je invop_push cmpl $DTRACE_INVOP_POPL_EBP, %eax @@ -172,7 +170,19 @@ uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new) */ ENTRY(dtrace_cas32) - ALTENTRY(dtrace_casptr) + movl 4(%esp), %edx + movl 8(%esp), %eax + movl 12(%esp), %ecx + lock + cmpxchgl %ecx, (%edx) + ret + END(dtrace_cas32) + +/* +uint32_t dtrace_casptr(uint32_t *target, uint32_t cmp, uint32_t new) +*/ + + ENTRY(dtrace_casptr) movl 4(%esp), %edx movl 8(%esp), %eax movl 12(%esp), %ecx @@ -180,7 +190,7 @@ uint32_t dtrace_cas32(uint32_t *target, uint32_t cmp, uint32_t new) cmpxchgl %ecx, (%edx) ret END(dtrace_casptr) - END(dtrace_cas32) + /* uintptr_t dtrace_caller(int aframes) diff --git a/external/cddl/osnet/dev/dtrace/i386/dtrace_isa.c b/external/cddl/osnet/dev/dtrace/i386/dtrace_isa.c index 6d516170b8f5..b461a0042433 100644 --- a/external/cddl/osnet/dev/dtrace/i386/dtrace_isa.c +++ b/external/cddl/osnet/dev/dtrace/i386/dtrace_isa.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_isa.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * @@ -30,22 +32,28 @@ #include #include #include -#include -#include +//#include -#include -#include +//#include +//#include -#include -#include -#include +//#include +#include +#include -extern uintptr_t kernbase; -uintptr_t kernelbase = (uintptr_t) &kernbase; +uintptr_t kernelbase = (uintptr_t)KERNBASE; #define INKERNEL(va) (((vm_offset_t)(va)) >= USRSTACK && \ ((vm_offset_t)(va)) < VM_MAX_KERNEL_ADDRESS) +struct i386_frame { + struct i386_frame *f_frame; + int f_retaddr; + int f_arg0; +}; + +typedef unsigned long vm_offset_t; + uint8_t dtrace_fuword8_nocheck(void *); uint16_t dtrace_fuword16_nocheck(void *); uint32_t dtrace_fuword32_nocheck(void *); @@ -59,7 +67,11 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, register_t ebp; struct i386_frame *frame; vm_offset_t callpc; - pc_t caller = (pc_t) solaris_cpu[curcpu].cpu_dtrace_caller; +#if 0 /* XXX TBD needs solaris_cpu (for fbt) */ + pc_t caller = (pc_t) solaris_cpu[cpu_number()].cpu_dtrace_caller; +#else + pc_t caller = (pc_t) 0; +#endif if (intrpc != 0) pcstack[depth++] = (pc_t) intrpc; @@ -90,7 +102,7 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes, if (frame->f_frame <= frame || (vm_offset_t)frame->f_frame >= - (vm_offset_t)ebp + KSTACK_PAGES * PAGE_SIZE) + (vm_offset_t)ebp + KSTACK_SIZE) break; frame = frame->f_frame; } @@ -109,7 +121,7 @@ dtrace_getustack_common(uint64_t *pcstack, int pcstack_limit, uintptr_t pc, proc_t *p = curproc; uintptr_t oldcontext = lwp->lwp_oldcontext; volatile uint16_t *flags = - (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags; + (volatile uint16_t *)&cpu_core[cpu_number()].cpuc_dtrace_flags; size_t s1, s2; int ret = 0; @@ -186,7 +198,7 @@ dtrace_getupcstack(uint64_t *pcstack, int pcstack_limit) struct regs *rp; uintptr_t pc, sp; volatile uint16_t *flags = - (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags; + (volatile uint16_t *)&cpu_core[cpu_number()].cpuc_dtrace_flags; int n; if (*flags & CPU_DTRACE_FAULT) @@ -247,7 +259,7 @@ dtrace_getufpstack(uint64_t *pcstack, uint64_t *fpstack, int pcstack_limit) struct regs *rp; uintptr_t pc, sp, oldcontext; volatile uint16_t *flags = - (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags; + (volatile uint16_t *)&cpu_core[cpu_number()].cpuc_dtrace_flags; size_t s1, s2; if (*flags & CPU_DTRACE_FAULT) @@ -355,8 +367,9 @@ dtrace_getarg(int arg, int aframes) uintptr_t val; struct i386_frame *fp = (struct i386_frame *)dtrace_getfp(); uintptr_t *stack; - int i; +#if 0 /* XXX TBD needs ALTENTRY in dtrace_asm.S */ + int i; for (i = 1; i <= aframes; i++) { fp = fp->f_frame; @@ -372,8 +385,8 @@ dtrace_getarg(int arg, int aframes) stack = ((uintptr_t **)&fp[1])[1] + 1; goto load; } - } +#endif /* * We know that we did not come through a trap to get into @@ -414,7 +427,7 @@ dtrace_getstackdepth(int aframes) depth++; if (frame->f_frame <= frame || (vm_offset_t)frame->f_frame >= - (vm_offset_t)ebp + KSTACK_PAGES * PAGE_SIZE) + (vm_offset_t)ebp + KSTACK_SIZE) break; frame = frame->f_frame; } @@ -538,7 +551,7 @@ dtrace_copycheck(uintptr_t uaddr, uintptr_t kaddr, size_t size) if (uaddr + size >= kernelbase || uaddr + size < uaddr) { DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); - cpu_core[curcpu].cpuc_dtrace_illval = uaddr; + cpu_core[cpu_number()].cpuc_dtrace_illval = uaddr; return (0); } @@ -582,7 +595,7 @@ dtrace_fuword8(void *uaddr) { if ((uintptr_t)uaddr >= kernelbase) { DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); - cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr; + cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr; return (0); } return (dtrace_fuword8_nocheck(uaddr)); @@ -593,7 +606,7 @@ dtrace_fuword16(void *uaddr) { if ((uintptr_t)uaddr >= kernelbase) { DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); - cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr; + cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr; return (0); } return (dtrace_fuword16_nocheck(uaddr)); @@ -604,7 +617,7 @@ dtrace_fuword32(void *uaddr) { if ((uintptr_t)uaddr >= kernelbase) { DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); - cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr; + cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr; return (0); } return (dtrace_fuword32_nocheck(uaddr)); @@ -615,7 +628,7 @@ dtrace_fuword64(void *uaddr) { if ((uintptr_t)uaddr >= kernelbase) { DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); - cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr; + cpu_core[cpu_number()].cpuc_dtrace_illval = (uintptr_t)uaddr; return (0); } return (dtrace_fuword64_nocheck(uaddr)); diff --git a/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c b/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c index 53be57ba105f..0842efa63de4 100644 --- a/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c +++ b/external/cddl/osnet/dev/dtrace/i386/dtrace_subr.c @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace_subr.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * @@ -33,12 +35,18 @@ #include #include #include -#include +#include +#include +#include +//#include #include #include +#include #include #include -#include +#include +#include +#include extern uintptr_t kernelbase; extern uintptr_t dtrace_in_probe_addr; @@ -110,31 +118,32 @@ dtrace_toxic_ranges(void (*func)(uintptr_t base, uintptr_t limit)) (*func)(0, kernelbase); } +static void +xcall_func(void *arg0, void *arg1) +{ + dtrace_xcall_t func = arg0; + + (*func)(arg1); +} + void dtrace_xcall(processorid_t cpu, dtrace_xcall_t func, void *arg) { - cpumask_t cpus; + uint64_t where; - critical_enter(); + if (cpu == DTRACE_CPUALL) { + where = xc_broadcast(0, xcall_func, func, arg); + } else { + struct cpu_info *cinfo = cpu_lookup(cpu); - if (cpu == DTRACE_CPUALL) - cpus = all_cpus; - else - cpus = (cpumask_t) (1 << cpu); - - /* If the current CPU is in the set, call the function directly: */ - if ((cpus & (1 << curcpu)) != 0) { - (*func)(arg); - - /* Mask the current CPU from the set */ - cpus &= ~(1 << curcpu); + KASSERT(cinfo != NULL); + where = xc_unicast(0, xcall_func, func, arg, cinfo); } + xc_wait(where); - /* If there are any CPUs in the set, cross-call to those CPUs */ - if (cpus != 0) - smp_rendezvous_cpus(cpus, NULL, func, smp_no_rendevous_barrier, arg); - - critical_exit(); + /* XXX Q. Do we really need the other cpus to wait also? + * (see solaris:xc_sync()) + */ } static void @@ -365,12 +374,21 @@ dtrace_safe_defer_signal(void) static int64_t tgt_cpu_tsc; static int64_t hst_cpu_tsc; -static int64_t tsc_skew[MAXCPU]; +static int64_t tsc_skew[MAXCPUS]; static uint64_t nsec_scale; /* See below for the explanation of this macro. */ #define SCALE_SHIFT 28 +static __inline uint64_t +dtrace_rdtsc(void) +{ + uint64_t rv; + + __asm __volatile("rdtsc" : "=A" (rv)); + return (rv); +} + static void dtrace_gethrtime_init_sync(void *arg) { @@ -385,7 +403,7 @@ dtrace_gethrtime_init_sync(void *arg) if (cpu == curcpu) { int i; for (i = 0; i < 1000000000; i++) - tgt_cpu_tsc = rdtsc(); + tgt_cpu_tsc = dtrace_rdtsc(); tgt_cpu_tsc = 0; } #endif @@ -396,18 +414,19 @@ dtrace_gethrtime_init_cpu(void *arg) { uintptr_t cpu = (uintptr_t) arg; - if (cpu == curcpu) - tgt_cpu_tsc = rdtsc(); + if (cpu == cpu_number()) + tgt_cpu_tsc = dtrace_rdtsc(); else - hst_cpu_tsc = rdtsc(); + hst_cpu_tsc = dtrace_rdtsc(); } -static void +void dtrace_gethrtime_init(void *arg) { uint64_t tsc_f; - cpumask_t map; - int i; + CPU_INFO_ITERATOR cpuind; + struct cpu_info *cinfo = curcpu(); + cpuid_t cur_cpuid = cpu_number(); /* current cpu id */ /* * Get TSC frequency known at this moment. @@ -415,7 +434,7 @@ dtrace_gethrtime_init(void *arg) * Otherwise tick->time conversion will be inaccurate, but * will preserve monotonic property of TSC. */ - tsc_f = tsc_freq; + tsc_f = cpu_frequency(cinfo); /* * The following line checks that nsec_scale calculated below @@ -423,7 +442,8 @@ dtrace_gethrtime_init(void *arg) * another 32-bit integer without overflowing 64-bit. * Thus minimum supported TSC frequency is 62.5MHz. */ - KASSERT(tsc_f > (NANOSEC >> (32 - SCALE_SHIFT)), ("TSC frequency is too low")); + //KASSERT(tsc_f > (NANOSEC >> (32 - SCALE_SHIFT)), ("TSC frequency is too low")); + KASSERT(tsc_f > (NANOSEC >> (32 - SCALE_SHIFT))); /* * We scale up NANOSEC/tsc_f ratio to preserve as much precision @@ -437,8 +457,15 @@ dtrace_gethrtime_init(void *arg) nsec_scale = ((uint64_t)NANOSEC << SCALE_SHIFT) / tsc_f; /* The current CPU is the reference one. */ - tsc_skew[curcpu] = 0; + tsc_skew[cur_cpuid] = 0; + for (CPU_INFO_FOREACH(cpuind, cinfo)) { + /* use skew relative to cpu 0 */ + tsc_skew[cpu_index(cinfo)] = cinfo->ci_data.cpu_cc_skew; + } + + /* Already handled in x86/tsc.c for ci_data.cpu_cc_skew */ +#if 0 for (i = 0; i <= mp_maxid; i++) { if (i == curcpu) continue; @@ -456,10 +483,9 @@ dtrace_gethrtime_init(void *arg) tsc_skew[i] = tgt_cpu_tsc - hst_cpu_tsc; } +#endif } -SYSINIT(dtrace_gethrtime_init, SI_SUB_SMP, SI_ORDER_ANY, dtrace_gethrtime_init, NULL); - /* * DTrace needs a high resolution time function which can * be called from a probe context and guaranteed not to have @@ -480,7 +506,7 @@ dtrace_gethrtime() * (see nsec_scale calculations) taking into account 32-bit shift of * the higher half and finally add. */ - tsc = rdtsc() + tsc_skew[curcpu]; + tsc = dtrace_rdtsc() + tsc_skew[cpu_number()]; lo = tsc; hi = tsc >> 32; return (((lo * nsec_scale) >> SCALE_SHIFT) + @@ -498,6 +524,8 @@ dtrace_gethrestime(void) int dtrace_trap(struct trapframe *frame, u_int type) { + cpuid_t cpuid = cpu_number(); /* current cpu id */ + /* * A trap can occur while DTrace executes a probe. Before * executing the probe, DTrace blocks re-scheduling and sets @@ -508,7 +536,7 @@ dtrace_trap(struct trapframe *frame, u_int type) * Check if DTrace has enabled 'no-fault' mode: * */ - if ((cpu_core[curcpu].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) { + if ((cpu_core[cpuid].cpuc_dtrace_flags & CPU_DTRACE_NOFAULT) != 0) { /* * There are only a couple of trap types that are expected. * All the rest will be handled in the usual way. @@ -517,7 +545,7 @@ dtrace_trap(struct trapframe *frame, u_int type) /* General protection fault. */ case T_PROTFLT: /* Flag an illegal operation. */ - cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP; + cpu_core[cpuid].cpuc_dtrace_flags |= CPU_DTRACE_ILLOP; /* * Offset the instruction pointer to the instruction @@ -528,8 +556,8 @@ dtrace_trap(struct trapframe *frame, u_int type) /* Page fault. */ case T_PAGEFLT: /* Flag a bad address. */ - cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR; - cpu_core[curcpu].cpuc_dtrace_illval = rcr2(); + cpu_core[cpuid].cpuc_dtrace_flags |= CPU_DTRACE_BADADDR; + cpu_core[cpuid].cpuc_dtrace_illval = rcr2(); /* * Offset the instruction pointer to the instruction diff --git a/external/cddl/osnet/dev/dtrace/i386/instr_size.c b/external/cddl/osnet/dev/dtrace/i386/instr_size.c index 21cb0460a63f..b81e03454124 100644 --- a/external/cddl/osnet/dev/dtrace/i386/instr_size.c +++ b/external/cddl/osnet/dev/dtrace/i386/instr_size.c @@ -1,3 +1,5 @@ +/* $NetBSD: instr_size.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/fbt/fbt.c b/external/cddl/osnet/dev/fbt/fbt.c index aae5cd62c2b5..ef3239319136 100644 --- a/external/cddl/osnet/dev/fbt/fbt.c +++ b/external/cddl/osnet/dev/fbt/fbt.c @@ -1,3 +1,5 @@ +/* $NetBSD: fbt.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/lockstat/lockstat.c b/external/cddl/osnet/dev/lockstat/lockstat.c index 9dc82e2d651b..2a4b60e8a316 100644 --- a/external/cddl/osnet/dev/lockstat/lockstat.c +++ b/external/cddl/osnet/dev/lockstat/lockstat.c @@ -1,3 +1,5 @@ +/* $NetBSD: lockstat.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/profile/profile.c b/external/cddl/osnet/dev/profile/profile.c index 309b0b345755..44fa488b4434 100644 --- a/external/cddl/osnet/dev/profile/profile.c +++ b/external/cddl/osnet/dev/profile/profile.c @@ -1,3 +1,5 @@ +/* $NetBSD: profile.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/prototype.c b/external/cddl/osnet/dev/prototype.c index 469e62cc4d47..6c7f8c28a087 100644 --- a/external/cddl/osnet/dev/prototype.c +++ b/external/cddl/osnet/dev/prototype.c @@ -1,3 +1,5 @@ +/* $NetBSD: prototype.c,v 1.2 2010/02/21 01:46:32 darran Exp $ */ + /* * This file is freeware. You are free to use it and add your own * license. diff --git a/external/cddl/osnet/dev/sdt/sdt.c b/external/cddl/osnet/dev/sdt/sdt.c index 5c8f0fe9c6d5..88da7fd3bc0d 100644 --- a/external/cddl/osnet/dev/sdt/sdt.c +++ b/external/cddl/osnet/dev/sdt/sdt.c @@ -1,3 +1,5 @@ +/* $NetBSD: sdt.c,v 1.2 2010/02/21 01:46:33 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dev/systrace/systrace.c b/external/cddl/osnet/dev/systrace/systrace.c index 9eb1f235810c..77b70071d533 100644 --- a/external/cddl/osnet/dev/systrace/systrace.c +++ b/external/cddl/osnet/dev/systrace/systrace.c @@ -1,3 +1,5 @@ +/* $NetBSD: systrace.c,v 1.2 2010/02/21 01:46:34 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/dist/common/ctf/ctf_create.c b/external/cddl/osnet/dist/common/ctf/ctf_create.c index a4f3df34e8cf..511fecfc1708 100644 --- a/external/cddl/osnet/dist/common/ctf/ctf_create.c +++ b/external/cddl/osnet/dist/common/ctf/ctf_create.c @@ -60,10 +60,10 @@ ctf_create(int *errp) if (hash == NULL) return (ctf_set_open_errno(errp, EAGAIN)); - cts.cts_name = _CTF_SECTION; + cts.cts_name = (char *)_CTF_SECTION; cts.cts_type = SHT_PROGBITS; cts.cts_flags = 0; - cts.cts_data = &hdr; + cts.cts_data = (ctf_header_t *)&hdr; cts.cts_size = sizeof (hdr); cts.cts_entsize = 1; cts.cts_offset = 0; @@ -364,7 +364,7 @@ ctf_update(ctf_file_t *fp) * is successful, we then switch nfp and fp and free the old container. */ ctf_data_protect(buf, size); - cts.cts_name = _CTF_SECTION; + cts.cts_name = (char *)_CTF_SECTION; cts.cts_type = SHT_PROGBITS; cts.cts_flags = 0; cts.cts_data = buf; diff --git a/external/cddl/osnet/dist/common/ctf/ctf_open.c b/external/cddl/osnet/dist/common/ctf/ctf_open.c index e49a4cb32934..8255bafff904 100644 --- a/external/cddl/osnet/dist/common/ctf/ctf_open.c +++ b/external/cddl/osnet/dist/common/ctf/ctf_open.c @@ -694,11 +694,11 @@ ctf_bufopen(const ctf_sect_t *ctfsect, const ctf_sect_t *symsect, fp->ctf_strtab.cts_name = ctf_strdup(fp->ctf_strtab.cts_name); if (fp->ctf_data.cts_name == NULL) - fp->ctf_data.cts_name = _CTF_NULLSTR; + fp->ctf_data.cts_name = (char *)_CTF_NULLSTR; if (fp->ctf_symtab.cts_name == NULL) - fp->ctf_symtab.cts_name = _CTF_NULLSTR; + fp->ctf_symtab.cts_name = (char *)_CTF_NULLSTR; if (fp->ctf_strtab.cts_name == NULL) - fp->ctf_strtab.cts_name = _CTF_NULLSTR; + fp->ctf_strtab.cts_name = (char *)_CTF_NULLSTR; fp->ctf_str[CTF_STRTAB_0].cts_strs = (const char *)buf + hp.cth_stroff; fp->ctf_str[CTF_STRTAB_0].cts_len = hp.cth_strlen; diff --git a/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c b/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c index 6cd003663cac..0df71d32c0f0 100644 --- a/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c +++ b/external/cddl/osnet/dist/lib/libctf/common/ctf_lib.c @@ -252,7 +252,7 @@ ctf_fdopen(int fd, int *errp) if (ctfsect.cts_data == MAP_FAILED) return (ctf_set_open_errno(errp, errno)); - ctfsect.cts_name = _CTF_SECTION; + ctfsect.cts_name = (char *)_CTF_SECTION; ctfsect.cts_type = SHT_PROGBITS; ctfsect.cts_flags = SHF_ALLOC; ctfsect.cts_size = (size_t)st.st_size; diff --git a/external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c b/external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c index ac32f769a934..949d2dfe4dc0 100644 --- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c +++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_aggregate.c @@ -251,6 +251,7 @@ dt_aggregate_quantizedcmp(int64_t *lhs, int64_t *rhs) static void dt_aggregate_usym(dtrace_hdl_t *dtp, uint64_t *data) { +#if 0 /* XXX TBD needs libproc */ uint64_t pid = data[0]; uint64_t *pc = &data[1]; struct ps_prochandle *P; @@ -273,11 +274,15 @@ dt_aggregate_usym(dtrace_hdl_t *dtp, uint64_t *data) dt_proc_unlock(dtp, P); dt_proc_release(dtp, P); +#else + printf("XXX %s not implemented\n", __func__); +#endif } static void dt_aggregate_umod(dtrace_hdl_t *dtp, uint64_t *data) { +#if 0 /* XXX TBD needs libproc */ uint64_t pid = data[0]; uint64_t *pc = &data[1]; struct ps_prochandle *P; @@ -300,6 +305,9 @@ dt_aggregate_umod(dtrace_hdl_t *dtp, uint64_t *data) dt_proc_unlock(dtp, P); dt_proc_release(dtp, P); +#else + printf("XXX %s not implemented\n", __func__); +#endif } static void diff --git a/external/cddl/osnet/dist/lib/libdtrace/common/dt_consume.c b/external/cddl/osnet/dist/lib/libdtrace/common/dt_consume.c index 776fd17c0309..f79d07119d00 100644 --- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_consume.c +++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_consume.c @@ -905,6 +905,7 @@ int dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr, uint64_t arg) { +#if 0 /* XXX TBD needs libproc */ /* LINTED - alignment */ uint64_t *pc = (uint64_t *)addr; uint32_t depth = DTRACE_USTACK_NFRAMES(arg); @@ -1048,11 +1049,16 @@ dt_print_ustack(dtrace_hdl_t *dtp, FILE *fp, const char *format, } return (err); +#else + printf("XXX %s not implemented\n", __func__); + return ENODEV; +#endif } static int dt_print_usym(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, dtrace_actkind_t act) { +#if 0 /* XXX TBD needs libproc */ /* LINTED - alignment */ uint64_t pid = ((uint64_t *)addr)[0]; /* LINTED - alignment */ @@ -1088,11 +1094,16 @@ dt_print_usym(dtrace_hdl_t *dtp, FILE *fp, caddr_t addr, dtrace_actkind_t act) } while ((len = dtrace_uaddr2str(dtp, pid, pc, s, n)) >= n); return (dt_printf(dtp, fp, format, s)); +#else + printf("XXX %s not implemented\n", __func__); + return ENODEV; +#endif } int dt_print_umod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr) { +#if 0 /* XXX TBD needs libproc */ /* LINTED - alignment */ uint64_t pid = ((uint64_t *)addr)[0]; /* LINTED - alignment */ @@ -1135,6 +1146,10 @@ dt_print_umod(dtrace_hdl_t *dtp, FILE *fp, const char *format, caddr_t addr) } return (err); +#else + printf("XXX %s not implemented\n", __func__); + return -1; +#endif } int diff --git a/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c b/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c index af175012b3be..c81c5382ac15 100644 --- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c +++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c @@ -25,6 +25,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" +#define ELFSIZE ARCH_ELFSIZE /* XXX debug */ #include #if defined(sun) #include @@ -37,6 +38,7 @@ #include #include #include +#include #endif #include @@ -825,11 +827,7 @@ dt_module_modelname(dt_module_t *dmp) * including the path. */ static void -#if defined(sun) dt_module_update(dtrace_hdl_t *dtp, const char *name) -#else -dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) -#endif { char fname[MAXPATHLEN]; struct stat64 st; @@ -847,11 +845,38 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) "%s/%s/object", OBJFS_ROOT, name); #else GElf_Phdr ph; - char name[MAXPATHLEN]; - int i = 0; + int i; + int mib_osrel[2] = { CTL_KERN, KERN_OSRELEASE }; + int mib_mach[2] = { CTL_HW, HW_MACHINE }; + char osrel[64]; + char machine[64]; + size_t len; - (void) strlcpy(name, k_stat->name, sizeof(name)); - (void) strlcpy(fname, k_stat->pathname, sizeof(fname)); + printf("dt_module_update: %s\n", name); /* XXX debug */ + + if (strcmp("netbsd",name) == 0) { + /* want the kernel */ + strncpy(fname, "/netbsd", sizeof(fname)); + } else { + + /* build stand module path from system */ + len = sizeof(osrel); + if (sysctl(mib_osrel, 2, osrel, &len, NULL, 0) == -1) { + dt_dprintf("sysctl osrel failed: %s\n", + strerror(errno)); + return; + } + + len = sizeof(machine); + if (sysctl(mib_mach, 2, machine, &len, NULL, 0) == -1) { + dt_dprintf("sysctl machine failed: %s\n", + strerror(errno)); + return; + } + + (void) snprintf(fname, sizeof (fname), + "/stand/%s/%s/%s.kmod", machine, osrel, name, name); + } #endif if ((fd = open(fname, O_RDONLY)) == -1 || fstat64(fd, &st) == -1 || @@ -928,6 +953,7 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) dmp->dm_modid = (int)OBJFS_MODID(st.st_ino); #else #if defined(__i386__) +#if 0 /* XXX TBD needs module support */ /* * Find the first load section and figure out the relocation * offset for the symbols. The kernel module will not need @@ -940,6 +966,7 @@ dt_module_update(dtrace_hdl_t *dtp, struct kld_file_stat *k_stat) } } #endif +#endif #endif if (dmp->dm_info.objfs_info_primary) @@ -993,6 +1020,9 @@ dtrace_update(dtrace_hdl_t *dtp) if (kldstat(fileid, &k_stat) == 0) dt_module_update(dtp, &k_stat); } +#else + /* XXX just the kernel for now */ + dt_module_update(dtp, "netbsd"); #endif /* diff --git a/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c b/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c index 483082268a31..df038607ae5b 100644 --- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c +++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_open.c @@ -788,9 +788,11 @@ _dtrace_init(void) } #endif #if defined(__i386__) +#if 0 /* XXX TBD - no NetBSD equivalent? */ /* make long doubles 64 bits -sson */ (void) fpsetprec(FP_PE); #endif +#endif } static dtrace_hdl_t * @@ -1233,6 +1235,7 @@ alloc: int i; size_t len = sizeof(bootfile); +#if 0 /* XXX debug */ /* This call shouldn't fail, but use a default just in case. */ if (sysctlbyname("kern.bootfile", bootfile, &len, NULL, 0) != 0) strlcpy(bootfile, "kernel", sizeof(bootfile)); @@ -1241,6 +1244,9 @@ alloc: p++; else p = bootfile; +#else + p = "netbsd"; +#endif /* * Format the global variables based on the kernel module name. diff --git a/external/cddl/osnet/dist/lib/libdtrace/common/dt_options.c b/external/cddl/osnet/dist/lib/libdtrace/common/dt_options.c index fa1407f83c12..89c6b4792593 100644 --- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_options.c +++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_options.c @@ -790,6 +790,8 @@ dt_options_load(dtrace_hdl_t *dtp) size_t offs; int i; + printf("dt_options_load() entry \n"); /* XXX debug */ + /* * To load the option values, we need to ask the kernel to provide its * DOF, which we'll sift through to look for OPTDESC sections. @@ -845,6 +847,7 @@ dt_options_load(dtrace_hdl_t *dtp) dtp->dt_options[opt->dofo_option] = opt->dofo_value; } + printf("dt_options_load() exit \n"); /* XXX debug */ return (0); } diff --git a/external/cddl/osnet/dist/lib/libdtrace/common/dt_pid.c b/external/cddl/osnet/dist/lib/libdtrace/common/dt_pid.c index 5640b4af053d..16c019e8f83f 100644 --- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_pid.c +++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_pid.c @@ -108,6 +108,7 @@ dt_pid_error(dtrace_hdl_t *dtp, dt_pcb_t *pcb, dt_proc_t *dpr, static int dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func) { +#if 0 /* XXX TBD needs libproc */ dtrace_hdl_t *dtp = pp->dpp_dtp; dt_pcb_t *pcb = pp->dpp_pcb; dt_proc_t *dpr = pp->dpp_dpr; @@ -223,6 +224,10 @@ dt_pid_per_sym(dt_pid_probe_t *pp, const GElf_Sym *symp, const char *func) dt_free(dtp, ftp); return (0); +#else + printf("XXX %s not implemented\n", __func__); + return ENODEV; +#endif } static int @@ -263,6 +268,7 @@ dt_pid_sym_filt(void *arg, const GElf_Sym *symp, const char *func) static int dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj) { +#if 0 /* XXX TBD needs libproc */ dt_pid_probe_t *pp = arg; dtrace_hdl_t *dtp = pp->dpp_dtp; dt_pcb_t *pcb = pp->dpp_pcb; @@ -421,6 +427,10 @@ dt_pid_per_mod(void *arg, const prmap_t *pmp, const char *obj) } return (0); +#else + printf("XXX %s not implemented\n", __func__); + return ENODEV; +#endif } static int @@ -507,6 +517,7 @@ static int dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb, dt_proc_t *dpr) { +#if 0 /* XXX TBD needs libproc */ dt_pid_probe_t pp; int ret = 0; @@ -588,11 +599,16 @@ dt_pid_create_pid_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, #endif return (ret); +#else + printf("XXX %s not implemented\n", __func__); + return ENODEV; +#endif } static int dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) { +#if 0 /* XXX TBD needs libproc */ struct ps_prochandle *P = data; GElf_Sym sym; #if defined(sun) @@ -664,12 +680,17 @@ dt_pid_usdt_mapping(void *data, const prmap_t *pmp, const char *oname) #endif return (0); +#else + printf("XXX %s not implemented\n", __func__); + return ENODEV; +#endif } static int dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb, dt_proc_t *dpr) { +#if 0 /* XXX TBD needs libproc */ struct ps_prochandle *P = dpr->dpr_proc; int ret = 0; @@ -695,6 +716,10 @@ dt_pid_create_usdt_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, (void) dt_pid_fix_mod(pdp, P); return (ret); +#else + printf("XXX %s not implemented\n", __func__); + return ENODEV; +#endif } static pid_t @@ -730,6 +755,7 @@ dt_pid_get_pid(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb, int dt_pid_create_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb) { +#if 0 /* XXX TBD needs libproc */ char provname[DTRACE_PROVNAMELEN]; struct ps_prochandle *P; dt_proc_t *dpr; @@ -804,6 +830,10 @@ dt_pid_create_probes(dtrace_probedesc_t *pdp, dtrace_hdl_t *dtp, dt_pcb_t *pcb) } return (err ? -1 : 0); +#else + printf("XXX %s not implemented\n", __func__); + return -1; +#endif } int diff --git a/external/cddl/osnet/dist/lib/libdtrace/common/dt_proc.c b/external/cddl/osnet/dist/lib/libdtrace/common/dt_proc.c index f420a0c2b3ca..d1b4a6d5c149 100644 --- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_proc.c +++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_proc.c @@ -91,6 +91,89 @@ #include #include +/* XXX TBD needs libproc */ +/* Stub proc functions for now */ +int +proc_setflags(struct proc_handle *phdl, int mask) +{ + + printf("dtrace: XXX %s not implemented\n", __func__); + return EINVAL; +} + +int +proc_create(const char *file, char * const *argv, proc_child_func *pcf, + void *child_arg, struct proc_handle **pphdl) +{ + + printf("dtrace: XXX %s not implemented\n", __func__); + return EINVAL; +} + +int +proc_detach(struct proc_handle *phdl) +{ + + printf("dtrace: XXX %s not implemented\n", __func__); + return EINVAL; +} + +int +proc_getflags(struct proc_handle *phdl) +{ + + printf("dtrace: XXX %s not implemented\n", __func__); + return -1; +} + +int +proc_wait(struct proc_handle *phdl) +{ + + printf("dtrace: XXX %s not implemented\n", __func__); + return EINVAL; +} + +pid_t +proc_getpid(struct proc_handle *phdl) +{ + + printf("dtrace: XXX %s not implemented\n", __func__); + return -1; +} + +int +proc_attach(pid_t pid, int flags, struct proc_handle **pphdl) +{ + + printf("dtrace: XXX %s not implemented\n", __func__); + return EINVAL; +} + +int +proc_state(struct proc_handle *phdl) +{ + + printf("dtrace: XXX %s not implemented\n", __func__); + return -1; +} + +int +proc_clearflags(struct proc_handle *phdl, int mask) +{ + + printf("dtrace: XXX %s not implemented\n", __func__); + return EINVAL; +} + +int +proc_continue(struct proc_handle *phdl) +{ + + printf("dtrace: XXX %s not implemented\n", __func__); + return EINVAL; +} + #define IS_SYS_EXEC(w) (w == SYS_exec || w == SYS_execve) #define IS_SYS_FORK(w) (w == SYS_vfork || w == SYS_fork1 || \ w == SYS_forkall || w == SYS_forksys) diff --git a/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c b/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c index 12f186ae51fd..8e1c502c6f3e 100644 --- a/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c +++ b/external/cddl/osnet/dist/lib/libdtrace/common/dt_subr.c @@ -948,6 +948,7 @@ int dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid, uint64_t addr, char *str, int nbytes) { +#if 0 /* XXX TBD needs libproc */ char name[PATH_MAX], objname[PATH_MAX], c[PATH_MAX * 2]; struct ps_prochandle *P = NULL; GElf_Sym sym; @@ -994,4 +995,8 @@ dtrace_uaddr2str(dtrace_hdl_t *dtp, pid_t pid, dt_proc_release(dtp, P); return (dt_string2str(c, str, nbytes)); +#else + printf("XXX %s not implemented\n", __func__); + return 0; +#endif } diff --git a/external/cddl/osnet/dist/lib/libdtrace/common/dtrace.h b/external/cddl/osnet/dist/lib/libdtrace/common/dtrace.h index 00b32eebf07a..719ae18d70ce 100644 --- a/external/cddl/osnet/dist/lib/libdtrace/common/dtrace.h +++ b/external/cddl/osnet/dist/lib/libdtrace/common/dtrace.h @@ -30,6 +30,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include +typedef processorid_t test_processor_id_t; #include #include #include diff --git a/external/cddl/osnet/dist/tools/ctf/cvt/alist.c b/external/cddl/osnet/dist/tools/ctf/cvt/alist.c index 8e776dc08a7f..3fa8eae8c65a 100644 --- a/external/cddl/osnet/dist/tools/ctf/cvt/alist.c +++ b/external/cddl/osnet/dist/tools/ctf/cvt/alist.c @@ -33,6 +33,7 @@ #include #include +#include #include "alist.h" #include "memory.h" diff --git a/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c b/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c index 546dcdfc9386..bfc8c95a753e 100644 --- a/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c +++ b/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.c @@ -364,7 +364,7 @@ wip_save_work(workqueue_t *wq, wip_t *slot, int slotnum) pthread_mutex_lock(&wq->wq_donequeue_lock); while (wq->wq_lastdonebatch + 1 < slot->wip_batchid) - pthread_cond_wait(&slot->wip_cv, &wq->wq_donequeue_lock); + pthread_cond_wait(&slot->wip_cv, &wq->wq_donequeue_lock); assert(wq->wq_lastdonebatch + 1 == slot->wip_batchid); fifo_add(wq->wq_donequeue, slot->wip_td); @@ -650,6 +650,7 @@ wq_init(workqueue_t *wq, int nfiles) wq->wq_wip = xcalloc(sizeof (wip_t) * nslots); wq->wq_nwipslots = nslots; wq->wq_nthreads = MIN(sysconf(_SC_NPROCESSORS_ONLN) * 3 / 2, nslots); + wq->wq_thread = xmalloc(sizeof (pthread_t) * wq->wq_nthreads); if (getenv("CTFMERGE_INPUT_THROTTLE")) throttle = atoi(getenv("CTFMERGE_INPUT_THROTTLE")); @@ -664,6 +665,7 @@ wq_init(workqueue_t *wq, int nfiles) for (i = 0; i < nslots; i++) { pthread_mutex_init(&wq->wq_wip[i].wip_lock, NULL); + pthread_cond_init(&wq->wq_wip[i].wip_cv, NULL); wq->wq_wip[i].wip_batchid = wq->wq_next_batchid++; } @@ -703,8 +705,8 @@ start_threads(workqueue_t *wq) pthread_sigmask(SIG_BLOCK, &sets, NULL); for (i = 0; i < wq->wq_nthreads; i++) { - pthread_create(&thrid, NULL, (void *(*)(void *))worker_thread, - wq); + pthread_create(&wq->wq_thread[i], NULL, + (void *(*)(void *))worker_thread, wq); } #if defined(sun) @@ -719,6 +721,17 @@ start_threads(workqueue_t *wq) pthread_sigmask(SIG_UNBLOCK, &sets, NULL); } +static void +join_threads(workqueue_t *wq) +{ + int i; + + for (i = 0; i < wq->wq_nthreads; i++) { + pthread_join(wq->wq_thread[i], NULL); + } +} + + static int strcompare(const void *p1, const void *p2) { @@ -728,10 +741,18 @@ strcompare(const void *p1, const void *p2) return (strcmp(s1, s2)); } +/* + * Core work queue structure; passed to worker threads on thread creation + * as the main point of coordination. Allocate as a static structure; we + * could have put this into a local variable in main, but passing a pointer + * into your stack to another thread is fragile at best and leads to some + * hard-to-debug failure modes. + */ +static workqueue_t wq; + int main(int argc, char **argv) { - workqueue_t wq; tdata_t *mstrtd, *savetd; char *uniqfile = NULL, *uniqlabel = NULL; char *withfile = NULL; @@ -913,6 +934,8 @@ main(int argc, char **argv) pthread_cond_wait(&wq.wq_alldone_cv, &wq.wq_queue_lock); pthread_mutex_unlock(&wq.wq_queue_lock); + join_threads(&wq); + /* * All requested files have been merged, with the resulting tree in * mstrtd. savetd is the tree that will be placed into the output file. diff --git a/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.h b/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.h index 38560eab6446..45ae37bfc35c 100644 --- a/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.h +++ b/external/cddl/osnet/dist/tools/ctf/cvt/ctfmerge.h @@ -78,6 +78,8 @@ typedef struct workqueue { int wq_nomorefiles; + pthread_t *wq_thread; + barrier_t wq_bar1; barrier_t wq_bar2; } workqueue_t; diff --git a/external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c b/external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c index 19aeff2c7942..9fc85c7ad944 100644 --- a/external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c +++ b/external/cddl/osnet/dist/tools/ctf/cvt/dwarf.c @@ -1043,7 +1043,16 @@ die_sou_resolve(tdesc_t *tdp, tdesc_t **tdpp __unused, void *private) continue; if (mt->t_type == ARRAY && mt->t_ardef->ad_nelems == 0) continue; + if (mt->t_type == STRUCT && + mt->t_members != NULL && + mt->t_members->ml_type->t_type == ARRAY && + mt->t_members->ml_type->t_ardef->ad_nelems == 0) { + /* struct with zero sized array */ + continue; + } + printf("%s unresolved type = %d (%s)\n", tdesc_name(tdp), + mt->t_type, tdesc_name(mt)); dw->dw_nunres++; return (1); } @@ -1798,8 +1807,13 @@ dw_read(tdata_t *td, Elf *elf, char *filename __unused) } if ((rc = dwarf_next_cu_header(dw.dw_dw, &hdrlen, &vers, &abboff, - &addrsz, &nxthdr, &dw.dw_err)) != DW_DLV_OK) + &addrsz, &nxthdr, &dw.dw_err)) != DW_DLV_OK) { + if (rc == DW_DLV_NO_ENTRY) { + /* no compilation unit in the DWARF section */ + return 0; + } terminate("rc = %d %s\n", rc, dwarf_errmsg(&dw.dw_err)); + } if ((cu = die_sibling(&dw, NULL)) == NULL) terminate("file does not contain dwarf type data " diff --git a/external/cddl/osnet/dist/tools/ctf/cvt/output.c b/external/cddl/osnet/dist/tools/ctf/cvt/output.c index ae8c5945c8ef..1ea7441eee85 100644 --- a/external/cddl/osnet/dist/tools/ctf/cvt/output.c +++ b/external/cddl/osnet/dist/tools/ctf/cvt/output.c @@ -472,7 +472,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname, int pad; int i; - if (gelf_newehdr(dst, gelf_getclass(src)) == NULL) + if (gelf_newehdr(dst, gelf_getclass(src)) == 0) elfterminate(dstname, "Cannot copy ehdr to temp file"); gelf_getehdr(src, &sehdr); memcpy(&dehdr, &sehdr, sizeof (GElf_Ehdr)); @@ -488,7 +488,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname, */ if (sehdr.e_phnum != 0) { (void) elf_flagelf(dst, ELF_C_SET, ELF_F_LAYOUT); - if (gelf_newphdr(dst, sehdr.e_phnum) == NULL) + if (gelf_newphdr(dst, sehdr.e_phnum) == 0) elfterminate(dstname, "Cannot make phdrs in temp file"); for (i = 0; i < sehdr.e_phnum; i++) { @@ -579,8 +579,9 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname, elfterminate(dstname, "Cannot update sect %s", sname); #endif - if ((sdata = elf_getdata(sscn, NULL)) == NULL) + if ((sdata = elf_getdata(sscn, NULL)) == NULL) { elfterminate(srcname, "Cannot get sect %s data", sname); + } if ((ddata = elf_newdata(dscn)) == NULL) elfterminate(dstname, "Can't make sect %s data", sname); #if defined(sun) @@ -644,7 +645,7 @@ write_file(Elf *src, const char *srcname, Elf *dst, const char *dstname, } #if !defined(sun) - if (ddata->d_buf == NULL) { + if ((ddata->d_buf == NULL) && (sdata->d_buf != NULL)) { ddata->d_buf = xmalloc(shdr.sh_size); bcopy(sdata->d_buf, ddata->d_buf, shdr.sh_size); } diff --git a/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c b/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c index bf385778f909..7629a7d30f04 100644 --- a/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c +++ b/external/cddl/osnet/dist/uts/common/dtrace/dtrace.c @@ -67,15 +67,21 @@ * [Group] Functions", allowing one to find each block by searching forward * on capital-f functions. */ +#if !defined(sun) +/* we need internal access to mutexes for state inspection */ +#define __MUTEX_PRIVATE +#define __RWLOCK_PRIVATE +#endif + #include #if !defined(sun) #include #endif #include -#include #include #include #if defined(sun) +#include #include #include #endif @@ -88,10 +94,8 @@ #include #include #include -#if defined(sun) #include #include -#endif #include #if defined(sun) #include @@ -113,18 +117,24 @@ /* FreeBSD includes: */ #if !defined(sun) + #include #include #include -#include +//#include #include #include #include #include #include #include -#include +//#include +#include +#include #include +#include +#include +#include #include #include "dtrace_cddl.h" #include "dtrace_debug.c" @@ -161,7 +171,7 @@ dtrace_optval_t dtrace_helper_actions_max = 32; dtrace_optval_t dtrace_helper_providers_max = 32; dtrace_optval_t dtrace_dstate_defsize = (1 * 1024 * 1024); size_t dtrace_strsize_default = 256; -dtrace_optval_t dtrace_cleanrate_default = 9900990; /* 101 hz */ +dtrace_optval_t dtrace_cleanrate_default = 99009900; /* 101 hz */ dtrace_optval_t dtrace_cleanrate_min = 200000; /* 5000 hz */ dtrace_optval_t dtrace_cleanrate_max = (uint64_t)60 * NANOSEC; /* 1/minute */ dtrace_optval_t dtrace_aggrate_default = NANOSEC; /* 1 hz */ @@ -200,14 +210,13 @@ const char dtrace_zero[256] = { 0 }; /* zero-filled memory */ #if defined(sun) static dev_info_t *dtrace_devi; /* device info */ #endif -#if defined(sun) static vmem_t *dtrace_arena; /* probe ID arena */ +#if defined(sun) static vmem_t *dtrace_minor; /* minor number arena */ static taskq_t *dtrace_taskq; /* task queue */ -#else -static struct unrhdr *dtrace_arena; /* Probe ID number. */ #endif static dtrace_probe_t **dtrace_probes; /* array of all probes */ +int dtrace_probes_size=0; /* size for kmem_free */ static int dtrace_nprobes; /* number of probes */ static dtrace_provider_t *dtrace_provider; /* provider list */ static dtrace_meta_t *dtrace_meta_pid; /* user-land meta provider */ @@ -232,12 +241,15 @@ static dtrace_helpers_t *dtrace_deferred_pid; /* deferred helper list */ static dtrace_enabling_t *dtrace_retained; /* list of retained enablings */ static dtrace_dynvar_t dtrace_dynhash_sink; /* end of dynamic hash chains */ #if !defined(sun) -static struct mtx dtrace_unr_mtx; -MTX_SYSINIT(dtrace_unr_mtx, &dtrace_unr_mtx, "Unique resource identifier", MTX_DEF); int dtrace_in_probe; /* non-zero if executing a probe */ #if defined(__i386__) || defined(__amd64__) uintptr_t dtrace_in_probe_addr; /* Address of invop when already in probe */ #endif + +kmutex_t dtrace_deadman_mutex; +void *dtrace_deadman_wchan; +int dtrace_deadman_alive; /* deadman thread keep alive */ +lwp_t *dtrace_deadman_proc; #endif /* @@ -283,9 +295,10 @@ static kmutex_t mod_lock; #define ipaddr_t in_addr_t #define mod_modname pathname #define vuprintf vprintf -#define ttoproc(_a) ((_a)->td_proc) +#define ttoproc(_a) ((_a)->l_proc) #define crgetzoneid(_a) 0 -#define NCPU MAXCPU +//#define NCPU MAXCPUS +#define NCPU ncpu #define SNOCD 0 #define CPU_ON_INTR(_a) 0 @@ -297,11 +310,13 @@ static kmutex_t mod_lock; #define PRIV_PROC_ZONE (1 << 5) #define PRIV_ALL ~0 -SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace Information"); +//SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace Information"); #endif #if defined(sun) -#define curcpu CPU->cpu_id +#define curcpu_id CPU->cpu_id +#else +#define curcpu_id cpu_number() #endif @@ -325,7 +340,11 @@ dtrace_nullop(void) static dtrace_pops_t dtrace_provider_ops = { (void (*)(void *, dtrace_probedesc_t *))dtrace_nullop, +#if defined(sun) (void (*)(void *, modctl_t *))dtrace_nullop, +#else + (void (*)(void *, dtrace_modctl_t *))dtrace_nullop, +#endif (void (*)(void *, dtrace_id_t, void *))dtrace_nullop, (void (*)(void *, dtrace_id_t, void *))dtrace_nullop, (void (*)(void *, dtrace_id_t, void *))dtrace_nullop, @@ -422,16 +441,25 @@ static kmutex_t dtrace_errlock; } #else #define DTRACE_TLS_THRKEY(where) { \ - solaris_cpu_t *_c = &solaris_cpu[curcpu]; \ + uint_t intr = 0; \ + (where) = ((curthread->l_lid + (curthread->l_proc->p_pid << 16) + \ + DIF_VARIABLE_MAX) & \ + (((uint64_t)1 << 61) - 1)) | ((uint64_t)intr << 61); \ +} +#if 0 +#define DTRACE_TLS_THRKEY(where) { \ + solaris_cpu_t *_c = &solaris_cpu[curcpu_id]; \ uint_t intr = 0; \ uint_t actv = _c->cpu_intr_actv; \ for (; actv; actv >>= 1) \ intr++; \ ASSERT(intr < (1 << 3)); \ - (where) = ((curthread->td_tid + DIF_VARIABLE_MAX) & \ - (((uint64_t)1 << 61) - 1)) | ((uint64_t)intr << 61); \ + (where) = ((curthread->l_lid + (curthread->l_proc->p_pid << 16) + \ + DIF_VARIABLE_MAX) & \ + (((uint64_t)1 << 61) - 1)) | ((uint64_t)intr << 61); \ } #endif +#endif #define DT_BSWAP_8(x) ((x) & 0xff) #define DT_BSWAP_16(x) ((DT_BSWAP_8(x) << 8) | DT_BSWAP_8((x) >> 8)) @@ -447,7 +475,7 @@ static kmutex_t dtrace_errlock; #define DTRACE_ALIGNCHECK(addr, size, flags) \ if (addr & (size - 1)) { \ *flags |= CPU_DTRACE_BADALIGN; \ - cpu_core[curcpu].cpuc_dtrace_illval = addr; \ + cpu_core[curcpu_id].cpuc_dtrace_illval = addr; \ return (0); \ } #else @@ -486,7 +514,7 @@ dtrace_load##bits(uintptr_t addr) \ uint##bits##_t rval; \ int i; \ volatile uint16_t *flags = (volatile uint16_t *) \ - &cpu_core[curcpu].cpuc_dtrace_flags; \ + &cpu_core[curcpu_id].cpuc_dtrace_flags; \ \ DTRACE_ALIGNCHECK(addr, size, flags); \ \ @@ -501,7 +529,7 @@ dtrace_load##bits(uintptr_t addr) \ * This address falls within a toxic region; return 0. \ */ \ *flags |= CPU_DTRACE_BADADDR; \ - cpu_core[curcpu].cpuc_dtrace_illval = addr; \ + cpu_core[curcpu_id].cpuc_dtrace_illval = addr; \ return (0); \ } \ \ @@ -783,7 +811,7 @@ static int dtrace_canload(uint64_t addr, size_t sz, dtrace_mstate_t *mstate, dtrace_vstate_t *vstate) { - volatile uintptr_t *illval = &cpu_core[curcpu].cpuc_dtrace_illval; + volatile uintptr_t *illval = &cpu_core[curcpu_id].cpuc_dtrace_illval; /* * If we hold the privilege to read from kernel memory, then @@ -875,7 +903,7 @@ dtrace_strncmp(char *s1, char *s2, size_t limit) if (s1 == s2 || limit == 0) return (0); - flags = (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags; + flags = (volatile uint16_t *)&cpu_core[curcpu_id].cpuc_dtrace_flags; do { if (s1 == NULL) { @@ -929,13 +957,13 @@ dtrace_istoxic(uintptr_t kaddr, size_t size) if (kaddr - taddr < tsize) { DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); - cpu_core[curcpu].cpuc_dtrace_illval = kaddr; + cpu_core[curcpu_id].cpuc_dtrace_illval = kaddr; return (1); } if (taddr - kaddr < size) { DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); - cpu_core[curcpu].cpuc_dtrace_illval = taddr; + cpu_core[curcpu_id].cpuc_dtrace_illval = taddr; return (1); } } @@ -1019,7 +1047,7 @@ dtrace_bcmp(const void *s1, const void *s2, size_t len) { volatile uint16_t *flags; - flags = (volatile uint16_t *)&cpu_core[curcpu].cpuc_dtrace_flags; + flags = (volatile uint16_t *)&cpu_core[curcpu_id].cpuc_dtrace_flags; if (s1 == s2) return (0); @@ -1155,6 +1183,7 @@ dtrace_priv_proc_common_user(dtrace_state_t *state) */ ASSERT(s_cr != NULL); +#if defined(sun) if ((cr = CRED()) != NULL && s_cr->cr_uid == cr->cr_uid && s_cr->cr_uid == cr->cr_ruid && @@ -1163,6 +1192,24 @@ dtrace_priv_proc_common_user(dtrace_state_t *state) s_cr->cr_gid == cr->cr_rgid && s_cr->cr_gid == cr->cr_sgid) return (1); +#else + if ((cr = CRED()) != NULL) { + uid_t uid; + gid_t gid; + + uid = kauth_cred_getuid(s_cr); + uid = kauth_cred_getgid(s_cr); + + if (uid == kauth_cred_getuid(cr) && + uid == kauth_cred_geteuid(cr) && + uid == kauth_cred_getsvuid(cr) && + gid == kauth_cred_getgid(cr) && + gid == kauth_cred_getegid(cr) && + gid == kauth_cred_getsvgid(cr)) { + return 1; + } + } +#endif return (0); } @@ -1230,7 +1277,7 @@ dtrace_priv_proc_destructive(dtrace_state_t *state) return (1); bad: - cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV; + cpu_core[curcpu_id].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV; return (0); } @@ -1246,7 +1293,7 @@ dtrace_priv_proc_control(dtrace_state_t *state) dtrace_priv_proc_common_nocd()) return (1); - cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV; + cpu_core[curcpu_id].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV; return (0); } @@ -1257,7 +1304,7 @@ dtrace_priv_proc(dtrace_state_t *state) if (state->dts_cred.dcr_action & DTRACE_CRA_PROC) return (1); - cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV; + cpu_core[curcpu_id].cpuc_dtrace_flags |= CPU_DTRACE_UPRIV; return (0); } @@ -1268,7 +1315,7 @@ dtrace_priv_kernel(dtrace_state_t *state) if (state->dts_cred.dcr_action & DTRACE_CRA_KERNEL) return (1); - cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_KPRIV; + cpu_core[curcpu_id].cpuc_dtrace_flags |= CPU_DTRACE_KPRIV; return (0); } @@ -1279,7 +1326,7 @@ dtrace_priv_kernel_destructive(dtrace_state_t *state) if (state->dts_cred.dcr_action & DTRACE_CRA_KERNEL_DESTRUCTIVE) return (1); - cpu_core[curcpu].cpuc_dtrace_flags |= CPU_DTRACE_KPRIV; + cpu_core[curcpu_id].cpuc_dtrace_flags |= CPU_DTRACE_KPRIV; return (0); } @@ -1390,7 +1437,7 @@ dtrace_dynvar(dtrace_dstate_t *dstate, uint_t nkeys, uint64_t hashval = DTRACE_DYNHASH_VALID; dtrace_dynhash_t *hash = dstate->dtds_hash; dtrace_dynvar_t *free, *new_free, *next, *dvar, *start, *prev = NULL; - processorid_t me = curcpu, cpu = me; + processorid_t me = curcpu_id, cpu = me; dtrace_dstate_percpu_t *dcpu = &dstate->dtds_percpu[me]; size_t bucket, ksize; size_t chunksize = dstate->dtds_chunksize; @@ -2472,7 +2519,7 @@ static void dtrace_speculation_clean_here(dtrace_state_t *state) { dtrace_icookie_t cookie; - processorid_t cpu = curcpu; + processorid_t cpu = curcpu_id; dtrace_buffer_t *dest = &state->dts_buffer[cpu]; dtrace_specid_t i; @@ -2777,7 +2824,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, if ((lwp = curthread->t_lwp) == NULL) { DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR); - cpu_core[curcpu].cpuc_dtrace_illval = NULL; + cpu_core[curcpu_id].cpuc_dtrace_illval = NULL; return (0); } @@ -3006,6 +3053,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, return ((uint64_t)curthread->t_tid); case DIF_VAR_EXECARGS: { +#if 0 struct pargs *p_args = curthread->td_proc->p_args; if (p_args == NULL) @@ -3013,6 +3061,9 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, return (dtrace_dif_varstrz( (uintptr_t) p_args->ar_args, p_args->ar_length, state, mstate)); +#endif + /* XXX FreeBSD extension */ + return 0; } case DIF_VAR_EXECNAME: @@ -3037,7 +3088,7 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, state, mstate)); #else return (dtrace_dif_varstr( - (uintptr_t) curthread->td_proc->p_comm, state, mstate)); + (uintptr_t) curthread->l_proc->p_comm, state, mstate)); #endif case DIF_VAR_ZONENAME: @@ -3074,7 +3125,6 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, */ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU)) return ((uint64_t)p0.p_cred->cr_uid); -#endif /* * It is always safe to dereference one's own t_procp pointer: @@ -3086,6 +3136,9 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, * credential, since this is never NULL after process birth. */ return ((uint64_t)curthread->t_procp->p_cred->cr_uid); +#else + return (uint64_t)kauth_cred_getuid(curthread->t_procp->p_cred); +#endif case DIF_VAR_GID: if (!dtrace_priv_proc(state)) @@ -3097,7 +3150,6 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, */ if (DTRACE_ANCHORED(mstate->dtms_probe) && CPU_ON_INTR(CPU)) return ((uint64_t)p0.p_cred->cr_gid); -#endif /* * It is always safe to dereference one's own t_procp pointer: @@ -3109,6 +3161,9 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, * credential, since this is never NULL after process birth. */ return ((uint64_t)curthread->t_procp->p_cred->cr_gid); +#else + return (uint64_t)kauth_cred_getgid(curthread->t_procp->p_cred); +#endif case DIF_VAR_ERRNO: { #if defined(sun) @@ -3133,7 +3188,11 @@ dtrace_dif_variable(dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t v, return ((uint64_t)lwp->lwp_errno); #else - return (curthread->td_errno); +#if 0 + return (curthread->l_errno); +#else + return 0; /* XXX TBD errno support at lwp level? */ +#endif #endif } default: @@ -3154,8 +3213,8 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs, dtrace_key_t *tupregs, int nargs, dtrace_mstate_t *mstate, dtrace_state_t *state) { - volatile uint16_t *flags = &cpu_core[curcpu].cpuc_dtrace_flags; - volatile uintptr_t *illval = &cpu_core[curcpu].cpuc_dtrace_illval; + volatile uint16_t *flags = &cpu_core[curcpu_id].cpuc_dtrace_flags; + volatile uintptr_t *illval = &cpu_core[curcpu_id].cpuc_dtrace_illval; dtrace_vstate_t *vstate = &state->dts_vstate; #if defined(sun) @@ -3169,11 +3228,15 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs, uintptr_t rw; } r; #else - struct thread *lowner; union { - struct lock_object *li; - uintptr_t lx; - } l; + kmutex_t mi; + uint64_t mx; + } m; + + union { + krwlock_t ri; + uintptr_t rw; + } r; #endif switch (subr) { @@ -3271,83 +3334,90 @@ dtrace_dif_subr(uint_t subr, uint_t rd, uint64_t *regs, #else case DIF_SUBR_MUTEX_OWNED: - if (!dtrace_canload(tupregs[0].dttk_value, - sizeof (struct lock_object), mstate, vstate)) { + if (!dtrace_canload(tupregs[0].dttk_value, sizeof (kmutex_t), + mstate, vstate)) { regs[rd] = 0; break; } - l.lx = dtrace_loadptr((uintptr_t)&tupregs[0].dttk_value); - regs[rd] = LOCK_CLASS(l.li)->lc_owner(l.li, &lowner); + + m.mx = dtrace_load64(tupregs[0].dttk_value); + if (MUTEX_TYPE_ADAPTIVE(&m.mi)) + regs[rd] = MUTEX_OWNER(&m.mi) != MUTEX_NO_OWNER; + else + regs[rd] = __SIMPLELOCK_LOCKED_P(&m.mi.mtx_lock); break; case DIF_SUBR_MUTEX_OWNER: - if (!dtrace_canload(tupregs[0].dttk_value, - sizeof (struct lock_object), mstate, vstate)) { + if (!dtrace_canload(tupregs[0].dttk_value, sizeof (kmutex_t), + mstate, vstate)) { regs[rd] = 0; break; } - l.lx = dtrace_loadptr((uintptr_t)&tupregs[0].dttk_value); - LOCK_CLASS(l.li)->lc_owner(l.li, &lowner); - regs[rd] = (uintptr_t)lowner; + + m.mx = dtrace_load64(tupregs[0].dttk_value); + if (MUTEX_TYPE_ADAPTIVE(&m.mi) && + MUTEX_OWNER(&m.mi) != MUTEX_NO_OWNER) + regs[rd] = (uintptr_t)MUTEX_OWNER(&m.mi); + else + regs[rd] = 0; break; case DIF_SUBR_MUTEX_TYPE_ADAPTIVE: - if (!dtrace_canload(tupregs[0].dttk_value, sizeof (struct mtx), + if (!dtrace_canload(tupregs[0].dttk_value, sizeof (kmutex_t), mstate, vstate)) { regs[rd] = 0; break; } - l.lx = dtrace_loadptr((uintptr_t)&tupregs[0].dttk_value); - /* XXX - should be only LC_SLEEPABLE? */ - regs[rd] = (LOCK_CLASS(l.li)->lc_flags & - (LC_SLEEPLOCK | LC_SLEEPABLE)) != 0; + + m.mx = dtrace_load64(tupregs[0].dttk_value); + regs[rd] = MUTEX_TYPE_ADAPTIVE(&m.mi); break; case DIF_SUBR_MUTEX_TYPE_SPIN: - if (!dtrace_canload(tupregs[0].dttk_value, sizeof (struct mtx), + if (!dtrace_canload(tupregs[0].dttk_value, sizeof (kmutex_t), mstate, vstate)) { regs[rd] = 0; break; } - l.lx = dtrace_loadptr((uintptr_t)&tupregs[0].dttk_value); - regs[rd] = (LOCK_CLASS(l.li)->lc_flags & LC_SPINLOCK) != 0; + + m.mx = dtrace_load64(tupregs[0].dttk_value); + regs[rd] = MUTEX_TYPE_SPIN(&m.mi); break; - case DIF_SUBR_RW_READ_HELD: - case DIF_SUBR_SX_SHARED_HELD: - if (!dtrace_canload(tupregs[0].dttk_value, sizeof (uintptr_t), + case DIF_SUBR_RW_READ_HELD: { + if (!dtrace_canload(tupregs[0].dttk_value, sizeof (krwlock_t), mstate, vstate)) { regs[rd] = 0; break; } - l.lx = dtrace_loadptr((uintptr_t)&tupregs[0].dttk_value); - regs[rd] = LOCK_CLASS(l.li)->lc_owner(l.li, &lowner) && - lowner == NULL; + + r.rw = dtrace_loadptr(tupregs[0].dttk_value); + regs[rd] = _RW_READ_HELD(&r.ri); break; + } case DIF_SUBR_RW_WRITE_HELD: - case DIF_SUBR_SX_EXCLUSIVE_HELD: - if (!dtrace_canload(tupregs[0].dttk_value, sizeof (uintptr_t), + if (!dtrace_canload(tupregs[0].dttk_value, sizeof (krwlock_t), mstate, vstate)) { regs[rd] = 0; break; } - l.lx = dtrace_loadptr(tupregs[0].dttk_value); - LOCK_CLASS(l.li)->lc_owner(l.li, &lowner); - regs[rd] = (lowner == curthread); + + r.rw = dtrace_loadptr(tupregs[0].dttk_value); + regs[rd] = _RW_WRITE_HELD(&r.ri); break; case DIF_SUBR_RW_ISWRITER: - case DIF_SUBR_SX_ISEXCLUSIVE: - if (!dtrace_canload(tupregs[0].dttk_value, sizeof (uintptr_t), + if (!dtrace_canload(tupregs[0].dttk_value, sizeof (krwlock_t), mstate, vstate)) { regs[rd] = 0; break; } - l.lx = dtrace_loadptr(tupregs[0].dttk_value); - regs[rd] = LOCK_CLASS(l.li)->lc_owner(l.li, &lowner) && - lowner != NULL; + + r.rw = dtrace_loadptr(tupregs[0].dttk_value); + regs[rd] = _RW_ISWRITER(&r.ri); break; + #endif /* ! defined(sun) */ case DIF_SUBR_BCOPY: { @@ -4770,8 +4840,8 @@ dtrace_dif_emulate(dtrace_difo_t *difo, dtrace_mstate_t *mstate, dtrace_statvar_t *svar; dtrace_dstate_t *dstate = &vstate->dtvs_dynvars; dtrace_difv_t *v; - volatile uint16_t *flags = &cpu_core[curcpu].cpuc_dtrace_flags; - volatile uintptr_t *illval = &cpu_core[curcpu].cpuc_dtrace_illval; + volatile uint16_t *flags = &cpu_core[curcpu_id].cpuc_dtrace_flags; + volatile uintptr_t *illval = &cpu_core[curcpu_id].cpuc_dtrace_illval; dtrace_key_t tupregs[DIF_DTR_NREGS + 2]; /* +2 for thread and id */ uint64_t regs[DIF_DIR_NREGS]; @@ -5163,7 +5233,7 @@ dtrace_dif_emulate(dtrace_difo_t *difo, dtrace_mstate_t *mstate, sz += sizeof (uint64_t); ASSERT(svar->dtsv_size == NCPU * sz); - a += curcpu * sz; + a += curcpu_id * sz; if (*(uint8_t *)a == UINT8_MAX) { /* @@ -5181,7 +5251,7 @@ dtrace_dif_emulate(dtrace_difo_t *difo, dtrace_mstate_t *mstate, ASSERT(svar->dtsv_size == NCPU * sizeof (uint64_t)); tmp = (uint64_t *)(uintptr_t)svar->dtsv_data; - regs[rd] = tmp[curcpu]; + regs[rd] = tmp[curcpu_id]; break; case DIF_OP_STLS: @@ -5202,7 +5272,7 @@ dtrace_dif_emulate(dtrace_difo_t *difo, dtrace_mstate_t *mstate, sz += sizeof (uint64_t); ASSERT(svar->dtsv_size == NCPU * sz); - a += curcpu * sz; + a += curcpu_id * sz; if (regs[rd] == 0) { *(uint8_t *)a = UINT8_MAX; @@ -5224,7 +5294,7 @@ dtrace_dif_emulate(dtrace_difo_t *difo, dtrace_mstate_t *mstate, ASSERT(svar->dtsv_size == NCPU * sizeof (uint64_t)); tmp = (uint64_t *)(uintptr_t)svar->dtsv_data; - tmp[curcpu] = regs[rd]; + tmp[curcpu_id] = regs[rd]; break; case DIF_OP_LDTS: { @@ -5473,7 +5543,6 @@ dtrace_dif_emulate(dtrace_difo_t *difo, dtrace_mstate_t *mstate, *illval = regs[rd]; break; } - if (!dtrace_canload(regs[r1], regs[r2], mstate, vstate)) break; @@ -5605,7 +5674,12 @@ dtrace_action_breakpoint(dtrace_ecb_t *ecb) #if defined(sun) debug_enter(c); #else - kdb_enter(KDB_WHY_DTRACE, "breakpoint action"); +#ifdef DDB + db_printf("%s\n", c); + Debugger(); +#else + printf("%s ignored\n", c); +#endif /* DDB */ #endif } @@ -5661,9 +5735,9 @@ dtrace_action_raise(uint64_t sig) aston(curthread); #else struct proc *p = curproc; - PROC_LOCK(p); + mutex_enter(proc_lock); psignal(p, sig); - PROC_UNLOCK(p); + mutex_exit(proc_lock); #endif } @@ -5681,21 +5755,22 @@ dtrace_action_stop(void) } #else struct proc *p = curproc; - PROC_LOCK(p); + mutex_enter(proc_lock); psignal(p, SIGSTOP); - PROC_UNLOCK(p); + mutex_exit(proc_lock); #endif } static void dtrace_action_chill(dtrace_mstate_t *mstate, hrtime_t val) { +#if 0 /* XXX TBD - needs solaris_cpu */ hrtime_t now; volatile uint16_t *flags; #if defined(sun) cpu_t *cpu = CPU; #else - cpu_t *cpu = &solaris_cpu[curcpu]; + cpu_t *cpu = &solaris_cpu[curcpu_id]; #endif if (dtrace_destructive_disallow) @@ -5734,6 +5809,7 @@ dtrace_action_chill(dtrace_mstate_t *mstate, hrtime_t val) */ mstate->dtms_present &= ~DTRACE_MSTATE_TIMESTAMP; cpu->cpu_dtrace_chilled += val; +#endif } #if defined(sun) @@ -5747,7 +5823,7 @@ dtrace_action_ustack(dtrace_mstate_t *mstate, dtrace_state_t *state, char *str = (char *)&pcs[nframes]; int size, offs = 0, i, j; uintptr_t old = mstate->dtms_scratch_ptr, saved; - uint16_t *flags = &cpu_core[curcpu].cpuc_dtrace_flags; + uint16_t *flags = &cpu_core[curcpu_id].cpuc_dtrace_flags; char *sym; /* @@ -5884,7 +5960,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1, cookie = dtrace_interrupt_disable(); probe = dtrace_probes[id - 1]; - cpuid = curcpu; + cpuid = curcpu_id; onintr = CPU_ON_INTR(CPU); if (!onintr && probe->dtpr_predcache != DTRACE_CACHEIDNONE && @@ -6400,7 +6476,6 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1, #if defined(sun) struct pid *pid = curthread->t_procp->p_pidp; #endif - if (!dtrace_priv_proc(state)) continue; @@ -7359,8 +7434,13 @@ dtrace_register(const char *name, const dtrace_pattr_t *pap, uint32_t priv, if (pops->dtps_provide_module == NULL) { ASSERT(pops->dtps_provide != NULL); +#if defined(sun) provider->dtpv_pops.dtps_provide_module = (void (*)(void *, modctl_t *))dtrace_nullop; +#else + provider->dtpv_pops.dtps_provide_module = + (void (*)(void *, dtrace_modctl_t *))dtrace_nullop; +#endif } if (pops->dtps_suspend == NULL) { @@ -7545,7 +7625,7 @@ dtrace_unregister(dtrace_provider_id_t id) #if defined(sun) vmem_free(dtrace_arena, (void *)(uintptr_t)(probe->dtpr_id), 1); #else - free_unr(dtrace_arena, probe->dtpr_id); + vmem_free(dtrace_arena, (uintptr_t)(probe->dtpr_id), 1); #endif kmem_free(probe, sizeof (dtrace_probe_t)); } @@ -7664,7 +7744,7 @@ dtrace_condense(dtrace_provider_id_t id) #if defined(sun) vmem_free(dtrace_arena, (void *)((uintptr_t)i + 1), 1); #else - free_unr(dtrace_arena, i + 1); + vmem_free(dtrace_arena, ((uintptr_t)i + 1), 1); #endif } @@ -7701,12 +7781,8 @@ dtrace_probe_create(dtrace_provider_id_t prov, const char *mod, mutex_enter(&dtrace_lock); } -#if defined(sun) id = (dtrace_id_t)(uintptr_t)vmem_alloc(dtrace_arena, 1, VM_BESTFIT | VM_SLEEP); -#else - id = alloc_unr(dtrace_arena); -#endif probe = kmem_zalloc(sizeof (dtrace_probe_t), KM_SLEEP); probe->dtpr_id = id; @@ -7733,6 +7809,7 @@ dtrace_probe_create(dtrace_provider_id_t prov, const char *mod, } probes = kmem_zalloc(nsize, KM_SLEEP); + dtrace_probes_size = nsize; if (dtrace_probes == NULL) { ASSERT(osize == 0); @@ -7854,6 +7931,7 @@ dtrace_probe_description(const dtrace_probe_t *prp, dtrace_probedesc_t *pdp) (void) strncpy(pdp->dtpd_name, prp->dtpr_name, DTRACE_NAMELEN - 1); } +#ifdef notyet /* XXX TBD */ #if !defined(sun) static int dtrace_probe_provide_cb(linker_file_t lf, void *arg) @@ -7865,6 +7943,7 @@ dtrace_probe_provide_cb(linker_file_t lf, void *arg) return(0); } #endif +#endif /* notyet */ /* @@ -7887,6 +7966,8 @@ dtrace_probe_provide(dtrace_probedesc_t *desc, dtrace_provider_t *prv) { #if defined(sun) modctl_t *ctl; +#else + module_t *mod; #endif int all = 0; @@ -7921,7 +8002,11 @@ dtrace_probe_provide(dtrace_probedesc_t *desc, dtrace_provider_t *prv) } while ((ctl = ctl->mod_next) != &modules); #else - (void) linker_file_foreach(dtrace_probe_provide_cb, prv); + mutex_enter(&module_lock); + TAILQ_FOREACH(mod, &module_list, mod_chain) { + prv->dtpv_pops.dtps_provide_module(prv->dtpv_arg, mod); + } + mutex_exit(&module_lock); #endif mutex_exit(&mod_lock); @@ -9913,12 +9998,8 @@ success: /* * We need to allocate an id for this aggregation. */ -#if defined(sun) aggid = (dtrace_aggid_t)(uintptr_t)vmem_alloc(state->dts_aggid_arena, 1, VM_BESTFIT | VM_SLEEP); -#else - aggid = alloc_unr(state->dts_aggid_arena); -#endif if (aggid - 1 >= state->dts_naggregations) { dtrace_aggregation_t **oaggs = state->dts_aggregations; @@ -9970,7 +10051,7 @@ dtrace_ecb_aggregation_destroy(dtrace_ecb_t *ecb, dtrace_action_t *act) #if defined(sun) vmem_free(state->dts_aggid_arena, (void *)(uintptr_t)aggid, 1); #else - free_unr(state->dts_aggid_arena, aggid); + vmem_free(state->dts_aggid_arena, (uintptr_t)aggid, 1); #endif ASSERT(state->dts_aggregations[aggid - 1] == agg); @@ -10561,7 +10642,7 @@ dtrace_buffer_activate(dtrace_state_t *state) dtrace_buffer_t *buf; dtrace_icookie_t cookie = dtrace_interrupt_disable(); - buf = &state->dts_buffer[curcpu]; + buf = &state->dts_buffer[curcpu_id]; if (buf->dtb_tomax != NULL) { /* @@ -10584,7 +10665,8 @@ dtrace_buffer_alloc(dtrace_buffer_t *bufs, size_t size, int flags, #if defined(sun) cpu_t *cp; #else - struct pcpu *cp; + CPU_INFO_ITERATOR cpuind; + struct cpu_info *cinfo; #endif dtrace_buffer_t *buf; @@ -10672,14 +10754,11 @@ err: #endif ASSERT(MUTEX_HELD(&dtrace_lock)); - for (i = 0; i <= mp_maxid; i++) { - if ((cp = pcpu_find(i)) == NULL) + for (CPU_INFO_FOREACH(cpuind, cinfo)) { + if (cpu != DTRACE_CPUALL && cpu != cpu_index(cinfo)) continue; - if (cpu != DTRACE_CPUALL && cpu != i) - continue; - - buf = &bufs[i]; + buf = &bufs[cpu_index(cinfo)]; /* * If there is already a buffer allocated for this CPU, it @@ -10715,14 +10794,11 @@ err: * Error allocating memory, so free the buffers that were * allocated before the failed allocation. */ - for (i = 0; i <= mp_maxid; i++) { - if ((cp = pcpu_find(i)) == NULL) + for (CPU_INFO_FOREACH(cpuind, cinfo)) { + if (cpu != DTRACE_CPUALL && cpu != cpu_index(cinfo)) continue; - if (cpu != DTRACE_CPUALL && cpu != i) - continue; - - buf = &bufs[i]; + buf = &bufs[cpu_index(cinfo)]; if (buf->dtb_xamot != NULL) { ASSERT(buf->dtb_tomax != NULL); @@ -11675,7 +11751,7 @@ dtrace_dof_property(const char *name) uchar_t *buf; uint64_t loadsz; unsigned int len, i; - dof_hdr_t *dof; + dof_hdr_t *dof = NULL; #if defined(sun) /* @@ -11712,6 +11788,8 @@ dtrace_dof_property(const char *name) bcopy(buf, dof, loadsz); ddi_prop_free(buf); #else + printf("dtrace: XXX %s not implemented (name=%s)\n", __func__, name); +#if 0 /* XXX TBD dtrace_dof_provide */ char *p; char *p_env; @@ -11751,6 +11829,7 @@ dtrace_dof_property(const char *name) dtrace_dof_error(NULL, "oversized DOF"); return (NULL); } +#endif #endif return (dof); @@ -12622,10 +12701,6 @@ dtrace_dstate_init(dtrace_dstate_t *dstate, size_t size) maxper = (maxper / dstate->dtds_chunksize) * dstate->dtds_chunksize; for (i = 0; i < NCPU; i++) { -#if !defined(sun) - if (CPU_ABSENT(i)) - continue; -#endif dstate->dtds_percpu[i].dtdsc_free = dvar = start; /* @@ -12751,7 +12826,7 @@ dtrace_state_clean(void *arg) dtrace_dynvar_clean(&state->dts_vstate.dtvs_dynvars); dtrace_speculation_clean(state); - callout_reset(&state->dts_cleaner, hz * opt[DTRACEOPT_CLEANRATE] / NANOSEC, + callout_reset(&state->dts_cleaner, ((dtrace_optval_t)hz * opt[DTRACEOPT_CLEANRATE]) / NANOSEC, dtrace_state_clean, state); } @@ -12760,32 +12835,44 @@ dtrace_state_deadman(void *arg) { dtrace_state_t *state = arg; hrtime_t now; + int res; - dtrace_sync(); + while (dtrace_deadman_alive) { + mutex_enter(&dtrace_deadman_mutex); + res = mtsleep(&dtrace_deadman_wchan, PRI_BIO, "dtrace_deadman", + ((dtrace_optval_t)hz * dtrace_deadman_interval) / NANOSEC, + &dtrace_deadman_mutex); + mutex_exit(&dtrace_deadman_mutex); - dtrace_debug_output(); + if (!dtrace_deadman_alive) { + break; + } - now = dtrace_gethrtime(); + dtrace_sync(); - if (state != dtrace_anon.dta_state && - now - state->dts_laststatus >= dtrace_deadman_user) - return; + dtrace_debug_output(); - /* - * We must be sure that dts_alive never appears to be less than the - * value upon entry to dtrace_state_deadman(), and because we lack a - * dtrace_cas64(), we cannot store to it atomically. We thus instead - * store INT64_MAX to it, followed by a memory barrier, followed by - * the new value. This assures that dts_alive never appears to be - * less than its true value, regardless of the order in which the - * stores to the underlying storage are issued. - */ - state->dts_alive = INT64_MAX; - dtrace_membar_producer(); - state->dts_alive = now; + now = dtrace_gethrtime(); - callout_reset(&state->dts_deadman, hz * dtrace_deadman_interval / NANOSEC, - dtrace_state_deadman, state); + if (state != dtrace_anon.dta_state && + now - state->dts_laststatus >= dtrace_deadman_user) + return; + + /* + * We must be sure that dts_alive never appears to be less than the + * value upon entry to dtrace_state_deadman(), and because we lack a + * dtrace_cas64(), we cannot store to it atomically. We thus instead + * store INT64_MAX to it, followed by a memory barrier, followed by + * the new value. This assures that dts_alive never appears to be + * less than its true value, regardless of the order in which the + * stores to the underlying storage are issued. + */ + state->dts_alive = INT64_MAX; + dtrace_membar_producer(); + state->dts_alive = now; + } + + kthread_exit(0); } #endif @@ -12793,14 +12880,13 @@ static dtrace_state_t * #if defined(sun) dtrace_state_create(dev_t *devp, cred_t *cr) #else -dtrace_state_create(struct cdev *dev) +dtrace_state_create(dev_t dev, cred_t *cr) #endif { #if defined(sun) minor_t minor; major_t major; #else - cred_t *cr = NULL; int m = 0; #endif char c[30]; @@ -12822,10 +12908,7 @@ dtrace_state_create(struct cdev *dev) state = ddi_get_soft_state(dtrace_softstate, minor); #else - if (dev != NULL) { - cr = dev->si_cred; - m = dev2unit(dev); - } + m = minor(dev) & 0x0F; /* Allocate memory for the state. */ state = kmem_zalloc(sizeof(dtrace_state_t), KM_SLEEP); @@ -12849,7 +12932,8 @@ dtrace_state_create(struct cdev *dev) if (devp != NULL) *devp = state->dts_dev; #else - state->dts_aggid_arena = new_unrhdr(1, INT_MAX, &dtrace_unr_mtx); + state->dts_aggid_arena = vmem_create(c, 1, INT_MAX, 1, + NULL, NULL, NULL, 0, VM_SLEEP, IPL_NONE); state->dts_dev = dev; #endif @@ -12867,7 +12951,6 @@ dtrace_state_create(struct cdev *dev) state->dts_deadman = CYCLIC_NONE; #else callout_init(&state->dts_cleaner, CALLOUT_MPSAFE); - callout_init(&state->dts_deadman, CALLOUT_MPSAFE); #endif state->dts_vstate.dtvs_state = state; @@ -12912,7 +12995,11 @@ dtrace_state_create(struct cdev *dev) * credential from disappearing. This means that we can * examine the credential and the zone from probe context. */ +#if defined(sun) crhold(cr); +#else + kauth_cred_hold(cr); +#endif state->dts_cred.dcr_cred = cr; /* @@ -13351,10 +13438,20 @@ dtrace_state_go(dtrace_state_t *state, processorid_t *cpu) state->dts_deadman = cyclic_add(&hdlr, &when); #else - callout_reset(&state->dts_cleaner, hz * opt[DTRACEOPT_CLEANRATE] / NANOSEC, + callout_reset(&state->dts_cleaner, + ((dtrace_optval_t)hz * opt[DTRACEOPT_CLEANRATE]) / NANOSEC, dtrace_state_clean, state); - callout_reset(&state->dts_deadman, hz * dtrace_deadman_interval / NANOSEC, - dtrace_state_deadman, state); + + mutex_init(&dtrace_deadman_mutex, NULL, MUTEX_DEFAULT, NULL); + dtrace_deadman_wchan = &dtrace_deadman_wchan; + dtrace_deadman_alive = 1; + + if ((rval = kthread_create(PRI_BIO, KTHREAD_MPSAFE, + NULL, dtrace_state_deadman, state, + &dtrace_deadman_proc, "dtrace_deadman")) != 0) { + printf("failed to create deadman thread %s, error=%d\n", rval); + goto out; + } #endif state->dts_activity = DTRACE_ACTIVITY_WARMUP; @@ -13366,7 +13463,7 @@ dtrace_state_go(dtrace_state_t *state, processorid_t *cpu) * level) and to manually activate the buffer for this CPU. */ cookie = dtrace_interrupt_disable(); - *cpu = curcpu; + *cpu = curcpu_id; ASSERT(state->dts_buffer[*cpu].dtb_flags & DTRACEBUF_INACTIVE); state->dts_buffer[*cpu].dtb_flags &= ~DTRACEBUF_INACTIVE; @@ -13467,7 +13564,7 @@ dtrace_state_stop(dtrace_state_t *state, processorid_t *cpu) state->dts_reserve = 0; cookie = dtrace_interrupt_disable(); - *cpu = curcpu; + *cpu = curcpu_id; dtrace_probe(dtrace_probeid_end, (uint64_t)(uintptr_t)state, 0, 0, 0, 0); dtrace_interrupt_enable(cookie); @@ -13573,8 +13670,13 @@ dtrace_state_destroy(dtrace_state_t *state) /* * Release the credential hold we took in dtrace_state_create(). */ - if (state->dts_cred.dcr_cred != NULL) + if (state->dts_cred.dcr_cred != NULL) { +#if defined(sun) crfree(state->dts_cred.dcr_cred); +#else + kauth_cred_free(state->dts_cred.dcr_cred); +#endif + } /* * Now we can safely disable and destroy any enabled probes. Because @@ -13624,9 +13726,16 @@ dtrace_state_destroy(dtrace_state_t *state) cyclic_remove(state->dts_deadman); #else callout_stop(&state->dts_cleaner); - callout_drain(&state->dts_cleaner); - callout_stop(&state->dts_deadman); - callout_drain(&state->dts_deadman); + + /* Kill off the deadman thread */ + if (dtrace_deadman_alive) { + dtrace_deadman_alive = 0; + wakeup(dtrace_deadman_wchan); + /* Wait for thread to exit */ + mutex_enter(&dtrace_deadman_mutex); + mutex_exit(&dtrace_deadman_mutex); + mutex_destroy(&dtrace_deadman_mutex); + } #endif dtrace_dstate_fini(&vstate->dtvs_dynvars); @@ -13656,16 +13765,14 @@ dtrace_state_destroy(dtrace_state_t *state) dtrace_format_destroy(state); if (state->dts_aggid_arena != NULL) { -#if defined(sun) vmem_destroy(state->dts_aggid_arena); -#else - delete_unrhdr(state->dts_aggid_arena); -#endif state->dts_aggid_arena = NULL; } #if defined(sun) ddi_soft_state_free(dtrace_softstate, minor); vmem_free(dtrace_minor, (void *)(uintptr_t)minor, 1); +#else + kmem_free(state, sizeof(dtrace_state_t)); #endif } @@ -13736,8 +13843,6 @@ dtrace_anon_property(void) if ((state = dtrace_anon.dta_state) == NULL) { #if defined(sun) state = dtrace_state_create(NULL, NULL); -#else - state = dtrace_state_create(NULL); #endif dtrace_anon.dta_state = state; @@ -13809,7 +13914,7 @@ dtrace_helper_trace(dtrace_helper_action_t *helper, { uint32_t size, next, nnext, i; dtrace_helptrace_t *ent; - uint16_t flags = cpu_core[curcpu].cpuc_dtrace_flags; + uint16_t flags = cpu_core[curcpu_id].cpuc_dtrace_flags; if (!dtrace_helptrace_enabled) return; @@ -13850,7 +13955,7 @@ dtrace_helper_trace(dtrace_helper_action_t *helper, ent->dtht_fltoffs = (mstate->dtms_present & DTRACE_MSTATE_FLTOFFS) ? mstate->dtms_fltoffs : -1; ent->dtht_fault = DTRACE_FLAGS2FLT(flags); - ent->dtht_illval = cpu_core[curcpu].cpuc_dtrace_illval; + ent->dtht_illval = cpu_core[curcpu_id].cpuc_dtrace_illval; for (i = 0; i < vstate->dtvs_nlocals; i++) { dtrace_statvar_t *svar; @@ -13860,7 +13965,7 @@ dtrace_helper_trace(dtrace_helper_action_t *helper, ASSERT(svar->dtsv_size >= NCPU * sizeof (uint64_t)); ent->dtht_locals[i] = - ((uint64_t *)(uintptr_t)svar->dtsv_data)[curcpu]; + ((uint64_t *)(uintptr_t)svar->dtsv_data)[curcpu_id]; } } #endif @@ -13870,7 +13975,7 @@ static uint64_t dtrace_helper(int which, dtrace_mstate_t *mstate, dtrace_state_t *state, uint64_t arg0, uint64_t arg1) { - uint16_t *flags = &cpu_core[curcpu].cpuc_dtrace_flags; + uint16_t *flags = &cpu_core[curcpu_id].cpuc_dtrace_flags; uint64_t sarg0 = mstate->dtms_arg[0]; uint64_t sarg1 = mstate->dtms_arg[1]; uint64_t rval; @@ -15254,12 +15359,38 @@ dtrace_dtr(void *data __unused) #endif #endif +#if !defined(sun) +static dev_type_open(dtrace_open); + +/* Pseudo Device Entry points */ +/* Just opens, clones to the fileops below */ +const struct cdevsw dtrace_cdevsw = { + dtrace_open, noclose, noread, nowrite, noioctl, + nostop, notty, nopoll, nommap, nokqfilter, + D_OTHER +}; + +static int dtrace_ioctl(struct file *fp, u_long cmd, void *data); +static int dtrace_close(struct file *fp); + +static const struct fileops dtrace_fileops = { + .fo_read = fbadop_read, + .fo_write = fbadop_write, + .fo_ioctl = dtrace_ioctl, + .fo_fcntl = fnullop_fcntl, + .fo_poll = fnullop_poll, + .fo_stat = fbadop_stat, + .fo_close = dtrace_close, + .fo_kqfilter = fnullop_kqfilter, +}; +#endif + /*ARGSUSED*/ static int #if defined(sun) dtrace_open(dev_t *devp, int flag, int otyp, cred_t *cred_p) #else -dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td) +dtrace_open(dev_t dev, int flags, int mode, struct lwp *l) #endif { dtrace_state_t *state; @@ -15278,7 +15409,13 @@ dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td) ASSERT(getminor(*devp) == DTRACEMNRN_DTRACE); #else cred_t *cred_p = NULL; + struct file *fp; + int fd; + int res; + if ((res = fd_allocfile(&fp, &fd)) != 0) + return res; +#if 0 #if __FreeBSD_version < 800039 /* * The first minor device is the one that is cloned so there is @@ -15299,6 +15436,8 @@ dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td) cred_p = dev->si_cred; #endif + cred_p = l->l_cred; +#endif /* * If no DTRACE_PRIV_* bits are set in the credential, then the @@ -15306,13 +15445,6 @@ dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td) */ dtrace_cred2priv(cred_p, &priv, &uid, &zoneid); if (priv == DTRACE_PRIV_NONE) { -#if !defined(sun) -#if __FreeBSD_version < 800039 - /* Destroy the cloned device. */ - destroy_dev(dev); -#endif -#endif - return (EACCES); } @@ -15342,12 +15474,7 @@ dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td) state = dtrace_state_create(devp, cred_p); #else - state = dtrace_state_create(dev); -#if __FreeBSD_version < 800039 - dev->si_drv1 = state; -#else - devfs_set_cdevpriv(state, dtrace_dtr); -#endif + state = dtrace_state_create(dev, cred_p); #endif mutex_exit(&cpu_lock); @@ -15360,18 +15487,16 @@ dtrace_open(struct cdev *dev, int oflags, int devtype, struct thread *td) --dtrace_opens; #endif mutex_exit(&dtrace_lock); -#if !defined(sun) -#if __FreeBSD_version < 800039 - /* Destroy the cloned device. */ - destroy_dev(dev); -#endif -#endif return (EAGAIN); } mutex_exit(&dtrace_lock); +#if defined(sun) return (0); +#else + return fd_clone(fp, fd, flags, &dtrace_fileops, state); +#endif } /*ARGSUSED*/ @@ -15379,7 +15504,7 @@ static int #if defined(sun) dtrace_close(dev_t dev, int flag, int otyp, cred_t *cred_p) #else -dtrace_close(struct cdev *dev, int flags, int fmt __unused, struct thread *td) +dtrace_close(struct file *fp) #endif { #if defined(sun) @@ -15391,17 +15516,7 @@ dtrace_close(struct cdev *dev, int flags, int fmt __unused, struct thread *td) state = ddi_get_soft_state(dtrace_softstate, minor); #else -#if __FreeBSD_version < 800039 - dtrace_state_t *state = dev->si_drv1; - - /* Check if this is not a cloned device. */ - if (dev2unit(dev) == 0) - return (0); -#else - dtrace_state_t *state; - devfs_get_cdevpriv((void **) &state); -#endif - + dtrace_state_t *state = (dtrace_state_t *)fp->f_data; #endif mutex_enter(&cpu_lock); @@ -15419,12 +15534,7 @@ dtrace_close(struct cdev *dev, int flags, int fmt __unused, struct thread *td) dtrace_state_destroy(state); #if !defined(sun) - kmem_free(state, 0); -#if __FreeBSD_version < 800039 - dev->si_drv1 = NULL; -#else - devfs_clear_cdevpriv(); -#endif + fp->f_data = NULL; #endif } @@ -15439,11 +15549,6 @@ dtrace_close(struct cdev *dev, int flags, int fmt __unused, struct thread *td) mutex_exit(&dtrace_lock); mutex_exit(&cpu_lock); -#if __FreeBSD_version < 800039 - /* Schedule this cloned device to be destroyed. */ - destroy_dev_sched(dev); -#endif - return (0); } @@ -16473,6 +16578,7 @@ _fini(void) } #else +#if 0 static d_ioctl_t dtrace_ioctl; static void dtrace_load(void *); static int dtrace_unload(void); @@ -16495,11 +16601,14 @@ static struct cdevsw dtrace_cdevsw = { .d_open = dtrace_open, .d_name = "dtrace", }; +#endif +void dtrace_invop_init(void); +void dtrace_invop_uninit(void); + +static void dtrace_load(void *); +static int dtrace_unload(void); #include -#if __FreeBSD_version < 800039 -#include -#endif #include #include #include @@ -16509,12 +16618,12 @@ static struct cdevsw dtrace_cdevsw = { #include #include -SYSINIT(dtrace_load, SI_SUB_DTRACE, SI_ORDER_FIRST, dtrace_load, NULL); -SYSUNINIT(dtrace_unload, SI_SUB_DTRACE, SI_ORDER_FIRST, dtrace_unload, NULL); -SYSINIT(dtrace_anon_init, SI_SUB_DTRACE_ANON, SI_ORDER_FIRST, dtrace_anon_init, NULL); +MODULE(MODULE_CLASS_MISC, dtrace, NULL); +#if 0 DEV_MODULE(dtrace, dtrace_modevent, NULL); MODULE_VERSION(dtrace, 1); MODULE_DEPEND(dtrace, cyclic, 1, 1, 1); MODULE_DEPEND(dtrace, opensolaris, 1, 1, 1); #endif +#endif diff --git a/external/cddl/osnet/dist/uts/common/sys/dtrace.h b/external/cddl/osnet/dist/uts/common/sys/dtrace.h index 82b97a373682..0d132a4b3eb3 100644 --- a/external/cddl/osnet/dist/uts/common/sys/dtrace.h +++ b/external/cddl/osnet/dist/uts/common/sys/dtrace.h @@ -49,6 +49,7 @@ extern "C" { #include #include #include +#include #if defined(sun) #include #else @@ -59,7 +60,9 @@ extern "C" { typedef int model_t; #endif #include +#if 0 #include +#endif #if defined(sun) #include #else @@ -2013,9 +2016,12 @@ typedef struct dof_helper { * instrument the kernel arbitrarily should be sure to not instrument these * routines. */ + +typedef dtrace_modctl_t *mymodctl_p; + typedef struct dtrace_pops { void (*dtps_provide)(void *arg, dtrace_probedesc_t *spec); - void (*dtps_provide_module)(void *arg, modctl_t *mp); + void (*dtps_provide_module)(void *arg, dtrace_modctl_t *mp); void (*dtps_enable)(void *arg, dtrace_id_t id, void *parg); void (*dtps_disable)(void *arg, dtrace_id_t id, void *parg); void (*dtps_suspend)(void *arg, dtrace_id_t id, void *parg); @@ -2239,8 +2245,8 @@ extern void dtrace_membar_producer(void); extern void dtrace_membar_consumer(void); extern void (*dtrace_cpu_init)(processorid_t); -extern void (*dtrace_modload)(modctl_t *); -extern void (*dtrace_modunload)(modctl_t *); +extern void (*dtrace_modload)(dtrace_modctl_t *); +extern void (*dtrace_modunload)(dtrace_modctl_t *); extern void (*dtrace_helpers_cleanup)(void); extern void (*dtrace_helpers_fork)(proc_t *parent, proc_t *child); extern void (*dtrace_cpustart_init)(void); @@ -2253,12 +2259,12 @@ extern dtrace_cacheid_t dtrace_predcache_id; #if defined(sun) extern hrtime_t dtrace_gethrtime(void); #else -void dtrace_debug_printf(const char *, ...) __printflike(1, 2); +void dtrace_debug_printf(const char *, ...); #endif extern void dtrace_sync(void); extern void dtrace_toxic_ranges(void (*)(uintptr_t, uintptr_t)); extern void dtrace_xcall(processorid_t, dtrace_xcall_t, void *); -extern void dtrace_vpanic(const char *, __va_list); +extern void dtrace_vpanic(const char *, _BSD_VA_LIST_); extern void dtrace_panic(const char *, ...); extern int dtrace_safe_defer_signal(void); @@ -2280,13 +2286,13 @@ extern void dtrace_getfsr(uint64_t *); #endif #define DTRACE_CPUFLAG_ISSET(flag) \ - (cpu_core[curcpu].cpuc_dtrace_flags & (flag)) + (cpu_core[curcpu_id].cpuc_dtrace_flags & (flag)) #define DTRACE_CPUFLAG_SET(flag) \ - (cpu_core[curcpu].cpuc_dtrace_flags |= (flag)) + (cpu_core[curcpu_id].cpuc_dtrace_flags |= (flag)) #define DTRACE_CPUFLAG_CLEAR(flag) \ - (cpu_core[curcpu].cpuc_dtrace_flags &= ~(flag)) + (cpu_core[curcpu_id].cpuc_dtrace_flags &= ~(flag)) #endif /* _KERNEL */ diff --git a/external/cddl/osnet/dist/uts/common/sys/dtrace_impl.h b/external/cddl/osnet/dist/uts/common/sys/dtrace_impl.h index 21295239a099..a9d473c45803 100644 --- a/external/cddl/osnet/dist/uts/common/sys/dtrace_impl.h +++ b/external/cddl/osnet/dist/uts/common/sys/dtrace_impl.h @@ -1109,11 +1109,7 @@ typedef struct dtrace_cred { * dtrace_state structure. */ struct dtrace_state { -#if defined(sun) dev_t dts_dev; /* device */ -#else - struct cdev *dts_dev; /* device */ -#endif int dts_necbs; /* total number of ECBs */ dtrace_ecb_t **dts_ecbs; /* array of ECBs */ dtrace_epid_t dts_epid; /* next EPID to allocate */ @@ -1127,11 +1123,7 @@ struct dtrace_state { int dts_nspeculations; /* number of speculations */ int dts_naggregations; /* number of aggregations */ dtrace_aggregation_t **dts_aggregations; /* aggregation array */ -#if defined(sun) vmem_t *dts_aggid_arena; /* arena for aggregation IDs */ -#else - struct unrhdr *dts_aggid_arena; /* arena for aggregation IDs */ -#endif uint64_t dts_errors; /* total number of errors */ uint32_t dts_speculations_busy; /* number of spec. busy */ uint32_t dts_speculations_unavail; /* number of spec unavail */ diff --git a/external/cddl/osnet/dist/uts/common/sys/processor.h b/external/cddl/osnet/dist/uts/common/sys/processor.h index 3a76c8c9b420..2f864f2f893d 100644 --- a/external/cddl/osnet/dist/uts/common/sys/processor.h +++ b/external/cddl/osnet/dist/uts/common/sys/processor.h @@ -36,6 +36,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -53,7 +54,7 @@ typedef uint16_t lgrpid_t; /* * Type for processor name (CPU number). */ -typedef int processorid_t; +//typedef int processorid_t; typedef int chipid_t; /* diff --git a/external/cddl/osnet/include/alloca.h b/external/cddl/osnet/include/alloca.h index 14bb30b3790d..181e7034eb22 100644 --- a/external/cddl/osnet/include/alloca.h +++ b/external/cddl/osnet/include/alloca.h @@ -1,3 +1,5 @@ +/* $NetBSD: alloca.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/cddl/compat/opensolaris/include/alloca.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/compat/opensolaris/include/alloca.h,v 1.1 2007/11/28 21:40:07 jb Exp $ * */ diff --git a/external/cddl/osnet/include/assert.h b/external/cddl/osnet/include/assert.h index 22c8854891f6..923026f1e131 100644 --- a/external/cddl/osnet/include/assert.h +++ b/external/cddl/osnet/include/assert.h @@ -1,3 +1,5 @@ +/* $NetBSD: assert.h,v 1.2 2010/02/21 01:46:34 darran Exp $ */ + /*- * Copyright (c) 2009 Pawel Jakub Dawidek * All rights reserved. diff --git a/external/cddl/osnet/include/devid.h b/external/cddl/osnet/include/devid.h index 8b14f389a7cd..47207c4ea281 100644 --- a/external/cddl/osnet/include/devid.h +++ b/external/cddl/osnet/include/devid.h @@ -1,3 +1,5 @@ +/* $NetBSD: devid.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + /* * CDDL HEADER START * @@ -18,8 +20,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD: src/cddl/compat/opensolaris/include/devid.h,v 1.4.2.1 2009/08/03 08:13:06 kensmith Exp $ */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. @@ -33,6 +33,8 @@ #include #include +#define DISK_IDENT_SIZE 128 + typedef struct ddi_devid { char devid[DISK_IDENT_SIZE]; } ddi_devid_t; diff --git a/external/cddl/osnet/include/dtrace.h b/external/cddl/osnet/include/dtrace.h index 7b49b3b0a3b2..300bce796cfc 100644 --- a/external/cddl/osnet/include/dtrace.h +++ b/external/cddl/osnet/include/dtrace.h @@ -1,3 +1,5 @@ +/* $NetBSD: dtrace.h,v 1.2 2010/02/21 01:46:34 darran Exp $ */ + /* * Copyright (C) 2008 John Birrell * All rights reserved. diff --git a/external/cddl/osnet/include/fcntl.h b/external/cddl/osnet/include/fcntl.h index 936fa7ffd959..e39ab33fd49b 100644 --- a/external/cddl/osnet/include/fcntl.h +++ b/external/cddl/osnet/include/fcntl.h @@ -1,3 +1,5 @@ +/* $NetBSD: fcntl.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/cddl/compat/opensolaris/include/fcntl.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/compat/opensolaris/include/fcntl.h,v 1.1 2007/11/28 21:40:07 jb Exp $ * */ diff --git a/external/cddl/osnet/include/fsshare.h b/external/cddl/osnet/include/fsshare.h index 7baf19ed170d..3cff02e6eafe 100644 --- a/external/cddl/osnet/include/fsshare.h +++ b/external/cddl/osnet/include/fsshare.h @@ -1,3 +1,5 @@ +/* $NetBSD: fsshare.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/cddl/compat/opensolaris/include/fsshare.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/compat/opensolaris/include/fsshare.h,v 1.1 2007/04/06 01:08:58 pjd Exp $ */ #ifndef _OPENSOLARIS_FSSHARE_H_ diff --git a/external/cddl/osnet/include/libintl.h b/external/cddl/osnet/include/libintl.h index fdb3af77c3f4..640f0bd445f6 100644 --- a/external/cddl/osnet/include/libintl.h +++ b/external/cddl/osnet/include/libintl.h @@ -1,4 +1,33 @@ -/* $FreeBSD: src/cddl/compat/opensolaris/include/libintl.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ */ +/* $NetBSD: libintl.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #ifndef _LIBINTL_H_ #define _LIBINTL_H_ diff --git a/external/cddl/osnet/include/libproc.h b/external/cddl/osnet/include/libproc.h index c11c698bdf92..3e06715ed9a4 100644 --- a/external/cddl/osnet/include/libproc.h +++ b/external/cddl/osnet/include/libproc.h @@ -1,3 +1,5 @@ +/* $NetBSD: libproc.h,v 1.2 2010/02/21 01:46:34 darran Exp $ */ + /* * Copyright (C) 2008 John Birrell * All rights reserved. @@ -41,6 +43,24 @@ #define PGRAB_RDONLY O_RDONLY #define PGRAB_FORCE 0 +struct proc_handle; +typedef void (*proc_child_func)(void *); + +/* Values returned by proc_state(). */ +#define PS_IDLE 1 +#define PS_STOP 2 +#define PS_RUN 3 +#define PS_UNDEAD 4 +#define PS_DEAD 5 +#define PS_LOST 6 + + +typedef struct prmap { + uintptr_t pr_vaddr; /* Virtual address. */ +} prmap_t; + +#if 0 #include_next +#endif #endif diff --git a/external/cddl/osnet/include/libshare.h b/external/cddl/osnet/include/libshare.h index a3a06111585d..72927a0bdab2 100644 --- a/external/cddl/osnet/include/libshare.h +++ b/external/cddl/osnet/include/libshare.h @@ -1,3 +1,5 @@ +/* $NetBSD: libshare.h,v 1.2 2010/02/21 01:46:34 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. diff --git a/external/cddl/osnet/include/mnttab.h b/external/cddl/osnet/include/mnttab.h index 4f997b28d104..9a3f00702eef 100644 --- a/external/cddl/osnet/include/mnttab.h +++ b/external/cddl/osnet/include/mnttab.h @@ -1,4 +1,33 @@ -/* $FreeBSD: src/cddl/compat/opensolaris/include/mnttab.h,v 1.4.2.1 2009/08/03 08:13:06 kensmith Exp $ */ +/* $NetBSD: mnttab.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #ifndef _OPENSOLARIS_MNTTAB_H_ #define _OPENSOLARIS_MNTTAB_H_ @@ -9,8 +38,6 @@ #define MNTTAB _PATH_DEVNULL #define MNT_LINE_MAX 1024 -#define umount2(p, f) unmount(p, f) - struct mnttab { char *mnt_special; char *mnt_mountp; diff --git a/external/cddl/osnet/include/priv.h b/external/cddl/osnet/include/priv.h index 0a9d262d6a30..bd6b960844e7 100644 --- a/external/cddl/osnet/include/priv.h +++ b/external/cddl/osnet/include/priv.h @@ -1,19 +1,46 @@ -/* $FreeBSD: src/cddl/compat/opensolaris/include/priv.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ */ +/* $NetBSD: priv.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #ifndef _OPENSOLARIS_PRIV_H_ #define _OPENSOLARIS_PRIV_H_ #include +#include #include #include -#define PRIV_SYS_CONFIG 0 - static __inline int -priv_ineffect(priv) +priv_ineffect(const char *name) { - assert(priv == PRIV_SYS_CONFIG); return (geteuid() == 0); } diff --git a/external/cddl/osnet/include/solaris.h b/external/cddl/osnet/include/solaris.h index 69c073fe4569..690e93ad44d6 100644 --- a/external/cddl/osnet/include/solaris.h +++ b/external/cddl/osnet/include/solaris.h @@ -1,4 +1,33 @@ -/* $FreeBSD: src/cddl/compat/opensolaris/include/solaris.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ */ +/* $NetBSD: solaris.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #ifndef _SOLARIS_H_ #define _SOLARIS_H_ diff --git a/external/cddl/osnet/include/stdio.h b/external/cddl/osnet/include/stdio.h index 0648c5903487..711489c3f656 100644 --- a/external/cddl/osnet/include/stdio.h +++ b/external/cddl/osnet/include/stdio.h @@ -1,3 +1,5 @@ +/* $NetBSD: stdio.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/cddl/compat/opensolaris/include/stdio.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/compat/opensolaris/include/stdio.h,v 1.1 2007/11/28 21:40:07 jb Exp $ * */ diff --git a/external/cddl/osnet/include/stdlib.h b/external/cddl/osnet/include/stdlib.h index 38a3a6ee4739..4bdd75b69278 100644 --- a/external/cddl/osnet/include/stdlib.h +++ b/external/cddl/osnet/include/stdlib.h @@ -1,3 +1,5 @@ +/* $NetBSD: stdlib.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/cddl/compat/opensolaris/include/stdlib.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/compat/opensolaris/include/stdlib.h,v 1.1 2007/11/28 21:40:07 jb Exp $ * */ diff --git a/external/cddl/osnet/include/strings.h b/external/cddl/osnet/include/strings.h index 4d61854be31e..a711d3913cba 100644 --- a/external/cddl/osnet/include/strings.h +++ b/external/cddl/osnet/include/strings.h @@ -1,3 +1,5 @@ +/* $NetBSD: strings.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/cddl/compat/opensolaris/include/strings.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/compat/opensolaris/include/strings.h,v 1.1 2007/11/28 21:40:07 jb Exp $ * */ diff --git a/external/cddl/osnet/include/unistd.h b/external/cddl/osnet/include/unistd.h index 5a8ad2bb5f79..14784fc1672a 100644 --- a/external/cddl/osnet/include/unistd.h +++ b/external/cddl/osnet/include/unistd.h @@ -1,3 +1,5 @@ +/* $NetBSD: unistd.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/cddl/compat/opensolaris/include/unistd.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/compat/opensolaris/include/unistd.h,v 1.1 2007/11/28 21:40:07 jb Exp $ * */ diff --git a/external/cddl/osnet/include/zone.h b/external/cddl/osnet/include/zone.h index 67f7a888b8b7..39f4dcff5d3f 100644 --- a/external/cddl/osnet/include/zone.h +++ b/external/cddl/osnet/include/zone.h @@ -1,4 +1,33 @@ -/* $FreeBSD: src/cddl/compat/opensolaris/include/zone.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ */ +/* $NetBSD: zone.h,v 1.3 2010/02/21 01:46:34 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #ifndef _ZONE_H_ #define _ZONE_H_ diff --git a/external/cddl/osnet/lib/Makefile b/external/cddl/osnet/lib/Makefile index 09c30c890cf0..2448f053c4f9 100644 --- a/external/cddl/osnet/lib/Makefile +++ b/external/cddl/osnet/lib/Makefile @@ -1,22 +1,19 @@ -# $FreeBSD: src/cddl/lib/Makefile,v 1.9.2.1 2009/08/03 08:13:06 kensmith Exp $ +# $NetBSD: Makefile,v 1.3 2010/02/21 01:46:34 darran Exp $ +# +# -.include - -SUBDIR= drti \ - libavl \ - libctf \ - libdtrace \ - libnvpair \ - libumem \ - libuutil \ - ${_libzfs} \ - ${_libzpool} - -.if ${MK_ZFS} != "no" -_libzfs= libzfs -.if ${MK_LIBTHR} != "no" -_libzpool= libzpool +.if (defined(MKDTRACE) && ${MKDTRACE} != "no") +SUBDIR+= libdtrace +SUBDIR+= libctf .endif + +.if !defined(MKZFS) || ${MKZFS} != "no" +SUBDIR+= libavl +SUBDIR+= libnvpair +SUBDIR+= libumem +SUBDIR+= libuutil +SUBDIR+= libzfs +SUBDIR+= libzpool .endif .include diff --git a/external/cddl/osnet/lib/Makefile.inc b/external/cddl/osnet/lib/Makefile.inc index 306e48c52312..d5ba8261c5c6 100644 --- a/external/cddl/osnet/lib/Makefile.inc +++ b/external/cddl/osnet/lib/Makefile.inc @@ -1,6 +1,4 @@ -# $FreeBSD: src/cddl/lib/Makefile.inc,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ +# $NetBSD: Makefile.inc,v 1.3 2010/02/21 01:46:34 darran Exp $ -SHLIBDIR?= /lib -SHLIB_MAJOR?= 2 - -.include "../Makefile.inc" +MKLINT=no +MKLINTLIB=no diff --git a/external/cddl/osnet/lib/libavl/Makefile b/external/cddl/osnet/lib/libavl/Makefile index 67b79383cd6a..201b6ce914db 100644 --- a/external/cddl/osnet/lib/libavl/Makefile +++ b/external/cddl/osnet/lib/libavl/Makefile @@ -1,10 +1,9 @@ -# $FreeBSD: src/cddl/lib/libavl/Makefile,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ +# $NetBSD: Makefile,v 1.3 2010/02/21 01:46:35 darran Exp $ -.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/avl +.PATH: ${.CURDIR}/../../dist/common/avl LIB= avl SRCS= avl.c -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common +.include "../../Makefile.zfs" .include diff --git a/external/cddl/osnet/lib/libctf/Makefile b/external/cddl/osnet/lib/libctf/Makefile index d20efb0f12c2..64d3dc606880 100644 --- a/external/cddl/osnet/lib/libctf/Makefile +++ b/external/cddl/osnet/lib/libctf/Makefile @@ -1,9 +1,10 @@ +# $NetBSD: Makefile,v 1.2 2010/02/21 01:46:35 darran Exp $ + # $FreeBSD: src/cddl/lib/libctf/Makefile,v 1.2.2.1 2009/08/03 08:13:06 kensmith Exp $ .include "../../Makefile.inc" LIB= ctf -SHLIB_MAJOR= 2 SRCS= ctf_create.c \ ctf_decl.c \ @@ -23,8 +24,8 @@ SRCS= ctf_create.c \ CFLAGS+= -DCTF_OLD_VERSIONS -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \ - -I${.CURDIR}/../../../cddl/compat/opensolaris/include \ +CFLAGS+= -I${OSNETDIR}/sys \ + -I${OSNETDIR}/include \ -I${OPENSOLARIS_USR_DISTDIR}/head \ -I${OPENSOLARIS_USR_DISTDIR}/common/ctf \ -I${OPENSOLARIS_USR_DISTDIR}/lib/libctf/common \ diff --git a/external/cddl/osnet/lib/libctf/shlib_version b/external/cddl/osnet/lib/libctf/shlib_version new file mode 100644 index 000000000000..686c8bf8c54e --- /dev/null +++ b/external/cddl/osnet/lib/libctf/shlib_version @@ -0,0 +1,6 @@ +# $NetBSD: shlib_version,v 1.1 2010/02/21 01:46:35 darran Exp $ +# Remember to update distrib/sets/lists/base/shl.* when changing +# + +major=2 +minor=0 diff --git a/external/cddl/osnet/lib/libdtrace/Makefile b/external/cddl/osnet/lib/libdtrace/Makefile index 09e4c89f25de..291e478fdfa4 100644 --- a/external/cddl/osnet/lib/libdtrace/Makefile +++ b/external/cddl/osnet/lib/libdtrace/Makefile @@ -1,11 +1,12 @@ +# $NetBSD: Makefile,v 1.2 2010/02/21 01:46:35 darran Exp $ + # $FreeBSD: src/cddl/lib/libdtrace/Makefile,v 1.2.2.1 2009/08/03 08:13:06 kensmith Exp $ .include "../../Makefile.inc" LIB= dtrace -SHLIB_MAJOR= 2 -WARNS= 1 +#WARNS= 1 SRCS= dt_aggregate.c \ dt_as.c \ @@ -55,13 +56,15 @@ DSRCS= errno.d \ .PATH: ${OPENSOLARIS_USR_DISTDIR}/lib/libgen/common CFLAGS+= -I${.OBJDIR} \ - -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \ - -I${.CURDIR}/../../../cddl/compat/opensolaris/include \ + -I${OSNETDIR}/sys \ + -I${OSNETDIR}/include \ -I${OPENSOLARIS_USR_DISTDIR}/head \ -I${OPENSOLARIS_USR_DISTDIR}/lib/libctf/common \ -I${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common \ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common +# XXX need new libelf (not GPL) + #CFLAGS+= -DYYDEBUG .if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" @@ -77,7 +80,7 @@ LFLAGS+=-l YFLAGS+=-d -CLEANFILES= dt_errtags.c dt_names.c +CLEANFILES= dt_errtags.c dt_names.c dt_grammar.h dt_errtags.c: sh ${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common/mkerrtags.sh < ${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common/dt_errtags.h > dt_errtags.c @@ -87,11 +90,11 @@ dt_names.c: beforedepend: dt_errtags.c dt_names.c -beforeinstall: -.if exists(${DESTDIR}/usr/lib/dtrace) -.for file in ${DSRCS} - ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} ${.CURDIR}/${file} ${DESTDIR}/usr/lib/dtrace -.endfor -.endif +#beforeinstall: +#.if exists(${DESTDIR}/usr/lib/dtrace) +#.for file in ${DSRCS} +# ${INSTALL} -o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} ${.CURDIR}/${file} ${DESTDIR}/usr/lib/dtrace +#.endfor +#.endif .include diff --git a/external/cddl/osnet/lib/libdtrace/errno.d b/external/cddl/osnet/lib/libdtrace/errno.d index 9ccebb638c64..4fb6db3fd692 100644 --- a/external/cddl/osnet/lib/libdtrace/errno.d +++ b/external/cddl/osnet/lib/libdtrace/errno.d @@ -1,3 +1,5 @@ +/* $NetBSD: errno.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/lib/libdtrace/net.d b/external/cddl/osnet/lib/libdtrace/net.d index b81c8f7d1fdc..104fd1e452ce 100644 --- a/external/cddl/osnet/lib/libdtrace/net.d +++ b/external/cddl/osnet/lib/libdtrace/net.d @@ -1,3 +1,5 @@ +/* $NetBSD: net.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/lib/libdtrace/nfs.d b/external/cddl/osnet/lib/libdtrace/nfs.d index d5e99412cdd4..641c2bf88d30 100644 --- a/external/cddl/osnet/lib/libdtrace/nfs.d +++ b/external/cddl/osnet/lib/libdtrace/nfs.d @@ -1,3 +1,5 @@ +/* $NetBSD: nfs.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/lib/libdtrace/psinfo.d b/external/cddl/osnet/lib/libdtrace/psinfo.d index 248532259e42..580597186206 100644 --- a/external/cddl/osnet/lib/libdtrace/psinfo.d +++ b/external/cddl/osnet/lib/libdtrace/psinfo.d @@ -1,3 +1,5 @@ +/* $NetBSD: psinfo.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/lib/libdtrace/sched.d b/external/cddl/osnet/lib/libdtrace/sched.d index 5566d30ec61a..211981566fde 100644 --- a/external/cddl/osnet/lib/libdtrace/sched.d +++ b/external/cddl/osnet/lib/libdtrace/sched.d @@ -1,3 +1,5 @@ +/* $NetBSD: sched.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/lib/libdtrace/shlib_version b/external/cddl/osnet/lib/libdtrace/shlib_version new file mode 100644 index 000000000000..686c8bf8c54e --- /dev/null +++ b/external/cddl/osnet/lib/libdtrace/shlib_version @@ -0,0 +1,6 @@ +# $NetBSD: shlib_version,v 1.1 2010/02/21 01:46:35 darran Exp $ +# Remember to update distrib/sets/lists/base/shl.* when changing +# + +major=2 +minor=0 diff --git a/external/cddl/osnet/lib/libdtrace/signal.d b/external/cddl/osnet/lib/libdtrace/signal.d index 23c96fae94a4..12f41050092b 100644 --- a/external/cddl/osnet/lib/libdtrace/signal.d +++ b/external/cddl/osnet/lib/libdtrace/signal.d @@ -1,3 +1,5 @@ +/* $NetBSD: signal.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/lib/libdtrace/unistd.d b/external/cddl/osnet/lib/libdtrace/unistd.d index f6cc2c1930b3..abb46ece4ff7 100644 --- a/external/cddl/osnet/lib/libdtrace/unistd.d +++ b/external/cddl/osnet/lib/libdtrace/unistd.d @@ -1,3 +1,5 @@ +/* $NetBSD: unistd.d,v 1.2 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/lib/libnvpair/Makefile b/external/cddl/osnet/lib/libnvpair/Makefile index e1ad8d081c28..fa2ac2b24bb4 100644 --- a/external/cddl/osnet/lib/libnvpair/Makefile +++ b/external/cddl/osnet/lib/libnvpair/Makefile @@ -1,18 +1,17 @@ -# $FreeBSD: src/cddl/lib/libnvpair/Makefile,v 1.4.2.2 2009/08/17 08:09:46 pjd Exp $ +# $NetBSD: Makefile,v 1.4 2010/02/21 01:46:35 darran Exp $ -.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair -.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/nvpair +.PATH: ${.CURDIR}/../../dist/lib/libnvpair +.PATH: ${.CURDIR}/../../dist/common/nvpair LIB= nvpair -SRCS= libnvpair.c \ - nvpair_alloc_system.c \ - nvpair_alloc_fixed.c \ - nvpair.c +SRCS= lib_nvpair.c nvpair_alloc_system.c nvpair_alloc_fixed.c nvpair.c -CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common -CFLAGS+= -I${.CURDIR}/../../../sys +lib_nvpair.c: libnvpair.c + @rm -f ${.TARGET} + @ln -s ${.ALLSRC} ${.TARGET} +CLEANFILES+=lib_nvpair.c + +.include "../../Makefile.zfs" .include diff --git a/external/cddl/osnet/lib/libumem/Makefile b/external/cddl/osnet/lib/libumem/Makefile index 204b6027deae..094b790361bc 100644 --- a/external/cddl/osnet/lib/libumem/Makefile +++ b/external/cddl/osnet/lib/libumem/Makefile @@ -1,9 +1,7 @@ -# $FreeBSD: src/cddl/lib/libumem/Makefile,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ - -.PATH: ${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem +# $NetBSD: Makefile,v 1.3 2010/02/21 01:46:35 darran Exp $ LIB= umem SRCS= umem.c -CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem +.include "../../Makefile.zfs" .include diff --git a/external/cddl/osnet/lib/libuutil/Makefile b/external/cddl/osnet/lib/libuutil/Makefile index 6460797bf30a..b549c4061e77 100644 --- a/external/cddl/osnet/lib/libuutil/Makefile +++ b/external/cddl/osnet/lib/libuutil/Makefile @@ -1,25 +1,13 @@ -# $FreeBSD: src/cddl/lib/libuutil/Makefile,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ +# $NetBSD: Makefile,v 1.3 2010/02/21 01:46:35 darran Exp $ -.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common -.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/avl +.PATH: ${.CURDIR}/../../dist/lib/libuutil/common +.PATH: ${.CURDIR}/../../dist/common/avl LIB= uutil -SRCS= avl.c \ - uu_alloc.c \ - uu_avl.c \ - uu_dprintf.c \ - uu_ident.c \ - uu_list.c \ - uu_misc.c \ - uu_open.c \ - uu_pname.c \ - uu_strtoint.c +SRCS= avl.c uu_alloc.c uu_avl.c uu_dprintf.c uu_ident.c uu_list.c \ + uu_misc.c uu_open.c uu_pname.c uu_strtoint.c CFLAGS+= -DNATIVE_BUILD -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common -CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head +.include "../../Makefile.zfs" .include diff --git a/external/cddl/osnet/lib/libzfs/Makefile b/external/cddl/osnet/lib/libzfs/Makefile index 920227f868aa..5424abbbc9a0 100644 --- a/external/cddl/osnet/lib/libzfs/Makefile +++ b/external/cddl/osnet/lib/libzfs/Makefile @@ -1,51 +1,30 @@ -# $FreeBSD: src/cddl/lib/libzfs/Makefile,v 1.5.2.1 2009/08/03 08:13:06 kensmith Exp $ +# $NetBSD: Makefile,v 1.3 2010/02/21 01:46:35 darran Exp $ -.PATH: ${.CURDIR}/../../../cddl/compat/opensolaris/misc -.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs -.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs -.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common +.PATH: ${.CURDIR}/../../dist/common/zfs +.PATH: ${.CURDIR}/../../dist/common/fs/zfs +.PATH: ${.CURDIR}/../../dist/lib/libzfs/common LIB= zfs DPADD= ${LIBUTIL} LDADD= -lutil -SRCS= deviceid.c \ - fsshare.c \ - mkdirp.c \ - mnttab.c \ - zmount.c \ - zone.c +# Local +SRCS= deviceid.c mnttab.c mkdirp.c zmount.c fsshare.c zone.c efi.c ucred.c -SRCS+= zfs_deleg.c \ - zfs_namecheck.c \ - zfs_prop.c \ - zpool_prop.c \ - zprop_common.c \ - libzfs_dataset.c \ - libzfs_util.c \ - libzfs_graph.c \ - libzfs_mount.c \ - libzfs_pool.c \ - libzfs_changelist.c \ - libzfs_config.c \ - libzfs_import.c \ - libzfs_sendrecv.c \ - libzfs_status.c +# Sun +SRCS+= zfs_namecheck.c zprop_common.c zfs_prop.c zpool_prop.c +SRCS+= zfs_deleg.c zfs_comutil.c +SRCS+= libzfs_dataset.c libzfs_util.c libzfs_graph.c libzfs_mount.c +SRCS+= libzfs_pool.c libzfs_changelist.c libzfs_config.c libzfs_import.c +SRCS+= libzfs_status.c libzfs_sendrecv.c -CFLAGS+= -DZFS_NO_ACL -CFLAGS+= -I${.CURDIR}/../../../sbin/mount -CFLAGS+= -I${.CURDIR}/../../../cddl/lib/libumem -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris -CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include -CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzfs/common +CPPFLAGS+= -I${NETBSDSRCDIR}/sbin/mount +# Avoid conflict with libprop +CPPFLAGS+= -D_PROPLIB_ZFS_CONFLICT + +# Avoid internal header conflicts +CPPFLAGS+= -D_ZFS_CONTEXT_NO_VERIFY + +.include "../../Makefile.zfs" .include diff --git a/external/cddl/osnet/lib/libzpool/Makefile b/external/cddl/osnet/lib/libzpool/Makefile index f412a43728b2..73e3925bd4ee 100644 --- a/external/cddl/osnet/lib/libzpool/Makefile +++ b/external/cddl/osnet/lib/libzpool/Makefile @@ -1,63 +1,36 @@ -# $FreeBSD: src/cddl/lib/libzpool/Makefile,v 1.9.2.1 2009/08/03 08:13:06 kensmith Exp $ +# $NetBSD: Makefile,v 1.4 2010/02/21 01:46:35 darran Exp $ -.include "${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/Makefile.files" +.include "${.CURDIR}/../../dist/uts/common/Makefile.files" +.include "../../Makefile.zfs" -# ZFS_COMMON_SRCS -.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs -# ZFS_SHARED_SRCS -.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs -# KERNEL_SRCS -.PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common -# LIST_SRCS -.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/os -# ATOMIC_SRCS -.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "ia64" -.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/atomic/${MACHINE_ARCH} -ATOMIC_SRCS= opensolaris_atomic.S -.else -.PATH: ${.CURDIR}/../../../sys/cddl/compat/opensolaris/kern -ATOMIC_SRCS= opensolaris_atomic.c -.endif -# UNICODE_SRCS -.PATH: ${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/unicode +.PATH: ${.CURDIR}/../../dist/common/zfs +.PATH: ${.CURDIR}/../../dist/common/unicode +.PATH: ${.CURDIR}/../../dist/lib/libzpool/common +.PATH: ${.CURDIR}/../../dist/uts/common/fs/zfs +.PATH: ${.CURDIR}/../../dist/uts/common/os LIB= zpool - -ZFS_COMMON_SRCS= ${ZFS_COMMON_OBJS:C/.o$/.c/} vdev_file.c -ZFS_SHARED_SRCS= ${ZFS_SHARED_OBJS:C/.o$/.c/} -KERNEL_SRCS= kernel.c taskq.c util.c -LIST_SRCS= list.c -UNICODE_SRCS= u8_textprep.c - -SRCS= ${ZFS_COMMON_SRCS} ${ZFS_SHARED_SRCS} \ - ${KERNEL_SRCS} ${LIST_SRCS} ${ATOMIC_SRCS} \ - ${UNICODE_SRCS} - -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris -CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include -CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/sys -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common/fs/zfs -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/common/zfs -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/head -CFLAGS+= -I${.CURDIR}/../../../cddl/lib/libumem -CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libnvpair -# XXX: pthread doesn't have mutex_owned() equivalent, so we need to look -# into libthr private structures. That's sooo evil, but it's only for -# ZFS debugging tools needs. -CFLAGS+= -DWANTS_MUTEX_OWNED -CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/thread -CFLAGS+= -I${.CURDIR}/../../../lib/libpthread/sys -CFLAGS+= -I${.CURDIR}/../../../lib/libthr/arch/${MACHINE_ARCH}/include - DPADD= ${LIBPTHREAD} ${LIBZ} LDADD= -lpthread -lz +CPPFLAGS+= -std=c99 -# atomic.S doesn't like profiling. -NO_PROFILE= +# Local stuff +SRCS= kernel.c kernel2.c + +# Sun stuff +SRCS+= ${ZFS_COMMON_OBJS:C/.o$/.c/} +SRCS+= ${ZFS_SHARED_OBJS:C/.o$/.c/} +SRCS+= taskq.c util.c list.o u8_textprep.o + +# Add opensolaris atomic functions and use fakedones if we do not support them +.if ${MACHINE_ARCH} == "i386" +CPPFLAGS+= -D__HAVE_ATOMIC64_OPS # add NetBSD 64 add operations on i386 +.PATH: ${NETBSDSRCDIR}/common/lib/libc/atomic +SRCS+= atomic_add_64_cas.c atomic_add_64_nv_cas.c atomic_inc_64_add.c atomic_dec_64_add.c +.endif + +print: + echo ${LIST_SRCS} ${LIST_OBJS} -CSTD= c99 .include diff --git a/external/cddl/osnet/sys/sys/processor.h b/external/cddl/osnet/sys/elf.h similarity index 87% rename from external/cddl/osnet/sys/sys/processor.h rename to external/cddl/osnet/sys/elf.h index df3ca7ee182b..9cde17aa6612 100644 --- a/external/cddl/osnet/sys/sys/processor.h +++ b/external/cddl/osnet/sys/elf.h @@ -1,12 +1,9 @@ -/* $NetBSD: processor.h,v 1.1 2009/08/07 20:57:58 haad Exp $ */ +/* $NetBSD: elf.h,v 1.1 2010/02/21 01:46:35 darran Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. * - * This code is derived from software contributed to The NetBSD Foundation - * by Andrew Doran. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -28,3 +25,14 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ + +#ifndef _ELF_H_ +#define _ELF_H_ + +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif + +#endif diff --git a/external/cddl/osnet/sys/machine/endian.h b/external/cddl/osnet/sys/machine/endian.h index c7b65795ad20..422c770c8ca2 100644 --- a/external/cddl/osnet/sys/machine/endian.h +++ b/external/cddl/osnet/sys/machine/endian.h @@ -1,3 +1,5 @@ +/* $NetBSD: endian.h,v 1.2 2010/02/21 01:46:35 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. diff --git a/external/cddl/osnet/sys/sys/acl.h b/external/cddl/osnet/sys/sys/acl.h index bdcde76f3251..4d89128401cd 100644 --- a/external/cddl/osnet/sys/sys/acl.h +++ b/external/cddl/osnet/sys/sys/acl.h @@ -1,3 +1,5 @@ +/* $NetBSD: acl.h,v 1.2 2010/02/21 01:46:35 darran Exp $ */ + /*- * Copyright (c) 2008, 2009 Edward Tomasz Napierała * All rights reserved. diff --git a/external/cddl/osnet/sys/sys/acl/acl_common.h b/external/cddl/osnet/sys/sys/acl/acl_common.h index 12c1664ede57..e7a9d6b31aa7 100644 --- a/external/cddl/osnet/sys/sys/acl/acl_common.h +++ b/external/cddl/osnet/sys/sys/acl/acl_common.h @@ -1,3 +1,5 @@ +/* $NetBSD: acl_common.h,v 1.2 2010/02/21 01:46:36 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/sys/sys/atomic.h b/external/cddl/osnet/sys/sys/atomic.h index 92d1b31531c9..65259ffefb02 100644 --- a/external/cddl/osnet/sys/sys/atomic.h +++ b/external/cddl/osnet/sys/sys/atomic.h @@ -1,7 +1,12 @@ +/* $NetBSD: atomic.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + /*- - * Copyright (c) 2007 Pawel Jakub Dawidek + * Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -11,118 +16,69 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/atomic.h,v 1.6.2.1 2009/08/03 08:13:06 kensmith Exp $ + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _OPENSOLARIS_SYS_ATOMIC_H_ -#define _OPENSOLARIS_SYS_ATOMIC_H_ +#ifndef _CDDL_SYS_ATOMIC_H_ +#define _CDDL_SYS_ATOMIC_H_ -#include -#include +#include_next -#define casptr(_a, _b, _c) \ - atomic_cmpset_ptr((volatile uintptr_t *)(_a), (uintptr_t)(_b), (uintptr_t) (_c)) -#define cas32 atomic_cmpset_32 +#define casptr(_a, _b, _c) \ + atomic_cas_ptr((volatile uint64_t *) _a, _b, _c); -#ifndef __LP64__ -extern void atomic_add_64(volatile uint64_t *target, int64_t delta); -extern void atomic_dec_64(volatile uint64_t *target); -extern void *atomic_cas_ptr(volatile void *target, void *cmp, void *newval); -#endif -#ifndef __sparc64__ -extern uint64_t atomic_cas_64(volatile uint64_t *target, uint64_t cmp, - uint64_t newval); -#endif -extern uint64_t atomic_add_64_nv(volatile uint64_t *target, int64_t delta); -extern uint8_t atomic_or_8_nv(volatile uint8_t *target, uint8_t value); -extern void membar_producer(void); -#if defined(__sparc64__) || defined(__powerpc__) || defined(__arm__) || \ - defined(__mips__) -extern void atomic_or_8(volatile uint8_t *target, uint8_t value); + +static __inline void +atomic_or_8(volatile uint8_t *ptr, uint8_t val) +{ + uint32_t mask; + +#if _BYTE_ORDER == _LITTLE_ENDIAN + switch ((uintptr_t)ptr & 3) { + case 0: + mask = (uint32_t)val; + break; + case 1: + mask = (uint32_t)val << 8; + break; + case 2: + mask = (uint32_t)val << 16; + break; + case 3: + mask = (uint32_t)val << 24; + break; + } +#elif _BYTE_ORDER == _BIG_ENDIAN + switch ((uintptr_t)ptr & 3) { + case 3: + mask = (uint32_t)val; + break; + case 2: + mask = (uint32_t)val << 8; + break; + case 1: + mask = (uint32_t)val << 16; + break; + case 0: + mask = (uint32_t)val << 24; + break; + } #else -static __inline void -atomic_or_8(volatile uint8_t *target, uint8_t value) -{ - atomic_set_8(target, value); -} +#error What byte order? #endif -static __inline uint32_t -atomic_add_32_nv(volatile uint32_t *target, int32_t delta) -{ - return (atomic_fetchadd_32(target, delta) + delta); + atomic_or_32((uint32_t *)((uintptr_t)ptr & (uintptr_t)~3ULL), mask); } -static __inline u_int -atomic_add_int_nv(volatile u_int *target, int delta) -{ - return (atomic_add_32_nv(target, delta)); -} - -static __inline void -atomic_dec_32(volatile uint32_t *target) -{ - atomic_subtract_32(target, 1); -} - -static __inline uint32_t -atomic_dec_32_nv(volatile uint32_t *target) -{ - return (atomic_fetchadd_32(target, -1) - 1); -} - -#ifdef __LP64__ -static __inline void -atomic_dec_64(volatile uint64_t *target) -{ - atomic_subtract_64(target, 1); -} -#endif - -static __inline void -atomic_inc_32(volatile uint32_t *target) -{ - atomic_add_32(target, 1); -} - -static __inline uint32_t -atomic_inc_32_nv(volatile uint32_t *target) -{ - return (atomic_add_32_nv(target, 1)); -} - -static __inline void -atomic_inc_64(volatile uint64_t *target) -{ - atomic_add_64(target, 1); -} - -static __inline uint64_t -atomic_inc_64_nv(volatile uint64_t *target) -{ - return (atomic_add_64_nv(target, 1)); -} - -#ifdef __LP64__ -static __inline void * -atomic_cas_ptr(volatile void *target, void *cmp, void *newval) -{ - return ((void *)atomic_cas_64((volatile uint64_t *)target, (uint64_t)cmp, - (uint64_t)newval)); -} -#endif - -#endif /* !_OPENSOLARIS_SYS_ATOMIC_H_ */ +#endif /* _CDDL_SYS_ATOMIC_H */ diff --git a/external/cddl/osnet/sys/sys/bitmap.h b/external/cddl/osnet/sys/sys/bitmap.h index bb1f6457dd3e..9b6e9196ab44 100644 --- a/external/cddl/osnet/sys/sys/bitmap.h +++ b/external/cddl/osnet/sys/sys/bitmap.h @@ -1,3 +1,5 @@ +/* $NetBSD: bitmap.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * @@ -17,8 +19,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/bitmap.h,v 1.3.4.1 2009/08/03 08:13:06 kensmith Exp $ */ /* diff --git a/external/cddl/osnet/sys/sys/byteorder.h b/external/cddl/osnet/sys/sys/byteorder.h index 93afe5f6b8be..3aca9ba5dcf9 100644 --- a/external/cddl/osnet/sys/sys/byteorder.h +++ b/external/cddl/osnet/sys/sys/byteorder.h @@ -1,3 +1,5 @@ +/* $NetBSD: byteorder.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * @@ -17,8 +19,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/byteorder.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ */ /* diff --git a/external/cddl/osnet/sys/sys/cmn_err.h b/external/cddl/osnet/sys/sys/cmn_err.h index e27290c76d4c..3200048532f9 100644 --- a/external/cddl/osnet/sys/sys/cmn_err.h +++ b/external/cddl/osnet/sys/sys/cmn_err.h @@ -1,3 +1,34 @@ +/* $NetBSD: cmn_err.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,15 +54,20 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/cmn_err.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/cmn_err.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_CMN_ERR_H_ #define _OPENSOLARIS_SYS_CMN_ERR_H_ -#include #include +#ifdef _KERNEL +#include +#else +#include +#endif + #ifdef __cplusplus extern "C" { #endif @@ -44,8 +80,46 @@ extern "C" { #define CE_PANIC 3 /* panic */ #define CE_IGNORE 4 /* print nothing */ -void cmn_err(int, const char *, ...); -void vcmn_err(int, const char *, va_list); +void vcmn_err(int, const char *, va_list); +void cmn_err(int, const char *, ...); + +#ifdef XXXAD + +{ + char buf[256]; + + switch (ce) { + case CE_CONT: + snprintf(buf, sizeof(buf), "ZFS(cont): %s\n", fmt); + break; + case CE_NOTE: + snprintf(buf, sizeof(buf), "ZFS: NOTICE: %s\n", fmt); + break; + case CE_WARN: + snprintf(buf, sizeof(buf), "ZFS: WARNING: %s\n", fmt); + break; + case CE_PANIC: + snprintf(buf, sizeof(buf), "ZFS(panic): %s\n", fmt); + break; + case CE_IGNORE: + break; + default: + panic("unknown severity level"); + } + if (ce != CE_IGNORE) + vprintf(buf, adx); + if (ce == CE_PANIC) + panic("ZFS"); +} + +{ + va_list adx; + + va_start(adx, fmt); + vcmn_err(ce, fmt, adx); + va_end(adx); +} +#endif #ifdef __cplusplus } diff --git a/external/cddl/osnet/sys/sys/cpupart.h b/external/cddl/osnet/sys/sys/cpupart.h index 872c9bd7607a..002ac6421cf9 100644 --- a/external/cddl/osnet/sys/sys/cpupart.h +++ b/external/cddl/osnet/sys/sys/cpupart.h @@ -1,3 +1,5 @@ +/* $NetBSD: cpupart.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * @@ -17,8 +19,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/cpupart.h,v 1.3.4.1 2009/08/03 08:13:06 kensmith Exp $ */ /* diff --git a/external/cddl/osnet/sys/sys/cpuvar.h b/external/cddl/osnet/sys/sys/cpuvar.h index 7d1eaede6a71..59cf3866d92c 100644 --- a/external/cddl/osnet/sys/sys/cpuvar.h +++ b/external/cddl/osnet/sys/sys/cpuvar.h @@ -1,3 +1,5 @@ +/* $NetBSD: cpuvar.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/sys/sys/cpuvar_defs.h b/external/cddl/osnet/sys/sys/cpuvar_defs.h index d99eaea7947e..13e2722bdca1 100644 --- a/external/cddl/osnet/sys/sys/cpuvar_defs.h +++ b/external/cddl/osnet/sys/sys/cpuvar_defs.h @@ -1,3 +1,5 @@ +/* $NetBSD: cpuvar_defs.h,v 1.2 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/sys/sys/cred.h b/external/cddl/osnet/sys/sys/cred.h index e7d0b312401a..2254dff51b83 100644 --- a/external/cddl/osnet/sys/sys/cred.h +++ b/external/cddl/osnet/sys/sys/cred.h @@ -1,3 +1,5 @@ +/* $NetBSD: cred.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,36 +25,63 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/cred.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/cred.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_CRED_H_ #define _OPENSOLARIS_SYS_CRED_H_ #include -#define _WANT_UCRED -#include -#undef _WANT_UCRED - -typedef struct ucred cred_t; -typedef struct ucred ucred_t; +#include #ifdef _KERNEL -#define CRED() (curthread->td_ucred) +#include -/* - * kcred is used when you need all privileges. - */ -#define kcred (thread0.td_ucred) +#define CRED() (kauth_cred_get()) +#define KCRED() (cred0) +#define kcred cred0 -#define crgetuid(cred) ((cred)->cr_uid) -#define crgetgid(cred) ((cred)->cr_gid) -#define crgetgroups(cred) ((cred)->cr_groups) -#define crgetngroups(cred) ((cred)->cr_ngroups) -#define crgetsid(cred, i) (NULL) -#else /* !_KERNEL */ -#define kcred NULL -#define CRED() NULL -#endif /* !_KERNEL */ +extern kauth_cred_t cred0; + +#define crget(cr) cr = kauth_cred_get() +#define crgetuid(cr) kauth_cred_getuid(cr) +#define crgetgid(cr) kauth_cred_getgid(cr) +#define crgetngroups(cr) kauth_cred_ngroups(cr) +#define cralloc() kauth_cred_alloc() +#define crfree(cr) kauth_cred_free(cr) +#define crsetugid(cr, u, g) ( \ + kauth_cred_setuid(cr, u), \ + kauth_cred_setgid(cr, g), \ + kauth_cred_seteuid(cr, u), \ + kauth_cred_setegid(cr, g), \ + kauth_cred_setsvuid(cr, u), \ + kauth_cred_setsvgid(cr, g), 0) +#define crsetgroups(cr, gc, ga) \ + kauth_cred_setgroups(cr, ga, gc, 0, UIO_SYSSPACE) +#define crgetsid(cr, i) (NULL) + +static __inline gid_t * +crgetgroups(cred_t *cr) +{ + static gid_t gids[NGROUPS_MAX]; + + memset(gids, 0, NGROUPS_MAX); + if (kauth_cred_getgroups(cr, gids, NGROUPS_MAX, UIO_SYSSPACE) != 0) + return NULL; + + return gids; +} + +static int +groupmember(gid_t gid, cred_t *cr) +{ + int result; + + kauth_cred_ismember_gid(cr, gid, &result); + + return result; +} + +#endif /* _KERNEL */ #endif /* _OPENSOLARIS_SYS_CRED_H_ */ diff --git a/external/cddl/osnet/sys/sys/cyclic.h b/external/cddl/osnet/sys/sys/cyclic.h index 9383714c7205..945e9f02e4a9 100644 --- a/external/cddl/osnet/sys/sys/cyclic.h +++ b/external/cddl/osnet/sys/sys/cyclic.h @@ -1,30 +1,32 @@ +/* $NetBSD: cyclic.h,v 1.3 2010/02/21 01:46:35 darran 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. - * - * 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 - * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/cyclic.h,v 1.3.4.1 2009/08/03 08:13:06 kensmith Exp $ - * - */ -/* - * Copyright (c) 1999-2001 by Sun Microsystems, Inc. + * Copyright (C) 2007 John Birrell * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/compat/opensolaris/sys/cyclic.h,v 1.1 2007/11/28 21:50:40 jb Exp $ + * */ #ifndef _COMPAT_OPENSOLARIS_SYS_CYCLIC_H_ @@ -34,46 +36,6 @@ typedef void cpu_t; #endif - -#ifndef _ASM -#include -#include -#endif /* !_ASM */ - -#ifndef _ASM - -typedef uintptr_t cyclic_id_t; -typedef int cyc_index_t; -typedef uint16_t cyc_level_t; -typedef void (*cyc_func_t)(void *); -typedef void *cyb_arg_t; - -#define CYCLIC_NONE ((cyclic_id_t)0) - -typedef struct cyc_handler { - cyc_func_t cyh_func; - void *cyh_arg; -} cyc_handler_t; - -typedef struct cyc_time { - hrtime_t cyt_when; - hrtime_t cyt_interval; -} cyc_time_t; - -typedef struct cyc_omni_handler { - void (*cyo_online)(void *, cpu_t *, cyc_handler_t *, cyc_time_t *); - void (*cyo_offline)(void *, cpu_t *, void *); - void *cyo_arg; -} cyc_omni_handler_t; - -#ifdef _KERNEL - -cyclic_id_t cyclic_add(cyc_handler_t *, cyc_time_t *); -cyclic_id_t cyclic_add_omni(cyc_omni_handler_t *); -void cyclic_remove(cyclic_id_t); - -#endif /* _KERNEL */ - -#endif /* !_ASM */ +#include_next #endif diff --git a/external/cddl/osnet/sys/sys/cyclic_impl.h b/external/cddl/osnet/sys/sys/cyclic_impl.h index 3ffa0a5927a5..7a9999cb3cfb 100644 --- a/external/cddl/osnet/sys/sys/cyclic_impl.h +++ b/external/cddl/osnet/sys/sys/cyclic_impl.h @@ -1,3 +1,5 @@ +/* $NetBSD: cyclic_impl.h,v 1.2 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/sys/sys/debug.h b/external/cddl/osnet/sys/sys/debug.h index ad6dddb1f520..9ea88e35d3df 100644 --- a/external/cddl/osnet/sys/sys/debug.h +++ b/external/cddl/osnet/sys/sys/debug.h @@ -1,3 +1,5 @@ +/* $NetBSD: debug.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/debug.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/debug.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_DEBUG_H_ diff --git a/external/cddl/osnet/sys/sys/dirent.h b/external/cddl/osnet/sys/sys/dirent.h index 9e2bf00bd209..dde76e0e61c2 100644 --- a/external/cddl/osnet/sys/sys/dirent.h +++ b/external/cddl/osnet/sys/sys/dirent.h @@ -1,3 +1,5 @@ +/* $NetBSD: dirent.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/dirent.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/dirent.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_DIRENT_H_ diff --git a/external/cddl/osnet/sys/sys/dkio.h b/external/cddl/osnet/sys/sys/dkio.h index 2e1e85f8700b..6974f062dc80 100644 --- a/external/cddl/osnet/sys/sys/dkio.h +++ b/external/cddl/osnet/sys/sys/dkio.h @@ -1,3 +1,5 @@ +/* $NetBSD: dkio.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * @@ -17,8 +19,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/dkio.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ */ /* * Copyright 2006 Sun Microsystems, Inc. All rights reserved. @@ -28,6 +28,7 @@ #ifndef _OPENSOLARIS_SYS_DKIO_H_ #define _OPENSOLARIS_SYS_DKIO_H_ + #ifdef __cplusplus extern "C" { #endif @@ -84,4 +85,6 @@ struct dk_callback { } #endif +#include_next + #endif /* _OPENSOLARIS_SYS_DKIO_H_ */ diff --git a/external/cddl/osnet/sys/sys/dnlc.h b/external/cddl/osnet/sys/sys/dnlc.h index 765bd6196329..b017b7c2f4ea 100644 --- a/external/cddl/osnet/sys/sys/dnlc.h +++ b/external/cddl/osnet/sys/sys/dnlc.h @@ -1,3 +1,5 @@ +/* $NetBSD: dnlc.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/dnlc.h,v 1.4.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/dnlc.h,v 1.2 2007/05/24 13:44:45 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_DNLC_H_ @@ -35,6 +37,6 @@ #define dnlc_update(dvp, name, vp) do { } while (0) #define dnlc_remove(dvp, name) do { } while (0) #define dnlc_purge_vfsp(vfsp, count) (0) -#define dnlc_reduce_cache(percent) EVENTHANDLER_INVOKE(vfs_lowvnodes, (int)(intptr_t)(percent)) +#define dnlc_reduce_cache(percent) do { } while (0) #endif /* !_OPENSOLARIS_SYS_DNLC_H_ */ diff --git a/external/cddl/osnet/sys/sys/elf.h b/external/cddl/osnet/sys/sys/elf.h index c1d0bafbe824..3d49c78bc511 100644 --- a/external/cddl/osnet/sys/sys/elf.h +++ b/external/cddl/osnet/sys/sys/elf.h @@ -1,3 +1,5 @@ +/* $NetBSD: elf.h,v 1.3 2010/02/21 01:46:35 darran Exp $ */ + /* * CDDL HEADER START * @@ -18,7 +20,7 @@ * * CDDL HEADER END * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/elf.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/elf.h,v 1.1 2007/11/28 21:50:40 jb Exp $ * * ELF compatibility definitions for OpenSolaris source. * @@ -27,32 +29,20 @@ #ifndef _SYS__ELF_SOLARIS_H_ #define _SYS__ELF_SOLARIS_H_ -#include_next +#if HAVE_NBTOOL_CONFIG_H +#include +#else +#include +#endif -#define __sElfN(x) typedef __CONCAT(__CONCAT(__CONCAT(Elf,__ELF_WORD_SIZE),_),x) x +#define SHT_SUNW_dof 0x6ffffff4 +#define EM_AMD64 EM_X86_64 -__sElfN(Addr); -__sElfN(Cap); -__sElfN(Dyn); -__sElfN(Ehdr); -__sElfN(Move); -__sElfN(Off); -__sElfN(Phdr); -__sElfN(Rel); -__sElfN(Rela); -__sElfN(Shdr); -__sElfN(Sym); -__sElfN(Syminfo); -__sElfN(Verdaux); -__sElfN(Verdef); -__sElfN(Vernaux); -__sElfN(Verneed); -__sElfN(Versym); - -__sElfN(Half); -__sElfN(Sword); -__sElfN(Word); +#define __ELF_WORD_SIZE ELFSIZE +#define __CONCAT(x,y) x ## y +#define __sElfN(x) typedef __CONCAT(Elf32_,x) x +#if 0 /* XXX not needed? */ #if __ELF_WORD_SIZE == 32 typedef Elf32_Word Xword; /* Xword/Sxword are 32-bits in Elf32 */ typedef Elf32_Sword Sxword; @@ -112,5 +102,6 @@ typedef Elf64_Sxword Sxword; #define Elf_ver_line_4 __ElfN(ver_line_4) #define Elf_ver_line_5 __ElfN(ver_line_5) #define Elf_ver_need_title __ElfN(ver_need_title) +#endif #endif /* !_SYS__ELF_SOLARIS_H_ */ diff --git a/external/cddl/osnet/sys/sys/feature_tests.h b/external/cddl/osnet/sys/sys/feature_tests.h index 5b8d1a829057..eb0620fd8ea3 100644 --- a/external/cddl/osnet/sys/sys/feature_tests.h +++ b/external/cddl/osnet/sys/sys/feature_tests.h @@ -1,3 +1,5 @@ +/* $NetBSD: feature_tests.h,v 1.2 2010/02/21 01:46:36 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. diff --git a/external/cddl/osnet/sys/sys/file.h b/external/cddl/osnet/sys/sys/file.h index 8a149047baa1..f2d234076e88 100644 --- a/external/cddl/osnet/sys/sys/file.h +++ b/external/cddl/osnet/sys/sys/file.h @@ -1,3 +1,5 @@ +/* $NetBSD: file.h,v 1.2 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. diff --git a/external/cddl/osnet/sys/sys/idmap.h b/external/cddl/osnet/sys/sys/idmap.h index 3a405e409708..a88cad4e45d6 100644 --- a/external/cddl/osnet/sys/sys/idmap.h +++ b/external/cddl/osnet/sys/sys/idmap.h @@ -1,3 +1,5 @@ +/* $NetBSD: idmap.h,v 1.2 2010/02/21 01:46:36 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/sys/sys/kcondvar.h b/external/cddl/osnet/sys/sys/kcondvar.h index 0df62aeeabb3..2ca3961adb7b 100644 --- a/external/cddl/osnet/sys/sys/kcondvar.h +++ b/external/cddl/osnet/sys/sys/kcondvar.h @@ -1,7 +1,12 @@ +/* $NetBSD: kcondvar.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- - * Copyright (c) 2007 Pawel Jakub Dawidek + * Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -11,52 +16,33 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/kcondvar.h,v 1.3.4.1 2009/08/03 08:13:06 kensmith Exp $ + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _OPENSOLARIS_SYS_CONDVAR_H_ -#define _OPENSOLARIS_SYS_CONDVAR_H_ +#ifndef _OPENSOLARIS_SYS_KCONDVAR_H_ +#define _OPENSOLARIS_SYS_KCONDVAR_H_ -#include -#include +#include_next #ifdef _KERNEL -#include -#include - -typedef struct cv kcondvar_t; - typedef enum { CV_DEFAULT, CV_DRIVER } kcv_type_t; -#define zfs_cv_init(cv, name, type, arg) do { \ - const char *_name; \ - ASSERT((type) == CV_DEFAULT); \ - for (_name = #cv; *_name != '\0'; _name++) { \ - if (*_name >= 'a' && *_name <= 'z') \ - break; \ - } \ - if (*_name == '\0') \ - _name = #cv; \ - cv_init((cv), _name); \ -} while (0) -#define cv_init(cv, name, type, arg) zfs_cv_init((cv), (name), (type), (arg)) +#define cv_init(a, b, c, d) cv_init(a, "zfscv") #endif /* _KERNEL */ -#endif /* _OPENSOLARIS_SYS_CONDVAR_H_ */ +#endif /* _OPENSOLARIS_SYS_KCONDVAR_H_ */ diff --git a/external/cddl/osnet/sys/sys/kidmap.h b/external/cddl/osnet/sys/sys/kidmap.h index 2b11a09c085d..b86a9b098451 100644 --- a/external/cddl/osnet/sys/sys/kidmap.h +++ b/external/cddl/osnet/sys/sys/kidmap.h @@ -1,3 +1,5 @@ +/* $NetBSD: kidmap.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/kidmap.h,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD$ */ #ifndef _OPENSOLARIS_SYS_KIDMAP_H_ diff --git a/external/cddl/osnet/sys/sys/kmem.h b/external/cddl/osnet/sys/sys/kmem.h index 084aa07ea325..c3d189761bb3 100644 --- a/external/cddl/osnet/sys/sys/kmem.h +++ b/external/cddl/osnet/sys/sys/kmem.h @@ -1,7 +1,13 @@ + +/* $NetBSD: kmem.h,v 1.6 2010/02/21 01:46:36 darran Exp $ */ + /*- - * Copyright (c) 2007 Pawel Jakub Dawidek + * Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -11,68 +17,57 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/kmem.h,v 1.7.2.1 2009/08/03 08:13:06 kensmith Exp $ + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _OPENSOLARIS_SYS_KMEM_H_ #define _OPENSOLARIS_SYS_KMEM_H_ -#include -#include -#include +#include_next +#include_next +#include_next -#include -#include -#include +typedef void kmem_cache_t; -#define KM_SLEEP M_WAITOK -#define KM_PUSHPAGE M_WAITOK -#define KM_NOSLEEP M_NOWAIT -#define KMC_NODEBUG 0 +u_long kmem_size(void); +u_long kmem_used(void); +void kmem_reap(void); -typedef struct kmem_cache { - char kc_name[32]; -#if defined(_KERNEL) && !defined(KMEM_DEBUG) - uma_zone_t kc_zone; -#else - size_t kc_size; -#endif - int (*kc_constructor)(void *, void *, int); - void (*kc_destructor)(void *, void *); - void *kc_private; -} kmem_cache_t; +void *calloc(size_t n, size_t s); -#define vmem_t void - -void *zfs_kmem_alloc(size_t size, int kmflags); -void zfs_kmem_free(void *buf, size_t size); -uint64_t kmem_size(void); -uint64_t kmem_used(void); -kmem_cache_t *kmem_cache_create(char *name, size_t bufsize, size_t align, +static inline kmem_cache_t * +kmem_cache_create(char *name, size_t bufsize, size_t align, int (*constructor)(void *, void *, int), void (*destructor)(void *, void *), - void (*reclaim)(void *) __unused, void *private, vmem_t *vmp, int cflags); -void kmem_cache_destroy(kmem_cache_t *cache); -void *kmem_cache_alloc(kmem_cache_t *cache, int flags); -void kmem_cache_free(kmem_cache_t *cache, void *buf); -void kmem_cache_reap_now(kmem_cache_t *cache); -void kmem_reap(void); -int kmem_debugging(void); -void *calloc(size_t n, size_t s); + void (*reclaim)(void *) __unused, void *private, vmem_t *vmp, int cflags) +{ + pool_cache_t pc; -#define kmem_alloc(size, kmflags) zfs_kmem_alloc((size), (kmflags)) -#define kmem_zalloc(size, kmflags) zfs_kmem_alloc((size), (kmflags) | M_ZERO) -#define kmem_free(buf, size) zfs_kmem_free((buf), (size)) + KASSERT(vmp == NULL); + + pc = pool_cache_init(bufsize, align, 0, 0, name, NULL, IPL_NONE, + constructor, destructor, private); + if (pc != NULL && reclaim != NULL) { + pool_cache_set_drain_hook(pc, (void *)reclaim, private); + } + return pc; +} + +#define kmem_cache_destroy(cache) pool_cache_destroy(cache) +#define kmem_cache_alloc(cache, flags) pool_cache_get(cache, flags) +#define kmem_cache_free(cache, buf) pool_cache_put(cache, buf) +#define kmem_cache_reap_now(cache) pool_cache_invalidate(cache) + +#define KM_PUSHPAGE 0x00 /* XXXNETBSD */ +#define KMC_NODEBUG 0x00 #endif /* _OPENSOLARIS_SYS_KMEM_H_ */ diff --git a/external/cddl/osnet/sys/sys/kobj.h b/external/cddl/osnet/sys/sys/kobj.h index d3592d3e2019..089e887df504 100644 --- a/external/cddl/osnet/sys/sys/kobj.h +++ b/external/cddl/osnet/sys/sys/kobj.h @@ -1,3 +1,5 @@ +/* $NetBSD: kobj.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/kobj.h,v 1.3.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/kobj.h,v 1.2 2007/04/08 23:57:08 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_KOBJ_H_ @@ -31,7 +33,6 @@ #include #include -#include_next #ifdef AT_UID #undef AT_UID #endif diff --git a/external/cddl/osnet/sys/sys/kstat.h b/external/cddl/osnet/sys/sys/kstat.h index ea83b6dd3ff3..0cb86df02105 100644 --- a/external/cddl/osnet/sys/sys/kstat.h +++ b/external/cddl/osnet/sys/sys/kstat.h @@ -1,3 +1,34 @@ +/* $NetBSD: kstat.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +54,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/kstat.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/kstat.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_KSTAT_H_ @@ -38,10 +69,8 @@ typedef struct kstat { void *ks_data; u_int ks_ndata; -#ifdef _KERNEL - struct sysctl_ctx_list ks_sysctl_ctx; - struct sysctl_oid *ks_sysctl_root; -#endif + struct sysctllog *ks_clog; + const struct sysctlnode *ks_node; } kstat_t; typedef struct kstat_named { diff --git a/external/cddl/osnet/sys/sys/lock.h b/external/cddl/osnet/sys/sys/lock.h index 1c8a8f230bfc..8952b922ee97 100644 --- a/external/cddl/osnet/sys/sys/lock.h +++ b/external/cddl/osnet/sys/sys/lock.h @@ -1,3 +1,5 @@ +/* $NetBSD: lock.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/lock.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/lock.h,v 1.1 2007/04/09 01:05:31 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_LOCK_H_ @@ -35,7 +37,8 @@ #define LO_ALLMASK (LO_INITIALIZED | LO_WITNESS | LO_QUIET | \ LO_RECURSABLE | LO_SLEEPABLE | LO_UPGRADABLE | \ - LO_DUPOK | LO_CLASSMASK | LO_NOPROFILE) + LO_DUPOK | LO_ENROLLPEND | LO_CLASSMASK | \ + LO_NOPROFILE) #define LO_EXPECTED (LO_INITIALIZED | LO_WITNESS | LO_RECURSABLE | \ LO_SLEEPABLE | LO_UPGRADABLE | LO_DUPOK | \ /* sx lock class */(2 << LO_CLASSSHIFT)) diff --git a/external/cddl/osnet/sys/sys/misc.h b/external/cddl/osnet/sys/sys/misc.h index 4aef05491303..2f285bc3fb99 100644 --- a/external/cddl/osnet/sys/sys/misc.h +++ b/external/cddl/osnet/sys/sys/misc.h @@ -1,3 +1,5 @@ +/* $NetBSD: misc.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,19 +25,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/misc.h,v 1.4.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/misc.h,v 1.2 2007/04/23 00:52:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_MISC_H_ #define _OPENSOLARIS_SYS_MISC_H_ -#define MAXUID 2147483647 - -#define SPEC_MAXOFFSET_T OFF_MAX - -#define _ACL_ACLENT_ENABLED 0x1 -#define _ACL_ACE_ENABLED 0x2 - #define _FIOFFS (INT_MIN) #define _FIOGDIO (INT_MIN+1) #define _FIOSDIO (INT_MIN+2) @@ -43,10 +38,6 @@ #define _FIO_SEEK_DATA FIOSEEKDATA #define _FIO_SEEK_HOLE FIOSEEKHOLE -struct opensolaris_utsname { - char *nodename; -}; - extern char hw_serial[11]; -extern struct opensolaris_utsname utsname; + #endif /* _OPENSOLARIS_SYS_MISC_H_ */ diff --git a/external/cddl/osnet/sys/sys/mman.h b/external/cddl/osnet/sys/sys/mman.h index b753f558335b..21f4a59b4a80 100644 --- a/external/cddl/osnet/sys/sys/mman.h +++ b/external/cddl/osnet/sys/sys/mman.h @@ -1,3 +1,5 @@ +/* $NetBSD: mman.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/mman.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/mman.h,v 1.1 2007/11/28 21:50:40 jb Exp $ * */ diff --git a/external/cddl/osnet/sys/sys/mntent.h b/external/cddl/osnet/sys/sys/mntent.h index 691b28939ef6..a30bce6f3920 100644 --- a/external/cddl/osnet/sys/sys/mntent.h +++ b/external/cddl/osnet/sys/sys/mntent.h @@ -1,3 +1,5 @@ +/* $NetBSD: mntent.h,v 1.2 2010/02/21 01:46:36 darran Exp $ */ + /* * CDDL HEADER START * diff --git a/external/cddl/osnet/sys/sys/mnttab.h b/external/cddl/osnet/sys/sys/mnttab.h index 8bc72765a0a4..c7413304592d 100644 --- a/external/cddl/osnet/sys/sys/mnttab.h +++ b/external/cddl/osnet/sys/sys/mnttab.h @@ -1,36 +1,105 @@ -/*- - * Copyright (c) 2007 Pawel Jakub Dawidek - * All rights reserved. +/* $NetBSD: mnttab.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + +/* + * CDDL HEADER START * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. + * 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. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. + * 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. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/mnttab.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * 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 (c) 1984, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + + +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. */ -#ifndef _OPENSOLARIS_SYS_MNTTAB_H_ -#define _OPENSOLARIS_SYS_MNTTAB_H_ +#ifndef _SYS_MNTTAB_H +#define _SYS_MNTTAB_H -#ifndef _KERNEL -#include +#pragma ident "%Z%%M% %I% %E% SMI" + +#include +#include + +#ifdef __cplusplus +extern "C" { #endif -#endif /* !_OPENSOLARIS_MNTTAB_H_ */ +#define MNTTAB "/etc/mnttab" +#define MNT_LINE_MAX 1024 + +#define MNT_TOOLONG 1 /* entry exceeds MNT_LINE_MAX */ +#define MNT_TOOMANY 2 /* too many fields in line */ +#define MNT_TOOFEW 3 /* too few fields in line */ + +#define mntnull(mp)\ + ((mp)->mnt_special = (mp)->mnt_mountp = \ + (mp)->mnt_fstype = (mp)->mnt_mntopts = \ + (mp)->mnt_time = NULL) + +#define putmntent(fd, mp) (-1) + +struct mnttab { + char *mnt_special; + char *mnt_mountp; + char *mnt_fstype; + char *mnt_mntopts; + char *mnt_time; +}; + +/* + * NOTE: fields in extmnttab should match struct mnttab till new fields + * are encountered, this allows hasmntopt to work properly when its arg is + * a pointer to an extmnttab struct cast to a mnttab struct pointer. + */ +struct extmnttab { + char *mnt_special; + char *mnt_mountp; + char *mnt_fstype; + char *mnt_mntopts; + char *mnt_time; + uint_t mnt_major; + uint_t mnt_minor; +}; + +#if !defined(_KERNEL) +#ifdef __STDC__ +extern void resetmnttab(FILE *); +extern int getmntent(FILE *, struct mnttab *); +extern int getextmntent(FILE *, struct extmnttab *, size_t); +extern int getmntany(FILE *, struct mnttab *, struct mnttab *); +extern int getstatfs(struct statvfs *, const char *); +extern char *hasmntopt(struct mnttab *, char *); +extern char *mntopt(char **); +#else +extern void resetmnttab(); +extern int getmntent(); +extern int getextmntent(); +extern int getmntany(); +extern char *hasmntopt(); +extern char *mntopt(); +#endif +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MNTTAB_H */ diff --git a/external/cddl/osnet/sys/sys/modctl.h b/external/cddl/osnet/sys/sys/modctl.h index aefd84814b7c..bad28436c855 100644 --- a/external/cddl/osnet/sys/sys/modctl.h +++ b/external/cddl/osnet/sys/sys/modctl.h @@ -1,3 +1,5 @@ +/* $NetBSD: modctl.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. @@ -32,7 +34,8 @@ #include #include +#include -typedef struct linker_file modctl_t; +typedef struct module dtrace_modctl_t; #endif /* _COMPAT_OPENSOLARIS_SYS_MODCTL_H */ diff --git a/external/cddl/osnet/sys/sys/mount.h b/external/cddl/osnet/sys/sys/mount.h index c75f5a23545d..8bf723106923 100644 --- a/external/cddl/osnet/sys/sys/mount.h +++ b/external/cddl/osnet/sys/sys/mount.h @@ -1,3 +1,5 @@ +/* $NetBSD: mount.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,17 +25,42 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/mount.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/mount.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ +#include_next + #ifndef _OPENSOLARIS_SYS_MOUNT_H_ #define _OPENSOLARIS_SYS_MOUNT_H_ -#include_next - +#define MS_OVERLAY 0 #define MS_FORCE MNT_FORCE #define MS_REMOUNT MNT_UPDATE +#define MS_OPTIONSTR __MNT_UNUSED1 +#define MS_NOMNTTAB __MNT_UNUSED2 typedef struct fid fid_t; +#define mount(a,b,c,d,e,f,g,h) zmount(a,b,c,d,e,f,g,h) + +struct zfs_args { + char fspec[MAXNAMELEN - 1]; + char dataptr[MAXPATHLEN]; + char optptr[MAXPATHLEN]; + char *fstype; + int mflag; + int datalen; + int optlen; + int flags; +} za; + +typedef struct zfs_args zfs_args_t; + +int +zmount(const char *spec, const char *dir, int mflag, char *fstype, + char *dataptr, int datalen, char *optptr, int optlen); + +int +umount2(const char *spec, int mflag); + #endif /* !_OPENSOLARIS_SYS_MOUNT_H_ */ diff --git a/external/cddl/osnet/sys/sys/mutex.h b/external/cddl/osnet/sys/sys/mutex.h index 5be87b6b4fed..3c85796fad87 100644 --- a/external/cddl/osnet/sys/sys/mutex.h +++ b/external/cddl/osnet/sys/sys/mutex.h @@ -1,7 +1,12 @@ +/* $NetBSD: mutex.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- - * Copyright (c) 2007 Pawel Jakub Dawidek + * Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -11,68 +16,29 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/mutex.h,v 1.7.2.2 2009/09/15 11:13:40 pjd Exp $ + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. */ #ifndef _OPENSOLARIS_SYS_MUTEX_H_ #define _OPENSOLARIS_SYS_MUTEX_H_ +#include_next + #ifdef _KERNEL -#include -#include -#include_next -#include -#include - -typedef enum { - MUTEX_DEFAULT = 6 /* kernel default mutex */ -} kmutex_type_t; - #define MUTEX_HELD(x) (mutex_owned(x)) -#define MUTEX_NOT_HELD(x) (!mutex_owned(x) || panicstr) - -typedef struct sx kmutex_t; - -#ifndef DEBUG -#define MUTEX_FLAGS (SX_DUPOK | SX_NOWITNESS) -#else -#define MUTEX_FLAGS (SX_DUPOK) -#endif - -#define mutex_init(lock, desc, type, arg) do { \ - const char *_name; \ - ASSERT((type) == MUTEX_DEFAULT); \ - KASSERT(((lock)->lock_object.lo_flags & LO_ALLMASK) != \ - LO_EXPECTED, ("lock %s already initialized", #lock)); \ - bzero((lock), sizeof(struct sx)); \ - for (_name = #lock; *_name != '\0'; _name++) { \ - if (*_name >= 'a' && *_name <= 'z') \ - break; \ - } \ - if (*_name == '\0') \ - _name = #lock; \ - sx_init_flags((lock), _name, MUTEX_FLAGS); \ -} while (0) -#define mutex_destroy(lock) sx_destroy(lock) -#define mutex_enter(lock) sx_xlock(lock) -#define mutex_tryenter(lock) sx_try_xlock(lock) -#define mutex_exit(lock) sx_xunlock(lock) -#define mutex_owned(lock) sx_xlocked(lock) -/* TODO: Change to sx_xholder() once it is moved from kern_sx.c to sx.h. */ -#define mutex_owner(lock) ((lock)->sx_lock & SX_LOCK_SHARED ? NULL : (struct thread *)SX_OWNER((lock)->sx_lock)) +#define MUTEX_NOT_HELD(x) (!mutex_owned(x) || panicstr != NULL) +#define mutex_init(a, b, c, d) mutex_init(a, c, IPL_NONE) #endif /* _KERNEL */ diff --git a/external/cddl/osnet/sys/sys/mutex_impl.h b/external/cddl/osnet/sys/sys/mutex_impl.h new file mode 100644 index 000000000000..58710759ff67 --- /dev/null +++ b/external/cddl/osnet/sys/sys/mutex_impl.h @@ -0,0 +1,48 @@ +/* $NetBSD: mutex_impl.h,v 1.1 2010/02/21 01:46:36 darran Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _COMPAT_OPENSOLARIS_SYS_MUTEX_IMPL_H +#define _COMPAT_OPENSOLARIS_SYS_MUTEX_IMPL_H + +#define __MUTEX_PRIVATE +#include + +#define mtx_owner u.mtxa_owner +#define MUTEX_THREAD ((uintptr_t)-16L) +#define MUTEX_OWNER(mtx) \ + ((mtx)->mtx_owner & MUTEX_THREAD) +#define MUTEX_NO_OWNER 0 + +#define MUTEX_BIT_SPIN 0x01 +#define MUTEX_TYPE_ADAPTIVE(mtx) (((mtx)->mtx_owner & MUTEX_BIT_SPIN) == 0) +#define MUTEX_TYPE_SPIN(mtx) (((mtx)->mtx_owner & MUTEX_BIT_SPIN) != 0) + +#endif diff --git a/external/cddl/osnet/sys/sys/objfs.h b/external/cddl/osnet/sys/sys/objfs.h index 93395c7ffff6..c6ac8a67ba54 100644 --- a/external/cddl/osnet/sys/sys/objfs.h +++ b/external/cddl/osnet/sys/sys/objfs.h @@ -1,3 +1,5 @@ +/* $NetBSD: objfs.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /* * CDDL HEADER START * @@ -17,8 +19,6 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/objfs.h,v 1.3.4.1 2009/08/03 08:13:06 kensmith Exp $ */ #ifndef _COMPAT_OPENSOLARIS_SYS_OBJFS_H diff --git a/external/cddl/osnet/sys/sys/param.h b/external/cddl/osnet/sys/sys/param.h index 6a925be194c5..63db7e1febac 100644 --- a/external/cddl/osnet/sys/sys/param.h +++ b/external/cddl/osnet/sys/sys/param.h @@ -1,3 +1,5 @@ +/* $NetBSD: param.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/param.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/param.h,v 1.1 2007/11/28 21:50:40 jb Exp $ * */ @@ -32,10 +34,10 @@ #include_next -#define PAGESIZE PAGE_SIZE - #ifdef _KERNEL -#define ptob(x) ((uint64_t)(x) << PAGE_SHIFT) +#define PAGESIZE PAGE_SIZE +#else +#define PAGESIZE getpagesize() #endif #endif diff --git a/external/cddl/osnet/sys/sys/pathname.h b/external/cddl/osnet/sys/sys/pathname.h index fa989d19cc61..9005e7ea06a9 100644 --- a/external/cddl/osnet/sys/sys/pathname.h +++ b/external/cddl/osnet/sys/sys/pathname.h @@ -1,3 +1,5 @@ +/* $NetBSD: pathname.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/pathname.h,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/pathname.h,v 1.1 2008/11/17 20:49:29 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_PATHNAME_H_ @@ -44,8 +46,10 @@ typedef struct pathname { #define pn_alloc(pnp) panic("pn_alloc() called") #define pn_free(pnp) panic("pn_free() called") -int lookupname(char *, enum uio_seg, enum symfollow, vnode_t **, vnode_t **); -int lookupnameat(char *, enum uio_seg, enum symfollow, vnode_t **, vnode_t **, +#define NO_FOLLOW NOFOLLOW + +int lookupname(char *, enum uio_seg, vnode_t **, vnode_t **); +int lookupnameat(char *, enum uio_seg, vnode_t **, vnode_t **, vnode_t *); int traverse(vnode_t **, int); diff --git a/external/cddl/osnet/sys/sys/pcpu.h b/external/cddl/osnet/sys/sys/pcpu.h index 4e0bd83f4046..a32efd0cfc85 100644 --- a/external/cddl/osnet/sys/sys/pcpu.h +++ b/external/cddl/osnet/sys/sys/pcpu.h @@ -1,3 +1,5 @@ +/* $NetBSD: pcpu.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/pcpu.h,v 1.3.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/pcpu.h,v 1.1 2007/11/28 21:50:40 jb Exp $ * */ @@ -32,6 +34,8 @@ #include_next -typedef struct pcpu pcpu_t; +typedef struct pcpu cpu_t; + +#define cpu_id pc_cpuid #endif diff --git a/external/cddl/osnet/sys/sys/policy.h b/external/cddl/osnet/sys/sys/policy.h index 0100a5b65574..bb61c407bd46 100644 --- a/external/cddl/osnet/sys/sys/policy.h +++ b/external/cddl/osnet/sys/sys/policy.h @@ -1,3 +1,5 @@ +/* $NetBSD: policy.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - $ $FreeBSD: src/sys/cddl/compat/opensolaris/sys/policy.h,v 1.4.2.1 2009/08/03 08:13:06 kensmith Exp $ + $ $FreeBSD: src/sys/compat/opensolaris/sys/policy.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_POLICY_H_ @@ -40,37 +42,30 @@ struct ucred; struct vattr; struct vnode; -int secpolicy_nfs(struct ucred *cred); -int secpolicy_zfs(struct ucred *cred); -int secpolicy_sys_config(struct ucred *cred, int checkonly); -int secpolicy_zinject(struct ucred *cred); -int secpolicy_fs_unmount(struct ucred *cred, struct mount *vfsp); -int secpolicy_basic_link(struct vnode *vp, struct ucred *cred); -int secpolicy_vnode_owner(struct vnode *vp, cred_t *cred, uid_t owner); -int secpolicy_vnode_chown(struct vnode *vp, cred_t *cred, - boolean_t check_self); -int secpolicy_vnode_stky_modify(struct ucred *cred); -int secpolicy_vnode_remove(struct vnode *vp, struct ucred *cred); -int secpolicy_vnode_access(struct ucred *cred, struct vnode *vp, - uint64_t owner, accmode_t accmode); -int secpolicy_vnode_setdac(struct vnode *vp, struct ucred *cred, - uid_t owner); -int secpolicy_vnode_setattr(struct ucred *cred, struct vnode *vp, +int secpolicy_zfs(struct kauth_cred *cred); +int secpolicy_sys_config(struct kauth_cred *cred, int checkonly); +int secpolicy_zinject(struct kauth_cred *cred); +int secpolicy_fs_mount(struct kauth_cred *cred, struct vnode *mvp, struct mount *vfsp); +int secpolicy_fs_unmount(struct kauth_cred *cred, struct mount *vfsp); +int secpolicy_basic_link(struct kauth_cred *cred); +int secpolicy_vnode_stky_modify(struct kauth_cred *cred); +int secpolicy_vnode_owner(cred_t *cred, uid_t owner); +int secpolicy_vnode_remove(struct kauth_cred *cred); +int secpolicy_vnode_access(struct kauth_cred *cred, struct vnode *vp, + uint64_t owner, int mode); +int secpolicy_vnode_chown(struct kauth_cred *cred, + boolean_t check_self); +int secpolicy_vnode_setdac(struct kauth_cred *cred, uid_t owner); +int secpolicy_vnode_setattr(struct kauth_cred *cred, struct vnode *vp, struct vattr *vap, const struct vattr *ovap, int flags, - int unlocked_access(void *, int, struct ucred *), void *node); -int secpolicy_vnode_create_gid(struct ucred *cred); -int secpolicy_vnode_setids_setgids(struct vnode *vp, struct ucred *cred, - gid_t gid); -int secpolicy_vnode_setid_retain(struct vnode *vp, struct ucred *cred, - boolean_t issuidroot); -void secpolicy_setid_clear(struct vattr *vap, struct vnode *vp, - struct ucred *cred); + int unlocked_access(void *, int, struct kauth_cred *), void *node); +int secpolicy_vnode_create_gid(struct kauth_cred *cred); +int secpolicy_vnode_setids_setgids(struct kauth_cred *cred, gid_t gid); +int secpolicy_vnode_setid_retain(struct kauth_cred *cred, boolean_t issuidroot); +void secpolicy_setid_clear(struct vattr *vap, struct kauth_cred *cred); int secpolicy_setid_setsticky_clear(struct vnode *vp, struct vattr *vap, - const struct vattr *ovap, struct ucred *cred); -int secpolicy_fs_owner(struct mount *vfsp, struct ucred *cred); -int secpolicy_fs_mount(cred_t *cr, vnode_t *mvp, struct mount *vfsp); -void secpolicy_fs_mount_clearopts(cred_t *cr, struct mount *vfsp); -int secpolicy_xvattr(xvattr_t *xvap, uid_t owner, cred_t *cr, vtype_t vtype); + const struct vattr *ovap, struct kauth_cred *cred); +int secpolicy_xvattr(xvattr_t *xvap, uid_t owner, cred_t *cr, vtype_t vtype); #endif /* _KERNEL */ diff --git a/external/cddl/osnet/sys/sys/proc.h b/external/cddl/osnet/sys/sys/proc.h index e8103f771bb7..0ce83afa7230 100644 --- a/external/cddl/osnet/sys/sys/proc.h +++ b/external/cddl/osnet/sys/sys/proc.h @@ -1,3 +1,34 @@ +/* $NetBSD: proc.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,70 +54,44 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/proc.h,v 1.6.2.2 2009/09/15 11:13:40 pjd Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/proc.h,v 1.4 2007/11/28 21:50:05 jb Exp $ */ #ifndef _OPENSOLARIS_SYS_PROC_H_ #define _OPENSOLARIS_SYS_PROC_H_ #include -#include #include_next #include -#include -#include -#include -#include -#include -#include #ifdef _KERNEL -#define CPU curcpu -#define minclsyspri PRIBIO -#define maxclsyspri PVM -#define max_ncpus mp_ncpus -#define boot_max_ncpus mp_ncpus +#include + +#define CPU curcpu() +#define minclsyspri PRI_KTHREAD +#define maxclsyspri MAXPRI_KTHREAD +#define max_ncpus ncpu +#define boot_max_ncpus ncpu +#define curthread curlwp #define TS_RUN 0 #define p0 proc0 -typedef short pri_t; -typedef struct thread _kthread; -typedef struct thread kthread_t; -typedef struct thread *kthread_id_t; -typedef struct proc proc_t; +typedef struct lwp _kthread; +typedef struct lwp kthread_t; +typedef struct lwp *kthread_id_t; -extern struct proc *zfsproc; +#if (KSTACK_PAGES * PAGE_SIZE) < 16384 +#define ZFS_KSTACK_PAGES (16384 / PAGE_SIZE) +#else +#define ZFS_KSTACK_PAGES 0 +#endif -static __inline kthread_t * -thread_create(caddr_t stk, size_t stksize, void (*proc)(void *), void *arg, - size_t len, proc_t *pp, int state, pri_t pri) -{ - kthread_t *td = NULL; - int error; - - /* - * Be sure there are no surprises. - */ - ASSERT(stk == NULL); - ASSERT(len == 0); - ASSERT(state == TS_RUN); - ASSERT(pp == &p0); - - error = kproc_kthread_add(proc, arg, &zfsproc, &td, RFSTOPPED, - stksize / PAGE_SIZE, "zfskern", "solthread %p", proc); - if (error == 0) { - thread_lock(td); - sched_prio(td, pri); - sched_add(td, SRQ_BORING); - thread_unlock(td); - } - return (td); -} - -#define thread_exit() kthread_exit() +kthread_t *thread_create(void *, size_t, void (*)(), void *, size_t, + proc_t *, int, pri_t); +void thread_exit(void); #endif /* _KERNEL */ diff --git a/external/cddl/osnet/sys/sys/random.h b/external/cddl/osnet/sys/sys/random.h index 66d09b5b8831..c1a2b61d9806 100644 --- a/external/cddl/osnet/sys/sys/random.h +++ b/external/cddl/osnet/sys/sys/random.h @@ -1,3 +1,5 @@ +/* $NetBSD: random.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,15 +25,15 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/random.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/random.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_RANDOM_H_ #define _OPENSOLARIS_SYS_RANDOM_H_ -#include_next +#include -#define random_get_bytes(p, s) read_random((p), (int)(s)) -#define random_get_pseudo_bytes(p, s) read_random((p), (int)(s)) +#define random_get_bytes(p, s) rnd_extract_data((p), (uint32_t)(s), 0) +#define random_get_pseudo_bytes(p, s) rnd_extract_data((p), (uint32_t)(s), 0) #endif /* !_OPENSOLARIS_SYS_RANDOM_H_ */ diff --git a/external/cddl/osnet/sys/sys/refstr.h b/external/cddl/osnet/sys/sys/refstr.h index f4e16570b6b8..fd7fea5195db 100644 --- a/external/cddl/osnet/sys/sys/refstr.h +++ b/external/cddl/osnet/sys/sys/refstr.h @@ -1,3 +1,5 @@ +/* $NetBSD: refstr.h,v 1.2 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. diff --git a/external/cddl/osnet/sys/sys/rwlock.h b/external/cddl/osnet/sys/sys/rwlock.h index f93d0e357acc..3b1690e423fd 100644 --- a/external/cddl/osnet/sys/sys/rwlock.h +++ b/external/cddl/osnet/sys/sys/rwlock.h @@ -1,3 +1,34 @@ +/* $NetBSD: rwlock.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,16 +54,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/rwlock.h,v 1.7.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/rwlock.h,v 1.4 2007/11/05 18:40:55 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_RWLOCK_H_ #define _OPENSOLARIS_SYS_RWLOCK_H_ -#include -#include -#include -#include +#include_next #ifdef _KERNEL @@ -41,54 +69,11 @@ typedef enum { RW_DEFAULT = 4 /* kernel default rwlock */ } krw_type_t; -typedef enum { - RW_WRITER, - RW_READER -} krw_t; - -typedef struct sx krwlock_t; - -#ifndef DEBUG -#define RW_FLAGS (SX_DUPOK | SX_NOWITNESS) -#else -#define RW_FLAGS (SX_DUPOK) -#endif - #define RW_READ_HELD(x) (rw_read_held((x))) #define RW_WRITE_HELD(x) (rw_write_held((x))) #define RW_LOCK_HELD(x) (rw_lock_held((x))) #define RW_ISWRITER(x) (rw_iswriter(x)) - -#define rw_init(lock, desc, type, arg) do { \ - const char *_name; \ - KASSERT(((lock)->lock_object.lo_flags & LO_ALLMASK) != \ - LO_EXPECTED, ("lock %s already initialized", #lock)); \ - bzero((lock), sizeof(struct sx)); \ - for (_name = #lock; *_name != '\0'; _name++) { \ - if (*_name >= 'a' && *_name <= 'z') \ - break; \ - } \ - if (*_name == '\0') \ - _name = #lock; \ - sx_init_flags((lock), _name, RW_FLAGS); \ -} while (0) -#define rw_destroy(lock) sx_destroy(lock) -#define rw_enter(lock, how) do { \ - if ((how) == RW_READER) \ - sx_slock(lock); \ - else /* if ((how) == RW_WRITER) */ \ - sx_xlock(lock); \ -} while (0) -#define rw_tryenter(lock, how) ((how) == RW_READER ? sx_try_slock(lock) : sx_try_xlock(lock)) -#define rw_exit(lock) sx_unlock(lock) -#define rw_downgrade(lock) sx_downgrade(lock) -#define rw_tryupgrade(lock) sx_try_upgrade(lock) -#define rw_read_held(lock) ((lock)->sx_lock != SX_LOCK_UNLOCKED && ((lock)->sx_lock & SX_LOCK_SHARED)) -#define rw_write_held(lock) sx_xlocked(lock) -#define rw_lock_held(lock) (rw_read_held(lock) || rw_write_held(lock)) -#define rw_iswriter(lock) sx_xlocked(lock) -/* TODO: Change to sx_xholder() once it is moved from kern_sx.c to sx.h. */ -#define rw_owner(lock) ((lock)->sx_lock & SX_LOCK_SHARED ? NULL : (struct thread *)SX_OWNER((lock)->sx_lock)) +#define rw_init(a, b, c, d) rw_init(a) #endif /* defined(_KERNEL) */ diff --git a/external/cddl/osnet/sys/sys/rwlock_impl.h b/external/cddl/osnet/sys/sys/rwlock_impl.h new file mode 100644 index 000000000000..8a2d8b38e654 --- /dev/null +++ b/external/cddl/osnet/sys/sys/rwlock_impl.h @@ -0,0 +1,48 @@ +/* $NetBSD: rwlock_impl.h,v 1.1 2010/02/21 01:46:36 darran Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe and Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _COMPAT_OPENSOLARIS_SYS_RWLOCK_IMPL_H +#define _COMPAT_OPENSOLARIS_SYS_RWLOCK_IMPL_H + +#define __RWLOCK_PRIVATE +#include + +#define _RW_READ_HELD(rw) ((((rw)->rw_owner & RW_WRITE_LOCKED) == 0) && \ + (((rw)->rw_owner & RW_THREAD) != 0)) +#define _RW_WRITE_HELD(rw) \ + (((rw)->rw_owner & RW_THREAD) && \ + ((rw)->rw_owner & RW_WRITE_LOCKED)) +#define _RW_ISWRITER(rw) \ + (((rw)->rw_owner & RW_WRITE_LOCKED) && \ + (((rw)->rw_owner & RW_THREAD) == \ + (uintptr_t)curlwp)) + +#endif diff --git a/external/cddl/osnet/sys/sys/sdt.h b/external/cddl/osnet/sys/sys/sdt.h index ce3192d3d309..36304d916ccf 100644 --- a/external/cddl/osnet/sys/sys/sdt.h +++ b/external/cddl/osnet/sys/sys/sdt.h @@ -1,3 +1,5 @@ +/* $NetBSD: sdt.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/sdt.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/sdt.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_SDT_H_ diff --git a/external/cddl/osnet/sys/sys/sema.h b/external/cddl/osnet/sys/sys/sema.h index f29666e3551c..7ca76d46e12b 100644 --- a/external/cddl/osnet/sys/sys/sema.h +++ b/external/cddl/osnet/sys/sys/sema.h @@ -1,3 +1,5 @@ +/* $NetBSD: sema.h,v 1.2 2010/02/21 01:46:36 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. diff --git a/external/cddl/osnet/sys/sys/sid.h b/external/cddl/osnet/sys/sys/sid.h index d2ac02610ccd..14179aa21cac 100644 --- a/external/cddl/osnet/sys/sys/sid.h +++ b/external/cddl/osnet/sys/sys/sid.h @@ -1,3 +1,34 @@ +/* $NetBSD: sid.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +54,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/sid.h,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/sid.h,v 1.1 2008/11/17 20:49:29 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_SID_H_ @@ -51,4 +82,7 @@ ksiddomain_rele(ksiddomain_t *kd) kmem_free(kd, sizeof(*kd)); } +#define kidmap_getuidbysid(a, b, c, d) panic("XXXNETBSD kidmap_getuidbysid") +#define kidmap_getgidbysid(a, b, c, d) panic("XXXNETBSD kidmap_getgidbysid") + #endif /* _OPENSOLARIS_SYS_SID_H_ */ diff --git a/external/cddl/osnet/sys/sys/sig.h b/external/cddl/osnet/sys/sys/sig.h index 7a5cd7fa0f0b..d3ccd6d9a1a4 100644 --- a/external/cddl/osnet/sys/sys/sig.h +++ b/external/cddl/osnet/sys/sys/sig.h @@ -1,3 +1,5 @@ +/* $NetBSD: sig.h,v 1.2 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2008 Pawel Jakub Dawidek * All rights reserved. diff --git a/external/cddl/osnet/sys/sys/stat.h b/external/cddl/osnet/sys/sys/stat.h index 66162aad5cfe..686e6a952e83 100644 --- a/external/cddl/osnet/sys/sys/stat.h +++ b/external/cddl/osnet/sys/sys/stat.h @@ -1,3 +1,5 @@ +/* $NetBSD: stat.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /* * Copyright (C) 2007 John Birrell * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/stat.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/stat.h,v 1.1 2007/11/28 21:50:40 jb Exp $ * */ @@ -35,4 +37,6 @@ #define stat64 stat #define fstat64 fstat +#define SF_NOUNLINK 0x00100000 + #endif diff --git a/external/cddl/osnet/sys/sys/string.h b/external/cddl/osnet/sys/sys/string.h index d3e918b2a8af..8a541a02df1e 100644 --- a/external/cddl/osnet/sys/sys/string.h +++ b/external/cddl/osnet/sys/sys/string.h @@ -1,3 +1,5 @@ +/* $NetBSD: string.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,14 +25,12 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/string.h,v 1.3.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/string.h,v 1.2 2007/04/10 21:42:12 wkoszek Exp $ */ #ifndef _OPENSOLARIS_SYS_STRING_H_ #define _OPENSOLARIS_SYS_STRING_H_ -#include - char *strpbrk(const char *, const char *); void strident_canon(char *s, size_t n); diff --git a/external/cddl/osnet/sys/sys/sunddi.h b/external/cddl/osnet/sys/sys/sunddi.h index b324896a81c0..2318c04f0307 100644 --- a/external/cddl/osnet/sys/sys/sunddi.h +++ b/external/cddl/osnet/sys/sys/sunddi.h @@ -1,3 +1,5 @@ +/* $NetBSD: sunddi.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,16 +25,14 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/sunddi.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/sunddi.h,v 1.1 2007/04/23 00:52:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_SUNDDI_H_ #define _OPENSOLARIS_SYS_SUNDDI_H_ -#define ddi_driver_major(zfs_dip) (0) #define ddi_copyin(from, to, size, flag) (bcopy((from), (to), (size)), 0) #define ddi_copyout(from, to, size, flag) (bcopy((from), (to), (size)), 0) -int ddi_strtol(const char *str, char **nptr, int base, long *result); int ddi_strtoul(const char *str, char **nptr, int base, unsigned long *result); #endif /* _OPENSOLARIS_SYS_SUNDDI_H_ */ diff --git a/external/cddl/osnet/sys/sys/sysmacros.h b/external/cddl/osnet/sys/sys/sysmacros.h index 6978fab109ce..4d1d81c91f3c 100644 --- a/external/cddl/osnet/sys/sys/sysmacros.h +++ b/external/cddl/osnet/sys/sys/sysmacros.h @@ -1,10 +1,11 @@ +/* $NetBSD: sysmacros.h,v 1.3 2010/02/21 01:46:36 darran 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. @@ -18,20 +19,18 @@ * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END - * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/sysmacros.h,v 1.5.2.1 2009/08/03 08:13:06 kensmith Exp $ */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#ifndef _OPENSOLARIS_SYS_SYSMACROS_H_ -#define _OPENSOLARIS_SYS_SYSMACROS_H_ +#ifndef _SYS_SYSMACROS_H +#define _SYS_SYSMACROS_H #include @@ -39,33 +38,266 @@ extern "C" { #endif -#ifndef ABS -#define ABS(a) ((a) < 0 ? -(a) : (a)) +/* + * Some macros for units conversion + */ +/* + * Disk blocks (sectors) and bytes. + */ +#define dtob(DD) ((DD) << DEV_BSHIFT) +#define btod(BB) (((BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) +#define btodt(BB) ((BB) >> DEV_BSHIFT) +#define lbtod(BB) (((offset_t)(BB) + DEV_BSIZE - 1) >> DEV_BSHIFT) + +/* common macros */ +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif +#ifndef MAX +#define MAX(a, b) ((a) < (b) ? (b) : (a)) +#endif +#ifndef ABS +#define ABS(a) ((a) < 0 ? -(a) : (a)) +#endif +#ifndef SIGNOF +#define SIGNOF(a) ((a) < 0 ? -1 : (a) > 0) +#endif + +#ifdef _KERNEL + +/* + * Convert a single byte to/from binary-coded decimal (BCD). + */ +extern unsigned char byte_to_bcd[256]; +extern unsigned char bcd_to_byte[256]; + +#define BYTE_TO_BCD(x) byte_to_bcd[(x) & 0xff] +#define BCD_TO_BYTE(x) bcd_to_byte[(x) & 0xff] + +#define MAXMIN 0xfffffffful /* max minor value with 64b dev_t*/ + +#endif /* _KERNEL */ + +#ifndef __NetBSD__ + +/* + * WARNING: The device number macros defined here should not be used by device + * drivers or user software. Device drivers should use the device functions + * defined in the DDI/DKI interface (see also ddi.h). Application software + * should make use of the library routines available in makedev(3). A set of + * new device macros are provided to operate on the expanded device number + * format supported in SVR4. Macro versions of the DDI device functions are + * provided for use by kernel proper routines only. Macro routines bmajor(), + * major(), minor(), emajor(), eminor(), and makedev() will be removed or + * their definitions changed at the next major release following SVR4. + */ + +#define O_BITSMAJOR 7 /* # of SVR3 major device bits */ +#define O_BITSMINOR 8 /* # of SVR3 minor device bits */ +#define O_MAXMAJ 0x7f /* SVR3 max major value */ +#define O_MAXMIN 0xff /* SVR3 max minor value */ + + +#define L_BITSMAJOR32 14 /* # of SVR4 major device bits */ +#define L_BITSMINOR32 18 /* # of SVR4 minor device bits */ +#define L_MAXMAJ32 0x3fff /* SVR4 max major value */ +#define L_MAXMIN32 0x3ffff /* MAX minor for 3b2 software drivers. */ + /* For 3b2 hardware devices the minor is */ + /* restricted to 256 (0-255) */ + +#ifdef _LP64 +#define L_BITSMAJOR 32 /* # of major device bits in 64-bit Solaris */ +#define L_BITSMINOR 32 /* # of minor device bits in 64-bit Solaris */ +#define L_MAXMAJ 0xfffffffful /* max major value */ +#define L_MAXMIN 0xfffffffful /* max minor value */ +#else +#define L_BITSMAJOR L_BITSMAJOR32 +#define L_BITSMINOR L_BITSMINOR32 +#define L_MAXMAJ L_MAXMAJ32 +#define L_MAXMIN L_MAXMIN32 +#endif + +#ifdef _KERNEL + +/* major part of a device internal to the kernel */ + +#define major(x) (major_t)((((unsigned)(x)) >> O_BITSMINOR) & O_MAXMAJ) +#define bmajor(x) (major_t)((((unsigned)(x)) >> O_BITSMINOR) & O_MAXMAJ) + +/* get internal major part of expanded device number */ + +#define getmajor(x) (major_t)((((dev_t)(x)) >> L_BITSMINOR) & L_MAXMAJ) + +/* minor part of a device internal to the kernel */ + +#define minor(x) (minor_t)((x) & O_MAXMIN) + +/* get internal minor part of expanded device number */ + +#define getminor(x) (minor_t)((x) & L_MAXMIN) + +#else + +/* major part of a device external from the kernel (same as emajor below) */ + +#define major(x) (major_t)((((unsigned)(x)) >> O_BITSMINOR) & O_MAXMAJ) + +/* minor part of a device external from the kernel (same as eminor below) */ + +#define minor(x) (minor_t)((x) & O_MAXMIN) + +#endif /* _KERNEL */ + +/* create old device number */ + +#define makedev(x, y) (unsigned short)(((x) << O_BITSMINOR) | ((y) & O_MAXMIN)) + +/* make an new device number */ + +#define makedevice(x, y) (dev_t)(((dev_t)(x) << L_BITSMINOR) | ((y) & L_MAXMIN)) + + +/* + * emajor() allows kernel/driver code to print external major numbers + * eminor() allows kernel/driver code to print external minor numbers + */ + +#define emajor(x) \ + (major_t)(((unsigned int)(x) >> O_BITSMINOR) > O_MAXMAJ) ? \ + NODEV : (((unsigned int)(x) >> O_BITSMINOR) & O_MAXMAJ) + +#define eminor(x) \ + (minor_t)((x) & O_MAXMIN) + +/* + * get external major and minor device + * components from expanded device number + */ +#define getemajor(x) (major_t)((((dev_t)(x) >> L_BITSMINOR) > L_MAXMAJ) ? \ + NODEV : (((dev_t)(x) >> L_BITSMINOR) & L_MAXMAJ)) +#define geteminor(x) (minor_t)((x) & L_MAXMIN) + +/* + * These are versions of the kernel routines for compressing and + * expanding long device numbers that don't return errors. + */ +#if (L_BITSMAJOR32 == L_BITSMAJOR) && (L_BITSMINOR32 == L_BITSMINOR) + +#define DEVCMPL(x) (x) +#define DEVEXPL(x) (x) + +#else + +#define DEVCMPL(x) \ + (dev32_t)((((x) >> L_BITSMINOR) > L_MAXMAJ32 || \ + ((x) & L_MAXMIN) > L_MAXMIN32) ? NODEV32 : \ + ((((x) >> L_BITSMINOR) << L_BITSMINOR32) | ((x) & L_MAXMIN32))) + +#define DEVEXPL(x) \ + (((x) == NODEV32) ? NODEV : \ + makedevice(((x) >> L_BITSMINOR32) & L_MAXMAJ32, (x) & L_MAXMIN32)) + +#endif /* L_BITSMAJOR32 ... */ + +/* convert to old (SVR3.2) dev format */ + +#define cmpdev(x) \ + (o_dev_t)((((x) >> L_BITSMINOR) > O_MAXMAJ || \ + ((x) & L_MAXMIN) > O_MAXMIN) ? NODEV : \ + ((((x) >> L_BITSMINOR) << O_BITSMINOR) | ((x) & O_MAXMIN))) + +/* convert to new (SVR4) dev format */ + +#define expdev(x) \ + (dev_t)(((dev_t)(((x) >> O_BITSMINOR) & O_MAXMAJ) << L_BITSMINOR) | \ + ((x) & O_MAXMIN)) + +#endif /* !__NetBSD__ */ /* * Macro for checking power of 2 address alignment. */ #define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0) +#ifndef __NetBSD__ + +/* + * Macros for counting and rounding. + */ +#define howmany(x, y) (((x)+((y)-1))/(y)) +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) + +#endif /* !__NetBSD__ */ + /* * Macro to determine if value is a power of 2 */ #define ISP2(x) (((x) & ((x) - 1)) == 0) /* - * Macros for various sorts of alignment and rounding when the alignment - * is known to be a power of 2. + * Macros for various sorts of alignment and rounding. The "align" must + * be a power of 2. Often times it is a block, sector, or page. + */ + +/* + * return x rounded down to an align boundary + * eg, P2ALIGN(1200, 1024) == 1024 (1*align) + * eg, P2ALIGN(1024, 1024) == 1024 (1*align) + * eg, P2ALIGN(0x1234, 0x100) == 0x1200 (0x12*align) + * eg, P2ALIGN(0x5600, 0x100) == 0x5600 (0x56*align) */ #define P2ALIGN(x, align) ((x) & -(align)) -#define P2PHASE(x, align) ((x) & ((align) - 1)) -#define P2NPHASE(x, align) (-(x) & ((align) - 1)) -#define P2ROUNDUP(x, align) (-(-(x) & -(align))) -#define P2END(x, align) (-(~(x) & -(align))) -#define P2PHASEUP(x, align, phase) ((phase) - (((phase) - (x)) & -(align))) -#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1) + /* - * Determine whether two numbers have the same high-order bit. + * return x % (mod) align + * eg, P2PHASE(0x1234, 0x100) == 0x34 (x-0x12*align) + * eg, P2PHASE(0x5600, 0x100) == 0x00 (x-0x56*align) + */ +#define P2PHASE(x, align) ((x) & ((align) - 1)) + +/* + * return how much space is left in this block (but if it's perfectly + * aligned, return 0). + * eg, P2NPHASE(0x1234, 0x100) == 0xcc (0x13*align-x) + * eg, P2NPHASE(0x5600, 0x100) == 0x00 (0x56*align-x) + */ +#define P2NPHASE(x, align) (-(x) & ((align) - 1)) + +/* + * return x rounded up to an align boundary + * eg, P2ROUNDUP(0x1234, 0x100) == 0x1300 (0x13*align) + * eg, P2ROUNDUP(0x5600, 0x100) == 0x5600 (0x56*align) + */ +#define P2ROUNDUP(x, align) (-(-(x) & -(align))) + +/* + * return the ending address of the block that x is in + * eg, P2END(0x1234, 0x100) == 0x12ff (0x13*align - 1) + * eg, P2END(0x5600, 0x100) == 0x56ff (0x57*align - 1) + */ +#define P2END(x, align) (-(~(x) & -(align))) + +/* + * return x rounded up to the next phase (offset) within align. + * phase should be < align. + * eg, P2PHASEUP(0x1234, 0x100, 0x10) == 0x1310 (0x13*align + phase) + * eg, P2PHASEUP(0x5600, 0x100, 0x10) == 0x5610 (0x56*align + phase) + */ +#define P2PHASEUP(x, align, phase) ((phase) - (((phase) - (x)) & -(align))) + +/* + * return TRUE if adding len to off would cause it to cross an align + * boundary. + * eg, P2BOUNDARY(0x1234, 0xe0, 0x100) == TRUE (0x1234 + 0xe0 == 0x1314) + * eg, P2BOUNDARY(0x1234, 0x50, 0x100) == FALSE (0x1234 + 0x50 == 0x1284) + */ +#define P2BOUNDARY(off, len, align) \ + (((off) ^ ((off) + (len) - 1)) > (align) - 1) + +/* + * Return TRUE if they have the same highest bit set. + * eg, P2SAMEHIGHBIT(0x1234, 0x1001) == TRUE (the high bit is 0x1000) + * eg, P2SAMEHIGHBIT(0x1234, 0x3010) == FALSE (high bit of 0x3010 is 0x2000) */ #define P2SAMEHIGHBIT(x, y) (((x) ^ (y)) < ((x) & (y))) @@ -97,6 +329,62 @@ extern "C" { #define P2SAMEHIGHBIT_TYPED(x, y, type) \ (((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y))) +/* + * Macros to atomically increment/decrement a variable. mutex and var + * must be pointers. + */ +#define INCR_COUNT(var, mutex) mutex_enter(mutex), (*(var))++, mutex_exit(mutex) +#define DECR_COUNT(var, mutex) mutex_enter(mutex), (*(var))--, mutex_exit(mutex) + +/* + * Macros to declare bitfields - the order in the parameter list is + * Low to High - that is, declare bit 0 first. We only support 8-bit bitfields + * because if a field crosses a byte boundary it's not likely to be meaningful + * without reassembly in its nonnative endianness. + */ +#ifndef __NetBSD__ +#if defined(_BIT_FIELDS_LTOH) +#define DECL_BITFIELD2(_a, _b) \ + uint8_t _a, _b +#define DECL_BITFIELD3(_a, _b, _c) \ + uint8_t _a, _b, _c +#define DECL_BITFIELD4(_a, _b, _c, _d) \ + uint8_t _a, _b, _c, _d +#define DECL_BITFIELD5(_a, _b, _c, _d, _e) \ + uint8_t _a, _b, _c, _d, _e +#define DECL_BITFIELD6(_a, _b, _c, _d, _e, _f) \ + uint8_t _a, _b, _c, _d, _e, _f +#define DECL_BITFIELD7(_a, _b, _c, _d, _e, _f, _g) \ + uint8_t _a, _b, _c, _d, _e, _f, _g +#define DECL_BITFIELD8(_a, _b, _c, _d, _e, _f, _g, _h) \ + uint8_t _a, _b, _c, _d, _e, _f, _g, _h +#elif defined(_BIT_FIELDS_HTOL) +#define DECL_BITFIELD2(_a, _b) \ + uint8_t _b, _a +#define DECL_BITFIELD3(_a, _b, _c) \ + uint8_t _c, _b, _a +#define DECL_BITFIELD4(_a, _b, _c, _d) \ + uint8_t _d, _c, _b, _a +#define DECL_BITFIELD5(_a, _b, _c, _d, _e) \ + uint8_t _e, _d, _c, _b, _a +#define DECL_BITFIELD6(_a, _b, _c, _d, _e, _f) \ + uint8_t _f, _e, _d, _c, _b, _a +#define DECL_BITFIELD7(_a, _b, _c, _d, _e, _f, _g) \ + uint8_t _g, _f, _e, _d, _c, _b, _a +#define DECL_BITFIELD8(_a, _b, _c, _d, _e, _f, _g, _h) \ + uint8_t _h, _g, _f, _e, _d, _c, _b, _a +#else +#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined +#endif /* _BIT_FIELDS_LTOH */ +#endif + +#if defined(_KERNEL) && !defined(_KMEMUSER) && !defined(offsetof) + +/* avoid any possibility of clashing with version */ + +#define offsetof(s, m) ((size_t)(&(((s *)0)->m))) +#endif + /* * Find highest one bit set. * Returns bit number + 1 of highest bit that is set, otherwise returns 0. @@ -136,4 +424,4 @@ highbit(ulong_t i) } #endif -#endif /* _OPENSOLARIS_SYS_SYSMACROS_H_ */ +#endif /* _SYS_SYSMACROS_H */ diff --git a/external/cddl/osnet/sys/sys/systm.h b/external/cddl/osnet/sys/sys/systm.h index a2268f405753..f4a7762ffc50 100644 --- a/external/cddl/osnet/sys/sys/systm.h +++ b/external/cddl/osnet/sys/sys/systm.h @@ -1,3 +1,34 @@ +/* $NetBSD: systm.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,14 +54,17 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/systm.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/systm.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_SYSTM_H_ #define _OPENSOLARIS_SYS_SYSTM_H_ -#include +#ifdef _KERNEL #include_next +#endif + +#include #ifdef _KERNEL #include @@ -39,7 +73,8 @@ #define PAGEOFFSET (PAGESIZE - 1) #define PAGEMASK (~PAGEOFFSET) -#define delay(x) pause("soldelay", (x)) +#undef delay +#define delay(x) kpause("soldelay", false, (x), NULL) #define xcopyin(u, k, s) copyin(u, k, s) #define xcopyout(k, u, s) copyout(k, u, s) diff --git a/external/cddl/osnet/sys/sys/time.h b/external/cddl/osnet/sys/sys/time.h index 3afea33bdd01..be40451db6f0 100644 --- a/external/cddl/osnet/sys/sys/time.h +++ b/external/cddl/osnet/sys/sys/time.h @@ -1,3 +1,5 @@ +/* $NetBSD: time.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/time.h,v 1.4.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/time.h,v 1.2 2007/11/28 21:44:17 jb Exp $ */ #ifndef _OPENSOLARIS_SYS_TIME_H_ @@ -36,15 +38,13 @@ #define MICROSEC 1000000 #define NANOSEC 1000000000 -typedef longlong_t hrtime_t; - #define LBOLT ((gethrtime() * hz) / NANOSEC) -#define TIMESPEC_OVERFLOW(ts) \ +#define TIMESPEC_OVERFLOW(ts) \ ((ts)->tv_sec < INT32_MIN || (ts)->tv_sec > INT32_MAX) #ifdef _KERNEL -#define lbolt64 (int64_t)(LBOLT) +#include static __inline hrtime_t gethrtime(void) { @@ -68,11 +68,10 @@ gethrtime(void) { static __inline hrtime_t gethrtime(void) { struct timespec ts; - clock_gettime(CLOCK_UPTIME,&ts); + clock_gettime(CLOCK_REALTIME,&ts); return (((u_int64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec); } - #endif /* _KERNEL */ #endif /* !_OPENSOLARIS_SYS_TIME_H_ */ diff --git a/external/cddl/osnet/sys/sys/types.h b/external/cddl/osnet/sys/sys/types.h index 4fbfff30af56..86a0cd5f821c 100644 --- a/external/cddl/osnet/sys/sys/types.h +++ b/external/cddl/osnet/sys/sys/types.h @@ -1,3 +1,34 @@ +/* $NetBSD: types.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +54,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/types.h,v 1.6.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/types.h,v 1.3 2007/11/28 21:49:16 jb Exp $ */ #ifndef _OPENSOLARIS_SYS_TYPES_H_ @@ -35,54 +66,77 @@ #include #include_next +#include_next + +#ifndef _KERNEL +#include +#else +#include +#endif #define MAXNAMELEN 256 +#define FMNAMESZ 8 + +typedef unsigned int size32_t; +typedef unsigned int caddr32_t; typedef struct timespec timestruc_t; typedef u_int uint_t; typedef u_char uchar_t; typedef u_short ushort_t; typedef u_long ulong_t; -typedef long long longlong_t; -typedef unsigned long long u_longlong_t; typedef off_t off64_t; typedef id_t taskid_t; typedef id_t projid_t; typedef id_t poolid_t; typedef id_t zoneid_t; typedef id_t ctid_t; -typedef mode_t o_mode_t; -typedef uint64_t pgcnt_t; - -#ifdef _KERNEL #define B_FALSE 0 #define B_TRUE 1 +typedef int boolean_t; + +typedef longlong_t hrtime_t; +typedef int32_t t_scalar_t; +typedef uint32_t t_uscalar_t; +typedef vsize_t pgcnt_t; +typedef u_longlong_t len_t; +typedef int major_t; +typedef int minor_t; +typedef int o_uid_t; +typedef int o_gid_t; +typedef struct kauth_cred cred_t; +typedef uintptr_t pc_t; +typedef struct vm_page page_t; +typedef ushort_t o_mode_t; /* old file attribute type */ +typedef u_longlong_t diskaddr_t; +typedef void *zone_t; +typedef struct vfsops vfsops_t; + +#ifdef _KERNEL typedef short index_t; typedef off_t offset_t; typedef long ptrdiff_t; /* pointer difference */ typedef int64_t rlim64_t; -typedef int major_t; +typedef __caddr_t caddr_t; /* core address */ #else -#ifdef NEED_SOLARIS_BOOLEAN -#if defined(__XOPEN_OR_POSIX) -typedef enum { _B_FALSE, _B_TRUE } boolean_t; -#else -typedef enum { B_FALSE, B_TRUE } boolean_t; -#endif /* defined(__XOPEN_OR_POSIX) */ -#endif typedef longlong_t offset_t; typedef u_longlong_t u_offset_t; typedef uint64_t upad64_t; typedef struct timespec timespec_t; -typedef short pri_t; typedef int32_t daddr32_t; typedef int32_t time32_t; -typedef u_longlong_t diskaddr_t; #endif /* !_KERNEL */ +#define MAXOFFSET_T 0x7fffffffffffffffLL +#define seg_rw uio_rw +#define S_READ UIO_READ +#define S_WRITE UIO_WRITE +struct aio_req; +typedef void *dev_info_t; + #endif /* !_OPENSOLARIS_SYS_TYPES_H_ */ diff --git a/external/cddl/osnet/sys/sys/uio.h b/external/cddl/osnet/sys/sys/uio.h index 89e092d09186..4d5ed1724642 100644 --- a/external/cddl/osnet/sys/sys/uio.h +++ b/external/cddl/osnet/sys/sys/uio.h @@ -1,3 +1,34 @@ +/* $NetBSD: uio.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +54,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/uio.h,v 1.4.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/uio.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_UIO_H_ @@ -33,6 +64,8 @@ #include #ifndef _KERNEL +#include + #define FOF_OFFSET 1 /* Use the offset in uio argument */ struct uio { @@ -49,17 +82,19 @@ struct uio { typedef struct uio uio_t; typedef struct iovec iovec_t; +typedef enum uio_seg uio_seg_t; + #define uio_loffset uio_offset -#ifdef BUILDING_ZFS +int uiomove(void *, size_t, struct uio *); + static __inline int zfs_uiomove(void *cp, size_t n, enum uio_rw dir, uio_t *uio) { - ASSERT(uio->uio_rw == dir); + assert(uio->uio_rw == dir); return (uiomove(cp, (int)n, uio)); } #define uiomove(cp, n, dir, uio) zfs_uiomove((cp), (n), (dir), (uio)) -#endif /* BUILDING_ZFS */ #endif /* !_OPENSOLARIS_SYS_UIO_H_ */ diff --git a/external/cddl/osnet/sys/sys/varargs.h b/external/cddl/osnet/sys/sys/varargs.h index 6870d96e2212..32ea20ab9d3f 100644 --- a/external/cddl/osnet/sys/sys/varargs.h +++ b/external/cddl/osnet/sys/sys/varargs.h @@ -1,3 +1,5 @@ +/* $NetBSD: varargs.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/varargs.h,v 1.2.4.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/varargs.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_VARARGS_H_ diff --git a/external/cddl/osnet/sys/sys/vfs.h b/external/cddl/osnet/sys/sys/vfs.h index 0efefbd92bb5..c2cf1a4df590 100644 --- a/external/cddl/osnet/sys/sys/vfs.h +++ b/external/cddl/osnet/sys/sys/vfs.h @@ -1,3 +1,5 @@ +/* $NetBSD: vfs.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/vfs.h,v 1.4.2.2 2009/09/15 11:13:40 pjd Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/vfs.h,v 1.2 2007/06/04 11:31:45 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_VFS_H_ @@ -42,31 +44,31 @@ typedef struct mount vfs_t; #define vfs_flag mnt_flag #define vfs_data mnt_data -#define vfs_count mnt_ref +#define vfs_count mnt_refcnt #define vfs_fsid mnt_stat.f_fsid #define vfs_bsize mnt_stat.f_bsize -#define vfs_resource mnt_stat.f_mntfromname #define v_flag v_vflag #define v_vfsp v_mount +#define f_basetype f_fstypename + +#define vfs_setfsops(a, b, c) vfs_attach(&b) +#define vfs_freevfsops_by_type(zfsfstype) do { } while (0) + #define VFS_RDONLY MNT_RDONLY #define VFS_NOSETUID MNT_NOSUID #define VFS_NOEXEC MNT_NOEXEC +#define VFS_NODEVICES MNT_NODEV +#define VFS_NOTRUNC 0 #define VFS_HOLD(vfsp) do { \ - MNT_ILOCK(vfsp); \ - MNT_REF(vfsp); \ - MNT_IUNLOCK(vfsp); \ + /* XXXNETBSD nothing */ \ } while (0) #define VFS_RELE(vfsp) do { \ - MNT_ILOCK(vfsp); \ - MNT_REL(vfsp); \ - MNT_IUNLOCK(vfsp); \ + /* XXXNETBSD nothing */ \ } while (0) -#define fs_vscan(vp, cr, async) (0) - #define VROOT VV_ROOT /* @@ -97,6 +99,10 @@ typedef struct mntopt { #define VFS_DISPLAY 0x02 /* Turn off MO_NODISPLAY bit for opt */ #define VFS_NODISPLAY 0x04 /* Turn on MO_NODISPLAY bit for opt */ #define VFS_CREATEOPT 0x08 /* Create the opt if it's not there */ +#define VFS_UNMOUNTED 0x100 /* file system has been unmounted */ + +#define MS_SYSSPACE 0x0008 /* Mounta already in kernel space */ +#define MS_DATA 0 /* * Structure holding mount option strings for the mounted file system. @@ -106,24 +112,42 @@ typedef struct mntopts { mntopt_t *mo_list; /* list of mount options */ } mntopts_t; + /* + * Argument structure for mount(2). + * + * Flags are defined in . + * + * Note that if the MS_SYSSPACE bit is set in flags, the pointer fields in + * this structure are to be interpreted as kernel addresses. File systems + * should be prepared for this possibility. + */ +struct mounta { + char fspec[MAXNAMELEN - 1]; + char dataptr[MAXPATHLEN]; + char optptr[MAXPATHLEN]; + char *fstype; /* Unused */ + int mflag; + int datalen; + int optlen; + int flags; /* Unused */ +}; + +#define vfs_devismounted(dev) 0 +#define fs_vscan(vp, cr, async) (0) + void vfs_setmntopt(vfs_t *vfsp, const char *name, const char *arg, int flags __unused); void vfs_clearmntopt(vfs_t *vfsp, const char *name); int vfs_optionisset(const vfs_t *vfsp, const char *opt, char **argp); -int mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, - char *fspath, char *fspec, int fsflags); +int traverse(vnode_t **cvpp, int lktype); +int domount(kthread_t *td, vnode_t *vp, const char *fstype, char *fspath, + char *fspec, int fsflags); -typedef uint64_t vfs_feature_t; +#define vfs_set_feature(vfsp, feature) do { } while (0) +#define vfs_has_feature(vfsp, feature) (0) -#define VFSFT_XVATTR 0x100000001 /* Supports xvattr for attrs */ -#define VFSFT_CASEINSENSITIVE 0x100000002 /* Supports case-insensitive */ -#define VFSFT_NOCASESENSITIVE 0x100000004 /* NOT case-sensitive */ -#define VFSFT_DIRENTFLAGS 0x100000008 /* Supports dirent flags */ -#define VFSFT_ACLONCREATE 0x100000010 /* Supports ACL on create */ -#define VFSFT_ACEMASKONACCESS 0x100000020 /* Can use ACEMASK for access */ - -#define vfs_set_feature(vfsp, feature) do { } while (0) -#define vfs_has_feature(vfsp, feature) (0) +int zfs_vfsinit(int fstype, char *name); +int zfs_vfsfini(void); #endif /* _KERNEL */ diff --git a/external/cddl/osnet/sys/sys/vnode.h b/external/cddl/osnet/sys/sys/vnode.h index f0420b200239..533e74c09987 100644 --- a/external/cddl/osnet/sys/sys/vnode.h +++ b/external/cddl/osnet/sys/sys/vnode.h @@ -1,3 +1,73 @@ + +/* $NetBSD: vnode.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * 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. + * 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 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ +/* All Rights Reserved */ + +/* + * University Copyright- Copyright (c) 1982, 1986, 1988 + * The Regents of the University of California + * All Rights Reserved + * + * University Acknowledgment- Portions of this document are derived from + * software developed by the University of California, Berkeley, and its + * contributors. + */ + +/*- + * Copyright (c) 2009 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Andrew Doran. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,68 +93,205 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/vnode.h,v 1.12.2.2 2009/08/17 09:55:58 pjd Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/vnode.h,v 1.3 2007/05/31 11:51:49 kib Exp $ */ +#include +#include_next + #ifndef _OPENSOLARIS_SYS_VNODE_H_ #define _OPENSOLARIS_SYS_VNODE_H_ -struct vnode; -struct vattr; - -typedef struct vnode vnode_t; -typedef struct vattr vattr_t; -typedef enum vtype vtype_t; - -#include -enum symfollow { NO_FOLLOW = NOFOLLOW }; - -#include -#include_next -#include #include #include -#include +#include +#include #include -#include +#include + +#ifdef _KERNEL +#include +#endif + +typedef struct vattr vattr_t; +typedef enum vtype vtype_t; +typedef void caller_context_t; + +typedef int (**vnodeops_t)(void *); -typedef struct vop_vector vnodeops_t; #define vop_fid vop_vptofh #define vop_fid_args vop_vptofh_args #define a_fid a_fhp -#define IS_XATTRDIR(dvp) (0) +#define v_count v_usecount +#define v_object v_uobj -#define v_count v_usecount +struct vop_vptofh_args { + struct vnode *a_vp; + struct fid *a_fid; +}; + +/* + * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations + */ + +/* + * Flags to VOP_SETATTR/VOP_GETATTR. + */ +#define ATTR_UTIME 0x01 /* non-default utime(2) request */ +#define ATTR_EXEC 0x02 /* invocation from exec(2) */ +#define ATTR_COMM 0x04 /* yield common vp attributes */ +#define ATTR_HINT 0x08 /* information returned will be `hint' */ +#define ATTR_REAL 0x10 /* yield attributes of the real vp */ +#define ATTR_NOACLCHECK 0x20 /* Don't check ACL when checking permissions */ +#define ATTR_TRIGGER 0x40 /* Mount first if vnode is a trigger mount */ + +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 */ + uint_t vsa_aclflags; /* ACE ACL flags */ +} vsecattr_t; + +#define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */ + +/* + * Structure of all optional attributes. + */ +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_opaque; + uint8_t xoa_av_quarantined; + uint8_t xoa_av_modified; + uint8_t xoa_av_scanstamp[AV_SCANSTAMP_SZ]; +} xoptattr_t; + + +/* + * The xvattr structure is really a variable length structure that + * is made up of: + * - The classic vattr_t (xva_vattr) + * - a 32 bit quantity (xva_mapsize) that specifies the size of the + * attribute bitmaps in 32 bit words. + * - A pointer to the returned attribute bitmap (needed because the + * previous element, the requested attribute bitmap) is variable lenth. + * - The requested attribute bitmap, which is an array of 32 bit words. + * Callers use the XVA_SET_REQ() macro to set the bits corresponding to + * the attributes that are being requested. + * - The returned attribute bitmap, which is an array of 32 bit words. + * File systems that support optional attributes use the XVA_SET_RTN() + * macro to set the bits corresponding to the attributes that are being + * returned. + * - The xoptattr_t structure which contains the attribute values + * + * xva_mapsize determines how many words in the attribute bitmaps. + * Immediately following the attribute bitmaps is the xoptattr_t. + * xva_getxoptattr() is used to get the pointer to the xoptattr_t + * section. + */ + +#define XVA_MAPSIZE 3 /* Size of attr bitmaps */ +#define XVA_MAGIC 0x78766174 /* Magic # for verification */ + +/* + * The xvattr structure is an extensible structure which permits optional + * attributes to be requested/returned. File systems may or may not support + * optional attributes. They do so at their own discretion but if they do + * support optional attributes, they must register the VFSFT_XVATTR feature + * so that the optional attributes can be set/retrived. + * + * The fields of the xvattr structure are: + * + * xva_vattr - The first element of an xvattr is a legacy vattr structure + * which includes the common attributes. If AT_XVATTR is set in the va_mask + * then the entire structure is treated as an xvattr. If AT_XVATTR is not + * set, then only the xva_vattr structure can be used. + * + * xva_magic - 0x78766174 (hex for "xvat"). Magic number for verification. + * + * xva_mapsize - Size of requested and returned attribute bitmaps. + * + * xva_rtnattrmapp - Pointer to xva_rtnattrmap[]. We need this since the + * size of the array before it, xva_reqattrmap[], could change which means + * the location of xva_rtnattrmap[] could change. This will allow unbundled + * file systems to find the location of xva_rtnattrmap[] when the sizes change. + * + * xva_reqattrmap[] - Array of requested attributes. Attributes are + * represented by a specific bit in a specific element of the attribute + * map array. Callers set the bits corresponding to the attributes + * that the caller wants to get/set. + * + * xva_rtnattrmap[] - Array of attributes that the file system was able to + * process. Not all file systems support all optional attributes. This map + * informs the caller which attributes the underlying file system was able + * to set/get. (Same structure as the requested attributes array in terms + * of each attribute corresponding to specific bits and array elements.) + * + * xva_xoptattrs - Structure containing values of optional attributes. + * These values are only valid if the corresponding bits in xva_reqattrmap + * are set and the underlying file system supports those attributes. + */ +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; + +/* vsa_mask values */ +#define VSA_ACL 0x0001 +#define VSA_ACLCNT 0x0002 +#define VSA_DFACL 0x0004 +#define VSA_DFACLCNT 0x0008 +#define VSA_ACE 0x0010 +#define VSA_ACECNT 0x0020 +#define VSA_ACE_ALLTYPES 0x0040 +#define VSA_ACE_ACLFLAGS 0x0080 /* get/set ACE ACL flags */ + +int vn_is_readonly(vnode_t *); -static __inline int -vn_is_readonly(vnode_t *vp) -{ - return (vp->v_mount->mnt_flag & MNT_RDONLY); -} #define vn_vfswlock(vp) (0) #define vn_vfsunlock(vp) do { } while (0) #define vn_ismntpt(vp) ((vp)->v_type == VDIR && (vp)->v_mountedhere != NULL) #define vn_mountedvfs(vp) ((vp)->v_mountedhere) -#define vn_has_cached_data(vp) ((vp)->v_object != NULL && (vp)->v_object->resident_page_count > 0) -#define vn_exists(vp) do { } while (0) -#define vn_invalid(vp) do { } while (0) -#define vn_renamepath(tdvp, svp, tnm, lentnm) do { } while (0) -#define vn_free(vp) do { } while (0) +#define vn_has_cached_data(vp) ((vp)->v_uobj.uo_npages > 0) +#define vn_renamepath(tdvp, svp, tnm, lentnm) do { } while (0) #define VN_HOLD(v) vref(v) #define VN_RELE(v) vrele(v) #define VN_URELE(v) vput(v) +#define VI_LOCK(vp) mutex_enter(&(vp)->v_interlock) +#define VI_UNLOCK(vp) mutex_exit(&(vp)->v_interlock) + #define VOP_REALVP(vp, vpp, ct) (*(vpp) = (vp), 0) -#define vnevent_create(vp, ct) do { } while (0) -#define vnevent_link(vp, ct) do { } while (0) -#define vnevent_remove(vp, dvp, name, ct) do { } while (0) -#define vnevent_rmdir(vp, dvp, name, ct) do { } while (0) -#define vnevent_rename_src(vp, dvp, name, ct) do { } while (0) +#define vnevent_remove(vp, dvp, name, ct) do { } while (0) +#define vnevent_rmdir(vp, dvp, name, ct) do { } while (0) +#define vnevent_rename_src(vp, dvp, name, ct) do { } while (0) #define vnevent_rename_dest(vp, dvp, name, ct) do { } while (0) -#define vnevent_rename_dest_dir(vp, ct) do { } while (0) +#define vnevent_rename_dest_dir(vp, ct) do { } while (0) +#define vnevent_create(vp, ct) do { } while (0) +#define vnevent_link(vp, ct) do { } while (0) + +#define IS_DEVVP(vp) \ + ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO) + +#define MODEMASK ALLPERMS #define specvp(vp, rdev, type, cr) (VN_HOLD(vp), (vp)) #define MANDMODE(mode) (0) @@ -104,13 +311,160 @@ vn_is_readonly(vnode_t *vp) #define va_blksize va_blocksize #define va_seq va_gen -#define MAXOFFSET_T OFF_MAX #define EXCL 0 +#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 0x4000 +#define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ + AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) + #define ACCESSED (AT_ATIME) #define STATE_CHANGED (AT_CTIME) #define CONTENT_MODIFIED (AT_MTIME | AT_CTIME) +/* + * If AT_XVATTR is set then there are additional bits to process in + * the xvattr_t's attribute bitmap. If this is not set then the bitmap + * MUST be ignored. Note that this bit must be set/cleared explicitly. + * That is, setting AT_ALL will NOT set AT_XVATTR. + */ +#define AT_XVATTR 0x10000 + +#define AT_ALL (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ + AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ + AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) + +#define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ + AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE) + +#define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME) + +#define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ + AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) + +/* + * Attribute bits used in the extensible attribute's (xva's) attribute + * bitmaps. Note that the bitmaps are made up of a variable length number + * of 32-bit words. The convention is to use XAT{n}_{attrname} where "n" + * is the element in the bitmap (starting at 1). This convention is for + * the convenience of the maintainer to keep track of which element each + * attribute belongs to. + * + * NOTE THAT CONSUMERS MUST *NOT* USE THE XATn_* DEFINES DIRECTLY. CONSUMERS + * MUST USE THE XAT_* DEFINES. + */ +#define XAT0_INDEX 0LL /* Index into bitmap for XAT0 attrs */ +#define XAT0_CREATETIME 0x00000001 /* Create time of file */ +#define XAT0_ARCHIVE 0x00000002 /* Archive */ +#define XAT0_SYSTEM 0x00000004 /* System */ +#define XAT0_READONLY 0x00000008 /* Readonly */ +#define XAT0_HIDDEN 0x00000010 /* Hidden */ +#define XAT0_NOUNLINK 0x00000020 /* Nounlink */ +#define XAT0_IMMUTABLE 0x00000040 /* immutable */ +#define XAT0_APPENDONLY 0x00000080 /* appendonly */ +#define XAT0_NODUMP 0x00000100 /* nodump */ +#define XAT0_OPAQUE 0x00000200 /* opaque */ +#define XAT0_AV_QUARANTINED 0x00000400 /* anti-virus quarantine */ +#define XAT0_AV_MODIFIED 0x00000800 /* anti-virus modified */ +#define XAT0_AV_SCANSTAMP 0x00001000 /* anti-virus scanstamp */ + +#define XAT0_ALL_ATTRS (XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \ + XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \ + XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED| \ + XAT0_AV_MODIFIED|XAT0_AV_SCANSTAMP) + +/* Support for XAT_* optional attributes */ +#define XVA_MASK 0xffffffff /* Used to mask off 32 bits */ +#define XVA_SHFT 32 /* Used to shift index */ + +/* + * Used to pry out the index and attribute bits from the XAT_* attributes + * defined below. Note that we're masking things down to 32 bits then + * casting to uint32_t. + */ +#define XVA_INDEX(attr) ((uint32_t)(((attr) >> XVA_SHFT) & XVA_MASK)) +#define XVA_ATTRBIT(attr) ((uint32_t)((attr) & XVA_MASK)) + +/* + * The following defines present a "flat namespace" so that consumers don't + * need to keep track of which element belongs to which bitmap entry. + * + * NOTE THAT THESE MUST NEVER BE OR-ed TOGETHER + */ +#define XAT_CREATETIME ((XAT0_INDEX << XVA_SHFT) | XAT0_CREATETIME) +#define XAT_ARCHIVE ((XAT0_INDEX << XVA_SHFT) | XAT0_ARCHIVE) +#define XAT_SYSTEM ((XAT0_INDEX << XVA_SHFT) | XAT0_SYSTEM) +#define XAT_READONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_READONLY) +#define XAT_HIDDEN ((XAT0_INDEX << XVA_SHFT) | XAT0_HIDDEN) +#define XAT_NOUNLINK ((XAT0_INDEX << XVA_SHFT) | XAT0_NOUNLINK) +#define XAT_IMMUTABLE ((XAT0_INDEX << XVA_SHFT) | XAT0_IMMUTABLE) +#define XAT_APPENDONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_APPENDONLY) +#define XAT_NODUMP ((XAT0_INDEX << XVA_SHFT) | XAT0_NODUMP) +#define XAT_OPAQUE ((XAT0_INDEX << XVA_SHFT) | XAT0_OPAQUE) +#define XAT_AV_QUARANTINED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_QUARANTINED) +#define XAT_AV_MODIFIED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_MODIFIED) +#define XAT_AV_SCANSTAMP ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_SCANSTAMP) + +/* + * The returned attribute map array (xva_rtnattrmap[]) is located past the + * requested attribute map array (xva_reqattrmap[]). Its location changes + * when the array sizes change. We use a separate pointer in a known location + * (xva_rtnattrmapp) to hold the location of xva_rtnattrmap[]. This is + * set in xva_init() + */ +#define XVA_RTNATTRMAP(xvap) ((xvap)->xva_rtnattrmapp) + +/* + * XVA_SET_REQ() sets an attribute bit in the proper element in the bitmap + * of requested attributes (xva_reqattrmap[]). + */ +#define XVA_SET_REQ(xvap, attr) \ + ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ + ASSERT((xvap)->xva_magic == XVA_MAGIC); \ + (xvap)->xva_reqattrmap[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr) + +/* + * XVA_SET_RTN() sets an attribute bit in the proper element in the bitmap + * of returned attributes (xva_rtnattrmap[]). + */ +#define XVA_SET_RTN(xvap, attr) \ + ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \ + ASSERT((xvap)->xva_magic == XVA_MAGIC); \ + (XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr) + +/* + * XVA_ISSET_REQ() checks the requested attribute bitmap (xva_reqattrmap[]) + * to see of the corresponding attribute bit is set. If so, returns non-zero. + */ +#define XVA_ISSET_REQ(xvap, attr) \ + ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \ + ((xvap)->xva_magic == XVA_MAGIC) && \ + ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \ + ((xvap)->xva_reqattrmap[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0) + +/* + * XVA_ISSET_RTN() checks the returned attribute bitmap (xva_rtnattrmap[]) + * to see of the corresponding attribute bit is set. If so, returns non-zero. + */ +#define XVA_ISSET_RTN(xvap, attr) \ + ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \ + ((xvap)->xva_magic == XVA_MAGIC) && \ + ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \ + ((XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0) + static __inline void vattr_init_mask(vattr_t *vap) { @@ -131,98 +485,58 @@ vattr_init_mask(vattr_t *vap) vap->va_mask |= AT_MTIME; if (vap->va_mode != (u_short)VNOVAL) vap->va_mask |= AT_MODE; - if (vap->va_flags != VNOVAL) - vap->va_mask |= AT_XVATTR; } -#define FCREAT O_CREAT -#define FTRUNC O_TRUNC -#define FDSYNC FFSYNC -#define FRSYNC FFSYNC -#define FSYNC FFSYNC -#define FOFFMAX 0x00 -#define FIGNORECASE 0x00 +#define FCREAT O_CREAT +#define FTRUNC O_TRUNC +#define FSYNC FFSYNC +#define FOFFMAX 0x00 + +enum create { CRCREAT }; static __inline int -vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode, - vnode_t **vpp, enum create crwhy, mode_t umask, struct vnode *startvp, - int fd) +zfs_vn_open(const char *pnamep, enum uio_seg seg, int filemode, int createmode, + vnode_t **vpp, enum create crwhy, mode_t umask) { - struct thread *td = curthread; - struct filedesc *fdc; struct nameidata nd; - int error, operation; + int error; ASSERT(seg == UIO_SYSSPACE); - if ((filemode & FCREAT) != 0) { - ASSERT(filemode == (FWRITE | FCREAT | FTRUNC | FOFFMAX)); - ASSERT(crwhy == CRCREAT); - operation = CREATE; - } else { - ASSERT(filemode == (FREAD | FWRITE | FOFFMAX)); - ASSERT(crwhy == 0); - operation = LOOKUP; - } + ASSERT(filemode == (FWRITE | FCREAT | FTRUNC | FOFFMAX)); + ASSERT(crwhy == CRCREAT); ASSERT(umask == 0); - fdc = td->td_proc->p_fd; - FILEDESC_XLOCK(fdc); - if (fdc->fd_rdir == NULL) { - fdc->fd_rdir = rootvnode; - vref(fdc->fd_rdir); - } - if (fdc->fd_cdir == NULL) { - fdc->fd_cdir = rootvnode; - vref(fdc->fd_rdir); - } - FILEDESC_XUNLOCK(fdc); - - if (startvp != NULL) - vref(startvp); - NDINIT_ATVP(&nd, operation, MPSAFE, UIO_SYSSPACE, pnamep, startvp, td); - filemode |= O_NOFOLLOW; - error = vn_open_cred(&nd, &filemode, createmode, 0, td->td_ucred, NULL); - NDFREE(&nd, NDF_ONLY_PNBUF); + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, pnamep); + error = vn_open(&nd, filemode, createmode); if (error == 0) { - /* We just unlock so we hold a reference. */ VOP_UNLOCK(nd.ni_vp, 0); *vpp = nd.ni_vp; } return (error); } - -static __inline int -zfs_vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode, - vnode_t **vpp, enum create crwhy, mode_t umask) -{ - - return (vn_openat(pnamep, seg, filemode, createmode, vpp, crwhy, - umask, NULL, -1)); -} #define vn_open(pnamep, seg, filemode, createmode, vpp, crwhy, umask) \ zfs_vn_open((pnamep), (seg), (filemode), (createmode), (vpp), (crwhy), (umask)) +#define vn_openat(pnamep, seg, filemode, createmode, vpp, crwhy, umask, rootvn, unk) \ + zfs_vn_open((pnamep), (seg), (filemode), (createmode), (vpp), (crwhy), (umask)) + #define RLIM64_INFINITY 0 static __inline int zfs_vn_rdwr(enum uio_rw rw, vnode_t *vp, caddr_t base, ssize_t len, - offset_t offset, enum uio_seg seg, int ioflag, int ulimit, cred_t *cr, + offset_t offset, enum uio_seg seg, int ioflag, uint64_t ulimit, cred_t *cr, ssize_t *residp) { - struct thread *td = curthread; - int error, vfslocked, resid; + int error; + size_t resid; + ASSERT(rw == UIO_WRITE); ASSERT(ioflag == 0); ASSERT(ulimit == RLIM64_INFINITY); - vfslocked = VFS_LOCK_GIANT(vp->v_mount); - if (rw == UIO_WRITE) { - ioflag = IO_SYNC; - } else { - ioflag = IO_DIRECT; - } - error = vn_rdwr(rw, vp, base, len, offset, seg, ioflag, cr, NOCRED, - &resid, td); - VFS_UNLOCK_GIANT(vfslocked); + ioflag = IO_APPEND | IO_UNIT; + + error = vn_rdwr(rw, vp, base, len, offset, seg, ioflag, cr, + &resid, curlwp); if (residp != NULL) *residp = (ssize_t)resid; return (error); @@ -233,39 +547,78 @@ zfs_vn_rdwr(enum uio_rw rw, vnode_t *vp, caddr_t base, ssize_t len, static __inline int zfs_vop_fsync(vnode_t *vp, int flag, cred_t *cr) { - struct mount *mp; - int error, vfslocked; + int error; ASSERT(flag == FSYNC); - vfslocked = VFS_LOCK_GIANT(vp->v_mount); - if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) - goto drop; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - error = VOP_FSYNC(vp, MNT_WAIT, curthread); + error = VOP_FSYNC(vp, cr, FSYNC_WAIT, 0, 0); VOP_UNLOCK(vp, 0); - vn_finished_write(mp); -drop: - VFS_UNLOCK_GIANT(vfslocked); return (error); } -#define VOP_FSYNC(vp, flag, cr, ct) zfs_vop_fsync((vp), (flag), (cr)) +#define VOP_FSYNC(vp, flag, cr, unk) zfs_vop_fsync((vp), (flag), (cr)) static __inline int zfs_vop_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr) { - int error, vfslocked; + ASSERT(flag == (FWRITE | FCREAT | FTRUNC | FOFFMAX)); ASSERT(count == 1); ASSERT(offset == 0); - vfslocked = VFS_LOCK_GIANT(vp->v_mount); - error = vn_close(vp, flag, cr, curthread); - VFS_UNLOCK_GIANT(vfslocked); + return (vn_close(vp, flag, cr)); +} +#define VOP_CLOSE(vp, oflags, count, offset, cr, unk) \ + zfs_vop_close((vp), (oflags), (count), (offset), (cr)) + +static __inline int +zfs_vop_getattr(vnode_t *vp, vattr_t *ap, int flag, cred_t *cr) +{ + int error; + + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + error = VOP_GETATTR(vp, ap, cr); + VOP_UNLOCK(vp, 0); return (error); } -#define VOP_CLOSE(vp, oflags, count, offset, cr, ct) \ - zfs_vop_close((vp), (oflags), (count), (offset), (cr)) +#define VOP_GETATTR(vp, ap, flag, cr, unk) zfs_vop_getattr((vp), (ap), (flag), (cr)) + +static __inline int +zfs_vop_seek(vnode_t *vp, off_t off, off_t *offp) +{ + int error; + + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + error = VOP_SEEK(vp, off, *offp, kauth_cred_get()); + VOP_UNLOCK(vp, 0); + return (error); +} +#define VOP_SEEK(vp, off, offp, unk) zfs_vop_seek(vp, off, offp) + +#define B_INVAL BC_INVAL + +static __inline int +zfs_vop_putpage(vnode_t *vp, off_t off, size_t len, int flag) +{ + int nbflag; + + nbflag = 0; + if (len == 0) { + nbflag |= PGO_ALLPAGES; + } + if ((flag & B_ASYNC) == 0) { + nbflag |= PGO_SYNCIO; + } + if ((flag & B_INVAL) != 0) { + nbflag |= PGO_FREE; + } else { + nbflag |= PGO_CLEANIT; + } + + mutex_enter(&vp->v_interlock); + return VOP_PUTPAGES(vp, off, len, nbflag); +} +#define VOP_PUTPAGE(vp, off, len, flag, cr, ct) zfs_vop_putpage((vp), (off), (len), (flag)) static __inline int vn_rename(char *from, char *to, enum uio_seg seg) @@ -273,9 +626,10 @@ vn_rename(char *from, char *to, enum uio_seg seg) ASSERT(seg == UIO_SYSSPACE); - return (kern_rename(curthread, from, to, seg)); + return (do_sys_rename(from, to, seg, 0)); } +enum rm { RMFILE }; static __inline int vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag) { @@ -283,7 +637,34 @@ vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag) ASSERT(seg == UIO_SYSSPACE); ASSERT(dirflag == RMFILE); - return (kern_unlink(curthread, fnamep, seg)); + return (do_sys_unlink(fnamep, seg)); } +/* + * Flags for VOP_LOOKUP + * + * Defined in file.h, but also possible, FIGNORECASE + * + */ +#define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */ + +/* + * Flags for VOP_READDIR + */ +#define V_RDDIR_ENTFLAGS 0x01 /* request dirent flags */ + +/* + * Extensible vnode attribute (xva) routines: + * xva_init() initializes an xvattr_t (zero struct, init mapsize, set AT_XATTR) + * xva_getxoptattr() returns a ponter to the xoptattr_t section of xvattr_t + */ +void xva_init(xvattr_t *); +xoptattr_t *xva_getxoptattr(xvattr_t *); + +/* + * VOP_ACCESS flags + */ +#define V_ACE_MASK 0x1 /* mask represents NFSv4 ACE permissions */ +#define V_APPEND 0x2 /* want to do append only check */ + #endif /* _OPENSOLARIS_SYS_VNODE_H_ */ diff --git a/external/cddl/osnet/sys/sys/zone.h b/external/cddl/osnet/sys/sys/zone.h index c0f5c21fd6dd..980ed681c0dd 100644 --- a/external/cddl/osnet/sys/sys/zone.h +++ b/external/cddl/osnet/sys/sys/zone.h @@ -1,3 +1,5 @@ +/* $NetBSD: zone.h,v 1.3 2010/02/21 01:46:36 darran Exp $ */ + /*- * Copyright (c) 2007 Pawel Jakub Dawidek * All rights reserved. @@ -23,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: src/sys/cddl/compat/opensolaris/sys/zone.h,v 1.3.2.1 2009/08/03 08:13:06 kensmith Exp $ + * $FreeBSD: src/sys/compat/opensolaris/sys/zone.h,v 1.1 2007/04/06 01:09:06 pjd Exp $ */ #ifndef _OPENSOLARIS_SYS_ZONE_H_ @@ -31,26 +33,26 @@ #ifdef _KERNEL -#include +struct ucred; /* * Macros to help with zone visibility restrictions. */ /* - * Is thread in the global zone? + * Is process in the global zone? */ -#define INGLOBALZONE(thread) (!jailed((thread)->td_ucred)) +#define INGLOBALZONE(p) (1) /* * Attach the given dataset to the given jail. */ -extern int zone_dataset_attach(struct ucred *, const char *, int); +extern int zone_dataset_attach(struct kauth_cred *, const char *, int); /* * Detach the given dataset to the given jail. */ -extern int zone_dataset_detach(struct ucred *, const char *, int); +extern int zone_dataset_detach(struct kauth_cred *, const char *, int); /* * Returns true if the named pool/dataset is visible in the current zone. @@ -61,6 +63,8 @@ extern int zone_dataset_visible(const char *, int *); #define GLOBAL_ZONEID 0 +extern int getzoneid(void); + #endif /* _KERNEL */ #endif /* !_OPENSOLARIS_SYS_ZONE_H_ */ diff --git a/external/cddl/osnet/usr.bin/Makefile b/external/cddl/osnet/usr.bin/Makefile index 2bcf37a0682f..9c270611d53f 100644 --- a/external/cddl/osnet/usr.bin/Makefile +++ b/external/cddl/osnet/usr.bin/Makefile @@ -1,8 +1,12 @@ -# $NetBSD: Makefile,v 1.1 2009/08/07 20:57:59 haad Exp $ +# $NetBSD: Makefile,v 1.2 2010/02/21 01:46:36 darran Exp $ .include -.if !defined(MKZFS) || ${MKZFS} != "no" +.if ${MKDTRACE} != "no" +SUBDIR+= ctfconvert ctfmerge ctfdump +.endif + +.if ${MKZFS} != "no" SUBDIR+= ztest .endif diff --git a/external/cddl/osnet/usr.bin/ctfconvert/Makefile b/external/cddl/osnet/usr.bin/ctfconvert/Makefile index 462a06c6888a..10298dee9d6c 100644 --- a/external/cddl/osnet/usr.bin/ctfconvert/Makefile +++ b/external/cddl/osnet/usr.bin/ctfconvert/Makefile @@ -1,3 +1,5 @@ +# $NetBSD: Makefile,v 1.2 2010/02/21 01:46:36 darran Exp $ + # $FreeBSD: src/cddl/usr.bin/ctfconvert/Makefile,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ .include @@ -29,23 +31,27 @@ SRCS= alist.c \ traverse.c \ util.c -WARNS?= 6 - -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \ - -I${.CURDIR}/../../../cddl/compat/opensolaris/include \ +CFLAGS+= -I${OSNETDIR}/sys \ + -I${OSNETDIR}/include \ -I${OPENSOLARIS_USR_DISTDIR} \ -I${OPENSOLARIS_SYS_DISTDIR} \ -I${OPENSOLARIS_USR_DISTDIR}/head \ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/common \ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \ - -I${OPENSOLARIS_SYS_DISTDIR}/uts/common + -I${OPENSOLARIS_SYS_DISTDIR}/uts/common \ + -g -LDADD+= -lctf -ldwarf -lelf -lz -lthr +.ifndef HOSTPROG +LDADD+= -L${OSNETDIR}/lib/libctf \ + -L${NETBSDSRCDIR}/external/bsd/libdwarf/lib \ + -L${NETBSDSRCDIR}/external/bsd/libelf/lib +LDADD+= -lctf -ldwarf -lelf -lz +.endif .PATH: ${.CURDIR} .PATH: ${OPENSOLARIS_USR_DISTDIR}/tools/ctf/common .PATH: ${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt -MK_MAN= no +MKMAN= no .include diff --git a/external/cddl/osnet/usr.bin/ctfdump/Makefile b/external/cddl/osnet/usr.bin/ctfdump/Makefile index 538cbf7cf5fa..05e491d6322d 100644 --- a/external/cddl/osnet/usr.bin/ctfdump/Makefile +++ b/external/cddl/osnet/usr.bin/ctfdump/Makefile @@ -1,3 +1,5 @@ +# $NetBSD: Makefile,v 1.2 2010/02/21 01:46:36 darran Exp $ + # $FreeBSD: src/cddl/usr.bin/ctfdump/Makefile,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ .include "../../Makefile.inc" @@ -8,24 +10,24 @@ SRCS= dump.c \ symbol.c \ utils.c -WARNS?= 6 - -CFLAGS+= -I${OPENSOLARIS_USR_DISTDIR} \ +CFLAGS+= -I${OSNETDIR}/sys \ + -I${OSNETDIR}/include \ + -I${OPENSOLARIS_USR_DISTDIR} \ -I${OPENSOLARIS_SYS_DISTDIR} \ -I${OPENSOLARIS_USR_DISTDIR}/head \ -I${OPENSOLARIS_USR_DISTDIR}/cmd/mdb/tools/common \ - -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \ - -I${.CURDIR}/../../../cddl/compat/opensolaris/include \ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/common \ - -I${OPENSOLARIS_SYS_DISTDIR}/uts/common + -I${OPENSOLARIS_SYS_DISTDIR}/uts/common \ + -I${NETBSDSRCDIR}/external/bsd/libelf/dist LDFLAGS+= -pthread +LDADD+= -L${NETBSDSRCDIR}/external/bsd/libelf/lib LDADD+= -lelf -lz .PATH: ${OPENSOLARIS_USR_DISTDIR}/tools/ctf/common .PATH: ${OPENSOLARIS_USR_DISTDIR}/tools/ctf/dump -NO_MAN= +MKMAN= no .include diff --git a/external/cddl/osnet/usr.bin/ctfmerge/Makefile b/external/cddl/osnet/usr.bin/ctfmerge/Makefile index f4f809e4bed8..12207b8e1a12 100644 --- a/external/cddl/osnet/usr.bin/ctfmerge/Makefile +++ b/external/cddl/osnet/usr.bin/ctfmerge/Makefile @@ -1,11 +1,11 @@ +# $NetBSD: Makefile,v 1.2 2010/02/21 01:46:36 darran Exp $ + # $FreeBSD: src/cddl/usr.bin/ctfmerge/Makefile,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ .include .include "../../Makefile.inc" -WARNS= 1 - PROG= ctfmerge SRCS= alist.c \ @@ -26,22 +26,25 @@ SRCS= alist.c \ traverse.c \ util.c -WARNS?= 6 - -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \ - -I${.CURDIR}/../../../cddl/compat/opensolaris/include \ +CFLAGS+= -I${OSNETDIR}/sys \ + -I${OSNETDIR}/include \ -I${OPENSOLARIS_USR_DISTDIR} \ -I${OPENSOLARIS_SYS_DISTDIR} \ -I${OPENSOLARIS_USR_DISTDIR}/head \ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/common \ -I${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt \ - -I${OPENSOLARIS_SYS_DISTDIR}/uts/common + -I${OPENSOLARIS_SYS_DISTDIR}/uts/common \ -LDADD+= -lctf -ldwarf -lelf -lz -lthr +.ifndef HOSTPROG +LDADD+= -L${OSNETDIR}/lib/libctf \ + -L${NETBSDSRCDIR}/exernal/bsd/libdwarf/lib \ + -L${NETBSDSRCDIR}/external/bsd/libelf/lib +LDADD+= -lctf -ldwarf -lelf -lz -lpthread +.endif .PATH: ${OPENSOLARIS_USR_DISTDIR}/tools/ctf/common .PATH: ${OPENSOLARIS_USR_DISTDIR}/tools/ctf/cvt -MK_MAN= no +MKMAN= no .include diff --git a/external/cddl/osnet/usr.sbin/Makefile b/external/cddl/osnet/usr.sbin/Makefile index 0ebb2f85e6a3..477580c3acb3 100644 --- a/external/cddl/osnet/usr.sbin/Makefile +++ b/external/cddl/osnet/usr.sbin/Makefile @@ -1,8 +1,12 @@ -# $NetBSD: Makefile,v 1.1 2009/08/07 20:57:59 haad Exp $ +# $NetBSD: Makefile,v 1.2 2010/02/21 01:46:36 darran Exp $ .include -.if !defined(MKZFS) || ${MKZFS} != "no" +.if ${MKDTRACE} != "no" +SUBDIR+= dtrace +.endif + +.if ${MKZFS} != "no" SUBDIR+= zdb .endif diff --git a/external/cddl/osnet/usr.sbin/dtrace/Makefile b/external/cddl/osnet/usr.sbin/dtrace/Makefile index 8f4728639a32..1ef3c0e36f7b 100644 --- a/external/cddl/osnet/usr.sbin/dtrace/Makefile +++ b/external/cddl/osnet/usr.sbin/dtrace/Makefile @@ -1,3 +1,5 @@ +# $NetBSD: Makefile,v 1.2 2010/02/21 01:46:36 darran Exp $ + # $FreeBSD: src/cddl/usr.sbin/dtrace/Makefile,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ .include "../../Makefile.inc" @@ -8,15 +10,15 @@ BINDIR?= /usr/sbin SRCS= dtrace.c -WARNS= 1 +#WARNS= 1 -CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \ - -I${.CURDIR}/../../../cddl/compat/opensolaris/include \ +CFLAGS+= -I${OSNETDIR}/sys \ + -I${OSNETDIR}/include \ -I${OPENSOLARIS_USR_DISTDIR}/head \ -I${OPENSOLARIS_USR_DISTDIR}/lib/libdtrace/common \ -I${OPENSOLARIS_USR_DISTDIR}/lib/libproc/common \ -I${OPENSOLARIS_SYS_DISTDIR}/uts/common \ - -I${OPENSOLARIS_SYS_DISTDIR}/compat + -I${OPENSOLARIS_SYS_DISTDIR}/compat \ .PATH: ${OPENSOLARIS_USR_DISTDIR}/cmd/dtrace @@ -25,13 +27,19 @@ CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \ #YFLAGS+= -d LDFLAGS+= -pthread \ + -L${OSNETDIR}/lib/libdtrace \ + -L${OSNETDIR}/lib/libctf + +LDADD+= -ldtrace -ly -ll -lctf -lelf -lz + +#LDFLAGS+= -pthread \ -L${.OBJDIR}/../../lib/libdtrace \ -L${.OBJDIR}/../../lib/libproc \ -L${.OBJDIR}/../../lib/libctf \ -L${.OBJDIR}/../../../lib/libelf -LDADD+= -ldtrace -ly -ll -lproc -lctf -lelf -lz +#LDADD+= -ldtrace -ly -ll -lproc -lctf -lelf -lz -DPADD+= ${LIBDTRACE} ${LIBCTF} ${LIBELF} ${LIBPTHREAD} ${LIBL} ${LIBY} ${LIBZ} +#DPADD+= ${LIBDTRACE} ${LIBCTF} ${LIBELF} ${LIBPTHREAD} ${LIBL} ${LIBY} ${LIBZ} .include