Merge ^/head r320573 through r320970.

This commit is contained in:
dim 2017-07-13 22:01:38 +00:00
commit ffc6bbcae0
836 changed files with 40016 additions and 14815 deletions

View File

@ -655,7 +655,8 @@ LIBCOMPAT= SOFT
# when the ABI breaks though that we want to force rebuilding WORLDTMP
# to get updated host tools.
.if ${MK_META_MODE} == "yes" && defined(NO_CLEAN) && \
!defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS)
!defined(NO_META_IGNORE_HOST) && !defined(NO_META_IGNORE_HOST_HEADERS) && \
!make(showconfig)
# r318736 - ino64 major ABI breakage
META_MODE_BAD_ABI_VERS+= 1200031
@ -761,7 +762,15 @@ _worldtmp: .PHONY
.endif
.else
rm -rf ${WORLDTMP}/legacy/usr/include
.endif
.if ${USING_SYSTEM_COMPILER} == "yes"
.for cc in cc c++
if [ -x ${WORLDTMP}/usr/bin/${cc} ]; then \
inum=$$(stat -f %i ${WORLDTMP}/usr/bin/${cc}); \
find ${WORLDTMP}/usr/bin -inum $${inum} -delete; \
fi
.endfor
.endif # ${USING_SYSTEM_COMPILER} == "yes"
.endif # !defined(NO_CLEAN)
# Our current approach to dependency tracking cannot cope with certain source
# tree changes, particularly with respect to removing source files and
@ -1641,8 +1650,8 @@ create-kernel-packages-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap
.for _kernel in ${BUILDKERNELS:[2..-1]}
.if exists(${KSTAGEDIR}/kernel.${_kernel}.meta)
.for flavor in "" -debug
create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}
create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}: _pkgbootstrap .PHONY
create-kernel-packages: create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}
create-kernel-packages-extra-flavor${flavor:C,^""$,${_default_flavor},}-${_kernel}: _pkgbootstrap .PHONY
@cd ${KSTAGEDIR}/kernel.${_kernel} ; \
awk -f ${SRCDIR}/release/scripts/mtree-to-plist.awk \
-v kernel=yes -v _kernconf=${_kernel} \

View File

@ -47,8 +47,6 @@ SUBDIR.${MK_TESTS}+= tests
.include <bsd.arch.inc.mk>
SUBDIR:= ${SUBDIR:O}
SUBDIR_PARALLEL=
.include <bsd.subdir.mk>

View File

@ -350,7 +350,8 @@ next_addr(void)
ibufp++;
addr_cnt++;
second_addr = (c == ';') ? current_addr : 1;
addr = addr_last;
if ((addr = next_addr()) < 0)
addr = addr_last;
break;
}
/* FALLTHROUGH */
@ -809,7 +810,7 @@ exec_command(void)
if ((addr = write_file(*fnp ? fnp : old_filename,
(c == 'W') ? "a" : "w", first_addr, second_addr)) < 0)
return ERR;
else if (addr == addr_last)
else if (addr == addr_last && *fnp != '!')
modified = 0;
else if (modified && !scripted && n == 'q')
gflag = EMOD;

View File

@ -29,7 +29,7 @@
.\" @(#)rcp.1 8.1 (Berkeley) 5/31/93
.\" $FreeBSD$
.\"
.Dd October 16, 2002
.Dd July 3, 2017
.Dt RCP 1
.Os
.Sh NAME
@ -43,6 +43,15 @@
.Op Fl 46pr
.Ar
.Ar directory
.Sh DEPRECATION NOTICE
.Nm
is deprecated and will be removed from future versions of the
.Fx
base system.
If
.Nm
is still required, it can be installed from ports or packages
(net/bsdrcmds).
.Sh DESCRIPTION
The
.Nm

View File

@ -18,7 +18,7 @@ ippool \- user interface to the IPFilter pools
-F [-dv] [-o <role>] [-t <type>]
.br
.B ippool
-l [-dv] [-m <name>] [-t <type>]
-l [-dv] [-m <name>] [-t <type>] [-o <role>] [-M <core>] [-N <namelist>]
.br
.B ippool
-r [-dnv] [-m <name>] [-o <role>] [-t <type>] -i <ipaddr>[/<netmask>]

View File

@ -79,7 +79,7 @@ usage(prog)
fprintf(stderr, "\t-A [-dnv] [-m <name>] [-o <role>] [-S <seed>] [-t <type>]\n");
fprintf(stderr, "\t-f <file> [-dnuv]\n");
fprintf(stderr, "\t-F [-dv] [-o <role>] [-t <type>]\n");
fprintf(stderr, "\t-l [-dv] [-m <name>] [-t <type>]\n");
fprintf(stderr, "\t-l [-dv] [-m <name>] [-t <type>] [-o <role>] [-M <core>] [-N <namelist>]\n");
fprintf(stderr, "\t-r [-dnv] [-m <name>] [-o <role>] [-t type] -i <ipaddr>[/netmask]\n");
fprintf(stderr, "\t-R [-dnv] [-m <name>] [-o <role>] [-t <type>]\n");
fprintf(stderr, "\t-s [-dtv] [-M <core>] [-N <namelist>]\n");

View File

@ -4,6 +4,41 @@ brevity. Much more detail can be found in the git revision history:
https://github.com/jemalloc/jemalloc
* 5.0.1 (July 1, 2017)
This bugfix release fixes several issues, most of which are obscure enough
that typical applications are not impacted.
Bug fixes:
- Update decay->nunpurged before purging, in order to avoid potential update
races and subsequent incorrect purging volume. (@interwq)
- Only abort on dlsym(3) error if the failure impacts an enabled feature (lazy
locking and/or background threads). This mitigates an initialization
failure bug for which we still do not have a clear reproduction test case.
(@interwq)
- Modify tsd management so that it neither crashes nor leaks if a thread's
only allocation activity is to call free() after TLS destructors have been
executed. This behavior was observed when operating with GNU libc, and is
unlikely to be an issue with other libc implementations. (@interwq)
- Mask signals during background thread creation. This prevents signals from
being inadvertently delivered to background threads. (@jasone,
@davidtgoldblatt, @interwq)
- Avoid inactivity checks within background threads, in order to prevent
recursive mutex acquisition. (@interwq)
- Fix extent_grow_retained() to use the specified hooks when the
arena.<i>.extent_hooks mallctl is used to override the default hooks.
(@interwq)
- Add missing reentrancy support for custom extent hooks which allocate.
(@interwq)
- Post-fork(2), re-initialize the list of tcaches associated with each arena
to contain no tcaches except the forking thread's. (@interwq)
- Add missing post-fork(2) mutex reinitialization for extent_grow_mtx. This
fixes potential deadlocks after fork(2). (@interwq)
- Enforce minimum autoconf version (currently 2.68), since 2.63 is known to
generate corrupt configure scripts. (@jasone)
- Ensure that the configured page size (--with-lg-page) is no larger than the
configured huge page size (--with-lg-hugepage). (@jasone)
* 5.0.0 (June 13, 2017)
Unlike all previous jemalloc releases, this release does not use naturally

View File

@ -1 +1 @@
5.0.0-4-g84f6c2cae0fb1399377ef6aea9368444c4987cc6
5.0.1-0-g896ed3a8b3f41998d4fb4d625d30ac63ef2d51fb

View File

@ -2,12 +2,12 @@
.\" Title: JEMALLOC
.\" Author: Jason Evans
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
.\" Date: 06/29/2017
.\" Date: 07/01/2017
.\" Manual: User Manual
.\" Source: jemalloc 5.0.0-4-g84f6c2cae0fb1399377ef6aea9368444c4987cc6
.\" Source: jemalloc 5.0.1-0-g896ed3a8b3f41998d4fb4d625d30ac63ef2d51fb
.\" Language: English
.\"
.TH "JEMALLOC" "3" "06/29/2017" "jemalloc 5.0.0-4-g84f6c2cae0fb" "User Manual"
.TH "JEMALLOC" "3" "07/01/2017" "jemalloc 5.0.1-0-g896ed3a8b3f4" "User Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@ -31,7 +31,7 @@
jemalloc \- general purpose memory allocation functions
.SH "LIBRARY"
.PP
This manual describes jemalloc 5\&.0\&.0\-4\-g84f6c2cae0fb1399377ef6aea9368444c4987cc6\&. More information can be found at the
This manual describes jemalloc 5\&.0\&.1\-0\-g896ed3a8b3f41998d4fb4d625d30ac63ef2d51fb\&. More information can be found at the
\m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&.
.PP
The following configuration options are enabled in libc\*(Aqs built\-in jemalloc:

View File

@ -90,6 +90,7 @@ void arena_prefork3(tsdn_t *tsdn, arena_t *arena);
void arena_prefork4(tsdn_t *tsdn, arena_t *arena);
void arena_prefork5(tsdn_t *tsdn, arena_t *arena);
void arena_prefork6(tsdn_t *tsdn, arena_t *arena);
void arena_prefork7(tsdn_t *tsdn, arena_t *arena);
void arena_postfork_parent(tsdn_t *tsdn, arena_t *arena);
void arena_postfork_child(tsdn_t *tsdn, arena_t *arena);

View File

@ -41,8 +41,9 @@ background_thread_indefinite_sleep(background_thread_info_t *info) {
}
JEMALLOC_ALWAYS_INLINE void
arena_background_thread_inactivity_check(tsdn_t *tsdn, arena_t *arena) {
if (!background_thread_enabled()) {
arena_background_thread_inactivity_check(tsdn_t *tsdn, arena_t *arena,
bool is_background_thread) {
if (!background_thread_enabled() || is_background_thread) {
return;
}
background_thread_info_t *info =

View File

@ -3,7 +3,7 @@
base_t *b0get(void);
base_t *base_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks);
void base_delete(base_t *base);
void base_delete(tsdn_t *tsdn, base_t *base);
extent_hooks_t *base_extent_hooks_get(base_t *base);
extent_hooks_t *base_extent_hooks_set(base_t *base,
extent_hooks_t *extent_hooks);

View File

@ -91,8 +91,7 @@ typedef struct ctl_arenas_s {
int ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
void *newp, size_t newlen);
int ctl_nametomib(tsdn_t *tsdn, const char *name, size_t *mibp,
size_t *miblenp);
int ctl_nametomib(tsd_t *tsd, const char *name, size_t *mibp, size_t *miblenp);
int ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
size_t *oldlenp, void *newp, size_t newlen);

View File

@ -25,6 +25,7 @@
# include <sys/uio.h>
# endif
# include <pthread.h>
# include <signal.h>
# ifdef JEMALLOC_OS_UNFAIR_LOCK
# include <os/lock.h>
# endif

View File

@ -99,6 +99,9 @@
/* Defined if pthread_atfork(3) is available. */
#define JEMALLOC_HAVE_PTHREAD_ATFORK
/* Defined if pthread_setname_np(3) is available. */
/* #undef JEMALLOC_HAVE_PTHREAD_SETNAME_NP */
/*
* Defined if clock_gettime(CLOCK_MONOTONIC_COARSE, ...) is available.
*/

View File

@ -146,7 +146,10 @@ tcache_get(tsd_t *tsd) {
}
static inline void
pre_reentrancy(tsd_t *tsd) {
pre_reentrancy(tsd_t *tsd, arena_t *arena) {
/* arena is the current context. Reentry from a0 is not allowed. */
assert(arena != arena_get(tsd_tsdn(tsd), 0, false));
bool fast = tsd_fast(tsd);
++*tsd_reentrancy_levelp_get(tsd);
if (fast) {

View File

@ -69,6 +69,7 @@
#define arena_prefork4 JEMALLOC_N(arena_prefork4)
#define arena_prefork5 JEMALLOC_N(arena_prefork5)
#define arena_prefork6 JEMALLOC_N(arena_prefork6)
#define arena_prefork7 JEMALLOC_N(arena_prefork7)
#define arena_prof_promote JEMALLOC_N(arena_prof_promote)
#define arena_ralloc JEMALLOC_N(arena_ralloc)
#define arena_ralloc_no_move JEMALLOC_N(arena_ralloc_no_move)

View File

@ -48,7 +48,7 @@ void tcache_arena_associate(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena);
void tcache_prefork(tsdn_t *tsdn);
void tcache_postfork_parent(tsdn_t *tsdn);
void tcache_postfork_child(tsdn_t *tsdn);
void tcache_flush(void);
void tcache_flush(tsd_t *tsd);
bool tsd_tcache_data_init(tsd_t *tsd);
bool tsd_tcache_enabled_data_init(tsd_t *tsd);

View File

@ -99,9 +99,10 @@ enum {
tsd_state_nominal_slow = 1, /* Initialized but on slow path. */
/* the above 2 nominal states should be lower values. */
tsd_state_nominal_max = 1, /* used for comparison only. */
tsd_state_purgatory = 2,
tsd_state_reincarnated = 3,
tsd_state_uninitialized = 4
tsd_state_minimal_initialized = 2,
tsd_state_purgatory = 3,
tsd_state_reincarnated = 4,
tsd_state_uninitialized = 5
};
/* Manually limit tsd_state_t to a single byte. */
@ -190,7 +191,8 @@ JEMALLOC_ALWAYS_INLINE t * \
tsd_##n##p_get(tsd_t *tsd) { \
assert(tsd->state == tsd_state_nominal || \
tsd->state == tsd_state_nominal_slow || \
tsd->state == tsd_state_reincarnated); \
tsd->state == tsd_state_reincarnated || \
tsd->state == tsd_state_minimal_initialized); \
return tsd_##n##p_get_unsafe(tsd); \
}
MALLOC_TSD
@ -225,7 +227,8 @@ MALLOC_TSD
#define O(n, t, nt) \
JEMALLOC_ALWAYS_INLINE void \
tsd_##n##_set(tsd_t *tsd, t val) { \
assert(tsd->state != tsd_state_reincarnated); \
assert(tsd->state != tsd_state_reincarnated && \
tsd->state != tsd_state_minimal_initialized); \
*tsd_##n##p_get(tsd) = val; \
}
MALLOC_TSD
@ -248,7 +251,7 @@ tsd_fast(tsd_t *tsd) {
}
JEMALLOC_ALWAYS_INLINE tsd_t *
tsd_fetch_impl(bool init, bool internal) {
tsd_fetch_impl(bool init, bool minimal) {
tsd_t *tsd = tsd_get(init);
if (!init && tsd_get_allocates() && tsd == NULL) {
@ -257,7 +260,7 @@ tsd_fetch_impl(bool init, bool internal) {
assert(tsd != NULL);
if (unlikely(tsd->state != tsd_state_nominal)) {
return tsd_fetch_slow(tsd, internal);
return tsd_fetch_slow(tsd, minimal);
}
assert(tsd_fast(tsd));
tsd_assert_fast(tsd);
@ -265,9 +268,20 @@ tsd_fetch_impl(bool init, bool internal) {
return tsd;
}
/* Get a minimal TSD that requires no cleanup. See comments in free(). */
JEMALLOC_ALWAYS_INLINE tsd_t *
tsd_fetch_min(void) {
return tsd_fetch_impl(true, true);
}
/* For internal background threads use only. */
JEMALLOC_ALWAYS_INLINE tsd_t *
tsd_internal_fetch(void) {
return tsd_fetch_impl(true, true);
tsd_t *tsd = tsd_fetch_min();
/* Use reincarnated state to prevent full initialization. */
tsd->state = tsd_state_reincarnated;
return tsd;
}
JEMALLOC_ALWAYS_INLINE tsd_t *

View File

@ -87,12 +87,12 @@ extern "C" {
#include <limits.h>
#include <strings.h>
#define JEMALLOC_VERSION "5.0.0-4-g84f6c2cae0fb1399377ef6aea9368444c4987cc6"
#define JEMALLOC_VERSION "5.0.1-0-g896ed3a8b3f41998d4fb4d625d30ac63ef2d51fb"
#define JEMALLOC_VERSION_MAJOR 5
#define JEMALLOC_VERSION_MINOR 0
#define JEMALLOC_VERSION_BUGFIX 0
#define JEMALLOC_VERSION_NREV 4
#define JEMALLOC_VERSION_GID "84f6c2cae0fb1399377ef6aea9368444c4987cc6"
#define JEMALLOC_VERSION_BUGFIX 1
#define JEMALLOC_VERSION_NREV 0
#define JEMALLOC_VERSION_GID "896ed3a8b3f41998d4fb4d625d30ac63ef2d51fb"
#define MALLOCX_LG_ALIGN(la) ((int)(la))
#if LG_SIZEOF_PTR == 2

View File

@ -61,7 +61,8 @@ const uint64_t h_steps[SMOOTHSTEP_NSTEPS] = {
*/
static void arena_decay_to_limit(tsdn_t *tsdn, arena_t *arena,
arena_decay_t *decay, extents_t *extents, bool all, size_t npages_limit);
arena_decay_t *decay, extents_t *extents, bool all, size_t npages_limit,
bool is_background_thread);
static bool arena_decay_dirty(tsdn_t *tsdn, arena_t *arena,
bool is_background_thread, bool all);
static void arena_dalloc_bin_slab(tsdn_t *tsdn, arena_t *arena, extent_t *slab,
@ -378,7 +379,7 @@ arena_extents_dirty_dalloc(tsdn_t *tsdn, arena_t *arena,
if (arena_dirty_decay_ms_get(arena) == 0) {
arena_decay_dirty(tsdn, arena, false, true);
} else {
arena_background_thread_inactivity_check(tsdn, arena);
arena_background_thread_inactivity_check(tsdn, arena, false);
}
}
@ -687,10 +688,11 @@ arena_decay_backlog_update(arena_decay_t *decay, uint64_t nadvance_u64,
static void
arena_decay_try_purge(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay,
extents_t *extents, size_t current_npages, size_t npages_limit) {
extents_t *extents, size_t current_npages, size_t npages_limit,
bool is_background_thread) {
if (current_npages > npages_limit) {
arena_decay_to_limit(tsdn, arena, decay, extents, false,
npages_limit);
npages_limit, is_background_thread);
}
}
@ -720,7 +722,7 @@ arena_decay_epoch_advance_helper(arena_decay_t *decay, const nstime_t *time,
static void
arena_decay_epoch_advance(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay,
extents_t *extents, const nstime_t *time, bool purge) {
extents_t *extents, const nstime_t *time, bool is_background_thread) {
size_t current_npages = extents_npages_get(extents);
arena_decay_epoch_advance_helper(decay, time, current_npages);
@ -728,9 +730,10 @@ arena_decay_epoch_advance(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay,
/* We may unlock decay->mtx when try_purge(). Finish logging first. */
decay->nunpurged = (npages_limit > current_npages) ? npages_limit :
current_npages;
if (purge) {
if (!background_thread_enabled() || is_background_thread) {
arena_decay_try_purge(tsdn, arena, decay, extents,
current_npages, npages_limit);
current_npages, npages_limit, is_background_thread);
}
}
@ -795,7 +798,7 @@ arena_maybe_decay(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay,
if (decay_ms <= 0) {
if (decay_ms == 0) {
arena_decay_to_limit(tsdn, arena, decay, extents, false,
0);
0, is_background_thread);
}
return false;
}
@ -830,14 +833,13 @@ arena_maybe_decay(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay,
*/
bool advance_epoch = arena_decay_deadline_reached(decay, &time);
if (advance_epoch) {
bool should_purge = is_background_thread ||
!background_thread_enabled();
arena_decay_epoch_advance(tsdn, arena, decay, extents, &time,
should_purge);
is_background_thread);
} else if (is_background_thread) {
arena_decay_try_purge(tsdn, arena, decay, extents,
extents_npages_get(extents),
arena_decay_backlog_npages_limit(decay));
arena_decay_backlog_npages_limit(decay),
is_background_thread);
}
return advance_epoch;
@ -916,7 +918,7 @@ arena_stash_decayed(tsdn_t *tsdn, arena_t *arena,
static size_t
arena_decay_stashed(tsdn_t *tsdn, arena_t *arena,
extent_hooks_t **r_extent_hooks, arena_decay_t *decay, extents_t *extents,
bool all, extent_list_t *decay_extents) {
bool all, extent_list_t *decay_extents, bool is_background_thread) {
UNUSED size_t nmadvise, nunmapped;
size_t npurged;
@ -946,7 +948,7 @@ arena_decay_stashed(tsdn_t *tsdn, arena_t *arena,
extents_dalloc(tsdn, arena, r_extent_hooks,
&arena->extents_muzzy, extent);
arena_background_thread_inactivity_check(tsdn,
arena);
arena, is_background_thread);
break;
}
/* Fall through. */
@ -985,7 +987,8 @@ arena_decay_stashed(tsdn_t *tsdn, arena_t *arena,
*/
static void
arena_decay_to_limit(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay,
extents_t *extents, bool all, size_t npages_limit) {
extents_t *extents, bool all, size_t npages_limit,
bool is_background_thread) {
witness_assert_depth_to_rank(tsdn_witness_tsdp_get(tsdn),
WITNESS_RANK_CORE, 1);
malloc_mutex_assert_owner(tsdn, &decay->mtx);
@ -1005,7 +1008,8 @@ arena_decay_to_limit(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay,
npages_limit, &decay_extents);
if (npurge != 0) {
UNUSED size_t npurged = arena_decay_stashed(tsdn, arena,
&extent_hooks, decay, extents, all, &decay_extents);
&extent_hooks, decay, extents, all, &decay_extents,
is_background_thread);
assert(npurged == npurge);
}
@ -1018,7 +1022,8 @@ arena_decay_impl(tsdn_t *tsdn, arena_t *arena, arena_decay_t *decay,
extents_t *extents, bool is_background_thread, bool all) {
if (all) {
malloc_mutex_lock(tsdn, &decay->mtx);
arena_decay_to_limit(tsdn, arena, decay, extents, all, 0);
arena_decay_to_limit(tsdn, arena, decay, extents, all, 0,
is_background_thread);
malloc_mutex_unlock(tsdn, &decay->mtx);
return false;
@ -1252,7 +1257,7 @@ arena_destroy(tsd_t *tsd, arena_t *arena) {
* Destroy the base allocator, which manages all metadata ever mapped by
* this arena.
*/
base_delete(arena->base);
base_delete(tsd_tsdn(tsd), arena->base);
}
static extent_t *
@ -2046,7 +2051,7 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
* is done enough that we should have tsd.
*/
assert(!tsdn_null(tsdn));
pre_reentrancy(tsdn_tsd(tsdn));
pre_reentrancy(tsdn_tsd(tsdn), arena);
if (hooks_arena_new_hook) {
hooks_arena_new_hook();
}
@ -2056,7 +2061,7 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
return arena;
label_error:
if (ind != 0) {
base_delete(base);
base_delete(tsdn, base);
}
return NULL;
}
@ -2082,28 +2087,33 @@ arena_prefork1(tsdn_t *tsdn, arena_t *arena) {
void
arena_prefork2(tsdn_t *tsdn, arena_t *arena) {
malloc_mutex_prefork(tsdn, &arena->extent_grow_mtx);
}
void
arena_prefork3(tsdn_t *tsdn, arena_t *arena) {
extents_prefork(tsdn, &arena->extents_dirty);
extents_prefork(tsdn, &arena->extents_muzzy);
extents_prefork(tsdn, &arena->extents_retained);
}
void
arena_prefork3(tsdn_t *tsdn, arena_t *arena) {
arena_prefork4(tsdn_t *tsdn, arena_t *arena) {
malloc_mutex_prefork(tsdn, &arena->extent_avail_mtx);
}
void
arena_prefork4(tsdn_t *tsdn, arena_t *arena) {
arena_prefork5(tsdn_t *tsdn, arena_t *arena) {
base_prefork(tsdn, arena->base);
}
void
arena_prefork5(tsdn_t *tsdn, arena_t *arena) {
arena_prefork6(tsdn_t *tsdn, arena_t *arena) {
malloc_mutex_prefork(tsdn, &arena->large_mtx);
}
void
arena_prefork6(tsdn_t *tsdn, arena_t *arena) {
arena_prefork7(tsdn_t *tsdn, arena_t *arena) {
for (unsigned i = 0; i < NBINS; i++) {
malloc_mutex_prefork(tsdn, &arena->bins[i].lock);
}
@ -2122,6 +2132,7 @@ arena_postfork_parent(tsdn_t *tsdn, arena_t *arena) {
extents_postfork_parent(tsdn, &arena->extents_dirty);
extents_postfork_parent(tsdn, &arena->extents_muzzy);
extents_postfork_parent(tsdn, &arena->extents_retained);
malloc_mutex_postfork_parent(tsdn, &arena->extent_grow_mtx);
malloc_mutex_postfork_parent(tsdn, &arena->decay_dirty.mtx);
malloc_mutex_postfork_parent(tsdn, &arena->decay_muzzy.mtx);
if (config_stats) {
@ -2133,6 +2144,23 @@ void
arena_postfork_child(tsdn_t *tsdn, arena_t *arena) {
unsigned i;
atomic_store_u(&arena->nthreads[0], 0, ATOMIC_RELAXED);
atomic_store_u(&arena->nthreads[1], 0, ATOMIC_RELAXED);
if (tsd_arena_get(tsdn_tsd(tsdn)) == arena) {
arena_nthreads_inc(arena, false);
}
if (tsd_iarena_get(tsdn_tsd(tsdn)) == arena) {
arena_nthreads_inc(arena, true);
}
if (config_stats) {
ql_new(&arena->tcache_ql);
tcache_t *tcache = tcache_get(tsdn_tsd(tsdn));
if (tcache != NULL && tcache->arena == arena) {
ql_elm_new(tcache, link);
ql_tail_insert(&arena->tcache_ql, tcache, link);
}
}
for (i = 0; i < NBINS; i++) {
malloc_mutex_postfork_child(tsdn, &arena->bins[i].lock);
}
@ -2142,6 +2170,7 @@ arena_postfork_child(tsdn_t *tsdn, arena_t *arena) {
extents_postfork_child(tsdn, &arena->extents_dirty);
extents_postfork_child(tsdn, &arena->extents_muzzy);
extents_postfork_child(tsdn, &arena->extents_retained);
malloc_mutex_postfork_child(tsdn, &arena->extent_grow_mtx);
malloc_mutex_postfork_child(tsdn, &arena->decay_dirty.mtx);
malloc_mutex_postfork_child(tsdn, &arena->decay_muzzy.mtx);
if (config_stats) {

View File

@ -316,7 +316,7 @@ background_threads_disable_single(tsd_t *tsd, background_thread_info_t *info) {
&background_thread_lock);
}
pre_reentrancy(tsd);
pre_reentrancy(tsd, NULL);
malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx);
bool has_thread;
assert(info->state != background_thread_paused);
@ -347,6 +347,38 @@ background_threads_disable_single(tsd_t *tsd, background_thread_info_t *info) {
static void *background_thread_entry(void *ind_arg);
static int
background_thread_create_signals_masked(pthread_t *thread,
const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg) {
/*
* Mask signals during thread creation so that the thread inherits
* an empty signal set.
*/
sigset_t set;
sigfillset(&set);
sigset_t oldset;
int mask_err = pthread_sigmask(SIG_SETMASK, &set, &oldset);
if (mask_err != 0) {
return mask_err;
}
int create_err = pthread_create_wrapper(thread, attr, start_routine,
arg);
/*
* Restore the signal mask. Failure to restore the signal mask here
* changes program behavior.
*/
int restore_err = pthread_sigmask(SIG_SETMASK, &oldset, NULL);
if (restore_err != 0) {
malloc_printf("<jemalloc>: background thread creation "
"failed (%d), and signal mask restoration failed "
"(%d)\n", create_err, restore_err);
if (opt_abort) {
abort();
}
}
return create_err;
}
static void
check_background_thread_creation(tsd_t *tsd, unsigned *n_created,
bool *created_threads) {
@ -376,9 +408,9 @@ check_background_thread_creation(tsd_t *tsd, unsigned *n_created,
*/
malloc_mutex_unlock(tsd_tsdn(tsd), &background_thread_lock);
pre_reentrancy(tsd);
int err = pthread_create_wrapper(&info->thread, NULL,
background_thread_entry, (void *)(uintptr_t)i);
pre_reentrancy(tsd, NULL);
int err = background_thread_create_signals_masked(&info->thread,
NULL, background_thread_entry, (void *)(uintptr_t)i);
post_reentrancy(tsd);
if (err == 0) {
@ -467,7 +499,9 @@ static void *
background_thread_entry(void *ind_arg) {
unsigned thread_ind = (unsigned)(uintptr_t)ind_arg;
assert(thread_ind < ncpus);
#ifdef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
pthread_setname_np(pthread_self(), "jemalloc_bg_thd");
#endif
if (opt_percpu_arena != percpu_arena_disabled) {
set_current_thread_affinity((int)thread_ind);
}
@ -523,12 +557,12 @@ background_thread_create(tsd_t *tsd, unsigned arena_ind) {
return false;
}
pre_reentrancy(tsd);
pre_reentrancy(tsd, NULL);
/*
* To avoid complications (besides reentrancy), create internal
* background threads with the underlying pthread_create.
*/
int err = pthread_create_wrapper(&info->thread, NULL,
int err = background_thread_create_signals_masked(&info->thread, NULL,
background_thread_entry, (void *)thread_ind);
post_reentrancy(tsd);

View File

@ -15,7 +15,7 @@ static base_t *b0;
/******************************************************************************/
static void *
base_map(extent_hooks_t *extent_hooks, unsigned ind, size_t size) {
base_map(tsdn_t *tsdn, extent_hooks_t *extent_hooks, unsigned ind, size_t size) {
void *addr;
bool zero = true;
bool commit = true;
@ -25,15 +25,19 @@ base_map(extent_hooks_t *extent_hooks, unsigned ind, size_t size) {
if (extent_hooks == &extent_hooks_default) {
addr = extent_alloc_mmap(NULL, size, PAGE, &zero, &commit);
} else {
/* No arena context as we are creating new arenas. */
tsd_t *tsd = tsdn_null(tsdn) ? tsd_fetch() : tsdn_tsd(tsdn);
pre_reentrancy(tsd, NULL);
addr = extent_hooks->alloc(extent_hooks, NULL, size, PAGE,
&zero, &commit, ind);
post_reentrancy(tsd);
}
return addr;
}
static void
base_unmap(extent_hooks_t *extent_hooks, unsigned ind, void *addr,
base_unmap(tsdn_t *tsdn, extent_hooks_t *extent_hooks, unsigned ind, void *addr,
size_t size) {
/*
* Cascade through dalloc, decommit, purge_forced, and purge_lazy,
@ -61,27 +65,32 @@ base_unmap(extent_hooks_t *extent_hooks, unsigned ind, void *addr,
/* Nothing worked. This should never happen. */
not_reached();
} else {
tsd_t *tsd = tsdn_null(tsdn) ? tsd_fetch() : tsdn_tsd(tsdn);
pre_reentrancy(tsd, NULL);
if (extent_hooks->dalloc != NULL &&
!extent_hooks->dalloc(extent_hooks, addr, size, true,
ind)) {
return;
goto label_done;
}
if (extent_hooks->decommit != NULL &&
!extent_hooks->decommit(extent_hooks, addr, size, 0, size,
ind)) {
return;
goto label_done;
}
if (extent_hooks->purge_forced != NULL &&
!extent_hooks->purge_forced(extent_hooks, addr, size, 0,
size, ind)) {
return;
goto label_done;
}
if (extent_hooks->purge_lazy != NULL &&
!extent_hooks->purge_lazy(extent_hooks, addr, size, 0, size,
ind)) {
return;
goto label_done;
}
/* Nothing worked. That's the application's problem. */
label_done:
post_reentrancy(tsd);
return;
}
}
@ -157,7 +166,7 @@ base_extent_bump_alloc(tsdn_t *tsdn, base_t *base, extent_t *extent,
* On success a pointer to the initialized base_block_t header is returned.
*/
static base_block_t *
base_block_alloc(extent_hooks_t *extent_hooks, unsigned ind,
base_block_alloc(tsdn_t *tsdn, extent_hooks_t *extent_hooks, unsigned ind,
pszind_t *pind_last, size_t *extent_sn_next, size_t size,
size_t alignment) {
alignment = ALIGNMENT_CEILING(alignment, QUANTUM);
@ -179,7 +188,7 @@ base_block_alloc(extent_hooks_t *extent_hooks, unsigned ind,
size_t next_block_size = HUGEPAGE_CEILING(sz_pind2sz(pind_next));
size_t block_size = (min_block_size > next_block_size) ? min_block_size
: next_block_size;
base_block_t *block = (base_block_t *)base_map(extent_hooks, ind,
base_block_t *block = (base_block_t *)base_map(tsdn, extent_hooks, ind,
block_size);
if (block == NULL) {
return NULL;
@ -207,8 +216,9 @@ base_extent_alloc(tsdn_t *tsdn, base_t *base, size_t size, size_t alignment) {
* called.
*/
malloc_mutex_unlock(tsdn, &base->mtx);
base_block_t *block = base_block_alloc(extent_hooks, base_ind_get(base),
&base->pind_last, &base->extent_sn_next, size, alignment);
base_block_t *block = base_block_alloc(tsdn, extent_hooks,
base_ind_get(base), &base->pind_last, &base->extent_sn_next, size,
alignment);
malloc_mutex_lock(tsdn, &base->mtx);
if (block == NULL) {
return NULL;
@ -234,8 +244,8 @@ base_t *
base_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
pszind_t pind_last = 0;
size_t extent_sn_next = 0;
base_block_t *block = base_block_alloc(extent_hooks, ind, &pind_last,
&extent_sn_next, sizeof(base_t), QUANTUM);
base_block_t *block = base_block_alloc(tsdn, extent_hooks, ind,
&pind_last, &extent_sn_next, sizeof(base_t), QUANTUM);
if (block == NULL) {
return NULL;
}
@ -249,7 +259,7 @@ base_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
atomic_store_p(&base->extent_hooks, extent_hooks, ATOMIC_RELAXED);
if (malloc_mutex_init(&base->mtx, "base", WITNESS_RANK_BASE,
malloc_mutex_rank_exclusive)) {
base_unmap(extent_hooks, ind, block, block->size);
base_unmap(tsdn, extent_hooks, ind, block, block->size);
return NULL;
}
base->pind_last = pind_last;
@ -272,13 +282,13 @@ base_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
}
void
base_delete(base_t *base) {
base_delete(tsdn_t *tsdn, base_t *base) {
extent_hooks_t *extent_hooks = base_extent_hooks_get(base);
base_block_t *next = base->blocks;
do {
base_block_t *block = next;
next = block->next;
base_unmap(extent_hooks, base_ind_get(base), block,
base_unmap(tsdn, extent_hooks, base_ind_get(base), block,
block->size);
} while (next != NULL);
}

View File

@ -622,7 +622,7 @@ arenas_i2a(size_t i) {
}
static ctl_arena_t *
arenas_i_impl(tsdn_t *tsdn, size_t i, bool compat, bool init) {
arenas_i_impl(tsd_t *tsd, size_t i, bool compat, bool init) {
ctl_arena_t *ret;
assert(!compat || !init);
@ -635,15 +635,15 @@ arenas_i_impl(tsdn_t *tsdn, size_t i, bool compat, bool init) {
ctl_arena_stats_t astats;
};
struct container_s *cont =
(struct container_s *)base_alloc(tsdn, b0get(),
sizeof(struct container_s), QUANTUM);
(struct container_s *)base_alloc(tsd_tsdn(tsd),
b0get(), sizeof(struct container_s), QUANTUM);
if (cont == NULL) {
return NULL;
}
ret = &cont->ctl_arena;
ret->astats = &cont->astats;
} else {
ret = (ctl_arena_t *)base_alloc(tsdn, b0get(),
ret = (ctl_arena_t *)base_alloc(tsd_tsdn(tsd), b0get(),
sizeof(ctl_arena_t), QUANTUM);
if (ret == NULL) {
return NULL;
@ -659,7 +659,7 @@ arenas_i_impl(tsdn_t *tsdn, size_t i, bool compat, bool init) {
static ctl_arena_t *
arenas_i(size_t i) {
ctl_arena_t *ret = arenas_i_impl(TSDN_NULL, i, true, false);
ctl_arena_t *ret = arenas_i_impl(tsd_fetch(), i, true, false);
assert(ret != NULL);
return ret;
}
@ -863,7 +863,7 @@ ctl_arena_refresh(tsdn_t *tsdn, arena_t *arena, ctl_arena_t *ctl_sdarena,
}
static unsigned
ctl_arena_init(tsdn_t *tsdn, extent_hooks_t *extent_hooks) {
ctl_arena_init(tsd_t *tsd, extent_hooks_t *extent_hooks) {
unsigned arena_ind;
ctl_arena_t *ctl_arena;
@ -876,12 +876,12 @@ ctl_arena_init(tsdn_t *tsdn, extent_hooks_t *extent_hooks) {
}
/* Trigger stats allocation. */
if (arenas_i_impl(tsdn, arena_ind, false, true) == NULL) {
if (arenas_i_impl(tsd, arena_ind, false, true) == NULL) {
return UINT_MAX;
}
/* Initialize new arena. */
if (arena_init(tsdn, arena_ind, extent_hooks) == NULL) {
if (arena_init(tsd_tsdn(tsd), arena_ind, extent_hooks) == NULL) {
return UINT_MAX;
}
@ -975,8 +975,9 @@ ctl_refresh(tsdn_t *tsdn) {
}
static bool
ctl_init(tsdn_t *tsdn) {
ctl_init(tsd_t *tsd) {
bool ret;
tsdn_t *tsdn = tsd_tsdn(tsd);
malloc_mutex_lock(tsdn, &ctl_mtx);
if (!ctl_initialized) {
@ -1010,14 +1011,14 @@ ctl_init(tsdn_t *tsdn) {
* here rather than doing it lazily elsewhere, in order
* to limit when OOM-caused errors can occur.
*/
if ((ctl_sarena = arenas_i_impl(tsdn, MALLCTL_ARENAS_ALL, false,
if ((ctl_sarena = arenas_i_impl(tsd, MALLCTL_ARENAS_ALL, false,
true)) == NULL) {
ret = true;
goto label_return;
}
ctl_sarena->initialized = true;
if ((ctl_darena = arenas_i_impl(tsdn, MALLCTL_ARENAS_DESTROYED,
if ((ctl_darena = arenas_i_impl(tsd, MALLCTL_ARENAS_DESTROYED,
false, true)) == NULL) {
ret = true;
goto label_return;
@ -1031,7 +1032,7 @@ ctl_init(tsdn_t *tsdn) {
ctl_arenas->narenas = narenas_total_get();
for (i = 0; i < ctl_arenas->narenas; i++) {
if (arenas_i_impl(tsdn, i, false, true) == NULL) {
if (arenas_i_impl(tsd, i, false, true) == NULL) {
ret = true;
goto label_return;
}
@ -1156,7 +1157,7 @@ ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
size_t mib[CTL_MAX_DEPTH];
const ctl_named_node_t *node;
if (!ctl_initialized && ctl_init(tsd_tsdn(tsd))) {
if (!ctl_initialized && ctl_init(tsd)) {
ret = EAGAIN;
goto label_return;
}
@ -1180,15 +1181,15 @@ ctl_byname(tsd_t *tsd, const char *name, void *oldp, size_t *oldlenp,
}
int
ctl_nametomib(tsdn_t *tsdn, const char *name, size_t *mibp, size_t *miblenp) {
ctl_nametomib(tsd_t *tsd, const char *name, size_t *mibp, size_t *miblenp) {
int ret;
if (!ctl_initialized && ctl_init(tsdn)) {
if (!ctl_initialized && ctl_init(tsd)) {
ret = EAGAIN;
goto label_return;
}
ret = ctl_lookup(tsdn, name, NULL, mibp, miblenp);
ret = ctl_lookup(tsd_tsdn(tsd), name, NULL, mibp, miblenp);
label_return:
return(ret);
}
@ -1200,7 +1201,7 @@ ctl_bymib(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
const ctl_named_node_t *node;
size_t i;
if (!ctl_initialized && ctl_init(tsd_tsdn(tsd))) {
if (!ctl_initialized && ctl_init(tsd)) {
ret = EAGAIN;
goto label_return;
}
@ -1696,7 +1697,7 @@ thread_tcache_flush_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
READONLY();
WRITEONLY();
tcache_flush();
tcache_flush(tsd);
ret = 0;
label_return:
@ -1970,7 +1971,7 @@ arena_reset_finish_background_thread(tsd_t *tsd, unsigned arena_ind) {
unsigned ind = arena_ind % ncpus;
background_thread_info_t *info =
&background_thread_info[ind];
assert(info->state = background_thread_paused);
assert(info->state == background_thread_paused);
malloc_mutex_lock(tsd_tsdn(tsd), &info->mtx);
info->state = background_thread_started;
malloc_mutex_unlock(tsd_tsdn(tsd), &info->mtx);
@ -2312,8 +2313,7 @@ arenas_create_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, void *oldp,
extent_hooks = (extent_hooks_t *)&extent_hooks_default;
WRITE(extent_hooks, extent_hooks_t *);
if ((arena_ind = ctl_arena_init(tsd_tsdn(tsd), extent_hooks)) ==
UINT_MAX) {
if ((arena_ind = ctl_arena_init(tsd, extent_hooks)) == UINT_MAX) {
ret = EAGAIN;
goto label_return;
}

View File

@ -1025,6 +1025,18 @@ extent_alloc_default(extent_hooks_t *extent_hooks, void *new_addr, size_t size,
alignment, zero, commit);
}
static void
extent_hook_pre_reentrancy(tsdn_t *tsdn, arena_t *arena) {
tsd_t *tsd = tsdn_null(tsdn) ? tsd_fetch() : tsdn_tsd(tsdn);
pre_reentrancy(tsd, arena);
}
static void
extent_hook_post_reentrancy(tsdn_t *tsdn) {
tsd_t *tsd = tsdn_null(tsdn) ? tsd_fetch() : tsdn_tsd(tsdn);
post_reentrancy(tsd);
}
/*
* If virtual memory is retained, create increasingly larger extents from which
* to split requested extents in order to limit the total number of disjoint
@ -1073,9 +1085,11 @@ extent_grow_retained(tsdn_t *tsdn, arena_t *arena,
&zeroed, &committed, (dss_prec_t)atomic_load_u(
&arena->dss_prec, ATOMIC_RELAXED));
} else {
extent_hook_pre_reentrancy(tsdn, arena);
ptr = (*r_extent_hooks)->alloc(*r_extent_hooks, NULL,
alloc_size, PAGE, &zeroed, &committed,
arena_ind_get(arena));
extent_hook_post_reentrancy(tsdn);
}
extent_init(extent, arena, ptr, alloc_size, false, NSIZES,
@ -1247,8 +1261,10 @@ extent_alloc_wrapper_hard(tsdn_t *tsdn, arena_t *arena,
addr = extent_alloc_default_impl(tsdn, arena, new_addr, esize,
alignment, zero, commit);
} else {
extent_hook_pre_reentrancy(tsdn, arena);
addr = (*r_extent_hooks)->alloc(*r_extent_hooks, new_addr,
esize, alignment, zero, commit, arena_ind_get(arena));
extent_hook_post_reentrancy(tsdn);
}
if (addr == NULL) {
extent_dalloc(tsdn, arena, extent);
@ -1486,10 +1502,12 @@ extent_dalloc_wrapper_try(tsdn_t *tsdn, arena_t *arena,
err = extent_dalloc_default_impl(extent_base_get(extent),
extent_size_get(extent));
} else {
extent_hook_pre_reentrancy(tsdn, arena);
err = ((*r_extent_hooks)->dalloc == NULL ||
(*r_extent_hooks)->dalloc(*r_extent_hooks,
extent_base_get(extent), extent_size_get(extent),
extent_committed_get(extent), arena_ind_get(arena)));
extent_hook_post_reentrancy(tsdn);
}
if (!err) {
@ -1515,6 +1533,9 @@ extent_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena,
}
extent_reregister(tsdn, extent);
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_pre_reentrancy(tsdn, arena);
}
/* Try to decommit; purge if that fails. */
bool zeroed;
if (!extent_committed_get(extent)) {
@ -1536,6 +1557,9 @@ extent_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena,
} else {
zeroed = false;
}
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_post_reentrancy(tsdn);
}
extent_zeroed_set(extent, zeroed);
if (config_prof) {
@ -1579,9 +1603,11 @@ extent_destroy_wrapper(tsdn_t *tsdn, arena_t *arena,
extent_destroy_default_impl(extent_base_get(extent),
extent_size_get(extent));
} else if ((*r_extent_hooks)->destroy != NULL) {
extent_hook_pre_reentrancy(tsdn, arena);
(*r_extent_hooks)->destroy(*r_extent_hooks,
extent_base_get(extent), extent_size_get(extent),
extent_committed_get(extent), arena_ind_get(arena));
extent_hook_post_reentrancy(tsdn);
}
extent_dalloc(tsdn, arena, extent);
@ -1602,9 +1628,15 @@ extent_commit_impl(tsdn_t *tsdn, arena_t *arena,
WITNESS_RANK_CORE, growing_retained ? 1 : 0);
extent_hooks_assure_initialized(arena, r_extent_hooks);
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_pre_reentrancy(tsdn, arena);
}
bool err = ((*r_extent_hooks)->commit == NULL ||
(*r_extent_hooks)->commit(*r_extent_hooks, extent_base_get(extent),
extent_size_get(extent), offset, length, arena_ind_get(arena)));
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_post_reentrancy(tsdn);
}
extent_committed_set(extent, extent_committed_get(extent) || !err);
return err;
}
@ -1633,10 +1665,16 @@ extent_decommit_wrapper(tsdn_t *tsdn, arena_t *arena,
extent_hooks_assure_initialized(arena, r_extent_hooks);
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_pre_reentrancy(tsdn, arena);
}
bool err = ((*r_extent_hooks)->decommit == NULL ||
(*r_extent_hooks)->decommit(*r_extent_hooks,
extent_base_get(extent), extent_size_get(extent), offset, length,
arena_ind_get(arena)));
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_post_reentrancy(tsdn);
}
extent_committed_set(extent, extent_committed_get(extent) && err);
return err;
}
@ -1663,10 +1701,21 @@ extent_purge_lazy_impl(tsdn_t *tsdn, arena_t *arena,
WITNESS_RANK_CORE, growing_retained ? 1 : 0);
extent_hooks_assure_initialized(arena, r_extent_hooks);
return ((*r_extent_hooks)->purge_lazy == NULL ||
(*r_extent_hooks)->purge_lazy(*r_extent_hooks,
if ((*r_extent_hooks)->purge_lazy == NULL) {
return true;
}
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_pre_reentrancy(tsdn, arena);
}
bool err = (*r_extent_hooks)->purge_lazy(*r_extent_hooks,
extent_base_get(extent), extent_size_get(extent), offset, length,
arena_ind_get(arena)));
arena_ind_get(arena));
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_post_reentrancy(tsdn);
}
return err;
}
bool
@ -1699,10 +1748,20 @@ extent_purge_forced_impl(tsdn_t *tsdn, arena_t *arena,
WITNESS_RANK_CORE, growing_retained ? 1 : 0);
extent_hooks_assure_initialized(arena, r_extent_hooks);
return ((*r_extent_hooks)->purge_forced == NULL ||
(*r_extent_hooks)->purge_forced(*r_extent_hooks,
if ((*r_extent_hooks)->purge_forced == NULL) {
return true;
}
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_pre_reentrancy(tsdn, arena);
}
bool err = (*r_extent_hooks)->purge_forced(*r_extent_hooks,
extent_base_get(extent), extent_size_get(extent), offset, length,
arena_ind_get(arena)));
arena_ind_get(arena));
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_post_reentrancy(tsdn);
}
return err;
}
bool
@ -1771,9 +1830,16 @@ extent_split_impl(tsdn_t *tsdn, arena_t *arena,
extent_lock2(tsdn, extent, trail);
if ((*r_extent_hooks)->split(*r_extent_hooks, extent_base_get(extent),
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_pre_reentrancy(tsdn, arena);
}
bool err = (*r_extent_hooks)->split(*r_extent_hooks, extent_base_get(extent),
size_a + size_b, size_a, size_b, extent_committed_get(extent),
arena_ind_get(arena))) {
arena_ind_get(arena));
if (*r_extent_hooks != &extent_hooks_default) {
extent_hook_post_reentrancy(tsdn);
}
if (err) {
goto label_error_c;
}
@ -1843,10 +1909,12 @@ extent_merge_impl(tsdn_t *tsdn, arena_t *arena,
err = extent_merge_default_impl(extent_base_get(a),
extent_base_get(b));
} else {
extent_hook_pre_reentrancy(tsdn, arena);
err = (*r_extent_hooks)->merge(*r_extent_hooks,
extent_base_get(a), extent_size_get(a), extent_base_get(b),
extent_size_get(b), extent_committed_get(a),
arena_ind_get(arena));
extent_hook_post_reentrancy(tsdn);
}
if (err) {

View File

@ -1480,7 +1480,7 @@ malloc_init_hard(void) {
malloc_mutex_lock(tsd_tsdn(tsd), &init_lock);
/* Set reentrancy level to 1 during init. */
pre_reentrancy(tsd);
pre_reentrancy(tsd, NULL);
/* Initialize narenas before prof_boot2 (for allocation). */
if (malloc_init_narenas() || background_thread_boot1(tsd_tsdn(tsd))) {
UNLOCK_RETURN(tsd_tsdn(tsd), true, true)
@ -1803,7 +1803,7 @@ imalloc_body(static_opts_t *sopts, dynamic_opts_t *dopts, tsd_t *tsd) {
*/
assert(dopts->tcache_ind == TCACHE_IND_AUTOMATIC ||
dopts->tcache_ind == TCACHE_IND_NONE);
assert(dopts->arena_ind = ARENA_IND_AUTOMATIC);
assert(dopts->arena_ind == ARENA_IND_AUTOMATIC);
dopts->tcache_ind = TCACHE_IND_NONE;
/* We know that arena 0 has already been initialized. */
dopts->arena_ind = 0;
@ -2268,7 +2268,15 @@ JEMALLOC_EXPORT void JEMALLOC_NOTHROW
je_free(void *ptr) {
UTRACE(ptr, 0, 0);
if (likely(ptr != NULL)) {
tsd_t *tsd = tsd_fetch();
/*
* We avoid setting up tsd fully (e.g. tcache, arena binding)
* based on only free() calls -- other activities trigger the
* minimal to full transition. This is because free() may
* happen during thread shutdown after tls deallocation: if a
* thread never had any malloc activities until then, a
* fully-setup tsd won't be destructed properly.
*/
tsd_t *tsd = tsd_fetch_min();
check_entry_exit_locking(tsd_tsdn(tsd));
tcache_t *tcache;
@ -2914,16 +2922,15 @@ je_mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp,
JEMALLOC_EXPORT int JEMALLOC_NOTHROW
je_mallctlnametomib(const char *name, size_t *mibp, size_t *miblenp) {
int ret;
tsdn_t *tsdn;
if (unlikely(malloc_init())) {
return EAGAIN;
}
tsdn = tsdn_fetch();
check_entry_exit_locking(tsdn);
ret = ctl_nametomib(tsdn, name, mibp, miblenp);
check_entry_exit_locking(tsdn);
tsd_t *tsd = tsd_fetch();
check_entry_exit_locking(tsd_tsdn(tsd));
ret = ctl_nametomib(tsd, name, mibp, miblenp);
check_entry_exit_locking(tsd_tsdn(tsd));
return ret;
}
@ -3143,7 +3150,7 @@ _malloc_prefork(void)
background_thread_prefork1(tsd_tsdn(tsd));
}
/* Break arena prefork into stages to preserve lock order. */
for (i = 0; i < 7; i++) {
for (i = 0; i < 8; i++) {
for (j = 0; j < narenas; j++) {
if ((arena = arena_get(tsd_tsdn(tsd), j, false)) !=
NULL) {
@ -3169,6 +3176,9 @@ _malloc_prefork(void)
case 6:
arena_prefork6(tsd_tsdn(tsd), arena);
break;
case 7:
arena_prefork7(tsd_tsdn(tsd), arena);
break;
default: not_reached();
}
}

View File

@ -1633,7 +1633,7 @@ prof_dump(tsd_t *tsd, bool propagate_err, const char *filename,
return true;
}
pre_reentrancy(tsd);
pre_reentrancy(tsd, NULL);
malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_mtx);
prof_gctx_tree_t gctxs;

View File

@ -474,8 +474,7 @@ tcache_flush_cache(tsd_t *tsd, tcache_t *tcache) {
}
void
tcache_flush(void) {
tsd_t *tsd = tsd_fetch();
tcache_flush(tsd_t *tsd) {
assert(tcache_available(tsd));
tcache_flush_cache(tsd, tsd_tcachep_get(tsd));
}

View File

@ -87,7 +87,8 @@ assert_tsd_data_cleanup_done(tsd_t *tsd) {
static bool
tsd_data_init_nocleanup(tsd_t *tsd) {
assert(tsd->state == tsd_state_reincarnated);
assert(tsd->state == tsd_state_reincarnated ||
tsd->state == tsd_state_minimal_initialized);
/*
* During reincarnation, there is no guarantee that the cleanup function
* will be called (deallocation may happen after all tsd destructors).
@ -103,15 +104,8 @@ tsd_data_init_nocleanup(tsd_t *tsd) {
}
tsd_t *
tsd_fetch_slow(tsd_t *tsd, bool internal) {
if (internal) {
/* For internal background threads use only. */
assert(tsd->state == tsd_state_uninitialized);
tsd->state = tsd_state_reincarnated;
tsd_set(tsd);
tsd_data_init_nocleanup(tsd);
return tsd;
}
tsd_fetch_slow(tsd_t *tsd, bool minimal) {
assert(!tsd_fast(tsd));
if (tsd->state == tsd_state_nominal_slow) {
/* On slow path but no work needed. */
@ -119,11 +113,28 @@ tsd_fetch_slow(tsd_t *tsd, bool internal) {
tsd_reentrancy_level_get(tsd) > 0 ||
*tsd_arenas_tdata_bypassp_get(tsd));
} else if (tsd->state == tsd_state_uninitialized) {
tsd->state = tsd_state_nominal;
tsd_slow_update(tsd);
/* Trigger cleanup handler registration. */
tsd_set(tsd);
tsd_data_init(tsd);
if (!minimal) {
tsd->state = tsd_state_nominal;
tsd_slow_update(tsd);
/* Trigger cleanup handler registration. */
tsd_set(tsd);
tsd_data_init(tsd);
} else {
tsd->state = tsd_state_minimal_initialized;
tsd_set(tsd);
tsd_data_init_nocleanup(tsd);
}
} else if (tsd->state == tsd_state_minimal_initialized) {
if (!minimal) {
/* Switch to fully initialized. */
tsd->state = tsd_state_nominal;
assert(*tsd_reentrancy_levelp_get(tsd) >= 1);
(*tsd_reentrancy_levelp_get(tsd))--;
tsd_slow_update(tsd);
tsd_data_init(tsd);
} else {
assert_tsd_data_cleanup_done(tsd);
}
} else if (tsd->state == tsd_state_purgatory) {
tsd->state = tsd_state_reincarnated;
tsd_set(tsd);
@ -197,6 +208,9 @@ tsd_cleanup(void *arg) {
case tsd_state_uninitialized:
/* Do nothing. */
break;
case tsd_state_minimal_initialized:
/* This implies the thread only did free() in its life time. */
/* Fall through. */
case tsd_state_reincarnated:
/*
* Reincarnated means another destructor deallocated memory

View File

@ -1,3 +1,5 @@
Jul 09, 2017: libarchive 3.3.2 released
Mar 16, 2017: NFSv4 ACL support for Linux (librichacl)
Feb 26, 2017: libarchive 3.3.1 released

View File

@ -36,7 +36,7 @@
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
*/
/* Note: Compiler will complain if this does not match archive_entry.h! */
#define ARCHIVE_VERSION_NUMBER 3003001
#define ARCHIVE_VERSION_NUMBER 3003002
#include <sys/stat.h>
#include <stddef.h> /* for wchar_t */
@ -155,7 +155,7 @@ __LA_DECL int archive_version_number(void);
/*
* Textual name/version of the library, useful for version displays.
*/
#define ARCHIVE_VERSION_ONLY_STRING "3.3.1"
#define ARCHIVE_VERSION_ONLY_STRING "3.3.2"
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char * archive_version_string(void);

View File

@ -30,7 +30,7 @@
#define ARCHIVE_ENTRY_H_INCLUDED
/* Note: Compiler will complain if this does not match archive.h! */
#define ARCHIVE_VERSION_NUMBER 3003001
#define ARCHIVE_VERSION_NUMBER 3003002
/*
* Note: archive_entry.h is for use outside of libarchive; the

View File

@ -28,10 +28,12 @@ __FBSDID("$FreeBSD$");
DEFINE_TEST(test_archive_read_close_twice_open_filename)
{
const char *filename = "empty.file";
struct archive* a = archive_read_new();
assertMakeFile(filename, 0644, "");
assertEqualInt(ARCHIVE_OK, archive_read_support_format_empty(a));
assertEqualInt(ARCHIVE_OK, archive_read_open_filename(a, 0, 0));
assertEqualInt(ARCHIVE_OK, archive_read_open_filename(a, filename, 0));
assertEqualInt(0, archive_errno(a));
assertEqualString(NULL, archive_error_string(a));

View File

@ -61,7 +61,12 @@
#include <sys/types.h>
#include <sys/time.h>
#define SOLARIS (defined(sun) && (defined(__SVR4) || defined(__svr4__)))
#if (defined(sun) && (defined(__SVR4) || defined(__svr4__)))
#define SOLARIS 1
#else
#define SOLARIS 0
#endif
#if defined(__hpux) || SOLARIS
# include <sys/sysmacros.h>
# include <sys/stream.h>

View File

@ -46,6 +46,7 @@ LINE("libdevctl", "Device Control Library (libdevctl, \\-ldevctl)")
LINE("libdevinfo", "Device and Resource Information Utility Library (libdevinfo, \\-ldevinfo)")
LINE("libdevstat", "Device Statistics Library (libdevstat, \\-ldevstat)")
LINE("libdisk", "Interface to Slice and Partition Labels Library (libdisk, \\-ldisk)")
LINE("libdl", "Dynamic Linker Services Filter (libdl, \\-ldl)")
LINE("libdm", "Device Mapper Library (libdm, \\-ldm)")
LINE("libdwarf", "DWARF Access Library (libdwarf, \\-ldwarf)")
LINE("libedit", "Command Line Editor Library (libedit, \\-ledit)")

View File

@ -34,11 +34,13 @@ __RCSID("$NetBSD: t_setdomainname.c,v 1.2 2012/03/25 08:17:54 joerg Exp $");
#include <sys/param.h>
#include <atf-c.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
static char domain[MAXHOSTNAMELEN];
#define DOMAIN_BACKUP_FILE "domain.bak"
static const char domains[][MAXHOSTNAMELEN] = {
"1234567890",
@ -47,6 +49,45 @@ static const char domains[][MAXHOSTNAMELEN] = {
"--------------------------------------------------------------------"
};
static void
backup_domain(void)
{
char domain[MAXHOSTNAMELEN];
int fd;
size_t l;
ssize_t r,n = 0;
memset(domain, 0, sizeof(domain));
ATF_REQUIRE_EQ(0, getdomainname(domain, sizeof(domain)));
l = strnlen(domain, MAXHOSTNAMELEN);
fd = open(DOMAIN_BACKUP_FILE, O_WRONLY | O_CREAT | O_EXCL, 0644);
ATF_REQUIRE(fd >= 0);
while ((r = write(fd, domain + n, l - n)) > 0)
n += r;
ATF_REQUIRE_EQ(0, r);
close(fd);
}
static void
restore_domain(void)
{
char domain[MAXHOSTNAMELEN];
int fd;
ssize_t r, n = 0;
memset(domain, 0, sizeof(domain));
if ((fd = open(DOMAIN_BACKUP_FILE, O_RDONLY)) < 0)
err(1, "open");
while ((r = read(fd, domain + n, sizeof(domain) - n)) > 0)
n += r;
if (r < 0)
err(1, "read");
if (setdomainname(domain, n) != 0)
err(1, "setdomainname");
close(fd);
}
ATF_TC_WITH_CLEANUP(setdomainname_basic);
ATF_TC_HEAD(setdomainname_basic, tc)
{
@ -59,6 +100,7 @@ ATF_TC_BODY(setdomainname_basic, tc)
char name[MAXHOSTNAMELEN];
size_t i;
backup_domain();
for (i = 0; i < __arraycount(domains); i++) {
(void)memset(name, 0, sizeof(name));
@ -80,12 +122,11 @@ ATF_TC_BODY(setdomainname_basic, tc)
ATF_REQUIRE(strcmp(domains[i], name) == 0);
}
(void)setdomainname(domain, sizeof(domain));
}
ATF_TC_CLEANUP(setdomainname_basic, tc)
{
(void)setdomainname(domain, sizeof(domain));
restore_domain();
}
ATF_TC_WITH_CLEANUP(setdomainname_limit);
@ -100,6 +141,7 @@ ATF_TC_BODY(setdomainname_limit, tc)
char name[MAXHOSTNAMELEN + 1];
(void)memset(name, 0, sizeof(name));
backup_domain();
#ifdef __FreeBSD__
ATF_REQUIRE(setdomainname(name, MAXHOSTNAMELEN - 1 ) == 0);
@ -110,10 +152,10 @@ ATF_TC_BODY(setdomainname_limit, tc)
ATF_TC_CLEANUP(setdomainname_limit, tc)
{
(void)setdomainname(domain, sizeof(domain));
restore_domain();
}
ATF_TC_WITH_CLEANUP(setdomainname_perm);
ATF_TC(setdomainname_perm);
ATF_TC_HEAD(setdomainname_perm, tc)
{
atf_tc_set_md_var(tc, "descr", "Can normal user set the domain name?");
@ -122,24 +164,16 @@ ATF_TC_HEAD(setdomainname_perm, tc)
ATF_TC_BODY(setdomainname_perm, tc)
{
char domain[MAXHOSTNAMELEN];
memset(domain, 0, sizeof(domain));
errno = 0;
ATF_REQUIRE_ERRNO(EPERM, setdomainname(domain, sizeof(domain)) == -1);
}
ATF_TC_CLEANUP(setdomainname_perm, tc)
{
(void)setdomainname(domain, sizeof(domain));
}
ATF_TP_ADD_TCS(tp)
{
(void)memset(domain, 0, sizeof(domain));
ATF_REQUIRE(getdomainname(domain, sizeof(domain)) == 0);
ATF_TP_ADD_TC(tp, setdomainname_basic);
ATF_TP_ADD_TC(tp, setdomainname_limit);
ATF_TP_ADD_TC(tp, setdomainname_perm);

View File

@ -127,6 +127,10 @@ ATF_TC_HEAD(snprintf_float, tc)
atf_tc_set_md_var(tc, "descr", "test that floating conversions don't"
" leak memory");
#ifdef __FreeBSD__
atf_tc_set_md_var(tc, "require.memory", "64m");
atf_tc_set_md_var(tc, "require.user", "root");
#endif
}
ATF_TC_BODY(snprintf_float, tc)
@ -140,10 +144,17 @@ ATF_TC_BODY(snprintf_float, tc)
char buf[1000];
struct rlimit rl;
#ifdef __FreeBSD__
rl.rlim_cur = rl.rlim_max = 32 * 1024 * 1024;
ATF_CHECK(setrlimit(RLIMIT_AS, &rl) != -1);
rl.rlim_cur = rl.rlim_max = 32 * 1024 * 1024;
ATF_CHECK(setrlimit(RLIMIT_DATA, &rl) != -1);
#else
rl.rlim_cur = rl.rlim_max = 1 * 1024 * 1024;
ATF_CHECK(setrlimit(RLIMIT_AS, &rl) != -1);
rl.rlim_cur = rl.rlim_max = 1 * 1024 * 1024;
ATF_CHECK(setrlimit(RLIMIT_DATA, &rl) != -1);
#endif
time(&now);
srand(now);

View File

@ -713,8 +713,8 @@ _krb5_extract_ticket(krb5_context context,
/* check server referral and save principal */
ret = _krb5_principalname2krb5_principal (context,
&tmp_principal,
rep->kdc_rep.ticket.sname,
rep->kdc_rep.ticket.realm);
rep->enc_part.sname,
rep->enc_part.srealm);
if (ret)
goto out;
if((flags & EXTRACT_TICKET_ALLOW_SERVER_MISMATCH) == 0){

View File

@ -342,19 +342,6 @@ distribution:
MTREE_CMD?= mtree
.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
.else
MTREE_FILTER= cat
.if !defined(NO_FSCHG)
MTREE_FSCHG= -i
.endif
.endif
MTREES= mtree/BSD.root.dist / \
mtree/BSD.var.dist /var \
mtree/BSD.usr.dist /usr \
@ -467,3 +454,16 @@ etc-examples: etc-examples-install
DESTDIR=${DESTDIR}${SHAREDIR}/examples
.include <bsd.prog.mk>
.if ${MK_INSTALL_AS_USER} == "yes" && ${_uid} != 0
MTREE_FILTER= sed -e 's,\([gu]\)name=,\1id=,g' \
-e 's,\(uid=\)[^ ]* ,\1${_uid} ,' \
-e 's,\(gid=\)[^ ]* ,\1${_gid} ,' \
-e 's,\(uid=\)[^ ]*$$,\1${_uid},' \
-e 's,\(gid=\)[^ ]*$$,\1${_gid},'
.else
MTREE_FILTER= cat
.if !defined(NO_FSCHG)
MTREE_FSCHG= -i
.endif
.endif

View File

@ -92,7 +92,7 @@ geli_autodetach="YES" # Automatically detach on last close.
root_rw_mount="YES" # Set to NO to inhibit remounting root read-write.
root_hold_delay="30" # Time to wait for root mount hold release.
fsck_y_enable="NO" # Set to YES to do fsck -y if the initial preen fails.
fsck_y_flags="" # Additional flags for fsck -y
fsck_y_flags="-T ffs:-R -T ufs:-R" # Additional flags for fsck -y
background_fsck="YES" # Attempt to run fsck in the background where possible.
background_fsck_delay="60" # Time to wait (seconds) before starting the fsck.
netfs_types="nfs:NFS smbfs:SMB" # Net filesystems.

View File

@ -90,6 +90,8 @@
cam
ata
..
mmc
..
nvme
..
scsi
@ -234,7 +236,7 @@
gssapi
..
infiniband
complib
complib
..
iba
..

View File

@ -400,6 +400,8 @@
..
..
..
zoneinfo
..
..
sys
acl
@ -642,6 +644,8 @@
..
gzip
..
hexdump
..
ident
..
indent

View File

@ -5,7 +5,7 @@
# PROVIDE: bsnmpd
# REQUIRE: NETWORKING syslogd
# KEYWORD: nojail shutdown
# KEYWORD: nojailvnet shutdown
. /etc/rc.subr

View File

@ -7,7 +7,7 @@
# PROVIDE: defaultroute
# REQUIRE: devd netif stf
# KEYWORD: nojail
# KEYWORD: nojailvnet
. /etc/rc.subr
. /etc/network.subr

View File

@ -4,7 +4,7 @@
#
# PROVIDE: dhclient
# KEYWORD: nojail nostart
# KEYWORD: nojailvnet nostart
. /etc/rc.subr
. /etc/network.subr

View File

@ -6,7 +6,7 @@
# PROVIDE: ip6addrctl
# REQUIRE: FILESYSTEMS
# BEFORE: netif
# KEYWORD: nojail
# KEYWORD: nojailvnet
. /etc/rc.subr
. /etc/network.subr

View File

@ -17,7 +17,9 @@ start_cmd="ipfw_start"
start_precmd="ipfw_prestart"
start_postcmd="ipfw_poststart"
stop_cmd="ipfw_stop"
status_cmd="ipfw_status"
required_modules="ipfw"
extra_commands="status"
set_rcvar_obsolete ipv6_firewall_enable
@ -109,6 +111,18 @@ ipfw_stop()
done
}
ipfw_status()
{
status=$(sysctl -n net.inet.ip.fw.enable)
if [ ${status} -eq 0 ]; then
echo "ipfw is not enabled"
exit 1
else
echo "ipfw is enabled"
exit 0
fi
}
load_rc_config $name
firewall_coscripts="/etc/rc.d/natd ${firewall_coscripts}"

77
etc/rc.d/ipfw_netflow Executable file
View File

@ -0,0 +1,77 @@
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: ipfw_netflow
# REQUIRE: ipfw
# KEYWORD: nojailvnet
. /etc/rc.subr
. /etc/network.subr
name="ipfw_netflow"
desc="firewall, ipfw, netflow"
rcvar="${name}_enable"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
start_precmd="${name}_test"
status_cmd="${name}_status"
required_modules="ipfw ng_netflow ng_ipfw"
extra_commands="status"
: ${ipfw_netflow_hook:=9995}
: ${ipfw_netflow_rule:=01000}
: ${ipfw_netflow_ip:=127.0.0.1}
: ${ipfw_netflow_port:=9995}
: ${ipfw_netflow_version:=}
ipfw_netflow_test()
{
if [ "${ipfw_netflow_version}" != "" ] && [ "${ipfw_netflow_version}" != 9 ]; then
err 1 "Unknown netflow version \'${ipfw_netflow_version}\'"
fi
case "${ipfw_netflow_hook}" in
[!0-9]*)
err 1 "Bad value \"${ipfw_netflow_hook}\": Hook must be numerical"
esac
case "${ipfw_netflow_rule}" in
[!0-9]*)
err 1 "Bad value \"${ipfw_netflow_rule}\": Rule number must be numerical"
esac
}
ipfw_netflow_is_running()
{
ngctl show netflow: > /dev/null 2>&1 && return 0 || return 1
}
ipfw_netflow_status()
{
ipfw_netflow_is_running && echo "ipfw_netflow is active" || echo "ipfw_netflow is not active"
}
ipfw_netflow_start()
{
ipfw_netflow_is_running && err 1 "ipfw_netflow is already active"
ipfw add ${ipfw_netflow_rule} ngtee ${ipfw_netflow_hook} ip from any to any
ngctl -f - <<-EOF
mkpeer ipfw: netflow ${ipfw_netflow_hook} iface0
name ipfw:${ipfw_netflow_hook} netflow
mkpeer netflow: ksocket export${ipfw_netflow_version} inet/dgram/udp
msg netflow: setdlt {iface=0 dlt=12}
name netflow:export${ipfw_netflow_version} netflow_export
msg netflow:export${ipfw_netflow_version} connect inet/${ipfw_netflow_ip}:${ipfw_netflow_port}
EOF
}
ipfw_netflow_stop()
{
ipfw_netflow_is_running || err 1 "ipfw_netflow is not active"
ngctl shutdown netflow:
ipfw delete ${ipfw_netflow_rule}
}
load_rc_config $name
run_rc_command $*

View File

@ -6,7 +6,7 @@
# PROVIDE: ipsec
# REQUIRE: FILESYSTEMS
# BEFORE: DAEMON mountcritremote
# KEYWORD: nojail
# KEYWORD: nojailvnet
. /etc/rc.subr

View File

@ -4,7 +4,7 @@
#
# PROVIDE: natd
# KEYWORD: nostart nojail
# KEYWORD: nostart nojailvnet
. /etc/rc.subr
. /etc/network.subr

View File

@ -6,7 +6,7 @@
# PROVIDE: pf
# REQUIRE: FILESYSTEMS netif pflog pfsync
# BEFORE: routing
# KEYWORD: nojail
# KEYWORD: nojailvnet
. /etc/rc.subr

View File

@ -5,7 +5,7 @@
# PROVIDE: pflog
# REQUIRE: FILESYSTEMS netif
# KEYWORD: nojail
# KEYWORD: nojailvnet
. /etc/rc.subr

View File

@ -5,7 +5,7 @@
# PROVIDE: pfsync
# REQUIRE: FILESYSTEMS netif
# KEYWORD: nojail
# KEYWORD: nojailvnet
. /etc/rc.subr
@ -15,7 +15,7 @@ rcvar="pfsync_enable"
start_precmd="pfsync_prestart"
start_cmd="pfsync_start"
stop_cmd="pfsync_stop"
required_modules="pf"
required_modules="pf pfsync"
pfsync_prestart()
{
@ -36,7 +36,6 @@ pfsync_start()
if [ -n "${pfsync_syncpeer}" ]; then
_syncpeer="syncpeer ${pfsync_syncpeer}"
fi
load_kld pfsync
ifconfig pfsync0 $_syncpeer syncdev $pfsync_syncdev $pfsync_ifconfig up
}

View File

@ -6,7 +6,7 @@
# PROVIDE: rarpd
# REQUIRE: DAEMON FILESYSTEMS
# BEFORE: LOGIN
# KEYWORD: nojail
# KEYWORD: nojailvnet
. /etc/rc.subr

View File

@ -5,7 +5,7 @@
# PROVIDE: route6d
# REQUIRE: netif routing
# KEYWORD: nojail
# KEYWORD: nojailvnet
. /etc/rc.subr

View File

@ -6,7 +6,7 @@
# PROVIDE: routed
# REQUIRE: netif routing
# BEFORE: NETWORK
# KEYWORD: nojail
# KEYWORD: nojailvnet
. /etc/rc.subr

View File

@ -6,7 +6,7 @@
# PROVIDE: rtadvd
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: nojail shutdown
# KEYWORD: nojailvnet shutdown
. /etc/rc.subr
. /etc/network.subr

View File

@ -6,7 +6,7 @@
# PROVIDE: rtsold
# REQUIRE: netif
# BEFORE: NETWORKING
# KEYWORD: nojail shutdown
# KEYWORD: nojailvnet shutdown
. /etc/rc.subr

View File

@ -31,7 +31,7 @@
# PROVIDE: static_arp
# REQUIRE: netif
# KEYWORD: nojail
# KEYWORD: nojailvnet
. /etc/rc.subr
. /etc/network.subr

View File

@ -31,7 +31,7 @@
# PROVIDE: static_ndp
# REQUIRE: netif
# KEYWORD: nojail
# KEYWORD: nojailvnet
. /etc/rc.subr
. /etc/network.subr

View File

@ -2,8 +2,11 @@
#
# .login - csh login script, read by login shell, after `.cshrc' at login.
#
# see also csh(1), environ(7).
# See also csh(1), environ(7).
#
# Uncomment to display a random cookie each login:
# Query terminal size; useful for serial lines.
if ( -x /usr/bin/resizewin ) /usr/bin/resizewin -z
# Uncomment to display a random cookie on each login.
# if ( -x /usr/bin/fortune ) /usr/bin/fortune -s

View File

@ -8,3 +8,9 @@ TERM=${TERM:-xterm}
export TERM
PAGER=more
export PAGER
# Query terminal size; useful for serial lines.
if [ -x /usr/bin/resizewin ] ; then /usr/bin/resizewin -z ; fi
# Uncomment to display a random cookie on each login.
# if [ -x /usr/bin/fortune ] ; then /usr/bin/fortune -s ; fi

View File

@ -44,6 +44,11 @@ gdb \- The GNU Debugger
.IR core \||\| procID\c
\&\|]\&\|]
.ad b
.SH DEPRECATION NOTICE
This version of gdb is deprecated and will be removed from future versions
of the FreeBSD base system.
A newer version of gdb is available from ports or packages
(devel/gdb).
.SH DESCRIPTION
The purpose of a debugger such as GDB is to allow you to see what is
going on ``inside'' another program while it executes\(em\&or what another

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd October 11, 2006
.Dd July 5, 2017
.Dt KGDB 1
.Os
.Sh NAME
@ -40,6 +40,16 @@
.Op Fl d Ar crashdir
.Op Fl c Ar core | Fl n Ar dumpnr | Fl r Ar device
.Op Ar kernel Op Ar core
.Sh DEPRECATION NOTICE
This version of
.Nm
is deprecated and will be removed from future versions of the
.Fx
base system.
A newer version of
.Nm
is available from ports or packages
(devel/gdb).
.Sh DESCRIPTION
The
.Nm

View File

@ -42,7 +42,7 @@ LHDRS= aio.h errno.h fcntl.h linker_set.h poll.h stdatomic.h stdint.h \
LDIRS= bsm cam geom net net80211 netgraph netinet netinet6 \
netipsec netsmb nfs nfsclient nfsserver sys vm
LSUBDIRS= cam/ata cam/nvme cam/scsi \
LSUBDIRS= cam/ata cam/mmc cam/nvme cam/scsi \
dev/acpica dev/agp dev/an dev/bktr dev/ciss dev/filemon dev/firewire \
dev/hwpmc dev/hyperv \
dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/mmc dev/nvme \

View File

@ -40,6 +40,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \
libdevctl \
libdevinfo \
libdevstat \
${_libdl} \
libdwarf \
libedit \
libevent \
@ -183,6 +184,10 @@ _libproc= libproc
_librtld_db= librtld_db
.endif
.if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mfilter}
_libdl= libdl
.endif
SUBDIR.${MK_OPENSSL}+= libmp
SUBDIR.${MK_PMC}+= libpmc
SUBDIR.${MK_RADIUS_SUPPORT}+= libradius

View File

@ -0,0 +1,14 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
include \
include/xlocale \
lib/msun \
.include <dirdeps.mk>
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
# local dependencies - needed for -jN in clean tree
.endif

View File

@ -27,6 +27,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#if !defined(IN_LIBDL) || defined(PIC)
/*
* Linkage to services provided by the dynamic linker.
*/
@ -57,95 +59,107 @@ void _rtld_atfork_post(int *);
#pragma weak _rtld_error
void
_rtld_error(const char *fmt, ...)
_rtld_error(const char *fmt __unused, ...)
{
}
#pragma weak dladdr
int
dladdr(const void *addr, Dl_info *dlip)
dladdr(const void *addr __unused, Dl_info *dlip __unused)
{
_rtld_error(sorry);
return 0;
return (0);
}
#pragma weak dlclose
int
dlclose(void *handle)
dlclose(void *handle __unused)
{
_rtld_error(sorry);
return -1;
return (-1);
}
#pragma weak dlerror
char *
dlerror(void)
{
return sorry;
return (sorry);
}
#pragma weak dllockinit
void
dllockinit(void *context,
void *(*lock_create)(void *context),
void (*rlock_acquire)(void *lock),
void (*wlock_acquire)(void *lock),
void (*lock_release)(void *lock),
void (*lock_destroy)(void *lock),
void (*context_destroy)(void *context))
void *(*lock_create)(void *context) __unused,
void (*rlock_acquire)(void *lock) __unused,
void (*wlock_acquire)(void *lock) __unused,
void (*lock_release)(void *lock) __unused,
void (*lock_destroy)(void *lock) __unused,
void (*context_destroy)(void *context) __unused)
{
if (context_destroy != NULL)
context_destroy(context);
}
#pragma weak dlopen
void *
dlopen(const char *name, int mode)
dlopen(const char *name __unused, int mode __unused)
{
_rtld_error(sorry);
return NULL;
return (NULL);
}
#pragma weak dlsym
void *
dlsym(void * __restrict handle, const char * __restrict name)
dlsym(void * __restrict handle __unused, const char * __restrict name __unused)
{
_rtld_error(sorry);
return NULL;
return (NULL);
}
#pragma weak dlfunc
dlfunc_t
dlfunc(void * __restrict handle, const char * __restrict name)
dlfunc(void * __restrict handle __unused, const char * __restrict name __unused)
{
_rtld_error(sorry);
return NULL;
return (NULL);
}
#pragma weak dlvsym
void *
dlvsym(void * __restrict handle, const char * __restrict name,
const char * __restrict version)
dlvsym(void * __restrict handle __unused, const char * __restrict name __unused,
const char * __restrict version __unused)
{
_rtld_error(sorry);
return NULL;
return (NULL);
}
#pragma weak dlinfo
int
dlinfo(void * __restrict handle, int request, void * __restrict p)
dlinfo(void * __restrict handle __unused, int request __unused,
void * __restrict p __unused)
{
_rtld_error(sorry);
return 0;
return (0);
}
#pragma weak _rtld_thread_init
void
_rtld_thread_init(void * li)
_rtld_thread_init(void *li __unused)
{
_rtld_error(sorry);
}
#ifndef IN_LIBDL
static pthread_once_t dl_phdr_info_once = PTHREAD_ONCE_INIT;
static struct dl_phdr_info phdr_info;
@ -181,44 +195,50 @@ dl_init_phdr_info(void)
}
phdr_info.dlpi_adds = 1;
}
#endif
#pragma weak dl_iterate_phdr
int
dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *),
void *data)
dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *) __unused,
void *data __unused)
{
#ifndef IN_LIBDL
__init_elf_aux_vector();
if (__elf_aux_vector == NULL)
return (1);
_once(&dl_phdr_info_once, dl_init_phdr_info);
return (callback(&phdr_info, sizeof(phdr_info), data));
#else
return (0);
#endif
}
#pragma weak fdlopen
void *
fdlopen(int fd, int mode)
fdlopen(int fd __unused, int mode __unused)
{
_rtld_error(sorry);
return NULL;
return (NULL);
}
#pragma weak _rtld_atfork_pre
void
_rtld_atfork_pre(int *locks)
_rtld_atfork_pre(int *locks __unused)
{
}
#pragma weak _rtld_atfork_post
void
_rtld_atfork_post(int *locks)
_rtld_atfork_post(int *locks __unused)
{
}
#pragma weak _rtld_addr_phdr
int
_rtld_addr_phdr(const void *addr, struct dl_phdr_info *phdr_info)
_rtld_addr_phdr(const void *addr __unused,
struct dl_phdr_info *phdr_info_a __unused)
{
return (0);
@ -234,8 +254,10 @@ _rtld_get_stack_prot(void)
#pragma weak _rtld_is_dlopened
int
_rtld_is_dlopened(void *arg)
_rtld_is_dlopened(void *arg __unused)
{
return (0);
}
#endif /* !defined(IN_LIBDL) || defined(PIC) */

View File

@ -32,7 +32,7 @@
.\" @(#) dlopen.3 1.6 90/01/31 SMI
.\" $FreeBSD$
.\"
.Dd February 14, 2015
.Dd July 7, 2017
.Dt DLOPEN 3
.Os
.Sh NAME
@ -377,6 +377,14 @@ option to
for symbols defined in the executable to become visible to
.Fn dlsym .
.Pp
Other ELF platforms require linking with
.Lb libdl
to provide
.Fn dlopen
and other functions.
.Fx
does not require linking with the library, but supports it for compatibility.
.Pp
In previous implementations, it was necessary to prepend an underscore
to all external symbols in order to gain symbol
compatibility with object code compiled from the C language.

View File

@ -525,7 +525,7 @@ nss_load_module(const char *source, nss_module_register_fn reg_fn)
vector_sort(_nsmod, _nsmodsize, sizeof(*_nsmod), string_compare);
}
static int exiting = 0;
static void
ns_mod_free(ns_mod *mod)
@ -536,12 +536,10 @@ ns_mod_free(ns_mod *mod)
return;
if (mod->unregister != NULL)
mod->unregister(mod->mtab, mod->mtabsize);
if (mod->handle != nss_builtin_handle)
if (mod->handle != nss_builtin_handle && !exiting)
(void)dlclose(mod->handle);
}
/*
* Cleanup
*/
@ -550,6 +548,7 @@ nss_atexit(void)
{
int isthreaded;
exiting = 1;
isthreaded = __isthreaded;
if (isthreaded)
(void)_pthread_rwlock_wrlock(&nss_lock);
@ -561,8 +560,6 @@ nss_atexit(void)
(void)_pthread_rwlock_unlock(&nss_lock);
}
/*
* Finally, the actual implementation.
*/

View File

@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <limits.h>
#include <stdlib.h>
#include <regex.h>
#include <stdbool.h>
#include <wchar.h>
#include <wctype.h>
@ -61,6 +62,24 @@ __FBSDID("$FreeBSD$");
#include "cname.h"
/*
* Branching context, used to keep track of branch state for all of the branch-
* aware functions. In addition to keeping track of branch positions for the
* p_branch_* functions, we use this to simplify some clumsiness in BREs for
* detection of whether ^ is acting as an anchor or being used erroneously and
* also for whether we're in a sub-expression or not.
*/
struct branchc {
sopno start;
sopno back;
sopno fwd;
int nbranch;
int nchain;
bool outer;
bool terminate;
};
/*
* parse structure, passed up and down to avoid global variables and
* other clumsinesses
@ -77,6 +96,11 @@ struct parse {
# define NPAREN 10 /* we need to remember () 1-9 for back refs */
sopno pbegin[NPAREN]; /* -> ( ([0] unused) */
sopno pend[NPAREN]; /* -> ) ([0] unused) */
bool allowbranch; /* can this expression branch? */
bool bre; /* convenience; is this a BRE? */
bool (*parse_expr)(struct parse *, struct branchc *);
void (*pre_parse)(struct parse *, struct branchc *);
void (*post_parse)(struct parse *, struct branchc *);
};
/* ========= begin header generated by ./mkh ========= */
@ -85,11 +109,17 @@ extern "C" {
#endif
/* === regcomp.c === */
static void p_ere(struct parse *p, int stop);
static void p_ere_exp(struct parse *p);
static bool p_ere_exp(struct parse *p, struct branchc *bc);
static void p_str(struct parse *p);
static void p_bre(struct parse *p, int end1, int end2);
static int p_simp_re(struct parse *p, int starordinary);
static int p_branch_eat_delim(struct parse *p, struct branchc *bc);
static void p_branch_ins_offset(struct parse *p, struct branchc *bc);
static void p_branch_fix_tail(struct parse *p, struct branchc *bc);
static bool p_branch_empty(struct parse *p, struct branchc *bc);
static bool p_branch_do(struct parse *p, struct branchc *bc);
static void p_bre_pre_parse(struct parse *p, struct branchc *bc);
static void p_bre_post_parse(struct parse *p, struct branchc *bc);
static void p_re(struct parse *p, int end1, int end2);
static bool p_simp_re(struct parse *p, struct branchc *bc);
static int p_count(struct parse *p);
static void p_bracket(struct parse *p);
static void p_b_term(struct parse *p, cset *cs);
@ -139,6 +169,7 @@ static char nuls[10]; /* place to point scanner in event of error */
#define MORE2() (p->next+1 < p->end)
#define SEE(c) (MORE() && PEEK() == (c))
#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b))
#define SEESPEC(a) (p->bre ? SEETWO('\\', a) : SEE(a))
#define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0)
#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0)
#define NEXT() (p->next++)
@ -247,6 +278,19 @@ regcomp(regex_t * __restrict preg,
p->pbegin[i] = 0;
p->pend[i] = 0;
}
if (cflags & REG_EXTENDED) {
p->allowbranch = true;
p->bre = false;
p->parse_expr = p_ere_exp;
p->pre_parse = NULL;
p->post_parse = NULL;
} else {
p->allowbranch = false;
p->bre = true;
p->parse_expr = p_simp_re;
p->pre_parse = p_bre_pre_parse;
p->post_parse = p_bre_post_parse;
}
g->sets = NULL;
g->ncsets = 0;
g->cflags = cflags;
@ -264,12 +308,10 @@ regcomp(regex_t * __restrict preg,
/* do it */
EMIT(OEND, 0);
g->firststate = THERE();
if (cflags&REG_EXTENDED)
p_ere(p, OUT);
else if (cflags&REG_NOSPEC)
if (cflags & REG_NOSPEC)
p_str(p);
else
p_bre(p, OUT, OUT);
p_re(p, OUT, OUT);
EMIT(OEND, 0);
g->laststate = THERE();
@ -305,56 +347,12 @@ regcomp(regex_t * __restrict preg,
}
/*
- p_ere - ERE parser top level, concatenation and alternation
== static void p_ere(struct parse *p, int_t stop);
- p_ere_exp - parse one subERE, an atom possibly followed by a repetition op,
- return whether we should terminate or not
== static bool p_ere_exp(struct parse *p);
*/
static void
p_ere(struct parse *p,
int stop) /* character this ERE should end at */
{
char c;
sopno prevback;
sopno prevfwd;
sopno conc;
int first = 1; /* is this the first alternative? */
for (;;) {
/* do a bunch of concatenated expressions */
conc = HERE();
while (MORE() && (c = PEEK()) != '|' && c != stop)
p_ere_exp(p);
(void)REQUIRE(HERE() != conc, REG_EMPTY); /* require nonempty */
if (!EAT('|'))
break; /* NOTE BREAK OUT */
if (first) {
INSERT(OCH_, conc); /* offset is wrong */
prevfwd = conc;
prevback = conc;
first = 0;
}
ASTERN(OOR1, prevback);
prevback = THERE();
AHEAD(prevfwd); /* fix previous offset */
prevfwd = HERE();
EMIT(OOR2, 0); /* offset is very wrong */
}
if (!first) { /* tail-end fixups */
AHEAD(prevfwd);
ASTERN(O_CH, prevback);
}
assert(!MORE() || SEE(stop));
}
/*
- p_ere_exp - parse one subERE, an atom possibly followed by a repetition op
== static void p_ere_exp(struct parse *p);
*/
static void
p_ere_exp(struct parse *p)
static bool
p_ere_exp(struct parse *p, struct branchc *bc)
{
char c;
wint_t wc;
@ -377,7 +375,7 @@ p_ere_exp(struct parse *p)
p->pbegin[subno] = HERE();
EMIT(OLPAREN, subno);
if (!SEE(')'))
p_ere(p, ')');
p_re(p, ')', IGN);
if (subno < NPAREN) {
p->pend[subno] = HERE();
assert(p->pend[subno] != 0);
@ -445,7 +443,7 @@ p_ere_exp(struct parse *p)
/* FALLTHROUGH */
default:
if (p->error != 0)
return;
return (false);
p->next--;
wc = WGETNEXT();
ordinary(p, wc);
@ -453,12 +451,12 @@ p_ere_exp(struct parse *p)
}
if (!MORE())
return;
return (false);
c = PEEK();
/* we call { a repetition if followed by a digit */
if (!( c == '*' || c == '+' || c == '?' ||
(c == '{' && MORE2() && isdigit((uch)PEEK2())) ))
return; /* no repetition, we're done */
return (false); /* no repetition, we're done */
NEXT();
(void)REQUIRE(!wascaret, REG_BADRPT);
@ -504,12 +502,13 @@ p_ere_exp(struct parse *p)
}
if (!MORE())
return;
return (false);
c = PEEK();
if (!( c == '*' || c == '+' || c == '?' ||
(c == '{' && MORE2() && isdigit((uch)PEEK2())) ) )
return;
return (false);
SETERROR(REG_BADRPT);
return (false);
}
/*
@ -525,9 +524,129 @@ p_str(struct parse *p)
}
/*
- p_bre - BRE parser top level, anchoring and concatenation
== static void p_bre(struct parse *p, int end1, \
== int end2);
* Eat consecutive branch delimiters for the kind of expression that we are
* parsing, return the number of delimiters that we ate.
*/
static int
p_branch_eat_delim(struct parse *p, struct branchc *bc)
{
int nskip;
nskip = 0;
while (EAT('|'))
++nskip;
return (nskip);
}
/*
* Insert necessary branch book-keeping operations. This emits a
* bogus 'next' offset, since we still have more to parse
*/
static void
p_branch_ins_offset(struct parse *p, struct branchc *bc)
{
if (bc->nbranch == 0) {
INSERT(OCH_, bc->start); /* offset is wrong */
bc->fwd = bc->start;
bc->back = bc->start;
}
ASTERN(OOR1, bc->back);
bc->back = THERE();
AHEAD(bc->fwd); /* fix previous offset */
bc->fwd = HERE();
EMIT(OOR2, 0); /* offset is very wrong */
++bc->nbranch;
}
/*
* Fix the offset of the tail branch, if we actually had any branches.
* This is to correct the bogus placeholder offset that we use.
*/
static void
p_branch_fix_tail(struct parse *p, struct branchc *bc)
{
/* Fix bogus offset at the tail if we actually have branches */
if (bc->nbranch > 0) {
AHEAD(bc->fwd);
ASTERN(O_CH, bc->back);
}
}
/*
* Signal to the parser that an empty branch has been encountered; this will,
* in the future, be used to allow for more permissive behavior with empty
* branches. The return value should indicate whether parsing may continue
* or not.
*/
static bool
p_branch_empty(struct parse *p, struct branchc *bc)
{
SETERROR(REG_EMPTY);
return (false);
}
/*
* Take care of any branching requirements. This includes inserting the
* appropriate branching instructions as well as eating all of the branch
* delimiters until we either run out of pattern or need to parse more pattern.
*/
static bool
p_branch_do(struct parse *p, struct branchc *bc)
{
int ate = 0;
ate = p_branch_eat_delim(p, bc);
if (ate == 0)
return (false);
else if ((ate > 1 || (bc->outer && !MORE())) && !p_branch_empty(p, bc))
/*
* Halt parsing only if we have an empty branch and p_branch_empty
* indicates that we must not continue. In the future, this will not
* necessarily be an error.
*/
return (false);
p_branch_ins_offset(p, bc);
return (true);
}
static void
p_bre_pre_parse(struct parse *p, struct branchc *bc)
{
(void) bc;
/*
* Does not move cleanly into expression parser because of
* ordinary interpration of * at the beginning position of
* an expression.
*/
if (EAT('^')) {
EMIT(OBOL, 0);
p->g->iflags |= USEBOL;
p->g->nbol++;
}
}
static void
p_bre_post_parse(struct parse *p, struct branchc *bc)
{
/* Expression is terminating due to EOL token */
if (bc->terminate) {
DROP(1);
EMIT(OEOL, 0);
p->g->iflags |= USEEOL;
p->g->neol++;
}
}
/*
- p_re - Top level parser, concatenation and BRE anchoring
== static void p_re(struct parse *p, int end1, int end2);
* Giving end1 as OUT essentially eliminates the end1/end2 check.
*
* This implementation is a bit of a kludge, in that a trailing $ is first
@ -535,40 +654,55 @@ p_str(struct parse *p)
* The amount of lookahead needed to avoid this kludge is excessive.
*/
static void
p_bre(struct parse *p,
int end1, /* first terminating character */
int end2) /* second terminating character */
p_re(struct parse *p,
int end1, /* first terminating character */
int end2) /* second terminating character; ignored for EREs */
{
sopno start = HERE();
int first = 1; /* first subexpression? */
int wasdollar = 0;
struct branchc bc;
if (EAT('^')) {
EMIT(OBOL, 0);
p->g->iflags |= USEBOL;
p->g->nbol++;
bc.nbranch = 0;
if (end1 == OUT && end2 == OUT)
bc.outer = true;
else
bc.outer = false;
#define SEEEND() (!p->bre ? SEE(end1) : SEETWO(end1, end2))
for (;;) {
bc.start = HERE();
bc.nchain = 0;
bc.terminate = false;
if (p->pre_parse != NULL)
p->pre_parse(p, &bc);
while (MORE() && (!p->allowbranch || !SEESPEC('|')) && !SEEEND()) {
bc.terminate = p->parse_expr(p, &bc);
++bc.nchain;
}
if (p->post_parse != NULL)
p->post_parse(p, &bc);
(void) REQUIRE(HERE() != bc.start, REG_EMPTY);
if (!p->allowbranch)
break;
/*
* p_branch_do's return value indicates whether we should
* continue parsing or not. This is both for correctness and
* a slight optimization, because it will check if we've
* encountered an empty branch or the end of the string
* immediately following a branch delimiter.
*/
if (!p_branch_do(p, &bc))
break;
}
while (MORE() && !SEETWO(end1, end2)) {
wasdollar = p_simp_re(p, first);
first = 0;
}
if (wasdollar) { /* oops, that was a trailing anchor */
DROP(1);
EMIT(OEOL, 0);
p->g->iflags |= USEEOL;
p->g->neol++;
}
(void)REQUIRE(HERE() != start, REG_EMPTY); /* require nonempty */
#undef SEE_END
if (p->allowbranch)
p_branch_fix_tail(p, &bc);
assert(!MORE() || SEE(end1));
}
/*
- p_simp_re - parse a simple RE, an atom possibly followed by a repetition
== static int p_simp_re(struct parse *p, int starordinary);
== static bool p_simp_re(struct parse *p, struct branchc *bc);
*/
static int /* was the simple RE an unbackslashed $? */
p_simp_re(struct parse *p,
int starordinary) /* is a leading * an ordinary character? */
static bool /* was the simple RE an unbackslashed $? */
p_simp_re(struct parse *p, struct branchc *bc)
{
int c;
int count;
@ -614,7 +748,7 @@ p_simp_re(struct parse *p,
EMIT(OLPAREN, subno);
/* the MORE here is an error heuristic */
if (MORE() && !SEETWO('\\', ')'))
p_bre(p, '\\', ')');
p_re(p, '\\', ')');
if (subno < NPAREN) {
p->pend[subno] = HERE();
assert(p->pend[subno] != 0);
@ -650,11 +784,16 @@ p_simp_re(struct parse *p,
p->g->backrefs = 1;
break;
case '*':
(void)REQUIRE(starordinary, REG_BADRPT);
/*
* Ordinary if used as the first character beyond BOL anchor of
* a (sub-)expression, counts as a bad repetition operator if it
* appears otherwise.
*/
(void)REQUIRE(bc->nchain == 0, REG_BADRPT);
/* FALLTHROUGH */
default:
if (p->error != 0)
return(0); /* Definitely not $... */
return (false); /* Definitely not $... */
p->next--;
wc = WGETNEXT();
ordinary(p, wc);
@ -685,9 +824,9 @@ p_simp_re(struct parse *p,
SETERROR(REG_BADBR);
}
} else if (c == '$') /* $ (but not \$) ends it */
return(1);
return (true);
return(0);
return (false);
}
/*

View File

@ -189,4 +189,5 @@ struct re_guts {
/* misc utilities */
#define OUT (CHAR_MIN - 1) /* a non-character value */
#define IGN (CHAR_MIN - 2)
#define ISWORD(c) (iswalnum((uch)(c)) || (c) == '_')

View File

@ -329,10 +329,12 @@ stack top is the starting address returned by the call, plus
bytes.
The bottom of the stack at maximum growth is the starting
address returned by the call.
The system uses guards to prevent the inadvertent use of
regions into which stacks created with
.Pp
Stacks created with
.Dv MAP_STACK
will automatically grow, without mapping the whole stack in advance.
automatically grow.
Guards prevent inadvertent use of the regions into which those
stacks can grow without requiring mapping the whole stack in advance.
.El
.Pp
The

View File

@ -72,6 +72,7 @@ CFLAGS+= -I${.CURDIR}
SRCS.fmtcheck2_test= fmtcheck_test.c
SRCS.fnmatch2_test= fnmatch_test.c
TEST_METADATA.setdomainname_test+= is_exclusive=true
TESTS_SUBDIRS= execve
TESTS_SUBDIRS+= posix_spawn

View File

@ -36,8 +36,10 @@ MLINKS+= cam.3 cam_open_device.3 \
cam_cdbparse.3 csio_encode_visit.3 \
cam_cdbparse.3 buff_encode_visit.3
.PATH: ${SRCTOP}/sys/cam/scsi ${SRCTOP}/sys/cam/ata \
${SRCTOP}/sys/cam
.PATH: ${SRCTOP}/sys/cam \
${SRCTOP}/sys/cam/ata \
${SRCTOP}/sys/cam/mmc \
${SRCTOP}/sys/cam/scsi
CFLAGS+= -I${.CURDIR} -I${SRCTOP}/sys

View File

@ -0,0 +1,16 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
include \
include/arpa \
include/xlocale \
lib/libc++ \
lib/ncurses/ncursesw \
.include <dirdeps.mk>
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
# local dependencies - needed for -jN in clean tree
.endif

View File

@ -0,0 +1,13 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
include \
lib/libc++ \
.include <dirdeps.mk>
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
# local dependencies - needed for -jN in clean tree
.endif

View File

@ -225,9 +225,8 @@ SRCS+= switchu8.S
SRCS+= sync_synchronize.S
.endif
# GCC-6.3 on mips32 requires bswap32 built-in.
.if ${MACHINE_CPUARCH} == "mips"
# On some archs GCC-6.3 requires bswap32 built-in.
.if ${MACHINE_CPUARCH} == "mips" || ${MACHINE_CPUARCH} == "sparc64"
SRCS+= bswapdi2.c
SRCS+= bswapsi2.c
.endif

15
lib/libdl/Makefile Normal file
View File

@ -0,0 +1,15 @@
# $FreeBSD$
LIB=dl
SHLIB_MAJOR=1
.PATH: ${SRCTOP}/lib/libc/gen
CFLAGS+=-I${SRCTOP}/lib/libc/include
CFLAGS+=-DIN_LIBDL
LDFLAGS+=-Wl,-F,libc.so.7
VERSION_DEF=${SRCTOP}/lib/libc/Versions.def
SYMBOL_MAPS=${.CURDIR}/Symbol.map
SRCS = dlfcn.c
.include <bsd.lib.mk>

18
lib/libdl/Makefile.depend Normal file
View File

@ -0,0 +1,18 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
.include <dirdeps.mk>
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
# local dependencies - needed for -jN in clean tree
.endif

20
lib/libdl/Symbol.map Normal file
View File

@ -0,0 +1,20 @@
/*
* $FreeBSD$
*/
FBSD_1.0 {
dladdr;
dlclose;
dlerror;
dlfunc;
dlopen;
dlsym;
dlvsym;
dlinfo;
dl_iterate_phdr;
};
FBSD_1.3 {
fdlopen;
};

View File

@ -6,5 +6,5 @@
const char *
elftc_version(void)
{
return "elftoolchain r3520M";
return "elftoolchain r3561M";
}

View File

@ -48,9 +48,9 @@ global:
__moddi3;
__modti3;
__muldi3;
__multi3;
__mulvdi3;
__mulvsi3;
__multi3;
__negdi2;
__negti2;
__negvdi2;

View File

@ -0,0 +1,13 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
include \
include/xlocale \
.include <dirdeps.mk>
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
# local dependencies - needed for -jN in clean tree
.endif

View File

@ -0,0 +1,18 @@
# $FreeBSD$
# Autogenerated - do NOT edit!
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
include \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
.include <dirdeps.mk>
.if ${DEP_RELDIR} == ${_DEP_RELDIR}
# local dependencies - needed for -jN in clean tree
.endif

View File

@ -74,6 +74,7 @@ DIRDEPS = \
lib/libfigpar \
lib/libgeom \
lib/libgpio \
lib/libifconfig \
lib/libjail \
lib/libkvm \
lib/liblzma \
@ -92,6 +93,7 @@ DIRDEPS = \
lib/libproc \
lib/libprocstat \
lib/libradius \
lib/librss \
lib/librtld_db \
lib/libsdp \
lib/libsqlite3 \

View File

@ -28,7 +28,7 @@
.\" @(#)rlogind.8 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
.Dd February 9, 2005
.Dd July 3, 2017
.Dt RLOGIND 8
.Os
.Sh NAME
@ -37,6 +37,15 @@
.Sh SYNOPSIS
.Nm
.Op Fl Daln
.Sh DEPRECATION NOTICE
.Nm
is deprecated and will be removed from future versions of the
.Fx
base system.
If
.Nm
is still required, it can be installed from ports or packages
(net/bsdrcmds).
.Sh DESCRIPTION
The
.Nm

View File

@ -28,7 +28,7 @@
.\" @(#)rshd.8 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
.Dd June 4, 1993
.Dd July 3, 2017
.Dt RSHD 8
.Os
.Sh NAME
@ -37,6 +37,15 @@
.Sh SYNOPSIS
.Nm
.Op Fl aDLln
.Sh DEPRECATION NOTICE
.Nm
is deprecated and will be removed from future versions of the
.Fx
base system.
If
.Nm
is still required, it can be installed from ports or packages
(net/bsdrcmds).
.Sh DESCRIPTION
The
.Nm

View File

@ -1659,6 +1659,7 @@ find_symdef(unsigned long symnum, const Obj_Entry *refobj,
const Elf_Sym *ref;
const Elf_Sym *def;
const Obj_Entry *defobj;
const Ver_Entry *ve;
SymLook req;
const char *name;
int res;
@ -1678,6 +1679,7 @@ find_symdef(unsigned long symnum, const Obj_Entry *refobj,
name = refobj->strtab + ref->st_name;
def = NULL;
defobj = NULL;
ve = NULL;
/*
* We don't have to do a full scale lookup if the symbol is local.
@ -1694,7 +1696,7 @@ find_symdef(unsigned long symnum, const Obj_Entry *refobj,
}
symlook_init(&req, name);
req.flags = flags;
req.ventry = fetch_ventry(refobj, symnum);
ve = req.ventry = fetch_ventry(refobj, symnum);
req.lockstate = lockstate;
res = symlook_default(&req, refobj);
if (res == 0) {
@ -1724,7 +1726,8 @@ find_symdef(unsigned long symnum, const Obj_Entry *refobj,
}
} else {
if (refobj != &obj_rtld)
_rtld_error("%s: Undefined symbol \"%s\"", refobj->path, name);
_rtld_error("%s: Undefined symbol \"%s%s%s\"", refobj->path, name,
ve != NULL ? "@" : "", ve != NULL ? ve->name : "");
}
return def;
}
@ -3489,7 +3492,8 @@ do_dlsym(void *handle, const char *name, void *retaddr, const Ver_Entry *ve,
return (sym);
}
_rtld_error("Undefined symbol \"%s\"", name);
_rtld_error("Undefined symbol \"%s%s%s\"", name, ve != NULL ? "@" : "",
ve != NULL ? ve->name : "");
lock_release(rtld_bind_lock, &lockstate);
LD_UTRACE(UTRACE_DLSYM_STOP, handle, NULL, 0, 0, name);
return NULL;
@ -5296,14 +5300,14 @@ open_binary_fd(const char *argv0, bool search_in_path)
fd = -1;
errno = ENOENT;
while ((pe = strsep(&pathenv, ":")) != NULL) {
if (strlcpy(binpath, pe, sizeof(binpath)) >
if (strlcpy(binpath, pe, sizeof(binpath)) >=
sizeof(binpath))
continue;
if (binpath[0] != '\0' &&
strlcat(binpath, "/", sizeof(binpath)) >
strlcat(binpath, "/", sizeof(binpath)) >=
sizeof(binpath))
continue;
if (strlcat(binpath, argv0, sizeof(binpath)) >
if (strlcat(binpath, argv0, sizeof(binpath)) >=
sizeof(binpath))
continue;
fd = open(binpath, O_RDONLY | O_CLOEXEC | O_VERIFY);

View File

@ -269,7 +269,7 @@ packagesystem: base.txz kernel.txz ${EXTRA_PACKAGES}
touch ${.TARGET}
pkg-stage:
.if !defined(NOPKG)
.if !defined(NOPKG) || empty(NOPKG)
env PORTSDIR=${PORTSDIR} REPOS_DIR=${.CURDIR}/pkg_repos/ \
sh ${.CURDIR}/scripts/pkg-stage.sh
mkdir -p ${.OBJDIR}/dvd/packages/repos/

View File

@ -21,7 +21,7 @@ STAGE_TARGETS?= iso-images-stage
.endif
.if (defined(EMBEDDED_TARGET) && !empty(EMBEDDED_TARGET)) || (defined(EMBEDDEDBUILD) && !empty(EMBEDDEDBUILD))
. if ${TARGET} == "arm" || ${EMBEDDED_TARGET} == "arm"
. if ${TARGET:Marm*} != "" || ${EMBEDDED_TARGET:Marm*} != ""
EMBEDDED= 1
. endif
.endif
@ -57,7 +57,7 @@ TLD?= ${FTPDIR}/releases
.endif
.if defined(EMBEDDED) && !empty(EMBEDDED)
. if ${TARGET} == "arm" && ${TARGET_ARCH} == "armv6"
. if ${TARGET:Marm*} != "" && (${TARGET_ARCH} == "armv6" || ${TARGET_ARCH} == "aarch64")
. if !defined(BOARDNAME) && empty(BOARDNAME)
BOARDNAME:= ${KERNCONF}
. else

View File

@ -27,7 +27,7 @@
#
ATLAS_API_URL=''
ATLAS_UPLOAD_URL='https://binstore.hashicorp.com'
ATLAS_UPLOAD_URL='https://app.vagrantup.com'
DESCRIPTION="FreeBSD Snapshot Build"
usage() {
@ -76,7 +76,7 @@ main () {
fi
# Check to see if the box exists or create it
BOXRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}?access_token=${KEY}")
BOXRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}?access_token=${KEY}")
if [ $? != 0 ]; then
echo "Failed to connect to the API"
exit 2;
@ -84,26 +84,26 @@ main () {
echo $BOXRESULT | grep "\"name\":\"${BOX}\"" > /dev/null
if [ $? != 0 ]; then
echo "Creating box: ${BOX}"
/usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/boxes -X POST -d "box[name]=${BOX}" -d "access_token=${KEY}" > /dev/null
/usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX} -X PUT -d "box[is_private]=false" -d "access_token=${KEY}" > /dev/null
/usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX} -X PUT -d "box[description]='${DESCRIPTION}'" -d "access_token=${KEY}" > /dev/null
/usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/boxes -X POST -d "box[name]=${BOX}" -d "access_token=${KEY}" > /dev/null
/usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX} -X PUT -d "box[is_private]=false" -d "access_token=${KEY}" > /dev/null
/usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX} -X PUT -d "box[description]='${DESCRIPTION}'" -d "access_token=${KEY}" > /dev/null
else
echo "Box already exists"
fi
# Check to see if the version exists or create it
VERSIONRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}?access_token=${KEY}")
VERSIONRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}?access_token=${KEY}")
if [ $? != 0 ]; then
echo "Failed to connect to the API"
exit 2;
fi
echo $VERSIONRESULT | grep "\"version\":\"${VERSION}\"" > /dev/null
echo $VERSIONRESULT | grep "version/${VERSION}" > /dev/null
if [ $? != 0 ]; then
echo "Creating version: ${VERSION}"
/usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/versions -X POST -d "version[version]=${VERSION}" -d "access_token=${KEY}" > /dev/null
/usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION} -X PUT -d "version[description]=${DESCRIPTION}" -d "access_token=${KEY}" > /dev/null
VERSIONRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}?access_token=${KEY}")
echo $VERSIONRESULT | grep "\"version\":\"${VERSION}\"" > /dev/null
/usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/versions -X POST -d "version[version]=${VERSION}" -d "access_token=${KEY}" > /dev/null
/usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION} -X PUT -d "version[description]=${DESCRIPTION}" -d "access_token=${KEY}" > /dev/null
VERSIONRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}?access_token=${KEY}")
echo $VERSIONRESULT | grep "version/${VERSION}" > /dev/null
if [ $? != 0 ]; then
echo "Failed to create version"
exit 2
@ -113,37 +113,37 @@ main () {
fi
# Check to see if the provider exists or create it
PROVIDERRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}?access_token=${KEY}")
PROVIDERRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}?access_token=${KEY}")
if [ $? != 0 ]; then
echo "Failed to connect to the API"
exit 2;
fi
echo $PROVIDERRESULT | grep "\"name\":\"${PROVIDER}\"" > /dev/null
echo $PROVIDERRESULT | grep "provider/${PROVIDER}" > /dev/null
if [ $? != 0 ]; then
echo "Creating provider: ${PROVIDER}"
/usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/providers -X POST -d "provider[name]=${PROVIDER}" -d "access_token=${KEY}" > /dev/null
/usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/providers -X POST -d "provider[name]=${PROVIDER}" -d "access_token=${KEY}" > /dev/null
else
echo "Provider already exists"
fi
# Request an upload token
TOKENRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}/upload?access_token=${KEY}")
TOKENRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}/upload?access_token=${KEY}")
if [ $? != 0 ]; then
echo "Failed to get the token from the API"
exit 2;
fi
echo ${TOKENRESULT} | grep -E "\"(token|upload_path)\":" > /dev/null
echo ${TOKENRESULT} | grep -E "upload_path" > /dev/null
if [ $? != 0 ]; then
echo "No token found from the API"
exit 2
else
TOKEN=$(echo $TOKENRESULT | sed -e 's/.*token":"//' -e 's/.*upload_path":"//' -e 's/}$//g' -e 's/"//g')
echo "Uploading to Atlas"
UPLOADRESULT=$(/usr/local/bin/curl -s -X PUT --upload-file ${FILE} ${TOKEN})
UPLOADRESULT=$(/usr/local/bin/curl -s -X PUT --upload-file ${FILE} "${TOKEN}")
# Validate the Upload
echo "Validating"
VALIDRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}?access_token=${KEY}")
VALIDRESULT=$(/usr/local/bin/curl -s "${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}?access_token=${KEY}")
HOSTED_TOKEN=$(echo $VALIDRESULT | sed -e 's/.*"hosted"://' -e 's/,.*$//')
if [ ! -z ${TOKEN} -a "${HOSTED_TOKEN}" != "true" ]; then
echo "Upload failed, try again."
@ -152,7 +152,7 @@ main () {
# Release the version
echo "Releasing ${VERSION} of ${BOX} in Atlas"
/usr/local/bin/curl -s https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/release -X PUT -d "access_token=${KEY}" > /dev/null
/usr/local/bin/curl -s ${ATLAS_UPLOAD_URL}/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/release -X PUT -d "access_token=${KEY}" > /dev/null
fi
}

View File

@ -93,8 +93,6 @@ SUBDIR.${MK_TESTS}+= tests
.include <bsd.arch.inc.mk>
SUBDIR:= ${SUBDIR:O}
SUBDIR_PARALLEL=
.include <bsd.subdir.mk>

File diff suppressed because it is too large Load Diff

View File

@ -1271,8 +1271,8 @@ new_session(session_t *sprev, struct ttyent *typ)
sp->se_flags |= SE_PRESENT;
sp->se_device = malloc(sizeof(_PATH_DEV) + strlen(typ->ty_name));
sprintf(sp->se_device, "%s%s", _PATH_DEV, typ->ty_name);
if (asprintf(&sp->se_device, "%s%s", _PATH_DEV, typ->ty_name) < 0)
err(1, "asprintf");
/*
* Attempt to open the device, if we get "device not configured"
@ -1315,8 +1315,8 @@ setupargv(session_t *sp, struct ttyent *typ)
free(sp->se_getty_argv_space);
free(sp->se_getty_argv);
}
sp->se_getty = malloc(strlen(typ->ty_getty) + strlen(typ->ty_name) + 2);
sprintf(sp->se_getty, "%s %s", typ->ty_getty, typ->ty_name);
if (asprintf(&sp->se_getty, "%s %s", typ->ty_getty, typ->ty_name) < 0)
err(1, "asprintf");
sp->se_getty_argv_space = strdup(sp->se_getty);
sp->se_getty_argv = construct_argv(sp->se_getty_argv_space);
if (sp->se_getty_argv == NULL) {
@ -1429,7 +1429,7 @@ start_window_system(session_t *sp)
if (sp->se_type) {
/* Don't use malloc after fork */
strcpy(term, "TERM=");
strncat(term, sp->se_type, sizeof(term) - 6);
strlcat(term, sp->se_type, sizeof(term));
env[0] = term;
env[1] = 0;
}
@ -1493,7 +1493,7 @@ start_getty(session_t *sp)
if (sp->se_type) {
/* Don't use malloc after fork */
strcpy(term, "TERM=");
strncat(term, sp->se_type, sizeof(term) - 6);
strlcat(term, sp->se_type, sizeof(term));
env[0] = term;
env[1] = 0;
} else

View File

@ -398,7 +398,9 @@ main(int argc, char *argv[])
have_fstab = 1;
mntfromname = mntbuf->f_mntfromname;
} else if (argv[0][0] == '/' &&
argv[0][1] == '\0') {
argv[0][1] == '\0' &&
strcmp(fs->fs_vfstype,
mntbuf->f_fstypename) == 0) {
fs = getfsfile("/");
have_fstab = 1;
mntfromname = fs->fs_spec;

View File

@ -28,7 +28,7 @@
.\" @(#)newfs.8 8.6 (Berkeley) 5/3/95
.\" $FreeBSD$
.\"
.Dd July 15, 2015
.Dd July 7, 2017
.Dt NEWFS 8
.Os
.Sh NAME
@ -79,11 +79,9 @@ The following options define the general layout policies:
.It Fl E
Erase the content of the disk before making the filesystem.
The reserved area in front of the superblock (for bootcode) will not be erased.
.Pp
This option is only relevant for flash based storage devices that use
wear-leveling algorithms.
.Pp
Erasing may take a long time as it writes to every sector on the disk.
Erasing is only relevant to flash-memory or thinly provisioned devices.
Erasing may take a long time.
If the device does not support BIO_DELETE, the command will fail.
.It Fl J
Enable journaling on the new file system via gjournal.
See
@ -264,9 +262,11 @@ Turn on the TRIM enable flag.
If enabled, and if the underlying device supports the BIO_DELETE
command, the file system will send a delete request to the underlying
device for each freed block.
The trim enable flag is typically set when the underlying device
uses flash-memory as the device can use the delete command to
pre-zero or at least avoid copying blocks that have been deleted.
The trim enable flag is typically set for flash-memory devices to
reduce write amplification which reduces wear on write-limited
flash-memory and often improves long-term performance.
Thinly provisioned storage also benefits by returning unused blocks to
the global pool.
.El
.Pp
The following options override the standard sizes for the disk geometry.

View File

@ -119,7 +119,7 @@ printheader(xo_handle_t *xo, const struct kerneldumpheader *h, const char *devic
xo_emit_h(xo, "{P: }{Lwc:Dumptime}{:dumptime/%s}", ctime(&t));
xo_emit_h(xo, "{P: }{Lwc:Hostname}{:hostname/%s}\n", h->hostname);
xo_emit_h(xo, "{P: }{Lwc:Magic}{:magic/%s}\n", h->magic);
xo_emit_h(xo, "{P: }{Lwc:Version String}{:version_string/%s}", h->versionstring);
xo_emit_h(xo, "{P: }{Lwc:Version String}{:version_string/%s}\n", h->versionstring);
xo_emit_h(xo, "{P: }{Lwc:Panic String}{:panic_string/%s}\n", h->panicstring);
xo_emit_h(xo, "{P: }{Lwc:Dump Parity}{:dump_parity/%u}\n", h->parity);
xo_emit_h(xo, "{P: }{Lwc:Bounds}{:bounds/%d}\n", bounds);
@ -334,6 +334,13 @@ check_space(const char *savedir, off_t dumpsize, int bounds)
return (1);
}
static bool
compare_magic(const struct kerneldumpheader *kdh, const char *magic)
{
return (strncmp(kdh->magic, magic, sizeof(kdh->magic)) == 0);
}
#define BLOCKSIZE (1<<12)
#define BLOCKMASK (~(BLOCKSIZE-1))
@ -564,7 +571,7 @@ DoFile(const char *savedir, const char *device)
}
memcpy(&kdhl, temp, sizeof(kdhl));
istextdump = 0;
if (strncmp(kdhl.magic, TEXTDUMPMAGIC, sizeof kdhl) == 0) {
if (compare_magic(&kdhl, TEXTDUMPMAGIC)) {
if (verbose)
printf("textdump magic on last dump header on %s\n",
device);
@ -578,8 +585,7 @@ DoFile(const char *savedir, const char *device)
if (force == 0)
goto closefd;
}
} else if (memcmp(kdhl.magic, KERNELDUMPMAGIC, sizeof kdhl.magic) ==
0) {
} else if (compare_magic(&kdhl, KERNELDUMPMAGIC)) {
if (dtoh32(kdhl.version) != KERNELDUMPVERSION) {
syslog(LOG_ERR,
"unknown version (%d) in last dump header on %s",
@ -598,8 +604,7 @@ DoFile(const char *savedir, const char *device)
if (force == 0)
goto closefd;
if (memcmp(kdhl.magic, KERNELDUMPMAGIC_CLEARED,
sizeof kdhl.magic) == 0) {
if (compare_magic(&kdhl, KERNELDUMPMAGIC_CLEARED)) {
if (verbose)
printf("forcing magic on %s\n", device);
memcpy(kdhl.magic, KERNELDUMPMAGIC,

View File

@ -141,6 +141,7 @@ MAN= aac.4 \
edsc.4 \
ehci.4 \
em.4 \
ena.4 \
enc.4 \
epair.4 \
esp.4 \

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd June 11, 2017
.Dd July 3, 2017
.Dt DTRACE_LOCKSTAT 4
.Os
.Sh NAME
@ -54,198 +54,247 @@
.Sh DESCRIPTION
The DTrace
.Nm lockstat
provider allows the tracing of events related to locking on FreeBSD.
provider allows the tracing of events related to locking on
.Fx .
.Pp
The
.Nm lockstat
provider contains DTrace probe for inspecting the kernel's lock
provider contains DTrace probes for inspecting the kernel's lock
state transitions.
Tracepoints exist for several types of kernel
locking primitives, including mutexes, spin, reader-writer,
and shared exclusive locks.
An attempt has been made to provide a regular and easy to understand
interface to the
Probes exist for the
.Xr mutex 9 ,
.Xr rwlock 9
and
.Xr sx 9
lock types.
The
.Xr lockstat 1
utility can be used to collect and display data collected from the
.Nm lockstat
provider.
Each type of lock has an
Each type of lock has
.Fn acquire
and
.Fn release
probe which exposes the lock structure that is being operated upon.
.Pp
Whenever an MTX_DEF mutex is acquired the
.Fn lockstat:::adaptive-acquire
probe fires.
The only argument is a pointer to the lock structure which describes
the lock that is being acquired.
probes which expose the lock structure being operated upon,
as well as probes which fire when a thread contends with other threads
for ownership of a lock.
.Pp
The
.Fn lockstat:::adaptive-acquire
and
.Fn lockstat:::adaptive-release
probe fires whenever an adaptive lock is released.
probes fire when an
.Dv MTX_DEF
.Xr mutex 9
is acquired and released, respectively.
The only argument is a pointer to the lock structure which describes
the lock that is being released.
the lock being acquired or released.
.Pp
The
.Fn lockstat:::adaptive-spin
probe fires when an adaptive lock is acquired.
probe fires when a thread spins while waiting for a
.Dv MTX_DEF
.Xr mutex 9
to be released by another thread.
The first argument is a pointer to the lock structure that describes
the lock and the second argument is the amount of time,
in nanoseconds,
that the mutex spent spinning.
.Pp
in nanoseconds, that the mutex spent spinning.
The
.Fn lockstat:::adaptive-block
probe fires whenever thread takes itself off of the CPU
while trying to acquire the lock.
probe fires when a thread takes itself off the CPU while trying to acquire an
.Dv MTX_DEF
.Xr mutex 9
that is owned by another thread.
The first argument is a pointer to the lock structure that describes
the lock and the second argument is the length of time,
in nanoseconds,
that the waiting thread was blocked.
in nanoseconds, that the waiting thread was blocked.
The
.Fn lockstat:::adaptive-block
probe fires only after the lock has been successfully acquired,
after the adaptive-acquire probe fires.
.Pp
Whenever a spin mutex is acquired the
.Fn lockstat:::spin-acquire
and
.Fn lockstat:::adaptive-spin
probes fire only after the lock has been successfully acquired,
and in particular, after the
.Fn lockstat:::adaptive-acquire
probe fires.
The only argument is a pointer to the lock structure which describes
the lock that is being acquired.
.Pp
The
.Fn lockstat:::spin-acquire
and
.Fn lockstat:::spin-release
probe fires whenever a spin mutex is released.
probes fire when a
.Dv MTX_SPIN
.Xr mutex 9
is acquired and released, respectively.
The only argument is a pointer to the lock structure which describes
the lock that is being released.
the lock being acquired or released.
.Pp
The
.Fn lockstat:::spin-spin
probe fires when a thread stops spinning waiting for a spin mutex.
probe fires when a thread spins while waiting for a
.Dv MTX_SPIN
.Xr mutex 9
to be released by another thread.
The first argument is a pointer to the lock structure that describes
the lock and the second argument is the length of the time
spent spinning, in nanoseconds.
.Pp
Whenever a reader-writer lock is acquired the
.Fn lockstat:::rw-acquire
The
.Fn lockstat:::spin-spin
probe fires only after the lock has been successfully acquired,
and in particular, after the
.Fn lockstat:::spin-acquire
probe fires.
The only argument is a pointer to the structure which describes
the lock that is being acquired.
.Pp
The
.Fn lockstat:::rw-acquire
and
.Fn lockstat:::rw-release
probe fires whenever a reader-writer lock is released.
probes fire when a
.Xr rwlock 9
is acquired and released, respectively.
The first argument is a pointer to the structure which describes
the lock being acquired.
The second argument is
.Dv 0
if the lock is being acquired or released as a writer, and
.Dv 1
if it is being acquired or released as a reader.
.Pp
The
.Fn lockstat:::rw-block
probe fires whenever a thread removes itself from the CPU while
waiting to acquire the lock.
The first argument is a pointer to the lock structure that describes
the lock and the second argument is the length of time,
in nanoseconds,
that the waiting thread was blocked.
The third argument is 1 if the thread was were spinning while
trying to acquire a read lock,
otherwise it will be 0 indicating that we were spinning for the write lock.
The fourth argument is 1 if we were waiting for a reader to release the lock,
otherwise it will be 0 indicating that we were waiting for a writer
to release the lock.
The fifth argument is the number of readers that held the lock when
we started spinning; in particular, argument 5 is non-zero only
if the fourth argument is 1.
.Pp
probe fires when a thread removes itself from the CPU while
waiting to acquire a
.Xr rwlock 9 .
The
.Fn lockstat:::rw-spin
probe fires when a reader-writer lock takes itself off the CPU
while waiting for the lock.
probe fires when a thread spins while waiting to acquire a
.Xr rwlock 9 .
Both probes take the same set of arguments.
The first argument is a pointer to the lock structure that describes
the lock and the second argument returns an integer count of the
number of spins that were completed.
the lock.
The second argument is the length of time, in nanoseconds,
that the waiting thread was off the CPU or spinning for the lock.
The third argument is
.Dv 0
if the thread is attempting to acquire the lock as a writer, and
.Dv 1
if the thread is attempting to acquire the lock as a reader.
The fourth argument is
.Dv 0
if the thread is waiting for a writer to release the lock, and
.Dv 1
if the thread is waiting for a reader to release the lock.
The fifth argument is the number of readers that held the lock when
the thread first attempted to acquire the lock.
This argument will be
.Dv 0
if the fourth argument is
.Dv 0 .
.Pp
The
.Fn lockstat:::rw-upgrade
probe fires whenever a thread tries to upgrade a lock from a
probe fires when a thread successfully upgrades a held
.Xr rwlock 9
read lock to a write lock.
The only argument is a pointer to the structure which describes
the lock that is being acquired.
.Pp
The
.Fn lockstat:::rw-downgrade
probe fires whenever a thread tries downgrades a lock from a
read and write lock to a read lock.
probe first when a thread downgrades a held
.Xr rwlock 9
write lock to a read lock.
The only argument is a pointer to the structure which describes
the lock that is being acquired.
.Pp
Whenever a shared-exclusive lock is acquired the
.Fn lockstat:::sx-acquire
probe fires.
The only argument is a pointer to the structure which describes
the lock that is being acquired.
the lock being acquired.
.Pp
The
.Fn lockstat:::sx-acquire
and
.Fn lockstat:::sx-release
probe fires whenever an adaptive lock is released.
The only argument is a pointer to the lock structure which describes
the lock that is being released.
probes fire when a
.Xr sx 9
is acquired and released, respectively.
The first argument is a pointer to the structure which describes
the lock being acquired.
The second argument is
.Dv 0
if the shared lock is being acquired or released, and
.Dv 1
if the exclusive lock is being acquired or released.
.Pp
The
.Fn lockstat:::sx-block
probe fires whenever a thread takes itself off the CPU while
waiting for the lock.
The first argument is a pointer to the structure that describes
the lock and the second argument is the length of time,
in nanoseconds,
that the waiting thread was blocked.
The third argument is 1 if the thread was were spinning while
trying to acquire a read lock,
otherwise it will be 0 indicating that we were spinning for the write lock.
The fourth argument is 1 if we were waiting for a reader to release the lock,
otherwise it will be 0 indicating that we were waiting for a writer
to release the lock.
The fifth argument is the number of readers that held the lock when
we started spinning; in particular, argument 5 is non-zero only
if the fourth argument is 1.
.Pp
probe fires when a thread takes itself off the CPU while
waiting to acquire a
.Xr sx 9 .
The
.Fn lockstat:::sx-spin
probe fires when a thread takes itself off of the CPU while
waiting for the lock.
The first argument is a pointer to the structure that describes
the lock and the second argument returns an integer count of the
number of spins that were completed.
probe first when a thread spins while waiting to acquire a
.Xr sx 9 .
Both probes take the same set of arguments.
The first argument is a pointer to the lock structure that describes
the lock.
The second argument is the length of time, in nanoseconds,
that the waiting thread was off the CPU or spinning for the lock.
The third argument is
.Dv 0
if the thread is attempting to acquire the lock as a writer, and
.Dv 1
if the thread is attempting to acquire the lock as a reader.
The fourth argument is
.Dv 0
if the thread is waiting for a writer to release the lock, and
.Dv 1
if the thread is waiting for a reader to release the lock.
The fifth argument is the number of readers that held the lock when
the thread first attempted to acquire the lock.
This argument will be
.Dv 0
if the fourth argument is
.Dv 0 .
.Pp
The
.Fn lockstat:::sx-upgrade
probe fires whenever a thread tries to upgrade a lock from a
shared lock to a shared-exclusive lock.
probe fires when a thread successfully upgrades a held
.Xr sx 9
shared lock to an exclusive lock.
The only argument is a pointer to the structure which describes
the lock that is being upgraded.
.Pp
the lock being acquired.
The
.Fn lockstat:::sx-downgrade
probe fires whenever a thread downgrades a lock from a
shared-exclusive lock to a shared lock.
The only argument is a pointer to the structure which describes
the lock that is being downgraded.
probe fires when a thread downgrades a held
.Xr sx 9
exclusive lock to a shared lock.
.Pp
The
.Fn lockstat:::thread-spin
probe fires whenever a thread spins on a spin lock.
probe fires when a thread spins on a thread lock, which is a specialized
.Dv MTX_SPIN
.Xr mutex 9 .
The first argument is a pointer to the structure that describes
the lock and the second argument is the length of time,
in nanoseconds,
that the thread was spinning.
in nanoseconds, that the thread was spinning.
.Sh SEE ALSO
.Xr dtrace 1 ,
.Xr lockstat 1 ,
.Xr locking 9 ,
.Xr SDT 9
.Xr mutex 9 ,
.Xr rwlock 9 ,
.Xr SDT 9 ,
.Xr sx 9
.Sh HISTORY
The
.Nm lockstat
provider first appeared in OpenSolaris.
The FreeBSD implementation of the
provider first appeared in Solaris.
The
.Fx
implementation of the
.Nm lockstat
provider first appeared in
.Fx 9.
.Sh AUTHORS
This manual page was written by
.An George V. Neville-Neil Aq Mt gnn@FreeBSD.org .
.Sh BUGS
Probes for
.Xr lockmgr 9
and
.Xr rmlock 9
locks have not yet been added.

Some files were not shown because too many files have changed in this diff Show More