mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Enable -Wwrite-strings
Also, fix leak from ztest_global_vars_to_zdb_args() Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13348
This commit is contained in:
+7
-6
@@ -108,20 +108,21 @@ mtab_is_writeable(void)
|
||||
}
|
||||
|
||||
static int
|
||||
mtab_update(char *dataset, char *mntpoint, char *type, char *mntopts)
|
||||
mtab_update(const char *dataset, const char *mntpoint, const char *type,
|
||||
const char *mntopts)
|
||||
{
|
||||
struct mntent mnt;
|
||||
FILE *fp;
|
||||
int error;
|
||||
|
||||
mnt.mnt_fsname = dataset;
|
||||
mnt.mnt_dir = mntpoint;
|
||||
mnt.mnt_type = type;
|
||||
mnt.mnt_opts = mntopts ? mntopts : "";
|
||||
mnt.mnt_fsname = (char *)dataset;
|
||||
mnt.mnt_dir = (char *)mntpoint;
|
||||
mnt.mnt_type = (char *)type;
|
||||
mnt.mnt_opts = (char *)(mntopts ?: "");
|
||||
mnt.mnt_freq = 0;
|
||||
mnt.mnt_passno = 0;
|
||||
|
||||
fp = setmntent("/etc/mtab", "a+");
|
||||
fp = setmntent("/etc/mtab", "a+e");
|
||||
if (!fp) {
|
||||
(void) fprintf(stderr, gettext(
|
||||
"filesystem '%s' was mounted, but /etc/mtab "
|
||||
|
||||
@@ -69,7 +69,7 @@ static void sig_handler(int signo)
|
||||
|
||||
static void print_opts(raidz_test_opts_t *opts, boolean_t force)
|
||||
{
|
||||
char *verbose;
|
||||
const char *verbose;
|
||||
switch (opts->rto_v) {
|
||||
case D_ALL:
|
||||
verbose = "no";
|
||||
|
||||
+24
-24
@@ -102,7 +102,7 @@
|
||||
#define ZDB_MAP_OBJECT_ID(obj) (obj)
|
||||
#endif
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
zdb_ot_name(dmu_object_type_t type)
|
||||
{
|
||||
if (type < DMU_OT_NUMTYPES)
|
||||
@@ -2922,7 +2922,7 @@ dsl_deadlist_entry_dump(void *arg, dsl_deadlist_entry_t *dle)
|
||||
}
|
||||
|
||||
static void
|
||||
dump_blkptr_list(dsl_deadlist_t *dl, char *name)
|
||||
dump_blkptr_list(dsl_deadlist_t *dl, const char *name)
|
||||
{
|
||||
char bytes[32];
|
||||
char comp[32];
|
||||
@@ -2963,7 +2963,7 @@ dump_blkptr_list(dsl_deadlist_t *dl, char *name)
|
||||
if (dump_opt['d'] < 4)
|
||||
return;
|
||||
|
||||
(void) printf("\n");
|
||||
(void) putchar('\n');
|
||||
|
||||
dsl_deadlist_iterate(dl, dsl_deadlist_entry_dump, NULL);
|
||||
}
|
||||
@@ -3098,9 +3098,8 @@ static void
|
||||
print_idstr(uint64_t id, const char *id_type)
|
||||
{
|
||||
if (FUID_INDEX(id)) {
|
||||
char *domain;
|
||||
|
||||
domain = zfs_fuid_idx_domain(&idx_tree, FUID_INDEX(id));
|
||||
const char *domain =
|
||||
zfs_fuid_idx_domain(&idx_tree, FUID_INDEX(id));
|
||||
(void) printf("\t%s %llx [%s-%d]\n", id_type,
|
||||
(u_longlong_t)id, domain, (int)FUID_RID(id));
|
||||
} else {
|
||||
@@ -3643,7 +3642,7 @@ count_ds_mos_objects(dsl_dataset_t *ds)
|
||||
}
|
||||
}
|
||||
|
||||
static const char *objset_types[DMU_OST_NUMTYPES] = {
|
||||
static const char *const objset_types[DMU_OST_NUMTYPES] = {
|
||||
"NONE", "META", "ZPL", "ZVOL", "OTHER", "ANY" };
|
||||
|
||||
/*
|
||||
@@ -3653,7 +3652,7 @@ static const char *objset_types[DMU_OST_NUMTYPES] = {
|
||||
* pointer to point to a descriptive error message.
|
||||
*/
|
||||
static int
|
||||
parse_object_range(char *range, zopt_object_range_t *zor, char **msg)
|
||||
parse_object_range(char *range, zopt_object_range_t *zor, const char **msg)
|
||||
{
|
||||
uint64_t flags = 0;
|
||||
char *p, *s, *dup, *flagstr, *tmp = NULL;
|
||||
@@ -4236,13 +4235,13 @@ first_label(cksum_record_t *rec)
|
||||
}
|
||||
|
||||
static void
|
||||
print_label_numbers(char *prefix, cksum_record_t *rec)
|
||||
print_label_numbers(const char *prefix, const cksum_record_t *rec)
|
||||
{
|
||||
printf("%s", prefix);
|
||||
fputs(prefix, stdout);
|
||||
for (int i = 0; i < VDEV_LABELS; i++)
|
||||
if (rec->labels[i] == B_TRUE)
|
||||
printf("%d ", i);
|
||||
printf("\n");
|
||||
putchar('\n');
|
||||
}
|
||||
|
||||
#define MAX_UBERBLOCK_COUNT (VDEV_UBERBLOCK_RING >> UBERBLOCK_SHIFT)
|
||||
@@ -5126,7 +5125,7 @@ same_metaslab(spa_t *spa, uint64_t vdev, uint64_t off1, uint64_t off2)
|
||||
* Used to simplify reporting of the histogram data.
|
||||
*/
|
||||
typedef struct one_histo {
|
||||
char *name;
|
||||
const char *name;
|
||||
uint64_t *count;
|
||||
uint64_t *len;
|
||||
uint64_t cumulative;
|
||||
@@ -8093,32 +8092,33 @@ zdb_read_block(char *thing, spa_t *spa)
|
||||
vdev_t *vd;
|
||||
abd_t *pabd;
|
||||
void *lbuf, *buf;
|
||||
char *s, *p, *dup, *vdev, *flagstr, *sizes, *tmp = NULL;
|
||||
char *s, *p, *dup, *flagstr, *sizes, *tmp = NULL;
|
||||
const char *vdev, *errmsg = NULL;
|
||||
int i, error;
|
||||
boolean_t borrowed = B_FALSE, found = B_FALSE;
|
||||
|
||||
dup = strdup(thing);
|
||||
s = strtok_r(dup, ":", &tmp);
|
||||
vdev = s ? s : "";
|
||||
vdev = s ?: "";
|
||||
s = strtok_r(NULL, ":", &tmp);
|
||||
offset = strtoull(s ? s : "", NULL, 16);
|
||||
sizes = strtok_r(NULL, ":", &tmp);
|
||||
s = strtok_r(NULL, ":", &tmp);
|
||||
flagstr = strdup(s ? s : "");
|
||||
flagstr = strdup(s ?: "");
|
||||
|
||||
s = NULL;
|
||||
tmp = NULL;
|
||||
if (!zdb_parse_block_sizes(sizes, &lsize, &psize))
|
||||
s = "invalid size(s)";
|
||||
errmsg = "invalid size(s)";
|
||||
if (!IS_P2ALIGNED(psize, DEV_BSIZE) || !IS_P2ALIGNED(lsize, DEV_BSIZE))
|
||||
s = "size must be a multiple of sector size";
|
||||
errmsg = "size must be a multiple of sector size";
|
||||
if (!IS_P2ALIGNED(offset, DEV_BSIZE))
|
||||
s = "offset must be a multiple of sector size";
|
||||
if (s) {
|
||||
(void) printf("Invalid block specifier: %s - %s\n", thing, s);
|
||||
errmsg = "offset must be a multiple of sector size";
|
||||
if (errmsg) {
|
||||
(void) printf("Invalid block specifier: %s - %s\n",
|
||||
thing, errmsg);
|
||||
goto done;
|
||||
}
|
||||
|
||||
tmp = NULL;
|
||||
for (s = strtok_r(flagstr, ":", &tmp);
|
||||
s != NULL;
|
||||
s = strtok_r(NULL, ":", &tmp)) {
|
||||
@@ -8930,13 +8930,13 @@ retry_lookup:
|
||||
sizeof (zopt_object_range_t));
|
||||
for (unsigned i = 0; i < zopt_object_args; i++) {
|
||||
int err;
|
||||
char *msg = NULL;
|
||||
const char *msg = NULL;
|
||||
|
||||
err = parse_object_range(argv[i],
|
||||
&zopt_object_ranges[i], &msg);
|
||||
if (err != 0)
|
||||
fatal("Bad object or range: '%s': %s\n",
|
||||
argv[i], msg ? msg : "");
|
||||
argv[i], msg ?: "");
|
||||
}
|
||||
} else if (argc > 0 && dump_opt['m']) {
|
||||
zopt_metaslab_args = argc;
|
||||
|
||||
@@ -389,7 +389,8 @@ zed_log_fault(nvlist_t *nvl, const char *uuid, const char *code)
|
||||
static const char *
|
||||
fmd_fault_mkcode(nvlist_t *fault)
|
||||
{
|
||||
char *class, *code = "-";
|
||||
char *class;
|
||||
const char *code = "-";
|
||||
|
||||
/*
|
||||
* Note: message codes come from: openzfs/usr/src/cmd/fm/dicts/ZFS.po
|
||||
|
||||
+55
-58
@@ -471,7 +471,7 @@ safe_realloc(void *data, size_t size)
|
||||
}
|
||||
|
||||
static char *
|
||||
safe_strdup(char *str)
|
||||
safe_strdup(const char *str)
|
||||
{
|
||||
char *dupstr = strdup(str);
|
||||
|
||||
@@ -690,7 +690,8 @@ parse_depth(char *opt, int *flags)
|
||||
|
||||
#define PROGRESS_DELAY 2 /* seconds */
|
||||
|
||||
static char *pt_reverse = "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
|
||||
static const char *pt_reverse =
|
||||
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
|
||||
static time_t pt_begin;
|
||||
static char *pt_header = NULL;
|
||||
static boolean_t pt_shown;
|
||||
@@ -703,7 +704,7 @@ start_progress_timer(void)
|
||||
}
|
||||
|
||||
static void
|
||||
set_progress_header(char *header)
|
||||
set_progress_header(const char *header)
|
||||
{
|
||||
assert(pt_header == NULL);
|
||||
pt_header = safe_strdup(header);
|
||||
@@ -714,7 +715,7 @@ set_progress_header(char *header)
|
||||
}
|
||||
|
||||
static void
|
||||
update_progress(char *update)
|
||||
update_progress(const char *update)
|
||||
{
|
||||
if (!pt_shown && time(NULL) > pt_begin) {
|
||||
int len = strlen(update);
|
||||
@@ -732,10 +733,10 @@ update_progress(char *update)
|
||||
}
|
||||
|
||||
static void
|
||||
finish_progress(char *done)
|
||||
finish_progress(const char *done)
|
||||
{
|
||||
if (pt_shown) {
|
||||
(void) printf("%s\n", done);
|
||||
(void) puts(done);
|
||||
(void) fflush(stdout);
|
||||
}
|
||||
free(pt_header);
|
||||
@@ -1903,8 +1904,8 @@ get_callback(zfs_handle_t *zhp, void *data)
|
||||
nvlist_t *user_props = zfs_get_user_props(zhp);
|
||||
zprop_list_t *pl = cbp->cb_proplist;
|
||||
nvlist_t *propval;
|
||||
char *strval;
|
||||
char *sourceval;
|
||||
const char *strval;
|
||||
const char *sourceval;
|
||||
boolean_t received = is_recvd_column(cbp);
|
||||
|
||||
for (; pl != NULL; pl = pl->pl_next) {
|
||||
@@ -1973,10 +1974,10 @@ get_callback(zfs_handle_t *zhp, void *data)
|
||||
sourcetype = ZPROP_SRC_NONE;
|
||||
strval = "-";
|
||||
} else {
|
||||
verify(nvlist_lookup_string(propval,
|
||||
ZPROP_VALUE, &strval) == 0);
|
||||
verify(nvlist_lookup_string(propval,
|
||||
ZPROP_SOURCE, &sourceval) == 0);
|
||||
strval = fnvlist_lookup_string(propval,
|
||||
ZPROP_VALUE);
|
||||
sourceval = fnvlist_lookup_string(propval,
|
||||
ZPROP_SOURCE);
|
||||
|
||||
if (strcmp(sourceval,
|
||||
zfs_get_name(zhp)) == 0) {
|
||||
@@ -2618,9 +2619,9 @@ enum us_field_types {
|
||||
USFIELD_OBJUSED,
|
||||
USFIELD_OBJQUOTA
|
||||
};
|
||||
static char *us_field_hdr[] = { "TYPE", "NAME", "USED", "QUOTA",
|
||||
static const char *const us_field_hdr[] = { "TYPE", "NAME", "USED", "QUOTA",
|
||||
"OBJUSED", "OBJQUOTA" };
|
||||
static char *us_field_names[] = { "type", "name", "used", "quota",
|
||||
static const char *const us_field_names[] = { "type", "name", "used", "quota",
|
||||
"objused", "objquota" };
|
||||
#define USFIELD_LAST (sizeof (us_field_names) / sizeof (char *))
|
||||
|
||||
@@ -2640,8 +2641,8 @@ static int us_type_bits[] = {
|
||||
USTYPE_SMB_USR,
|
||||
USTYPE_ALL
|
||||
};
|
||||
static char *us_type_names[] = { "posixgroup", "posixuser", "smbgroup",
|
||||
"smbuser", "all" };
|
||||
static const char *const us_type_names[] = { "posixgroup", "posixuser",
|
||||
"smbgroup", "smbuser", "all" };
|
||||
|
||||
typedef struct us_node {
|
||||
nvlist_t *usn_nvl;
|
||||
@@ -2669,11 +2670,9 @@ typedef struct {
|
||||
} us_sort_info_t;
|
||||
|
||||
static int
|
||||
us_field_index(char *field)
|
||||
us_field_index(const char *field)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < USFIELD_LAST; i++) {
|
||||
for (int i = 0; i < USFIELD_LAST; i++) {
|
||||
if (strcmp(field, us_field_names[i]) == 0)
|
||||
return (i);
|
||||
}
|
||||
@@ -2695,8 +2694,8 @@ us_compare(const void *larg, const void *rarg, void *unused)
|
||||
boolean_t lvb, rvb;
|
||||
|
||||
for (; sortcol != NULL; sortcol = sortcol->sc_next) {
|
||||
char *lvstr = "";
|
||||
char *rvstr = "";
|
||||
char *lvstr = (char *)"";
|
||||
char *rvstr = (char *)"";
|
||||
uint32_t lv32 = 0;
|
||||
uint32_t rv32 = 0;
|
||||
uint64_t lv64 = 0;
|
||||
@@ -2818,7 +2817,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
|
||||
us_cbdata_t *cb = (us_cbdata_t *)arg;
|
||||
zfs_userquota_prop_t prop = cb->cb_prop;
|
||||
char *name = NULL;
|
||||
char *propname;
|
||||
const char *propname;
|
||||
char sizebuf[32];
|
||||
us_node_t *node;
|
||||
uu_avl_pool_t *avl_pool = cb->cb_avl_pool;
|
||||
@@ -3018,26 +3017,25 @@ print_us_node(boolean_t scripted, boolean_t parsable, int *fields, int types,
|
||||
while ((field = fields[cfield]) != USFIELD_LAST) {
|
||||
nvpair_t *nvp = NULL;
|
||||
data_type_t type;
|
||||
uint32_t val32;
|
||||
uint64_t val64;
|
||||
char *strval = "-";
|
||||
uint32_t val32 = -1;
|
||||
uint64_t val64 = -1;
|
||||
const char *strval = "-";
|
||||
|
||||
while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL) {
|
||||
while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL)
|
||||
if (strcmp(nvpair_name(nvp),
|
||||
us_field_names[field]) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
type = nvp == NULL ? DATA_TYPE_UNKNOWN : nvpair_type(nvp);
|
||||
switch (type) {
|
||||
case DATA_TYPE_UINT32:
|
||||
(void) nvpair_value_uint32(nvp, &val32);
|
||||
val32 = fnvpair_value_uint32(nvp);
|
||||
break;
|
||||
case DATA_TYPE_UINT64:
|
||||
(void) nvpair_value_uint64(nvp, &val64);
|
||||
val64 = fnvpair_value_uint64(nvp);
|
||||
break;
|
||||
case DATA_TYPE_STRING:
|
||||
(void) nvpair_value_string(nvp, &strval);
|
||||
strval = fnvpair_value_string(nvp);
|
||||
break;
|
||||
case DATA_TYPE_UNKNOWN:
|
||||
break;
|
||||
@@ -3048,7 +3046,7 @@ print_us_node(boolean_t scripted, boolean_t parsable, int *fields, int types,
|
||||
switch (field) {
|
||||
case USFIELD_TYPE:
|
||||
if (type == DATA_TYPE_UINT32)
|
||||
strval = (char *)us_type2str(val32);
|
||||
strval = us_type2str(val32);
|
||||
break;
|
||||
case USFIELD_NAME:
|
||||
if (type == DATA_TYPE_UINT64) {
|
||||
@@ -3095,12 +3093,12 @@ print_us_node(boolean_t scripted, boolean_t parsable, int *fields, int types,
|
||||
|
||||
if (!first) {
|
||||
if (scripted)
|
||||
(void) printf("\t");
|
||||
(void) putchar('\t');
|
||||
else
|
||||
(void) printf(" ");
|
||||
(void) fputs(" ", stdout);
|
||||
}
|
||||
if (scripted)
|
||||
(void) printf("%s", strval);
|
||||
(void) fputs(strval, stdout);
|
||||
else if (field == USFIELD_TYPE || field == USFIELD_NAME)
|
||||
(void) printf("%-*s", (int)width[field], strval);
|
||||
else
|
||||
@@ -3110,7 +3108,7 @@ print_us_node(boolean_t scripted, boolean_t parsable, int *fields, int types,
|
||||
cfield++;
|
||||
}
|
||||
|
||||
(void) printf("\n");
|
||||
(void) putchar('\n');
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -3476,15 +3474,15 @@ print_dataset(zfs_handle_t *zhp, list_cbdata_t *cb)
|
||||
char property[ZFS_MAXPROPLEN];
|
||||
nvlist_t *userprops = zfs_get_user_props(zhp);
|
||||
nvlist_t *propval;
|
||||
char *propstr;
|
||||
const char *propstr;
|
||||
boolean_t right_justify;
|
||||
|
||||
for (; pl != NULL; pl = pl->pl_next) {
|
||||
if (!first) {
|
||||
if (cb->cb_scripted)
|
||||
(void) printf("\t");
|
||||
(void) putchar('\t');
|
||||
else
|
||||
(void) printf(" ");
|
||||
(void) fputs(" ", stdout);
|
||||
} else {
|
||||
first = B_FALSE;
|
||||
}
|
||||
@@ -3521,8 +3519,8 @@ print_dataset(zfs_handle_t *zhp, list_cbdata_t *cb)
|
||||
pl->pl_user_prop, &propval) != 0)
|
||||
propstr = "-";
|
||||
else
|
||||
verify(nvlist_lookup_string(propval,
|
||||
ZPROP_VALUE, &propstr) == 0);
|
||||
propstr = fnvlist_lookup_string(propval,
|
||||
ZPROP_VALUE);
|
||||
right_justify = B_FALSE;
|
||||
}
|
||||
|
||||
@@ -3532,14 +3530,14 @@ print_dataset(zfs_handle_t *zhp, list_cbdata_t *cb)
|
||||
* format specifier.
|
||||
*/
|
||||
if (cb->cb_scripted || (pl->pl_next == NULL && !right_justify))
|
||||
(void) printf("%s", propstr);
|
||||
(void) fputs(propstr, stdout);
|
||||
else if (right_justify)
|
||||
(void) printf("%*s", (int)pl->pl_width, propstr);
|
||||
else
|
||||
(void) printf("%-*s", (int)pl->pl_width, propstr);
|
||||
}
|
||||
|
||||
(void) printf("\n");
|
||||
(void) putchar('\n');
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -6419,7 +6417,7 @@ print_holds(boolean_t scripted, int nwidth, int tagwidth, nvlist_t *nvl)
|
||||
{
|
||||
int i;
|
||||
nvpair_t *nvp = NULL;
|
||||
char *hdr_cols[] = { "NAME", "TAG", "TIMESTAMP" };
|
||||
const char *const hdr_cols[] = { "NAME", "TAG", "TIMESTAMP" };
|
||||
const char *col;
|
||||
|
||||
if (!scripted) {
|
||||
@@ -6607,7 +6605,7 @@ typedef struct get_all_state {
|
||||
static int
|
||||
get_one_dataset(zfs_handle_t *zhp, void *data)
|
||||
{
|
||||
static char *spin[] = { "-", "\\", "|", "/" };
|
||||
static const char *const spin[] = { "-", "\\", "|", "/" };
|
||||
static int spinval = 0;
|
||||
static int spincheck = 0;
|
||||
static time_t last_spin_time = (time_t)0;
|
||||
@@ -6893,10 +6891,7 @@ share_mount_one(zfs_handle_t *zhp, int op, int flags, enum sa_protocol protocol,
|
||||
break;
|
||||
|
||||
case OP_MOUNT:
|
||||
if (options == NULL)
|
||||
mnt.mnt_mntopts = "";
|
||||
else
|
||||
mnt.mnt_mntopts = (char *)options;
|
||||
mnt.mnt_mntopts = (char *)(options ?: "");
|
||||
|
||||
if (!hasmntopt(&mnt, MNTOPT_REMOUNT) &&
|
||||
zfs_is_mounted(zhp, NULL)) {
|
||||
@@ -7616,7 +7611,7 @@ zfs_do_unshare(int argc, char **argv)
|
||||
}
|
||||
|
||||
static int
|
||||
find_command_idx(char *command, int *idx)
|
||||
find_command_idx(const char *command, int *idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -7881,7 +7876,6 @@ static int
|
||||
zfs_do_channel_program(int argc, char **argv)
|
||||
{
|
||||
int ret, fd, c;
|
||||
char *progbuf, *filename, *poolname;
|
||||
size_t progsize, progread;
|
||||
nvlist_t *outnvl = NULL;
|
||||
uint64_t instrlimit = ZCP_DEFAULT_INSTRLIMIT;
|
||||
@@ -7938,8 +7932,8 @@ zfs_do_channel_program(int argc, char **argv)
|
||||
goto usage;
|
||||
}
|
||||
|
||||
poolname = argv[0];
|
||||
filename = argv[1];
|
||||
const char *poolname = argv[0];
|
||||
const char *filename = argv[1];
|
||||
if (strcmp(filename, "-") == 0) {
|
||||
fd = 0;
|
||||
filename = "standard input";
|
||||
@@ -7964,7 +7958,7 @@ zfs_do_channel_program(int argc, char **argv)
|
||||
*/
|
||||
progread = 0;
|
||||
progsize = 1024;
|
||||
progbuf = safe_malloc(progsize);
|
||||
char *progbuf = safe_malloc(progsize);
|
||||
do {
|
||||
ret = read(fd, progbuf + progread, progsize - progread);
|
||||
progread += ret;
|
||||
@@ -8010,14 +8004,17 @@ zfs_do_channel_program(int argc, char **argv)
|
||||
* exists. Otherwise, generate an appropriate error message,
|
||||
* falling back on strerror() for an unexpected return code.
|
||||
*/
|
||||
char *errstring = NULL;
|
||||
const char *errstring = NULL;
|
||||
const char *msg = gettext("Channel program execution failed");
|
||||
uint64_t instructions = 0;
|
||||
if (outnvl != NULL && nvlist_exists(outnvl, ZCP_RET_ERROR)) {
|
||||
char *es = NULL;
|
||||
(void) nvlist_lookup_string(outnvl,
|
||||
ZCP_RET_ERROR, &errstring);
|
||||
if (errstring == NULL)
|
||||
ZCP_RET_ERROR, &es);
|
||||
if (es == NULL)
|
||||
errstring = strerror(ret);
|
||||
else
|
||||
errstring = es;
|
||||
if (ret == ETIME) {
|
||||
(void) nvlist_lookup_uint64(outnvl,
|
||||
ZCP_ARG_INSTRLIMIT, &instructions);
|
||||
@@ -8601,7 +8598,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
int i = 0;
|
||||
char *cmdname;
|
||||
const char *cmdname;
|
||||
char **newargv;
|
||||
|
||||
(void) setlocale(LC_ALL, "");
|
||||
|
||||
@@ -442,9 +442,8 @@ static void
|
||||
vdev_run_cmd(vdev_cmd_data_t *data, char *cmd)
|
||||
{
|
||||
int rc;
|
||||
char *argv[2] = {cmd, 0};
|
||||
char *env[5] = {"PATH=/bin:/sbin:/usr/bin:/usr/sbin", NULL, NULL, NULL,
|
||||
NULL};
|
||||
char *argv[2] = {cmd};
|
||||
char *env[5] = {(char *)"PATH=/bin:/sbin:/usr/bin:/usr/sbin"};
|
||||
char **lines = NULL;
|
||||
int lines_cnt = 0;
|
||||
int i;
|
||||
|
||||
+39
-42
@@ -711,7 +711,7 @@ print_vdev_tree(zpool_handle_t *zhp, const char *name, nvlist_t *nv, int indent,
|
||||
|
||||
for (c = 0; c < children; c++) {
|
||||
uint64_t is_log = B_FALSE, is_hole = B_FALSE;
|
||||
char *class = "";
|
||||
char *class = (char *)"";
|
||||
|
||||
(void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_HOLE,
|
||||
&is_hole);
|
||||
@@ -723,7 +723,7 @@ print_vdev_tree(zpool_handle_t *zhp, const char *name, nvlist_t *nv, int indent,
|
||||
(void) nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG,
|
||||
&is_log);
|
||||
if (is_log)
|
||||
class = VDEV_ALLOC_BIAS_LOG;
|
||||
class = (char *)VDEV_ALLOC_BIAS_LOG;
|
||||
(void) nvlist_lookup_string(child[c],
|
||||
ZPOOL_CONFIG_ALLOCATION_BIAS, &class);
|
||||
if (strcmp(match, class) != 0)
|
||||
@@ -804,7 +804,7 @@ prop_list_contains_feature(nvlist_t *proplist)
|
||||
* Add a property pair (name, string-value) into a property nvlist.
|
||||
*/
|
||||
static int
|
||||
add_prop_list(const char *propname, char *propval, nvlist_t **props,
|
||||
add_prop_list(const char *propname, const char *propval, nvlist_t **props,
|
||||
boolean_t poolprop)
|
||||
{
|
||||
zpool_prop_t prop = ZPOOL_PROP_INVAL;
|
||||
@@ -905,7 +905,8 @@ add_prop_list(const char *propname, char *propval, nvlist_t **props,
|
||||
* Set a default property pair (name, string-value) in a property nvlist
|
||||
*/
|
||||
static int
|
||||
add_prop_list_default(const char *propname, char *propval, nvlist_t **props)
|
||||
add_prop_list_default(const char *propname, const char *propval,
|
||||
nvlist_t **props)
|
||||
{
|
||||
char *pval;
|
||||
|
||||
@@ -2069,15 +2070,13 @@ typedef struct status_cbdata {
|
||||
} status_cbdata_t;
|
||||
|
||||
/* Return 1 if string is NULL, empty, or whitespace; return 0 otherwise. */
|
||||
static int
|
||||
is_blank_str(char *str)
|
||||
static boolean_t
|
||||
is_blank_str(const char *str)
|
||||
{
|
||||
while (str != NULL && *str != '\0') {
|
||||
for (; str != NULL && *str != '\0'; ++str)
|
||||
if (!isblank(*str))
|
||||
return (0);
|
||||
str++;
|
||||
}
|
||||
return (1);
|
||||
return (B_FALSE);
|
||||
return (B_TRUE);
|
||||
}
|
||||
|
||||
/* Print command output lines for specific vdev in a specific pool */
|
||||
@@ -2086,7 +2085,7 @@ zpool_print_cmd(vdev_cmd_data_list_t *vcdl, const char *pool, char *path)
|
||||
{
|
||||
vdev_cmd_data_t *data;
|
||||
int i, j;
|
||||
char *val;
|
||||
const char *val;
|
||||
|
||||
for (i = 0; i < vcdl->count; i++) {
|
||||
if ((strcmp(vcdl->data[i].path, path) != 0) ||
|
||||
@@ -2117,17 +2116,17 @@ zpool_print_cmd(vdev_cmd_data_list_t *vcdl, const char *pool, char *path)
|
||||
|
||||
printf("%*s", vcdl->uniq_cols_width[j], val);
|
||||
if (j < vcdl->uniq_cols_cnt - 1)
|
||||
printf(" ");
|
||||
fputs(" ", stdout);
|
||||
}
|
||||
|
||||
/* Print out any values that aren't in a column at the end */
|
||||
for (j = data->cols_cnt; j < data->lines_cnt; j++) {
|
||||
/* Did we have any columns? If so print a spacer. */
|
||||
if (vcdl->uniq_cols_cnt > 0)
|
||||
printf(" ");
|
||||
fputs(" ", stdout);
|
||||
|
||||
val = data->lines[j];
|
||||
printf("%s", val ? val : "");
|
||||
fputs(val ?: "", stdout);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2240,7 +2239,7 @@ print_status_trim(vdev_stat_t *vs, boolean_t verbose)
|
||||
* Return the color associated with a health string. This includes returning
|
||||
* NULL for no color change.
|
||||
*/
|
||||
static char *
|
||||
static const char *
|
||||
health_str_to_color(const char *health)
|
||||
{
|
||||
if (strcmp(health, gettext("FAULTED")) == 0 ||
|
||||
@@ -2276,7 +2275,7 @@ print_status_config(zpool_handle_t *zhp, status_cbdata_t *cb, const char *name,
|
||||
const char *state;
|
||||
char *type;
|
||||
char *path = NULL;
|
||||
char *rcolor = NULL, *wcolor = NULL, *ccolor = NULL;
|
||||
const char *rcolor = NULL, *wcolor = NULL, *ccolor = NULL;
|
||||
|
||||
if (nvlist_lookup_nvlist_array(nv, ZPOOL_CONFIG_CHILDREN,
|
||||
&child, &children) != 0)
|
||||
@@ -2318,13 +2317,13 @@ print_status_config(zpool_handle_t *zhp, status_cbdata_t *cb, const char *name,
|
||||
ccolor = ANSI_RED;
|
||||
|
||||
if (cb->cb_literal) {
|
||||
printf(" ");
|
||||
fputc(' ', stdout);
|
||||
printf_color(rcolor, "%5llu",
|
||||
(u_longlong_t)vs->vs_read_errors);
|
||||
printf(" ");
|
||||
fputc(' ', stdout);
|
||||
printf_color(wcolor, "%5llu",
|
||||
(u_longlong_t)vs->vs_write_errors);
|
||||
printf(" ");
|
||||
fputc(' ', stdout);
|
||||
printf_color(ccolor, "%5llu",
|
||||
(u_longlong_t)vs->vs_checksum_errors);
|
||||
} else {
|
||||
@@ -2332,11 +2331,11 @@ print_status_config(zpool_handle_t *zhp, status_cbdata_t *cb, const char *name,
|
||||
zfs_nicenum(vs->vs_write_errors, wbuf, sizeof (wbuf));
|
||||
zfs_nicenum(vs->vs_checksum_errors, cbuf,
|
||||
sizeof (cbuf));
|
||||
printf(" ");
|
||||
fputc(' ', stdout);
|
||||
printf_color(rcolor, "%5s", rbuf);
|
||||
printf(" ");
|
||||
fputc(' ', stdout);
|
||||
printf_color(wcolor, "%5s", wbuf);
|
||||
printf(" ");
|
||||
fputc(' ', stdout);
|
||||
printf_color(ccolor, "%5s", cbuf);
|
||||
}
|
||||
if (cb->cb_print_slow_ios) {
|
||||
@@ -2671,7 +2670,7 @@ print_class_vdevs(zpool_handle_t *zhp, status_cbdata_t *cb, nvlist_t *nv,
|
||||
&is_log);
|
||||
|
||||
if (is_log) {
|
||||
bias = VDEV_ALLOC_CLASS_LOGS;
|
||||
bias = (char *)VDEV_ALLOC_CLASS_LOGS;
|
||||
} else {
|
||||
(void) nvlist_lookup_string(child[c],
|
||||
ZPOOL_CONFIG_ALLOCATION_BIAS, &bias);
|
||||
@@ -2711,8 +2710,8 @@ show_import(nvlist_t *config, boolean_t report_error)
|
||||
char *name;
|
||||
uint64_t guid;
|
||||
uint64_t hostid = 0;
|
||||
char *msgid;
|
||||
char *hostname = "unknown";
|
||||
const char *msgid;
|
||||
const char *hostname = "unknown";
|
||||
nvlist_t *nvroot, *nvinfo;
|
||||
zpool_status_t reason;
|
||||
zpool_errata_t errata;
|
||||
@@ -3252,7 +3251,7 @@ import_pools(nvlist_t *pools, nvlist_t *props, char *mntopts, int flags,
|
||||
if (first)
|
||||
first = B_FALSE;
|
||||
else if (!do_all)
|
||||
(void) putchar('\n');
|
||||
(void) fputc('\n', stdout);
|
||||
|
||||
if (do_all) {
|
||||
err |= do_import(config, NULL, mntopts,
|
||||
@@ -4848,7 +4847,7 @@ children:
|
||||
(void) nvlist_lookup_uint64(newchild[c],
|
||||
ZPOOL_CONFIG_IS_LOG, &islog);
|
||||
if (islog) {
|
||||
bias = VDEV_ALLOC_CLASS_LOGS;
|
||||
bias = (char *)VDEV_ALLOC_CLASS_LOGS;
|
||||
} else {
|
||||
(void) nvlist_lookup_string(newchild[c],
|
||||
ZPOOL_CONFIG_ALLOCATION_BIAS, &bias);
|
||||
@@ -5382,7 +5381,7 @@ terminal_height(void)
|
||||
static void
|
||||
print_zpool_script_help(char *name, char *path)
|
||||
{
|
||||
char *argv[] = {path, "-h", NULL};
|
||||
char *argv[] = {path, (char *)"-h", NULL};
|
||||
char **lines = NULL;
|
||||
int lines_cnt = 0;
|
||||
int rc;
|
||||
@@ -5434,7 +5433,7 @@ print_zpool_dir_scripts(char *dirpath)
|
||||
* Print out help text for all zpool status/iostat -c scripts.
|
||||
*/
|
||||
static void
|
||||
print_zpool_script_list(char *subcommand)
|
||||
print_zpool_script_list(const char *subcommand)
|
||||
{
|
||||
char *dir, *sp, *tmp;
|
||||
|
||||
@@ -5979,7 +5978,7 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
|
||||
zprop_list_t *pl = cb->cb_proplist;
|
||||
boolean_t first = B_TRUE;
|
||||
char property[ZPOOL_MAXPROPLEN];
|
||||
char *propstr;
|
||||
const char *propstr;
|
||||
boolean_t right_justify;
|
||||
size_t width;
|
||||
|
||||
@@ -6214,7 +6213,7 @@ print_list_stats(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
|
||||
|
||||
if (nvlist_lookup_uint64(child[c], ZPOOL_CONFIG_IS_LOG,
|
||||
&islog) == 0 && islog) {
|
||||
bias = VDEV_ALLOC_CLASS_LOGS;
|
||||
bias = (char *)VDEV_ALLOC_CLASS_LOGS;
|
||||
} else {
|
||||
(void) nvlist_lookup_string(child[c],
|
||||
ZPOOL_CONFIG_ALLOCATION_BIAS, &bias);
|
||||
@@ -8118,7 +8117,7 @@ status_callback(zpool_handle_t *zhp, void *data)
|
||||
{
|
||||
status_cbdata_t *cbp = data;
|
||||
nvlist_t *config, *nvroot;
|
||||
char *msgid;
|
||||
const char *msgid;
|
||||
zpool_status_t reason;
|
||||
zpool_errata_t errata;
|
||||
const char *health;
|
||||
@@ -8163,12 +8162,12 @@ status_callback(zpool_handle_t *zhp, void *data)
|
||||
printf(" ");
|
||||
printf_color(ANSI_BOLD, gettext("pool:"));
|
||||
printf(" %s\n", zpool_get_name(zhp));
|
||||
printf(" ");
|
||||
fputc(' ', stdout);
|
||||
printf_color(ANSI_BOLD, gettext("state: "));
|
||||
|
||||
printf_color(health_str_to_color(health), "%s", health);
|
||||
|
||||
printf("\n");
|
||||
fputc('\n', stdout);
|
||||
|
||||
switch (reason) {
|
||||
case ZPOOL_STATUS_MISSING_DEV_R:
|
||||
@@ -10485,8 +10484,8 @@ print_wait_status_row(wait_data_t *wd, zpool_handle_t *zhp, int row)
|
||||
pool_checkpoint_stat_t *pcs = NULL;
|
||||
pool_scan_stat_t *pss = NULL;
|
||||
pool_removal_stat_t *prs = NULL;
|
||||
char *headers[] = {"DISCARD", "FREE", "INITIALIZE", "REPLACE",
|
||||
"REMOVE", "RESILVER", "SCRUB", "TRIM"};
|
||||
const char *const headers[] = {"DISCARD", "FREE", "INITIALIZE",
|
||||
"REPLACE", "REMOVE", "RESILVER", "SCRUB", "TRIM"};
|
||||
int col_widths[ZPOOL_WAIT_NUM_ACTIVITIES];
|
||||
|
||||
/* Calculate the width of each column */
|
||||
@@ -10508,7 +10507,7 @@ print_wait_status_row(wait_data_t *wd, zpool_handle_t *zhp, int row)
|
||||
if (wd->wd_enabled[i])
|
||||
(void) printf("%*s", col_widths[i], headers[i]);
|
||||
}
|
||||
(void) printf("\n");
|
||||
(void) fputc('\n', stdout);
|
||||
}
|
||||
|
||||
/* Bytes of work remaining in each activity */
|
||||
@@ -10795,11 +10794,9 @@ found:;
|
||||
}
|
||||
|
||||
static int
|
||||
find_command_idx(char *command, int *idx)
|
||||
find_command_idx(const char *command, int *idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NCOMMAND; i++) {
|
||||
for (int i = 0; i < NCOMMAND; ++i) {
|
||||
if (command_table[i].name == NULL)
|
||||
continue;
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ make_leaf_vdev(nvlist_t *props, const char *arg, boolean_t is_primary)
|
||||
char path[MAXPATHLEN];
|
||||
struct stat64 statbuf;
|
||||
nvlist_t *vdev = NULL;
|
||||
char *type = NULL;
|
||||
const char *type = NULL;
|
||||
boolean_t wholedisk = B_FALSE;
|
||||
uint64_t ashift = 0;
|
||||
int err;
|
||||
|
||||
@@ -90,7 +90,7 @@ char metric_data_type = 'u';
|
||||
uint64_t metric_value_mask = UINT64_MAX;
|
||||
uint64_t timestamp = 0;
|
||||
int complained_about_sync = 0;
|
||||
char *tags = "";
|
||||
const char *tags = "";
|
||||
|
||||
typedef int (*stat_printer_f)(nvlist_t *, const char *, const char *);
|
||||
|
||||
@@ -131,7 +131,7 @@ escape_string(const char *s)
|
||||
* print key=value where value is a uint64_t
|
||||
*/
|
||||
static void
|
||||
print_kv(char *key, uint64_t value)
|
||||
print_kv(const char *key, uint64_t value)
|
||||
{
|
||||
printf("%s=%llu%c", key,
|
||||
(u_longlong_t)value & metric_value_mask, metric_data_type);
|
||||
@@ -152,9 +152,9 @@ print_scan_status(nvlist_t *nvroot, const char *pool_name)
|
||||
uint64_t remaining_time;
|
||||
pool_scan_stat_t *ps = NULL;
|
||||
double pct_done;
|
||||
char *state[DSS_NUM_STATES] = {
|
||||
const char *const state[DSS_NUM_STATES] = {
|
||||
"none", "scanning", "finished", "canceled"};
|
||||
char *func;
|
||||
const char *func;
|
||||
|
||||
(void) nvlist_lookup_uint64_array(nvroot,
|
||||
ZPOOL_CONFIG_SCAN_STATS,
|
||||
@@ -262,17 +262,15 @@ static char *
|
||||
get_vdev_name(nvlist_t *nvroot, const char *parent_name)
|
||||
{
|
||||
static char vdev_name[256];
|
||||
char *vdev_type = NULL;
|
||||
uint64_t vdev_id = 0;
|
||||
|
||||
if (nvlist_lookup_string(nvroot, ZPOOL_CONFIG_TYPE,
|
||||
&vdev_type) != 0) {
|
||||
vdev_type = "unknown";
|
||||
}
|
||||
char *vdev_type = (char *)"unknown";
|
||||
nvlist_lookup_string(nvroot, ZPOOL_CONFIG_TYPE, &vdev_type);
|
||||
|
||||
if (nvlist_lookup_uint64(
|
||||
nvroot, ZPOOL_CONFIG_ID, &vdev_id) != 0) {
|
||||
nvroot, ZPOOL_CONFIG_ID, &vdev_id) != 0)
|
||||
vdev_id = UINT64_MAX;
|
||||
}
|
||||
|
||||
if (parent_name == NULL) {
|
||||
(void) snprintf(vdev_name, sizeof (vdev_name), "%s",
|
||||
vdev_type);
|
||||
@@ -298,22 +296,15 @@ static char *
|
||||
get_vdev_desc(nvlist_t *nvroot, const char *parent_name)
|
||||
{
|
||||
static char vdev_desc[2 * MAXPATHLEN];
|
||||
char *vdev_type = NULL;
|
||||
uint64_t vdev_id = 0;
|
||||
char vdev_value[MAXPATHLEN];
|
||||
char *vdev_path = NULL;
|
||||
char *s, *t;
|
||||
|
||||
if (nvlist_lookup_string(nvroot, ZPOOL_CONFIG_TYPE, &vdev_type) != 0) {
|
||||
vdev_type = "unknown";
|
||||
}
|
||||
if (nvlist_lookup_uint64(nvroot, ZPOOL_CONFIG_ID, &vdev_id) != 0) {
|
||||
vdev_id = UINT64_MAX;
|
||||
}
|
||||
if (nvlist_lookup_string(
|
||||
nvroot, ZPOOL_CONFIG_PATH, &vdev_path) != 0) {
|
||||
vdev_path = NULL;
|
||||
}
|
||||
char *vdev_type = (char *)"unknown";
|
||||
uint64_t vdev_id = UINT64_MAX;
|
||||
char *vdev_path = NULL;
|
||||
nvlist_lookup_string(nvroot, ZPOOL_CONFIG_TYPE, &vdev_type);
|
||||
nvlist_lookup_uint64(nvroot, ZPOOL_CONFIG_ID, &vdev_id);
|
||||
nvlist_lookup_string(nvroot, ZPOOL_CONFIG_PATH, &vdev_path);
|
||||
|
||||
if (parent_name == NULL) {
|
||||
s = escape_string(vdev_type);
|
||||
@@ -393,8 +384,8 @@ print_vdev_latency_stats(nvlist_t *nvroot, const char *pool_name,
|
||||
|
||||
/* short_names become part of the metric name and are influxdb-ready */
|
||||
struct lat_lookup {
|
||||
char *name;
|
||||
char *short_name;
|
||||
const char *name;
|
||||
const char *short_name;
|
||||
uint64_t sum;
|
||||
uint64_t *array;
|
||||
};
|
||||
@@ -487,8 +478,8 @@ print_vdev_size_stats(nvlist_t *nvroot, const char *pool_name,
|
||||
|
||||
/* short_names become the field name */
|
||||
struct size_lookup {
|
||||
char *name;
|
||||
char *short_name;
|
||||
const char *name;
|
||||
const char *short_name;
|
||||
uint64_t sum;
|
||||
uint64_t *array;
|
||||
};
|
||||
@@ -579,8 +570,8 @@ print_queue_stats(nvlist_t *nvroot, const char *pool_name,
|
||||
|
||||
/* short_names are used for the field name */
|
||||
struct queue_lookup {
|
||||
char *name;
|
||||
char *short_name;
|
||||
const char *name;
|
||||
const char *short_name;
|
||||
};
|
||||
struct queue_lookup queue_type[] = {
|
||||
{ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE, "sync_r_active"},
|
||||
@@ -632,8 +623,8 @@ print_top_level_vdev_stats(nvlist_t *nvroot, const char *pool_name)
|
||||
|
||||
/* short_names become part of the metric name */
|
||||
struct queue_lookup {
|
||||
char *name;
|
||||
char *short_name;
|
||||
const char *name;
|
||||
const char *short_name;
|
||||
};
|
||||
struct queue_lookup queue_type[] = {
|
||||
{ZPOOL_CONFIG_VDEV_SYNC_R_ACTIVE_QUEUE, "sync_r_active_queue"},
|
||||
@@ -789,7 +780,7 @@ main(int argc, char *argv[])
|
||||
{
|
||||
int opt;
|
||||
int ret = 8;
|
||||
char *line = NULL;
|
||||
char *line = NULL, *ttags = NULL;
|
||||
size_t len, tagslen = 0;
|
||||
struct option long_options[] = {
|
||||
{"execd", no_argument, NULL, 'e'},
|
||||
@@ -817,15 +808,17 @@ main(int argc, char *argv[])
|
||||
sum_histogram_buckets = 1;
|
||||
break;
|
||||
case 't':
|
||||
free(ttags);
|
||||
tagslen = strlen(optarg) + 2;
|
||||
tags = calloc(1, tagslen);
|
||||
if (tags == NULL) {
|
||||
ttags = calloc(1, tagslen);
|
||||
if (ttags == NULL) {
|
||||
fprintf(stderr,
|
||||
"error: cannot allocate memory "
|
||||
"for tags\n");
|
||||
exit(1);
|
||||
}
|
||||
(void) snprintf(tags, tagslen, ",%s", optarg);
|
||||
(void) snprintf(ttags, tagslen, ",%s", optarg);
|
||||
tags = ttags;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
|
||||
+23
-25
@@ -264,7 +264,7 @@ extern unsigned long zfs_reconstruct_indirect_damage_fraction;
|
||||
|
||||
static ztest_shared_opts_t *ztest_shared_opts;
|
||||
static ztest_shared_opts_t ztest_opts;
|
||||
static char *ztest_wkeydata = "abcdefghijklmnopqrstuvwxyz012345";
|
||||
static const char *const ztest_wkeydata = "abcdefghijklmnopqrstuvwxyz012345";
|
||||
|
||||
typedef struct ztest_shared_ds {
|
||||
uint64_t zd_seq;
|
||||
@@ -623,10 +623,10 @@ static void sig_handler(int signo)
|
||||
|
||||
#define FATAL_MSG_SZ 1024
|
||||
|
||||
char *fatal_msg;
|
||||
static const char *fatal_msg;
|
||||
|
||||
static __attribute__((format(printf, 2, 3))) __attribute__((noreturn)) void
|
||||
fatal(int do_perror, char *message, ...)
|
||||
fatal(int do_perror, const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
int save_errno = errno;
|
||||
@@ -724,7 +724,7 @@ typedef struct ztest_option {
|
||||
const char *long_opt_param;
|
||||
const char *comment;
|
||||
unsigned int default_int;
|
||||
char *default_str;
|
||||
const char *default_str;
|
||||
} ztest_option_t;
|
||||
|
||||
/*
|
||||
@@ -1200,30 +1200,31 @@ ztest_is_draid_spare(const char *name)
|
||||
}
|
||||
|
||||
static nvlist_t *
|
||||
make_vdev_file(char *path, char *aux, char *pool, size_t size, uint64_t ashift)
|
||||
make_vdev_file(const char *path, const char *aux, const char *pool,
|
||||
size_t size, uint64_t ashift)
|
||||
{
|
||||
char *pathbuf;
|
||||
char *pathbuf = NULL;
|
||||
uint64_t vdev;
|
||||
nvlist_t *file;
|
||||
boolean_t draid_spare = B_FALSE;
|
||||
|
||||
pathbuf = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
|
||||
|
||||
if (ashift == 0)
|
||||
ashift = ztest_get_ashift();
|
||||
|
||||
if (path == NULL) {
|
||||
pathbuf = umem_alloc(MAXPATHLEN, UMEM_NOFAIL);
|
||||
path = pathbuf;
|
||||
|
||||
if (aux != NULL) {
|
||||
vdev = ztest_shared->zs_vdev_aux;
|
||||
(void) snprintf(path, MAXPATHLEN,
|
||||
(void) snprintf(pathbuf, MAXPATHLEN,
|
||||
ztest_aux_template, ztest_opts.zo_dir,
|
||||
pool == NULL ? ztest_opts.zo_pool : pool,
|
||||
aux, vdev);
|
||||
} else {
|
||||
vdev = ztest_shared->zs_vdev_next_leaf++;
|
||||
(void) snprintf(path, MAXPATHLEN,
|
||||
(void) snprintf(pathbuf, MAXPATHLEN,
|
||||
ztest_dev_template, ztest_opts.zo_dir,
|
||||
pool == NULL ? ztest_opts.zo_pool : pool, vdev);
|
||||
}
|
||||
@@ -1251,7 +1252,7 @@ make_vdev_file(char *path, char *aux, char *pool, size_t size, uint64_t ashift)
|
||||
}
|
||||
|
||||
static nvlist_t *
|
||||
make_vdev_raid(char *path, char *aux, char *pool, size_t size,
|
||||
make_vdev_raid(const char *path, const char *aux, const char *pool, size_t size,
|
||||
uint64_t ashift, int r)
|
||||
{
|
||||
nvlist_t *raid, **child;
|
||||
@@ -1302,8 +1303,8 @@ make_vdev_raid(char *path, char *aux, char *pool, size_t size,
|
||||
}
|
||||
|
||||
static nvlist_t *
|
||||
make_vdev_mirror(char *path, char *aux, char *pool, size_t size,
|
||||
uint64_t ashift, int r, int m)
|
||||
make_vdev_mirror(const char *path, const char *aux, const char *pool,
|
||||
size_t size, uint64_t ashift, int r, int m)
|
||||
{
|
||||
nvlist_t *mirror, **child;
|
||||
int c;
|
||||
@@ -1330,8 +1331,8 @@ make_vdev_mirror(char *path, char *aux, char *pool, size_t size,
|
||||
}
|
||||
|
||||
static nvlist_t *
|
||||
make_vdev_root(char *path, char *aux, char *pool, size_t size, uint64_t ashift,
|
||||
const char *class, int r, int m, int t)
|
||||
make_vdev_root(const char *path, const char *aux, const char *pool, size_t size,
|
||||
uint64_t ashift, const char *class, int r, int m, int t)
|
||||
{
|
||||
nvlist_t *root, **child;
|
||||
int c;
|
||||
@@ -3371,7 +3372,7 @@ ztest_vdev_aux_add_remove(ztest_ds_t *zd, uint64_t id)
|
||||
spa_t *spa = ztest_spa;
|
||||
vdev_t *rvd = spa->spa_root_vdev;
|
||||
spa_aux_vdev_t *sav;
|
||||
char *aux;
|
||||
const char *aux;
|
||||
char *path;
|
||||
uint64_t guid = 0;
|
||||
int error, ignore_err = 0;
|
||||
@@ -5271,7 +5272,7 @@ ztest_zap(ztest_ds_t *zd, uint64_t id)
|
||||
dmu_tx_t *tx;
|
||||
char propname[100], txgname[100];
|
||||
int error;
|
||||
char *hc[2] = { "s.acl.h", ".s.open.h.hyLZlg" };
|
||||
const char *const hc[2] = { "s.acl.h", ".s.open.h.hyLZlg" };
|
||||
|
||||
od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
|
||||
ztest_od_init(od, id, FTAG, 0, DMU_OT_ZAP_OTHER, 0, 0, 0);
|
||||
@@ -6636,11 +6637,8 @@ ztest_global_vars_to_zdb_args(void)
|
||||
char **args = calloc(2*ztest_opts.zo_gvars_count + 1, sizeof (char *));
|
||||
char **cur = args;
|
||||
for (size_t i = 0; i < ztest_opts.zo_gvars_count; i++) {
|
||||
char *kv = ztest_opts.zo_gvars[i];
|
||||
*cur = "-o";
|
||||
cur++;
|
||||
*cur = strdup(kv);
|
||||
cur++;
|
||||
*cur++ = (char *)"-o";
|
||||
*cur++ = ztest_opts.zo_gvars[i];
|
||||
}
|
||||
ASSERT3P(cur, ==, &args[2*ztest_opts.zo_gvars_count]);
|
||||
*cur = NULL;
|
||||
@@ -6891,7 +6889,7 @@ ztest_trim(ztest_ds_t *zd, uint64_t id)
|
||||
* Verify pool integrity by running zdb.
|
||||
*/
|
||||
static void
|
||||
ztest_run_zdb(char *pool)
|
||||
ztest_run_zdb(const char *pool)
|
||||
{
|
||||
int status;
|
||||
char *bin;
|
||||
@@ -6949,12 +6947,12 @@ out:
|
||||
}
|
||||
|
||||
static void
|
||||
ztest_walk_pool_directory(char *header)
|
||||
ztest_walk_pool_directory(const char *header)
|
||||
{
|
||||
spa_t *spa = NULL;
|
||||
|
||||
if (ztest_opts.zo_verbose >= 6)
|
||||
(void) printf("%s\n", header);
|
||||
(void) puts(header);
|
||||
|
||||
mutex_enter(&spa_namespace_lock);
|
||||
while ((spa = spa_next(spa)) != NULL)
|
||||
@@ -7206,7 +7204,7 @@ ztest_thread(void *arg)
|
||||
}
|
||||
|
||||
static void
|
||||
ztest_dataset_name(char *dsname, char *pool, int d)
|
||||
ztest_dataset_name(char *dsname, const char *pool, int d)
|
||||
{
|
||||
(void) snprintf(dsname, ZFS_MAX_DATASET_NAME_LEN, "%s/ds_%d", pool, d);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user