MFhead @ r305314

This commit is contained in:
Enji Cooper 2016-09-03 00:50:18 +00:00
commit 637cce3a32
169 changed files with 2647 additions and 2879 deletions

View File

@ -1628,8 +1628,10 @@ _crunchide= usr.sbin/crunch/crunchide
# r285986 crunchen: use STRIPBIN rather than STRIP
# 1100113: Support MK_AUTO_OBJ
# 1200006: META_MODE fixes
.if ${BOOTSTRAPPING} < 1100078 || \
(${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114)
(${MK_AUTO_OBJ} == "yes" && ${BOOTSTRAPPING} < 1100114) || \
(${MK_META_MODE} == "yes" && ${BOOTSTRAPPING} < 1200006)
_crunchgen= usr.sbin/crunch/crunchgen
.endif

View File

@ -38,6 +38,8 @@
# xargs -n1 | sort | uniq -d;
# done
# 20160901: Remove digi(4)
OLD_FILES+=usr/share/man/man4/digi.4.gz
# 20160819: Remove ie(4)
OLD_FILES+=usr/share/man/man4/i386/ie.4.gz
# 20160819: Remove spic(4)

View File

@ -68,6 +68,9 @@ ${PACKAGE}FILES+= dot1.0
${PACKAGE}FILES+= dot2.0
${PACKAGE}FILES+= dot3.0
${PACKAGE}FILES+= dot4.0
${PACKAGE}FILES+= echo1.0
${PACKAGE}FILES+= echo2.0
${PACKAGE}FILES+= echo3.0
${PACKAGE}FILES+= eval1.0
${PACKAGE}FILES+= eval2.0
${PACKAGE}FILES+= eval3.0

View File

@ -0,0 +1,6 @@
# $FreeBSD$
# Not specified by POSIX.
[ "`echo -n a b; echo c d; echo e f`" = "a bc d
e f" ]

View File

@ -0,0 +1,7 @@
# $FreeBSD$
# Not specified by POSIX.
a=`echo -e '\a\b\e\f\n\r\t\v\\\\\0041\c'; echo .`
b=`printf '\a\b\033\f\n\r\t\v\\\\!.'`
[ "$a" = "$b" ]

View File

@ -0,0 +1,5 @@
# $FreeBSD$
# Not specified by POSIX.
[ "`echo -e 'a\cb' c; echo d`" = "ad" ]

View File

@ -60,7 +60,6 @@
#include <sys/ddt.h>
#include <sys/zfeature.h>
#include <zfs_comutil.h>
#undef ZFS_MAXNAMELEN
#undef verify
#include <libzfs.h>
@ -1945,7 +1944,7 @@ dump_dir(objset_t *os)
uint64_t refdbytes, usedobjs, scratch;
char numbuf[32];
char blkbuf[BP_SPRINTF_LEN + 20];
char osname[MAXNAMELEN];
char osname[ZFS_MAX_DATASET_NAME_LEN];
char *type = "UNKNOWN";
int verbosity = dump_opt['d'];
int print_header = 1;
@ -3482,7 +3481,7 @@ find_zpool(char **target, nvlist_t **configp, int dirc, char **dirv)
nvlist_t *match = NULL;
char *name = NULL;
char *sepp = NULL;
char sep;
char sep = '\0';
int count = 0;
importargs_t args = { 0 };

View File

@ -21,8 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved.
* Copyright (c) 2012 Pawel Jakub Dawidek. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
@ -320,8 +319,8 @@ zfs_sort(const void *larg, const void *rarg, void *data)
} else if (psc->sc_prop == ZFS_PROP_NAME) {
lvalid = rvalid = B_TRUE;
(void) strlcpy(lbuf, zfs_get_name(l), sizeof(lbuf));
(void) strlcpy(rbuf, zfs_get_name(r), sizeof(rbuf));
(void) strlcpy(lbuf, zfs_get_name(l), sizeof (lbuf));
(void) strlcpy(rbuf, zfs_get_name(r), sizeof (rbuf));
lstr = lbuf;
rstr = rbuf;

View File

@ -22,6 +22,7 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
*/

View File

@ -24,13 +24,12 @@
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright 2012 Milan Jurik. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright (c) 2011-2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved.
* Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved.
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>.
* Copyright 2016 Nexenta Systems, Inc.
*/
#include <assert.h>
@ -1511,7 +1510,7 @@ get_callback(zfs_handle_t *zhp, void *data)
char buf[ZFS_MAXPROPLEN];
char rbuf[ZFS_MAXPROPLEN];
zprop_source_t sourcetype;
char source[ZFS_MAXNAMELEN];
char source[ZFS_MAX_DATASET_NAME_LEN];
zprop_get_cbdata_t *cbp = data;
nvlist_t *user_props = zfs_get_user_props(zhp);
zprop_list_t *pl = cbp->cb_proplist;
@ -1991,7 +1990,7 @@ typedef struct upgrade_cbdata {
uint64_t cb_version;
boolean_t cb_newer;
boolean_t cb_foundone;
char cb_lastfs[ZFS_MAXNAMELEN];
char cb_lastfs[ZFS_MAX_DATASET_NAME_LEN];
} upgrade_cbdata_t;
static int
@ -2437,7 +2436,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
if (domain != NULL && domain[0] != '\0') {
/* SMB */
char sid[ZFS_MAXNAMELEN + 32];
char sid[MAXNAMELEN + 32];
uid_t id;
#ifdef illumos
int err;
@ -2574,7 +2573,7 @@ print_us_node(boolean_t scripted, boolean_t parsable, int *fields, int types,
size_t *width, us_node_t *node)
{
nvlist_t *nvl = node->usn_nvl;
char valstr[ZFS_MAXNAMELEN];
char valstr[MAXNAMELEN];
boolean_t first = B_TRUE;
int cfield = 0;
int field;
@ -3009,7 +3008,7 @@ print_dataset(zfs_handle_t *zhp, list_cbdata_t *cb)
if (pl->pl_prop == ZFS_PROP_NAME) {
(void) strlcpy(property, zfs_get_name(zhp),
sizeof(property));
sizeof (property));
propstr = property;
right_justify = zfs_prop_align_right(pl->pl_prop);
} else if (pl->pl_prop != ZPROP_INVAL) {
@ -3473,7 +3472,7 @@ zfs_do_rollback(int argc, char **argv)
boolean_t force = B_FALSE;
rollback_cbdata_t cb = { 0 };
zfs_handle_t *zhp, *snap;
char parentname[ZFS_MAXNAMELEN];
char parentname[ZFS_MAX_DATASET_NAME_LEN];
char *delim;
/* check options */
@ -3873,7 +3872,7 @@ zfs_do_send(int argc, char **argv)
*/
if (strchr(argv[0], '@') == NULL ||
(fromname && strchr(fromname, '#') != NULL)) {
char frombuf[ZFS_MAXNAMELEN];
char frombuf[ZFS_MAX_DATASET_NAME_LEN];
enum lzc_send_flags lzc_flags = 0;
if (flags.replicate || flags.doall || flags.props ||
@ -3925,7 +3924,7 @@ zfs_do_send(int argc, char **argv)
* case if they specify the origin.
*/
if (fromname && (cp = strchr(fromname, '@')) != NULL) {
char origin[ZFS_MAXNAMELEN];
char origin[ZFS_MAX_DATASET_NAME_LEN];
zprop_source_t src;
(void) zfs_prop_get(zhp, ZFS_PROP_ORIGIN,
@ -4059,7 +4058,7 @@ zfs_do_receive(int argc, char **argv)
usage(B_FALSE);
}
char namebuf[ZFS_MAXNAMELEN];
char namebuf[ZFS_MAX_DATASET_NAME_LEN];
(void) snprintf(namebuf, sizeof (namebuf),
"%s/%%recv", argv[0]);
@ -4917,7 +4916,7 @@ store_allow_perm(zfs_deleg_who_type_t type, boolean_t local, boolean_t descend,
{
int i;
char ld[2] = { '\0', '\0' };
char who_buf[ZFS_MAXNAMELEN+32];
char who_buf[MAXNAMELEN + 32];
char base_type = '\0';
char set_type = '\0';
nvlist_t *base_nvl = NULL;
@ -5285,7 +5284,7 @@ static void
print_fs_perms(fs_perm_set_t *fspset)
{
fs_perm_node_t *node = NULL;
char buf[ZFS_MAXNAMELEN+32];
char buf[MAXNAMELEN + 32];
const char *dsname = buf;
for (node = uu_list_first(fspset->fsps_list); node != NULL;
@ -5294,7 +5293,7 @@ print_fs_perms(fs_perm_set_t *fspset)
uu_avl_t *uge_avl = node->fspn_fsperm.fsp_uge_avl;
int left = 0;
(void) snprintf(buf, ZFS_MAXNAMELEN+32,
(void) snprintf(buf, sizeof (buf),
gettext("---- Permissions on %s "),
node->fspn_fsperm.fsp_name);
(void) printf(dsname);
@ -5491,7 +5490,7 @@ zfs_do_hold_rele_impl(int argc, char **argv, boolean_t holding)
for (i = 0; i < argc; ++i) {
zfs_handle_t *zhp;
char parent[ZFS_MAXNAMELEN];
char parent[ZFS_MAX_DATASET_NAME_LEN];
const char *delim;
char *path = argv[i];
@ -5624,7 +5623,7 @@ holds_callback(zfs_handle_t *zhp, void *data)
nvlist_t *nvl = NULL;
nvpair_t *nvp = NULL;
const char *zname = zfs_get_name(zhp);
size_t znamelen = strnlen(zname, ZFS_MAXNAMELEN);
size_t znamelen = strlen(zname);
if (cbp->cb_recursive && cbp->cb_snapname != NULL) {
const char *snapname;
@ -5645,7 +5644,7 @@ holds_callback(zfs_handle_t *zhp, void *data)
while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL) {
const char *tag = nvpair_name(nvp);
size_t taglen = strnlen(tag, MAXNAMELEN);
size_t taglen = strlen(tag);
if (taglen > cbp->cb_max_taglen)
cbp->cb_max_taglen = taglen;
}
@ -6484,6 +6483,15 @@ unshare_unmount(int op, int argc, char **argv)
continue;
}
/*
* Ignore datasets that are excluded/restricted by
* parent pool name.
*/
if (zpool_skip_pool(zfs_get_pool_name(zhp))) {
zfs_close(zhp);
continue;
}
switch (op) {
case OP_SHARE:
verify(zfs_prop_get(zhp, ZFS_PROP_SHARENFS,
@ -6973,7 +6981,7 @@ zfs_do_diff(int argc, char **argv)
static int
zfs_do_bookmark(int argc, char **argv)
{
char snapname[ZFS_MAXNAMELEN];
char snapname[ZFS_MAX_DATASET_NAME_LEN];
zfs_handle_t *zhp;
nvlist_t *nvl;
int ret = 0;

View File

@ -48,7 +48,6 @@
#include <sys/zio_compress.h>
#include <sys/zfeature.h>
#include <sys/dmu_tx.h>
#undef ZFS_MAXNAMELEN
#undef verify
#include <libzfs.h>

View File

@ -4540,7 +4540,7 @@ zpool_do_status(int argc, char **argv)
typedef struct upgrade_cbdata {
boolean_t cb_first;
boolean_t cb_unavail;
char cb_poolname[ZPOOL_MAXNAMELEN];
char cb_poolname[ZFS_MAX_DATASET_NAME_LEN];
int cb_argc;
uint64_t cb_version;
char **cb_argv;

View File

@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2013, 2015 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>.
*/
@ -597,7 +597,6 @@ get_replication(nvlist_t *nvroot, boolean_t fatal)
verify(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN,
&top, &toplevels) == 0);
lastrep.zprl_type = NULL;
for (t = 0; t < toplevels; t++) {
uint64_t is_log = B_FALSE;

View File

@ -141,8 +141,8 @@ typedef struct ztest_shared_hdr {
static ztest_shared_hdr_t *ztest_shared_hdr;
typedef struct ztest_shared_opts {
char zo_pool[MAXNAMELEN];
char zo_dir[MAXNAMELEN];
char zo_pool[ZFS_MAX_DATASET_NAME_LEN];
char zo_dir[ZFS_MAX_DATASET_NAME_LEN];
char zo_alt_ztest[MAXNAMELEN];
char zo_alt_libpath[MAXNAMELEN];
uint64_t zo_vdevs;
@ -268,7 +268,7 @@ typedef struct ztest_od {
uint64_t od_crblocksize;
uint64_t od_gen;
uint64_t od_crgen;
char od_name[MAXNAMELEN];
char od_name[ZFS_MAX_DATASET_NAME_LEN];
} ztest_od_t;
/*
@ -280,7 +280,7 @@ typedef struct ztest_ds {
rwlock_t zd_zilog_lock;
zilog_t *zd_zilog;
ztest_od_t *zd_od; /* debugging aid */
char zd_name[MAXNAMELEN];
char zd_name[ZFS_MAX_DATASET_NAME_LEN];
mutex_t zd_dirobj_lock;
rll_t zd_object_lock[ZTEST_OBJECT_LOCKS];
rll_t zd_range_lock[ZTEST_RANGE_LOCKS];
@ -3227,7 +3227,7 @@ ztest_objset_destroy_cb(const char *name, void *arg)
static boolean_t
ztest_snapshot_create(char *osname, uint64_t id)
{
char snapname[MAXNAMELEN];
char snapname[ZFS_MAX_DATASET_NAME_LEN];
int error;
(void) snprintf(snapname, sizeof (snapname), "%llu", (u_longlong_t)id);
@ -3247,10 +3247,10 @@ ztest_snapshot_create(char *osname, uint64_t id)
static boolean_t
ztest_snapshot_destroy(char *osname, uint64_t id)
{
char snapname[MAXNAMELEN];
char snapname[ZFS_MAX_DATASET_NAME_LEN];
int error;
(void) snprintf(snapname, MAXNAMELEN, "%s@%llu", osname,
(void) snprintf(snapname, sizeof (snapname), "%s@%llu", osname,
(u_longlong_t)id);
error = dsl_destroy_snapshot(snapname, B_FALSE);
@ -3267,12 +3267,12 @@ ztest_dmu_objset_create_destroy(ztest_ds_t *zd, uint64_t id)
int iters;
int error;
objset_t *os, *os2;
char name[MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
zilog_t *zilog;
(void) rw_rdlock(&ztest_name_lock);
(void) snprintf(name, MAXNAMELEN, "%s/temp_%llu",
(void) snprintf(name, sizeof (name), "%s/temp_%llu",
ztest_opts.zo_pool, (u_longlong_t)id);
/*
@ -3378,18 +3378,23 @@ ztest_dmu_snapshot_create_destroy(ztest_ds_t *zd, uint64_t id)
void
ztest_dsl_dataset_cleanup(char *osname, uint64_t id)
{
char snap1name[MAXNAMELEN];
char clone1name[MAXNAMELEN];
char snap2name[MAXNAMELEN];
char clone2name[MAXNAMELEN];
char snap3name[MAXNAMELEN];
char snap1name[ZFS_MAX_DATASET_NAME_LEN];
char clone1name[ZFS_MAX_DATASET_NAME_LEN];
char snap2name[ZFS_MAX_DATASET_NAME_LEN];
char clone2name[ZFS_MAX_DATASET_NAME_LEN];
char snap3name[ZFS_MAX_DATASET_NAME_LEN];
int error;
(void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id);
(void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id);
(void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id);
(void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
(void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
(void) snprintf(snap1name, sizeof (snap1name),
"%s@s1_%llu", osname, id);
(void) snprintf(clone1name, sizeof (clone1name),
"%s/c1_%llu", osname, id);
(void) snprintf(snap2name, sizeof (snap2name),
"%s@s2_%llu", clone1name, id);
(void) snprintf(clone2name, sizeof (clone2name),
"%s/c2_%llu", osname, id);
(void) snprintf(snap3name, sizeof (snap3name),
"%s@s3_%llu", clone1name, id);
error = dsl_destroy_head(clone2name);
if (error && error != ENOENT)
@ -3415,11 +3420,11 @@ void
ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
{
objset_t *os;
char snap1name[MAXNAMELEN];
char clone1name[MAXNAMELEN];
char snap2name[MAXNAMELEN];
char clone2name[MAXNAMELEN];
char snap3name[MAXNAMELEN];
char snap1name[ZFS_MAX_DATASET_NAME_LEN];
char clone1name[ZFS_MAX_DATASET_NAME_LEN];
char snap2name[ZFS_MAX_DATASET_NAME_LEN];
char clone2name[ZFS_MAX_DATASET_NAME_LEN];
char snap3name[ZFS_MAX_DATASET_NAME_LEN];
char *osname = zd->zd_name;
int error;
@ -3427,11 +3432,16 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
ztest_dsl_dataset_cleanup(osname, id);
(void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id);
(void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id);
(void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id);
(void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
(void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
(void) snprintf(snap1name, sizeof (snap1name),
"%s@s1_%llu", osname, id);
(void) snprintf(clone1name, sizeof (clone1name),
"%s/c1_%llu", osname, id);
(void) snprintf(snap2name, sizeof (snap2name),
"%s@s2_%llu", clone1name, id);
(void) snprintf(clone2name, sizeof (clone2name),
"%s/c2_%llu", osname, id);
(void) snprintf(snap3name, sizeof (snap3name),
"%s@s3_%llu", clone1name, id);
error = dmu_objset_snapshot_one(osname, strchr(snap1name, '@') + 1);
if (error && error != EEXIST) {
@ -4249,7 +4259,7 @@ ztest_fzap(ztest_ds_t *zd, uint64_t id)
* 2050 entries we should see ptrtbl growth and leaf-block split.
*/
for (int i = 0; i < 2050; i++) {
char name[MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
uint64_t value = i;
dmu_tx_t *tx;
int error;
@ -4654,7 +4664,7 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
char fullname[100];
char clonename[100];
char tag[100];
char osname[MAXNAMELEN];
char osname[ZFS_MAX_DATASET_NAME_LEN];
nvlist_t *holds;
(void) rw_rdlock(&ztest_name_lock);
@ -5450,13 +5460,13 @@ ztest_thread(void *arg)
static void
ztest_dataset_name(char *dsname, char *pool, int d)
{
(void) snprintf(dsname, MAXNAMELEN, "%s/ds_%d", pool, d);
(void) snprintf(dsname, ZFS_MAX_DATASET_NAME_LEN, "%s/ds_%d", pool, d);
}
static void
ztest_dataset_destroy(int d)
{
char name[MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
ztest_dataset_name(name, ztest_opts.zo_pool, d);
@ -5505,7 +5515,7 @@ ztest_dataset_open(int d)
uint64_t committed_seq = ZTEST_GET_SHARED_DS(d)->zd_seq;
objset_t *os;
zilog_t *zilog;
char name[MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
int error;
ztest_dataset_name(name, ztest_opts.zo_pool, d);
@ -5728,8 +5738,8 @@ ztest_run(ztest_shared_t *zs)
* different name.
*/
if (ztest_random(2) == 0) {
char name[MAXNAMELEN];
(void) snprintf(name, MAXNAMELEN, "%s_import",
char name[ZFS_MAX_DATASET_NAME_LEN];
(void) snprintf(name, sizeof (name), "%s_import",
ztest_opts.zo_pool);
ztest_spa_import_export(ztest_opts.zo_pool, name);
ztest_spa_import_export(name, ztest_opts.zo_pool);
@ -6297,7 +6307,7 @@ main(int argc, char **argv)
if (spa_open(ztest_opts.zo_pool, &spa, FTAG) == 0) {
spa_close(spa, FTAG);
} else {
char tmpname[MAXNAMELEN];
char tmpname[ZFS_MAX_DATASET_NAME_LEN];
kernel_fini();
kernel_init(FREAD | FWRITE);
(void) snprintf(tmpname, sizeof (tmpname), "%s_tmp",

View File

@ -26,7 +26,7 @@
#include <solaris.h>
#include <inttypes.h>
#include <unistd.h>
#include <strings.h>
#include <string.h>
#include <libintl.h>
#include <stdarg.h>
#include "libnvpair.h"
@ -1228,7 +1228,8 @@ nvpair_value_match_regex(nvpair_t *nvp, int ai,
break;
}
case DATA_TYPE_BOOLEAN_VALUE: {
boolean_t val, val_arg;
int32_t val_arg;
boolean_t val;
/* scanf boolean_t from value and check for match */
sr = sscanf(value, "%"SCNi32, &val_arg);
@ -1239,7 +1240,8 @@ nvpair_value_match_regex(nvpair_t *nvp, int ai,
break;
}
case DATA_TYPE_BOOLEAN_ARRAY: {
boolean_t *val_array, val_arg;
boolean_t *val_array;
int32_t val_arg;
/* check indexed value of array for match */
sr = sscanf(value, "%"SCNi32, &val_arg);

View File

@ -21,14 +21,13 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved.
* Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
* Copyright 2016 Nexenta Systems, Inc.
*/
#ifndef _LIBZFS_H
@ -52,8 +51,6 @@ extern "C" {
/*
* Miscellaneous ZFS constants
*/
#define ZFS_MAXNAMELEN MAXNAMELEN
#define ZPOOL_MAXNAMELEN MAXNAMELEN
#define ZFS_MAXPROPLEN MAXPATHLEN
#define ZPOOL_MAXPROPLEN MAXPATHLEN
@ -222,6 +219,7 @@ extern void zpool_free_handles(libzfs_handle_t *);
*/
typedef int (*zpool_iter_f)(zpool_handle_t *, void *);
extern int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *);
extern boolean_t zpool_skip_pool(const char *);
/*
* Functions to create and destroy pools
@ -412,6 +410,7 @@ extern void zfs_close(zfs_handle_t *);
extern zfs_type_t zfs_get_type(const zfs_handle_t *);
extern const char *zfs_get_name(const zfs_handle_t *);
extern zpool_handle_t *zfs_get_pool_handle(const zfs_handle_t *);
extern const char *zfs_get_pool_name(const zfs_handle_t *);
/*
* Property management functions. Some functions are shared with the kernel,

View File

@ -24,9 +24,10 @@
* Use is subject to license terms.
*
* Portions Copyright 2007 Ramprakash Jelari
*
* Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved.
* Copyright (c) 2014, 2015 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/
#include <libintl.h>
@ -136,6 +137,9 @@ changelist_prefix(prop_changelist_t *clp)
case ZFS_PROP_SHARESMB:
(void) zfs_unshare_smb(cn->cn_handle, NULL);
break;
default:
break;
}
}
}
@ -293,7 +297,7 @@ void
changelist_rename(prop_changelist_t *clp, const char *src, const char *dst)
{
prop_changenode_t *cn;
char newname[ZFS_MAXNAMELEN];
char newname[ZFS_MAX_DATASET_NAME_LEN];
for (cn = uu_list_first(clp->cl_list); cn != NULL;
cn = uu_list_next(clp->cl_list, cn)) {

View File

@ -27,6 +27,7 @@
/*
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2015 by Syneto S.R.L. All rights reserved.
* Copyright 2016 Nexenta Systems, Inc.
*/
/*
@ -338,33 +339,47 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
}
/*
* If the __ZFS_POOL_RESTRICT environment variable is set we only iterate over
* pools it lists.
* The following environment variables are undocumented
* and should be used for testing purposes only:
*
* This is an undocumented feature for use during testing only.
* __ZFS_POOL_EXCLUDE - don't iterate over the pools it lists
* __ZFS_POOL_RESTRICT - iterate only over the pools it lists
*
* This function returns B_TRUE if the pool should be skipped
* during iteration.
*/
static boolean_t
check_restricted(const char *poolname)
boolean_t
zpool_skip_pool(const char *poolname)
{
static boolean_t initialized = B_FALSE;
static char *restricted = NULL;
static const char *exclude = NULL;
static const char *restricted = NULL;
const char *cur, *end;
int len, namelen;
int len;
int namelen = strlen(poolname);
if (!initialized) {
initialized = B_TRUE;
exclude = getenv("__ZFS_POOL_EXCLUDE");
restricted = getenv("__ZFS_POOL_RESTRICT");
}
if (exclude != NULL) {
cur = exclude;
do {
end = strchr(cur, ' ');
len = (NULL == end) ? strlen(cur) : (end - cur);
if (len == namelen && 0 == strncmp(cur, poolname, len))
return (B_TRUE);
cur += (len + 1);
} while (NULL != end);
}
if (NULL == restricted)
return (B_FALSE);
cur = restricted;
namelen = strlen(poolname);
do {
end = strchr(cur, ' ');
len = (NULL == end) ? strlen(cur) : (end - cur);
@ -402,7 +417,7 @@ zpool_iter(libzfs_handle_t *hdl, zpool_iter_f func, void *data)
for (cn = uu_avl_first(hdl->libzfs_ns_avl); cn != NULL;
cn = uu_avl_next(hdl->libzfs_ns_avl, cn)) {
if (check_restricted(cn->cn_name))
if (zpool_skip_pool(cn->cn_name))
continue;
if (zpool_open_silent(hdl, cn->cn_name, &zhp) != 0) {
@ -440,7 +455,7 @@ zfs_iter_root(libzfs_handle_t *hdl, zfs_iter_f func, void *data)
for (cn = uu_avl_first(hdl->libzfs_ns_avl); cn != NULL;
cn = uu_avl_next(hdl->libzfs_ns_avl, cn)) {
if (check_restricted(cn->cn_name))
if (zpool_skip_pool(cn->cn_name))
continue;
if ((zhp = make_dataset_handle(hdl, cn->cn_name)) == NULL)

View File

@ -24,12 +24,12 @@
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
* Copyright (c) 2011-2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved.
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2011-2012 Pawel Jakub Dawidek. All rights reserved.
* Copyright (c) 2013 Martin Matuska. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
* Copyright 2016 Nexenta Systems, Inc.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/
#include <ctype.h>
@ -79,54 +79,17 @@ zfs_type_to_name(zfs_type_t type)
return (dgettext(TEXT_DOMAIN, "snapshot"));
case ZFS_TYPE_VOLUME:
return (dgettext(TEXT_DOMAIN, "volume"));
case ZFS_TYPE_POOL:
return (dgettext(TEXT_DOMAIN, "pool"));
case ZFS_TYPE_BOOKMARK:
return (dgettext(TEXT_DOMAIN, "bookmark"));
default:
assert(!"unhandled zfs_type_t");
}
return (NULL);
}
/*
* Given a path and mask of ZFS types, return a string describing this dataset.
* This is used when we fail to open a dataset and we cannot get an exact type.
* We guess what the type would have been based on the path and the mask of
* acceptable types.
*/
static const char *
path_to_str(const char *path, int types)
{
/*
* When given a single type, always report the exact type.
*/
if (types == ZFS_TYPE_SNAPSHOT)
return (dgettext(TEXT_DOMAIN, "snapshot"));
if (types == ZFS_TYPE_FILESYSTEM)
return (dgettext(TEXT_DOMAIN, "filesystem"));
if (types == ZFS_TYPE_VOLUME)
return (dgettext(TEXT_DOMAIN, "volume"));
/*
* The user is requesting more than one type of dataset. If this is the
* case, consult the path itself. If we're looking for a snapshot, and
* a '@' is found, then report it as "snapshot". Otherwise, remove the
* snapshot attribute and try again.
*/
if (types & ZFS_TYPE_SNAPSHOT) {
if (strchr(path, '@') != NULL)
return (dgettext(TEXT_DOMAIN, "snapshot"));
return (path_to_str(path, types & ~ZFS_TYPE_SNAPSHOT));
}
/*
* The user has requested either filesystems or volumes.
* We have no way of knowing a priori what type this would be, so always
* report it as "filesystem" or "volume", our two primitive types.
*/
if (types & ZFS_TYPE_FILESYSTEM)
return (dgettext(TEXT_DOMAIN, "filesystem"));
assert(types & ZFS_TYPE_VOLUME);
return (dgettext(TEXT_DOMAIN, "volume"));
}
/*
* Validate a ZFS path. This is used even before trying to open the dataset, to
* provide a more meaningful error message. We call zfs_error_aux() to
@ -188,6 +151,11 @@ zfs_validate_name(libzfs_handle_t *hdl, const char *path, int type,
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"reserved disk name"));
break;
default:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"(%d) not defined"), why);
break;
}
}
@ -586,7 +554,7 @@ zfs_bookmark_exists(const char *path)
{
nvlist_t *bmarks;
nvlist_t *props;
char fsname[ZFS_MAXNAMELEN];
char fsname[ZFS_MAX_DATASET_NAME_LEN];
char *bmark_name;
char *pound;
int err;
@ -770,7 +738,8 @@ libzfs_mnttab_fini(libzfs_handle_t *hdl)
void *cookie = NULL;
mnttab_node_t *mtn;
while (mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie)) {
while ((mtn = avl_destroy_nodes(&hdl->libzfs_mnttab_cache, &cookie))
!= NULL) {
free(mtn->mtn_mt.mnt_special);
free(mtn->mtn_mt.mnt_mountp);
free(mtn->mtn_mt.mnt_fstype);
@ -842,7 +811,8 @@ libzfs_mnttab_remove(libzfs_handle_t *hdl, const char *fsname)
mnttab_node_t *ret;
find.mtn_mt.mnt_special = (char *)fsname;
if (ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL)) {
if ((ret = avl_find(&hdl->libzfs_mnttab_cache, (void *)&find, NULL))
!= NULL) {
avl_remove(&hdl->libzfs_mnttab_cache, ret);
free(ret->mtn_mt.mnt_special);
free(ret->mtn_mt.mnt_mountp);
@ -1194,6 +1164,13 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
"component of '%s' is too long"),
propname);
break;
default:
zfs_error_aux(hdl,
dgettext(TEXT_DOMAIN,
"(%d) not defined"),
why);
break;
}
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
goto error;
@ -1312,12 +1289,17 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
}
break;
case ZFS_PROP_UTF8ONLY:
chosen_utf = (int)intval;
break;
case ZFS_PROP_NORMALIZE:
chosen_normal = (int)intval;
break;
default:
break;
}
/*
@ -1366,6 +1348,9 @@ zfs_valid_proplist(libzfs_handle_t *hdl, zfs_type_t type, nvlist_t *nvl,
goto error;
}
break;
default:
break;
}
}
}
@ -1585,7 +1570,7 @@ zfs_prop_set_list(zfs_handle_t *zhp, nvlist_t *props)
libzfs_handle_t *hdl = zhp->zfs_hdl;
nvlist_t *nvl;
int nvl_len;
int added_resv;
int added_resv = 0;
(void) snprintf(errbuf, sizeof (errbuf),
dgettext(TEXT_DOMAIN, "cannot set property for '%s'"),
@ -1975,6 +1960,9 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t prop, zprop_source_t *src,
mntopt_on = MNTOPT_NBMAND;
mntopt_off = MNTOPT_NONBMAND;
break;
default:
break;
}
/*
@ -2193,7 +2181,7 @@ struct get_clones_arg {
uint64_t numclones;
nvlist_t *value;
const char *origin;
char buf[ZFS_MAXNAMELEN];
char buf[ZFS_MAX_DATASET_NAME_LEN];
};
int
@ -2248,7 +2236,7 @@ zfs_get_clones_nvl(zfs_handle_t *zhp)
if (gca.numclones != 0) {
zfs_handle_t *root;
char pool[ZFS_MAXNAMELEN];
char pool[ZFS_MAX_DATASET_NAME_LEN];
char *cp = pool;
/* get the pool name */
@ -2962,6 +2950,15 @@ zfs_get_name(const zfs_handle_t *zhp)
return (zhp->zfs_name);
}
/*
* Returns the name of the parent pool for the given zfs handle.
*/
const char *
zfs_get_pool_name(const zfs_handle_t *zhp)
{
return (zhp->zpool_hdl->zpool_name);
}
/*
* Returns the type of the given zfs handle.
*/
@ -3024,7 +3021,7 @@ check_parents(libzfs_handle_t *hdl, const char *path, uint64_t *zoned,
boolean_t accept_ancestor, int *prefixlen)
{
zfs_cmd_t zc = { 0 };
char parent[ZFS_MAXNAMELEN];
char parent[ZFS_MAX_DATASET_NAME_LEN];
char *slash;
zfs_handle_t *zhp;
char errbuf[1024];
@ -3152,7 +3149,7 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
* up to the prefixlen-long one.
*/
for (cp = target + prefixlen + 1;
cp = strchr(cp, '/'); *cp = '/', cp++) {
(cp = strchr(cp, '/')) != NULL; *cp = '/', cp++) {
*cp = '\0';
@ -3204,7 +3201,7 @@ zfs_create_ancestors(libzfs_handle_t *hdl, const char *path)
{
int prefix;
char *path_copy;
int rc;
int rc = 0;
if (check_parents(hdl, path, NULL, B_TRUE, &prefix) != 0)
return (-1);
@ -3263,7 +3260,7 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type,
ost = LZC_DATSET_TYPE_ZFS;
/* open zpool handle for prop validation */
char pool_path[MAXNAMELEN];
char pool_path[ZFS_MAX_DATASET_NAME_LEN];
(void) strlcpy(pool_path, path, sizeof (pool_path));
/* truncate pool_path at first slash */
@ -3332,7 +3329,7 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type,
/* check for failure */
if (ret != 0) {
char parent[ZFS_MAXNAMELEN];
char parent[ZFS_MAX_DATASET_NAME_LEN];
(void) parent_name(path, parent, sizeof (parent));
switch (errno) {
@ -3422,7 +3419,7 @@ static int
zfs_check_snap_cb(zfs_handle_t *zhp, void *arg)
{
struct destroydata *dd = arg;
char name[ZFS_MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
int rv = 0;
(void) snprintf(name, sizeof (name),
@ -3467,12 +3464,14 @@ int
zfs_destroy_snaps_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, boolean_t defer)
{
int ret;
nvlist_t *errlist;
nvlist_t *errlist = NULL;
ret = lzc_destroy_snaps(snaps, defer, &errlist);
if (ret == 0)
if (ret == 0) {
nvlist_free(errlist);
return (0);
}
if (nvlist_empty(errlist)) {
char errbuf[1024];
@ -3500,6 +3499,7 @@ zfs_destroy_snaps_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, boolean_t defer)
}
}
nvlist_free(errlist);
return (ret);
}
@ -3509,7 +3509,7 @@ zfs_destroy_snaps_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, boolean_t defer)
int
zfs_clone(zfs_handle_t *zhp, const char *target, nvlist_t *props)
{
char parent[ZFS_MAXNAMELEN];
char parent[ZFS_MAX_DATASET_NAME_LEN];
int ret;
char errbuf[1024];
libzfs_handle_t *hdl = zhp->zfs_hdl;
@ -3639,7 +3639,7 @@ static int
zfs_snapshot_cb(zfs_handle_t *zhp, void *arg)
{
snapdata_t *sd = arg;
char name[ZFS_MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
int rv = 0;
if (zfs_prop_get_int(zhp, ZFS_PROP_INCONSISTENT) == 0) {
@ -3688,7 +3688,7 @@ zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, nvlist_t *props)
* get pool handle for prop validation. assumes all snaps are in the
* same pool, as does lzc_snapshot (below).
*/
char pool[MAXNAMELEN];
char pool[ZFS_MAX_DATASET_NAME_LEN];
elem = nvlist_next_nvpair(snaps, NULL);
(void) strlcpy(pool, nvpair_name(elem), sizeof (pool));
pool[strcspn(pool, "/@")] = '\0';
@ -3742,7 +3742,7 @@ zfs_snapshot(libzfs_handle_t *hdl, const char *path, boolean_t recursive,
{
int ret;
snapdata_t sd = { 0 };
char fsname[ZFS_MAXNAMELEN];
char fsname[ZFS_MAX_DATASET_NAME_LEN];
char *cp;
zfs_handle_t *zhp;
char errbuf[1024];
@ -3843,7 +3843,7 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force)
rollback_data_t cb = { 0 };
int err;
boolean_t restore_resv = 0;
uint64_t old_volsize, new_volsize;
uint64_t old_volsize = 0, new_volsize;
zfs_prop_t resv_prop;
assert(zhp->zfs_type == ZFS_TYPE_FILESYSTEM ||
@ -3915,13 +3915,13 @@ int
zfs_rename(zfs_handle_t *zhp, const char *source, const char *target,
renameflags_t flags)
{
int ret;
int ret = 0;
zfs_cmd_t zc = { 0 };
char *delim;
prop_changelist_t *cl = NULL;
zfs_handle_t *zhrp = NULL;
char *parentname = NULL;
char parent[ZFS_MAXNAMELEN];
char parent[ZFS_MAX_DATASET_NAME_LEN];
char property[ZFS_MAXPROPLEN];
libzfs_handle_t *hdl = zhp->zfs_hdl;
char errbuf[1024];
@ -4060,6 +4060,7 @@ zfs_rename(zfs_handle_t *zhp, const char *source, const char *target,
"child dataset with inherited mountpoint is used "
"in a non-global zone"));
(void) zfs_error(hdl, EZFS_ZONED, errbuf);
ret = -1;
goto error;
}
@ -4434,7 +4435,7 @@ static int
zfs_hold_one(zfs_handle_t *zhp, void *arg)
{
struct holdarg *ha = arg;
char name[ZFS_MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
int rv = 0;
(void) snprintf(name, sizeof (name),
@ -4553,7 +4554,7 @@ static int
zfs_release_one(zfs_handle_t *zhp, void *arg)
{
struct holdarg *ha = arg;
char name[ZFS_MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
int rv = 0;
nvlist_t *existing_holds;
@ -4682,7 +4683,7 @@ zfs_get_fsacl(zfs_handle_t *zhp, nvlist_t **nvl)
zc.zc_nvlist_dst_size = nvsz;
zc.zc_nvlist_dst = (uintptr_t)nvbuf;
(void) strlcpy(zc.zc_name, zhp->zfs_name, ZFS_MAXNAMELEN);
(void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
if (ioctl(hdl->libzfs_fd, ZFS_IOC_GET_FSACL, &zc) != 0) {
(void) snprintf(errbuf, sizeof (errbuf),

View File

@ -22,7 +22,9 @@
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2015 by Delphix. All rights reserved.
* Copyright 2016 Joyent, Inc.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/
/*
@ -353,7 +355,7 @@ write_inuse_diffs(FILE *fp, differ_info_t *di, dmu_diff_record_t *dr)
int err;
for (o = dr->ddr_first; o <= dr->ddr_last; o++) {
if (err = write_inuse_diffs_one(fp, di, o))
if ((err = write_inuse_diffs_one(fp, di, o)) != 0)
return (err);
}
return (0);
@ -617,7 +619,7 @@ get_snapshot_names(differ_info_t *di, const char *fromsnap,
* not the same dataset name, might be okay if
* tosnap is a clone of a fromsnap descendant.
*/
char origin[ZFS_MAXNAMELEN];
char origin[ZFS_MAX_DATASET_NAME_LEN];
zprop_source_t src;
zfs_handle_t *zhp;

View File

@ -21,20 +21,19 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
*/
#ifndef _LIBZFS_IMPL_H
#define _LIBZFS_IMPL_H
#include <sys/dmu.h>
#include <sys/fs/zfs.h>
#include <sys/zfs_ioctl.h>
#include <sys/spa.h>
#include <sys/nvpair.h>
#include <sys/dmu.h>
#include <sys/zfs_ioctl.h>
#include <libshare.h>
#include <libuutil.h>
@ -87,7 +86,7 @@ struct libzfs_handle {
struct zfs_handle {
libzfs_handle_t *zfs_hdl;
zpool_handle_t *zpool_hdl;
char zfs_name[ZFS_MAXNAMELEN];
char zfs_name[ZFS_MAX_DATASET_NAME_LEN];
zfs_type_t zfs_type; /* type including snapshot */
zfs_type_t zfs_head_type; /* type excluding snapshot */
dmu_objset_stats_t zfs_dmustats;
@ -108,7 +107,7 @@ struct zfs_handle {
struct zpool_handle {
libzfs_handle_t *zpool_hdl;
zpool_handle_t *zpool_next;
char zpool_name[ZPOOL_MAXNAMELEN];
char zpool_name[ZFS_MAX_DATASET_NAME_LEN];
int zpool_state;
size_t zpool_config_size;
nvlist_t *zpool_config;

View File

@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
* Copyright 2015 RackTop Systems.
* Copyright 2016 Nexenta Systems, Inc.
*/
@ -440,12 +440,12 @@ get_configs(libzfs_handle_t *hdl, pool_list_t *pl, boolean_t active_ok)
pool_entry_t *pe;
vdev_entry_t *ve;
config_entry_t *ce;
nvlist_t *ret = NULL, *config = NULL, *tmp, *nvtop, *nvroot;
nvlist_t *ret = NULL, *config = NULL, *tmp = NULL, *nvtop, *nvroot;
nvlist_t **spares, **l2cache;
uint_t i, nspares, nl2cache;
boolean_t config_seen;
uint64_t best_txg;
char *name, *hostname;
char *name, *hostname = NULL;
uint64_t guid;
uint_t children = 0;
nvlist_t **child = NULL;

View File

@ -22,8 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2015 by Delphix. All rights reserved.
* Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved.
* Copyright (c) 2012 Pawel Jakub Dawidek. All rights reserved.
* Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
@ -198,7 +197,7 @@ zfs_iter_bookmarks(zfs_handle_t *zhp, zfs_iter_f func, void *data)
for (nvpair_t *pair = nvlist_next_nvpair(bmarks, NULL);
pair != NULL; pair = nvlist_next_nvpair(bmarks, pair)) {
char name[ZFS_MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
char *bmark_name;
nvlist_t *bmark_props;
@ -386,7 +385,7 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig,
* exists.
*/
if (ssa.ssa_last[0] != '\0') {
char snapname[ZFS_MAXNAMELEN];
char snapname[ZFS_MAX_DATASET_NAME_LEN];
(void) snprintf(snapname, sizeof (snapname),
"%s@%s", zfs_get_name(fs_zhp),
ssa.ssa_last);
@ -406,7 +405,7 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig,
ret = ENOENT;
}
} else {
char snapname[ZFS_MAXNAMELEN];
char snapname[ZFS_MAX_DATASET_NAME_LEN];
zfs_handle_t *snap_zhp;
(void) snprintf(snapname, sizeof (snapname), "%s@%s",
zfs_get_name(fs_zhp), comma_separated);

View File

@ -22,6 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/
/*
@ -235,7 +236,7 @@ static boolean_t
zfs_is_mountable(zfs_handle_t *zhp, char *buf, size_t buflen,
zprop_source_t *source)
{
char sourceloc[ZFS_MAXNAMELEN];
char sourceloc[MAXNAMELEN];
zprop_source_t sourcetype;
if (!zfs_prop_valid_for_type(ZFS_PROP_MOUNTPOINT, zhp->zfs_type))
@ -475,7 +476,8 @@ zfs_is_shared_proto(zfs_handle_t *zhp, char **where, zfs_share_proto_t proto)
if (!zfs_is_mounted(zhp, &mountpoint))
return (SHARED_NOT_SHARED);
if (rc = is_shared(zhp->zfs_hdl, mountpoint, proto)) {
if ((rc = is_shared(zhp->zfs_hdl, mountpoint, proto))
!= SHARED_NOT_SHARED) {
if (where != NULL)
*where = mountpoint;
else

View File

@ -24,6 +24,7 @@
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright 2016 Nexenta Systems, Inc.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/
#include <sys/types.h>
@ -199,6 +200,9 @@ zpool_state_to_name(vdev_state_t state, vdev_aux_t aux)
return (gettext("DEGRADED"));
case VDEV_STATE_HEALTHY:
return (gettext("ONLINE"));
default:
break;
}
return (gettext("UNKNOWN"));
@ -403,7 +407,7 @@ bootfs_name_valid(const char *pool, char *bootfs)
boolean_t
zpool_is_bootable(zpool_handle_t *zhp)
{
char bootfs[ZPOOL_MAXNAMELEN];
char bootfs[ZFS_MAX_DATASET_NAME_LEN];
return (zpool_get_prop(zhp, ZPOOL_PROP_BOOTFS, bootfs,
sizeof (bootfs), NULL, B_FALSE) == 0 && strncmp(bootfs, "-",
@ -635,6 +639,11 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
goto error;
}
break;
default:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property '%s'(%d) not defined"), propname, prop);
break;
}
}
@ -943,6 +952,10 @@ zpool_name_valid(libzfs_handle_t *hdl, boolean_t isopen, const char *pool)
"multiple '@' delimiters in name"));
break;
default:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"(%d) not defined"), why);
break;
}
}
return (B_FALSE);
@ -1786,7 +1799,12 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname,
case EEXIST:
(void) zpool_standard_error(hdl, error, desc);
break;
case ENAMETOOLONG:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"new name of at least one dataset is longer than "
"the maximum allowable length"));
(void) zfs_error(hdl, EZFS_NAMETOOLONG, desc);
break;
default:
(void) zpool_standard_error(hdl, error, desc);
zpool_explain_recover(hdl,
@ -3785,7 +3803,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
zfs_cmd_t zc = { 0 };
boolean_t mounted = B_FALSE;
char *mntpnt = NULL;
char dsname[MAXNAMELEN];
char dsname[ZFS_MAX_DATASET_NAME_LEN];
if (dsobj == 0) {
/* special case for the MOS */
@ -4046,7 +4064,7 @@ zvol_check_dump_config(char *arg)
uint_t toplevels;
libzfs_handle_t *hdl;
char errbuf[1024];
char poolname[ZPOOL_MAXNAMELEN];
char poolname[ZFS_MAX_DATASET_NAME_LEN];
int pathlen = strlen(ZVOL_FULL_DEV_DIR);
int ret = 1;
@ -4069,7 +4087,7 @@ zvol_check_dump_config(char *arg)
"malformed dataset name"));
(void) zfs_error(hdl, EZFS_INVALIDNAME, errbuf);
return (1);
} else if (p - volname >= ZFS_MAXNAMELEN) {
} else if (p - volname >= ZFS_MAX_DATASET_NAME_LEN) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"dataset name is too long"));
(void) zfs_error(hdl, EZFS_NAMETOOLONG, errbuf);

View File

@ -23,11 +23,11 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright (c) 2012 Pawel Jakub Dawidek <pawel@dawidek.net>.
* All rights reserved.
* Copyright (c) 2012 Pawel Jakub Dawidek. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
* Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/
#include <assert.h>
@ -580,13 +580,30 @@ fsavl_create(nvlist_t *fss)
* Routines for dealing with the giant nvlist of fs-nvlists, etc.
*/
typedef struct send_data {
/*
* assigned inside every recursive call,
* restored from *_save on return:
*
* guid of fromsnap snapshot in parent dataset
* txg of fromsnap snapshot in current dataset
* txg of tosnap snapshot in current dataset
*/
uint64_t parent_fromsnap_guid;
uint64_t fromsnap_txg;
uint64_t tosnap_txg;
/* the nvlists get accumulated during depth-first traversal */
nvlist_t *parent_snaps;
nvlist_t *fss;
nvlist_t *snapprops;
/* send-receive configuration, does not change during traversal */
const char *fsname;
const char *fromsnap;
const char *tosnap;
boolean_t recursive;
boolean_t verbose;
/*
* The header nvlist is of the following format:
@ -619,11 +636,23 @@ send_iterate_snap(zfs_handle_t *zhp, void *arg)
{
send_data_t *sd = arg;
uint64_t guid = zhp->zfs_dmustats.dds_guid;
uint64_t txg = zhp->zfs_dmustats.dds_creation_txg;
char *snapname;
nvlist_t *nv;
snapname = strrchr(zhp->zfs_name, '@')+1;
if (sd->tosnap_txg != 0 && txg > sd->tosnap_txg) {
if (sd->verbose) {
(void) fprintf(stderr, dgettext(TEXT_DOMAIN,
"skipping snapshot %s because it was created "
"after the destination snapshot (%s)\n"),
zhp->zfs_name, sd->tosnap);
}
zfs_close(zhp);
return (0);
}
VERIFY(0 == nvlist_add_uint64(sd->parent_snaps, snapname, guid));
/*
* NB: if there is no fromsnap here (it's a newly created fs in
@ -716,6 +745,31 @@ send_iterate_prop(zfs_handle_t *zhp, nvlist_t *nv)
}
}
/*
* returns snapshot creation txg
* and returns 0 if the snapshot does not exist
*/
static uint64_t
get_snap_txg(libzfs_handle_t *hdl, const char *fs, const char *snap)
{
char name[ZFS_MAX_DATASET_NAME_LEN];
uint64_t txg = 0;
if (fs == NULL || fs[0] == '\0' || snap == NULL || snap[0] == '\0')
return (txg);
(void) snprintf(name, sizeof (name), "%s@%s", fs, snap);
if (zfs_dataset_exists(hdl, name, ZFS_TYPE_SNAPSHOT)) {
zfs_handle_t *zhp = zfs_open(hdl, name, ZFS_TYPE_SNAPSHOT);
if (zhp != NULL) {
txg = zfs_prop_get_int(zhp, ZFS_PROP_CREATETXG);
zfs_close(zhp);
}
}
return (txg);
}
/*
* recursively generate nvlists describing datasets. See comment
* for the data structure send_data_t above for description of contents
@ -728,9 +782,48 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg)
nvlist_t *nvfs, *nv;
int rv = 0;
uint64_t parent_fromsnap_guid_save = sd->parent_fromsnap_guid;
uint64_t fromsnap_txg_save = sd->fromsnap_txg;
uint64_t tosnap_txg_save = sd->tosnap_txg;
uint64_t txg = zhp->zfs_dmustats.dds_creation_txg;
uint64_t guid = zhp->zfs_dmustats.dds_guid;
uint64_t fromsnap_txg, tosnap_txg;
char guidstring[64];
fromsnap_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name, sd->fromsnap);
if (fromsnap_txg != 0)
sd->fromsnap_txg = fromsnap_txg;
tosnap_txg = get_snap_txg(zhp->zfs_hdl, zhp->zfs_name, sd->tosnap);
if (tosnap_txg != 0)
sd->tosnap_txg = tosnap_txg;
/*
* on the send side, if the current dataset does not have tosnap,
* perform two additional checks:
*
* - skip sending the current dataset if it was created later than
* the parent tosnap
* - return error if the current dataset was created earlier than
* the parent tosnap
*/
if (sd->tosnap != NULL && tosnap_txg == 0) {
if (sd->tosnap_txg != 0 && txg > sd->tosnap_txg) {
if (sd->verbose) {
(void) fprintf(stderr, dgettext(TEXT_DOMAIN,
"skipping dataset %s: snapshot %s does "
"not exist\n"), zhp->zfs_name, sd->tosnap);
}
} else {
(void) fprintf(stderr, dgettext(TEXT_DOMAIN,
"cannot send %s@%s%s: snapshot %s@%s does not "
"exist\n"), sd->fsname, sd->tosnap, sd->recursive ?
dgettext(TEXT_DOMAIN, " recursively") : "",
zhp->zfs_name, sd->tosnap);
rv = -1;
}
goto out;
}
VERIFY(0 == nvlist_alloc(&nvfs, NV_UNIQUE_NAME, 0));
VERIFY(0 == nvlist_add_string(nvfs, "name", zhp->zfs_name));
VERIFY(0 == nvlist_add_uint64(nvfs, "parentfromsnap",
@ -739,8 +832,10 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg)
if (zhp->zfs_dmustats.dds_origin[0]) {
zfs_handle_t *origin = zfs_open(zhp->zfs_hdl,
zhp->zfs_dmustats.dds_origin, ZFS_TYPE_SNAPSHOT);
if (origin == NULL)
return (-1);
if (origin == NULL) {
rv = -1;
goto out;
}
VERIFY(0 == nvlist_add_uint64(nvfs, "origin",
origin->zfs_dmustats.dds_guid));
}
@ -771,7 +866,10 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg)
if (sd->recursive)
rv = zfs_iter_filesystems(zhp, send_iterate_fs, sd);
out:
sd->parent_fromsnap_guid = parent_fromsnap_guid_save;
sd->fromsnap_txg = fromsnap_txg_save;
sd->tosnap_txg = tosnap_txg_save;
zfs_close(zhp);
return (rv);
@ -779,7 +877,8 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg)
static int
gather_nvlist(libzfs_handle_t *hdl, const char *fsname, const char *fromsnap,
const char *tosnap, boolean_t recursive, nvlist_t **nvlp, avl_tree_t **avlp)
const char *tosnap, boolean_t recursive, boolean_t verbose,
nvlist_t **nvlp, avl_tree_t **avlp)
{
zfs_handle_t *zhp;
send_data_t sd = { 0 };
@ -790,9 +889,11 @@ gather_nvlist(libzfs_handle_t *hdl, const char *fsname, const char *fromsnap,
return (EZFS_BADTYPE);
VERIFY(0 == nvlist_alloc(&sd.fss, NV_UNIQUE_NAME, 0));
sd.fsname = fsname;
sd.fromsnap = fromsnap;
sd.tosnap = tosnap;
sd.recursive = recursive;
sd.verbose = verbose;
if ((error = send_iterate_fs(zhp, &sd)) != 0) {
nvlist_free(sd.fss);
@ -819,7 +920,7 @@ typedef struct send_dump_data {
/* these are all just the short snapname (the part after the @) */
const char *fromsnap;
const char *tosnap;
char prevsnap[ZFS_MAXNAMELEN];
char prevsnap[ZFS_MAX_DATASET_NAME_LEN];
uint64_t prevsnap_obj;
boolean_t seenfrom, seento, replicate, doall, fromorigin;
boolean_t verbose, dryrun, parsable, progress, embed_data, std_out;
@ -832,7 +933,7 @@ typedef struct send_dump_data {
snapfilter_cb_t *filter_cb;
void *filter_cb_arg;
nvlist_t *debugnv;
char holdtag[ZFS_MAXNAMELEN];
char holdtag[ZFS_MAX_DATASET_NAME_LEN];
int cleanup_fd;
uint64_t size;
} send_dump_data_t;
@ -1183,8 +1284,8 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
pa.pa_fd = sdd->outfd;
pa.pa_parsable = sdd->parsable;
if (err = pthread_create(&tid, NULL,
send_progress_thread, &pa)) {
if ((err = pthread_create(&tid, NULL,
send_progress_thread, &pa)) != 0) {
zfs_close(zhp);
return (err);
}
@ -1468,7 +1569,7 @@ zfs_send_resume(libzfs_handle_t *hdl, sendflags_t *flags, int outfd,
uint64_t resumeobj, resumeoff, toguid, fromguid, bytes;
zfs_handle_t *zhp;
int error = 0;
char name[ZFS_MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
enum lzc_send_flags lzc_flags = 0;
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
@ -1662,7 +1763,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
if (flags->dedup && !flags->dryrun) {
featureflags |= (DMU_BACKUP_FEATURE_DEDUP |
DMU_BACKUP_FEATURE_DEDUPPROPS);
if (err = pipe(pipefd)) {
if ((err = pipe(pipefd)) != 0) {
zfs_error_aux(zhp->zfs_hdl, strerror(errno));
return (zfs_error(zhp->zfs_hdl, EZFS_PIPEFAILED,
errbuf));
@ -1670,7 +1771,7 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
dda.outputfd = outfd;
dda.inputfd = pipefd[1];
dda.dedup_hdl = zhp->zfs_hdl;
if (err = pthread_create(&tid, NULL, cksummer, &dda)) {
if ((err = pthread_create(&tid, NULL, cksummer, &dda)) != 0) {
(void) close(pipefd[0]);
(void) close(pipefd[1]);
zfs_error_aux(zhp->zfs_hdl, strerror(errno));
@ -1700,7 +1801,8 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
}
err = gather_nvlist(zhp->zfs_hdl, zhp->zfs_name,
fromsnap, tosnap, flags->replicate, &fss, &fsavl);
fromsnap, tosnap, flags->replicate, flags->verbose,
&fss, &fsavl);
if (err)
goto err_out;
VERIFY(0 == nvlist_add_nvlist(hdrnv, "fss", fss));
@ -2061,8 +2163,8 @@ recv_rename(libzfs_handle_t *hdl, const char *name, const char *tryname,
if (err != 0 && strncmp(name + baselen, "recv-", 5) != 0) {
seq++;
(void) snprintf(newname, ZFS_MAXNAMELEN, "%.*srecv-%u-%u",
baselen, name, getpid(), seq);
(void) snprintf(newname, ZFS_MAX_DATASET_NAME_LEN,
"%.*srecv-%u-%u", baselen, name, getpid(), seq);
(void) strlcpy(zc.zc_value, newname, sizeof (zc.zc_value));
if (flags->verbose) {
@ -2190,7 +2292,7 @@ static int
guid_to_name(libzfs_handle_t *hdl, const char *parent, uint64_t guid,
boolean_t bookmark_ok, char *name)
{
char pname[ZFS_MAXNAMELEN];
char pname[ZFS_MAX_DATASET_NAME_LEN];
guid_to_name_data_t gtnd;
gtnd.guid = guid;
@ -2245,7 +2347,7 @@ created_before(libzfs_handle_t *hdl, avl_tree_t *avl,
{
nvlist_t *nvfs;
char *fsname, *snapname;
char buf[ZFS_MAXNAMELEN];
char buf[ZFS_MAX_DATASET_NAME_LEN];
int rv;
zfs_handle_t *guid1hdl, *guid2hdl;
uint64_t create1, create2;
@ -2296,7 +2398,7 @@ recv_incremental_replication(libzfs_handle_t *hdl, const char *tofs,
avl_tree_t *local_avl;
nvpair_t *fselem, *nextfselem;
char *fromsnap;
char newname[ZFS_MAXNAMELEN];
char newname[ZFS_MAX_DATASET_NAME_LEN];
char guidname[32];
int error;
boolean_t needagain, progress, recursive;
@ -2316,7 +2418,7 @@ recv_incremental_replication(libzfs_handle_t *hdl, const char *tofs,
VERIFY(0 == nvlist_alloc(&deleted, NV_UNIQUE_NAME, 0));
if ((error = gather_nvlist(hdl, tofs, fromsnap, NULL,
recursive, &local_nv, &local_avl)) != 0)
recursive, B_FALSE, &local_nv, &local_avl)) != 0)
return (error);
/*
@ -2415,7 +2517,7 @@ recv_incremental_replication(libzfs_handle_t *hdl, const char *tofs,
/* check for delete */
if (found == NULL) {
char name[ZFS_MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
if (!flags->force)
continue;
@ -2455,8 +2557,8 @@ recv_incremental_replication(libzfs_handle_t *hdl, const char *tofs,
/* check for different snapname */
if (strcmp(nvpair_name(snapelem),
stream_snapname) != 0) {
char name[ZFS_MAXNAMELEN];
char tryname[ZFS_MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
char tryname[ZFS_MAX_DATASET_NAME_LEN];
(void) snprintf(name, sizeof (name), "%s@%s",
fsname, nvpair_name(snapelem));
@ -2538,7 +2640,7 @@ recv_incremental_replication(libzfs_handle_t *hdl, const char *tofs,
((flags->isprefix || strcmp(tofs, fsname) != 0) &&
(s1 != NULL) && (s2 != NULL) && strcmp(s1, s2) != 0)) {
nvlist_t *parent;
char tryname[ZFS_MAXNAMELEN];
char tryname[ZFS_MAX_DATASET_NAME_LEN];
parent = fsavl_find(local_avl,
stream_parent_fromsnap_guid, NULL);
@ -2606,8 +2708,8 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
char *fromsnap = NULL;
char *sendsnap = NULL;
char *cp;
char tofs[ZFS_MAXNAMELEN];
char sendfs[ZFS_MAXNAMELEN];
char tofs[ZFS_MAX_DATASET_NAME_LEN];
char sendfs[ZFS_MAX_DATASET_NAME_LEN];
char errbuf[1024];
dmu_replay_record_t drre;
int error;
@ -2691,7 +2793,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
nvlist_t *renamed = NULL;
nvpair_t *pair = NULL;
(void) strlcpy(tofs, destname, ZFS_MAXNAMELEN);
(void) strlcpy(tofs, destname, sizeof (tofs));
if (flags->isprefix) {
struct drr_begin *drrb = &drr->drr_u.drr_begin;
int i;
@ -2700,7 +2802,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
cp = strrchr(drrb->drr_toname, '/');
if (cp == NULL) {
(void) strlcat(tofs, "/",
ZFS_MAXNAMELEN);
sizeof (tofs));
i = 0;
} else {
i = (cp - drrb->drr_toname);
@ -2710,7 +2812,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
}
/* zfs_receive_one() will create_parents() */
(void) strlcat(tofs, &drrb->drr_toname[i],
ZFS_MAXNAMELEN);
sizeof (tofs));
*strchr(tofs, '@') = '\0';
}
@ -2752,7 +2854,7 @@ zfs_receive_package(libzfs_handle_t *hdl, int fd, const char *destname,
* zfs_receive_one().
*/
(void) strlcpy(sendfs, drr->drr_u.drr_begin.drr_toname,
ZFS_MAXNAMELEN);
sizeof (sendfs));
if ((cp = strchr(sendfs, '@')) != NULL) {
*cp = '\0';
/*
@ -2866,7 +2968,7 @@ recv_skip(libzfs_handle_t *hdl, int fd, boolean_t byteswap)
break;
case DRR_SPILL:
if (byteswap) {
drr->drr_u.drr_write.drr_length =
drr->drr_u.drr_spill.drr_length =
BSWAP_64(drr->drr_u.drr_spill.drr_length);
}
(void) recv_read(hdl, fd, buf,
@ -2902,7 +3004,7 @@ static void
recv_ecksum_set_aux(libzfs_handle_t *hdl, const char *target_snap,
boolean_t resumable)
{
char target_fs[ZFS_MAXNAMELEN];
char target_fs[ZFS_MAX_DATASET_NAME_LEN];
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"checksum mismatch or incomplete stream"));
@ -3105,7 +3207,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
if (flags->verbose)
(void) printf("found clone origin %s\n", zc.zc_string);
} else if (originsnap) {
(void) strncpy(zc.zc_string, originsnap, ZFS_MAXNAMELEN);
(void) strncpy(zc.zc_string, originsnap, sizeof (zc.zc_string));
if (flags->verbose)
(void) printf("using provided clone origin %s\n",
zc.zc_string);
@ -3130,7 +3232,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
*cp = '\0';
if (cp &&
!zfs_dataset_exists(hdl, zc.zc_name, ZFS_TYPE_DATASET)) {
char suffix[ZFS_MAXNAMELEN];
char suffix[ZFS_MAX_DATASET_NAME_LEN];
(void) strcpy(suffix, strrchr(zc.zc_value, '/'));
if (guid_to_name(hdl, zc.zc_name, parent_snapguid,
B_FALSE, zc.zc_value) == 0) {
@ -3157,7 +3259,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
if ((flags->isprefix || (*(chopprefix = drrb->drr_toname +
strlen(sendfs)) != '\0' && *chopprefix != '@')) &&
!zfs_dataset_exists(hdl, zc.zc_name, ZFS_TYPE_DATASET)) {
char snap[ZFS_MAXNAMELEN];
char snap[ZFS_MAX_DATASET_NAME_LEN];
(void) strcpy(snap, strchr(zc.zc_value, '@'));
if (guid_to_name(hdl, zc.zc_name, drrb->drr_fromguid,
B_FALSE, zc.zc_value) == 0) {
@ -3380,7 +3482,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
*/
*cp = '\0';
if (gather_nvlist(hdl, zc.zc_value, NULL, NULL, B_FALSE,
&local_nv, &local_avl) == 0) {
B_FALSE, &local_nv, &local_avl) == 0) {
*cp = '@';
fs = fsavl_find(local_avl, drrb->drr_toguid, NULL);
fsavl_destroy(local_avl);
@ -3607,7 +3709,7 @@ zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap,
}
if (DMU_GET_STREAM_HDRTYPE(drrb->drr_versioninfo) == DMU_SUBSTREAM) {
char nonpackage_sendfs[ZFS_MAXNAMELEN];
char nonpackage_sendfs[ZFS_MAX_DATASET_NAME_LEN];
if (sendfs == NULL) {
/*
* We were not called from zfs_receive_package(). Get
@ -3615,7 +3717,8 @@ zfs_receive_impl(libzfs_handle_t *hdl, const char *tosnap,
*/
char *cp;
(void) strlcpy(nonpackage_sendfs,
drr.drr_u.drr_begin.drr_toname, ZFS_MAXNAMELEN);
drr.drr_u.drr_begin.drr_toname,
sizeof (nonpackage_sendfs));
if ((cp = strchr(nonpackage_sendfs, '@')) != NULL)
*cp = '\0';
sendfs = nonpackage_sendfs;

View File

@ -23,6 +23,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/
/*
@ -1010,7 +1011,7 @@ zprop_print_one_property(const char *name, zprop_get_cbdata_t *cbp,
const char *source, const char *recvd_value)
{
int i;
const char *str;
const char *str = NULL;
char buf[128];
/*
@ -1062,6 +1063,10 @@ zprop_print_one_property(const char *name, zprop_get_cbdata_t *cbp,
case ZPROP_SRC_RECEIVED:
str = "received";
break;
default:
str = NULL;
assert(!"unhandled zprop_source_t");
}
break;

View File

@ -265,7 +265,7 @@ lzc_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t **errlist)
nvpair_t *elem;
nvlist_t *args;
int error;
char pool[MAXNAMELEN];
char pool[ZFS_MAX_DATASET_NAME_LEN];
*errlist = NULL;
@ -317,7 +317,7 @@ lzc_destroy_snaps(nvlist_t *snaps, boolean_t defer, nvlist_t **errlist)
nvpair_t *elem;
nvlist_t *args;
int error;
char pool[MAXNAMELEN];
char pool[ZFS_MAX_DATASET_NAME_LEN];
/* determine the pool name */
elem = nvlist_next_nvpair(snaps, NULL);
@ -344,7 +344,7 @@ lzc_snaprange_space(const char *firstsnap, const char *lastsnap,
nvlist_t *args;
nvlist_t *result;
int err;
char fs[MAXNAMELEN];
char fs[ZFS_MAX_DATASET_NAME_LEN];
char *atp;
/* determine the fs name */
@ -409,7 +409,7 @@ lzc_exists(const char *dataset)
int
lzc_hold(nvlist_t *holds, int cleanup_fd, nvlist_t **errlist)
{
char pool[MAXNAMELEN];
char pool[ZFS_MAX_DATASET_NAME_LEN];
nvlist_t *args;
nvpair_t *elem;
int error;
@ -456,7 +456,7 @@ lzc_hold(nvlist_t *holds, int cleanup_fd, nvlist_t **errlist)
int
lzc_release(nvlist_t *holds, nvlist_t **errlist)
{
char pool[MAXNAMELEN];
char pool[ZFS_MAX_DATASET_NAME_LEN];
nvpair_t *elem;
/* determine the pool name */
@ -743,7 +743,7 @@ lzc_bookmark(nvlist_t *bookmarks, nvlist_t **errlist)
{
nvpair_t *elem;
int error;
char pool[MAXNAMELEN];
char pool[ZFS_MAX_DATASET_NAME_LEN];
/* determine the pool name */
elem = nvlist_next_nvpair(bookmarks, NULL);
@ -805,7 +805,7 @@ lzc_destroy_bookmarks(nvlist_t *bmarks, nvlist_t **errlist)
{
nvpair_t *elem;
int error;
char pool[MAXNAMELEN];
char pool[ZFS_MAX_DATASET_NAME_LEN];
/* determine the pool name */
elem = nvlist_next_nvpair(bmarks, NULL);

View File

@ -82,7 +82,7 @@ struct zpool_handle
{
libzfs_handle_t *zpool_hdl;
zpool_handle_t *zpool_next;
char zpool_name[ZPOOL_MAXNAMELEN];
char zpool_name[ZFS_MAX_DATASET_NAME_LEN];
int zpool_state;
size_t zpool_config_size;
nvlist_t *zpool_config;

View File

@ -52,6 +52,9 @@ unsigned AArch64InstrInfo::GetInstSizeInBytes(const MachineInstr *MI) const {
case TargetOpcode::IMPLICIT_DEF:
case TargetOpcode::KILL:
return 0;
case AArch64::TLSDESC_CALLSEQ:
// This gets lowered to an instruction sequence which takes 16 bytes
return 16;
}
llvm_unreachable("GetInstSizeInBytes()- Unable to determin insn size");

View File

@ -60,7 +60,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \
${_libgssapi} \
${_librpcsec_gss} \
${_libiconv_modules} \
libifc \
libifconfig \
libipsec \
libjail \
libkiconv \

View File

@ -36,72 +36,72 @@ __FBSDID("$FreeBSD$");
#include <signal.h>
const char *const sys_signame[NSIG] = {
"Signal 0",
"HUP", /* SIGHUP */
"INT", /* SIGINT */
"QUIT", /* SIGQUIT */
"ILL", /* SIGILL */
"TRAP", /* SIGTRAP */
"ABRT", /* SIGABRT */
"EMT", /* SIGEMT */
"FPE", /* SIGFPE */
"KILL", /* SIGKILL */
"BUS", /* SIGBUS */
"SEGV", /* SIGSEGV */
"SYS", /* SIGSYS */
"PIPE", /* SIGPIPE */
"ALRM", /* SIGALRM */
"TERM", /* SIGTERM */
"URG", /* SIGURG */
"STOP", /* SIGSTOP */
"TSTP", /* SIGTSTP */
"CONT", /* SIGCONT */
"CHLD", /* SIGCHLD */
"TTIN", /* SIGTTIN */
"TTOU", /* SIGTTOU */
"IO", /* SIGIO */
"XCPU", /* SIGXCPU */
"XFSZ", /* SIGXFSZ */
"VTALRM", /* SIGVTALRM */
"PROF", /* SIGPROF */
"WINCH", /* SIGWINCH */
"INFO", /* SIGINFO */
"USR1", /* SIGUSR1 */
"USR2" /* SIGUSR2 */
[0] = "Signal 0",
[SIGHUP] = "HUP",
[SIGINT] = "INT",
[SIGQUIT] = "QUIT",
[SIGILL] = "ILL",
[SIGTRAP] = "TRAP",
[SIGABRT] = "ABRT",
[SIGEMT] = "EMT",
[SIGFPE] = "FPE",
[SIGKILL] = "KILL",
[SIGBUS] = "BUS",
[SIGSEGV] = "SEGV",
[SIGSYS] = "SYS",
[SIGPIPE] = "PIPE",
[SIGALRM] = "ALRM",
[SIGTERM] = "TERM",
[SIGURG] = "URG",
[SIGSTOP] = "STOP",
[SIGTSTP] = "TSTP",
[SIGCONT] = "CONT",
[SIGCHLD] = "CHLD",
[SIGTTIN] = "TTIN",
[SIGTTOU] = "TTOU",
[SIGIO] = "IO",
[SIGXCPU] = "XCPU",
[SIGXFSZ] = "XFSZ",
[SIGVTALRM] = "VTALRM",
[SIGPROF] = "PROF",
[SIGWINCH] = "WINCH",
[SIGINFO] = "INFO",
[SIGUSR1] = "USR1",
[SIGUSR2] = "USR2",
};
const char *const sys_siglist[NSIG] = {
"Signal 0",
"Hangup", /* SIGHUP */
"Interrupt", /* SIGINT */
"Quit", /* SIGQUIT */
"Illegal instruction", /* SIGILL */
"Trace/BPT trap", /* SIGTRAP */
"Abort trap", /* SIGABRT */
"EMT trap", /* SIGEMT */
"Floating point exception", /* SIGFPE */
"Killed", /* SIGKILL */
"Bus error", /* SIGBUS */
"Segmentation fault", /* SIGSEGV */
"Bad system call", /* SIGSYS */
"Broken pipe", /* SIGPIPE */
"Alarm clock", /* SIGALRM */
"Terminated", /* SIGTERM */
"Urgent I/O condition", /* SIGURG */
"Suspended (signal)", /* SIGSTOP */
"Suspended", /* SIGTSTP */
"Continued", /* SIGCONT */
"Child exited", /* SIGCHLD */
"Stopped (tty input)", /* SIGTTIN */
"Stopped (tty output)", /* SIGTTOU */
"I/O possible", /* SIGIO */
"Cputime limit exceeded", /* SIGXCPU */
"Filesize limit exceeded", /* SIGXFSZ */
"Virtual timer expired", /* SIGVTALRM */
"Profiling timer expired", /* SIGPROF */
"Window size changes", /* SIGWINCH */
"Information request", /* SIGINFO */
"User defined signal 1", /* SIGUSR1 */
"User defined signal 2" /* SIGUSR2 */
[0] = "Signal 0",
[SIGHUP] = "Hangup",
[SIGINT] = "Interrupt",
[SIGQUIT] = "Quit",
[SIGILL] = "Illegal instruction",
[SIGTRAP] = "Trace/BPT trap",
[SIGABRT] = "Abort trap",
[SIGEMT] = "EMT trap",
[SIGFPE] = "Floating point exception",
[SIGKILL] = "Killed",
[SIGBUS] = "Bus error",
[SIGSEGV] = "Segmentation fault",
[SIGSYS] = "Bad system call",
[SIGPIPE] = "Broken pipe",
[SIGALRM] = "Alarm clock",
[SIGTERM] = "Terminated",
[SIGURG] = "Urgent I/O condition",
[SIGSTOP] = "Suspended (signal)",
[SIGTSTP] = "Suspended",
[SIGCONT] = "Continued",
[SIGCHLD] = "Child exited",
[SIGTTIN] = "Stopped (tty input)",
[SIGTTOU] = "Stopped (tty output)",
[SIGIO] = "I/O possible",
[SIGXCPU] = "Cputime limit exceeded",
[SIGXFSZ] = "Filesize limit exceeded",
[SIGVTALRM] = "Virtual timer expired",
[SIGPROF] = "Profiling timer expired",
[SIGWINCH] = "Window size changes",
[SIGINFO] = "Information request",
[SIGUSR1] = "User defined signal 1",
[SIGUSR2] = "User defined signal 2",
};
const int sys_nsig = sizeof(sys_siglist) / sizeof(sys_siglist[0]);

View File

@ -84,9 +84,10 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, int *nread, locale_t locale)
return (WEOF);
do {
nconv = l->__mbrtowc(&wc, fp->_p, fp->_r, mbs);
if (nconv == (size_t)-1)
break;
else if (nconv == (size_t)-2)
if (nconv == (size_t)-1) {
fp->_flags |= __SERR;
return (WEOF);
} else if (nconv == (size_t)-2)
continue;
else if (nconv == 0) {
fp->_p++;
@ -100,7 +101,9 @@ __fgetwc_mbs(FILE *fp, mbstate_t *mbs, int *nread, locale_t locale)
return (wc);
}
} while (__srefill(fp) == 0);
fp->_flags |= __SERR;
errno = EILSEQ;
if (__sfeof(fp)) {
fp->_flags |= __SERR;
errno = EILSEQ;
}
return (WEOF);
}

View File

@ -47,11 +47,16 @@ fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale)
{
wint_t wc;
size_t len;
int savserr;
FIX_LOCALE(locale);
FLOCKFILE(fp);
ORIENT(fp, 1);
savserr = fp->_flags & __SERR;
fp->_flags &= ~__SERR;
len = 0;
while ((wc = __fgetwc(fp, locale)) != WEOF) {
#define GROW 512
@ -64,7 +69,12 @@ fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale)
if (wc == L'\n')
break;
}
if (len == 0 || (wc == WEOF && !__sfeof(fp)))
/* fgetwc(3) may set both __SEOF and __SERR at once. */
if (__sferror(fp))
goto error;
fp->_flags |= savserr;
if (len == 0)
goto error;
FUNLOCKFILE(fp);

View File

@ -1,18 +1,18 @@
# $FreeBSD$
PACKAGE= lib${LIB}
LIB= ifc
LIB= ifconfig
# Don't build shared library, for now.
NO_PIC=
SHLIBDIR?= /lib
SHLIB_MAJOR= 1
SRCS= libifc.c libifc_internal.c
SRCS= libifconfig.c libifconfig_internal.c
INCSDIR= ${INCLUDEDIR}
INCS= libifc.h
INCS= libifconfig.h
#MAN= libifco.3
#MAN= libifconfig.3
CFLAGS+= -I${.CURDIR}
WARNS?=6

View File

@ -71,16 +71,16 @@
#include <string.h>
#include <unistd.h>
#include "libifc.h"
#include "libifc_internal.h"
#include "libifconfig.h"
#include "libifconfig_internal.h"
libifc_handle_t *
libifc_open(void)
ifconfig_handle_t *
ifconfig_open(void)
{
struct libifc_handle *h;
struct ifconfig_handle *h;
h = calloc(1, sizeof(struct libifc_handle));
h = calloc(1, sizeof(struct ifconfig_handle));
for (int i = 0; i <= AF_MAX; i++) {
h->sockets[i] = -1;
@ -91,7 +91,7 @@ libifc_open(void)
void
libifc_close(libifc_handle_t *h)
ifconfig_close(ifconfig_handle_t *h)
{
for (int i = 0; i <= AF_MAX; i++) {
if (h->sockets[i] != -1) {
@ -102,29 +102,29 @@ libifc_close(libifc_handle_t *h)
}
libifc_errtype
libifc_err_errtype(libifc_handle_t *h)
ifconfig_errtype
ifconfig_err_errtype(ifconfig_handle_t *h)
{
return (h->error.errtype);
}
int
libifc_err_errno(libifc_handle_t *h)
ifconfig_err_errno(ifconfig_handle_t *h)
{
return (h->error.errcode);
}
unsigned long
libifc_err_ioctlreq(libifc_handle_t *h)
ifconfig_err_ioctlreq(ifconfig_handle_t *h)
{
return (h->error.ioctl_request);
}
int
libifc_get_description(libifc_handle_t *h, const char *name, char **description)
ifconfig_get_description(ifconfig_handle_t *h, const char *name, char **description)
{
struct ifreq ifr;
char *descr = NULL;
@ -141,7 +141,7 @@ libifc_get_description(libifc_handle_t *h, const char *name, char **description)
ifr.ifr_buffer.buffer = descr;
ifr.ifr_buffer.length = descrlen;
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFDESCR,
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFDESCR,
&ifr) != 0) {
return (-1);
}
@ -166,7 +166,7 @@ libifc_get_description(libifc_handle_t *h, const char *name, char **description)
int
libifc_set_description(libifc_handle_t *h, const char *name,
ifconfig_set_description(ifconfig_handle_t *h, const char *name,
const char *newdescription)
{
struct ifreq ifr;
@ -180,7 +180,7 @@ libifc_set_description(libifc_handle_t *h, const char *name,
* TODO: Decide whether this should be an error condition instead.
*/
if (desclen == 0) {
return (libifc_unset_description(h, name));
return (ifconfig_unset_description(h, name));
}
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
@ -193,7 +193,7 @@ libifc_set_description(libifc_handle_t *h, const char *name,
return (-1);
}
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFDESCR, &ifr) != 0) {
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFDESCR, &ifr) != 0) {
free(ifr.ifr_buffer.buffer);
return (-1);
}
@ -202,7 +202,7 @@ libifc_set_description(libifc_handle_t *h, const char *name,
}
int libifc_unset_description(libifc_handle_t *h, const char *name)
int ifconfig_unset_description(ifconfig_handle_t *h, const char *name)
{
struct ifreq ifr;
@ -211,14 +211,14 @@ int libifc_unset_description(libifc_handle_t *h, const char *name)
ifr.ifr_buffer.length = 0;
ifr.ifr_buffer.buffer = NULL;
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFDESCR, &ifr) < 0) {
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFDESCR, &ifr) < 0) {
return (-1);
}
return (0);
}
int libifc_set_name(libifc_handle_t *h, const char *name, const char *newname)
int ifconfig_set_name(ifconfig_handle_t *h, const char *name, const char *newname)
{
struct ifreq ifr;
char *tmpname;
@ -234,7 +234,7 @@ int libifc_set_name(libifc_handle_t *h, const char *name, const char *newname)
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_data = tmpname;
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFNAME, &ifr) != 0) {
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFNAME, &ifr) != 0) {
free(tmpname);
return (-1);
}
@ -243,27 +243,27 @@ int libifc_set_name(libifc_handle_t *h, const char *name, const char *newname)
}
int libifc_set_mtu(libifc_handle_t *h, const char *name, const int mtu)
int ifconfig_set_mtu(ifconfig_handle_t *h, const char *name, const int mtu)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_mtu = mtu;
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFMTU, &ifr) < 0) {
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFMTU, &ifr) < 0) {
return (-1);
}
return (0);
}
int libifc_get_mtu(libifc_handle_t *h, const char *name, int *mtu)
int ifconfig_get_mtu(ifconfig_handle_t *h, const char *name, int *mtu)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFMTU, &ifr) == -1) {
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFMTU, &ifr) == -1) {
return (-1);
}
*mtu = ifr.ifr_mtu;
@ -271,27 +271,27 @@ int libifc_get_mtu(libifc_handle_t *h, const char *name, int *mtu)
}
int libifc_set_metric(libifc_handle_t *h, const char *name, const int mtu)
int ifconfig_set_metric(ifconfig_handle_t *h, const char *name, const int mtu)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_mtu = mtu;
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFMETRIC, &ifr) < 0) {
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFMETRIC, &ifr) < 0) {
return (-1);
}
return (0);
}
int libifc_get_metric(libifc_handle_t *h, const char *name, int *metric)
int ifconfig_get_metric(ifconfig_handle_t *h, const char *name, int *metric)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFMETRIC, &ifr) == -1) {
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFMETRIC, &ifr) == -1) {
return (-1);
}
*metric = ifr.ifr_metric;
@ -299,16 +299,16 @@ int libifc_get_metric(libifc_handle_t *h, const char *name, int *metric)
}
int libifc_set_capability(libifc_handle_t *h, const char *name,
int ifconfig_set_capability(ifconfig_handle_t *h, const char *name,
const int capability)
{
struct ifreq ifr;
struct libifc_capabilities ifcap;
struct ifconfig_capabilities ifcap;
int flags;
int value;
memset(&ifr, 0, sizeof(struct ifreq));
if (libifc_get_capability(h, name, &ifcap) != 0) {
if (ifconfig_get_capability(h, name, &ifcap) != 0) {
return (-1);
}
@ -329,22 +329,22 @@ int libifc_set_capability(libifc_handle_t *h, const char *name,
* set for this request.
*/
ifr.ifr_reqcap = flags;
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFCAP, &ifr) < 0) {
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCSIFCAP, &ifr) < 0) {
return (-1);
}
return (0);
}
int libifc_get_capability(libifc_handle_t *h, const char *name,
struct libifc_capabilities *capability)
int ifconfig_get_capability(ifconfig_handle_t *h, const char *name,
struct ifconfig_capabilities *capability)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFCAP, &ifr) < 0) {
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFCAP, &ifr) < 0) {
return (-1);
}
capability->curcap = ifr.ifr_curcap;
@ -353,21 +353,21 @@ int libifc_get_capability(libifc_handle_t *h, const char *name,
}
int libifc_destroy_interface(libifc_handle_t *h, const char *name)
int ifconfig_destroy_interface(ifconfig_handle_t *h, const char *name)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCIFDESTROY, &ifr) < 0) {
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCIFDESTROY, &ifr) < 0) {
return (-1);
}
return (0);
}
int libifc_create_interface(libifc_handle_t *h, const char *name, char **ifname)
int ifconfig_create_interface(ifconfig_handle_t *h, const char *name, char **ifname)
{
struct ifreq ifr;
@ -389,7 +389,7 @@ int libifc_create_interface(libifc_handle_t *h, const char *name, char **ifname)
/* No special handling for this interface type. */
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCIFCREATE2, &ifr) < 0) {
if (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCIFCREATE2, &ifr) < 0) {
return (-1);
}
*ifname = strdup(ifr.ifr_name);

View File

@ -34,16 +34,16 @@
typedef enum {
OTHER, IOCTL, SOCKET
} libifc_errtype;
} ifconfig_errtype;
/*
* Opaque definition so calling application can just pass a
* pointer to it for library use.
*/
struct libifc_handle;
typedef struct libifc_handle libifc_handle_t;
struct ifconfig_handle;
typedef struct ifconfig_handle ifconfig_handle_t;
struct libifc_capabilities {
struct ifconfig_capabilities {
/** Current capabilities (ifconfig prints this as 'options')*/
int curcap;
/** Requested capabilities (ifconfig prints this as 'capabilities')*/
@ -55,57 +55,57 @@ struct libifc_capabilities {
* Example usage:
*{@code
* // Create state object
* libifc_handle_t *lifh = libifc_open();
* ifconfig_handle_t *lifh = ifconfig_open();
*
* // Do stuff with it
*
* // Dispose of the state object
* libifc_close(lifh);
* ifconfig_close(lifh);
* lifh = NULL;
*}
*/
libifc_handle_t *libifc_open(void);
ifconfig_handle_t *ifconfig_open(void);
/** Frees resources held in the provided state object.
* @param h The state object to close.
* @see #libifc_open(void)
* @see #ifconfig_open(void)
*/
void libifc_close(libifc_handle_t *h);
void ifconfig_close(ifconfig_handle_t *h);
/** Identifies what kind of error occured. */
libifc_errtype libifc_err_errtype(libifc_handle_t *h);
ifconfig_errtype ifconfig_err_errtype(ifconfig_handle_t *h);
/** Retrieves the errno associated with the error, if any. */
int libifc_err_errno(libifc_handle_t *h);
int ifconfig_err_errno(ifconfig_handle_t *h);
/** If error type was IOCTL, this identifies which request failed. */
unsigned long libifc_err_ioctlreq(libifc_handle_t *h);
unsigned long ifconfig_err_ioctlreq(ifconfig_handle_t *h);
int libifc_get_description(libifc_handle_t *h, const char *name,
int ifconfig_get_description(ifconfig_handle_t *h, const char *name,
char **description);
int libifc_set_description(libifc_handle_t *h, const char *name,
int ifconfig_set_description(ifconfig_handle_t *h, const char *name,
const char *newdescription);
int libifc_unset_description(libifc_handle_t *h, const char *name);
int libifc_set_name(libifc_handle_t *h, const char *name, const char *newname);
int libifc_set_mtu(libifc_handle_t *h, const char *name, const int mtu);
int libifc_get_mtu(libifc_handle_t *h, const char *name, int *mtu);
int ifconfig_unset_description(ifconfig_handle_t *h, const char *name);
int ifconfig_set_name(ifconfig_handle_t *h, const char *name, const char *newname);
int ifconfig_set_mtu(ifconfig_handle_t *h, const char *name, const int mtu);
int ifconfig_get_mtu(ifconfig_handle_t *h, const char *name, int *mtu);
int libifc_set_metric(libifc_handle_t *h, const char *name, const int metric);
int libifc_get_metric(libifc_handle_t *h, const char *name, int *metric);
int ifconfig_set_metric(ifconfig_handle_t *h, const char *name, const int metric);
int ifconfig_get_metric(ifconfig_handle_t *h, const char *name, int *metric);
int libifc_set_capability(libifc_handle_t *h, const char *name,
int ifconfig_set_capability(ifconfig_handle_t *h, const char *name,
const int capability);
int libifc_get_capability(libifc_handle_t *h, const char *name,
struct libifc_capabilities *capability);
int ifconfig_get_capability(ifconfig_handle_t *h, const char *name,
struct ifconfig_capabilities *capability);
/** Destroy a virtual interface
* @param name Interface to destroy
*/
int libifc_destroy_interface(libifc_handle_t *h, const char *name);
int ifconfig_destroy_interface(ifconfig_handle_t *h, const char *name);
/** Creates a (virtual) interface
* @param name Name of interface to create. Example: bridge or bridge42
* @param name ifname Is set to actual name of created interface
*/
int libifc_create_interface(libifc_handle_t *h, const char *name,
int ifconfig_create_interface(ifconfig_handle_t *h, const char *name,
char **ifname);

View File

@ -40,11 +40,11 @@
#include <unistd.h>
#include "libifc.h" // Needed for libifc_errstate
#include "libifc_internal.h"
#include "libifconfig.h" // Needed for ifconfig_errstate
#include "libifconfig_internal.h"
int
libifc_ioctlwrap_ret(libifc_handle_t *h, unsigned long request, int rcode)
ifconfig_ioctlwrap_ret(ifconfig_handle_t *h, unsigned long request, int rcode)
{
if (rcode != 0) {
h->error.errtype = IOCTL;
@ -56,17 +56,17 @@ libifc_ioctlwrap_ret(libifc_handle_t *h, unsigned long request, int rcode)
int
libifc_ioctlwrap(libifc_handle_t *h, const int addressfamily,
ifconfig_ioctlwrap(ifconfig_handle_t *h, const int addressfamily,
unsigned long request, struct ifreq *ifr)
{
int s;
if (libifc_socket(h, addressfamily, &s) != 0) {
if (ifconfig_socket(h, addressfamily, &s) != 0) {
return (-1);
}
int rcode = ioctl(s, request, ifr);
return (libifc_ioctlwrap_ret(h, request, rcode));
return (ifconfig_ioctlwrap_ret(h, request, rcode));
}
@ -74,7 +74,7 @@ libifc_ioctlwrap(libifc_handle_t *h, const int addressfamily,
* Function to get socket for the specified address family.
* If the socket doesn't already exist, attempt to create it.
*/
int libifc_socket(libifc_handle_t *h, const int addressfamily, int *s)
int ifconfig_socket(ifconfig_handle_t *h, const int addressfamily, int *s)
{
if (addressfamily > AF_MAX) {
h->error.errtype = SOCKET;

View File

@ -32,14 +32,14 @@
#pragma once
#include "libifc.h"
#include "libifconfig.h"
struct errstate {
/**
* Type of error.
*/
libifc_errtype errtype;
ifconfig_errtype errtype;
/**
* The error occured in this ioctl() request.
@ -53,7 +53,7 @@ struct errstate {
int errcode;
};
struct libifc_handle {
struct ifconfig_handle {
struct errstate error;
int sockets[AF_MAX + 1];
};
@ -69,7 +69,7 @@ struct libifc_handle {
* {@code
* static void myfunc() \{
* int s;
* if (libifc_socket(AF_LOCAL, &s) != 0) \{
* if (ifconfig_socket(AF_LOCAL, &s) != 0) \{
* // Handle error state here
* \}
* // user code here
@ -77,11 +77,11 @@ struct libifc_handle {
* }
* }
*/
int libifc_socket(libifc_handle_t *h, const int addressfamily, int *s);
int ifconfig_socket(ifconfig_handle_t *h, const int addressfamily, int *s);
/** Function used by other wrapper functions to populate _errstate when appropriate.*/
int libifc_ioctlwrap_ret(libifc_handle_t *h, unsigned long request, int rcode);
int ifconfig_ioctlwrap_ret(ifconfig_handle_t *h, unsigned long request, int rcode);
/** Function to wrap ioctl() and automatically populate libifc_errstate when appropriate.*/
int libifc_ioctlwrap(libifc_handle_t *h, const int addressfamily,
/** Function to wrap ioctl() and automatically populate ifconfig_errstate when appropriate.*/
int ifconfig_ioctlwrap(ifconfig_handle_t *h, const int addressfamily,
unsigned long request, struct ifreq *ifr);

View File

@ -176,6 +176,12 @@ libusb20_tr_open_stream(struct libusb20_transfer *xfer, uint32_t MaxBufSize,
return (LIBUSB20_ERROR_BUSY);
if (MaxFrameCount & LIBUSB20_MAX_FRAME_PRE_SCALE) {
MaxFrameCount &= ~LIBUSB20_MAX_FRAME_PRE_SCALE;
/*
* The kernel can setup 8 times more frames when
* pre-scaling ISOCHRONOUS transfers. Make sure the
* length and pointer buffers are big enough:
*/
MaxFrameCount *= 8;
pre_scale = 1;
} else {
pre_scale = 0;
@ -200,8 +206,13 @@ libusb20_tr_open_stream(struct libusb20_transfer *xfer, uint32_t MaxBufSize,
}
memset(xfer->ppBuffer, 0, size);
error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
MaxFrameCount, ep_no, stream_id, pre_scale);
if (pre_scale) {
error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
MaxFrameCount / 8, ep_no, stream_id, 1);
} else {
error = xfer->pdev->methods->tr_open(xfer, MaxBufSize,
MaxFrameCount, ep_no, stream_id, 0);
}
if (error) {
free(xfer->ppBuffer);

View File

@ -427,7 +427,6 @@ test_large(void)
test_odd_tol(ctanh, z,
CMPLXL(1.0, 8.95257245135025991216632140458264468e-309L),
DBL_ULP());
#if !defined(__i386__)
z = CMPLXL(30, 0x1p1023L);
test_odd_tol(ctanh, z,
CMPLXL(1.0, -1.62994325413993477997492170229268382e-26L),
@ -437,7 +436,6 @@ test_large(void)
CMPLXL(0.878606311888306869546254022621986509L,
-0.225462792499754505792678258169527424L),
DBL_ULP());
#endif
z = CMPLXL(710.6, 0.78539816339744830961566084581987572L);
test_odd_tol(csinh, z,
@ -475,8 +473,12 @@ main(int argc, char *argv[])
test_small();
printf("ok 5 - ctrig small\n");
#if defined(__i386__)
printf("ok 6 # SKIP ctrig large # fails on i386 because of bug 205446\n");
#else
test_large();
printf("ok 6 - ctrig large\n");
#endif
return (0);
}

View File

@ -1098,9 +1098,6 @@
<para>[&arch.i386;] STB 4 port card using shared IRQ</para>
<para>[&arch.i386;] DigiBoard intelligent serial cards (digi
driver)</para>
<para>[&arch.amd64;, &arch.i386;] PCI-Based multi-port serial
boards (&man.puc.4; driver)</para>

View File

@ -52,6 +52,7 @@ DIRDEPS = \
usr.bin/lex/lib \
usr.bin/yacc.host \
usr.sbin/crunch/crunchgen.host \
usr.sbin/crunch/crunchide.host \
.include <dirdeps.mk>

View File

@ -102,6 +102,8 @@ read_client_conf(void)
[top_level_config.requested_option_count++] = DHO_HOST_NAME;
top_level_config.requested_options
[top_level_config.requested_option_count++] = DHO_DOMAIN_SEARCH;
top_level_config.requested_options
[top_level_config.requested_option_count++] = DHO_INTERFACE_MTU;
if ((cfile = fopen(path_dhclient_conf, "r")) != NULL) {
do {

View File

@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include "privsep.h"
#include <sys/capsicum.h>
#include <sys/endian.h>
#include <net80211/ieee80211_freebsd.h>
@ -132,6 +133,9 @@ int fork_privchld(int, int);
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
/* Minimum MTU is 68 as per RFC791, p. 24 */
#define MIN_MTU 68
static time_t scripttime;
int
@ -798,9 +802,20 @@ dhcpack(struct packet *packet)
void
bind_lease(struct interface_info *ip)
{
struct option_data *opt;
/* Remember the medium. */
ip->client->new->medium = ip->client->medium;
opt = &ip->client->new->options[DHO_INTERFACE_MTU];
if (opt->len == sizeof(u_int16_t)) {
u_int16_t mtu = be16dec(opt->data);
if (mtu < MIN_MTU)
warning("mtu size %u < %d: ignored", (unsigned)mtu, MIN_MTU);
else
interface_set_mtu_unpriv(privfd, mtu);
}
/* Write out the new lease. */
write_client_lease(ip, ip->client->new, 0);

View File

@ -319,6 +319,8 @@ void cancel_timeout(void (*)(void *), void *);
void add_protocol(char *, int, void (*)(struct protocol *), void *);
void remove_protocol(struct protocol *);
int interface_link_status(char *);
void interface_set_mtu_unpriv(int, u_int16_t);
void interface_set_mtu_priv(char *, u_int16_t);
/* hash.c */
struct hash_table *new_hash(void);

View File

@ -43,6 +43,7 @@
__FBSDID("$FreeBSD$");
#include "dhcpd.h"
#include "privsep.h"
#include <sys/ioctl.h>
@ -501,3 +502,46 @@ interface_link_status(char *ifname)
}
return (1);
}
void
interface_set_mtu_unpriv(int privfd, u_int16_t mtu)
{
struct imsg_hdr hdr;
struct buf *buf;
int errs = 0;
hdr.code = IMSG_SET_INTERFACE_MTU;
hdr.len = sizeof(hdr) +
sizeof(u_int16_t);
if ((buf = buf_open(hdr.len)) == NULL)
error("buf_open: %m");
errs += buf_add(buf, &hdr, sizeof(hdr));
errs += buf_add(buf, &mtu, sizeof(mtu));
if (errs)
error("buf_add: %m");
if (buf_close(privfd, buf) == -1)
error("buf_close: %m");
}
void
interface_set_mtu_priv(char *ifname, u_int16_t mtu)
{
struct ifreq ifr;
int sock;
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
error("Can't create socket");
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
ifr.ifr_mtu = mtu;
if (ioctl(sock, SIOCSIFMTU, &ifr) == -1)
warning("SIOCSIFMTU failed (%d): %s", mtu,
strerror(errno));
close(sock);
}

View File

@ -111,6 +111,7 @@ dispatch_imsg(struct interface_info *ifi, int fd)
struct client_lease lease;
int ret, i, optlen;
struct buf *buf;
u_int16_t mtu;
buf_read(fd, &hdr, sizeof(hdr));
@ -235,6 +236,13 @@ dispatch_imsg(struct interface_info *ifi, int fd)
case IMSG_SEND_PACKET:
send_packet_priv(ifi, &hdr, fd);
break;
case IMSG_SET_INTERFACE_MTU:
if (hdr.len < sizeof(hdr) + sizeof(u_int16_t))
error("corrupted message received");
buf_read(fd, &mtu, sizeof(u_int16_t));
interface_set_mtu_priv(ifi->name, mtu);
break;
default:
error("received unknown message, code %d", hdr.code);
}

View File

@ -36,7 +36,8 @@ enum imsg_code {
IMSG_SCRIPT_WRITE_PARAMS,
IMSG_SCRIPT_GO,
IMSG_SCRIPT_GO_RET,
IMSG_SEND_PACKET
IMSG_SEND_PACKET,
IMSG_SET_INTERFACE_MTU,
};
struct imsg_hdr {

View File

@ -1,9 +0,0 @@
# $FreeBSD$
default:
$(CC) -Wall -fPIC -lifc -g -o example_setdescription setdescription.c
$(CC) -Wall -fPIC -lifc -g -o example_setmtu setmtu.c
$(CC) -Wall -fPIC -lifc -g -o example_ifdestroy ifdestroy.c
$(CC) -Wall -fPIC -lifc -g -o example_ifcreate ifcreate.c
clean:
rm -f example_*

View File

@ -0,0 +1,8 @@
# $FreeBSD$
default:
$(CC) -Wall -fPIC -lifconfig -g -o example_setdescription setdescription.c
$(CC) -Wall -fPIC -lifconfig -g -o example_setmtu setmtu.c
$(CC) -Wall -fPIC -lifconfig -g -o example_ifdestroy ifdestroy.c
$(CC) -Wall -fPIC -lifconfig -g -o example_ifcreate ifcreate.c
clean:
rm -f example_*

View File

@ -37,7 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libifc.h>
#include <libifconfig.h>
int main(int argc, char *argv[])
@ -55,21 +55,21 @@ int main(int argc, char *argv[])
printf("Requested interface name: %s\n", ifname);
libifc_handle_t *lifh = libifc_open();
if (libifc_create_interface(lifh, ifname, &ifactualname) == 0) {
ifconfig_handle_t *lifh = ifconfig_open();
if (ifconfig_create_interface(lifh, ifname, &ifactualname) == 0) {
printf("Successfully created interface '%s'\n", ifactualname);
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
free(ifactualname);
return (0);
} else {
switch (libifc_err_errtype(lifh)) {
switch (ifconfig_err_errtype(lifh)) {
case SOCKET:
warnx("couldn't create socket. This shouldn't happen.\n");
break;
case IOCTL:
if (libifc_err_ioctlreq(lifh) == SIOCIFCREATE2) {
if (ifconfig_err_ioctlreq(lifh) == SIOCIFCREATE2) {
warnx(
"Failed to create interface (SIOCIFCREATE2)\n");
}
@ -79,12 +79,12 @@ int main(int argc, char *argv[])
"This is a thorough example accommodating for temporary"
" 'not implemented yet' errors. That's likely what happened"
" now. If not, your guess is as good as mine. ;)"
" Error code: %d\n", libifc_err_errno(
" Error code: %d\n", ifconfig_err_errno(
lifh));
break;
}
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
free(ifactualname);

View File

@ -37,7 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libifc.h>
#include <libifconfig.h>
int main(int argc, char *argv[])
@ -55,20 +55,20 @@ int main(int argc, char *argv[])
printf("Interface name: %s\n", ifname);
libifc_handle_t *lifh = libifc_open();
if (libifc_destroy_interface(lifh, ifname) == 0) {
ifconfig_handle_t *lifh = ifconfig_open();
if (ifconfig_destroy_interface(lifh, ifname) == 0) {
printf("Successfully destroyed interface '%s'.", ifname);
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
return (0);
} else {
switch (libifc_err_errtype(lifh)) {
switch (ifconfig_err_errtype(lifh)) {
case SOCKET:
warnx("couldn't create socket. This shouldn't happen.\n");
break;
case IOCTL:
if (libifc_err_ioctlreq(lifh) == SIOCIFDESTROY) {
if (ifconfig_err_ioctlreq(lifh) == SIOCIFDESTROY) {
warnx(
"Failed to destroy interface (SIOCIFDESTROY)\n");
}
@ -79,7 +79,7 @@ int main(int argc, char *argv[])
break;
}
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
return (-1);

View File

@ -35,7 +35,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libifc.h>
#include <libifconfig.h>
int main(int argc, char *argv[])
@ -54,27 +54,27 @@ int main(int argc, char *argv[])
printf("Interface name: %s\n", ifname);
libifc_handle_t *lifh = libifc_open();
if (libifc_get_description(lifh, ifname, &curdescr) == 0) {
ifconfig_handle_t *lifh = ifconfig_open();
if (ifconfig_get_description(lifh, ifname, &curdescr) == 0) {
printf("Old description: %s\n", curdescr);
}
printf("New description: %s\n\n", ifdescr);
if (libifc_set_description(lifh, ifname, ifdescr) == 0) {
if (ifconfig_set_description(lifh, ifname, ifdescr) == 0) {
printf("New description successfully set.\n");
} else {
switch (libifc_err_errtype(lifh)) {
switch (ifconfig_err_errtype(lifh)) {
case SOCKET:
err(libifc_err_errno(lifh), "Socket error");
err(ifconfig_err_errno(lifh), "Socket error");
break;
case IOCTL:
err(libifc_err_errno(
err(ifconfig_err_errno(
lifh), "IOCTL(%lu) error",
libifc_err_ioctlreq(lifh));
ifconfig_err_ioctlreq(lifh));
break;
case OTHER:
err(libifc_err_errno(lifh), "Other error");
err(ifconfig_err_errno(lifh), "Other error");
break;
}
}
@ -86,6 +86,6 @@ int main(int argc, char *argv[])
ifdescr = NULL;
curdescr = NULL;
libifc_close(lifh);
ifconfig_close(lifh);
return (0);
}

View File

@ -37,7 +37,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libifc.h>
#include <libifconfig.h>
int main(int argc, char *argv[])
@ -58,26 +58,26 @@ int main(int argc, char *argv[])
printf("Interface name: %s\n", ifname);
printf("New MTU: %d", mtu);
libifc_handle_t *lifh = libifc_open();
if (libifc_set_mtu(lifh, ifname, mtu) == 0) {
ifconfig_handle_t *lifh = ifconfig_open();
if (ifconfig_set_mtu(lifh, ifname, mtu) == 0) {
printf("Successfully changed MTU of %s to %d\n", ifname, mtu);
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
return (0);
} else {
switch (libifc_err_errtype(lifh)) {
switch (ifconfig_err_errtype(lifh)) {
case SOCKET:
warnx("couldn't create socket. This shouldn't happen.\n");
break;
case IOCTL:
if (libifc_err_ioctlreq(lifh) == SIOCSIFMTU) {
if (ifconfig_err_ioctlreq(lifh) == SIOCSIFMTU) {
warnx("Failed to set MTU (SIOCSIFMTU)\n");
} else {
warnx(
"Failed to set MTU due to error in unexpected ioctl() call %lu. Error code: %i.\n",
libifc_err_ioctlreq(lifh),
libifc_err_errno(lifh));
ifconfig_err_ioctlreq(lifh),
ifconfig_err_errno(lifh));
}
break;
default:
@ -86,7 +86,7 @@ int main(int argc, char *argv[])
break;
}
libifc_close(lifh);
ifconfig_close(lifh);
lifh = NULL;
free(ifname);
return (-1);

View File

@ -122,7 +122,6 @@ MAN= aac.4 \
ddb.4 \
de.4 \
devctl.4 \
digi.4 \
disc.4 \
divert.4 \
${_dpms.4} \

View File

@ -1,377 +0,0 @@
.\" Copyright (c) 1990, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Systems Programming Group of the University of Utah Computer
.\" Science Department.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)dca.4 5.2 (Berkeley) 3/27/91
.\" from: com.4,v 1.1 1993/08/06 11:19:07 cgd Exp
.\" from: sio.4,v 1.15 1994/12/06 20:14:30 bde Exp
.\" $FreeBSD$
.\"
.Dd December 7, 2003
.Dt DIGI 4
.Os
.Sh NAME
.Nm digi
.Nd DigiBoard intelligent serial cards driver
.Sh SYNOPSIS
.Cd "device digi"
.Pp
This man page was originally written for the dgb driver, and should
likely be gone over with a fine tooth comb to reflect differences
with the digi driver.
.Pp
When not defined the number is computed:
.Bd -ragged -offset 4n
default
.Dv NDGBPORTS
= number_of_described_DigiBoard_cards * 16
.Ed
.Pp
If it is less than the actual number of ports
the system will be able to use only the
first
.Dv NDGBPORTS
ports.
If it is greater then all ports will be usable
but some memory will be wasted.
.Pp
Meaning of
.Cm flags :
.Bl -tag -width indent -compact
.It 0x0001
use alternate pinout (exchange DCD and DSR lines)
.It 0x0002
do not use 8K window mode of PC/Xe
.El
.Pp
Device numbering:
.Bd -literal -compact
0b\fICC\fPmmmmmmmm\fIOLIPPPPP\fP
\fBCC\fPard number
\fRmmmmmmmm\fPajor number
call\fBO\fPut
\fBL\fPock
\fBI\fPnitial
\fBPPPPP\fPort number
.Ed
.Sh DESCRIPTION
The
.Nm
driver provides support for DigiBoard PC/Xe and PC/Xi series intelligent
serial multiport cards with asynchronous interfaces based on the
.Tn EIA
.Tn RS-232C
.Pf ( Tn CCITT
.Tn V.24 )
standard.
.Pp
Input and output for each line may set to one of following baud rates;
50, 75, 110, 134.5, 150, 300, 600, 1200, 1800, 2400, 4800, 9600,
19200, 38400, 57600, or for newer versions of cards 115200.
.Pp
The driver does not use any interrupts, it is
.Dq polling-based .
This means that
it uses clock interrupts instead of interrupts generated by DigiBoard cards and
checks the state of cards 25 times per second.
This is practical because the
DigiBoard cards have large input and output buffers (more than 1Kbyte per
port) and hardware that allows efficiently finding the port that needs
attention.
The only problem seen with this policy is slower
SLIP and PPP response.
.Pp
Each line in the kernel configuration file describes one card, not one port
as in the
.Xr sio 4
driver.
.Pp
The
.Cm flags
keyword may be used on each
.Dq Li "device dgb"
line in the kernel configuration file
to change the pinout of the interface or to use new PC/Xe cards
which can work with an 8K memory window in compatibility mode
(with a 64K memory window).
Note
that using 8K memory window does not mean shorter input/output buffers, it means
only that all buffers will be mapped to the same memory address and switched as
needed.
.Pp
The
.Cm port
value must be the same
as the
port
set on the card by jumpers.
For PC/Xi cards the same rule is applicable to the
.Cm iomem
value.
It must be the same as the memory address set on the card
by jumpers.
.\"Some documentation gives the address as a ``paragraph'' or ``segment'';
.\"you can get the value of address by adding the digit "0" at end of
.\"paragraph value, e.g., 0xfc000 -> 0xfc0000.
For PC/Xe cards there is no need to use jumpers for this purpose.
In fact there are no jumpers to do it.
Just
write the address you want as the
.Cm iomem
value in kernel config file and the card will be programmed
to use this address.
.Pp
The same range of memory addresses may be used
for all the DigiBoards installed
(but not for any other card or real memory).
DigiBoards
with a large amount of memory (256K or 512K and perhaps
even 128K) must be mapped
to memory addresses outside of the first megabyte.
If the computer
has more than 15 megabytes of memory then there is no free address space
outside of the first megabyte where such DigiBoards can be mapped.
In this case you
may need to reduce the amount of memory in the computer.
But many machines provide a better solution.
They have the ability to
.Dq "turn off"
the memory in the 16th megabyte (addresses 0xF00000 - 0xFFFFFF)
using the
BIOS setup.
Then the DigiBoard's address space can be set to this
.Dq hole .
.\" XXX the following should be true for all serial drivers and
.\" should not be repeated in the man pages for all serial drivers.
.\" It was copied from sio.4. The only changes were s/sio/dgb/g.
.Pp
Serial ports controlled by the
.Nm
driver can be used for both
.Dq callin
and
.Dq callout .
For each port there is a callin device and a callout device.
The minor number of the callout device is 128 higher
than that of the corresponding callin port.
The callin device is general purpose.
Processes opening it normally wait for carrier
and for the callout device to become inactive.
The callout device is used to steal the port from
processes waiting for carrier on the callin device.
Processes opening it do not wait for carrier
and put any processes waiting for carrier on the callin device into
a deeper sleep so that they do not conflict with the callout session.
The callout device is abused for handling programs that are supposed
to work on general ports and need to open the port without waiting
but are too stupid to do so.
.Pp
The
.Nm
driver also supports an initial-state and a lock-state control
device for each of the callin and the callout
.Dq data
devices.
The minor number of the initial-state device is 32 higher
than that of the corresponding data device.
The minor number of the lock-state device is 64 higher
than that of the corresponding data device.
The termios settings of a data device are copied
from those of the corresponding initial-state device
on first opens and are not inherited from previous opens.
Use
.Xr stty 1
in the normal way on the initial-state devices to program
initial termios states suitable for your setup.
.Pp
The lock termios state acts as flags to disable changing
the termios state.
E.g., to lock a flag variable such as
.Dv CRTSCTS ,
use
.Dq Li "stty crtscts"
on the lock-state device.
Speeds and special characters
may be locked by setting the corresponding value in the lock-state
device to any nonzero value.
.Pp
Correct programs talking to correctly wired external devices
.\" XXX change next line in other man pages too, and rewrite this paragraph.
work with almost arbitrary initial states and no locking,
but other setups may benefit from changing some of the default
initial state and locking the state.
In particular, the initial states for non (POSIX) standard flags
should be set to suit the devices attached and may need to be
locked to prevent buggy programs from changing them.
E.g.,
.Dv CRTSCTS
should be locked on for devices that support
RTS/CTS handshaking at all times and off for devices that do not
support it at all.
.Dv CLOCAL
should be locked on for devices
that do not support carrier.
.Dv HUPCL
may be locked off if you do not
want to hang up for some reason.
In general, very bad things happen
if something is locked to the wrong state, and things should not
be locked for devices that support more than one setting.
The
.Dv CLOCAL
flag on callin ports should be locked off for logins
to avoid certain security holes, but this needs to be done by
getty if the callin port is used for anything else.
.Sh FILES
.Bl -tag -width /dev/ttyiD?? -compact
.It Pa /dev/ttyD??
for callin ports
.It Pa /dev/ttyiD??
.It Pa /dev/ttylD??
corresponding callin initial-state and lock-state devices
.Pp
.It Pa /dev/cuaD??
for callout ports
.It Pa /dev/cuaiD??
.It Pa /dev/cualD??
corresponding callout initial-state and lock-state devices
.El
.Pp
.Bl -tag -width /etc/rc.serial -compact
.It Pa /etc/rc.serial
examples of setting the initial-state and lock-state devices
.El
.Pp
The first question mark in these device names is short for the
card number
(a decimal number between 0 and 65535 inclusive).
The second question mark is short for the port number
(a letter in the range [0-9a-v]).
.Sh DIAGNOSTICS
You may enable extended diagnostics by defining DEBUG at the
start of the source file
.Pa dgb.c .
.Bl -diag
.It dgb\fIX\fP: warning: address \fIN\fP truncated to \fIM\fP
The memory address for the PC/Xe's 8K window is misaligned (it should be
on an 8K boundary) or outside of the first megabyte.
.It dgb\fIX\fP: 1st reset failed
Problems with accessing I/O port of the card, probably
the wrong
.Cm port
value is specified in the kernel config file.
.It dgb\fIX\fP: 2nd reset failed
Problems with hardware.
.It dgb\fIX\fP: \fIN\fP[st,nd,rd,th] memory test failed
Problems with accessing the memory of the card, probably
the wrong
.Cm iomem
value is specified in the kernel config file.
.It dgb\fIX\fP: BIOS start failed
Problems with starting the on-board BIOS.
Probably the memory addresses of the
DigiBoard overlap with some other device or with RAM.
.It dgb\fIX\fP: BIOS download failed
Problems with the on-board BIOS.
Probably the memory addresses of the
DigiBoard overlap with some other device or with RAM.
.It dgb\fIX\fP: FEP code download failed
Problems with downloading of the Front-End Processor's micro-OS.
Probably the memory addresses of the
DigiBoard overlap with some other device or with RAM.
.It dgb\fIX\fP: FEP/OS start failed
Problems with starting of the Front-End Processor's micro-OS.
Probably the memory addresses of the
DigiBoard overlap with some other device or with RAM.
.It dgb\fIX\fP: too many ports
This DigiBoard reports that it has more than 32 ports.
Perhaps a hardware problem or
the memory addresses of the
DigiBoard overlap with some other device or with RAM.
.It dgb\fIX\fP: only \fIN\fP ports are usable
The
.Dv NDGBPORTS
parameter is too small and there is only enough space allocated
for
.Ar N
ports on this card.
.It dgb\fIX\fP: port \fIY\fP is broken
The on-board diagnostic has reported that the specified port has hardware
problems.
.It dgb\fIX\fP: polling of disabled board stopped
Internal problems in the polling logic of driver.
.It dgb\fIX\fP: event queue's head or tail is wrong!
Internal problems in the driver or hardware.
.It dgb\fIX\fP: port \fIY\fP: got event on nonexisting port
Some status changed on a port that is physically present but is
unusable due to misconfiguration.
.It dgb\fIX\fP: port \fIY\fP: event \fIN\fP mstat \fIM\fP lstat \fIK\fP
The driver got a strange event from card.
Probably this means that you have a
newer card with an extended list of events or some other hardware problem.
.It dgb\fIX\fP: port \fIY\fP: overrun
Input buffer has filled up.
Problems in polling logic of driver.
.It dgb\fIX\fP: port \fIY\fP: FEP command on disabled port
Internal problems in driver.
.It dgb\fIX\fP: port \fIY\fP: timeout on FEP command
Problems in hardware.
.El
.Sh SEE ALSO
.Xr stty 1 ,
.Xr termios 4 ,
.Xr tty 4 ,
.Xr comcontrol 8
.\" XXX add next line to many other drivers.
.Sh HISTORY
The
.Nm
driver is derived from the
.Xr sio 4
driver and the DigiBoard driver from
.Tn Linux
and is
.Ud
.Sh BUGS
The implementation of sending
.Dv BREAK
is broken.
.Dv BREAK
of fixed length of 1/4 s
is sent anyway.
.Pp
There was a bug in implementation of
.Xr select 2 .
It is fixed now but not widely tested yet.
.Pp
There is no ditty command.
Most of its functions (alternate pinout,
speed up to 115200 baud, etc.) are implemented in the driver itself.
Some
other functions are missing.

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd August 3, 2016
.Dd September 1, 2016
.Dt PCI 9
.Os
.Sh NAME
@ -910,11 +910,6 @@ with one in the new distribution.
The
.Fn pci_remap_msix
function will fail if this condition is not met.
.Sh IMPLEMENTATION NOTES
The
.Vt pci_addr_t
type varies according to the size of the PCI bus address
space on the target architecture.
.Sh SEE ALSO
.Xr pci 4 ,
.Xr pciconf 8 ,

View File

@ -339,7 +339,7 @@ FreeBSD 5.2 | | | |
| FreeBSD | | OpenBSD 5.9 |
| 10.3 | | | |
| | | | DragonFly 4.6.0
*--FreeBSD | | | |
*--FreeBSD | | OpenBSD 6.0 |
| 11.0 | | | |
| | | | |
| | | | |
@ -692,6 +692,7 @@ DragonFly 4.4.1 2015-12-07 [DFB]
OpenBSD 5.9 2016-03-29 [OBD]
FreeBSD 10.3 2016-04-04 [FBD]
DragonFly 4.6.0 2016-08-02 [DFB]
OpenBSD 6.0 2016-09-01 [OBD]
Bibliography
------------------------

View File

@ -112,6 +112,7 @@ CRUNCHENV+= MK_TESTS=no \
_RECURSING_CRUNCH=1
.ORDER: ${OUTPUTS} objs
${OUTPUTS:[1]}: .META
${OUTPUTS:[2..-1]}: .NOMETA
${OUTPUTS}: ${CONF}
MAKE=${MAKE} ${CRUNCHENV:NMK_AUTO_OBJ=*} MAKEOBJDIRPREFIX=${CRUNCHOBJS} \
MK_AUTO_OBJ=${MK_AUTO_OBJ} \
@ -122,11 +123,13 @@ ${OUTPUTS}: ${CONF}
# These 2 targets cannot use .MAKE since they depend on the generated
# ${OUTMK} above.
${PROG}: ${OUTPUTS} objs .META
${PROG}: ${OUTPUTS} objs .NOMETA .PHONY
${CRUNCHENV} \
CC="${CC} ${CFLAGS} ${LDFLAGS}" \
CXX="${CXX} ${CXXFLAGS} ${LDFLAGS}" \
${MAKE} .MAKE.MODE=normal -f ${OUTMK} exe
${MAKE} .MAKE.MODE="${.MAKE.MODE} curdirOk=yes" \
.MAKE.META.IGNORE_PATHS="${.MAKE.META.IGNORE_PATHS}" \
-f ${OUTMK} exe
objs: ${OUTMK} .META
${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} \
@ -166,3 +169,5 @@ clean:
fi
META_XTRAS+= ${find ${CRUNCHOBJS}${SRCTOP} -name '*.meta' 2>/dev/null || true:L:sh}
META_XTRAS+= ${echo ${CRUNCHOBJS}/*.lo.meta 2>/dev/null || true:L:sh}
META_XTRAS+= ${PROG}.meta

View File

@ -181,7 +181,7 @@ DEPEND_CFLAGS+= -MT${.TARGET}
.if defined(.PARSEDIR)
# Only add in DEPEND_CFLAGS for CFLAGS on files we expect from DEPENDOBJS
# as those are the only ones we will include.
DEPEND_CFLAGS_CONDITION= "${DEPENDOBJS:M${.TARGET:${DEPEND_FILTER}}}" != ""
DEPEND_CFLAGS_CONDITION= "${DEPENDOBJS:${DEPEND_FILTER}:M${.TARGET:${DEPEND_FILTER}}}" != ""
CFLAGS+= ${${DEPEND_CFLAGS_CONDITION}:?${DEPEND_CFLAGS}:}
.else
CFLAGS+= ${DEPEND_CFLAGS}
@ -216,8 +216,17 @@ afterdepend: beforedepend
# For meta+filemon the .meta file is checked for since it is the dependency
# file used.
.for __obj in ${DEPENDOBJS:O:u}
.if (defined(_meta_filemon) && !exists(${.OBJDIR}/${__obj}.meta)) || \
(!defined(_meta_filemon) && !exists(${.OBJDIR}/${DEPENDFILE}.${__obj}))
# If the obj has any '/', then replace with '_'. For meta files, this is
# mimicing what bmake's meta_name() does and adding in the full path
# as well to ensure that the expected meta file is read.
.if ${__obj:M*/*}
_meta_obj= ${.OBJDIR:C,/,_,g}_${__obj:C,/,_,g}.meta
.else
_meta_obj= ${__obj}.meta
.endif
_dep_obj= ${DEPENDFILE}.${__obj:${DEPEND_FILTER}}
.if (defined(_meta_filemon) && !exists(${.OBJDIR}/${_meta_obj})) || \
(!defined(_meta_filemon) && !exists(${.OBJDIR}/${_dep_obj}))
${__obj}: ${OBJS_DEPEND_GUESS}
${__obj}: ${OBJS_DEPEND_GUESS.${__obj}}
.elif defined(_meta_filemon)

View File

@ -82,7 +82,7 @@ LIBIBMAD?= ${DESTDIR}${LIBDIR}/libibmad.a
LIBIBSDP?= ${DESTDIR}${LIBDIR}/libibsdp.a
LIBIBUMAD?= ${DESTDIR}${LIBDIR}/libibumad.a
LIBIBVERBS?= ${DESTDIR}${LIBDIR}/libibverbs.a
LIBIFC?= ${DESTDIR}${LIBDIR}/libifc.a
LIBIFCONFIG?= ${DESTDIR}${LIBDIR}/libifconfig.a
LIBIPSEC?= ${DESTDIR}${LIBDIR}/libipsec.a
LIBJAIL?= ${DESTDIR}${LIBDIR}/libjail.a
LIBKADM5CLNT?= ${DESTDIR}${LIBDIR}/libkadm5clnt.a

View File

@ -105,7 +105,7 @@ _LIBRARIES= \
heimntlm \
heimsqlite \
hx509 \
ifc \
ifconfig \
ipsec \
jail \
kadm5clnt \

View File

@ -4,18 +4,18 @@
# -----------------------------------------------------------------------------
#
# Short month names
1
2
3
4
5
6
7
8
9
10
11
12
!!#1TB
!!#2TB
!!#3TB
!!#4TB
!!#5TB
!!#6TB
!!#7TB
!!#8TB
!!#9TB
#1#0TB
#1#1TB
#1#2TB
#
# Long month names (as in a date)
一月
@ -63,7 +63,7 @@
下午
#
# date_fmt
%Y年%b月%e日 %A %X %Z
%Y年%_m月%e日 %A %X %Z
#
# Long month names (without case ending)
一月

View File

@ -4,18 +4,18 @@
# -----------------------------------------------------------------------------
#
# Short month names
1
2
3
4
5
6
7
8
9
10
11
12
1
2
3
4
5
6
7
8
9
10
11
12
#
# Long month names (as in a date)
一月
@ -63,7 +63,7 @@
下午
#
# date_fmt
%Y年%b月%e日 %A %X %Z
%Y年%_m月%e日 %A %X %Z
#
# Long month names (without case ending)
一月

View File

@ -4,18 +4,18 @@
# -----------------------------------------------------------------------------
#
# Short month names
1
2
3
4
5
6
7
8
9
10
11
12
1
2
3
4
5
6
7
8
9
10
11
12
#
# Long month names (as in a date)
一月
@ -63,7 +63,7 @@
下午
#
# date_fmt
%Y年%b月%e日 %A %X %Z
%Y年%_m月%e日 %A %X %Z
#
# Long month names (without case ending)
一月

View File

@ -4,18 +4,18 @@
# -----------------------------------------------------------------------------
#
# Short month names
1
2
3
4
5
6
7
8
9
10
11
12
 1月
 2月
 3月
 4月
 5月
 6月
 7月
 8月
 9月
10月
11月
12月
#
# Long month names (as in a date)
一月
@ -63,7 +63,7 @@
下午
#
# date_fmt
%Y年%b月%e日 %A %X %Z
%Y年%_m月%e日 %A %X %Z
#
# Long month names (without case ending)
一月

View File

@ -4,18 +4,18 @@
# -----------------------------------------------------------------------------
#
# Short month names
1
2
3
4
5
6
7
8
9
10
11
12
 1月
 2月
 3月
 4月
 5月
 6月
 7月
 8月
 9月
10月
11月
12月
#
# Long month names (as in a date)
1¤ë
@ -63,7 +63,7 @@
¤U¤È
#
# date_fmt
%Y¦~%b¤ë%e¤é %A %X %Z
%Y年%_m月%e日 %A %X %Z
#
# Long month names (without case ending)
1¤ë

View File

@ -4,18 +4,18 @@
# -----------------------------------------------------------------------------
#
# Short month names
1
2
3
4
5
6
7
8
9
10
11
12
1
2
3
4
5
6
7
8
9
10
11
12
#
# Long month names (as in a date)
1月
@ -63,7 +63,7 @@
下午
#
# date_fmt
%Y年%b月%e日 %A %X %Z
%Y年%_m月%e日 %A %X %Z
#
# Long month names (without case ending)
1月

View File

@ -5843,6 +5843,14 @@ safe_to_clear_referenced(pmap_t pmap, pt_entry_t pte)
* should be tested and standardized at some point in the future for
* optimal aging of shared pages.
*
* As an optimization, update the page's dirty field if a modified bit is
* found while counting reference bits. This opportunistic update can be
* performed at low cost and can eliminate the need for some future calls
* to pmap_is_modified(). However, since this function stops after
* finding PMAP_TS_REFERENCED_MAX reference bits, it may not detect some
* dirty pages. Those dirty pages will only be detected by a future call
* to pmap_is_modified().
*
* A DI block is not needed within this function, because
* invalidations are performed before the PV list lock is
* released.
@ -5855,7 +5863,7 @@ pmap_ts_referenced(vm_page_t m)
pmap_t pmap;
struct rwlock *lock;
pd_entry_t oldpde, *pde;
pt_entry_t *pte, PG_A;
pt_entry_t *pte, PG_A, PG_M, PG_RW;
vm_offset_t va;
vm_paddr_t pa;
int cleared, md_gen, not_cleared, pvh_gen;
@ -5890,9 +5898,19 @@ pmap_ts_referenced(vm_page_t m)
}
}
PG_A = pmap_accessed_bit(pmap);
PG_M = pmap_modified_bit(pmap);
PG_RW = pmap_rw_bit(pmap);
va = pv->pv_va;
pde = pmap_pde(pmap, pv->pv_va);
oldpde = *pde;
if ((oldpde & (PG_M | PG_RW)) == (PG_M | PG_RW)) {
/*
* Although "oldpde" is mapping a 2MB page, because
* this function is called at a 4KB page granularity,
* we only update the 4KB page under test.
*/
vm_page_dirty(m);
}
if ((*pde & PG_A) != 0) {
/*
* Since this reference bit is shared by 512 4KB
@ -5986,11 +6004,15 @@ pmap_ts_referenced(vm_page_t m)
}
}
PG_A = pmap_accessed_bit(pmap);
PG_M = pmap_modified_bit(pmap);
PG_RW = pmap_rw_bit(pmap);
pde = pmap_pde(pmap, pv->pv_va);
KASSERT((*pde & PG_PS) == 0,
("pmap_ts_referenced: found a 2mpage in page %p's pv list",
m));
pte = pmap_pde_to_pte(pde, pv->pv_va);
if ((*pte & (PG_M | PG_RW)) == (PG_M | PG_RW))
vm_page_dirty(m);
if ((*pte & PG_A) != 0) {
if (safe_to_clear_referenced(pmap, *pte)) {
atomic_clear_long(pte, PG_A);

View File

@ -61,8 +61,13 @@ __FBSDID("$FreeBSD$");
MALLOC_DEFINE(M_AXP81X_REG, "AXP81x regulator", "AXP81x power regulator");
#define AXP_ICTYPE 0x03
#define AXP_POWERCTL1 0x10
#define AXP_POWERCTL1_DCDC2 (1 << 1)
#define AXP_POWERCTL2 0x12
#define AXP_POWERCTL2_DC1SW (1 << 7)
#define AXP_VOLTCTL_DCDC2 0x21
#define AXP_VOLTCTL_STATUS (1 << 7)
#define AXP_VOLTCTL_MASK 0x7f
#define AXP_POWERBAT 0x32
#define AXP_POWERBAT_SHUTDOWN (1 << 7)
#define AXP_IRQEN1 0x40
@ -109,10 +114,18 @@ struct axp81x_regdef {
char *supply_name;
uint8_t enable_reg;
uint8_t enable_mask;
uint8_t voltage_reg;
int voltage_min;
int voltage_max;
int voltage_step1;
int voltage_nstep1;
int voltage_step2;
int voltage_nstep2;
};
enum axp81x_reg_id {
AXP81X_REG_ID_DC1SW
AXP81X_REG_ID_DC1SW,
AXP81X_REG_ID_DCDC2,
};
static struct axp81x_regdef axp81x_regdefs[] = {
@ -122,6 +135,19 @@ static struct axp81x_regdef axp81x_regdefs[] = {
.enable_reg = AXP_POWERCTL2,
.enable_mask = AXP_POWERCTL2_DC1SW,
},
{
.id = AXP81X_REG_ID_DCDC2,
.name = "dcdc2",
.enable_reg = AXP_POWERCTL1,
.enable_mask = AXP_POWERCTL1_DCDC2,
.voltage_reg = AXP_VOLTCTL_DCDC2,
.voltage_min = 500,
.voltage_max = 1300,
.voltage_step1 = 10,
.voltage_nstep1 = 70,
.voltage_step2 = 20,
.voltage_nstep2 = 5,
},
};
struct axp81x_softc;
@ -218,17 +244,82 @@ axp81x_regnode_enable(struct regnode *regnode, bool enable, int *udelay)
return (0);
}
static void
axp81x_regnode_reg_to_voltage(struct axp81x_reg_sc *sc, uint8_t val, int *uv)
{
if (val < sc->def->voltage_nstep1)
*uv = sc->def->voltage_min + val * sc->def->voltage_step1;
else
*uv = sc->def->voltage_min +
(sc->def->voltage_nstep1 * sc->def->voltage_step1) +
((val - sc->def->voltage_nstep1) * sc->def->voltage_step2);
*uv *= 1000;
}
static int
axp81x_regnode_voltage_to_reg(struct axp81x_reg_sc *sc, int min_uvolt,
int max_uvolt, uint8_t *val)
{
uint8_t nval;
int nstep, uvolt;
nval = 0;
uvolt = sc->def->voltage_min * 1000;
for (nstep = 0; nstep < sc->def->voltage_nstep1 && uvolt < min_uvolt;
nstep++) {
++nval;
uvolt += (sc->def->voltage_step1 * 1000);
}
for (nstep = 0; nstep < sc->def->voltage_nstep2 && uvolt < min_uvolt;
nstep++) {
++nval;
uvolt += (sc->def->voltage_step2 * 1000);
}
if (uvolt > max_uvolt)
return (EINVAL);
*val = nval;
return (0);
}
static int
axp81x_regnode_set_voltage(struct regnode *regnode, int min_uvolt,
int max_uvolt, int *udelay)
{
return (ENXIO);
struct axp81x_reg_sc *sc;
uint8_t val;
sc = regnode_get_softc(regnode);
if (!sc->def->voltage_step1 || !sc->def->voltage_step2)
return (ENXIO);
if (axp81x_regnode_voltage_to_reg(sc, min_uvolt, max_uvolt, &val) != 0)
return (ERANGE);
axp81x_write(sc->base_dev, sc->def->voltage_reg, val);
*udelay = 0;
return (0);
}
static int
axp81x_regnode_get_voltage(struct regnode *regnode, int *uvolt)
{
return (ENXIO);
struct axp81x_reg_sc *sc;
uint8_t val;
sc = regnode_get_softc(regnode);
if (!sc->def->voltage_step1 || !sc->def->voltage_step2)
return (ENXIO);
axp81x_read(sc->base_dev, sc->def->voltage_reg, &val, 1);
axp81x_regnode_reg_to_voltage(sc, val & AXP_VOLTCTL_MASK, uvolt);
return (0);
}
static regnode_method_t axp81x_regnode_methods[] = {
@ -519,6 +610,10 @@ axp81x_reg_attach(device_t dev, phandle_t node,
memset(&initdef, 0, sizeof(initdef));
regulator_parse_ofw_stdparam(dev, node, &initdef);
if (initdef.std_param.min_uvolt == 0)
initdef.std_param.min_uvolt = def->voltage_min * 1000;
if (initdef.std_param.max_uvolt == 0)
initdef.std_param.max_uvolt = def->voltage_max * 1000;
initdef.id = def->id;
initdef.ofw_node = node;
regnode = regnode_create(dev, &axp81x_regnode_class, &initdef);

View File

@ -110,14 +110,14 @@ __FBSDID("$FreeBSD$");
#define A13_PLL2_PRE_DIV (0x1f << 0)
#define A13_PLL2_PRE_DIV_SHIFT 0
#define A23_PLL1_FACTOR_P (0x3 << 16)
#define A23_PLL1_FACTOR_P_SHIFT 16
#define A23_PLL1_FACTOR_N (0x1f << 8)
#define A23_PLL1_FACTOR_N_SHIFT 8
#define A23_PLL1_FACTOR_K (0x3 << 4)
#define A23_PLL1_FACTOR_K_SHIFT 4
#define A23_PLL1_FACTOR_M (0x3 << 0)
#define A23_PLL1_FACTOR_M_SHIFT 0
#define A23_PLL1_FACTOR_P (0x3 << 16)
#define A23_PLL1_FACTOR_P_SHIFT 16
#define A31_PLL1_LOCK (1 << 28)
#define A31_PLL1_CPU_SIGMA_DELTA_EN (1 << 24)
@ -171,6 +171,24 @@ __FBSDID("$FreeBSD$");
#define CLKID_A31_PLL6 0
#define CLKID_A31_PLL6_X2 1
struct aw_pll_factor {
unsigned int n;
unsigned int k;
unsigned int m;
unsigned int p;
uint64_t freq;
};
#define PLLFACTOR(_n, _k, _m, _p, _freq) \
{ .n = (_n), .k = (_k), .m = (_m), .p = (_p), .freq = (_freq) }
static struct aw_pll_factor aw_a23_pll1_factors[] = {
PLLFACTOR(16, 0, 0, 0, 408000000),
PLLFACTOR(26, 0, 0, 0, 648000000),
PLLFACTOR(16, 1, 0, 0, 816000000),
PLLFACTOR(20, 1, 0, 0, 1008000000),
PLLFACTOR(24, 1, 0, 0, 1200000000),
};
enum aw_pll_type {
AWPLL_A10_PLL1 = 1,
AWPLL_A10_PLL2,
@ -556,6 +574,39 @@ a13_pll2_set_freq(struct aw_pll_sc *sc, uint64_t fin, uint64_t *fout,
return (0);
}
static int
a23_pll1_set_freq(struct aw_pll_sc *sc, uint64_t fin, uint64_t *fout,
int flags)
{
struct aw_pll_factor *f;
uint32_t val;
int n;
f = NULL;
for (n = 0; n < nitems(aw_a23_pll1_factors); n++) {
if (aw_a23_pll1_factors[n].freq == *fout) {
f = &aw_a23_pll1_factors[n];
break;
}
}
if (f == NULL)
return (EINVAL);
DEVICE_LOCK(sc);
PLL_READ(sc, &val);
val &= ~(A23_PLL1_FACTOR_N|A23_PLL1_FACTOR_K|A23_PLL1_FACTOR_M|
A23_PLL1_FACTOR_P);
val |= (f->n << A23_PLL1_FACTOR_N_SHIFT);
val |= (f->k << A23_PLL1_FACTOR_K_SHIFT);
val |= (f->m << A23_PLL1_FACTOR_M_SHIFT);
val |= (f->p << A23_PLL1_FACTOR_P_SHIFT);
PLL_WRITE(sc, val);
DEVICE_UNLOCK(sc);
return (0);
}
static int
a23_pll1_recalc(struct aw_pll_sc *sc, uint64_t *freq)
{
@ -719,7 +770,7 @@ static struct aw_pll_funcs aw_pll_func[] = {
PLL(AWPLL_A10_PLL5, a10_pll5_recalc, NULL, NULL),
PLL(AWPLL_A10_PLL6, a10_pll6_recalc, a10_pll6_set_freq, a10_pll6_init),
PLL(AWPLL_A13_PLL2, a13_pll2_recalc, a13_pll2_set_freq, NULL),
PLL(AWPLL_A23_PLL1, a23_pll1_recalc, NULL, NULL),
PLL(AWPLL_A23_PLL1, a23_pll1_recalc, a23_pll1_set_freq, NULL),
PLL(AWPLL_A31_PLL1, a31_pll1_recalc, NULL, NULL),
PLL(AWPLL_A31_PLL6, a31_pll6_recalc, NULL, a31_pll6_init),
PLL(AWPLL_A80_PLL4, a80_pll4_recalc, NULL, NULL),

View File

@ -416,8 +416,17 @@ cpu_flush_dcache(void *ptr, size_t len)
int
cpu_est_clockrate(int cpu_id, uint64_t *rate)
{
struct pcpu *pc;
panic("ARM64TODO: cpu_est_clockrate");
pc = pcpu_find(cpu_id);
if (pc == NULL || rate == NULL)
return (EINVAL);
if (pc->pc_clock == 0)
return (EOPNOTSUPP);
*rate = pc->pc_clock;
return (0);
}
void

View File

@ -2732,7 +2732,9 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
if (pde != NULL && lvl == 1) {
l2 = pmap_l1_to_l2(pde, va);
if ((pmap_load(l2) & ATTR_DESCR_MASK) == L2_BLOCK &&
(l3 = pmap_demote_l2_locked(pmap, l2, va, &lock)) != NULL) {
(l3 = pmap_demote_l2_locked(pmap, l2, va & ~L2_OFFSET,
&lock)) != NULL) {
l3 = &l3[pmap_l3_index(va)];
if (va < VM_MAXUSER_ADDRESS) {
mpte = PHYS_TO_VM_PAGE(
pmap_load(l2) & ~ATTR_MASK);
@ -2944,7 +2946,6 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, vm_prot_t prot,
pmap_superpages_enabled() &&
(m->flags & PG_FICTITIOUS) == 0 &&
vm_reserv_level_iffullpop(m) == 0) {
KASSERT(lvl == 2, ("Invalid pde level %d", lvl));
pmap_promote_l2(pmap, pde, va, &lock);
}
}

View File

@ -38,7 +38,8 @@
#define PCPU_MD_FIELDS \
u_int pc_acpi_id; /* ACPI CPU id */ \
u_int pc_midr; /* stored MIDR value */ \
char __pad[121]
uint64_t pc_clock; \
char __pad[113]
#ifdef _KERNEL

View File

@ -1,5 +1,5 @@
/*-
* Copyright (c) 2016 Ruslan Bukin <br@bsdpad.com>
* Copyright (c) 2015-2016 Ruslan Bukin <br@bsdpad.com>
* All rights reserved.
*
* Portions of this software were developed by SRI International and the
@ -37,8 +37,8 @@
/dts-v1/;
/ {
model = "UC Berkeley Spike Simulator RV64I";
compatible = "riscv,rv64i";
model = "RocketChip RV64";
compatible = "riscv,rv64";
#address-cells = <1>;
#size-cells = <1>;
#interrupt-cells = <1>;
@ -49,8 +49,8 @@
cpu@0 {
device_type = "cpu";
compatible = "riscv,rv64i";
reg = <0x40002000>;
compatible = "riscv,rv64";
reg = <0x0>;
};
};
@ -59,13 +59,17 @@
};
memory {
/*
* This is not used currently.
* We take information from sbi_query_memory.
*/
device_type = "memory";
reg = <0x0 0x10000000>; /* 256MB at 0x0 */
reg = <0x80000000 0x10000000>; /* 256MB at 0x80000000 */
};
soc {
#address-cells = <2>;
#size-cells = <2>;
#address-cells = <1>;
#size-cells = <1>;
#interrupt-cells = <1>;
compatible = "simple-bus";
@ -78,7 +82,9 @@
timer0: timer@0 {
compatible = "riscv,timer";
interrupts = < 1 >;
reg = < 0x4400bff8 0x0008 >, /* rtc */
< 0x44004000 0x1000 >; /* timecmp */
interrupts = < 5 >;
interrupt-parent = < &pic0 >;
clock-frequency = < 1000000 >;
};

View File

@ -50,13 +50,13 @@
cpu@0 {
device_type = "cpu";
compatible = "riscv,rv64";
reg = <0x40001000>;
reg = <0x0>;
};
cpu@1 {
device_type = "cpu";
compatible = "riscv,rv64";
reg = <0x40002000>;
reg = <0x0>;
};
};
@ -88,7 +88,8 @@
timer0: timer@0 {
compatible = "riscv,timer";
reg = < 0x40000000 0x100 >;
reg = < 0x40000000 0x0008 >, /* rtc */
< 0x40000008 0x1000 >; /* timecmp */
interrupts = < 5 >;
interrupt-parent = < &pic0 >;
clock-frequency = < 1000000 >;

View File

@ -244,6 +244,7 @@ static int
bd_int13probe(struct bdinfo *bd)
{
struct edd_params params;
int ret = 1; /* assume success */
v86.ctl = V86_FLAGS;
v86.addr = 0x13;
@ -251,11 +252,14 @@ bd_int13probe(struct bdinfo *bd)
v86.edx = bd->bd_unit;
v86int();
/* Don't error out if we get bad sector number, try EDD as well */
if (V86_CY(v86.efl) || /* carry set */
(v86.ecx & 0x3f) == 0 || /* absurd sector number */
(v86.edx & 0xff) <= (unsigned)(bd->bd_unit & 0x7f)) /* unit # bad */
return (0); /* skip device */
if ((v86.ecx & 0x3f) == 0) /* absurd sector number */
ret = 0; /* set error */
/* Convert max cyl # -> # of cylinders */
bd->bd_cyl = ((v86.ecx & 0xc0) << 2) + ((v86.ecx & 0xff00) >> 8) + 1;
/* Convert max head # -> # of heads */
@ -280,7 +284,8 @@ bd_int13probe(struct bdinfo *bd)
if (V86_CY(v86.efl) || /* carry set */
(v86.ebx & 0xffff) != 0xaa55 || /* signature */
(v86.ecx & EDD_INTERFACE_FIXED_DISK) == 0)
return (1);
return (ret); /* return code from int13 AH=08 */
/* EDD supported */
bd->bd_flags |= BD_MODEEDD1;
if ((v86.eax & 0xff00) >= 0x3000)
@ -295,12 +300,22 @@ bd_int13probe(struct bdinfo *bd)
v86.esi = VTOPOFF(&params);
v86int();
if (!V86_CY(v86.efl)) {
bd->bd_sectors = params.sectors;
uint64_t total;
if (params.sectors != 0)
bd->bd_sectors = params.sectors;
total = (uint64_t)params.cylinders *
params.heads * params.sectors_per_track;
if (bd->bd_sectors < total)
bd->bd_sectors = total;
bd->bd_sectorsize = params.sector_size;
ret = 1;
}
DEBUG("unit 0x%x flags %x, sectors %llu, sectorsize %u",
bd->bd_unit, bd->bd_flags, bd->bd_sectors, bd->bd_sectorsize);
return (1);
return (ret);
}
/*

View File

@ -1629,6 +1629,8 @@ nvlist_lookup_nvpair_ei_sep(nvlist_t *nvl, const char *name, const char sep,
if ((nvl == NULL) || (name == NULL))
return (EINVAL);
sepp = NULL;
idx = 0;
/* step through components of name */
for (np = name; np && *np; np = sepp) {
/* ensure unique names */
@ -2386,7 +2388,7 @@ nvlist_xpack(nvlist_t *nvl, char **bufp, size_t *buflen, int encoding,
*/
nv_priv_init(&nvpriv, nva, 0);
if (err = nvlist_size(nvl, &alloc_size, encoding))
if ((err = nvlist_size(nvl, &alloc_size, encoding)))
return (err);
if ((buf = nv_mem_zalloc(&nvpriv, alloc_size)) == NULL)

View File

@ -22,6 +22,7 @@
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2010 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright 2016 Igor Kozhukhov <ikozhukhov@gmail.com>
*/
#include <sys/zfs_context.h>
@ -177,8 +178,9 @@ zfs_deleg_verify_nvlist(nvlist_t *nvp)
nvpair_name(perm_name));
if (error)
return (-1);
} while (perm_name = nvlist_next_nvpair(perms, perm_name));
} while (who = nvlist_next_nvpair(nvp, who));
} while ((perm_name = nvlist_next_nvpair(perms, perm_name))
!= NULL);
} while ((who = nvlist_next_nvpair(nvp, who)) != NULL);
return (0);
}

View File

@ -55,8 +55,52 @@ zfs_cmd_compat_get(zfs_cmd_t *zc, caddr_t addr, const int cflag)
zfs_cmd_zcmd_t *zcmd_c;
zfs_cmd_edbp_t *edbp_c;
zfs_cmd_resume_t *resume_c;
zfs_cmd_inlanes_t *inlanes_c;
switch (cflag) {
case ZFS_CMD_COMPAT_INLANES:
inlanes_c = (void *)addr;
/* zc */
strlcpy(zc->zc_name, inlanes_c->zc_name, MAXPATHLEN);
strlcpy(zc->zc_value, inlanes_c->zc_value, MAXPATHLEN * 2);
strlcpy(zc->zc_string, inlanes_c->zc_string, MAXPATHLEN);
#define FIELD_COPY(field) zc->field = inlanes_c->field
FIELD_COPY(zc_nvlist_src);
FIELD_COPY(zc_nvlist_src_size);
FIELD_COPY(zc_nvlist_dst);
FIELD_COPY(zc_nvlist_dst_size);
FIELD_COPY(zc_nvlist_dst_filled);
FIELD_COPY(zc_pad2);
FIELD_COPY(zc_history);
FIELD_COPY(zc_guid);
FIELD_COPY(zc_nvlist_conf);
FIELD_COPY(zc_nvlist_conf_size);
FIELD_COPY(zc_cookie);
FIELD_COPY(zc_objset_type);
FIELD_COPY(zc_perm_action);
FIELD_COPY(zc_history_len);
FIELD_COPY(zc_history_offset);
FIELD_COPY(zc_obj);
FIELD_COPY(zc_iflags);
FIELD_COPY(zc_share);
FIELD_COPY(zc_jailid);
FIELD_COPY(zc_objset_stats);
FIELD_COPY(zc_begin_record);
FIELD_COPY(zc_inject_record);
FIELD_COPY(zc_defer_destroy);
FIELD_COPY(zc_flags);
FIELD_COPY(zc_action_handle);
FIELD_COPY(zc_cleanup_fd);
FIELD_COPY(zc_simple);
FIELD_COPY(zc_resumable);
FIELD_COPY(zc_sendobj);
FIELD_COPY(zc_fromobj);
FIELD_COPY(zc_createtxg);
FIELD_COPY(zc_stat);
#undef FIELD_COPY
break;
case ZFS_CMD_COMPAT_RESUME:
resume_c = (void *)addr;
/* zc */
@ -434,8 +478,50 @@ zfs_cmd_compat_put(zfs_cmd_t *zc, caddr_t addr, const int request,
zfs_cmd_zcmd_t *zcmd_c;
zfs_cmd_edbp_t *edbp_c;
zfs_cmd_resume_t *resume_c;
zfs_cmd_inlanes_t *inlanes_c;
switch (cflag) {
case ZFS_CMD_COMPAT_INLANES:
inlanes_c = (void *)addr;
strlcpy(inlanes_c->zc_name, zc->zc_name, MAXPATHLEN);
strlcpy(inlanes_c->zc_value, zc->zc_value, MAXPATHLEN * 2);
strlcpy(inlanes_c->zc_string, zc->zc_string, MAXPATHLEN);
#define FIELD_COPY(field) inlanes_c->field = zc->field
FIELD_COPY(zc_nvlist_src);
FIELD_COPY(zc_nvlist_src_size);
FIELD_COPY(zc_nvlist_dst);
FIELD_COPY(zc_nvlist_dst_size);
FIELD_COPY(zc_nvlist_dst_filled);
FIELD_COPY(zc_pad2);
FIELD_COPY(zc_history);
FIELD_COPY(zc_guid);
FIELD_COPY(zc_nvlist_conf);
FIELD_COPY(zc_nvlist_conf_size);
FIELD_COPY(zc_cookie);
FIELD_COPY(zc_objset_type);
FIELD_COPY(zc_perm_action);
FIELD_COPY(zc_history_len);
FIELD_COPY(zc_history_offset);
FIELD_COPY(zc_obj);
FIELD_COPY(zc_iflags);
FIELD_COPY(zc_share);
FIELD_COPY(zc_jailid);
FIELD_COPY(zc_objset_stats);
FIELD_COPY(zc_begin_record);
FIELD_COPY(zc_inject_record);
FIELD_COPY(zc_defer_destroy);
FIELD_COPY(zc_flags);
FIELD_COPY(zc_action_handle);
FIELD_COPY(zc_cleanup_fd);
FIELD_COPY(zc_simple);
FIELD_COPY(zc_sendobj);
FIELD_COPY(zc_fromobj);
FIELD_COPY(zc_createtxg);
FIELD_COPY(zc_stat);
#undef FIELD_COPY
break;
case ZFS_CMD_COMPAT_RESUME:
resume_c = (void *)addr;
strlcpy(resume_c->zc_name, zc->zc_name, MAXPATHLEN);
@ -987,6 +1073,12 @@ zcmd_ioctl_compat(int fd, int request, zfs_cmd_t *zc, const int cflag)
zp.zfs_cmd_size = sizeof(zfs_cmd_t);
zp.zfs_ioctl_version = ZFS_IOCVER_CURRENT;
return (ioctl(fd, ncmd, &zp));
case ZFS_CMD_COMPAT_INLANES:
ncmd = _IOWR('Z', request, struct zfs_iocparm);
zp.zfs_cmd = (uint64_t)zc;
zp.zfs_cmd_size = sizeof(zfs_cmd_inlanes_t);
zp.zfs_ioctl_version = ZFS_IOCVER_INLANES;
return (ioctl(fd, ncmd, &zp));
case ZFS_CMD_COMPAT_RESUME:
ncmd = _IOWR('Z', request, struct zfs_iocparm);
zp.zfs_cmd = (uint64_t)zc;
@ -1104,7 +1196,7 @@ zfs_ioctl_compat_innvl(zfs_cmd_t *zc, nvlist_t * innvl, const int vec,
if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC ||
cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP ||
cflag == ZFS_CMD_COMPAT_RESUME)
cflag == ZFS_CMD_COMPAT_RESUME || cflag == ZFS_CMD_COMPAT_INLANES)
goto out;
switch (vec) {
@ -1257,7 +1349,7 @@ zfs_ioctl_compat_outnvl(zfs_cmd_t *zc, nvlist_t * outnvl, const int vec,
if (cflag == ZFS_CMD_COMPAT_NONE || cflag == ZFS_CMD_COMPAT_LZC ||
cflag == ZFS_CMD_COMPAT_ZCMD || cflag == ZFS_CMD_COMPAT_EDBP ||
cflag == ZFS_CMD_COMPAT_RESUME)
cflag == ZFS_CMD_COMPAT_RESUME || cflag == ZFS_CMD_COMPAT_INLANES)
return (outnvl);
switch (vec) {

View File

@ -54,7 +54,8 @@ extern "C" {
#define ZFS_IOCVER_EDBP 4
#define ZFS_IOCVER_RESUME 5
#define ZFS_IOCVER_INLANES 6
#define ZFS_IOCVER_CURRENT ZFS_IOCVER_INLANES
#define ZFS_IOCVER_PAD 7
#define ZFS_IOCVER_CURRENT ZFS_IOCVER_PAD
/* compatibility conversion flag */
#define ZFS_CMD_COMPAT_NONE 0
@ -65,6 +66,7 @@ extern "C" {
#define ZFS_CMD_COMPAT_ZCMD 5
#define ZFS_CMD_COMPAT_EDBP 6
#define ZFS_CMD_COMPAT_RESUME 7
#define ZFS_CMD_COMPAT_INLANES 8
#define ZFS_IOC_COMPAT_PASS 254
#define ZFS_IOC_COMPAT_FAIL 255
@ -355,6 +357,49 @@ typedef struct zfs_cmd_resume {
zfs_stat_t zc_stat;
} zfs_cmd_resume_t;
typedef struct zfs_cmd_inlanes {
char zc_name[MAXPATHLEN]; /* name of pool or dataset */
uint64_t zc_nvlist_src; /* really (char *) */
uint64_t zc_nvlist_src_size;
uint64_t zc_nvlist_dst; /* really (char *) */
uint64_t zc_nvlist_dst_size;
boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
int zc_pad2;
/*
* The following members are for legacy ioctls which haven't been
* converted to the new method.
*/
uint64_t zc_history; /* really (char *) */
char zc_value[MAXPATHLEN * 2];
char zc_string[MAXNAMELEN];
uint64_t zc_guid;
uint64_t zc_nvlist_conf; /* really (char *) */
uint64_t zc_nvlist_conf_size;
uint64_t zc_cookie;
uint64_t zc_objset_type;
uint64_t zc_perm_action;
uint64_t zc_history_len;
uint64_t zc_history_offset;
uint64_t zc_obj;
uint64_t zc_iflags; /* internal to zfs(7fs) */
zfs_share_t zc_share;
uint64_t zc_jailid;
dmu_objset_stats_t zc_objset_stats;
dmu_replay_record_t zc_begin_record;
zinject_record_t zc_inject_record;
uint32_t zc_defer_destroy;
uint32_t zc_flags;
uint64_t zc_action_handle;
int zc_cleanup_fd;
uint8_t zc_simple;
boolean_t zc_resumable;
uint64_t zc_sendobj;
uint64_t zc_fromobj;
uint64_t zc_createtxg;
zfs_stat_t zc_stat;
} zfs_cmd_inlanes_t;
#ifdef _KERNEL
unsigned static long zfs_ioctl_v15_to_v28[] = {
0, /* 0 ZFS_IOC_POOL_CREATE */

View File

@ -69,7 +69,7 @@ zfs_component_namecheck(const char *path, namecheck_err_t *why, char *what)
{
const char *loc;
if (strlen(path) >= MAXNAMELEN) {
if (strlen(path) >= ZFS_MAX_DATASET_NAME_LEN) {
if (why)
*why = NAME_ERR_TOOLONG;
return (-1);
@ -140,14 +140,9 @@ dataset_namecheck(const char *path, namecheck_err_t *why, char *what)
/*
* Make sure the name is not too long.
*
* ZFS_MAXNAMELEN is the maximum dataset length used in the userland
* which is the same as MAXNAMELEN used in the kernel.
* If ZFS_MAXNAMELEN value is changed, make sure to cleanup all
* places using MAXNAMELEN.
*/
if (strlen(path) >= MAXNAMELEN) {
if (strlen(path) >= ZFS_MAX_DATASET_NAME_LEN) {
if (why)
*why = NAME_ERR_TOOLONG;
return (-1);
@ -276,7 +271,7 @@ mountpoint_namecheck(const char *path, namecheck_err_t *why)
while (*end != '/' && *end != '\0')
end++;
if (end - start >= MAXNAMELEN) {
if (end - start >= ZFS_MAX_DATASET_NAME_LEN) {
if (why)
*why = NAME_ERR_TOOLONG;
return (-1);
@ -301,13 +296,8 @@ pool_namecheck(const char *pool, namecheck_err_t *why, char *what)
/*
* Make sure the name is not too long.
*
* ZPOOL_MAXNAMELEN is the maximum pool length used in the userland
* which is the same as MAXNAMELEN used in the kernel.
* If ZPOOL_MAXNAMELEN value is changed, make sure to cleanup all
* places using MAXNAMELEN.
*/
if (strlen(pool) >= MAXNAMELEN) {
if (strlen(pool) >= ZFS_MAX_DATASET_NAME_LEN) {
if (why)
*why = NAME_ERR_TOOLONG;
return (-1);

View File

@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
*/
@ -220,9 +220,10 @@ bptree_iterate(objset_t *os, uint64_t obj, boolean_t free, bptree_itor_t func,
if (zfs_free_leak_on_eio)
flags |= TRAVERSE_HARD;
zfs_dbgmsg("bptree index %d: traversing from min_txg=%lld "
zfs_dbgmsg("bptree index %lld: traversing from min_txg=%lld "
"bookmark %lld/%lld/%lld/%lld",
i, (longlong_t)bte.be_birth_txg,
(longlong_t)i,
(longlong_t)bte.be_birth_txg,
(longlong_t)bte.be_zb.zb_objset,
(longlong_t)bte.be_zb.zb_object,
(longlong_t)bte.be_zb.zb_level,

View File

@ -621,7 +621,7 @@ dmu_objset_refresh_ownership(objset_t *os, void *tag)
{
dsl_pool_t *dp;
dsl_dataset_t *ds, *newds;
char name[MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
ds = os->os_dsl_dataset;
VERIFY3P(ds, !=, NULL);
@ -791,11 +791,17 @@ dmu_objset_create_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *bp,
/*
* Determine the number of levels necessary for the meta-dnode
* to contain DN_MAX_OBJECT dnodes.
* to contain DN_MAX_OBJECT dnodes. Note that in order to
* ensure that we do not overflow 64 bits, there has to be
* a nlevels that gives us a number of blocks > DN_MAX_OBJECT
* but < 2^64. Therefore,
* (mdn->dn_indblkshift - SPA_BLKPTRSHIFT) (10) must be
* less than (64 - log2(DN_MAX_OBJECT)) (16).
*/
while ((uint64_t)mdn->dn_nblkptr << (mdn->dn_datablkshift +
while ((uint64_t)mdn->dn_nblkptr <<
(mdn->dn_datablkshift - DNODE_SHIFT +
(levels - 1) * (mdn->dn_indblkshift - SPA_BLKPTRSHIFT)) <
DN_MAX_OBJECT * sizeof (dnode_phys_t))
DN_MAX_OBJECT)
levels++;
mdn->dn_next_nlevels[tx->tx_txg & TXG_MASK] =
@ -839,6 +845,9 @@ dmu_objset_create_check(void *arg, dmu_tx_t *tx)
if (strchr(doca->doca_name, '@') != NULL)
return (SET_ERROR(EINVAL));
if (strlen(doca->doca_name) >= ZFS_MAX_DATASET_NAME_LEN)
return (SET_ERROR(ENAMETOOLONG));
error = dsl_dir_hold(dp, doca->doca_name, FTAG, &pdd, &tail);
if (error != 0)
return (error);
@ -923,6 +932,9 @@ dmu_objset_clone_check(void *arg, dmu_tx_t *tx)
if (strchr(doca->doca_clone, '@') != NULL)
return (SET_ERROR(EINVAL));
if (strlen(doca->doca_clone) >= ZFS_MAX_DATASET_NAME_LEN)
return (SET_ERROR(ENAMETOOLONG));
error = dsl_dir_hold(dp, doca->doca_clone, FTAG, &pdd, &tail);
if (error != 0)
return (error);
@ -962,7 +974,7 @@ dmu_objset_clone_sync(void *arg, dmu_tx_t *tx)
const char *tail;
dsl_dataset_t *origin, *ds;
uint64_t obj;
char namebuf[MAXNAMELEN];
char namebuf[ZFS_MAX_DATASET_NAME_LEN];
VERIFY0(dsl_dir_hold(dp, doca->doca_clone, FTAG, &pdd, &tail));
VERIFY0(dsl_dataset_hold(dp, doca->doca_origin, FTAG, &origin));
@ -1973,7 +1985,7 @@ dmu_objset_get_user(objset_t *os)
/*
* Determine name of filesystem, given name of snapshot.
* buf must be at least MAXNAMELEN bytes
* buf must be at least ZFS_MAX_DATASET_NAME_LEN bytes
*/
int
dmu_fsname(const char *snapname, char *buf)
@ -1981,7 +1993,7 @@ dmu_fsname(const char *snapname, char *buf)
char *atp = strchr(snapname, '@');
if (atp == NULL)
return (SET_ERROR(EINVAL));
if (atp - snapname >= MAXNAMELEN)
if (atp - snapname >= ZFS_MAX_DATASET_NAME_LEN)
return (SET_ERROR(ENAMETOOLONG));
(void) strlcpy(buf, snapname, atp - snapname + 1);
return (0);

View File

@ -1347,7 +1347,7 @@ dmu_recv_begin_check(void *arg, dmu_tx_t *tx)
dsl_dataset_rele(ds, FTAG);
} else if (error == ENOENT) {
/* target fs does not exist; must be a full backup or clone */
char buf[MAXNAMELEN];
char buf[ZFS_MAX_DATASET_NAME_LEN];
/*
* If it's a non-clone incremental, we are missing the
@ -1367,7 +1367,7 @@ dmu_recv_begin_check(void *arg, dmu_tx_t *tx)
return (SET_ERROR(EINVAL));
/* Open the parent of tofs */
ASSERT3U(strlen(tofs), <, MAXNAMELEN);
ASSERT3U(strlen(tofs), <, sizeof (buf));
(void) strlcpy(buf, tofs, strrchr(tofs, '/') - tofs + 1);
error = dsl_dataset_hold(dp, buf, FTAG, &ds);
if (error != 0)
@ -1551,7 +1551,8 @@ dmu_recv_resume_begin_check(void *arg, dmu_tx_t *tx)
!spa_feature_is_enabled(dp->dp_spa, SPA_FEATURE_LZ4_COMPRESS))
return (SET_ERROR(ENOTSUP));
char recvname[ZFS_MAXNAMELEN];
/* 6 extra bytes for /%recv */
char recvname[ZFS_MAX_DATASET_NAME_LEN + 6];
(void) snprintf(recvname, sizeof (recvname), "%s/%s",
tofs, recv_clone_name);
@ -1624,7 +1625,8 @@ dmu_recv_resume_begin_sync(void *arg, dmu_tx_t *tx)
const char *tofs = drba->drba_cookie->drc_tofs;
dsl_dataset_t *ds;
uint64_t dsobj;
char recvname[ZFS_MAXNAMELEN];
/* 6 extra bytes for /%recv */
char recvname[ZFS_MAX_DATASET_NAME_LEN + 6];
(void) snprintf(recvname, sizeof (recvname), "%s/%s",
tofs, recv_clone_name);
@ -2364,7 +2366,7 @@ dmu_recv_cleanup_ds(dmu_recv_cookie_t *drc)
txg_wait_synced(drc->drc_ds->ds_dir->dd_pool, 0);
dsl_dataset_disown(drc->drc_ds, dmu_recv_tag);
} else {
char name[MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
dsl_dataset_name(drc->drc_ds, name);
dsl_dataset_disown(drc->drc_ds, dmu_recv_tag);
(void) dsl_destroy_head(name);
@ -3183,13 +3185,13 @@ static int
dmu_recv_existing_end(dmu_recv_cookie_t *drc)
{
int error;
char name[MAXNAMELEN];
#ifdef _KERNEL
/*
* We will be destroying the ds; make sure its origin is unmounted if
* necessary.
*/
char name[ZFS_MAX_DATASET_NAME_LEN];
dsl_dataset_name(drc->drc_ds, name);
zfs_destroy_unmount_origin(name);
#endif

View File

@ -129,6 +129,12 @@ dmu_tx_hold_object_impl(dmu_tx_t *tx, objset_t *os, uint64_t object,
txh = kmem_zalloc(sizeof (dmu_tx_hold_t), KM_SLEEP);
txh->txh_tx = tx;
txh->txh_dnode = dn;
refcount_create(&txh->txh_space_towrite);
refcount_create(&txh->txh_space_tofree);
refcount_create(&txh->txh_space_tooverwrite);
refcount_create(&txh->txh_space_tounref);
refcount_create(&txh->txh_memory_tohold);
refcount_create(&txh->txh_fudge);
#ifdef ZFS_DEBUG
txh->txh_type = type;
txh->txh_arg1 = arg1;
@ -201,12 +207,18 @@ dmu_tx_count_twig(dmu_tx_hold_t *txh, dnode_t *dn, dmu_buf_impl_t *db,
freeable = (bp && (freeable ||
dsl_dataset_block_freeable(ds, bp, bp->blk_birth)));
if (freeable)
txh->txh_space_tooverwrite += space;
else
txh->txh_space_towrite += space;
if (bp)
txh->txh_space_tounref += bp_get_dsize(os->os_spa, bp);
if (freeable) {
(void) refcount_add_many(&txh->txh_space_tooverwrite,
space, FTAG);
} else {
(void) refcount_add_many(&txh->txh_space_towrite,
space, FTAG);
}
if (bp) {
(void) refcount_add_many(&txh->txh_space_tounref,
bp_get_dsize(os->os_spa, bp), FTAG);
}
dmu_tx_count_twig(txh, dn, parent, level + 1,
blkid >> epbs, freeable, history);
@ -336,8 +348,11 @@ dmu_tx_count_write(dmu_tx_hold_t *txh, uint64_t off, uint64_t len)
bits = 64 - min_bs;
epbs = min_ibs - SPA_BLKPTRSHIFT;
for (bits -= epbs * (nlvls - 1);
bits >= 0; bits -= epbs)
txh->txh_fudge += 1ULL << max_ibs;
bits >= 0; bits -= epbs) {
(void) refcount_add_many(
&txh->txh_fudge,
1ULL << max_ibs, FTAG);
}
goto out;
}
off += delta;
@ -353,7 +368,8 @@ dmu_tx_count_write(dmu_tx_hold_t *txh, uint64_t off, uint64_t len)
*/
start = P2ALIGN(off, 1ULL << max_bs);
end = P2ROUNDUP(off + len, 1ULL << max_bs) - 1;
txh->txh_space_towrite += end - start + 1;
(void) refcount_add_many(&txh->txh_space_towrite,
end - start + 1, FTAG);
start >>= min_bs;
end >>= min_bs;
@ -368,18 +384,21 @@ dmu_tx_count_write(dmu_tx_hold_t *txh, uint64_t off, uint64_t len)
start >>= epbs;
end >>= epbs;
ASSERT3U(end, >=, start);
txh->txh_space_towrite += (end - start + 1) << max_ibs;
(void) refcount_add_many(&txh->txh_space_towrite,
(end - start + 1) << max_ibs, FTAG);
if (start != 0) {
/*
* We also need a new blkid=0 indirect block
* to reference any existing file data.
*/
txh->txh_space_towrite += 1ULL << max_ibs;
(void) refcount_add_many(&txh->txh_space_towrite,
1ULL << max_ibs, FTAG);
}
}
out:
if (txh->txh_space_towrite + txh->txh_space_tooverwrite >
if (refcount_count(&txh->txh_space_towrite) +
refcount_count(&txh->txh_space_tooverwrite) >
2 * DMU_MAX_ACCESS)
err = SET_ERROR(EFBIG);
@ -398,12 +417,15 @@ dmu_tx_count_dnode(dmu_tx_hold_t *txh)
if (dn && dn->dn_dbuf->db_blkptr &&
dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset,
dn->dn_dbuf->db_blkptr, dn->dn_dbuf->db_blkptr->blk_birth)) {
txh->txh_space_tooverwrite += space;
txh->txh_space_tounref += space;
(void) refcount_add_many(&txh->txh_space_tooverwrite,
space, FTAG);
(void) refcount_add_many(&txh->txh_space_tounref, space, FTAG);
} else {
txh->txh_space_towrite += space;
if (dn && dn->dn_dbuf->db_blkptr)
txh->txh_space_tounref += space;
(void) refcount_add_many(&txh->txh_space_towrite, space, FTAG);
if (dn && dn->dn_dbuf->db_blkptr) {
(void) refcount_add_many(&txh->txh_space_tounref,
space, FTAG);
}
}
}
@ -525,7 +547,8 @@ dmu_tx_count_free(dmu_tx_hold_t *txh, uint64_t off, uint64_t len)
break;
}
txh->txh_memory_tohold += dbuf->db.db_size;
(void) refcount_add_many(&txh->txh_memory_tohold,
dbuf->db.db_size, FTAG);
/*
* We don't check memory_tohold against DMU_MAX_ACCESS because
@ -578,20 +601,23 @@ dmu_tx_count_free(dmu_tx_hold_t *txh, uint64_t off, uint64_t len)
(dn->dn_indblkshift - SPA_BLKPTRSHIFT);
while (level++ < maxlevel) {
txh->txh_memory_tohold += MAX(MIN(blkcnt, nl1blks), 1)
<< dn->dn_indblkshift;
(void) refcount_add_many(&txh->txh_memory_tohold,
MAX(MIN(blkcnt, nl1blks), 1) << dn->dn_indblkshift,
FTAG);
blkcnt = 1 + (blkcnt >> epbs);
}
}
/* account for new level 1 indirect blocks that might show up */
if (skipped > 0) {
txh->txh_fudge += skipped << dn->dn_indblkshift;
(void) refcount_add_many(&txh->txh_fudge,
skipped << dn->dn_indblkshift, FTAG);
skipped = MIN(skipped, DMU_MAX_DELETEBLKCNT >> epbs);
txh->txh_memory_tohold += skipped << dn->dn_indblkshift;
(void) refcount_add_many(&txh->txh_memory_tohold,
skipped << dn->dn_indblkshift, FTAG);
}
txh->txh_space_tofree += space;
txh->txh_space_tounref += unref;
(void) refcount_add_many(&txh->txh_space_tofree, space, FTAG);
(void) refcount_add_many(&txh->txh_space_tounref, unref, FTAG);
}
/*
@ -617,7 +643,10 @@ dmu_tx_mark_netfree(dmu_tx_t *tx)
* cause overflows when doing math with these values (e.g. in
* dmu_tx_try_assign()).
*/
txh->txh_space_tofree = txh->txh_space_tounref = 1024 * 1024 * 1024;
(void) refcount_add_many(&txh->txh_space_tofree,
1024 * 1024 * 1024, FTAG);
(void) refcount_add_many(&txh->txh_space_tounref,
1024 * 1024 * 1024, FTAG);
}
void
@ -717,9 +746,7 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name)
{
dmu_tx_hold_t *txh;
dnode_t *dn;
dsl_dataset_phys_t *ds_phys;
uint64_t nblocks;
int epbs, err;
int err;
ASSERT(tx->tx_txg == 0);
@ -762,12 +789,17 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name)
*/
bp = &dn->dn_phys->dn_blkptr[0];
if (dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset,
bp, bp->blk_birth))
txh->txh_space_tooverwrite += MZAP_MAX_BLKSZ;
else
txh->txh_space_towrite += MZAP_MAX_BLKSZ;
if (!BP_IS_HOLE(bp))
txh->txh_space_tounref += MZAP_MAX_BLKSZ;
bp, bp->blk_birth)) {
(void) refcount_add_many(&txh->txh_space_tooverwrite,
MZAP_MAX_BLKSZ, FTAG);
} else {
(void) refcount_add_many(&txh->txh_space_towrite,
MZAP_MAX_BLKSZ, FTAG);
}
if (!BP_IS_HOLE(bp)) {
(void) refcount_add_many(&txh->txh_space_tounref,
MZAP_MAX_BLKSZ, FTAG);
}
return;
}
@ -789,15 +821,29 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name)
/*
* If the modified blocks are scattered to the four winds,
* we'll have to modify an indirect twig for each.
* we'll have to modify an indirect twig for each. We can make
* modifications at up to 3 locations:
* - header block at the beginning of the object
* - target leaf block
* - end of the object, where we might need to write:
* - a new leaf block if the target block needs to be split
* - the new pointer table, if it is growing
* - the new cookie table, if it is growing
*/
epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
ds_phys = dsl_dataset_phys(dn->dn_objset->os_dsl_dataset);
for (nblocks = dn->dn_maxblkid >> epbs; nblocks != 0; nblocks >>= epbs)
if (ds_phys->ds_prev_snap_obj)
txh->txh_space_towrite += 3 << dn->dn_indblkshift;
else
txh->txh_space_tooverwrite += 3 << dn->dn_indblkshift;
int epbs = dn->dn_indblkshift - SPA_BLKPTRSHIFT;
dsl_dataset_phys_t *ds_phys =
dsl_dataset_phys(dn->dn_objset->os_dsl_dataset);
for (int lvl = 1; lvl < dn->dn_nlevels; lvl++) {
uint64_t num_indirects = 1 + (dn->dn_maxblkid >> (epbs * lvl));
uint64_t spc = MIN(3, num_indirects) << dn->dn_indblkshift;
if (ds_phys->ds_prev_snap_obj != 0) {
(void) refcount_add_many(&txh->txh_space_towrite,
spc, FTAG);
} else {
(void) refcount_add_many(&txh->txh_space_tooverwrite,
spc, FTAG);
}
}
}
void
@ -822,7 +868,7 @@ dmu_tx_hold_space(dmu_tx_t *tx, uint64_t space)
txh = dmu_tx_hold_object_impl(tx, tx->tx_objset,
DMU_NEW_OBJECT, THT_SPACE, space, 0);
txh->txh_space_towrite += space;
(void) refcount_add_many(&txh->txh_space_towrite, space, FTAG);
}
int
@ -1175,12 +1221,12 @@ dmu_tx_try_assign(dmu_tx_t *tx, txg_how_t txg_how)
(void) refcount_add(&dn->dn_tx_holds, tx);
mutex_exit(&dn->dn_mtx);
}
towrite += txh->txh_space_towrite;
tofree += txh->txh_space_tofree;
tooverwrite += txh->txh_space_tooverwrite;
tounref += txh->txh_space_tounref;
tohold += txh->txh_memory_tohold;
fudge += txh->txh_fudge;
towrite += refcount_count(&txh->txh_space_towrite);
tofree += refcount_count(&txh->txh_space_tofree);
tooverwrite += refcount_count(&txh->txh_space_tooverwrite);
tounref += refcount_count(&txh->txh_space_tounref);
tohold += refcount_count(&txh->txh_memory_tohold);
fudge += refcount_count(&txh->txh_fudge);
}
/*
@ -1383,24 +1429,59 @@ dmu_tx_willuse_space(dmu_tx_t *tx, int64_t delta)
#endif
}
void
dmu_tx_commit(dmu_tx_t *tx)
static void
dmu_tx_destroy(dmu_tx_t *tx)
{
dmu_tx_hold_t *txh;
while ((txh = list_head(&tx->tx_holds)) != NULL) {
dnode_t *dn = txh->txh_dnode;
list_remove(&tx->tx_holds, txh);
refcount_destroy_many(&txh->txh_space_towrite,
refcount_count(&txh->txh_space_towrite));
refcount_destroy_many(&txh->txh_space_tofree,
refcount_count(&txh->txh_space_tofree));
refcount_destroy_many(&txh->txh_space_tooverwrite,
refcount_count(&txh->txh_space_tooverwrite));
refcount_destroy_many(&txh->txh_space_tounref,
refcount_count(&txh->txh_space_tounref));
refcount_destroy_many(&txh->txh_memory_tohold,
refcount_count(&txh->txh_memory_tohold));
refcount_destroy_many(&txh->txh_fudge,
refcount_count(&txh->txh_fudge));
kmem_free(txh, sizeof (dmu_tx_hold_t));
if (dn != NULL)
dnode_rele(dn, tx);
}
list_destroy(&tx->tx_callbacks);
list_destroy(&tx->tx_holds);
#ifdef ZFS_DEBUG
refcount_destroy_many(&tx->tx_space_written,
refcount_count(&tx->tx_space_written));
refcount_destroy_many(&tx->tx_space_freed,
refcount_count(&tx->tx_space_freed));
#endif
kmem_free(tx, sizeof (dmu_tx_t));
}
void
dmu_tx_commit(dmu_tx_t *tx)
{
ASSERT(tx->tx_txg != 0);
/*
* Go through the transaction's hold list and remove holds on
* associated dnodes, notifying waiters if no holds remain.
*/
while (txh = list_head(&tx->tx_holds)) {
for (dmu_tx_hold_t *txh = list_head(&tx->tx_holds); txh != NULL;
txh = list_next(&tx->tx_holds, txh)) {
dnode_t *dn = txh->txh_dnode;
list_remove(&tx->tx_holds, txh);
kmem_free(txh, sizeof (dmu_tx_hold_t));
if (dn == NULL)
continue;
mutex_enter(&dn->dn_mtx);
ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg);
@ -1409,7 +1490,6 @@ dmu_tx_commit(dmu_tx_t *tx)
cv_broadcast(&dn->dn_notxholds);
}
mutex_exit(&dn->dn_mtx);
dnode_rele(dn, tx);
}
if (tx->tx_tempreserve_cookie)
@ -1421,51 +1501,26 @@ dmu_tx_commit(dmu_tx_t *tx)
if (tx->tx_anyobj == FALSE)
txg_rele_to_sync(&tx->tx_txgh);
list_destroy(&tx->tx_callbacks);
list_destroy(&tx->tx_holds);
#ifdef ZFS_DEBUG
dprintf("towrite=%llu written=%llu tofree=%llu freed=%llu\n",
tx->tx_space_towrite, refcount_count(&tx->tx_space_written),
tx->tx_space_tofree, refcount_count(&tx->tx_space_freed));
refcount_destroy_many(&tx->tx_space_written,
refcount_count(&tx->tx_space_written));
refcount_destroy_many(&tx->tx_space_freed,
refcount_count(&tx->tx_space_freed));
#endif
kmem_free(tx, sizeof (dmu_tx_t));
dmu_tx_destroy(tx);
}
void
dmu_tx_abort(dmu_tx_t *tx)
{
dmu_tx_hold_t *txh;
ASSERT(tx->tx_txg == 0);
while (txh = list_head(&tx->tx_holds)) {
dnode_t *dn = txh->txh_dnode;
list_remove(&tx->tx_holds, txh);
kmem_free(txh, sizeof (dmu_tx_hold_t));
if (dn != NULL)
dnode_rele(dn, tx);
}
/*
* Call any registered callbacks with an error code.
*/
if (!list_is_empty(&tx->tx_callbacks))
dmu_tx_do_callbacks(&tx->tx_callbacks, ECANCELED);
list_destroy(&tx->tx_callbacks);
list_destroy(&tx->tx_holds);
#ifdef ZFS_DEBUG
refcount_destroy_many(&tx->tx_space_written,
refcount_count(&tx->tx_space_written));
refcount_destroy_many(&tx->tx_space_freed,
refcount_count(&tx->tx_space_freed));
#endif
kmem_free(tx, sizeof (dmu_tx_t));
dmu_tx_destroy(tx);
}
uint64_t
@ -1504,7 +1559,7 @@ dmu_tx_do_callbacks(list_t *cb_list, int error)
{
dmu_tx_callback_t *dcb;
while (dcb = list_head(cb_list)) {
while ((dcb = list_head(cb_list)) != NULL) {
list_remove(cb_list, dcb);
dcb->dcb_func(dcb->dcb_data, error);
kmem_free(dcb, sizeof (dmu_tx_callback_t));
@ -1562,18 +1617,24 @@ dmu_tx_hold_spill(dmu_tx_t *tx, uint64_t object)
/* If blkptr doesn't exist then add space to towrite */
if (!(dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR)) {
txh->txh_space_towrite += SPA_OLD_MAXBLOCKSIZE;
(void) refcount_add_many(&txh->txh_space_towrite,
SPA_OLD_MAXBLOCKSIZE, FTAG);
} else {
blkptr_t *bp;
bp = &dn->dn_phys->dn_spill;
if (dsl_dataset_block_freeable(dn->dn_objset->os_dsl_dataset,
bp, bp->blk_birth))
txh->txh_space_tooverwrite += SPA_OLD_MAXBLOCKSIZE;
else
txh->txh_space_towrite += SPA_OLD_MAXBLOCKSIZE;
if (!BP_IS_HOLE(bp))
txh->txh_space_tounref += SPA_OLD_MAXBLOCKSIZE;
bp, bp->blk_birth)) {
(void) refcount_add_many(&txh->txh_space_tooverwrite,
SPA_OLD_MAXBLOCKSIZE, FTAG);
} else {
(void) refcount_add_many(&txh->txh_space_towrite,
SPA_OLD_MAXBLOCKSIZE, FTAG);
}
if (!BP_IS_HOLE(bp)) {
(void) refcount_add_many(&txh->txh_space_tounref,
SPA_OLD_MAXBLOCKSIZE, FTAG);
}
}
}

View File

@ -34,10 +34,10 @@ static int
dsl_bookmark_hold_ds(dsl_pool_t *dp, const char *fullname,
dsl_dataset_t **dsp, void *tag, char **shortnamep)
{
char buf[MAXNAMELEN];
char buf[ZFS_MAX_DATASET_NAME_LEN];
char *hashp;
if (strlen(fullname) >= MAXNAMELEN)
if (strlen(fullname) >= ZFS_MAX_DATASET_NAME_LEN)
return (SET_ERROR(ENAMETOOLONG));
hashp = strchr(fullname, '#');
if (hashp == NULL)

View File

@ -676,22 +676,37 @@ dsl_dataset_name(dsl_dataset_t *ds, char *name)
dsl_dir_name(ds->ds_dir, name);
VERIFY0(dsl_dataset_get_snapname(ds));
if (ds->ds_snapname[0]) {
(void) strcat(name, "@");
VERIFY3U(strlcat(name, "@", ZFS_MAX_DATASET_NAME_LEN),
<, ZFS_MAX_DATASET_NAME_LEN);
/*
* We use a "recursive" mutex so that we
* can call dprintf_ds() with ds_lock held.
*/
if (!MUTEX_HELD(&ds->ds_lock)) {
mutex_enter(&ds->ds_lock);
(void) strcat(name, ds->ds_snapname);
VERIFY3U(strlcat(name, ds->ds_snapname,
ZFS_MAX_DATASET_NAME_LEN), <,
ZFS_MAX_DATASET_NAME_LEN);
mutex_exit(&ds->ds_lock);
} else {
(void) strcat(name, ds->ds_snapname);
VERIFY3U(strlcat(name, ds->ds_snapname,
ZFS_MAX_DATASET_NAME_LEN), <,
ZFS_MAX_DATASET_NAME_LEN);
}
}
}
}
int
dsl_dataset_namelen(dsl_dataset_t *ds)
{
VERIFY0(dsl_dataset_get_snapname(ds));
mutex_enter(&ds->ds_lock);
int len = dsl_dir_namelen(ds->ds_dir) + 1 + strlen(ds->ds_snapname);
mutex_exit(&ds->ds_lock);
return (len);
}
void
dsl_dataset_rele(dsl_dataset_t *ds, void *tag)
{
@ -1296,10 +1311,10 @@ dsl_dataset_snapshot_check(void *arg, dmu_tx_t *tx)
int error = 0;
dsl_dataset_t *ds;
char *name, *atp;
char dsname[MAXNAMELEN];
char dsname[ZFS_MAX_DATASET_NAME_LEN];
name = nvpair_name(pair);
if (strlen(name) >= MAXNAMELEN)
if (strlen(name) >= ZFS_MAX_DATASET_NAME_LEN)
error = SET_ERROR(ENAMETOOLONG);
if (error == 0) {
atp = strchr(name, '@');
@ -1474,7 +1489,7 @@ dsl_dataset_snapshot_sync(void *arg, dmu_tx_t *tx)
pair != NULL; pair = nvlist_next_nvpair(ddsa->ddsa_snaps, pair)) {
dsl_dataset_t *ds;
char *name, *atp;
char dsname[MAXNAMELEN];
char dsname[ZFS_MAX_DATASET_NAME_LEN];
name = nvpair_name(pair);
atp = strchr(name, '@');
@ -1520,7 +1535,7 @@ dsl_dataset_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t *errors)
suspended = fnvlist_alloc();
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
pair = nvlist_next_nvpair(snaps, pair)) {
char fsname[MAXNAMELEN];
char fsname[ZFS_MAX_DATASET_NAME_LEN];
char *snapname = nvpair_name(pair);
char *atp;
void *cookie;
@ -1738,7 +1753,7 @@ get_clones_stat(dsl_dataset_t *ds, nvlist_t *nv)
zap_cursor_retrieve(&zc, &za) == 0;
zap_cursor_advance(&zc)) {
dsl_dataset_t *clone;
char buf[ZFS_MAXNAMELEN];
char buf[ZFS_MAX_DATASET_NAME_LEN];
VERIFY0(dsl_dataset_hold_obj(ds->ds_dir->dd_pool,
za.za_first_integer, FTAG, &clone));
dsl_dir_name(clone->ds_dir, buf);
@ -1846,7 +1861,7 @@ dsl_dataset_stats(dsl_dataset_t *ds, nvlist_t *nv)
get_clones_stat(ds, nv);
} else {
if (ds->ds_prev != NULL && ds->ds_prev != dp->dp_origin_snap) {
char buf[MAXNAMELEN];
char buf[ZFS_MAX_DATASET_NAME_LEN];
dsl_dataset_name(ds->ds_prev, buf);
dsl_prop_nvlist_add_string(nv, ZFS_PROP_PREV_SNAP, buf);
}
@ -1907,12 +1922,15 @@ dsl_dataset_stats(dsl_dataset_t *ds, nvlist_t *nv)
* stats set on our child named "%recv". Check the child
* for the prop.
*/
char recvname[ZFS_MAXNAMELEN];
/* 6 extra bytes for /%recv */
char recvname[ZFS_MAX_DATASET_NAME_LEN + 6];
dsl_dataset_t *recv_ds;
dsl_dataset_name(ds, recvname);
(void) strcat(recvname, "/");
(void) strcat(recvname, recv_clone_name);
if (dsl_dataset_hold(dp, recvname, FTAG, &recv_ds) == 0) {
if (strlcat(recvname, "/", sizeof (recvname)) <
sizeof (recvname) &&
strlcat(recvname, recv_clone_name, sizeof (recvname)) <
sizeof (recvname) &&
dsl_dataset_hold(dp, recvname, FTAG, &recv_ds) == 0) {
get_receive_resume_stats(recv_ds, nv);
dsl_dataset_rele(recv_ds, FTAG);
}
@ -2039,7 +2057,7 @@ dsl_dataset_rename_snapshot_check_impl(dsl_pool_t *dp,
/* dataset name + 1 for the "@" + the new snapshot name must fit */
if (dsl_dir_namelen(hds->ds_dir) + 1 +
strlen(ddrsa->ddrsa_newsnapname) >= MAXNAMELEN)
strlen(ddrsa->ddrsa_newsnapname) >= ZFS_MAX_DATASET_NAME_LEN)
error = SET_ERROR(ENAMETOOLONG);
return (error);
@ -2287,7 +2305,7 @@ dsl_dataset_rollback_sync(void *arg, dmu_tx_t *tx)
dsl_pool_t *dp = dmu_tx_pool(tx);
dsl_dataset_t *ds, *clone;
uint64_t cloneobj;
char namebuf[ZFS_MAXNAMELEN];
char namebuf[ZFS_MAX_DATASET_NAME_LEN];
VERIFY0(dsl_dataset_hold(dp, ddra->ddra_fsname, FTAG, &ds));
@ -2863,7 +2881,7 @@ promote_rele(dsl_dataset_promote_arg_t *ddpa, void *tag)
* Promote a clone.
*
* If it fails due to a conflicting snapshot name, "conflsnap" will be filled
* in with the name. (It must be at least MAXNAMELEN bytes long.)
* in with the name. (It must be at least ZFS_MAX_DATASET_NAME_LEN bytes long.)
*/
int
dsl_dataset_promote(const char *name, char *conflsnap)

View File

@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
*/
/*
@ -330,7 +330,7 @@ dsl_deleg_get(const char *ddname, nvlist_t **nvp)
zap_attribute_t baseza;
nvlist_t *sp_nvp;
uint64_t n;
char source[MAXNAMELEN];
char source[ZFS_MAX_DATASET_NAME_LEN];
if (dsl_dir_phys(dd)->dd_deleg_zapobj == 0 ||
zap_count(mos,

View File

@ -303,13 +303,14 @@ dsl_dir_async_rele(dsl_dir_t *dd, void *tag)
dmu_buf_rele(dd->dd_dbuf, tag);
}
/* buf must be long enough (MAXNAMELEN + strlen(MOS_DIR_NAME) + 1 should do) */
/* buf must be at least ZFS_MAX_DATASET_NAME_LEN bytes */
void
dsl_dir_name(dsl_dir_t *dd, char *buf)
{
if (dd->dd_parent) {
dsl_dir_name(dd->dd_parent, buf);
(void) strcat(buf, "/");
VERIFY3U(strlcat(buf, "/", ZFS_MAX_DATASET_NAME_LEN), <,
ZFS_MAX_DATASET_NAME_LEN);
} else {
buf[0] = '\0';
}
@ -319,10 +320,12 @@ dsl_dir_name(dsl_dir_t *dd, char *buf)
* dprintf_dd() with dd_lock held
*/
mutex_enter(&dd->dd_lock);
(void) strcat(buf, dd->dd_myname);
VERIFY3U(strlcat(buf, dd->dd_myname, ZFS_MAX_DATASET_NAME_LEN),
<, ZFS_MAX_DATASET_NAME_LEN);
mutex_exit(&dd->dd_lock);
} else {
(void) strcat(buf, dd->dd_myname);
VERIFY3U(strlcat(buf, dd->dd_myname, ZFS_MAX_DATASET_NAME_LEN),
<, ZFS_MAX_DATASET_NAME_LEN);
}
}
@ -371,12 +374,12 @@ getcomponent(const char *path, char *component, const char **nextp)
if (p != NULL &&
(p[0] != '@' || strpbrk(path+1, "/@") || p[1] == '\0'))
return (SET_ERROR(EINVAL));
if (strlen(path) >= MAXNAMELEN)
if (strlen(path) >= ZFS_MAX_DATASET_NAME_LEN)
return (SET_ERROR(ENAMETOOLONG));
(void) strcpy(component, path);
p = NULL;
} else if (p[0] == '/') {
if (p - path >= MAXNAMELEN)
if (p - path >= ZFS_MAX_DATASET_NAME_LEN)
return (SET_ERROR(ENAMETOOLONG));
(void) strncpy(component, path, p - path);
component[p - path] = '\0';
@ -388,7 +391,7 @@ getcomponent(const char *path, char *component, const char **nextp)
*/
if (strchr(path, '/'))
return (SET_ERROR(EINVAL));
if (p - path >= MAXNAMELEN)
if (p - path >= ZFS_MAX_DATASET_NAME_LEN)
return (SET_ERROR(ENAMETOOLONG));
(void) strncpy(component, path, p - path);
component[p - path] = '\0';
@ -410,7 +413,7 @@ int
dsl_dir_hold(dsl_pool_t *dp, const char *name, void *tag,
dsl_dir_t **ddp, const char **tailp)
{
char buf[MAXNAMELEN];
char buf[ZFS_MAX_DATASET_NAME_LEN];
const char *spaname, *next, *nextnext = NULL;
int err;
dsl_dir_t *dd;
@ -977,7 +980,7 @@ dsl_dir_stats(dsl_dir_t *dd, nvlist_t *nv)
if (dsl_dir_is_clone(dd)) {
dsl_dataset_t *ds;
char buf[MAXNAMELEN];
char buf[ZFS_MAX_DATASET_NAME_LEN];
VERIFY0(dsl_dataset_hold_obj(dd->dd_pool,
dsl_dir_phys(dd)->dd_origin_obj, FTAG, &ds));
@ -1685,11 +1688,11 @@ static int
dsl_valid_rename(dsl_pool_t *dp, dsl_dataset_t *ds, void *arg)
{
int *deltap = arg;
char namebuf[MAXNAMELEN];
char namebuf[ZFS_MAX_DATASET_NAME_LEN];
dsl_dataset_name(ds, namebuf);
if (strlen(namebuf) + *deltap >= MAXNAMELEN)
if (strlen(namebuf) + *deltap >= ZFS_MAX_DATASET_NAME_LEN)
return (SET_ERROR(ENAMETOOLONG));
return (0);
}

View File

@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
* Copyright 2015, Joyent, Inc.
*/
@ -1059,7 +1059,7 @@ dsl_prop_get_all_ds(dsl_dataset_t *ds, nvlist_t **nvp,
dsl_pool_t *dp = dd->dd_pool;
objset_t *mos = dp->dp_meta_objset;
int err = 0;
char setpoint[MAXNAMELEN];
char setpoint[ZFS_MAX_DATASET_NAME_LEN];
VERIFY(nvlist_alloc(nvp, NV_UNIQUE_NAME, KM_SLEEP) == 0);

View File

@ -1115,7 +1115,7 @@ dsl_scan_visitds(dsl_scan_t *scn, uint64_t dsobj, dmu_tx_t *tx)
dmu_buf_will_dirty(ds->ds_dbuf, tx);
dsl_scan_visit_rootbp(scn, ds, &dsl_dataset_phys(ds)->ds_bp, tx);
char *dsname = kmem_alloc(ZFS_MAXNAMELEN, KM_SLEEP);
char *dsname = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN, KM_SLEEP);
dsl_dataset_name(ds, dsname);
zfs_dbgmsg("scanned dataset %llu (%s) with min=%llu max=%llu; "
"pausing=%u",
@ -1123,7 +1123,7 @@ dsl_scan_visitds(dsl_scan_t *scn, uint64_t dsobj, dmu_tx_t *tx)
(longlong_t)scn->scn_phys.scn_cur_min_txg,
(longlong_t)scn->scn_phys.scn_cur_max_txg,
(int)scn->scn_pausing);
kmem_free(dsname, ZFS_MAXNAMELEN);
kmem_free(dsname, ZFS_MAX_DATASET_NAME_LEN);
if (scn->scn_pausing)
goto out;

View File

@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2014 by Delphix. All rights reserved.
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
*/
@ -180,7 +180,7 @@ dsl_dataset_user_hold_sync_one_impl(nvlist_t *tmpholds, dsl_dataset_t *ds,
}
typedef struct zfs_hold_cleanup_arg {
char zhca_spaname[MAXNAMELEN];
char zhca_spaname[ZFS_MAX_DATASET_NAME_LEN];
uint64_t zhca_spa_load_guid;
nvlist_t *zhca_holds;
} zfs_hold_cleanup_arg_t;
@ -574,7 +574,7 @@ dsl_dataset_user_release_impl(nvlist_t *holds, nvlist_t *errlist,
error = dsl_dataset_hold_obj_string(tmpdp,
nvpair_name(pair), FTAG, &ds);
if (error == 0) {
char name[MAXNAMELEN];
char name[ZFS_MAX_DATASET_NAME_LEN];
dsl_dataset_name(ds, name);
dsl_pool_config_exit(tmpdp, FTAG);
dsl_dataset_rele(ds, FTAG);

View File

@ -151,6 +151,8 @@ const zio_taskq_info_t zio_taskqs[ZIO_TYPES][ZIO_TASKQ_TYPES] = {
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL }, /* IOCTL */
};
static sysevent_t *spa_event_create(spa_t *spa, vdev_t *vd, const char *name);
static void spa_event_post(sysevent_t *ev);
static void spa_sync_version(void *arg, dmu_tx_t *tx);
static void spa_sync_props(void *arg, dmu_tx_t *tx);
static boolean_t spa_has_active_shared_spare(spa_t *spa);
@ -370,8 +372,7 @@ spa_prop_get(spa_t *spa, nvlist_t **nvp)
break;
}
strval = kmem_alloc(
MAXNAMELEN + strlen(MOS_DIR_NAME) + 1,
strval = kmem_alloc(ZFS_MAX_DATASET_NAME_LEN,
KM_SLEEP);
dsl_dataset_name(ds, strval);
dsl_dataset_rele(ds, FTAG);
@ -384,8 +385,7 @@ spa_prop_get(spa_t *spa, nvlist_t **nvp)
spa_prop_add_list(*nvp, prop, strval, intval, src);
if (strval != NULL)
kmem_free(strval,
MAXNAMELEN + strlen(MOS_DIR_NAME) + 1);
kmem_free(strval, ZFS_MAX_DATASET_NAME_LEN);
break;
@ -1996,6 +1996,16 @@ spa_load_verify_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
return (0);
}
/* ARGSUSED */
int
verify_dataset_name_len(dsl_pool_t *dp, dsl_dataset_t *ds, void *arg)
{
if (dsl_dataset_namelen(ds) >= ZFS_MAX_DATASET_NAME_LEN)
return (SET_ERROR(ENAMETOOLONG));
return (0);
}
static int
spa_load_verify(spa_t *spa)
{
@ -2010,6 +2020,14 @@ spa_load_verify(spa_t *spa)
if (policy.zrp_request & ZPOOL_NEVER_REWIND)
return (0);
dsl_pool_config_enter(spa->spa_dsl_pool, FTAG);
error = dmu_objset_find_dp(spa->spa_dsl_pool,
spa->spa_dsl_pool->dp_root_dir_obj, verify_dataset_name_len, NULL,
DS_FIND_CHILDREN);
dsl_pool_config_exit(spa->spa_dsl_pool, FTAG);
if (error != 0)
return (error);
rio = zio_root(spa, NULL, &sle,
ZIO_FLAG_CANFAIL | ZIO_FLAG_SPECULATIVE);
@ -5722,6 +5740,7 @@ int
spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
{
vdev_t *vd;
sysevent_t *ev = NULL;
metaslab_group_t *mg;
nvlist_t **spares, **l2cache, *nv;
uint64_t txg = 0;
@ -5745,6 +5764,9 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
* in this pool.
*/
if (vd == NULL || unspare) {
if (vd == NULL)
vd = spa_lookup_by_guid(spa, guid, B_TRUE);
ev = spa_event_create(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX);
spa_vdev_remove_aux(spa->spa_spares.sav_config,
ZPOOL_CONFIG_SPARES, spares, nspares, nv);
spa_load_spares(spa);
@ -5759,6 +5781,8 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
/*
* Cache devices can always be removed.
*/
vd = spa_lookup_by_guid(spa, guid, B_TRUE);
ev = spa_event_create(spa, vd, ESC_ZFS_VDEV_REMOVE_AUX);
spa_vdev_remove_aux(spa->spa_l2cache.sav_config,
ZPOOL_CONFIG_L2CACHE, l2cache, nl2cache, nv);
spa_load_l2cache(spa);
@ -5799,6 +5823,7 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
/*
* Clean up the vdev namespace.
*/
ev = spa_event_create(spa, vd, ESC_ZFS_VDEV_REMOVE_DEV);
spa_vdev_remove_from_namespace(spa, vd);
} else if (vd != NULL) {
@ -5814,7 +5839,10 @@ spa_vdev_remove(spa_t *spa, uint64_t guid, boolean_t unspare)
}
if (!locked)
return (spa_vdev_exit(spa, NULL, txg, error));
error = spa_vdev_exit(spa, NULL, txg, error);
if (ev)
spa_event_post(ev);
return (error);
}
@ -7210,24 +7238,17 @@ spa_has_active_shared_spare(spa_t *spa)
return (B_FALSE);
}
/*
* Post a sysevent corresponding to the given event. The 'name' must be one of
* the event definitions in sys/sysevent/eventdefs.h. The payload will be
* filled in from the spa and (optionally) the vdev. This doesn't do anything
* in the userland libzpool, as we don't want consumers to misinterpret ztest
* or zdb as real changes.
*/
void
spa_event_notify(spa_t *spa, vdev_t *vd, const char *name)
static sysevent_t *
spa_event_create(spa_t *spa, vdev_t *vd, const char *name)
{
sysevent_t *ev = NULL;
#ifdef _KERNEL
sysevent_t *ev;
sysevent_attr_list_t *attr = NULL;
sysevent_value_t value;
sysevent_id_t eid;
ev = sysevent_alloc(EC_ZFS, (char *)name, SUNW_KERN_PUB "zfs",
SE_SLEEP);
ASSERT(ev != NULL);
value.value_type = SE_DATA_TYPE_STRING;
value.value.sv_string = spa_name(spa);
@ -7259,11 +7280,34 @@ spa_event_notify(spa_t *spa, vdev_t *vd, const char *name)
goto done;
attr = NULL;
(void) log_sysevent(ev, SE_SLEEP, &eid);
done:
if (attr)
sysevent_free_attr(attr);
#endif
return (ev);
}
static void
spa_event_post(sysevent_t *ev)
{
#ifdef _KERNEL
sysevent_id_t eid;
(void) log_sysevent(ev, SE_SLEEP, &eid);
sysevent_free(ev);
#endif
}
/*
* Post a sysevent corresponding to the given event. The 'name' must be one of
* the event definitions in sys/sysevent/eventdefs.h. The payload will be
* filled in from the spa and (optionally) the vdev. This doesn't do anything
* in the userland libzpool, as we don't want consumers to misinterpret ztest
* or zdb as real changes.
*/
void
spa_event_notify(spa_t *spa, vdev_t *vd, const char *name)
{
spa_event_post(spa_event_create(spa, vd, name));
}

View File

@ -21,7 +21,7 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2014 by Delphix. All rights reserved.
* Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2014 Integros [integros.com]
*/
@ -501,7 +501,7 @@ spa_history_log_internal_ds(dsl_dataset_t *ds, const char *operation,
dmu_tx_t *tx, const char *fmt, ...)
{
va_list adx;
char namebuf[MAXNAMELEN];
char namebuf[ZFS_MAX_DATASET_NAME_LEN];
nvlist_t *nvl = fnvlist_alloc();
ASSERT(tx != NULL);
@ -520,7 +520,7 @@ spa_history_log_internal_dd(dsl_dir_t *dd, const char *operation,
dmu_tx_t *tx, const char *fmt, ...)
{
va_list adx;
char namebuf[MAXNAMELEN];
char namebuf[ZFS_MAX_DATASET_NAME_LEN];
nvlist_t *nvl = fnvlist_alloc();
ASSERT(tx != NULL);

View File

@ -411,12 +411,20 @@ zfs_deadman_init()
* it is possible to run the pool completely out of space, causing it to
* be permanently read-only.
*
* Note that on very small pools, the slop space will be larger than
* 3.2%, in an effort to have it be at least spa_min_slop (128MB),
* but we never allow it to be more than half the pool size.
*
* See also the comments in zfs_space_check_t.
*/
int spa_slop_shift = 5;
SYSCTL_INT(_vfs_zfs, OID_AUTO, spa_slop_shift, CTLFLAG_RWTUN,
&spa_slop_shift, 0,
"Shift value of reserved space (1/(2^spa_slop_shift)).");
uint64_t spa_min_slop = 128 * 1024 * 1024;
SYSCTL_UQUAD(_vfs_zfs, OID_AUTO, spa_min_slop, CTLFLAG_RWTUN,
&spa_min_slop, 0,
"Minimal value of reserved space");
/*
* ==========================================================================
@ -1723,14 +1731,16 @@ spa_get_asize(spa_t *spa, uint64_t lsize)
/*
* Return the amount of slop space in bytes. It is 1/32 of the pool (3.2%),
* or at least 32MB.
* or at least 128MB, unless that would cause it to be more than half the
* pool size.
*
* See the comment above spa_slop_shift for details.
*/
uint64_t
spa_get_slop_space(spa_t *spa) {
spa_get_slop_space(spa_t *spa)
{
uint64_t space = spa_get_dspace(spa);
return (MAX(space >> spa_slop_shift, SPA_MINDEVSIZE >> 1));
return (MAX(space >> spa_slop_shift, MIN(space >> 1, spa_min_slop)));
}
uint64_t

View File

@ -816,7 +816,7 @@ typedef struct dmu_objset_stats {
dmu_objset_type_t dds_type;
uint8_t dds_is_snapshot;
uint8_t dds_inconsistent;
char dds_origin[MAXNAMELEN];
char dds_origin[ZFS_MAX_DATASET_NAME_LEN];
} dmu_objset_stats_t;
/*

View File

@ -23,7 +23,7 @@
* Use is subject to license terms.
*/
/*
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2012, 2015 by Delphix. All rights reserved.
*/
#ifndef _SYS_DMU_TX_H
@ -101,12 +101,12 @@ typedef struct dmu_tx_hold {
dmu_tx_t *txh_tx;
list_node_t txh_node;
struct dnode *txh_dnode;
uint64_t txh_space_towrite;
uint64_t txh_space_tofree;
uint64_t txh_space_tooverwrite;
uint64_t txh_space_tounref;
uint64_t txh_memory_tohold;
uint64_t txh_fudge;
refcount_t txh_space_towrite;
refcount_t txh_space_tofree;
refcount_t txh_space_tooverwrite;
refcount_t txh_space_tounref;
refcount_t txh_memory_tohold;
refcount_t txh_fudge;
#ifdef ZFS_DEBUG
enum dmu_tx_hold_type txh_type;
uint64_t txh_arg1;

View File

@ -58,7 +58,7 @@ extern "C" {
*/
#define DNODE_SHIFT 9 /* 512 bytes */
#define DN_MIN_INDBLKSHIFT 12 /* 4k */
#define DN_MAX_INDBLKSHIFT 14 /* 16k */
#define DN_MAX_INDBLKSHIFT 17 /* 128k */
#define DNODE_BLOCK_SHIFT 14 /* 16k */
#define DNODE_CORE_SIZE 64 /* 64 bytes for dnode sans blkptrs */
#define DN_MAX_OBJECT_SHIFT 48 /* 256 trillion (zfs_fid_t limit) */
@ -88,6 +88,11 @@ extern "C" {
#define DNODES_PER_BLOCK_SHIFT (DNODE_BLOCK_SHIFT - DNODE_SHIFT)
#define DNODES_PER_BLOCK (1ULL << DNODES_PER_BLOCK_SHIFT)
/*
* This is inaccurate if the indblkshift of the particular object is not the
* max. But it's only used by userland to calculate the zvol reservation.
*/
#define DNODES_PER_LEVEL_SHIFT (DN_MAX_INDBLKSHIFT - SPA_BLKPTRSHIFT)
#define DNODES_PER_LEVEL (1ULL << DNODES_PER_LEVEL_SHIFT)

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