cstyle: Resolve C style issues

The vast majority of these changes are in Linux specific code.
They are the result of not having an automated style checker to
validate the code when it was originally written.  Others were
caused when the common code was slightly adjusted for Linux.

This patch contains no functional changes.  It only refreshes
the code to conform to style guide.

Everyone submitting patches for inclusion upstream should now
run 'make checkstyle' and resolve any warning prior to opening
a pull request.  The automated builders have been updated to
fail a build if when 'make checkstyle' detects an issue.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1821
This commit is contained in:
Michael Kjorling 2013-11-01 20:26:11 +01:00 committed by Brian Behlendorf
parent 8ffef572ed
commit d1d7e2689d
165 changed files with 2120 additions and 1936 deletions

View File

@ -272,7 +272,7 @@ out:
len = strlen(cwd); len = strlen(cwd);
/* Do not add one when cwd already ends in a trailing '/' */ /* Do not add one when cwd already ends in a trailing '/' */
if (!strncmp(cwd, dataset, len)) if (strncmp(cwd, dataset, len) == 0)
return (dataset + len + (cwd[len-1] != '/')); return (dataset + len + (cwd[len-1] != '/'));
return (dataset); return (dataset);
@ -444,11 +444,11 @@ main(int argc, char **argv)
* done until zfs is added to the default selinux policy configuration * done until zfs is added to the default selinux policy configuration
* as a known filesystem type which supports xattrs. * as a known filesystem type which supports xattrs.
*/ */
if (is_selinux_enabled() && !(zfsflags & ZS_NOCONTEXT)) { if (is_selinux_enabled() && !(zfsflags & ZS_NOCONTEXT)) {
(void) strlcat(mntopts, ",context=\"system_u:" (void) strlcat(mntopts, ",context=\"system_u:"
"object_r:file_t:s0\"", sizeof (mntopts)); "object_r:file_t:s0\"", sizeof (mntopts));
(void) strlcat(mtabopt, ",context=\"system_u:" (void) strlcat(mtabopt, ",context=\"system_u:"
"object_r:file_t:s0\"", sizeof (mtabopt)); "object_r:file_t:s0\"", sizeof (mtabopt));
} }
#endif /* HAVE_LIBSELINUX */ #endif /* HAVE_LIBSELINUX */
@ -501,12 +501,12 @@ main(int argc, char **argv)
* using zfs as your root file system both rc.sysinit/umountroot and * using zfs as your root file system both rc.sysinit/umountroot and
* systemd depend on 'mount -o remount <mountpoint>' to work. * systemd depend on 'mount -o remount <mountpoint>' to work.
*/ */
if (zfsutil && !strcmp(legacy, ZFS_MOUNTPOINT_LEGACY)) { if (zfsutil && (strcmp(legacy, ZFS_MOUNTPOINT_LEGACY) == 0)) {
(void) fprintf(stderr, gettext( (void) fprintf(stderr, gettext(
"filesystem '%s' cannot be mounted using 'zfs mount'.\n" "filesystem '%s' cannot be mounted using 'zfs mount'.\n"
"Use 'zfs set mountpoint=%s' or 'mount -t zfs %s %s'.\n" "Use 'zfs set mountpoint=%s' or 'mount -t zfs %s %s'.\n"
"See zfs(8) for more information.\n"), "See zfs(8) for more information.\n"),
dataset, mntpoint, dataset, mntpoint); dataset, mntpoint, dataset, mntpoint);
return (MOUNT_USAGE); return (MOUNT_USAGE);
} }

View File

@ -165,7 +165,8 @@ usage(void)
(void) fprintf(stderr, " -t <txg> -- highest txg to use when " (void) fprintf(stderr, " -t <txg> -- highest txg to use when "
"searching for uberblocks\n"); "searching for uberblocks\n");
(void) fprintf(stderr, " -M <number of inflight I/Os> -- " (void) fprintf(stderr, " -M <number of inflight I/Os> -- "
"specify the maximum number of checksumming I/Os [default is 200]\n"); "specify the maximum number of checksumming I/Os "
"[default is 200]\n");
(void) fprintf(stderr, "Specify an option more than once (e.g. -bb) " (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) "
"to make only that option verbose\n"); "to make only that option verbose\n");
(void) fprintf(stderr, "Default is to dump everything non-verbosely\n"); (void) fprintf(stderr, "Default is to dump everything non-verbosely\n");
@ -1319,7 +1320,8 @@ dump_deadlist(dsl_deadlist_t *dl)
dle = AVL_NEXT(&dl->dl_tree, dle)) { dle = AVL_NEXT(&dl->dl_tree, dle)) {
if (dump_opt['d'] >= 5) { if (dump_opt['d'] >= 5) {
char buf[128]; char buf[128];
(void) snprintf(buf, sizeof (buf), "mintxg %llu -> obj %llu", (void) snprintf(buf, sizeof (buf),
"mintxg %llu -> obj %llu",
(longlong_t)dle->dle_mintxg, (longlong_t)dle->dle_mintxg,
(longlong_t)dle->dle_bpobj.bpo_object); (longlong_t)dle->dle_bpobj.bpo_object);
@ -1436,7 +1438,7 @@ dump_znode_sa_xattr(sa_handle_t *hdl)
(void) printf("\t\t%s = ", nvpair_name(elem)); (void) printf("\t\t%s = ", nvpair_name(elem));
nvpair_value_byte_array(elem, &value, &cnt); nvpair_value_byte_array(elem, &value, &cnt);
for (idx = 0 ; idx < cnt ; ++idx) { for (idx = 0; idx < cnt; ++idx) {
if (isprint(value[idx])) if (isprint(value[idx]))
(void) putchar(value[idx]); (void) putchar(value[idx]);
else else
@ -2394,7 +2396,7 @@ dump_block_stats(spa_t *spa)
* it's not part of any space map) is a double allocation, * it's not part of any space map) is a double allocation,
* reference to a freed block, or an unclaimed log block. * reference to a freed block, or an unclaimed log block.
*/ */
bzero(&zcb, sizeof(zdb_cb_t)); bzero(&zcb, sizeof (zdb_cb_t));
zdb_leak_init(spa, &zcb); zdb_leak_init(spa, &zcb);
/* /*

View File

@ -313,8 +313,8 @@ zfs_sort(const void *larg, const void *rarg, void *data)
} else if (psc->sc_prop == ZFS_PROP_NAME) { } else if (psc->sc_prop == ZFS_PROP_NAME) {
lvalid = rvalid = B_TRUE; lvalid = rvalid = B_TRUE;
(void) strlcpy(lbuf, zfs_get_name(l), sizeof(lbuf)); (void) strlcpy(lbuf, zfs_get_name(l), sizeof (lbuf));
(void) strlcpy(rbuf, zfs_get_name(r), sizeof(rbuf)); (void) strlcpy(rbuf, zfs_get_name(r), sizeof (rbuf));
lstr = lbuf; lstr = lbuf;
rstr = rbuf; rstr = rbuf;

View File

@ -2879,13 +2879,13 @@ print_dataset(zfs_handle_t *zhp, list_cbdata_t *cb)
if (pl->pl_prop == ZFS_PROP_NAME) { if (pl->pl_prop == ZFS_PROP_NAME) {
(void) strlcpy(property, zfs_get_name(zhp), (void) strlcpy(property, zfs_get_name(zhp),
sizeof(property)); sizeof (property));
propstr = property; propstr = property;
right_justify = zfs_prop_align_right(pl->pl_prop); right_justify = zfs_prop_align_right(pl->pl_prop);
} else if (pl->pl_prop != ZPROP_INVAL) { } else if (pl->pl_prop != ZPROP_INVAL) {
if (zfs_prop_get(zhp, pl->pl_prop, property, if (zfs_prop_get(zhp, pl->pl_prop, property,
sizeof (property), NULL, NULL, 0, sizeof (property), NULL, NULL, 0,
cb->cb_literal) != 0) cb->cb_literal) != 0)
propstr = "-"; propstr = "-";
else else
propstr = property; propstr = property;

View File

@ -1,4 +1,4 @@
/*****************************************************************************\ /*
* ZPIOS is a heavily modified version of the original PIOS test code. * ZPIOS is a heavily modified version of the original PIOS test code.
* It is designed to have the test code running in the Linux kernel * It is designed to have the test code running in the Linux kernel
* against ZFS while still being flexibly controled from user space. * against ZFS while still being flexibly controled from user space.
@ -29,73 +29,74 @@
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with ZPIOS. If not, see <http://www.gnu.org/licenses/>. * with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
\*****************************************************************************/ */
#ifndef _ZPIOS_H #ifndef _ZPIOS_H
#define _ZPIOS_H #define _ZPIOS_H
#include <zpios-ctl.h> #include <zpios-ctl.h>
#define VERSION_SIZE 64 #define VERSION_SIZE 64
/* Regular expressions */ /* Regular expressions */
#define REGEX_NUMBERS "^[0-9]*[0-9]$" #define REGEX_NUMBERS "^[0-9]*[0-9]$"
#define REGEX_NUMBERS_COMMA "^([0-9]+,)*[0-9]+$" #define REGEX_NUMBERS_COMMA "^([0-9]+,)*[0-9]+$"
#define REGEX_SIZE "^[0-9][0-9]*[kmgt]$" #define REGEX_SIZE "^[0-9][0-9]*[kmgt]$"
#define REGEX_SIZE_COMMA "^([0-9][0-9]*[kmgt]+,)*[0-9][0-9]*[kmgt]$" #define REGEX_SIZE_COMMA "^([0-9][0-9]*[kmgt]+,)*[0-9][0-9]*[kmgt]$"
/* Flags for low, high, incr */ /* Flags for low, high, incr */
#define FLAG_SET 0x01 #define FLAG_SET 0x01
#define FLAG_LOW 0x02 #define FLAG_LOW 0x02
#define FLAG_HIGH 0x04 #define FLAG_HIGH 0x04
#define FLAG_INCR 0x08 #define FLAG_INCR 0x08
#define TRUE 1 #define TRUE 1
#define FALSE 0 #define FALSE 0
#define KB (1024) #define KB (1024)
#define MB (KB * 1024) #define MB (KB * 1024)
#define GB (MB * 1024) #define GB (MB * 1024)
#define TB (GB * 1024) #define TB (GB * 1024)
#define KMGT_SIZE 16 #define KMGT_SIZE 16
/* All offsets, sizes and counts can be passed to the application in /*
* All offsets, sizes and counts can be passed to the application in
* multiple ways. * multiple ways.
* 1. a value (stored in val[0], val_count will be 1) * 1. a value (stored in val[0], val_count will be 1)
* 2. a comma separated list of values (stored in val[], using val_count) * 2. a comma separated list of values (stored in val[], using val_count)
* 3. a range and block sizes, low, high, factor (val_count must be 0) * 3. a range and block sizes, low, high, factor (val_count must be 0)
*/ */
typedef struct pios_range_repeat { typedef struct pios_range_repeat {
uint64_t val[32]; /* Comma sep array, or low, high, inc */ uint64_t val[32]; /* Comma sep array, or low, high, inc */
uint64_t val_count; /* Num of values */ uint64_t val_count; /* Num of values */
uint64_t val_low; uint64_t val_low;
uint64_t val_high; uint64_t val_high;
uint64_t val_inc_perc; uint64_t val_inc_perc;
uint64_t next_val; /* Used for multiple runs in get_next() */ uint64_t next_val; /* For multiple runs in get_next() */
} range_repeat_t; } range_repeat_t;
typedef struct cmd_args { typedef struct cmd_args {
range_repeat_t T; /* Thread count */ range_repeat_t T; /* Thread count */
range_repeat_t N; /* Region count */ range_repeat_t N; /* Region count */
range_repeat_t O; /* Offset count */ range_repeat_t O; /* Offset count */
range_repeat_t C; /* Chunksize */ range_repeat_t C; /* Chunksize */
range_repeat_t S; /* Regionsize */ range_repeat_t S; /* Regionsize */
const char *pool; /* Pool */ const char *pool; /* Pool */
const char *name; /* Name */ const char *name; /* Name */
uint32_t flags; /* Flags */ uint32_t flags; /* Flags */
uint32_t io_type; /* DMUIO only */ uint32_t io_type; /* DMUIO only */
uint32_t verbose; /* Verbose */ uint32_t verbose; /* Verbose */
uint32_t human_readable; /* Human readable output */ uint32_t human_readable; /* Human readable output */
uint64_t regionnoise; /* Region noise */ uint64_t regionnoise; /* Region noise */
uint64_t chunknoise; /* Chunk noise */ uint64_t chunknoise; /* Chunk noise */
uint64_t thread_delay; /* Thread delay */ uint64_t thread_delay; /* Thread delay */
char pre[ZPIOS_PATH_SIZE]; /* Pre-exec hook */ char pre[ZPIOS_PATH_SIZE]; /* Pre-exec hook */
char post[ZPIOS_PATH_SIZE]; /* Post-exec hook */ char post[ZPIOS_PATH_SIZE]; /* Post-exec hook */
char log[ZPIOS_PATH_SIZE]; /* Requested log dir */ char log[ZPIOS_PATH_SIZE]; /* Requested log dir */
/* Control */ /* Control */
int current_id; int current_id;
@ -109,9 +110,9 @@ typedef struct cmd_args {
} cmd_args_t; } cmd_args_t;
int set_count(char *pattern1, char *pattern2, range_repeat_t *range, int set_count(char *pattern1, char *pattern2, range_repeat_t *range,
char *optarg, uint32_t *flags, char *arg); char *optarg, uint32_t *flags, char *arg);
int set_lhi(char *pattern, range_repeat_t *range, char *optarg, int set_lhi(char *pattern, range_repeat_t *range, char *optarg,
int flag, uint32_t *flag_thread, char *arg); int flag, uint32_t *flag_thread, char *arg);
int set_noise(uint64_t *noise, char *optarg, char *arg); int set_noise(uint64_t *noise, char *optarg, char *arg);
int set_load_params(cmd_args_t *args, char *optarg); int set_load_params(cmd_args_t *args, char *optarg);
int check_mutual_exclusive_command_lines(uint32_t flag, char *arg); int check_mutual_exclusive_command_lines(uint32_t flag, char *arg);

View File

@ -1,7 +1,7 @@
/*****************************************************************************\ /*
* ZPIOS is a heavily modified version of the original PIOS test code. * ZPIOS is a heavily modified version of the original PIOS test code.
* It is designed to have the test code running in the Linux kernel * It is designed to have the test code running in the Linux kernel
* against ZFS while still being flexibly controled from user space. * against ZFS while still being flexibly controlled from user space.
* *
* Copyright (C) 2008-2010 Lawrence Livermore National Security, LLC. * Copyright (C) 2008-2010 Lawrence Livermore National Security, LLC.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@ -29,7 +29,7 @@
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with ZPIOS. If not, see <http://www.gnu.org/licenses/>. * with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
\*****************************************************************************/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -42,47 +42,48 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "zpios.h" #include "zpios.h"
static const char short_opt[] = "t:l:h:e:n:i:j:k:o:m:q:r:c:a:b:g:s:A:B:C:" static const char short_opt[] =
"L:p:M:xP:R:G:I:N:T:VzOfHv?"; "t:l:h:e:n:i:j:k:o:m:q:r:c:a:b:g:s:A:B:C:"
"L:p:M:xP:R:G:I:N:T:VzOfHv?";
static const struct option long_opt[] = { static const struct option long_opt[] = {
{"threadcount", required_argument, 0, 't' }, {"threadcount", required_argument, 0, 't' },
{"threadcount_low", required_argument, 0, 'l' }, {"threadcount_low", required_argument, 0, 'l' },
{"threadcount_high", required_argument, 0, 'h' }, {"threadcount_high", required_argument, 0, 'h' },
{"threadcount_incr", required_argument, 0, 'e' }, {"threadcount_incr", required_argument, 0, 'e' },
{"regioncount", required_argument, 0, 'n' }, {"regioncount", required_argument, 0, 'n' },
{"regioncount_low", required_argument, 0, 'i' }, {"regioncount_low", required_argument, 0, 'i' },
{"regioncount_high", required_argument, 0, 'j' }, {"regioncount_high", required_argument, 0, 'j' },
{"regioncount_incr", required_argument, 0, 'k' }, {"regioncount_incr", required_argument, 0, 'k' },
{"offset", required_argument, 0, 'o' }, {"offset", required_argument, 0, 'o' },
{"offset_low", required_argument, 0, 'm' }, {"offset_low", required_argument, 0, 'm' },
{"offset_high", required_argument, 0, 'q' }, {"offset_high", required_argument, 0, 'q' },
{"offset_incr", required_argument, 0, 'r' }, {"offset_incr", required_argument, 0, 'r' },
{"chunksize", required_argument, 0, 'c' }, {"chunksize", required_argument, 0, 'c' },
{"chunksize_low", required_argument, 0, 'a' }, {"chunksize_low", required_argument, 0, 'a' },
{"chunksize_high", required_argument, 0, 'b' }, {"chunksize_high", required_argument, 0, 'b' },
{"chunksize_incr", required_argument, 0, 'g' }, {"chunksize_incr", required_argument, 0, 'g' },
{"regionsize", required_argument, 0, 's' }, {"regionsize", required_argument, 0, 's' },
{"regionsize_low", required_argument, 0, 'A' }, {"regionsize_low", required_argument, 0, 'A' },
{"regionsize_high", required_argument, 0, 'B' }, {"regionsize_high", required_argument, 0, 'B' },
{"regionsize_incr", required_argument, 0, 'C' }, {"regionsize_incr", required_argument, 0, 'C' },
{"load", required_argument, 0, 'L' }, {"load", required_argument, 0, 'L' },
{"pool", required_argument, 0, 'p' }, {"pool", required_argument, 0, 'p' },
{"name", required_argument, 0, 'M' }, {"name", required_argument, 0, 'M' },
{"cleanup", no_argument, 0, 'x' }, {"cleanup", no_argument, 0, 'x' },
{"prerun", required_argument, 0, 'P' }, {"prerun", required_argument, 0, 'P' },
{"postrun", required_argument, 0, 'R' }, {"postrun", required_argument, 0, 'R' },
{"log", required_argument, 0, 'G' }, {"log", required_argument, 0, 'G' },
{"regionnoise", required_argument, 0, 'I' }, {"regionnoise", required_argument, 0, 'I' },
{"chunknoise", required_argument, 0, 'N' }, {"chunknoise", required_argument, 0, 'N' },
{"threaddelay", required_argument, 0, 'T' }, {"threaddelay", required_argument, 0, 'T' },
{"verify", no_argument, 0, 'V' }, {"verify", no_argument, 0, 'V' },
{"zerocopy", no_argument, 0, 'z' }, {"zerocopy", no_argument, 0, 'z' },
{"nowait", no_argument, 0, 'O' }, {"nowait", no_argument, 0, 'O' },
{"noprefetch", no_argument, 0, 'f' }, {"noprefetch", no_argument, 0, 'f' },
{"human-readable", no_argument, 0, 'H' }, {"human-readable", no_argument, 0, 'H' },
{"verbose", no_argument, 0, 'v' }, {"verbose", no_argument, 0, 'v' },
{"help", no_argument, 0, '?' }, {"help", no_argument, 0, '?' },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 },
}; };
static int zpiosctl_fd; /* Control file descriptor */ static int zpiosctl_fd; /* Control file descriptor */
@ -95,45 +96,45 @@ usage(void)
{ {
fprintf(stderr, "Usage: zpios\n"); fprintf(stderr, "Usage: zpios\n");
fprintf(stderr, fprintf(stderr,
" --threadcount -t =values\n" " --threadcount -t =values\n"
" --threadcount_low -l =value\n" " --threadcount_low -l =value\n"
" --threadcount_high -h =value\n" " --threadcount_high -h =value\n"
" --threadcount_incr -e =value\n" " --threadcount_incr -e =value\n"
" --regioncount -n =values\n" " --regioncount -n =values\n"
" --regioncount_low -i =value\n" " --regioncount_low -i =value\n"
" --regioncount_high -j =value\n" " --regioncount_high -j =value\n"
" --regioncount_incr -k =value\n" " --regioncount_incr -k =value\n"
" --offset -o =values\n" " --offset -o =values\n"
" --offset_low -m =value\n" " --offset_low -m =value\n"
" --offset_high -q =value\n" " --offset_high -q =value\n"
" --offset_incr -r =value\n" " --offset_incr -r =value\n"
" --chunksize -c =values\n" " --chunksize -c =values\n"
" --chunksize_low -a =value\n" " --chunksize_low -a =value\n"
" --chunksize_high -b =value\n" " --chunksize_high -b =value\n"
" --chunksize_incr -g =value\n" " --chunksize_incr -g =value\n"
" --regionsize -s =values\n" " --regionsize -s =values\n"
" --regionsize_low -A =value\n" " --regionsize_low -A =value\n"
" --regionsize_high -B =value\n" " --regionsize_high -B =value\n"
" --regionsize_incr -C =value\n" " --regionsize_incr -C =value\n"
" --load -L =dmuio|ssf|fpp\n" " --load -L =dmuio|ssf|fpp\n"
" --pool -p =pool name\n" " --pool -p =pool name\n"
" --name -M =test name\n" " --name -M =test name\n"
" --cleanup -x\n" " --cleanup -x\n"
" --prerun -P =pre-command\n" " --prerun -P =pre-command\n"
" --postrun -R =post-command\n" " --postrun -R =post-command\n"
" --log -G =log directory\n" " --log -G =log directory\n"
" --regionnoise -I =shift\n" " --regionnoise -I =shift\n"
" --chunknoise -N =bytes\n" " --chunknoise -N =bytes\n"
" --threaddelay -T =jiffies\n" " --threaddelay -T =jiffies\n"
" --verify -V\n" " --verify -V\n"
" --zerocopy -z\n" " --zerocopy -z\n"
" --nowait -O\n" " --nowait -O\n"
" --noprefetch -f\n" " --noprefetch -f\n"
" --human-readable -H\n" " --human-readable -H\n"
" --verbose -v =increase verbosity\n" " --verbose -v =increase verbosity\n"
" --help -? =this help\n\n"); " --help -? =this help\n\n");
return 0; return (0);
} }
static void args_fini(cmd_args_t *args) static void args_fini(cmd_args_t *args)
@ -155,99 +156,99 @@ args_init(int argc, char **argv)
if (argc == 1) { if (argc == 1) {
usage(); usage();
return (cmd_args_t *)NULL; return ((cmd_args_t *)NULL);
} }
/* Configure and populate the args structures */ /* Configure and populate the args structures */
args = malloc(sizeof(*args)); args = malloc(sizeof (*args));
if (args == NULL) if (args == NULL)
return NULL; return (NULL);
memset(args, 0, sizeof(*args)); memset(args, 0, sizeof (*args));
while ((c=getopt_long(argc, argv, short_opt, long_opt, NULL)) != -1) { while ((c = getopt_long(argc, argv, short_opt, long_opt, NULL)) != -1) {
rc = 0; rc = 0;
switch (c) { switch (c) {
case 't': /* --thread count */ case 't': /* --thread count */
rc = set_count(REGEX_NUMBERS, REGEX_NUMBERS_COMMA, rc = set_count(REGEX_NUMBERS, REGEX_NUMBERS_COMMA,
&args->T, optarg, &fl_th, "threadcount"); &args->T, optarg, &fl_th, "threadcount");
break; break;
case 'l': /* --threadcount_low */ case 'l': /* --threadcount_low */
rc = set_lhi(REGEX_NUMBERS, &args->T, optarg, rc = set_lhi(REGEX_NUMBERS, &args->T, optarg,
FLAG_LOW, &fl_th, "threadcount_low"); FLAG_LOW, &fl_th, "threadcount_low");
break; break;
case 'h': /* --threadcount_high */ case 'h': /* --threadcount_high */
rc = set_lhi(REGEX_NUMBERS, &args->T, optarg, rc = set_lhi(REGEX_NUMBERS, &args->T, optarg,
FLAG_HIGH, &fl_th, "threadcount_high"); FLAG_HIGH, &fl_th, "threadcount_high");
break; break;
case 'e': /* --threadcount_inc */ case 'e': /* --threadcount_inc */
rc = set_lhi(REGEX_NUMBERS, &args->T, optarg, rc = set_lhi(REGEX_NUMBERS, &args->T, optarg,
FLAG_INCR, &fl_th, "threadcount_incr"); FLAG_INCR, &fl_th, "threadcount_incr");
break; break;
case 'n': /* --regioncount */ case 'n': /* --regioncount */
rc = set_count(REGEX_NUMBERS, REGEX_NUMBERS_COMMA, rc = set_count(REGEX_NUMBERS, REGEX_NUMBERS_COMMA,
&args->N, optarg, &fl_rc, "regioncount"); &args->N, optarg, &fl_rc, "regioncount");
break; break;
case 'i': /* --regioncount_low */ case 'i': /* --regioncount_low */
rc = set_lhi(REGEX_NUMBERS, &args->N, optarg, rc = set_lhi(REGEX_NUMBERS, &args->N, optarg,
FLAG_LOW, &fl_rc, "regioncount_low"); FLAG_LOW, &fl_rc, "regioncount_low");
break; break;
case 'j': /* --regioncount_high */ case 'j': /* --regioncount_high */
rc = set_lhi(REGEX_NUMBERS, &args->N, optarg, rc = set_lhi(REGEX_NUMBERS, &args->N, optarg,
FLAG_HIGH, &fl_rc, "regioncount_high"); FLAG_HIGH, &fl_rc, "regioncount_high");
break; break;
case 'k': /* --regioncount_inc */ case 'k': /* --regioncount_inc */
rc = set_lhi(REGEX_NUMBERS, &args->N, optarg, rc = set_lhi(REGEX_NUMBERS, &args->N, optarg,
FLAG_INCR, &fl_rc, "regioncount_incr"); FLAG_INCR, &fl_rc, "regioncount_incr");
break; break;
case 'o': /* --offset */ case 'o': /* --offset */
rc = set_count(REGEX_SIZE, REGEX_SIZE_COMMA, rc = set_count(REGEX_SIZE, REGEX_SIZE_COMMA,
&args->O, optarg, &fl_of, "offset"); &args->O, optarg, &fl_of, "offset");
break; break;
case 'm': /* --offset_low */ case 'm': /* --offset_low */
rc = set_lhi(REGEX_SIZE, &args->O, optarg, rc = set_lhi(REGEX_SIZE, &args->O, optarg,
FLAG_LOW, &fl_of, "offset_low"); FLAG_LOW, &fl_of, "offset_low");
break; break;
case 'q': /* --offset_high */ case 'q': /* --offset_high */
rc = set_lhi(REGEX_SIZE, &args->O, optarg, rc = set_lhi(REGEX_SIZE, &args->O, optarg,
FLAG_HIGH, &fl_of, "offset_high"); FLAG_HIGH, &fl_of, "offset_high");
break; break;
case 'r': /* --offset_inc */ case 'r': /* --offset_inc */
rc = set_lhi(REGEX_NUMBERS, &args->O, optarg, rc = set_lhi(REGEX_NUMBERS, &args->O, optarg,
FLAG_INCR, &fl_of, "offset_incr"); FLAG_INCR, &fl_of, "offset_incr");
break; break;
case 'c': /* --chunksize */ case 'c': /* --chunksize */
rc = set_count(REGEX_SIZE, REGEX_SIZE_COMMA, rc = set_count(REGEX_SIZE, REGEX_SIZE_COMMA,
&args->C, optarg, &fl_cs, "chunksize"); &args->C, optarg, &fl_cs, "chunksize");
break; break;
case 'a': /* --chunksize_low */ case 'a': /* --chunksize_low */
rc = set_lhi(REGEX_SIZE, &args->C, optarg, rc = set_lhi(REGEX_SIZE, &args->C, optarg,
FLAG_LOW, &fl_cs, "chunksize_low"); FLAG_LOW, &fl_cs, "chunksize_low");
break; break;
case 'b': /* --chunksize_high */ case 'b': /* --chunksize_high */
rc = set_lhi(REGEX_SIZE, &args->C, optarg, rc = set_lhi(REGEX_SIZE, &args->C, optarg,
FLAG_HIGH, &fl_cs, "chunksize_high"); FLAG_HIGH, &fl_cs, "chunksize_high");
break; break;
case 'g': /* --chunksize_inc */ case 'g': /* --chunksize_inc */
rc = set_lhi(REGEX_NUMBERS, &args->C, optarg, rc = set_lhi(REGEX_NUMBERS, &args->C, optarg,
FLAG_INCR, &fl_cs, "chunksize_incr"); FLAG_INCR, &fl_cs, "chunksize_incr");
break; break;
case 's': /* --regionsize */ case 's': /* --regionsize */
rc = set_count(REGEX_SIZE, REGEX_SIZE_COMMA, rc = set_count(REGEX_SIZE, REGEX_SIZE_COMMA,
&args->S, optarg, &fl_rs, "regionsize"); &args->S, optarg, &fl_rs, "regionsize");
break; break;
case 'A': /* --regionsize_low */ case 'A': /* --regionsize_low */
rc = set_lhi(REGEX_SIZE, &args->S, optarg, rc = set_lhi(REGEX_SIZE, &args->S, optarg,
FLAG_LOW, &fl_rs, "regionsize_low"); FLAG_LOW, &fl_rs, "regionsize_low");
break; break;
case 'B': /* --regionsize_high */ case 'B': /* --regionsize_high */
rc = set_lhi(REGEX_SIZE, &args->S, optarg, rc = set_lhi(REGEX_SIZE, &args->S, optarg,
FLAG_HIGH, &fl_rs, "regionsize_high"); FLAG_HIGH, &fl_rs, "regionsize_high");
break; break;
case 'C': /* --regionsize_inc */ case 'C': /* --regionsize_inc */
rc = set_lhi(REGEX_NUMBERS, &args->S, optarg, rc = set_lhi(REGEX_NUMBERS, &args->S, optarg,
FLAG_INCR, &fl_rs, "regionsize_incr"); FLAG_INCR, &fl_rs, "regionsize_incr");
break; break;
case 'L': /* --load */ case 'L': /* --load */
rc = set_load_params(args, optarg); rc = set_load_params(args, optarg);
@ -271,13 +272,15 @@ args_init(int argc, char **argv)
strncpy(args->log, optarg, ZPIOS_PATH_SIZE - 1); strncpy(args->log, optarg, ZPIOS_PATH_SIZE - 1);
break; break;
case 'I': /* --regionnoise */ case 'I': /* --regionnoise */
rc = set_noise(&args->regionnoise, optarg, "regionnoise"); rc = set_noise(&args->regionnoise, optarg,
"regionnoise");
break; break;
case 'N': /* --chunknoise */ case 'N': /* --chunknoise */
rc = set_noise(&args->chunknoise, optarg, "chunknoise"); rc = set_noise(&args->chunknoise, optarg, "chunknoise");
break; break;
case 'T': /* --threaddelay */ case 'T': /* --threaddelay */
rc = set_noise(&args->thread_delay, optarg, "threaddelay"); rc = set_noise(&args->thread_delay, optarg,
"threaddelay");
break; break;
case 'V': /* --verify */ case 'V': /* --verify */
args->flags |= DMU_VERIFY; args->flags |= DMU_VERIFY;
@ -301,7 +304,8 @@ args_init(int argc, char **argv)
rc = 1; rc = 1;
break; break;
default: default:
fprintf(stderr,"Unknown option '%s'\n",argv[optind-1]); fprintf(stderr, "Unknown option '%s'\n",
argv[optind - 1]);
rc = EINVAL; rc = EINVAL;
break; break;
} }
@ -309,7 +313,7 @@ args_init(int argc, char **argv)
if (rc) { if (rc) {
usage(); usage();
args_fini(args); args_fini(args);
return NULL; return (NULL);
} }
} }
@ -323,19 +327,19 @@ args_init(int argc, char **argv)
fprintf(stderr, "Error: Pool not specificed\n"); fprintf(stderr, "Error: Pool not specificed\n");
usage(); usage();
args_fini(args); args_fini(args);
return NULL; return (NULL);
} }
if ((args->flags & (DMU_WRITE_ZC | DMU_READ_ZC)) && if ((args->flags & (DMU_WRITE_ZC | DMU_READ_ZC)) &&
(args->flags & DMU_VERIFY)) { (args->flags & DMU_VERIFY)) {
fprintf(stderr, "Error, --zerocopy incompatible --verify, " fprintf(stderr, "Error, --zerocopy incompatible --verify, "
"used for performance analysis only\n"); "used for performance analysis only\n");
usage(); usage();
args_fini(args); args_fini(args);
return NULL; return (NULL);
} }
return args; return (args);
} }
static int static int
@ -344,19 +348,19 @@ dev_clear(void)
zpios_cfg_t cfg; zpios_cfg_t cfg;
int rc; int rc;
memset(&cfg, 0, sizeof(cfg)); memset(&cfg, 0, sizeof (cfg));
cfg.cfg_magic = ZPIOS_CFG_MAGIC; cfg.cfg_magic = ZPIOS_CFG_MAGIC;
cfg.cfg_cmd = ZPIOS_CFG_BUFFER_CLEAR; cfg.cfg_cmd = ZPIOS_CFG_BUFFER_CLEAR;
cfg.cfg_arg1 = 0; cfg.cfg_arg1 = 0;
rc = ioctl(zpiosctl_fd, ZPIOS_CFG, &cfg); rc = ioctl(zpiosctl_fd, ZPIOS_CFG, &cfg);
if (rc) if (rc)
fprintf(stderr, "Ioctl() error %lu / %d: %d\n", fprintf(stderr, "Ioctl() error %lu / %d: %d\n",
(unsigned long) ZPIOS_CFG, cfg.cfg_cmd, errno); (unsigned long) ZPIOS_CFG, cfg.cfg_cmd, errno);
lseek(zpiosctl_fd, 0, SEEK_SET); lseek(zpiosctl_fd, 0, SEEK_SET);
return rc; return (rc);
} }
/* Passing a size of zero simply results in querying the current size */ /* Passing a size of zero simply results in querying the current size */
@ -366,19 +370,19 @@ dev_size(int size)
zpios_cfg_t cfg; zpios_cfg_t cfg;
int rc; int rc;
memset(&cfg, 0, sizeof(cfg)); memset(&cfg, 0, sizeof (cfg));
cfg.cfg_magic = ZPIOS_CFG_MAGIC; cfg.cfg_magic = ZPIOS_CFG_MAGIC;
cfg.cfg_cmd = ZPIOS_CFG_BUFFER_SIZE; cfg.cfg_cmd = ZPIOS_CFG_BUFFER_SIZE;
cfg.cfg_arg1 = size; cfg.cfg_arg1 = size;
rc = ioctl(zpiosctl_fd, ZPIOS_CFG, &cfg); rc = ioctl(zpiosctl_fd, ZPIOS_CFG, &cfg);
if (rc) { if (rc) {
fprintf(stderr, "Ioctl() error %lu / %d: %d\n", fprintf(stderr, "Ioctl() error %lu / %d: %d\n",
(unsigned long) ZPIOS_CFG, cfg.cfg_cmd, errno); (unsigned long) ZPIOS_CFG, cfg.cfg_cmd, errno);
return rc; return (rc);
} }
return cfg.cfg_rc1; return (cfg.cfg_rc1);
} }
static void static void
@ -390,7 +394,7 @@ dev_fini(void)
if (zpiosctl_fd != -1) { if (zpiosctl_fd != -1) {
if (close(zpiosctl_fd) == -1) { if (close(zpiosctl_fd) == -1) {
fprintf(stderr, "Unable to close %s: %d\n", fprintf(stderr, "Unable to close %s: %d\n",
ZPIOS_DEV, errno); ZPIOS_DEV, errno);
} }
} }
} }
@ -403,7 +407,7 @@ dev_init(void)
zpiosctl_fd = open(ZPIOS_DEV, O_RDONLY); zpiosctl_fd = open(ZPIOS_DEV, O_RDONLY);
if (zpiosctl_fd == -1) { if (zpiosctl_fd == -1) {
fprintf(stderr, "Unable to open %s: %d\n" fprintf(stderr, "Unable to open %s: %d\n"
"Is the zpios module loaded?\n", ZPIOS_DEV, errno); "Is the zpios module loaded?\n", ZPIOS_DEV, errno);
rc = errno; rc = errno;
goto error; goto error;
} }
@ -422,16 +426,16 @@ dev_init(void)
} }
memset(zpios_buffer, 0, zpios_buffer_size); memset(zpios_buffer, 0, zpios_buffer_size);
return 0; return (0);
error: error:
if (zpiosctl_fd != -1) { if (zpiosctl_fd != -1) {
if (close(zpiosctl_fd) == -1) { if (close(zpiosctl_fd) == -1) {
fprintf(stderr, "Unable to close %s: %d\n", fprintf(stderr, "Unable to close %s: %d\n",
ZPIOS_DEV, errno); ZPIOS_DEV, errno);
} }
} }
return rc; return (rc);
} }
static int static int
@ -440,91 +444,93 @@ get_next(uint64_t *val, range_repeat_t *range)
/* if low, incr, high is given */ /* if low, incr, high is given */
if (range->val_count == 0) { if (range->val_count == 0) {
*val = (range->val_low) + *val = (range->val_low) +
(range->val_low * range->next_val / 100); (range->val_low * range->next_val / 100);
if (*val > range->val_high) if (*val > range->val_high)
return 0; /* No more values, limit exceeded */ return (0); /* No more values, limit exceeded */
if (!range->next_val) if (!range->next_val)
range->next_val = range->val_inc_perc; range->next_val = range->val_inc_perc;
else else
range->next_val = range->next_val+range->val_inc_perc; range->next_val = range->next_val + range->val_inc_perc;
return 1; /* more values to come */ return (1); /* more values to come */
/* if only one val is given */ /* if only one val is given */
} else if (range->val_count == 1) { } else if (range->val_count == 1) {
if (range->next_val) if (range->next_val)
return 0; /* No more values, we only have one */ return (0); /* No more values, we only have one */
*val = range->val[0]; *val = range->val[0];
range->next_val = 1; range->next_val = 1;
return 1; /* more values to come */ return (1); /* more values to come */
/* if comma separated values are given */ /* if comma separated values are given */
} else if (range->val_count > 1) { } else if (range->val_count > 1) {
if (range->next_val > range->val_count - 1) if (range->next_val > range->val_count - 1)
return 0; /* No more values, limit exceeded */ return (0); /* No more values, limit exceeded */
*val = range->val[range->next_val]; *val = range->val[range->next_val];
range->next_val++; range->next_val++;
return 1; /* more values to come */ return (1); /* more values to come */
} }
return 0; return (0);
} }
static int static int
run_one(cmd_args_t *args, uint32_t id, uint32_t T, uint32_t N, run_one(cmd_args_t *args, uint32_t id, uint32_t T, uint32_t N,
uint64_t C, uint64_t S, uint64_t O) uint64_t C, uint64_t S, uint64_t O)
{ {
zpios_cmd_t *cmd; zpios_cmd_t *cmd;
int rc, rc2, cmd_size; int rc, rc2, cmd_size;
dev_clear(); dev_clear();
cmd_size = sizeof(zpios_cmd_t) + ((T + N + 1) * sizeof(zpios_stats_t)); cmd_size =
cmd = (zpios_cmd_t *)malloc(cmd_size); sizeof (zpios_cmd_t)
if (cmd == NULL) + ((T + N + 1) * sizeof (zpios_stats_t));
return ENOMEM; cmd = (zpios_cmd_t *)malloc(cmd_size);
if (cmd == NULL)
return (ENOMEM);
memset(cmd, 0, cmd_size); memset(cmd, 0, cmd_size);
cmd->cmd_magic = ZPIOS_CMD_MAGIC; cmd->cmd_magic = ZPIOS_CMD_MAGIC;
strncpy(cmd->cmd_pool, args->pool, ZPIOS_NAME_SIZE - 1); strncpy(cmd->cmd_pool, args->pool, ZPIOS_NAME_SIZE - 1);
strncpy(cmd->cmd_pre, args->pre, ZPIOS_PATH_SIZE - 1); strncpy(cmd->cmd_pre, args->pre, ZPIOS_PATH_SIZE - 1);
strncpy(cmd->cmd_post, args->post, ZPIOS_PATH_SIZE - 1); strncpy(cmd->cmd_post, args->post, ZPIOS_PATH_SIZE - 1);
strncpy(cmd->cmd_log, args->log, ZPIOS_PATH_SIZE - 1); strncpy(cmd->cmd_log, args->log, ZPIOS_PATH_SIZE - 1);
cmd->cmd_id = id; cmd->cmd_id = id;
cmd->cmd_chunk_size = C; cmd->cmd_chunk_size = C;
cmd->cmd_thread_count = T; cmd->cmd_thread_count = T;
cmd->cmd_region_count = N; cmd->cmd_region_count = N;
cmd->cmd_region_size = S; cmd->cmd_region_size = S;
cmd->cmd_offset = O; cmd->cmd_offset = O;
cmd->cmd_region_noise = args->regionnoise; cmd->cmd_region_noise = args->regionnoise;
cmd->cmd_chunk_noise = args->chunknoise; cmd->cmd_chunk_noise = args->chunknoise;
cmd->cmd_thread_delay = args->thread_delay; cmd->cmd_thread_delay = args->thread_delay;
cmd->cmd_flags = args->flags; cmd->cmd_flags = args->flags;
cmd->cmd_data_size = (T + N + 1) * sizeof(zpios_stats_t); cmd->cmd_data_size = (T + N + 1) * sizeof (zpios_stats_t);
rc = ioctl(zpiosctl_fd, ZPIOS_CMD, cmd); rc = ioctl(zpiosctl_fd, ZPIOS_CMD, cmd);
if (rc) if (rc)
args->rc = errno; args->rc = errno;
print_stats(args, cmd); print_stats(args, cmd);
if (args->verbose) { if (args->verbose) {
rc2 = read(zpiosctl_fd, zpios_buffer, zpios_buffer_size - 1); rc2 = read(zpiosctl_fd, zpios_buffer, zpios_buffer_size - 1);
if (rc2 < 0) { if (rc2 < 0) {
fprintf(stdout, "Error reading results: %d\n", rc2); fprintf(stdout, "Error reading results: %d\n", rc2);
} else if ((rc2 > 0) && (strlen(zpios_buffer) > 0)) { } else if ((rc2 > 0) && (strlen(zpios_buffer) > 0)) {
fprintf(stdout, "\n%s\n", zpios_buffer); fprintf(stdout, "\n%s\n", zpios_buffer);
fflush(stdout); fflush(stdout);
} }
} }
free(cmd); free(cmd);
return rc; return (rc);
} }
static int static int
@ -534,13 +540,13 @@ run_offsets(cmd_args_t *args)
while (rc == 0 && get_next(&args->current_O, &args->O)) { while (rc == 0 && get_next(&args->current_O, &args->O)) {
rc = run_one(args, args->current_id, rc = run_one(args, args->current_id,
args->current_T, args->current_N, args->current_C, args->current_T, args->current_N, args->current_C,
args->current_S, args->current_O); args->current_S, args->current_O);
args->current_id++; args->current_id++;
} }
args->O.next_val = 0; args->O.next_val = 0;
return rc; return (rc);
} }
static int static int
@ -549,10 +555,10 @@ run_region_counts(cmd_args_t *args)
int rc = 0; int rc = 0;
while (rc == 0 && get_next((uint64_t *)&args->current_N, &args->N)) while (rc == 0 && get_next((uint64_t *)&args->current_N, &args->N))
rc = run_offsets(args); rc = run_offsets(args);
args->N.next_val = 0; args->N.next_val = 0;
return rc; return (rc);
} }
static int static int
@ -564,14 +570,14 @@ run_region_sizes(cmd_args_t *args)
if (args->current_S < args->current_C) { if (args->current_S < args->current_C) {
fprintf(stderr, "Error: in any run chunksize can " fprintf(stderr, "Error: in any run chunksize can "
"not be smaller than regionsize.\n"); "not be smaller than regionsize.\n");
return EINVAL; return (EINVAL);
} }
rc = run_region_counts(args); rc = run_region_counts(args);
} }
args->S.next_val = 0; args->S.next_val = 0;
return rc; return (rc);
} }
static int static int
@ -580,11 +586,11 @@ run_chunk_sizes(cmd_args_t *args)
int rc = 0; int rc = 0;
while (rc == 0 && get_next(&args->current_C, &args->C)) { while (rc == 0 && get_next(&args->current_C, &args->C)) {
rc = run_region_sizes(args); rc = run_region_sizes(args);
} }
args->C.next_val = 0; args->C.next_val = 0;
return rc; return (rc);
} }
static int static int
@ -595,7 +601,7 @@ run_thread_counts(cmd_args_t *args)
while (rc == 0 && get_next((uint64_t *)&args->current_T, &args->T)) while (rc == 0 && get_next((uint64_t *)&args->current_T, &args->T))
rc = run_chunk_sizes(args); rc = run_chunk_sizes(args);
return rc; return (rc);
} }
int int
@ -625,5 +631,5 @@ out:
args_fini(args); args_fini(args);
dev_fini(); dev_fini();
return rc; return (rc);
} }

View File

@ -1,4 +1,4 @@
/*****************************************************************************\ /*
* ZPIOS is a heavily modified version of the original PIOS test code. * ZPIOS is a heavily modified version of the original PIOS test code.
* It is designed to have the test code running in the Linux kernel * It is designed to have the test code running in the Linux kernel
* against ZFS while still being flexibly controled from user space. * against ZFS while still being flexibly controled from user space.
@ -29,7 +29,7 @@
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with ZPIOS. If not, see <http://www.gnu.org/licenses/>. * with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
\*****************************************************************************/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -49,7 +49,7 @@ kmgt_to_uint64(const char *str, uint64_t *val)
*val = strtoll(str, &endptr, 0); *val = strtoll(str, &endptr, 0);
if ((str == endptr) && (*val == 0)) if ((str == endptr) && (*val == 0))
return EINVAL; return (EINVAL);
switch (endptr[0]) { switch (endptr[0]) {
case 'k': case 'K': case 'k': case 'K':
@ -70,7 +70,7 @@ kmgt_to_uint64(const char *str, uint64_t *val)
rc = EINVAL; rc = EINVAL;
} }
return rc; return (rc);
} }
static char * static char *
@ -85,12 +85,12 @@ uint64_to_kmgt(char *str, uint64_t val)
} }
if (i >= 4) if (i >= 4)
(void)snprintf(str, KMGT_SIZE-1, "inf"); (void) snprintf(str, KMGT_SIZE-1, "inf");
else else
(void)snprintf(str, KMGT_SIZE-1, "%lu%c", (unsigned long)val, (void) snprintf(str, KMGT_SIZE-1, "%lu%c", (unsigned long)val,
(i == -1) ? '\0' : postfix[i]); (i == -1) ? '\0' : postfix[i]);
return str; return (str);
} }
static char * static char *
@ -106,12 +106,12 @@ kmgt_per_sec(char *str, uint64_t v, double t)
} }
if (i >= 4) if (i >= 4)
(void)snprintf(str, KMGT_SIZE-1, "inf"); (void) snprintf(str, KMGT_SIZE-1, "inf");
else else
(void)snprintf(str, KMGT_SIZE-1, "%.2f%c", val, (void) snprintf(str, KMGT_SIZE-1, "%.2f%c", val,
(i == -1) ? '\0' : postfix[i]); (i == -1) ? '\0' : postfix[i]);
return str; return (str);
} }
static char * static char *
@ -126,7 +126,7 @@ print_flags(char *str, uint32_t flags)
str[6] = (flags & DMU_WRITE_NOWAIT) ? 'O' : '-'; str[6] = (flags & DMU_WRITE_NOWAIT) ? 'O' : '-';
str[7] = '\0'; str[7] = '\0';
return str; return (str);
} }
static int static int
@ -138,13 +138,13 @@ regex_match(const char *string, char *pattern)
rc = regcomp(&re, pattern, REG_EXTENDED | REG_NOSUB | REG_ICASE); rc = regcomp(&re, pattern, REG_EXTENDED | REG_NOSUB | REG_ICASE);
if (rc) { if (rc) {
fprintf(stderr, "Error: Couldn't do regcomp, %d\n", rc); fprintf(stderr, "Error: Couldn't do regcomp, %d\n", rc);
return rc; return (rc);
} }
rc = regexec(&re, string, (size_t) 0, NULL, 0); rc = regexec(&re, string, (size_t) 0, NULL, 0);
regfree(&re); regfree(&re);
return rc; return (rc);
} }
/* fills the pios_range_repeat structure of comma separated values */ /* fills the pios_range_repeat structure of comma separated values */
@ -156,14 +156,15 @@ split_string(const char *optarg, char *pattern, range_repeat_t *range)
int rc, i = 0; int rc, i = 0;
if ((rc = regex_match(optarg, pattern))) if ((rc = regex_match(optarg, pattern)))
return rc; return (rc);
cp = strdup(optarg); cp = strdup(optarg);
if (cp == NULL) if (cp == NULL)
return ENOMEM; return (ENOMEM);
do { do {
/* STRTOK(3) Each subsequent call, with a null pointer as the /*
* STRTOK(3) Each subsequent call, with a null pointer as the
* value of the * first argument, starts searching from the * value of the * first argument, starts searching from the
* saved pointer and behaves as described above. * saved pointer and behaves as described above.
*/ */
@ -177,12 +178,12 @@ split_string(const char *optarg, char *pattern, range_repeat_t *range)
kmgt_to_uint64(token[i], &range->val[i]); kmgt_to_uint64(token[i], &range->val[i]);
free(cp); free(cp);
return 0; return (0);
} }
int int
set_count(char *pattern1, char *pattern2, range_repeat_t *range, set_count(char *pattern1, char *pattern2, range_repeat_t *range,
char *optarg, uint32_t *flags, char *arg) char *optarg, uint32_t *flags, char *arg)
{ {
if (flags) if (flags)
*flags |= FLAG_SET; *flags |= FLAG_SET;
@ -194,25 +195,27 @@ set_count(char *pattern1, char *pattern2, range_repeat_t *range,
range->val_count = 1; range->val_count = 1;
} else if (split_string(optarg, pattern2, range) < 0) { } else if (split_string(optarg, pattern2, range) < 0) {
fprintf(stderr, "Error: Incorrect pattern for %s, '%s'\n", fprintf(stderr, "Error: Incorrect pattern for %s, '%s'\n",
arg, optarg); arg, optarg);
return EINVAL; return (EINVAL);
} }
return 0; return (0);
} }
/* validates the value with regular expression and sets low, high, incr /*
* according to value at which flag will be set. Sets the flag after. */ * Validates the value with regular expression and sets low, high, incr
* according to value at which flag will be set. Sets the flag after.
*/
int int
set_lhi(char *pattern, range_repeat_t *range, char *optarg, set_lhi(char *pattern, range_repeat_t *range, char *optarg,
int flag, uint32_t *flag_thread, char *arg) int flag, uint32_t *flag_thread, char *arg)
{ {
int rc; int rc;
if ((rc = regex_match(optarg, pattern))) { if ((rc = regex_match(optarg, pattern))) {
fprintf(stderr, "Error: Wrong pattern in %s, '%s'\n", fprintf(stderr, "Error: Wrong pattern in %s, '%s'\n",
arg, optarg); arg, optarg);
return rc; return (rc);
} }
switch (flag) { switch (flag) {
@ -231,7 +234,7 @@ set_lhi(char *pattern, range_repeat_t *range, char *optarg,
*flag_thread |= flag; *flag_thread |= flag;
return 0; return (0);
} }
int int
@ -241,10 +244,10 @@ set_noise(uint64_t *noise, char *optarg, char *arg)
kmgt_to_uint64(optarg, noise); kmgt_to_uint64(optarg, noise);
} else { } else {
fprintf(stderr, "Error: Incorrect pattern for %s\n", arg); fprintf(stderr, "Error: Incorrect pattern for %s\n", arg);
return EINVAL; return (EINVAL);
} }
return 0; return (0);
} }
int int
@ -255,7 +258,7 @@ set_load_params(cmd_args_t *args, char *optarg)
search = strdup(optarg); search = strdup(optarg);
if (search == NULL) if (search == NULL)
return ENOMEM; return (ENOMEM);
while ((param = strtok(search, comma)) != NULL) { while ((param = strtok(search, comma)) != NULL) {
search = NULL; search = NULL;
@ -275,52 +278,58 @@ set_load_params(cmd_args_t *args, char *optarg)
free(search); free(search);
return rc; return (rc);
} }
/* checks the low, high, increment values against the single value for /*
* Checks the low, high, increment values against the single value for
* mutual exclusion, for e.g threadcount is mutually exclusive to * mutual exclusion, for e.g threadcount is mutually exclusive to
* threadcount_low, ..._high, ..._incr */ * threadcount_low, ..._high, ..._incr
*/
int int
check_mutual_exclusive_command_lines(uint32_t flag, char *arg) check_mutual_exclusive_command_lines(uint32_t flag, char *arg)
{ {
if ((flag & FLAG_SET) && (flag & (FLAG_LOW | FLAG_HIGH | FLAG_INCR))) { if ((flag & FLAG_SET) && (flag & (FLAG_LOW | FLAG_HIGH | FLAG_INCR))) {
fprintf(stderr, "Error: --%s can not be given with --%s_low, " fprintf(stderr, "Error: --%s can not be given with --%s_low, "
"--%s_high or --%s_incr.\n", arg, arg, arg, arg); "--%s_high or --%s_incr.\n", arg, arg, arg, arg);
return 0; return (0);
} }
if ((flag & (FLAG_LOW | FLAG_HIGH | FLAG_INCR)) && !(flag & FLAG_SET)){ if ((flag & (FLAG_LOW | FLAG_HIGH | FLAG_INCR)) && !(flag & FLAG_SET)) {
if (flag != (FLAG_LOW | FLAG_HIGH | FLAG_INCR)) { if (flag != (FLAG_LOW | FLAG_HIGH | FLAG_INCR)) {
fprintf(stderr, "Error: One or more values missing " fprintf(stderr, "Error: One or more values missing "
"from --%s_low, --%s_high, --%s_incr.\n", "from --%s_low, --%s_high, --%s_incr.\n",
arg, arg, arg); arg, arg, arg);
return 0; return (0);
} }
} }
return 1; return (1);
} }
void void
print_stats_header(cmd_args_t *args) print_stats_header(cmd_args_t *args)
{ {
if (args->verbose) { if (args->verbose) {
printf("status name id\tth-cnt\trg-cnt\trg-sz\t" printf(
"ch-sz\toffset\trg-no\tch-no\tth-dly\tflags\ttime\t" "status name id\tth-cnt\trg-cnt\trg-sz\t"
"cr-time\trm-time\twr-time\trd-time\twr-data\twr-ch\t" "ch-sz\toffset\trg-no\tch-no\tth-dly\tflags\ttime\t"
"wr-bw\trd-data\trd-ch\trd-bw\n"); "cr-time\trm-time\twr-time\trd-time\twr-data\twr-ch\t"
printf("------------------------------------------------" "wr-bw\trd-data\trd-ch\trd-bw\n");
"------------------------------------------------" printf(
"------------------------------------------------" "------------------------------------------------"
"----------------------------------------------\n"); "------------------------------------------------"
"------------------------------------------------"
"----------------------------------------------\n");
} else { } else {
printf("status name id\t" printf(
"wr-data\twr-ch\twr-bw\t" "status name id\t"
"rd-data\trd-ch\trd-bw\n"); "wr-data\twr-ch\twr-bw\t"
printf("-----------------------------------------" "rd-data\trd-ch\trd-bw\n");
"--------------------------------------\n"); printf(
"-----------------------------------------"
"--------------------------------------\n");
} }
} }
@ -337,17 +346,17 @@ print_stats_human_readable(cmd_args_t *args, zpios_cmd_t *cmd)
printf("PASS: "); printf("PASS: ");
printf("%-12s", args->name ? args->name : ZPIOS_NAME); printf("%-12s", args->name ? args->name : ZPIOS_NAME);
printf("%2u\t", cmd->cmd_id); printf("%2u\t", cmd->cmd_id);
if (args->verbose) { if (args->verbose) {
printf("%u\t", cmd->cmd_thread_count); printf("%u\t", cmd->cmd_thread_count);
printf("%u\t", cmd->cmd_region_count); printf("%u\t", cmd->cmd_region_count);
printf("%s\t", uint64_to_kmgt(str, cmd->cmd_region_size)); printf("%s\t", uint64_to_kmgt(str, cmd->cmd_region_size));
printf("%s\t", uint64_to_kmgt(str, cmd->cmd_chunk_size)); printf("%s\t", uint64_to_kmgt(str, cmd->cmd_chunk_size));
printf("%s\t", uint64_to_kmgt(str, cmd->cmd_offset)); printf("%s\t", uint64_to_kmgt(str, cmd->cmd_offset));
printf("%s\t", uint64_to_kmgt(str, cmd->cmd_region_noise)); printf("%s\t", uint64_to_kmgt(str, cmd->cmd_region_noise));
printf("%s\t", uint64_to_kmgt(str, cmd->cmd_chunk_noise)); printf("%s\t", uint64_to_kmgt(str, cmd->cmd_chunk_noise));
printf("%s\t", uint64_to_kmgt(str, cmd->cmd_thread_delay)); printf("%s\t", uint64_to_kmgt(str, cmd->cmd_thread_delay));
printf("%s\t", print_flags(str, cmd->cmd_flags)); printf("%s\t", print_flags(str, cmd->cmd_flags));
} }
@ -371,12 +380,12 @@ print_stats_human_readable(cmd_args_t *args, zpios_cmd_t *cmd)
printf("%.2f\t", rd_time); printf("%.2f\t", rd_time);
} }
printf("%s\t", uint64_to_kmgt(str, summary_stats->wr_data)); printf("%s\t", uint64_to_kmgt(str, summary_stats->wr_data));
printf("%s\t", uint64_to_kmgt(str, summary_stats->wr_chunks)); printf("%s\t", uint64_to_kmgt(str, summary_stats->wr_chunks));
printf("%s\t", kmgt_per_sec(str, summary_stats->wr_data, wr_time)); printf("%s\t", kmgt_per_sec(str, summary_stats->wr_data, wr_time));
printf("%s\t", uint64_to_kmgt(str, summary_stats->rd_data)); printf("%s\t", uint64_to_kmgt(str, summary_stats->rd_data));
printf("%s\t", uint64_to_kmgt(str, summary_stats->rd_chunks)); printf("%s\t", uint64_to_kmgt(str, summary_stats->rd_chunks));
printf("%s\n", kmgt_per_sec(str, summary_stats->rd_data, rd_time)); printf("%s\n", kmgt_per_sec(str, summary_stats->rd_data, rd_time));
fflush(stdout); fflush(stdout);
} }
@ -393,17 +402,17 @@ print_stats_table(cmd_args_t *args, zpios_cmd_t *cmd)
printf("PASS: "); printf("PASS: ");
printf("%-12s", args->name ? args->name : ZPIOS_NAME); printf("%-12s", args->name ? args->name : ZPIOS_NAME);
printf("%2u\t", cmd->cmd_id); printf("%2u\t", cmd->cmd_id);
if (args->verbose) { if (args->verbose) {
printf("%u\t", cmd->cmd_thread_count); printf("%u\t", cmd->cmd_thread_count);
printf("%u\t", cmd->cmd_region_count); printf("%u\t", cmd->cmd_region_count);
printf("%llu\t", (long long unsigned)cmd->cmd_region_size); printf("%llu\t", (long long unsigned)cmd->cmd_region_size);
printf("%llu\t", (long long unsigned)cmd->cmd_chunk_size); printf("%llu\t", (long long unsigned)cmd->cmd_chunk_size);
printf("%llu\t", (long long unsigned)cmd->cmd_offset); printf("%llu\t", (long long unsigned)cmd->cmd_offset);
printf("%u\t", cmd->cmd_region_noise); printf("%u\t", cmd->cmd_region_noise);
printf("%u\t", cmd->cmd_chunk_noise); printf("%u\t", cmd->cmd_chunk_noise);
printf("%u\t", cmd->cmd_thread_delay); printf("%u\t", cmd->cmd_thread_delay);
printf("0x%x\t", cmd->cmd_flags); printf("0x%x\t", cmd->cmd_flags);
} }
@ -418,28 +427,28 @@ print_stats_table(cmd_args_t *args, zpios_cmd_t *cmd)
if (args->verbose) { if (args->verbose) {
printf("%ld.%02ld\t", printf("%ld.%02ld\t",
(long)summary_stats->total_time.delta.ts_sec, (long)summary_stats->total_time.delta.ts_sec,
(long)summary_stats->total_time.delta.ts_nsec); (long)summary_stats->total_time.delta.ts_nsec);
printf("%ld.%02ld\t", printf("%ld.%02ld\t",
(long)summary_stats->cr_time.delta.ts_sec, (long)summary_stats->cr_time.delta.ts_sec,
(long)summary_stats->cr_time.delta.ts_nsec); (long)summary_stats->cr_time.delta.ts_nsec);
printf("%ld.%02ld\t", printf("%ld.%02ld\t",
(long)summary_stats->rm_time.delta.ts_sec, (long)summary_stats->rm_time.delta.ts_sec,
(long)summary_stats->rm_time.delta.ts_nsec); (long)summary_stats->rm_time.delta.ts_nsec);
printf("%ld.%02ld\t", printf("%ld.%02ld\t",
(long)summary_stats->wr_time.delta.ts_sec, (long)summary_stats->wr_time.delta.ts_sec,
(long)summary_stats->wr_time.delta.ts_nsec); (long)summary_stats->wr_time.delta.ts_nsec);
printf("%ld.%02ld\t", printf("%ld.%02ld\t",
(long)summary_stats->rd_time.delta.ts_sec, (long)summary_stats->rd_time.delta.ts_sec,
(long)summary_stats->rd_time.delta.ts_nsec); (long)summary_stats->rd_time.delta.ts_nsec);
} }
printf("%lld\t", (long long unsigned)summary_stats->wr_data); printf("%lld\t", (long long unsigned)summary_stats->wr_data);
printf("%lld\t", (long long unsigned)summary_stats->wr_chunks); printf("%lld\t", (long long unsigned)summary_stats->wr_chunks);
printf("%.4f\t", (double)summary_stats->wr_data / wr_time); printf("%.4f\t", (double)summary_stats->wr_data / wr_time);
printf("%lld\t", (long long unsigned)summary_stats->rd_data); printf("%lld\t", (long long unsigned)summary_stats->rd_data);
printf("%lld\t", (long long unsigned)summary_stats->rd_chunks); printf("%lld\t", (long long unsigned)summary_stats->rd_chunks);
printf("%.4f\n", (double)summary_stats->rd_data / rd_time); printf("%.4f\n", (double)summary_stats->rd_data / rd_time);
fflush(stdout); fflush(stdout);
} }

View File

@ -2568,7 +2568,7 @@ get_columns(void)
columns = 999; columns = 999;
} }
return columns; return (columns);
} }
int int
@ -5037,19 +5037,21 @@ get_history_one(zpool_handle_t *zhp, void *data)
} }
(void) printf("%s [internal %s txg:%lld] %s", tbuf, (void) printf("%s [internal %s txg:%lld] %s", tbuf,
zfs_history_event_names[ievent], zfs_history_event_names[ievent],
(long long int)fnvlist_lookup_uint64(rec, ZPOOL_HIST_TXG), (longlong_t) fnvlist_lookup_uint64(
rec, ZPOOL_HIST_TXG),
fnvlist_lookup_string(rec, ZPOOL_HIST_INT_STR)); fnvlist_lookup_string(rec, ZPOOL_HIST_INT_STR));
} else if (nvlist_exists(rec, ZPOOL_HIST_INT_NAME)) { } else if (nvlist_exists(rec, ZPOOL_HIST_INT_NAME)) {
if (!cb->internal) if (!cb->internal)
continue; continue;
(void) printf("%s [txg:%lld] %s", tbuf, (void) printf("%s [txg:%lld] %s", tbuf,
(long long int)fnvlist_lookup_uint64(rec, ZPOOL_HIST_TXG), (longlong_t) fnvlist_lookup_uint64(
rec, ZPOOL_HIST_TXG),
fnvlist_lookup_string(rec, ZPOOL_HIST_INT_NAME)); fnvlist_lookup_string(rec, ZPOOL_HIST_INT_NAME));
if (nvlist_exists(rec, ZPOOL_HIST_DSNAME)) { if (nvlist_exists(rec, ZPOOL_HIST_DSNAME)) {
(void) printf(" %s (%llu)", (void) printf(" %s (%llu)",
fnvlist_lookup_string(rec, fnvlist_lookup_string(rec,
ZPOOL_HIST_DSNAME), ZPOOL_HIST_DSNAME),
(long long unsigned int)fnvlist_lookup_uint64(rec, (u_longlong_t)fnvlist_lookup_uint64(rec,
ZPOOL_HIST_DSID)); ZPOOL_HIST_DSID));
} }
(void) printf(" %s", fnvlist_lookup_string(rec, (void) printf(" %s", fnvlist_lookup_string(rec,
@ -5165,10 +5167,10 @@ zpool_do_events_short(nvlist_t *nvl)
verify(nvlist_lookup_int64_array(nvl, FM_EREPORT_TIME, &tv, &n) == 0); verify(nvlist_lookup_int64_array(nvl, FM_EREPORT_TIME, &tv, &n) == 0);
memset(str, ' ', 32); memset(str, ' ', 32);
(void) ctime_r((const time_t *)&tv[0], ctime_str); (void) ctime_r((const time_t *)&tv[0], ctime_str);
(void) strncpy(str, ctime_str+4, 6); /* 'Jun 30' */ (void) strncpy(str, ctime_str+4, 6); /* 'Jun 30' */
(void) strncpy(str+7, ctime_str+20, 4); /* '1993' */ (void) strncpy(str+7, ctime_str+20, 4); /* '1993' */
(void) strncpy(str+12, ctime_str+11, 8); /* '21:49:08' */ (void) strncpy(str+12, ctime_str+11, 8); /* '21:49:08' */
(void) sprintf(str+20, ".%09lld", (longlong_t)tv[1]);/* '.123456789' */ (void) sprintf(str+20, ".%09lld", (longlong_t)tv[1]); /* '.123456789' */
(void) printf(gettext("%s "), str); (void) printf(gettext("%s "), str);
verify(nvlist_lookup_string(nvl, FM_CLASS, &ptr) == 0); verify(nvlist_lookup_string(nvl, FM_CLASS, &ptr) == 0);
@ -5276,10 +5278,10 @@ zpool_do_events_nvprint(nvlist_t *nvl, int depth)
printf(gettext("(%d embedded nvlists)\n"), nelem); printf(gettext("(%d embedded nvlists)\n"), nelem);
for (i = 0; i < nelem; i++) { for (i = 0; i < nelem; i++) {
printf(gettext("%*s%s[%d] = %s\n"), printf(gettext("%*s%s[%d] = %s\n"),
depth, "", name, i, "(embedded nvlist)"); depth, "", name, i, "(embedded nvlist)");
zpool_do_events_nvprint(val[i], depth + 8); zpool_do_events_nvprint(val[i], depth + 8);
printf(gettext("%*s(end %s[%i])\n"), printf(gettext("%*s(end %s[%i])\n"),
depth, "", name, i); depth, "", name, i);
} }
printf(gettext("%*s(end %s)\n"), depth, "", name); printf(gettext("%*s(end %s)\n"), depth, "", name);
} }
@ -5357,7 +5359,8 @@ zpool_do_events_nvprint(nvlist_t *nvl, int depth)
(void) nvpair_value_int64_array(nvp, &val, &nelem); (void) nvpair_value_int64_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++) for (i = 0; i < nelem; i++)
printf(gettext("0x%llx "), (u_longlong_t)val[i]); printf(gettext("0x%llx "),
(u_longlong_t)val[i]);
break; break;
} }
@ -5368,7 +5371,8 @@ zpool_do_events_nvprint(nvlist_t *nvl, int depth)
(void) nvpair_value_uint64_array(nvp, &val, &nelem); (void) nvpair_value_uint64_array(nvp, &val, &nelem);
for (i = 0; i < nelem; i++) for (i = 0; i < nelem; i++)
printf(gettext("0x%llx "), (u_longlong_t)val[i]); printf(gettext("0x%llx "),
(u_longlong_t)val[i]);
break; break;
} }
@ -5392,8 +5396,8 @@ zpool_do_events_next(ev_opts_t *opts)
nvlist_t *nvl; nvlist_t *nvl;
int cleanup_fd, ret, dropped; int cleanup_fd, ret, dropped;
cleanup_fd = open(ZFS_DEV, O_RDWR); cleanup_fd = open(ZFS_DEV, O_RDWR);
VERIFY(cleanup_fd >= 0); VERIFY(cleanup_fd >= 0);
if (!opts->scripted) if (!opts->scripted)
(void) printf(gettext("%-30s %s\n"), "TIME", "CLASS"); (void) printf(gettext("%-30s %s\n"), "TIME", "CLASS");
@ -5418,7 +5422,7 @@ zpool_do_events_next(ev_opts_t *opts)
nvlist_free(nvl); nvlist_free(nvl);
} }
VERIFY(0 == close(cleanup_fd)); VERIFY(0 == close(cleanup_fd));
return (ret); return (ret);
} }
@ -5476,7 +5480,7 @@ zpool_do_events(int argc, char **argv)
else else
ret = zpool_do_events_next(&opts); ret = zpool_do_events_next(&opts);
return ret; return (ret);
} }
static int static int
@ -5690,8 +5694,7 @@ main(int argc, char **argv)
/* /*
* Special case '-?' * Special case '-?'
*/ */
if ((strcmp(cmdname, "-?") == 0) || if ((strcmp(cmdname, "-?") == 0) || strcmp(cmdname, "--help") == 0)
strcmp(cmdname, "--help") == 0)
usage(B_TRUE); usage(B_TRUE);
if ((g_zfs = libzfs_init()) == NULL) if ((g_zfs = libzfs_init()) == NULL)

View File

@ -44,7 +44,8 @@ uint_t num_logs(nvlist_t *nv);
*/ */
nvlist_t *make_root_vdev(zpool_handle_t *zhp, nvlist_t *props, int force, nvlist_t *make_root_vdev(zpool_handle_t *zhp, nvlist_t *props, int force,
int check_rep, boolean_t replacing, boolean_t dryrun, int argc, char **argv); int check_rep, boolean_t replacing, boolean_t dryrun, int argc,
char **argv);
nvlist_t *split_mirror_vdev(zpool_handle_t *zhp, char *newname, nvlist_t *split_mirror_vdev(zpool_handle_t *zhp, char *newname,
nvlist_t *props, splitflags_t flags, int argc, char **argv); nvlist_t *props, splitflags_t flags, int argc, char **argv);

View File

@ -80,7 +80,7 @@
#ifdef HAVE_LIBBLKID #ifdef HAVE_LIBBLKID
#include <blkid/blkid.h> #include <blkid/blkid.h>
#else #else
#define blkid_cache void * #define blkid_cache void *
#endif /* HAVE_LIBBLKID */ #endif /* HAVE_LIBBLKID */
#include "zpool_util.h" #include "zpool_util.h"
@ -187,7 +187,7 @@ static vdev_disk_db_entry_t vdev_disk_database[] = {
{"ATA SAMSUNG MCCOE32G", 4096}, {"ATA SAMSUNG MCCOE32G", 4096},
{"ATA SAMSUNG MCCOE64G", 4096}, {"ATA SAMSUNG MCCOE64G", 4096},
{"ATA SAMSUNG SSD PM80", 4096}, {"ATA SAMSUNG SSD PM80", 4096},
/* Imported from Open Solaris*/ /* Imported from Open Solaris */
{"ATA MARVELL SD88SA02", 4096}, {"ATA MARVELL SD88SA02", 4096},
/* Advanced format Hard drives */ /* Advanced format Hard drives */
{"ATA Hitachi HDS5C303", 4096}, {"ATA Hitachi HDS5C303", 4096},
@ -231,16 +231,16 @@ check_sector_size_database(char *path, int *sector_size)
int i; int i;
/* Prepare INQUIRY command */ /* Prepare INQUIRY command */
memset(&io_hdr, 0, sizeof(sg_io_hdr_t)); memset(&io_hdr, 0, sizeof (sg_io_hdr_t));
io_hdr.interface_id = 'S'; io_hdr.interface_id = 'S';
io_hdr.cmd_len = sizeof(inq_cmd_blk); io_hdr.cmd_len = sizeof (inq_cmd_blk);
io_hdr.mx_sb_len = sizeof(sense_buffer); io_hdr.mx_sb_len = sizeof (sense_buffer);
io_hdr.dxfer_direction = SG_DXFER_FROM_DEV; io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
io_hdr.dxfer_len = INQ_REPLY_LEN; io_hdr.dxfer_len = INQ_REPLY_LEN;
io_hdr.dxferp = inq_buff; io_hdr.dxferp = inq_buff;
io_hdr.cmdp = inq_cmd_blk; io_hdr.cmdp = inq_cmd_blk;
io_hdr.sbp = sense_buffer; io_hdr.sbp = sense_buffer;
io_hdr.timeout = 10; /* 10 milliseconds is ample time */ io_hdr.timeout = 10; /* 10 milliseconds is ample time */
if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0) if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0)
return (B_FALSE); return (B_FALSE);
@ -385,7 +385,7 @@ check_slice(const char *path, blkid_cache cache, int force, boolean_t isspare)
} else { } else {
err = -1; err = -1;
vdev_error(gettext("%s contains a filesystem of " vdev_error(gettext("%s contains a filesystem of "
"type '%s'\n"), path, value); "type '%s'\n"), path, value);
} }
} }
@ -403,7 +403,7 @@ check_slice(const char *path, blkid_cache cache, int force, boolean_t isspare)
*/ */
static int static int
check_disk(const char *path, blkid_cache cache, int force, check_disk(const char *path, blkid_cache cache, int force,
boolean_t isspare, boolean_t iswholedisk) boolean_t isspare, boolean_t iswholedisk)
{ {
struct dk_gpt *vtoc; struct dk_gpt *vtoc;
char slice_path[MAXPATHLEN]; char slice_path[MAXPATHLEN];
@ -412,7 +412,7 @@ check_disk(const char *path, blkid_cache cache, int force,
/* This is not a wholedisk we only check the given partition */ /* This is not a wholedisk we only check the given partition */
if (!iswholedisk) if (!iswholedisk)
return check_slice(path, cache, force, isspare); return (check_slice(path, cache, force, isspare));
/* /*
* When the device is a whole disk try to read the efi partition * When the device is a whole disk try to read the efi partition
@ -424,19 +424,19 @@ check_disk(const char *path, blkid_cache cache, int force,
*/ */
if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0) { if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0) {
check_error(errno); check_error(errno);
return -1; return (-1);
} }
if ((err = efi_alloc_and_read(fd, &vtoc)) != 0) { if ((err = efi_alloc_and_read(fd, &vtoc)) != 0) {
(void) close(fd); (void) close(fd);
if (force) { if (force) {
return 0; return (0);
} else { } else {
vdev_error(gettext("%s does not contain an EFI " vdev_error(gettext("%s does not contain an EFI "
"label but it may contain partition\n" "label but it may contain partition\n"
"information in the MBR.\n"), path); "information in the MBR.\n"), path);
return -1; return (-1);
} }
} }
@ -451,11 +451,11 @@ check_disk(const char *path, blkid_cache cache, int force,
if (force) { if (force) {
/* Partitions will no be created using the backup */ /* Partitions will no be created using the backup */
return 0; return (0);
} else { } else {
vdev_error(gettext("%s contains a corrupt primary " vdev_error(gettext("%s contains a corrupt primary "
"EFI label.\n"), path); "EFI label.\n"), path);
return -1; return (-1);
} }
} }
@ -486,7 +486,7 @@ check_disk(const char *path, blkid_cache cache, int force,
static int static int
check_device(const char *path, boolean_t force, check_device(const char *path, boolean_t force,
boolean_t isspare, boolean_t iswholedisk) boolean_t isspare, boolean_t iswholedisk)
{ {
static blkid_cache cache = NULL; static blkid_cache cache = NULL;
@ -500,18 +500,18 @@ check_device(const char *path, boolean_t force,
if ((err = blkid_get_cache(&cache, NULL)) != 0) { if ((err = blkid_get_cache(&cache, NULL)) != 0) {
check_error(err); check_error(err);
return -1; return (-1);
} }
if ((err = blkid_probe_all(cache)) != 0) { if ((err = blkid_probe_all(cache)) != 0) {
blkid_put_cache(cache); blkid_put_cache(cache);
check_error(err); check_error(err);
return -1; return (-1);
} }
} }
#endif /* HAVE_LIBBLKID */ #endif /* HAVE_LIBBLKID */
return check_disk(path, cache, force, isspare, iswholedisk); return (check_disk(path, cache, force, isspare, iswholedisk));
} }
/* /*
@ -526,7 +526,7 @@ static boolean_t
is_whole_disk(const char *path) is_whole_disk(const char *path)
{ {
struct dk_gpt *label; struct dk_gpt *label;
int fd; int fd;
if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0) if ((fd = open(path, O_RDONLY|O_DIRECT)) < 0)
return (B_FALSE); return (B_FALSE);
@ -547,7 +547,7 @@ is_whole_disk(const char *path)
*/ */
static int static int
is_shorthand_path(const char *arg, char *path, is_shorthand_path(const char *arg, char *path,
struct stat64 *statbuf, boolean_t *wholedisk) struct stat64 *statbuf, boolean_t *wholedisk)
{ {
int error; int error;
@ -558,8 +558,8 @@ is_shorthand_path(const char *arg, char *path,
return (0); return (0);
} }
strlcpy(path, arg, sizeof(path)); strlcpy(path, arg, sizeof (path));
memset(statbuf, 0, sizeof(*statbuf)); memset(statbuf, 0, sizeof (*statbuf));
*wholedisk = B_FALSE; *wholedisk = B_FALSE;
return (error); return (error);
@ -1136,7 +1136,7 @@ zero_label(char *path)
return (-1); return (-1);
} }
return 0; return (0);
} }
/* /*
@ -1225,7 +1225,7 @@ make_disks(zpool_handle_t *zhp, nvlist_t *nv)
* and then block until udev creates the new link. * and then block until udev creates the new link.
*/ */
if (!is_exclusive || !is_spare(NULL, udevpath)) { if (!is_exclusive || !is_spare(NULL, udevpath)) {
ret = strncmp(udevpath,UDISK_ROOT,strlen(UDISK_ROOT)); ret = strncmp(udevpath, UDISK_ROOT, strlen(UDISK_ROOT));
if (ret == 0) { if (ret == 0) {
ret = lstat64(udevpath, &statbuf); ret = lstat64(udevpath, &statbuf);
if (ret == 0 && S_ISLNK(statbuf.st_mode)) if (ret == 0 && S_ISLNK(statbuf.st_mode))
@ -1299,7 +1299,7 @@ check_in_use(nvlist_t *config, nvlist_t *nv, boolean_t force,
verify(!nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path)); verify(!nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path));
if (strcmp(type, VDEV_TYPE_DISK) == 0) if (strcmp(type, VDEV_TYPE_DISK) == 0)
verify(!nvlist_lookup_uint64(nv, verify(!nvlist_lookup_uint64(nv,
ZPOOL_CONFIG_WHOLE_DISK, &wholedisk)); ZPOOL_CONFIG_WHOLE_DISK, &wholedisk));
/* /*
* As a generic check, we look to see if this is a replace of a * As a generic check, we look to see if this is a replace of a
@ -1502,8 +1502,8 @@ construct_spec(nvlist_t *props, int argc, char **argv)
children * sizeof (nvlist_t *)); children * sizeof (nvlist_t *));
if (child == NULL) if (child == NULL)
zpool_no_memory(); zpool_no_memory();
if ((nv = make_leaf_vdev(props, argv[c], B_FALSE)) if ((nv = make_leaf_vdev(props, argv[c],
== NULL) B_FALSE)) == NULL)
return (NULL); return (NULL);
child[children - 1] = nv; child[children - 1] = nv;
} }
@ -1558,7 +1558,8 @@ construct_spec(nvlist_t *props, int argc, char **argv)
* We have a device. Pass off to make_leaf_vdev() to * We have a device. Pass off to make_leaf_vdev() to
* construct the appropriate nvlist describing the vdev. * construct the appropriate nvlist describing the vdev.
*/ */
if ((nv = make_leaf_vdev(props, argv[0], is_log)) == NULL) if ((nv = make_leaf_vdev(props, argv[0],
is_log)) == NULL)
return (NULL); return (NULL);
if (is_log) if (is_log)
nlogs++; nlogs++;

View File

@ -3574,7 +3574,7 @@ out:
} }
#undef OD_ARRAY_SIZE #undef OD_ARRAY_SIZE
#define OD_ARRAY_SIZE 4 #define OD_ARRAY_SIZE 4
/* /*
* Verify that dmu_object_{alloc,free} work as expected. * Verify that dmu_object_{alloc,free} work as expected.
@ -3587,7 +3587,7 @@ ztest_dmu_object_alloc_free(ztest_ds_t *zd, uint64_t id)
int size; int size;
int b; int b;
size = sizeof(ztest_od_t) * OD_ARRAY_SIZE; size = sizeof (ztest_od_t) * OD_ARRAY_SIZE;
od = umem_alloc(size, UMEM_NOFAIL); od = umem_alloc(size, UMEM_NOFAIL);
batchsize = OD_ARRAY_SIZE; batchsize = OD_ARRAY_SIZE;
@ -3609,7 +3609,7 @@ ztest_dmu_object_alloc_free(ztest_ds_t *zd, uint64_t id)
} }
#undef OD_ARRAY_SIZE #undef OD_ARRAY_SIZE
#define OD_ARRAY_SIZE 2 #define OD_ARRAY_SIZE 2
/* /*
* Verify that dmu_{read,write} work as expected. * Verify that dmu_{read,write} work as expected.
@ -3621,7 +3621,7 @@ ztest_dmu_read_write(ztest_ds_t *zd, uint64_t id)
ztest_od_t *od; ztest_od_t *od;
objset_t *os = zd->zd_os; objset_t *os = zd->zd_os;
size = sizeof(ztest_od_t) * OD_ARRAY_SIZE; size = sizeof (ztest_od_t) * OD_ARRAY_SIZE;
od = umem_alloc(size, UMEM_NOFAIL); od = umem_alloc(size, UMEM_NOFAIL);
dmu_tx_t *tx; dmu_tx_t *tx;
int i, freeit, error; int i, freeit, error;
@ -3888,7 +3888,7 @@ compare_and_update_pbbufs(uint64_t s, bufwad_t *packbuf, bufwad_t *bigbuf,
} }
#undef OD_ARRAY_SIZE #undef OD_ARRAY_SIZE
#define OD_ARRAY_SIZE 2 #define OD_ARRAY_SIZE 2
void void
ztest_dmu_read_write_zcopy(ztest_ds_t *zd, uint64_t id) ztest_dmu_read_write_zcopy(ztest_ds_t *zd, uint64_t id)
@ -3911,7 +3911,7 @@ ztest_dmu_read_write_zcopy(ztest_ds_t *zd, uint64_t id)
arc_buf_t **bigbuf_arcbufs; arc_buf_t **bigbuf_arcbufs;
dmu_object_info_t doi; dmu_object_info_t doi;
size = sizeof(ztest_od_t) * OD_ARRAY_SIZE; size = sizeof (ztest_od_t) * OD_ARRAY_SIZE;
od = umem_alloc(size, UMEM_NOFAIL); od = umem_alloc(size, UMEM_NOFAIL);
/* /*
@ -4132,7 +4132,7 @@ ztest_dmu_write_parallel(ztest_ds_t *zd, uint64_t id)
{ {
ztest_od_t *od; ztest_od_t *od;
od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL); od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
uint64_t offset = (1ULL << (ztest_random(20) + 43)) + uint64_t offset = (1ULL << (ztest_random(20) + 43)) +
(ztest_random(ZTEST_RANGE_LOCKS) << SPA_MAXBLOCKSHIFT); (ztest_random(ZTEST_RANGE_LOCKS) << SPA_MAXBLOCKSHIFT);
@ -4149,7 +4149,7 @@ ztest_dmu_write_parallel(ztest_ds_t *zd, uint64_t id)
while (ztest_random(10) != 0) while (ztest_random(10) != 0)
ztest_io(zd, od->od_object, offset); ztest_io(zd, od->od_object, offset);
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
} }
void void
@ -4162,17 +4162,18 @@ ztest_dmu_prealloc(ztest_ds_t *zd, uint64_t id)
uint64_t blocksize = ztest_random_blocksize(); uint64_t blocksize = ztest_random_blocksize();
void *data; void *data;
od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL); od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, id, FTAG, 0, DMU_OT_UINT64_OTHER, blocksize, 0); ztest_od_init(od, id, FTAG, 0, DMU_OT_UINT64_OTHER, blocksize, 0);
if (ztest_object_init(zd, od, sizeof (ztest_od_t), !ztest_random(2)) != 0) { if (ztest_object_init(zd, od, sizeof (ztest_od_t),
umem_free(od, sizeof(ztest_od_t)); !ztest_random(2)) != 0) {
umem_free(od, sizeof (ztest_od_t));
return; return;
} }
if (ztest_truncate(zd, od->od_object, offset, count * blocksize) != 0) { if (ztest_truncate(zd, od->od_object, offset, count * blocksize) != 0) {
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
return; return;
} }
@ -4190,7 +4191,7 @@ ztest_dmu_prealloc(ztest_ds_t *zd, uint64_t id)
} }
umem_free(data, blocksize); umem_free(data, blocksize);
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
} }
/* /*
@ -4215,7 +4216,7 @@ ztest_zap(ztest_ds_t *zd, uint64_t id)
int error; int error;
char *hc[2] = { "s.acl.h", ".s.open.h.hyLZlg" }; char *hc[2] = { "s.acl.h", ".s.open.h.hyLZlg" };
od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL); od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, id, FTAG, 0, DMU_OT_ZAP_OTHER, 0, 0); ztest_od_init(od, id, FTAG, 0, DMU_OT_ZAP_OTHER, 0, 0);
if (ztest_object_init(zd, od, sizeof (ztest_od_t), if (ztest_object_init(zd, od, sizeof (ztest_od_t),
@ -4338,7 +4339,7 @@ ztest_zap(ztest_ds_t *zd, uint64_t id)
VERIFY3U(0, ==, zap_remove(os, object, propname, tx)); VERIFY3U(0, ==, zap_remove(os, object, propname, tx));
dmu_tx_commit(tx); dmu_tx_commit(tx);
out: out:
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
} }
/* /*
@ -4352,7 +4353,7 @@ ztest_fzap(ztest_ds_t *zd, uint64_t id)
uint64_t object, txg; uint64_t object, txg;
int i; int i;
od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL); od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, id, FTAG, 0, DMU_OT_ZAP_OTHER, 0, 0); ztest_od_init(od, id, FTAG, 0, DMU_OT_ZAP_OTHER, 0, 0);
if (ztest_object_init(zd, od, sizeof (ztest_od_t), if (ztest_object_init(zd, od, sizeof (ztest_od_t),
@ -4385,7 +4386,7 @@ ztest_fzap(ztest_ds_t *zd, uint64_t id)
dmu_tx_commit(tx); dmu_tx_commit(tx);
} }
out: out:
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
} }
/* ARGSUSED */ /* ARGSUSED */
@ -4401,11 +4402,11 @@ ztest_zap_parallel(ztest_ds_t *zd, uint64_t id)
char name[20], string_value[20]; char name[20], string_value[20];
void *data; void *data;
od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL); od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, ID_PARALLEL, FTAG, micro, DMU_OT_ZAP_OTHER, 0, 0); ztest_od_init(od, ID_PARALLEL, FTAG, micro, DMU_OT_ZAP_OTHER, 0, 0);
if (ztest_object_init(zd, od, sizeof (ztest_od_t), B_FALSE) != 0) { if (ztest_object_init(zd, od, sizeof (ztest_od_t), B_FALSE) != 0) {
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
return; return;
} }
@ -4499,7 +4500,7 @@ ztest_zap_parallel(ztest_ds_t *zd, uint64_t id)
if (tx != NULL) if (tx != NULL)
dmu_tx_commit(tx); dmu_tx_commit(tx);
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
} }
/* /*
@ -4590,11 +4591,11 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id)
uint64_t old_txg, txg; uint64_t old_txg, txg;
int i, error = 0; int i, error = 0;
od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL); od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, id, FTAG, 0, DMU_OT_UINT64_OTHER, 0, 0); ztest_od_init(od, id, FTAG, 0, DMU_OT_UINT64_OTHER, 0, 0);
if (ztest_object_init(zd, od, sizeof (ztest_od_t), B_FALSE) != 0) { if (ztest_object_init(zd, od, sizeof (ztest_od_t), B_FALSE) != 0) {
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
return; return;
} }
@ -4637,7 +4638,7 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id)
umem_free(cb_data[i], sizeof (ztest_cb_data_t)); umem_free(cb_data[i], sizeof (ztest_cb_data_t));
} }
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
return; return;
} }
@ -4709,7 +4710,7 @@ ztest_dmu_commit_callbacks(ztest_ds_t *zd, uint64_t id)
dmu_tx_commit(tx); dmu_tx_commit(tx);
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
} }
/* ARGSUSED */ /* ARGSUSED */
@ -4790,11 +4791,12 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
dmu_objset_name(os, osname); dmu_objset_name(os, osname);
(void) snprintf(snapname, sizeof (snapname), "sh1_%llu", (long long unsigned int)id); (void) snprintf(snapname, sizeof (snapname), "sh1_%llu",
(u_longlong_t)id);
(void) snprintf(fullname, sizeof (fullname), "%s@%s", osname, snapname); (void) snprintf(fullname, sizeof (fullname), "%s@%s", osname, snapname);
(void) snprintf(clonename, sizeof (clonename), (void) snprintf(clonename, sizeof (clonename),
"%s/ch1_%llu", osname, (long long unsigned int)id); "%s/ch1_%llu", osname, (u_longlong_t)id);
(void) snprintf(tag, sizeof (tag), "tag_%llu", (long long unsigned int)id); (void) snprintf(tag, sizeof (tag), "tag_%llu", (u_longlong_t)id);
/* /*
* Clean up from any previous run. * Clean up from any previous run.
@ -5124,11 +5126,11 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_t id)
blocksize = ztest_random_blocksize(); blocksize = ztest_random_blocksize();
blocksize = MIN(blocksize, 2048); /* because we write so many */ blocksize = MIN(blocksize, 2048); /* because we write so many */
od = umem_alloc(sizeof(ztest_od_t), UMEM_NOFAIL); od = umem_alloc(sizeof (ztest_od_t), UMEM_NOFAIL);
ztest_od_init(od, id, FTAG, 0, DMU_OT_UINT64_OTHER, blocksize, 0); ztest_od_init(od, id, FTAG, 0, DMU_OT_UINT64_OTHER, blocksize, 0);
if (ztest_object_init(zd, od, sizeof (ztest_od_t), B_FALSE) != 0) { if (ztest_object_init(zd, od, sizeof (ztest_od_t), B_FALSE) != 0) {
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
return; return;
} }
@ -5143,7 +5145,7 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_t id)
ztest_dsl_prop_set_uint64(zd->zd_name, ZFS_PROP_COPIES, 1, ztest_dsl_prop_set_uint64(zd->zd_name, ZFS_PROP_COPIES, 1,
B_FALSE) != 0) { B_FALSE) != 0) {
(void) rw_exit(&ztest_name_lock); (void) rw_exit(&ztest_name_lock);
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
return; return;
} }
@ -5158,7 +5160,7 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_t id)
txg = ztest_tx_assign(tx, TXG_WAIT, FTAG); txg = ztest_tx_assign(tx, TXG_WAIT, FTAG);
if (txg == 0) { if (txg == 0) {
(void) rw_exit(&ztest_name_lock); (void) rw_exit(&ztest_name_lock);
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
return; return;
} }
@ -5207,7 +5209,7 @@ ztest_ddt_repair(ztest_ds_t *zd, uint64_t id)
zio_buf_free(buf, psize); zio_buf_free(buf, psize);
(void) rw_exit(&ztest_name_lock); (void) rw_exit(&ztest_name_lock);
umem_free(od, sizeof(ztest_od_t)); umem_free(od, sizeof (ztest_od_t));
} }
/* /*
@ -5493,7 +5495,7 @@ ztest_resume_thread(void *arg)
return (NULL); return (NULL);
} }
#define GRACE 300 #define GRACE 300
#if 0 #if 0
static void static void

View File

@ -33,7 +33,8 @@
#include <sys/zfs_znode.h> #include <sys/zfs_znode.h>
#include <sys/fs/zfs.h> #include <sys/fs/zfs.h>
int ioctl_get_msg(char *var, int fd) static int
ioctl_get_msg(char *var, int fd)
{ {
int error = 0; int error = 0;
char msg[ZFS_MAXNAMELEN]; char msg[ZFS_MAXNAMELEN];
@ -47,7 +48,8 @@ int ioctl_get_msg(char *var, int fd)
return (error); return (error);
} }
int main(int argc, char **argv) int
main(int argc, char **argv)
{ {
int fd, error = 0; int fd, error = 0;
char zvol_name[ZFS_MAXNAMELEN], zvol_name_part[ZFS_MAXNAMELEN]; char zvol_name[ZFS_MAXNAMELEN], zvol_name_part[ZFS_MAXNAMELEN];

View File

@ -27,7 +27,7 @@
*/ */
#ifndef _ZFS_BLKDEV_H #ifndef _ZFS_BLKDEV_H
#define _ZFS_BLKDEV_H #define _ZFS_BLKDEV_H
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/elevator.h> #include <linux/elevator.h>
@ -46,7 +46,7 @@ blk_fetch_request(struct request_queue *q)
if (req) if (req)
blkdev_dequeue_request(req); blkdev_dequeue_request(req);
return req; return (req);
} }
#endif /* HAVE_BLK_FETCH_REQUEST */ #endif /* HAVE_BLK_FETCH_REQUEST */
@ -79,7 +79,7 @@ __blk_end_request(struct request *req, int error, unsigned int nr_bytes)
req->hard_cur_sectors = nr_bytes >> 9; req->hard_cur_sectors = nr_bytes >> 9;
end_request(req, ((error == 0) ? 1 : error)); end_request(req, ((error == 0) ? 1 : error));
return 0; return (0);
} }
static inline bool static inline bool
@ -92,17 +92,17 @@ blk_end_request(struct request *req, int error, unsigned int nr_bytes)
rc = __blk_end_request(req, error, nr_bytes); rc = __blk_end_request(req, error, nr_bytes);
spin_unlock_irq(q->queue_lock); spin_unlock_irq(q->queue_lock);
return rc; return (rc);
} }
#else #else
# ifdef HAVE_BLK_END_REQUEST_GPL_ONLY #ifdef HAVE_BLK_END_REQUEST_GPL_ONLY
/* /*
* Define required to avoid conflicting 2.6.29 non-static prototype for a * Define required to avoid conflicting 2.6.29 non-static prototype for a
* GPL-only version of the helper. As of 2.6.31 the helper is available * GPL-only version of the helper. As of 2.6.31 the helper is available
* to non-GPL modules and is not explicitly exported GPL-only. * to non-GPL modules and is not explicitly exported GPL-only.
*/ */
# define __blk_end_request __blk_end_request_x #define __blk_end_request __blk_end_request_x
# define blk_end_request blk_end_request_x #define blk_end_request blk_end_request_x
static inline bool static inline bool
__blk_end_request_x(struct request *req, int error, unsigned int nr_bytes) __blk_end_request_x(struct request *req, int error, unsigned int nr_bytes)
@ -115,7 +115,7 @@ __blk_end_request_x(struct request *req, int error, unsigned int nr_bytes)
req->hard_cur_sectors = nr_bytes >> 9; req->hard_cur_sectors = nr_bytes >> 9;
end_request(req, ((error == 0) ? 1 : error)); end_request(req, ((error == 0) ? 1 : error));
return 0; return (0);
} }
static inline bool static inline bool
blk_end_request_x(struct request *req, int error, unsigned int nr_bytes) blk_end_request_x(struct request *req, int error, unsigned int nr_bytes)
@ -127,9 +127,9 @@ blk_end_request_x(struct request *req, int error, unsigned int nr_bytes)
rc = __blk_end_request_x(req, error, nr_bytes); rc = __blk_end_request_x(req, error, nr_bytes);
spin_unlock_irq(q->queue_lock); spin_unlock_irq(q->queue_lock);
return rc; return (rc);
} }
# endif /* HAVE_BLK_END_REQUEST_GPL_ONLY */ #endif /* HAVE_BLK_END_REQUEST_GPL_ONLY */
#endif /* HAVE_BLK_END_REQUEST */ #endif /* HAVE_BLK_END_REQUEST */
/* /*
@ -141,7 +141,7 @@ blk_end_request_x(struct request *req, int error, unsigned int nr_bytes)
* that long term this function will be opened up. * that long term this function will be opened up.
*/ */
#if defined(HAVE_BLK_QUEUE_FLUSH) && defined(HAVE_BLK_QUEUE_FLUSH_GPL_ONLY) #if defined(HAVE_BLK_QUEUE_FLUSH) && defined(HAVE_BLK_QUEUE_FLUSH_GPL_ONLY)
#define blk_queue_flush __blk_queue_flush #define blk_queue_flush __blk_queue_flush
static inline void static inline void
__blk_queue_flush(struct request_queue *q, unsigned int flags) __blk_queue_flush(struct request_queue *q, unsigned int flags)
{ {
@ -153,7 +153,7 @@ __blk_queue_flush(struct request_queue *q, unsigned int flags)
static inline sector_t static inline sector_t
blk_rq_pos(struct request *req) blk_rq_pos(struct request *req)
{ {
return req->sector; return (req->sector);
} }
#endif /* HAVE_BLK_RQ_POS */ #endif /* HAVE_BLK_RQ_POS */
@ -161,7 +161,7 @@ blk_rq_pos(struct request *req)
static inline unsigned int static inline unsigned int
blk_rq_sectors(struct request *req) blk_rq_sectors(struct request *req)
{ {
return req->nr_sectors; return (req->nr_sectors);
} }
#endif /* HAVE_BLK_RQ_SECTORS */ #endif /* HAVE_BLK_RQ_SECTORS */
@ -171,11 +171,11 @@ blk_rq_sectors(struct request *req)
* GPL-only version of the helper. As of 2.6.31 the helper is available * GPL-only version of the helper. As of 2.6.31 the helper is available
* to non-GPL modules in the form of a static inline in the header. * to non-GPL modules in the form of a static inline in the header.
*/ */
#define blk_rq_bytes __blk_rq_bytes #define blk_rq_bytes __blk_rq_bytes
static inline unsigned int static inline unsigned int
__blk_rq_bytes(struct request *req) __blk_rq_bytes(struct request *req)
{ {
return blk_rq_sectors(req) << 9; return (blk_rq_sectors(req) << 9);
} }
#endif /* !HAVE_BLK_RQ_BYTES || HAVE_BLK_RQ_BYTES_GPL_ONLY */ #endif /* !HAVE_BLK_RQ_BYTES || HAVE_BLK_RQ_BYTES_GPL_ONLY */
@ -186,7 +186,7 @@ __blk_rq_bytes(struct request *req)
* macros are redefined here if they are missing from the kernel. * macros are redefined here if they are missing from the kernel.
*/ */
#ifndef blk_fs_request #ifndef blk_fs_request
#define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS) #define blk_fs_request(rq) ((rq)->cmd_type == REQ_TYPE_FS)
#endif #endif
/* /*
@ -197,7 +197,7 @@ __blk_rq_bytes(struct request *req)
* this legacy behavior. * this legacy behavior.
*/ */
#ifndef blk_queue_stackable #ifndef blk_queue_stackable
#define blk_queue_stackable(q) ((q)->request_fn == NULL) #define blk_queue_stackable(q) ((q)->request_fn == NULL)
#endif #endif
/* /*
@ -205,7 +205,7 @@ __blk_rq_bytes(struct request *req)
* The blk_queue_max_hw_sectors() function replaces blk_queue_max_sectors(). * The blk_queue_max_hw_sectors() function replaces blk_queue_max_sectors().
*/ */
#ifndef HAVE_BLK_QUEUE_MAX_HW_SECTORS #ifndef HAVE_BLK_QUEUE_MAX_HW_SECTORS
#define blk_queue_max_hw_sectors __blk_queue_max_hw_sectors #define blk_queue_max_hw_sectors __blk_queue_max_hw_sectors
static inline void static inline void
__blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors) __blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors)
{ {
@ -219,7 +219,7 @@ __blk_queue_max_hw_sectors(struct request_queue *q, unsigned int max_hw_sectors)
* blk_queue_max_hw_segments() and blk_queue_max_phys_segments(). * blk_queue_max_hw_segments() and blk_queue_max_phys_segments().
*/ */
#ifndef HAVE_BLK_QUEUE_MAX_SEGMENTS #ifndef HAVE_BLK_QUEUE_MAX_SEGMENTS
#define blk_queue_max_segments __blk_queue_max_segments #define blk_queue_max_segments __blk_queue_max_segments
static inline void static inline void
__blk_queue_max_segments(struct request_queue *q, unsigned short max_segments) __blk_queue_max_segments(struct request_queue *q, unsigned short max_segments)
{ {
@ -235,7 +235,7 @@ __blk_queue_max_segments(struct request_queue *q, unsigned short max_segments)
* a read-modify-write penalty. For older kernels this is a no-op. * a read-modify-write penalty. For older kernels this is a no-op.
*/ */
#ifndef HAVE_BLK_QUEUE_PHYSICAL_BLOCK_SIZE #ifndef HAVE_BLK_QUEUE_PHYSICAL_BLOCK_SIZE
#define blk_queue_physical_block_size(q, x) ((void)(0)) #define blk_queue_physical_block_size(q, x) ((void)(0))
#endif #endif
/* /*
@ -244,7 +244,7 @@ __blk_queue_max_segments(struct request_queue *q, unsigned short max_segments)
* I/O size for the device. For older kernels this is a no-op. * I/O size for the device. For older kernels this is a no-op.
*/ */
#ifndef HAVE_BLK_QUEUE_IO_OPT #ifndef HAVE_BLK_QUEUE_IO_OPT
#define blk_queue_io_opt(q, x) ((void)(0)) #define blk_queue_io_opt(q, x) ((void)(0))
#endif #endif
#ifndef HAVE_GET_DISK_RO #ifndef HAVE_GET_DISK_RO
@ -256,7 +256,7 @@ get_disk_ro(struct gendisk *disk)
if (disk->part[0]) if (disk->part[0])
policy = disk->part[0]->policy; policy = disk->part[0]->policy;
return policy; return (policy);
} }
#endif /* HAVE_GET_DISK_RO */ #endif /* HAVE_GET_DISK_RO */
@ -274,14 +274,14 @@ struct req_iterator {
struct bio *bio; struct bio *bio;
}; };
# define for_each_bio(_bio) \ #define for_each_bio(_bio) \
for (; _bio; _bio = _bio->bi_next) for (; _bio; _bio = _bio->bi_next)
# define __rq_for_each_bio(_bio, rq) \ #define __rq_for_each_bio(_bio, rq) \
if ((rq->bio)) \ if ((rq->bio)) \
for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next) for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next)
# define rq_for_each_segment(bvl, _rq, _iter) \ #define rq_for_each_segment(bvl, _rq, _iter) \
__rq_for_each_bio(_iter.bio, _rq) \ __rq_for_each_bio(_iter.bio, _rq) \
bio_for_each_segment(bvl, _iter.bio, _iter.i) bio_for_each_segment(bvl, _iter.bio, _iter.i)
#endif /* HAVE_RQ_FOR_EACH_SEGMENT */ #endif /* HAVE_RQ_FOR_EACH_SEGMENT */
@ -315,21 +315,23 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
#ifdef HAVE_BIO_RW_FAILFAST_DTD #ifdef HAVE_BIO_RW_FAILFAST_DTD
/* BIO_RW_FAILFAST_* preferred interface from 2.6.28 - 2.6.35 */ /* BIO_RW_FAILFAST_* preferred interface from 2.6.28 - 2.6.35 */
*flags |= *flags |= (
((1 << BIO_RW_FAILFAST_DEV) | (1 << BIO_RW_FAILFAST_DEV) |
(1 << BIO_RW_FAILFAST_TRANSPORT) | (1 << BIO_RW_FAILFAST_TRANSPORT) |
(1 << BIO_RW_FAILFAST_DRIVER)); (1 << BIO_RW_FAILFAST_DRIVER));
#else #else
# ifdef HAVE_BIO_RW_FAILFAST #ifdef HAVE_BIO_RW_FAILFAST
/* BIO_RW_FAILFAST preferred interface from 2.6.12 - 2.6.27 */ /* BIO_RW_FAILFAST preferred interface from 2.6.12 - 2.6.27 */
*flags |= (1 << BIO_RW_FAILFAST); *flags |= (1 << BIO_RW_FAILFAST);
# else #else
# ifdef HAVE_REQ_FAILFAST_MASK #ifdef HAVE_REQ_FAILFAST_MASK
/* REQ_FAILFAST_* preferred interface from 2.6.36 - 2.6.xx, /*
* the BIO_* and REQ_* flags were unified under REQ_* flags. */ * REQ_FAILFAST_* preferred interface from 2.6.36 - 2.6.xx,
* the BIO_* and REQ_* flags were unified under REQ_* flags.
*/
*flags |= REQ_FAILFAST_MASK; *flags |= REQ_FAILFAST_MASK;
# endif /* HAVE_REQ_FAILFAST_MASK */ #endif /* HAVE_REQ_FAILFAST_MASK */
# endif /* HAVE_BIO_RW_FAILFAST */ #endif /* HAVE_BIO_RW_FAILFAST */
#endif /* HAVE_BIO_RW_FAILFAST_DTD */ #endif /* HAVE_BIO_RW_FAILFAST_DTD */
} }
@ -337,7 +339,7 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
* Maximum disk label length, it may be undefined for some kernels. * Maximum disk label length, it may be undefined for some kernels.
*/ */
#ifndef DISK_NAME_LEN #ifndef DISK_NAME_LEN
#define DISK_NAME_LEN 32 #define DISK_NAME_LEN 32
#endif /* DISK_NAME_LEN */ #endif /* DISK_NAME_LEN */
/* /*
@ -346,12 +348,14 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
* macro's to ensure the prototype and return value are handled. * macro's to ensure the prototype and return value are handled.
*/ */
#ifdef HAVE_2ARGS_BIO_END_IO_T #ifdef HAVE_2ARGS_BIO_END_IO_T
# define BIO_END_IO_PROTO(fn, x, y, z) static void fn(struct bio *x, int z) #define BIO_END_IO_PROTO(fn, x, y, z) static void fn(struct bio *x, int z)
# define BIO_END_IO_RETURN(rc) return #define BIO_END_IO_RETURN(rc) return
#else #else
# define BIO_END_IO_PROTO(fn, x, y, z) static int fn(struct bio *x, \ #define BIO_END_IO_PROTO(fn, x, y, z) static int fn( \
unsigned int y, int z) struct bio *x, \
# define BIO_END_IO_RETURN(rc) return rc unsigned int y, \
int z)
#define BIO_END_IO_RETURN(rc) return rc
#endif /* HAVE_2ARGS_BIO_END_IO_T */ #endif /* HAVE_2ARGS_BIO_END_IO_T */
/* /*
@ -370,15 +374,15 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
* Used to exclusively open a block device from within the kernel. * Used to exclusively open a block device from within the kernel.
*/ */
#if defined(HAVE_BLKDEV_GET_BY_PATH) #if defined(HAVE_BLKDEV_GET_BY_PATH)
# define vdev_bdev_open(path, md, hld) blkdev_get_by_path(path, \ #define vdev_bdev_open(path, md, hld) blkdev_get_by_path(path, \
(md) | FMODE_EXCL, hld) (md) | FMODE_EXCL, hld)
# define vdev_bdev_close(bdev, md) blkdev_put(bdev, (md) | FMODE_EXCL) #define vdev_bdev_close(bdev, md) blkdev_put(bdev, (md) | FMODE_EXCL)
#elif defined(HAVE_OPEN_BDEV_EXCLUSIVE) #elif defined(HAVE_OPEN_BDEV_EXCLUSIVE)
# define vdev_bdev_open(path, md, hld) open_bdev_exclusive(path, md, hld) #define vdev_bdev_open(path, md, hld) open_bdev_exclusive(path, md, hld)
# define vdev_bdev_close(bdev, md) close_bdev_exclusive(bdev, md) #define vdev_bdev_close(bdev, md) close_bdev_exclusive(bdev, md)
#else #else
# define vdev_bdev_open(path, md, hld) open_bdev_excl(path, md, hld) #define vdev_bdev_open(path, md, hld) open_bdev_excl(path, md, hld)
# define vdev_bdev_close(bdev, md) close_bdev_excl(bdev) #define vdev_bdev_close(bdev, md) close_bdev_excl(bdev)
#endif /* HAVE_BLKDEV_GET_BY_PATH | HAVE_OPEN_BDEV_EXCLUSIVE */ #endif /* HAVE_BLKDEV_GET_BY_PATH | HAVE_OPEN_BDEV_EXCLUSIVE */
/* /*
@ -387,9 +391,9 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
* it was unused. * it was unused.
*/ */
#ifdef HAVE_1ARG_INVALIDATE_BDEV #ifdef HAVE_1ARG_INVALIDATE_BDEV
# define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev) #define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev)
#else #else
# define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev, 1) #define vdev_bdev_invalidate(bdev) invalidate_bdev(bdev, 1)
#endif /* HAVE_1ARG_INVALIDATE_BDEV */ #endif /* HAVE_1ARG_INVALIDATE_BDEV */
/* /*
@ -398,7 +402,7 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
* symbol was not exported. * symbol was not exported.
*/ */
#ifndef HAVE_LOOKUP_BDEV #ifndef HAVE_LOOKUP_BDEV
# define lookup_bdev(path) ERR_PTR(-ENOTSUP) #define lookup_bdev(path) ERR_PTR(-ENOTSUP)
#endif #endif
/* /*
@ -416,13 +420,13 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
* the logical block size interface and then the older hard sector size. * the logical block size interface and then the older hard sector size.
*/ */
#ifdef HAVE_BDEV_PHYSICAL_BLOCK_SIZE #ifdef HAVE_BDEV_PHYSICAL_BLOCK_SIZE
# define vdev_bdev_block_size(bdev) bdev_physical_block_size(bdev) #define vdev_bdev_block_size(bdev) bdev_physical_block_size(bdev)
#else #else
# ifdef HAVE_BDEV_LOGICAL_BLOCK_SIZE #ifdef HAVE_BDEV_LOGICAL_BLOCK_SIZE
# define vdev_bdev_block_size(bdev) bdev_logical_block_size(bdev) #define vdev_bdev_block_size(bdev) bdev_logical_block_size(bdev)
# else #else
# define vdev_bdev_block_size(bdev) bdev_hardsect_size(bdev) #define vdev_bdev_block_size(bdev) bdev_hardsect_size(bdev)
# endif /* HAVE_BDEV_LOGICAL_BLOCK_SIZE */ #endif /* HAVE_BDEV_LOGICAL_BLOCK_SIZE */
#endif /* HAVE_BDEV_PHYSICAL_BLOCK_SIZE */ #endif /* HAVE_BDEV_PHYSICAL_BLOCK_SIZE */
/* /*
@ -438,13 +442,13 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
* compatibility macros. * compatibility macros.
*/ */
#ifdef WRITE_FLUSH_FUA #ifdef WRITE_FLUSH_FUA
# define VDEV_WRITE_FLUSH_FUA WRITE_FLUSH_FUA #define VDEV_WRITE_FLUSH_FUA WRITE_FLUSH_FUA
# define VDEV_REQ_FLUSH REQ_FLUSH #define VDEV_REQ_FLUSH REQ_FLUSH
# define VDEV_REQ_FUA REQ_FUA #define VDEV_REQ_FUA REQ_FUA
#else #else
# define VDEV_WRITE_FLUSH_FUA WRITE_BARRIER #define VDEV_WRITE_FLUSH_FUA WRITE_BARRIER
# define VDEV_REQ_FLUSH REQ_HARDBARRIER #define VDEV_REQ_FLUSH REQ_HARDBARRIER
# define VDEV_REQ_FUA REQ_HARDBARRIER #define VDEV_REQ_FUA REQ_HARDBARRIER
#endif #endif
/* /*
@ -452,7 +456,7 @@ bio_set_flags_failfast(struct block_device *bdev, int *flags)
* Use the normal I/O patch for discards. * Use the normal I/O patch for discards.
*/ */
#ifdef REQ_DISCARD #ifdef REQ_DISCARD
# define VDEV_REQ_DISCARD REQ_DISCARD #define VDEV_REQ_DISCARD REQ_DISCARD
#endif #endif
/* /*
@ -467,7 +471,7 @@ blk_queue_discard_granularity(struct request_queue *q, unsigned int dg)
q->limits.discard_granularity = dg; q->limits.discard_granularity = dg;
} }
#else #else
#define blk_queue_discard_granularity(x, dg) ((void)0) #define blk_queue_discard_granularity(x, dg) ((void)0)
#endif /* HAVE_DISCARD_GRANULARITY */ #endif /* HAVE_DISCARD_GRANULARITY */
/* /*
@ -485,6 +489,6 @@ blk_queue_discard_granularity(struct request_queue *q, unsigned int dg)
* user space processes which don't pass this value will get EBUSY. This is * user space processes which don't pass this value will get EBUSY. This is
* currently required for the correct operation of hot spares. * currently required for the correct operation of hot spares.
*/ */
#define VDEV_HOLDER ((void *)0x2401de7) #define VDEV_HOLDER ((void *)0x2401de7)
#endif /* _ZFS_BLKDEV_H */ #endif /* _ZFS_BLKDEV_H */

View File

@ -24,15 +24,15 @@
*/ */
#ifndef _ZFS_DCACHE_H #ifndef _ZFS_DCACHE_H
#define _ZFS_DCACHE_H #define _ZFS_DCACHE_H
#include <linux/dcache.h> #include <linux/dcache.h>
#define dname(dentry) ((char *)((dentry)->d_name.name)) #define dname(dentry) ((char *)((dentry)->d_name.name))
#define dlen(dentry) ((int)((dentry)->d_name.len)) #define dlen(dentry) ((int)((dentry)->d_name.len))
#ifndef HAVE_D_MAKE_ROOT #ifndef HAVE_D_MAKE_ROOT
#define d_make_root(inode) d_alloc_root(inode) #define d_make_root(inode) d_alloc_root(inode)
#endif /* HAVE_D_MAKE_ROOT */ #endif /* HAVE_D_MAKE_ROOT */
/* /*
@ -74,9 +74,9 @@ d_clear_d_op(struct dentry *dentry)
{ {
#ifdef HAVE_D_SET_D_OP #ifdef HAVE_D_SET_D_OP
dentry->d_op = NULL; dentry->d_op = NULL;
dentry->d_flags &= dentry->d_flags &= ~(
~(DCACHE_OP_HASH | DCACHE_OP_COMPARE | DCACHE_OP_HASH | DCACHE_OP_COMPARE |
DCACHE_OP_REVALIDATE | DCACHE_OP_DELETE); DCACHE_OP_REVALIDATE | DCACHE_OP_DELETE);
#endif /* HAVE_D_SET_D_OP */ #endif /* HAVE_D_SET_D_OP */
} }

View File

@ -24,7 +24,7 @@
*/ */
#ifndef _ZFS_VFS_H #ifndef _ZFS_VFS_H
#define _ZFS_VFS_H #define _ZFS_VFS_H
/* /*
* 2.6.28 API change, * 2.6.28 API change,
@ -71,7 +71,10 @@ truncate_setsize(struct inode *ip, loff_t new)
extern atomic_long_t zfs_bdi_seq; extern atomic_long_t zfs_bdi_seq;
static inline int static inline int
bdi_setup_and_register(struct backing_dev_info *bdi,char *name,unsigned int cap) bdi_setup_and_register(
struct backing_dev_info *bdi,
char *name,
unsigned int cap)
{ {
char tmp[32]; char tmp[32];
int error; int error;
@ -99,7 +102,7 @@ bdi_setup_and_register(struct backing_dev_info *bdi,char *name,unsigned int cap)
* LOOKUP_RCU flag introduced to distinguish rcu-walk from ref-walk cases. * LOOKUP_RCU flag introduced to distinguish rcu-walk from ref-walk cases.
*/ */
#ifndef LOOKUP_RCU #ifndef LOOKUP_RCU
#define LOOKUP_RCU 0x0 #define LOOKUP_RCU 0x0
#endif /* LOOKUP_RCU */ #endif /* LOOKUP_RCU */
/* /*
@ -136,7 +139,7 @@ typedef int zpl_umode_t;
* configure check in config/kernel-clear-inode.m4 for full details. * configure check in config/kernel-clear-inode.m4 for full details.
*/ */
#if defined(HAVE_EVICT_INODE) && !defined(HAVE_CLEAR_INODE) #if defined(HAVE_EVICT_INODE) && !defined(HAVE_CLEAR_INODE)
#define clear_inode(ip) end_writeback(ip) #define clear_inode(ip) end_writeback(ip)
#endif /* HAVE_EVICT_INODE && !HAVE_CLEAR_INODE */ #endif /* HAVE_EVICT_INODE && !HAVE_CLEAR_INODE */
/* /*
@ -144,18 +147,21 @@ typedef int zpl_umode_t;
* The sget() helper function now takes the mount flags as an argument. * The sget() helper function now takes the mount flags as an argument.
*/ */
#ifdef HAVE_5ARG_SGET #ifdef HAVE_5ARG_SGET
#define zpl_sget(type, cmp, set, fl, mtd) sget(type, cmp, set, fl, mtd) #define zpl_sget(type, cmp, set, fl, mtd) sget(type, cmp, set, fl, mtd)
#else #else
#define zpl_sget(type, cmp, set, fl, mtd) sget(type, cmp, set, mtd) #define zpl_sget(type, cmp, set, fl, mtd) sget(type, cmp, set, mtd)
#endif /* HAVE_5ARG_SGET */ #endif /* HAVE_5ARG_SGET */
#define ZFS_IOC_GETFLAGS FS_IOC_GETFLAGS #define ZFS_IOC_GETFLAGS FS_IOC_GETFLAGS
#define ZFS_IOC_SETFLAGS FS_IOC_SETFLAGS #define ZFS_IOC_SETFLAGS FS_IOC_SETFLAGS
#if defined(SEEK_HOLE) && defined(SEEK_DATA) && !defined(HAVE_LSEEK_EXECUTE) #if defined(SEEK_HOLE) && defined(SEEK_DATA) && !defined(HAVE_LSEEK_EXECUTE)
static inline loff_t static inline loff_t
lseek_execute(struct file *filp, struct inode *inode, lseek_execute(
loff_t offset, loff_t maxsize) struct file *filp,
struct inode *inode,
loff_t offset,
loff_t maxsize)
{ {
if (offset < 0 && !(filp->f_mode & FMODE_UNSIGNED_OFFSET)) if (offset < 0 && !(filp->f_mode & FMODE_UNSIGNED_OFFSET))
return (-EINVAL); return (-EINVAL);
@ -186,7 +192,7 @@ lseek_execute(struct file *filp, struct inode *inode,
*/ */
#include <linux/posix_acl.h> #include <linux/posix_acl.h>
#ifndef HAVE_POSIX_ACL_CACHING #ifndef HAVE_POSIX_ACL_CACHING
#define ACL_NOT_CACHED ((void *)(-1)) #define ACL_NOT_CACHED ((void *)(-1))
#endif /* HAVE_POSIX_ACL_CACHING */ #endif /* HAVE_POSIX_ACL_CACHING */
#if defined(HAVE_POSIX_ACL_RELEASE) && !defined(HAVE_POSIX_ACL_RELEASE_GPL_ONLY) #if defined(HAVE_POSIX_ACL_RELEASE) && !defined(HAVE_POSIX_ACL_RELEASE_GPL_ONLY)
@ -224,14 +230,14 @@ zpl_set_cached_acl(struct inode *ip, int type, struct posix_acl *newer) {
if ((newer != ACL_NOT_CACHED) && (newer != NULL)) if ((newer != ACL_NOT_CACHED) && (newer != NULL))
posix_acl_dup(newer); posix_acl_dup(newer);
switch(type) { switch (type) {
case ACL_TYPE_ACCESS: case ACL_TYPE_ACCESS:
older = ip->i_acl; older = ip->i_acl;
rcu_assign_pointer(ip->i_acl,newer); rcu_assign_pointer(ip->i_acl, newer);
break; break;
case ACL_TYPE_DEFAULT: case ACL_TYPE_DEFAULT:
older = ip->i_default_acl; older = ip->i_default_acl;
rcu_assign_pointer(ip->i_default_acl,newer); rcu_assign_pointer(ip->i_default_acl, newer);
break; break;
} }
@ -276,11 +282,11 @@ posix_acl_chmod(struct posix_acl **acl, int flags, umode_t umode) {
*acl = NULL; *acl = NULL;
} }
return (error); return (error);
} }
static inline int static inline int
posix_acl_create(struct posix_acl** acl, int flags, umode_t* umodep) { posix_acl_create(struct posix_acl **acl, int flags, umode_t *umodep) {
struct posix_acl *oldacl = *acl; struct posix_acl *oldacl = *acl;
mode_t mode = *umodep; mode_t mode = *umodep;
int error; int error;

View File

@ -24,7 +24,7 @@
*/ */
#ifndef _ZFS_XATTR_H #ifndef _ZFS_XATTR_H
#define _ZFS_XATTR_H #define _ZFS_XATTR_H
#include <linux/posix_acl_xattr.h> #include <linux/posix_acl_xattr.h>
@ -47,19 +47,19 @@ typedef struct xattr_handler xattr_handler_t;
* instead of an inode, and a handler_flags argument was added. * instead of an inode, and a handler_flags argument was added.
*/ */
#ifdef HAVE_DENTRY_XATTR_GET #ifdef HAVE_DENTRY_XATTR_GET
#define ZPL_XATTR_GET_WRAPPER(fn) \ #define ZPL_XATTR_GET_WRAPPER(fn) \
static int \ static int \
fn(struct dentry *dentry, const char *name, void *buffer, size_t size, \ fn(struct dentry *dentry, const char *name, void *buffer, size_t size, \
int unused_handler_flags) \ int unused_handler_flags) \
{ \ { \
return __ ## fn(dentry->d_inode, name, buffer, size); \ return (__ ## fn(dentry->d_inode, name, buffer, size)); \
} }
#else #else
#define ZPL_XATTR_GET_WRAPPER(fn) \ #define ZPL_XATTR_GET_WRAPPER(fn) \
static int \ static int \
fn(struct inode *ip, const char *name, void *buffer, size_t size) \ fn(struct inode *ip, const char *name, void *buffer, size_t size) \
{ \ { \
return __ ## fn(ip, name, buffer, size); \ return (__ ## fn(ip, name, buffer, size)); \
} }
#endif /* HAVE_DENTRY_XATTR_GET */ #endif /* HAVE_DENTRY_XATTR_GET */
@ -69,28 +69,28 @@ fn(struct inode *ip, const char *name, void *buffer, size_t size) \
* instead of an inode, and a handler_flags argument was added. * instead of an inode, and a handler_flags argument was added.
*/ */
#ifdef HAVE_DENTRY_XATTR_SET #ifdef HAVE_DENTRY_XATTR_SET
#define ZPL_XATTR_SET_WRAPPER(fn) \ #define ZPL_XATTR_SET_WRAPPER(fn) \
static int \ static int \
fn(struct dentry *dentry, const char *name, const void *buffer, \ fn(struct dentry *dentry, const char *name, const void *buffer, \
size_t size, int flags, int unused_handler_flags) \ size_t size, int flags, int unused_handler_flags) \
{ \ { \
return __ ## fn(dentry->d_inode, name, buffer, size, flags); \ return (__ ## fn(dentry->d_inode, name, buffer, size, flags)); \
} }
#else #else
#define ZPL_XATTR_SET_WRAPPER(fn) \ #define ZPL_XATTR_SET_WRAPPER(fn) \
static int \ static int \
fn(struct inode *ip, const char *name, const void *buffer, \ fn(struct inode *ip, const char *name, const void *buffer, \
size_t size, int flags) \ size_t size, int flags) \
{ \ { \
return __ ## fn(ip, name, buffer, size, flags); \ return (__ ## fn(ip, name, buffer, size, flags)); \
} }
#endif /* HAVE_DENTRY_XATTR_SET */ #endif /* HAVE_DENTRY_XATTR_SET */
#ifdef HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY #ifdef HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY
#define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \ #define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
security_inode_init_security(ip, dip, qstr, nm, val, len) security_inode_init_security(ip, dip, qstr, nm, val, len)
#else #else
#define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \ #define zpl_security_inode_init_security(ip, dip, qstr, nm, val, len) \
security_inode_init_security(ip, dip, nm, val, len) security_inode_init_security(ip, dip, nm, val, len)
#endif /* HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY */ #endif /* HAVE_6ARGS_SECURITY_INODE_INIT_SECURITY */
@ -103,27 +103,27 @@ fn(struct inode *ip, const char *name, const void *buffer, \
static inline struct posix_acl * static inline struct posix_acl *
zpl_acl_from_xattr(const void *value, int size) zpl_acl_from_xattr(const void *value, int size)
{ {
return posix_acl_from_xattr(CRED()->user_ns, value, size); return (posix_acl_from_xattr(CRED()->user_ns, value, size));
} }
static inline int static inline int
zpl_acl_to_xattr(struct posix_acl *acl, void *value, int size) zpl_acl_to_xattr(struct posix_acl *acl, void *value, int size)
{ {
return posix_acl_to_xattr(CRED()->user_ns,acl, value, size); return (posix_acl_to_xattr(CRED()->user_ns, acl, value, size));
} }
#else #else
static inline struct posix_acl * static inline struct posix_acl *
zpl_acl_from_xattr(const void *value,int size) zpl_acl_from_xattr(const void *value, int size)
{ {
return posix_acl_from_xattr(value, size); return (posix_acl_from_xattr(value, size));
} }
static inline int static inline int
zpl_acl_to_xattr(struct posix_acl *acl, void *value, int size) zpl_acl_to_xattr(struct posix_acl *acl, void *value, int size)
{ {
return posix_acl_to_xattr(acl, value, size); return (posix_acl_to_xattr(acl, value, size));
} }
#endif /* HAVE_POSIX_ACL_FROM_XATTR_USERNS */ #endif /* HAVE_POSIX_ACL_FROM_XATTR_USERNS */

View File

@ -142,9 +142,9 @@ typedef struct dmu_tx_stats {
extern dmu_tx_stats_t dmu_tx_stats; extern dmu_tx_stats_t dmu_tx_stats;
#define DMU_TX_STAT_INCR(stat, val) \ #define DMU_TX_STAT_INCR(stat, val) \
atomic_add_64(&dmu_tx_stats.stat.value.ui64, (val)); atomic_add_64(&dmu_tx_stats.stat.value.ui64, (val));
#define DMU_TX_STAT_BUMP(stat) \ #define DMU_TX_STAT_BUMP(stat) \
DMU_TX_STAT_INCR(stat, 1); DMU_TX_STAT_INCR(stat, 1);
/* /*

View File

@ -39,7 +39,7 @@ extern "C" {
#define FM_EREPORT_ZFS_CONFIG_SYNC "config.sync" #define FM_EREPORT_ZFS_CONFIG_SYNC "config.sync"
#define FM_EREPORT_ZFS_POOL "zpool" #define FM_EREPORT_ZFS_POOL "zpool"
#define FM_EREPORT_ZFS_POOL_DESTROY "zpool.destroy" #define FM_EREPORT_ZFS_POOL_DESTROY "zpool.destroy"
#define FM_EREPORT_ZFS_POOL_REGUID "zpool.reguid" #define FM_EREPORT_ZFS_POOL_REGUID "zpool.reguid"
#define FM_EREPORT_ZFS_DEVICE_UNKNOWN "vdev.unknown" #define FM_EREPORT_ZFS_DEVICE_UNKNOWN "vdev.unknown"
#define FM_EREPORT_ZFS_DEVICE_OPEN_FAILED "vdev.open_failed" #define FM_EREPORT_ZFS_DEVICE_OPEN_FAILED "vdev.open_failed"
#define FM_EREPORT_ZFS_DEVICE_CORRUPT_DATA "vdev.corrupt_data" #define FM_EREPORT_ZFS_DEVICE_CORRUPT_DATA "vdev.corrupt_data"

View File

@ -71,22 +71,22 @@ typedef struct erpt_dump {
#ifdef _KERNEL #ifdef _KERNEL
#define ZEVENT_SHUTDOWN 0x1 #define ZEVENT_SHUTDOWN 0x1
typedef void zevent_cb_t(nvlist_t *, nvlist_t *); typedef void zevent_cb_t(nvlist_t *, nvlist_t *);
typedef struct zevent_s { typedef struct zevent_s {
nvlist_t *ev_nvl; /* protected by the zevent_lock */ nvlist_t *ev_nvl; /* protected by the zevent_lock */
nvlist_t *ev_detector; /* " */ nvlist_t *ev_detector; /* " */
list_t ev_ze_list; /* " */ list_t ev_ze_list; /* " */
list_node_t ev_node; /* " */ list_node_t ev_node; /* " */
zevent_cb_t *ev_cb; /* " */ zevent_cb_t *ev_cb; /* " */
} zevent_t; } zevent_t;
typedef struct zfs_zevent { typedef struct zfs_zevent {
zevent_t *ze_zevent; /* protected by the zevent_lock */ zevent_t *ze_zevent; /* protected by the zevent_lock */
list_node_t ze_node; /* " */ list_node_t ze_node; /* " */
uint64_t ze_dropped; /* " */ uint64_t ze_dropped; /* " */
} zfs_zevent_t; } zfs_zevent_t;
extern void fm_init(void); extern void fm_init(void);

View File

@ -859,7 +859,7 @@ typedef enum zfs_ioc {
/* /*
* zvol ioctl to get dataset name * zvol ioctl to get dataset name
*/ */
#define BLKZNAME _IOR(0x12,125,char[ZFS_MAXNAMELEN]) #define BLKZNAME _IOR(0x12, 125, char[ZFS_MAXNAMELEN])
/* /*
* Internal SPA load state. Used by FMA diagnosis engine. * Internal SPA load state. Used by FMA diagnosis engine.

View File

@ -26,7 +26,7 @@
*/ */
#ifndef _SYS_VDEV_DISK_H #ifndef _SYS_VDEV_DISK_H
#define _SYS_VDEV_DISK_H #define _SYS_VDEV_DISK_H
#ifdef _KERNEL #ifdef _KERNEL
#include <sys/vdev.h> #include <sys/vdev.h>

View File

@ -225,7 +225,7 @@ typedef void (*thread_func_t)(void *);
typedef void (*thread_func_arg_t)(void *); typedef void (*thread_func_arg_t)(void *);
typedef pthread_t kt_did_t; typedef pthread_t kt_did_t;
#define kpreempt(x) ((void)0) #define kpreempt(x) ((void)0)
typedef struct kthread { typedef struct kthread {
kt_did_t t_tid; kt_did_t t_tid;
@ -711,7 +711,7 @@ void ksiddomain_rele(ksiddomain_t *);
#define ddi_log_sysevent(_a, _b, _c, _d, _e, _f, _g) \ #define ddi_log_sysevent(_a, _b, _c, _d, _e, _f, _g) \
sysevent_post_event(_c, _d, _b, "libzpool", _e, _f) sysevent_post_event(_c, _d, _b, "libzpool", _e, _f)
#define zfs_sleep_until(wakeup) \ #define zfs_sleep_until(wakeup) \
do { \ do { \
hrtime_t delta = wakeup - gethrtime(); \ hrtime_t delta = wakeup - gethrtime(); \
struct timespec ts; \ struct timespec ts; \

View File

@ -75,7 +75,7 @@ extern int zfs_recover;
* filtered based on the zfs_flags variable. * filtered based on the zfs_flags variable.
*/ */
#else #else
#define dprintf(...) \ #define dprintf(...) \
if (zfs_flags & ZFS_DEBUG_DPRINTF) \ if (zfs_flags & ZFS_DEBUG_DPRINTF) \
__dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__) __dprintf(__FILE__, __func__, __LINE__, __VA_ARGS__)
@ -92,7 +92,7 @@ typedef struct zfs_dbgmsg {
extern void zfs_dbgmsg_init(void); extern void zfs_dbgmsg_init(void);
extern void zfs_dbgmsg_fini(void); extern void zfs_dbgmsg_fini(void);
#if defined(_KERNEL) && defined(__linux__) #if defined(_KERNEL) && defined(__linux__)
#define zfs_dbgmsg(...) dprintf(__VA_ARGS__) #define zfs_dbgmsg(...) dprintf(__VA_ARGS__)
#else #else
extern void zfs_dbgmsg(const char *fmt, ...); extern void zfs_dbgmsg(const char *fmt, ...);
extern void zfs_dbgmsg_print(const char *tag); extern void zfs_dbgmsg_print(const char *tag);

View File

@ -27,7 +27,7 @@
/* /*
* Generic wrapper to sleep until a given time. * Generic wrapper to sleep until a given time.
*/ */
#define zfs_sleep_until(wakeup) \ #define zfs_sleep_until(wakeup) \
do { \ do { \
hrtime_t delta = wakeup - gethrtime(); \ hrtime_t delta = wakeup - gethrtime(); \
\ \

View File

@ -368,7 +368,7 @@ enum zfsdev_state_type {
}; };
typedef struct zfsdev_state { typedef struct zfsdev_state {
list_node_t zs_next; /* next zfsdev_state_t link */ list_node_t zs_next; /* next zfsdev_state_t link */
struct file *zs_file; /* associated file struct */ struct file *zs_file; /* associated file struct */
minor_t zs_minor; /* made up minor number */ minor_t zs_minor; /* made up minor number */
void *zs_onexit; /* onexit data */ void *zs_onexit; /* onexit data */

View File

@ -128,8 +128,8 @@ typedef struct znode_phys {
#ifdef _KERNEL #ifdef _KERNEL
#define DXATTR_MAX_ENTRY_SIZE (32768) #define DXATTR_MAX_ENTRY_SIZE (32768)
#define DXATTR_MAX_SA_SIZE (SPA_MAXBLOCKSIZE >> 1) #define DXATTR_MAX_SA_SIZE (SPA_MAXBLOCKSIZE >> 1)
int zfs_sa_readlink(struct znode *, uio_t *); int zfs_sa_readlink(struct znode *, uio_t *);
void zfs_sa_symlink(struct znode *, char *link, int len, dmu_tx_t *); void zfs_sa_symlink(struct znode *, char *link, int len, dmu_tx_t *);

View File

@ -70,7 +70,7 @@ typedef struct zfs_sb {
krwlock_t z_teardown_inactive_lock; krwlock_t z_teardown_inactive_lock;
list_t z_all_znodes; /* all znodes in the fs */ list_t z_all_znodes; /* all znodes in the fs */
uint64_t z_nr_znodes; /* number of znodes in the fs */ uint64_t z_nr_znodes; /* number of znodes in the fs */
unsigned long z_rollback_time;/* last online rollback time */ unsigned long z_rollback_time; /* last online rollback time */
kmutex_t z_znodes_lock; /* lock for z_all_znodes */ kmutex_t z_znodes_lock; /* lock for z_all_znodes */
struct inode *z_ctldir; /* .zfs directory inode */ struct inode *z_ctldir; /* .zfs directory inode */
avl_tree_t z_ctldir_snaps; /* .zfs/snapshot entries */ avl_tree_t z_ctldir_snaps; /* .zfs/snapshot entries */
@ -102,7 +102,7 @@ typedef struct zfs_sb {
* this the inode->i_nlink member is defined as an unsigned int. To be * this the inode->i_nlink member is defined as an unsigned int. To be
* safe we use 2^31-1 as the limit. * safe we use 2^31-1 as the limit.
*/ */
#define ZFS_LINK_MAX ((1U << 31) - 1U) #define ZFS_LINK_MAX ((1U << 31) - 1U)
/* /*
* Normal filesystems (those not under .zfs/snapshot) have a total * Normal filesystems (those not under .zfs/snapshot) have a total

View File

@ -210,8 +210,8 @@ typedef struct znode {
kmutex_t z_acl_lock; /* acl data lock */ kmutex_t z_acl_lock; /* acl data lock */
zfs_acl_t *z_acl_cached; /* cached acl */ zfs_acl_t *z_acl_cached; /* cached acl */
krwlock_t z_xattr_lock; /* xattr data lock */ krwlock_t z_xattr_lock; /* xattr data lock */
nvlist_t *z_xattr_cached;/* cached xattrs */ nvlist_t *z_xattr_cached; /* cached xattrs */
struct znode *z_xattr_parent;/* xattr parent znode */ struct znode *z_xattr_parent; /* xattr parent znode */
list_node_t z_link_node; /* all znodes in fs link */ list_node_t z_link_node; /* all znodes in fs link */
sa_handle_t *z_sa_hdl; /* handle to sa data */ sa_handle_t *z_sa_hdl; /* handle to sa data */
boolean_t z_is_sa; /* are we native sa? */ boolean_t z_is_sa; /* are we native sa? */

View File

@ -430,9 +430,9 @@ typedef struct zil_stats {
extern zil_stats_t zil_stats; extern zil_stats_t zil_stats;
#define ZIL_STAT_INCR(stat, val) \ #define ZIL_STAT_INCR(stat, val) \
atomic_add_64(&zil_stats.stat.value.ui64, (val)); atomic_add_64(&zil_stats.stat.value.ui64, (val));
#define ZIL_STAT_BUMP(stat) \ #define ZIL_STAT_BUMP(stat) \
ZIL_STAT_INCR(stat, 1); ZIL_STAT_INCR(stat, 1);
typedef int zil_parse_blk_func_t(zilog_t *zilog, blkptr_t *bp, void *arg, typedef int zil_parse_blk_func_t(zilog_t *zilog, blkptr_t *bp, void *arg,

View File

@ -41,7 +41,7 @@ extern "C" {
typedef struct lwb { typedef struct lwb {
zilog_t *lwb_zilog; /* back pointer to log struct */ zilog_t *lwb_zilog; /* back pointer to log struct */
blkptr_t lwb_blk; /* on disk address of this log blk */ blkptr_t lwb_blk; /* on disk address of this log blk */
boolean_t lwb_fastwrite; /* is blk marked for fastwrite? */ boolean_t lwb_fastwrite; /* is blk marked for fastwrite? */
int lwb_nused; /* # used bytes in buffer */ int lwb_nused; /* # used bytes in buffer */
int lwb_sz; /* size of block and buffer */ int lwb_sz; /* size of block and buffer */
char *lwb_buf; /* log write buffer */ char *lwb_buf; /* log write buffer */

View File

@ -124,7 +124,7 @@ enum zio_compress {
/* /*
* Default Linux timeout for a sd device. * Default Linux timeout for a sd device.
*/ */
#define ZIO_DELAY_MAX (30 * MILLISEC) #define ZIO_DELAY_MAX (30 * MILLISEC)
#define ZIO_FAILURE_MODE_WAIT 0 #define ZIO_FAILURE_MODE_WAIT 0
#define ZIO_FAILURE_MODE_CONTINUE 1 #define ZIO_FAILURE_MODE_CONTINUE 1

View File

@ -77,7 +77,7 @@ extern int zpl_set_acl(struct inode *ip, int type, struct posix_acl *acl);
extern struct posix_acl *zpl_get_acl(struct inode *ip, int type); extern struct posix_acl *zpl_get_acl(struct inode *ip, int type);
#if !defined(HAVE_GET_ACL) #if !defined(HAVE_GET_ACL)
#if defined(HAVE_CHECK_ACL_WITH_FLAGS) #if defined(HAVE_CHECK_ACL_WITH_FLAGS)
extern int zpl_check_acl(struct inode *inode, int mask,unsigned int flags); extern int zpl_check_acl(struct inode *inode, int mask, unsigned int flags);
#elif defined(HAVE_CHECK_ACL) #elif defined(HAVE_CHECK_ACL)
extern int zpl_check_acl(struct inode *inode, int mask); extern int zpl_check_acl(struct inode *inode, int mask);
#elif defined(HAVE_PERMISSION_WITH_NAMEIDATA) #elif defined(HAVE_PERMISSION_WITH_NAMEIDATA)
@ -122,7 +122,7 @@ extern const struct inode_operations zpl_ops_shares;
#ifdef HAVE_VFS_ITERATE #ifdef HAVE_VFS_ITERATE
#define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \ #define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
.actor = _actor, \ .actor = _actor, \
.pos = _pos, \ .pos = _pos, \
} }
@ -135,7 +135,7 @@ typedef struct dir_context {
loff_t pos; loff_t pos;
} dir_context_t; } dir_context_t;
#define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \ #define DIR_CONTEXT_INIT(_dirent, _actor, _pos) { \
.dirent = _dirent, \ .dirent = _dirent, \
.actor = _actor, \ .actor = _actor, \
.pos = _pos, \ .pos = _pos, \
@ -145,21 +145,22 @@ static inline bool
dir_emit(struct dir_context *ctx, const char *name, int namelen, dir_emit(struct dir_context *ctx, const char *name, int namelen,
uint64_t ino, unsigned type) uint64_t ino, unsigned type)
{ {
return ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type) == 0; return (ctx->actor(ctx->dirent, name, namelen, ctx->pos, ino, type)
== 0);
} }
static inline bool static inline bool
dir_emit_dot(struct file *file, struct dir_context *ctx) dir_emit_dot(struct file *file, struct dir_context *ctx)
{ {
return ctx->actor(ctx->dirent, ".", 1, ctx->pos, return (ctx->actor(ctx->dirent, ".", 1, ctx->pos,
file->f_path.dentry->d_inode->i_ino, DT_DIR) == 0; file->f_path.dentry->d_inode->i_ino, DT_DIR) == 0);
} }
static inline bool static inline bool
dir_emit_dotdot(struct file *file, struct dir_context *ctx) dir_emit_dotdot(struct file *file, struct dir_context *ctx)
{ {
return ctx->actor(ctx->dirent, "..", 2, ctx->pos, return (ctx->actor(ctx->dirent, "..", 2, ctx->pos,
parent_ino(file->f_path.dentry), DT_DIR) == 0; parent_ino(file->f_path.dentry), DT_DIR) == 0);
} }
static inline bool static inline bool
@ -167,15 +168,15 @@ dir_emit_dots(struct file *file, struct dir_context *ctx)
{ {
if (ctx->pos == 0) { if (ctx->pos == 0) {
if (!dir_emit_dot(file, ctx)) if (!dir_emit_dot(file, ctx))
return false; return (false);
ctx->pos = 1; ctx->pos = 1;
} }
if (ctx->pos == 1) { if (ctx->pos == 1) {
if (!dir_emit_dotdot(file, ctx)) if (!dir_emit_dotdot(file, ctx))
return false; return (false);
ctx->pos = 2; ctx->pos = 2;
} }
return true; return (true);
} }
#endif /* HAVE_VFS_ITERATE */ #endif /* HAVE_VFS_ITERATE */

View File

@ -1,4 +1,4 @@
/*****************************************************************************\ /*
* ZPIOS is a heavily modified version of the original PIOS test code. * ZPIOS is a heavily modified version of the original PIOS test code.
* It is designed to have the test code running in the Linux kernel * It is designed to have the test code running in the Linux kernel
* against ZFS while still being flexibly controled from user space. * against ZFS while still being flexibly controled from user space.
@ -29,48 +29,49 @@
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with ZPIOS. If not, see <http://www.gnu.org/licenses/>. * with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
\*****************************************************************************/ */
#ifndef _ZPIOS_CTL_H #ifndef _ZPIOS_CTL_H
#define _ZPIOS_CTL_H #define _ZPIOS_CTL_H
/* Contains shared definitions which both the userspace /*
* Contains shared definitions which both the userspace
* and kernelspace portions of zpios must agree on. * and kernelspace portions of zpios must agree on.
*/ */
#ifndef _KERNEL #ifndef _KERNEL
#include <stdint.h> #include <stdint.h>
#endif #endif
#define ZPIOS_MAJOR 232 /* XXX - Arbitrary */ #define ZPIOS_MAJOR 232 /* XXX - Arbitrary */
#define ZPIOS_MINORS 1 #define ZPIOS_MINORS 1
#define ZPIOS_NAME "zpios" #define ZPIOS_NAME "zpios"
#define ZPIOS_DEV "/dev/zpios" #define ZPIOS_DEV "/dev/zpios"
#define DMU_IO 0x01 #define DMU_IO 0x01
#define DMU_WRITE 0x0001 #define DMU_WRITE 0x0001
#define DMU_READ 0x0002 #define DMU_READ 0x0002
#define DMU_VERIFY 0x0004 #define DMU_VERIFY 0x0004
#define DMU_REMOVE 0x0008 #define DMU_REMOVE 0x0008
#define DMU_FPP 0x0010 #define DMU_FPP 0x0010
#define DMU_WRITE_ZC 0x0020 /* Incompatible w/DMU_VERIFY */ #define DMU_WRITE_ZC 0x0020 /* Incompatible w/DMU_VERIFY */
#define DMU_READ_ZC 0x0040 /* Incompatible w/DMU_VERIFY */ #define DMU_READ_ZC 0x0040 /* Incompatible w/DMU_VERIFY */
#define DMU_WRITE_NOWAIT 0x0080 #define DMU_WRITE_NOWAIT 0x0080
#define DMU_READ_NOPF 0x0100 #define DMU_READ_NOPF 0x0100
#define ZPIOS_NAME_SIZE 16 #define ZPIOS_NAME_SIZE 16
#define ZPIOS_PATH_SIZE 128 #define ZPIOS_PATH_SIZE 128
#define PHASE_PRE_RUN "pre-run" #define PHASE_PRE_RUN "pre-run"
#define PHASE_PRE_CREATE "pre-create" #define PHASE_PRE_CREATE "pre-create"
#define PHASE_PRE_WRITE "pre-write" #define PHASE_PRE_WRITE "pre-write"
#define PHASE_PRE_READ "pre-read" #define PHASE_PRE_READ "pre-read"
#define PHASE_PRE_REMOVE "pre-remove" #define PHASE_PRE_REMOVE "pre-remove"
#define PHASE_POST_RUN "post-run" #define PHASE_POST_RUN "post-run"
#define PHASE_POST_CREATE "post-create" #define PHASE_POST_CREATE "post-create"
#define PHASE_POST_WRITE "post-write" #define PHASE_POST_WRITE "post-write"
#define PHASE_POST_READ "post-read" #define PHASE_POST_READ "post-read"
#define PHASE_POST_REMOVE "post-remove" #define PHASE_POST_REMOVE "post-remove"
#define ZPIOS_CFG_MAGIC 0x87237190U #define ZPIOS_CFG_MAGIC 0x87237190U
typedef struct zpios_cfg { typedef struct zpios_cfg {
@ -117,27 +118,28 @@ typedef struct zpios_cmd {
uint32_t cmd_chunk_noise; /* Chunk noise */ uint32_t cmd_chunk_noise; /* Chunk noise */
uint32_t cmd_thread_delay; /* Thread delay */ uint32_t cmd_thread_delay; /* Thread delay */
uint32_t cmd_flags; /* Test flags */ uint32_t cmd_flags; /* Test flags */
char cmd_pre[ZPIOS_PATH_SIZE]; /* Pre-exec hook */ char cmd_pre[ZPIOS_PATH_SIZE]; /* Pre-exec hook */
char cmd_post[ZPIOS_PATH_SIZE]; /* Post-exec hook */ char cmd_post[ZPIOS_PATH_SIZE]; /* Post-exec hook */
char cmd_log[ZPIOS_PATH_SIZE]; /* Requested log dir */ char cmd_log[ZPIOS_PATH_SIZE]; /* Requested log dir */
uint64_t cmd_data_size; /* Opaque data size */ uint64_t cmd_data_size; /* Opaque data size */
char cmd_data_str[0]; /* Opaque data region */ char cmd_data_str[0]; /* Opaque data region */
} zpios_cmd_t; } zpios_cmd_t;
/* Valid ioctls */ /* Valid ioctls */
#define ZPIOS_CFG _IOWR('f', 101, zpios_cfg_t) #define ZPIOS_CFG _IOWR('f', 101, zpios_cfg_t)
#define ZPIOS_CMD _IOWR('f', 102, zpios_cmd_t) #define ZPIOS_CMD _IOWR('f', 102, zpios_cmd_t)
/* Valid configuration commands */ /* Valid configuration commands */
#define ZPIOS_CFG_BUFFER_CLEAR 0x001 /* Clear text buffer */ #define ZPIOS_CFG_BUFFER_CLEAR 0x001 /* Clear text buffer */
#define ZPIOS_CFG_BUFFER_SIZE 0x002 /* Resize text buffer */ #define ZPIOS_CFG_BUFFER_SIZE 0x002 /* Resize text buffer */
#ifndef NSEC_PER_SEC #ifndef NSEC_PER_SEC
#define NSEC_PER_SEC 1000000000L #define NSEC_PER_SEC 1000000000L
#endif #endif
static inline static inline
void zpios_timespec_normalize(zpios_timespec_t *ts, uint32_t sec, uint32_t nsec) void
zpios_timespec_normalize(zpios_timespec_t *ts, uint32_t sec, uint32_t nsec)
{ {
while (nsec >= NSEC_PER_SEC) { while (nsec >= NSEC_PER_SEC) {
nsec -= NSEC_PER_SEC; nsec -= NSEC_PER_SEC;
@ -152,27 +154,30 @@ void zpios_timespec_normalize(zpios_timespec_t *ts, uint32_t sec, uint32_t nsec)
} }
static inline static inline
zpios_timespec_t zpios_timespec_add(zpios_timespec_t lhs, zpios_timespec_t rhs) zpios_timespec_t
zpios_timespec_add(zpios_timespec_t lhs, zpios_timespec_t rhs)
{ {
zpios_timespec_t ts_delta; zpios_timespec_t ts_delta;
zpios_timespec_normalize(&ts_delta, lhs.ts_sec + rhs.ts_sec, zpios_timespec_normalize(&ts_delta, lhs.ts_sec + rhs.ts_sec,
lhs.ts_nsec + rhs.ts_nsec); lhs.ts_nsec + rhs.ts_nsec);
return ts_delta; return (ts_delta);
} }
static inline static inline
zpios_timespec_t zpios_timespec_sub(zpios_timespec_t lhs, zpios_timespec_t rhs) zpios_timespec_t
zpios_timespec_sub(zpios_timespec_t lhs, zpios_timespec_t rhs)
{ {
zpios_timespec_t ts_delta; zpios_timespec_t ts_delta;
zpios_timespec_normalize(&ts_delta, lhs.ts_sec - rhs.ts_sec, zpios_timespec_normalize(&ts_delta, lhs.ts_sec - rhs.ts_sec,
lhs.ts_nsec - rhs.ts_nsec); lhs.ts_nsec - rhs.ts_nsec);
return ts_delta; return (ts_delta);
} }
#ifdef _KERNEL #ifdef _KERNEL
static inline static inline
zpios_timespec_t zpios_timespec_now(void) zpios_timespec_t
zpios_timespec_now(void)
{ {
zpios_timespec_t zts_now; zpios_timespec_t zts_now;
struct timespec ts_now; struct timespec ts_now;
@ -181,16 +186,18 @@ zpios_timespec_t zpios_timespec_now(void)
zts_now.ts_sec = ts_now.tv_sec; zts_now.ts_sec = ts_now.tv_sec;
zts_now.ts_nsec = ts_now.tv_nsec; zts_now.ts_nsec = ts_now.tv_nsec;
return zts_now; return (zts_now);
} }
#else #else
static inline static inline
double zpios_timespec_to_double(zpios_timespec_t ts) double
zpios_timespec_to_double(zpios_timespec_t ts)
{ {
return ((double)(ts.ts_sec) + return
((double)(ts.ts_nsec) / (double)(NSEC_PER_SEC))); ((double)(ts.ts_sec) +
((double)(ts.ts_nsec) / (double)(NSEC_PER_SEC)));
} }
#endif /* _KERNEL */ #endif /* _KERNEL */

View File

@ -1,4 +1,4 @@
/*****************************************************************************\ /*
* ZPIOS is a heavily modified version of the original PIOS test code. * ZPIOS is a heavily modified version of the original PIOS test code.
* It is designed to have the test code running in the Linux kernel * It is designed to have the test code running in the Linux kernel
* against ZFS while still being flexibly controled from user space. * against ZFS while still being flexibly controled from user space.
@ -29,14 +29,14 @@
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with ZPIOS. If not, see <http://www.gnu.org/licenses/>. * with ZPIOS. If not, see <http://www.gnu.org/licenses/>.
\*****************************************************************************/ */
#ifndef _ZPIOS_INTERNAL_H #ifndef _ZPIOS_INTERNAL_H
#define _ZPIOS_INTERNAL_H #define _ZPIOS_INTERNAL_H
#include "zpios-ctl.h" #include "zpios-ctl.h"
#define OBJ_SIZE 64 #define OBJ_SIZE 64
struct run_args; struct run_args;
@ -51,7 +51,7 @@ typedef struct thread_data {
int thread_no; int thread_no;
int rc; int rc;
zpios_stats_t stats; zpios_stats_t stats;
kmutex_t lock; kmutex_t lock;
} thread_data_t; } thread_data_t;
/* region for IO data */ /* region for IO data */
@ -62,7 +62,7 @@ typedef struct zpios_region {
__u64 max_offset; __u64 max_offset;
dmu_obj_t obj; dmu_obj_t obj;
zpios_stats_t stats; zpios_stats_t stats;
kmutex_t lock; kmutex_t lock;
} zpios_region_t; } zpios_region_t;
/* arguments for one run */ /* arguments for one run */
@ -85,9 +85,9 @@ typedef struct run_args {
/* Control data */ /* Control data */
objset_t *os; objset_t *os;
wait_queue_head_t waitq; wait_queue_head_t waitq;
volatile uint64_t threads_done; volatile uint64_t threads_done;
kmutex_t lock_work; kmutex_t lock_work;
kmutex_t lock_ctl; kmutex_t lock_ctl;
__u32 region_next; __u32 region_next;
@ -99,40 +99,14 @@ typedef struct run_args {
zpios_region_t regions[0]; /* Must be last element */ zpios_region_t regions[0]; /* Must be last element */
} run_args_t; } run_args_t;
#define ZPIOS_INFO_BUFFER_SIZE 65536 #define ZPIOS_INFO_BUFFER_SIZE 65536
#define ZPIOS_INFO_BUFFER_REDZONE 1024 #define ZPIOS_INFO_BUFFER_REDZONE 1024
typedef struct zpios_info { typedef struct zpios_info {
spinlock_t info_lock; spinlock_t info_lock;
int info_size; int info_size;
char *info_buffer; char *info_buffer;
char *info_head; /* Internal kernel use only */ char *info_head; /* Internal kernel use only */
} zpios_info_t; } zpios_info_t;
#define zpios_print(file, format, args...) \
({ zpios_info_t *_info_ = (zpios_info_t *)file->private_data; \
int _rc_; \
\
ASSERT(_info_); \
ASSERT(_info_->info_buffer); \
\
spin_lock(&_info_->info_lock); \
\
/* Don't allow the kernel to start a write in the red zone */ \
if ((int)(_info_->info_head - _info_->info_buffer) > \
(_info_->info_size - ZPIOS_INFO_BUFFER_REDZONE)) { \
_rc_ = -EOVERFLOW; \
} else { \
_rc_ = sprintf(_info_->info_head, format, args); \
if (_rc_ >= 0) \
_info_->info_head += _rc_; \
} \
\
spin_unlock(&_info_->info_lock); \
_rc_; \
})
#define zpios_vprint(file, test, format, args...) \
zpios_print(file, "%*s: " format, ZPIOS_NAME_SIZE, test, args)
#endif /* _ZPIOS_INTERNAL_H */ #endif /* _ZPIOS_INTERNAL_H */

View File

@ -132,8 +132,8 @@ read_disk_info(int fd, diskaddr_t *capacity, uint_t *lbsize)
int sector_size; int sector_size;
unsigned long long capacity_size; unsigned long long capacity_size;
if (ioctl(fd, BLKSSZGET, &sector_size) < 0) if (ioctl(fd, BLKSSZGET, &sector_size) < 0)
return (-1); return (-1);
if (ioctl(fd, BLKGETSIZE64, &capacity_size) < 0) if (ioctl(fd, BLKGETSIZE64, &capacity_size) < 0)
return (-1); return (-1);
@ -152,7 +152,7 @@ efi_get_info(int fd, struct dk_cinfo *dki_info)
char *dev_path; char *dev_path;
int rval = 0; int rval = 0;
memset(dki_info, 0, sizeof(*dki_info)); memset(dki_info, 0, sizeof (*dki_info));
path = calloc(PATH_MAX, 1); path = calloc(PATH_MAX, 1);
if (path == NULL) if (path == NULL)
@ -182,44 +182,44 @@ efi_get_info(int fd, struct dk_cinfo *dki_info)
strcpy(dki_info->dki_cname, "sd"); strcpy(dki_info->dki_cname, "sd");
dki_info->dki_ctype = DKC_SCSI_CCS; dki_info->dki_ctype = DKC_SCSI_CCS;
rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu", rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu",
dki_info->dki_dname, dki_info->dki_dname,
&dki_info->dki_partition); &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/hd", 7) == 0)) { } else if ((strncmp(dev_path, "/dev/hd", 7) == 0)) {
strcpy(dki_info->dki_cname, "hd"); strcpy(dki_info->dki_cname, "hd");
dki_info->dki_ctype = DKC_DIRECT; dki_info->dki_ctype = DKC_DIRECT;
rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu", rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu",
dki_info->dki_dname, dki_info->dki_dname,
&dki_info->dki_partition); &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/md", 7) == 0)) { } else if ((strncmp(dev_path, "/dev/md", 7) == 0)) {
strcpy(dki_info->dki_cname, "pseudo"); strcpy(dki_info->dki_cname, "pseudo");
dki_info->dki_ctype = DKC_MD; dki_info->dki_ctype = DKC_MD;
rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu", rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu",
dki_info->dki_dname, dki_info->dki_dname,
&dki_info->dki_partition); &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/vd", 7) == 0)) { } else if ((strncmp(dev_path, "/dev/vd", 7) == 0)) {
strcpy(dki_info->dki_cname, "vd"); strcpy(dki_info->dki_cname, "vd");
dki_info->dki_ctype = DKC_MD; dki_info->dki_ctype = DKC_MD;
rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu", rval = sscanf(dev_path, "/dev/%[a-zA-Z]%hu",
dki_info->dki_dname, dki_info->dki_dname,
&dki_info->dki_partition); &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/dm-", 8) == 0)) { } else if ((strncmp(dev_path, "/dev/dm-", 8) == 0)) {
strcpy(dki_info->dki_cname, "pseudo"); strcpy(dki_info->dki_cname, "pseudo");
dki_info->dki_ctype = DKC_VBD; dki_info->dki_ctype = DKC_VBD;
rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9-]p%hu", rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9-]p%hu",
dki_info->dki_dname, dki_info->dki_dname,
&dki_info->dki_partition); &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/ram", 8) == 0)) { } else if ((strncmp(dev_path, "/dev/ram", 8) == 0)) {
strcpy(dki_info->dki_cname, "pseudo"); strcpy(dki_info->dki_cname, "pseudo");
dki_info->dki_ctype = DKC_PCMCIA_MEM; dki_info->dki_ctype = DKC_PCMCIA_MEM;
rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu", rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu",
dki_info->dki_dname, dki_info->dki_dname,
&dki_info->dki_partition); &dki_info->dki_partition);
} else if ((strncmp(dev_path, "/dev/loop", 9) == 0)) { } else if ((strncmp(dev_path, "/dev/loop", 9) == 0)) {
strcpy(dki_info->dki_cname, "pseudo"); strcpy(dki_info->dki_cname, "pseudo");
dki_info->dki_ctype = DKC_VBD; dki_info->dki_ctype = DKC_VBD;
rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu", rval = sscanf(dev_path, "/dev/%[a-zA-Z0-9]p%hu",
dki_info->dki_dname, dki_info->dki_dname,
&dki_info->dki_partition); &dki_info->dki_partition);
} else { } else {
strcpy(dki_info->dki_dname, "unknown"); strcpy(dki_info->dki_dname, "unknown");
strcpy(dki_info->dki_cname, "unknown"); strcpy(dki_info->dki_cname, "unknown");
@ -395,10 +395,10 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc)
*/ */
if (read_disk_info(fd, &capacity, &lbsize) == -1) { if (read_disk_info(fd, &capacity, &lbsize) == -1) {
if (efi_debug) if (efi_debug)
fprintf(stderr,"unable to read disk info: %d",errno); fprintf(stderr, "unable to read disk info: %d", errno);
errno = EIO; errno = EIO;
return -1; return (-1);
} }
switch (cmd) { switch (cmd) {
@ -406,7 +406,7 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc)
if (lbsize == 0) { if (lbsize == 0) {
if (efi_debug) if (efi_debug)
(void) fprintf(stderr, "DKIOCGETEFI assuming " (void) fprintf(stderr, "DKIOCGETEFI assuming "
"LBA %d bytes\n", DEV_BSIZE); "LBA %d bytes\n", DEV_BSIZE);
lbsize = DEV_BSIZE; lbsize = DEV_BSIZE;
} }
@ -415,24 +415,24 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc)
if (error == -1) { if (error == -1) {
if (efi_debug) if (efi_debug)
(void) fprintf(stderr, "DKIOCGETEFI lseek " (void) fprintf(stderr, "DKIOCGETEFI lseek "
"error: %d\n", errno); "error: %d\n", errno);
return error; return (error);
} }
error = read(fd, data, dk_ioc->dki_length); error = read(fd, data, dk_ioc->dki_length);
if (error == -1) { if (error == -1) {
if (efi_debug) if (efi_debug)
(void) fprintf(stderr, "DKIOCGETEFI read " (void) fprintf(stderr, "DKIOCGETEFI read "
"error: %d\n", errno); "error: %d\n", errno);
return error; return (error);
} }
if (error != dk_ioc->dki_length) { if (error != dk_ioc->dki_length) {
if (efi_debug) if (efi_debug)
(void) fprintf(stderr, "DKIOCGETEFI short " (void) fprintf(stderr, "DKIOCGETEFI short "
"read of %d bytes\n", error); "read of %d bytes\n", error);
errno = EIO; errno = EIO;
return -1; return (-1);
} }
error = 0; error = 0;
break; break;
@ -441,43 +441,43 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc)
if (lbsize == 0) { if (lbsize == 0) {
if (efi_debug) if (efi_debug)
(void) fprintf(stderr, "DKIOCSETEFI unknown " (void) fprintf(stderr, "DKIOCSETEFI unknown "
"LBA size\n"); "LBA size\n");
errno = EIO; errno = EIO;
return -1; return (-1);
} }
error = lseek(fd, dk_ioc->dki_lba * lbsize, SEEK_SET); error = lseek(fd, dk_ioc->dki_lba * lbsize, SEEK_SET);
if (error == -1) { if (error == -1) {
if (efi_debug) if (efi_debug)
(void) fprintf(stderr, "DKIOCSETEFI lseek " (void) fprintf(stderr, "DKIOCSETEFI lseek "
"error: %d\n", errno); "error: %d\n", errno);
return error; return (error);
} }
error = write(fd, data, dk_ioc->dki_length); error = write(fd, data, dk_ioc->dki_length);
if (error == -1) { if (error == -1) {
if (efi_debug) if (efi_debug)
(void) fprintf(stderr, "DKIOCSETEFI write " (void) fprintf(stderr, "DKIOCSETEFI write "
"error: %d\n", errno); "error: %d\n", errno);
return error; return (error);
} }
if (error != dk_ioc->dki_length) { if (error != dk_ioc->dki_length) {
if (efi_debug) if (efi_debug)
(void) fprintf(stderr, "DKIOCSETEFI short " (void) fprintf(stderr, "DKIOCSETEFI short "
"write of %d bytes\n", error); "write of %d bytes\n", error);
errno = EIO; errno = EIO;
return -1; return (-1);
} }
/* Sync the new EFI table to disk */ /* Sync the new EFI table to disk */
error = fsync(fd); error = fsync(fd);
if (error == -1) if (error == -1)
return error; return (error);
/* Ensure any local disk cache is also flushed */ /* Ensure any local disk cache is also flushed */
if (ioctl(fd, BLKFLSBUF, 0) == -1) if (ioctl(fd, BLKFLSBUF, 0) == -1)
return error; return (error);
error = 0; error = 0;
break; break;
@ -487,7 +487,7 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc)
(void) fprintf(stderr, "unsupported ioctl()\n"); (void) fprintf(stderr, "unsupported ioctl()\n");
errno = EIO; errno = EIO;
return -1; return (-1);
} }
#else #else
dk_ioc->dki_data_64 = (uint64_t)(uintptr_t)data; dk_ioc->dki_data_64 = (uint64_t)(uintptr_t)data;
@ -497,7 +497,8 @@ efi_ioctl(int fd, int cmd, dk_efi_t *dk_ioc)
return (error); return (error);
} }
int efi_rescan(int fd) int
efi_rescan(int fd)
{ {
#if defined(__linux__) #if defined(__linux__)
int retry = 5; int retry = 5;
@ -507,7 +508,7 @@ int efi_rescan(int fd)
while ((error = ioctl(fd, BLKRRPART)) != 0) { while ((error = ioctl(fd, BLKRRPART)) != 0) {
if (--retry == 0) { if (--retry == 0) {
(void) fprintf(stderr, "the kernel failed to rescan " (void) fprintf(stderr, "the kernel failed to rescan "
"the partition table: %d\n", errno); "the partition table: %d\n", errno);
return (-1); return (-1);
} }
} }
@ -548,7 +549,7 @@ check_label(int fd, dk_efi_t *dk_ioc)
efi->efi_gpt_HeaderCRC32 = 0; efi->efi_gpt_HeaderCRC32 = 0;
len_t headerSize = (len_t)LE_32(efi->efi_gpt_HeaderSize); len_t headerSize = (len_t)LE_32(efi->efi_gpt_HeaderSize);
if(headerSize < EFI_MIN_LABEL_SIZE || headerSize > EFI_LABEL_SIZE) { if (headerSize < EFI_MIN_LABEL_SIZE || headerSize > EFI_LABEL_SIZE) {
if (efi_debug) if (efi_debug)
(void) fprintf(stderr, (void) fprintf(stderr,
"Invalid EFI HeaderSize %llu. Assuming %d.\n", "Invalid EFI HeaderSize %llu. Assuming %d.\n",
@ -590,7 +591,7 @@ efi_read(int fd, struct dk_gpt *vtoc)
* get the partition number for this file descriptor. * get the partition number for this file descriptor.
*/ */
if ((rval = efi_get_info(fd, &dki_info)) != 0) if ((rval = efi_get_info(fd, &dki_info)) != 0)
return rval; return (rval);
if ((strncmp(dki_info.dki_cname, "pseudo", 7) == 0) && if ((strncmp(dki_info.dki_cname, "pseudo", 7) == 0) &&
(strncmp(dki_info.dki_dname, "md", 3) == 0)) { (strncmp(dki_info.dki_dname, "md", 3) == 0)) {
@ -608,8 +609,8 @@ efi_read(int fd, struct dk_gpt *vtoc)
if (read_disk_info(fd, &capacity, &lbsize) == -1) { if (read_disk_info(fd, &capacity, &lbsize) == -1) {
if (efi_debug) { if (efi_debug) {
(void) fprintf(stderr, (void) fprintf(stderr,
"unable to read disk info: %d", "unable to read disk info: %d",
errno); errno);
} }
return (VT_EINVAL); return (VT_EINVAL);
} }
@ -642,7 +643,7 @@ efi_read(int fd, struct dk_gpt *vtoc)
} }
if (posix_memalign((void **)&dk_ioc.dki_data, if (posix_memalign((void **)&dk_ioc.dki_data,
disk_info.dki_lbsize, label_len)) disk_info.dki_lbsize, label_len))
return (VT_ERROR); return (VT_ERROR);
memset(dk_ioc.dki_data, 0, label_len); memset(dk_ioc.dki_data, 0, label_len);
@ -1117,7 +1118,7 @@ efi_write(int fd, struct dk_gpt *vtoc)
diskaddr_t lba_backup_gpt_hdr; diskaddr_t lba_backup_gpt_hdr;
if ((rval = efi_get_info(fd, &dki_info)) != 0) if ((rval = efi_get_info(fd, &dki_info)) != 0)
return rval; return (rval);
/* check if we are dealing wih a metadevice */ /* check if we are dealing wih a metadevice */
if ((strncmp(dki_info.dki_cname, "pseudo", 7) == 0) && if ((strncmp(dki_info.dki_cname, "pseudo", 7) == 0) &&
@ -1156,7 +1157,7 @@ efi_write(int fd, struct dk_gpt *vtoc)
*/ */
lba_backup_gpt_hdr = vtoc->efi_last_u_lba + 1 + nblocks; lba_backup_gpt_hdr = vtoc->efi_last_u_lba + 1 + nblocks;
if (posix_memalign((void **)&dk_ioc.dki_data, if (posix_memalign((void **)&dk_ioc.dki_data,
vtoc->efi_lbasize, dk_ioc.dki_length)) vtoc->efi_lbasize, dk_ioc.dki_length))
return (VT_ERROR); return (VT_ERROR);
memset(dk_ioc.dki_data, 0, dk_ioc.dki_length); memset(dk_ioc.dki_data, 0, dk_ioc.dki_length);

View File

@ -64,7 +64,7 @@ register_fstype(const char *name, const sa_share_ops_t *ops)
fstype = calloc(sizeof (sa_fstype_t), 1); fstype = calloc(sizeof (sa_fstype_t), 1);
if (fstype == NULL) if (fstype == NULL)
return NULL; return (NULL);
fstype->name = name; fstype->name = name;
fstype->ops = ops; fstype->ops = ops;
@ -75,7 +75,7 @@ register_fstype(const char *name, const sa_share_ops_t *ops)
fstype->next = fstypes; fstype->next = fstypes;
fstypes = fstype; fstypes = fstype;
return fstype; return (fstype);
} }
sa_handle_t sa_handle_t
@ -86,7 +86,7 @@ sa_init(int init_service)
impl_handle = calloc(sizeof (struct sa_handle_impl), 1); impl_handle = calloc(sizeof (struct sa_handle_impl), 1);
if (impl_handle == NULL) if (impl_handle == NULL)
return NULL; return (NULL);
impl_handle->zfs_libhandle = libzfs_init(); impl_handle->zfs_libhandle = libzfs_init();
@ -243,30 +243,30 @@ update_zfs_shares_cb(zfs_handle_t *zhp, void *pcookie)
if (type == ZFS_TYPE_FILESYSTEM && if (type == ZFS_TYPE_FILESYSTEM &&
zfs_iter_filesystems(zhp, update_zfs_shares_cb, pcookie) != 0) { zfs_iter_filesystems(zhp, update_zfs_shares_cb, pcookie) != 0) {
zfs_close(zhp); zfs_close(zhp);
return 1; return (1);
} }
if (type != ZFS_TYPE_FILESYSTEM) { if (type != ZFS_TYPE_FILESYSTEM) {
zfs_close(zhp); zfs_close(zhp);
return 0; return (0);
} }
if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint, if (zfs_prop_get(zhp, ZFS_PROP_MOUNTPOINT, mountpoint,
sizeof (mountpoint), NULL, NULL, 0, B_FALSE) != 0) { sizeof (mountpoint), NULL, NULL, 0, B_FALSE) != 0) {
zfs_close(zhp); zfs_close(zhp);
return 0; return (0);
} }
dataset = (char *)zfs_get_name(zhp); dataset = (char *)zfs_get_name(zhp);
if (dataset == NULL) { if (dataset == NULL) {
zfs_close(zhp); zfs_close(zhp);
return 0; return (0);
} }
if (!zfs_is_mounted(zhp, NULL)) { if (!zfs_is_mounted(zhp, NULL)) {
zfs_close(zhp); zfs_close(zhp);
return 0; return (0);
} }
if ((udata->proto == NULL || strcmp(udata->proto, "nfs") == 0) && if ((udata->proto == NULL || strcmp(udata->proto, "nfs") == 0) &&
@ -287,7 +287,7 @@ update_zfs_shares_cb(zfs_handle_t *zhp, void *pcookie)
zfs_close(zhp); zfs_close(zhp);
return 0; return (0);
} }
static int static int
@ -298,7 +298,7 @@ update_zfs_share(sa_share_impl_t impl_share, const char *proto)
update_cookie_t udata; update_cookie_t udata;
if (impl_handle->zfs_libhandle == NULL) if (impl_handle->zfs_libhandle == NULL)
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
assert(impl_share->dataset != NULL); assert(impl_share->dataset != NULL);
@ -306,13 +306,13 @@ update_zfs_share(sa_share_impl_t impl_share, const char *proto)
ZFS_TYPE_FILESYSTEM); ZFS_TYPE_FILESYSTEM);
if (zhp == NULL) if (zhp == NULL)
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
udata.handle = impl_handle; udata.handle = impl_handle;
udata.proto = proto; udata.proto = proto;
(void) update_zfs_shares_cb(zhp, &udata); (void) update_zfs_shares_cb(zhp, &udata);
return SA_OK; return (SA_OK);
} }
static int static int
@ -321,14 +321,14 @@ update_zfs_shares(sa_handle_impl_t impl_handle, const char *proto)
update_cookie_t udata; update_cookie_t udata;
if (impl_handle->zfs_libhandle == NULL) if (impl_handle->zfs_libhandle == NULL)
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
udata.handle = impl_handle; udata.handle = impl_handle;
udata.proto = proto; udata.proto = proto;
(void) zfs_iter_root(impl_handle->zfs_libhandle, update_zfs_shares_cb, (void) zfs_iter_root(impl_handle->zfs_libhandle, update_zfs_shares_cb,
&udata); &udata);
return SA_OK; return (SA_OK);
} }
static int static int
@ -351,7 +351,7 @@ process_share(sa_handle_impl_t impl_handle, sa_share_impl_t impl_share,
if (impl_share == NULL) { if (impl_share == NULL) {
if (lstat(pathname, &statbuf) != 0 || if (lstat(pathname, &statbuf) != 0 ||
!S_ISDIR(statbuf.st_mode)) !S_ISDIR(statbuf.st_mode))
return SA_BAD_PATH; return (SA_BAD_PATH);
impl_share = alloc_share(pathname); impl_share = alloc_share(pathname);
@ -421,7 +421,7 @@ err:
free_share(impl_share); free_share(impl_share);
} }
return rc; return (rc);
} }
void void
@ -487,13 +487,13 @@ find_share(sa_handle_impl_t impl_handle, const char *sharepath)
impl_share = impl_share->next; impl_share = impl_share->next;
} }
return impl_share; return (impl_share);
} }
sa_share_t sa_share_t
sa_find_share(sa_handle_t handle, char *sharepath) sa_find_share(sa_handle_t handle, char *sharepath)
{ {
return (sa_share_t)find_share((sa_handle_impl_t)handle, sharepath); return ((sa_share_t)find_share((sa_handle_impl_t)handle, sharepath));
} }
int int
@ -715,16 +715,16 @@ sa_parse_legacy_options(sa_group_t group, char *options, char *proto)
continue; continue;
} }
return fstype->ops->validate_shareopts(options); return (fstype->ops->validate_shareopts(options));
} }
return SA_INVALID_PROTOCOL; return (SA_INVALID_PROTOCOL);
} }
boolean_t boolean_t
sa_needs_refresh(sa_handle_t handle) sa_needs_refresh(sa_handle_t handle)
{ {
return B_TRUE; return (B_TRUE);
} }
libzfs_handle_t * libzfs_handle_t *
@ -733,9 +733,9 @@ sa_get_zfs_handle(sa_handle_t handle)
sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle; sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle;
if (impl_handle == NULL) if (impl_handle == NULL)
return NULL; return (NULL);
return impl_handle->zfs_libhandle; return (impl_handle->zfs_libhandle);
} }
static sa_share_impl_t static sa_share_impl_t
@ -746,13 +746,13 @@ alloc_share(const char *sharepath)
impl_share = calloc(sizeof (struct sa_share_impl), 1); impl_share = calloc(sizeof (struct sa_share_impl), 1);
if (impl_share == NULL) if (impl_share == NULL)
return NULL; return (NULL);
impl_share->sharepath = strdup(sharepath); impl_share->sharepath = strdup(sharepath);
if (impl_share->sharepath == NULL) { if (impl_share->sharepath == NULL) {
free(impl_share); free(impl_share);
return NULL; return (NULL);
} }
impl_share->fsinfo = calloc(sizeof (sa_share_fsinfo_t), fstypes_count); impl_share->fsinfo = calloc(sizeof (sa_share_fsinfo_t), fstypes_count);
@ -760,10 +760,10 @@ alloc_share(const char *sharepath)
if (impl_share->fsinfo == NULL) { if (impl_share->fsinfo == NULL) {
free(impl_share->sharepath); free(impl_share->sharepath);
free(impl_share); free(impl_share);
return NULL; return (NULL);
} }
return impl_share; return (impl_share);
} }
static void static void
@ -799,8 +799,8 @@ sa_zfs_process_share(sa_handle_t handle, sa_group_t group, sa_share_t share,
shareopts, sourcestr, dataset); shareopts, sourcestr, dataset);
#endif #endif
return process_share(impl_handle, impl_share, mountpoint, NULL, return (process_share(impl_handle, impl_share, mountpoint, NULL,
proto, shareopts, NULL, dataset, B_FALSE); proto, shareopts, NULL, dataset, B_FALSE));
} }
void void

View File

@ -43,7 +43,7 @@ typedef struct sa_share_impl {
sa_share_fsinfo_t *fsinfo; /* per-fstype information */ sa_share_fsinfo_t *fsinfo; /* per-fstype information */
} *sa_share_impl_t; } *sa_share_impl_t;
#define FSINFO(impl_share, fstype) (&(impl_share->fsinfo[fstype->fsinfo_index])) #define FSINFO(impl_share, fstype) (&(impl_share->fsinfo[fstype->fsinfo_index]))
typedef struct sa_share_ops { typedef struct sa_share_ops {
int (*enable_share)(sa_share_impl_t share); int (*enable_share)(sa_share_impl_t share);

View File

@ -50,7 +50,7 @@ typedef int (*nfs_shareopt_callback_t)(const char *opt, const char *value,
typedef int (*nfs_host_callback_t)(const char *sharepath, const char *host, typedef int (*nfs_host_callback_t)(const char *sharepath, const char *host,
const char *security, const char *access, void *cookie); const char *security, const char *access, void *cookie);
/** /*
* Invokes the specified callback function for each Solaris share option * Invokes the specified callback function for each Solaris share option
* listed in the specified string. * listed in the specified string.
*/ */
@ -62,12 +62,12 @@ foreach_nfs_shareopt(const char *shareopts,
int was_nul, rc; int was_nul, rc;
if (shareopts == NULL) if (shareopts == NULL)
return SA_OK; return (SA_OK);
shareopts_dup = strdup(shareopts); shareopts_dup = strdup(shareopts);
if (shareopts_dup == NULL) if (shareopts_dup == NULL)
return SA_NO_MEMORY; return (SA_NO_MEMORY);
opt = shareopts_dup; opt = shareopts_dup;
was_nul = 0; was_nul = 0;
@ -95,7 +95,7 @@ foreach_nfs_shareopt(const char *shareopts,
if (rc != SA_OK) { if (rc != SA_OK) {
free(shareopts_dup); free(shareopts_dup);
return rc; return (rc);
} }
} }
@ -107,7 +107,7 @@ foreach_nfs_shareopt(const char *shareopts,
free(shareopts_dup); free(shareopts_dup);
return 0; return (0);
} }
typedef struct nfs_host_cookie_s { typedef struct nfs_host_cookie_s {
@ -117,7 +117,7 @@ typedef struct nfs_host_cookie_s {
const char *security; const char *security;
} nfs_host_cookie_t; } nfs_host_cookie_t;
/** /*
* Helper function for foreach_nfs_host. This function checks whether the * Helper function for foreach_nfs_host. This function checks whether the
* current share option is a host specification and invokes a callback * current share option is a host specification and invokes a callback
* function with information about the host. * function with information about the host.
@ -146,7 +146,7 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie)
host_dup = strdup(value); host_dup = strdup(value);
if (host_dup == NULL) if (host_dup == NULL)
return SA_NO_MEMORY; return (SA_NO_MEMORY);
host = host_dup; host = host_dup;
@ -163,7 +163,7 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie)
if (rc != SA_OK) { if (rc != SA_OK) {
free(host_dup); free(host_dup);
return rc; return (rc);
} }
host = next; host = next;
@ -172,10 +172,10 @@ foreach_nfs_host_cb(const char *opt, const char *value, void *pcookie)
free(host_dup); free(host_dup);
} }
return SA_OK; return (SA_OK);
} }
/** /*
* Invokes a callback function for all NFS hosts that are set for a share. * Invokes a callback function for all NFS hosts that are set for a share.
*/ */
static int static int
@ -196,7 +196,7 @@ foreach_nfs_host(sa_share_impl_t impl_share, nfs_host_callback_t callback,
&udata); &udata);
} }
/** /*
* Converts a Solaris NFS host specification to its Linux equivalent. * Converts a Solaris NFS host specification to its Linux equivalent.
*/ */
static int static int
@ -217,13 +217,13 @@ get_linux_hostspec(const char *solaris_hostspec, char **plinux_hostspec)
} }
if (*plinux_hostspec == NULL) { if (*plinux_hostspec == NULL) {
return SA_NO_MEMORY; return (SA_NO_MEMORY);
} }
return SA_OK; return (SA_OK);
} }
/** /*
* Used internally by nfs_enable_share to enable sharing for a single host. * Used internally by nfs_enable_share to enable sharing for a single host.
*/ */
static int static int
@ -281,12 +281,12 @@ nfs_enable_share_one(const char *sharepath, const char *host,
free(opts); free(opts);
if (rc < 0) if (rc < 0)
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
else else
return SA_OK; return (SA_OK);
} }
/** /*
* Adds a Linux share option to an array of NFS options. * Adds a Linux share option to an array of NFS options.
*/ */
static int static int
@ -302,7 +302,7 @@ add_linux_shareopt(char **plinux_opts, const char *key, const char *value)
(value ? 1 + strlen(value) : 0) + 1); (value ? 1 + strlen(value) : 0) + 1);
if (new_linux_opts == NULL) if (new_linux_opts == NULL)
return SA_NO_MEMORY; return (SA_NO_MEMORY);
new_linux_opts[len] = '\0'; new_linux_opts[len] = '\0';
@ -318,10 +318,10 @@ add_linux_shareopt(char **plinux_opts, const char *key, const char *value)
*plinux_opts = new_linux_opts; *plinux_opts = new_linux_opts;
return SA_OK; return (SA_OK);
} }
/** /*
* Validates and converts a single Solaris share option to its Linux * Validates and converts a single Solaris share option to its Linux
* equivalent. * equivalent.
*/ */
@ -333,15 +333,15 @@ get_linux_shareopts_cb(const char *key, const char *value, void *cookie)
/* host-specific options, these are taken care of elsewhere */ /* host-specific options, these are taken care of elsewhere */
if (strcmp(key, "ro") == 0 || strcmp(key, "rw") == 0 || if (strcmp(key, "ro") == 0 || strcmp(key, "rw") == 0 ||
strcmp(key, "sec") == 0) strcmp(key, "sec") == 0)
return SA_OK; return (SA_OK);
if (strcmp(key, "anon") == 0) if (strcmp(key, "anon") == 0)
key = "anonuid"; key = "anonuid";
if (strcmp(key, "root_mapping") == 0) { if (strcmp(key, "root_mapping") == 0) {
(void) add_linux_shareopt(plinux_opts, "root_squash", NULL); (void) add_linux_shareopt(plinux_opts, "root_squash", NULL);
key = "anonuid"; key = "anonuid";
} }
if (strcmp(key, "nosub") == 0) if (strcmp(key, "nosub") == 0)
key = "subtree_check"; key = "subtree_check";
@ -364,15 +364,15 @@ get_linux_shareopts_cb(const char *key, const char *value, void *cookie)
strcmp(key, "all_squash") != 0 && strcmp(key, "all_squash") != 0 &&
strcmp(key, "no_all_squash") != 0 && strcmp(key, "fsid") != 0 && strcmp(key, "no_all_squash") != 0 && strcmp(key, "fsid") != 0 &&
strcmp(key, "anonuid") != 0 && strcmp(key, "anongid") != 0) { strcmp(key, "anonuid") != 0 && strcmp(key, "anongid") != 0) {
return SA_SYNTAX_ERR; return (SA_SYNTAX_ERR);
} }
(void) add_linux_shareopt(plinux_opts, key, value); (void) add_linux_shareopt(plinux_opts, key, value);
return SA_OK; return (SA_OK);
} }
/** /*
* Takes a string containing Solaris share options (e.g. "sync,no_acl") and * Takes a string containing Solaris share options (e.g. "sync,no_acl") and
* converts them to a NULL-terminated array of Linux NFS options. * converts them to a NULL-terminated array of Linux NFS options.
*/ */
@ -390,17 +390,18 @@ get_linux_shareopts(const char *shareopts, char **plinux_opts)
(void) add_linux_shareopt(plinux_opts, "no_root_squash", NULL); (void) add_linux_shareopt(plinux_opts, "no_root_squash", NULL);
(void) add_linux_shareopt(plinux_opts, "mountpoint", NULL); (void) add_linux_shareopt(plinux_opts, "mountpoint", NULL);
rc = foreach_nfs_shareopt(shareopts, get_linux_shareopts_cb, plinux_opts); rc = foreach_nfs_shareopt(shareopts, get_linux_shareopts_cb,
plinux_opts);
if (rc != SA_OK) { if (rc != SA_OK) {
free(*plinux_opts); free(*plinux_opts);
*plinux_opts = NULL; *plinux_opts = NULL;
} }
return rc; return (rc);
} }
/** /*
* Enables NFS sharing for the specified share. * Enables NFS sharing for the specified share.
*/ */
static int static int
@ -410,27 +411,27 @@ nfs_enable_share(sa_share_impl_t impl_share)
int rc; int rc;
if (!nfs_available()) { if (!nfs_available()) {
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
} }
shareopts = FSINFO(impl_share, nfs_fstype)->shareopts; shareopts = FSINFO(impl_share, nfs_fstype)->shareopts;
if (shareopts == NULL) if (shareopts == NULL)
return SA_OK; return (SA_OK);
rc = get_linux_shareopts(shareopts, &linux_opts); rc = get_linux_shareopts(shareopts, &linux_opts);
if (rc != SA_OK) if (rc != SA_OK)
return rc; return (rc);
rc = foreach_nfs_host(impl_share, nfs_enable_share_one, linux_opts); rc = foreach_nfs_host(impl_share, nfs_enable_share_one, linux_opts);
free(linux_opts); free(linux_opts);
return rc; return (rc);
} }
/** /*
* Used internally by nfs_disable_share to disable sharing for a single host. * Used internally by nfs_disable_share to disable sharing for a single host.
*/ */
static int static int
@ -471,12 +472,12 @@ nfs_disable_share_one(const char *sharepath, const char *host,
free(hostpath); free(hostpath);
if (rc < 0) if (rc < 0)
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
else else
return SA_OK; return (SA_OK);
} }
/** /*
* Disables NFS sharing for the specified share. * Disables NFS sharing for the specified share.
*/ */
static int static int
@ -487,13 +488,13 @@ nfs_disable_share(sa_share_impl_t impl_share)
* The share can't possibly be active, so nothing * The share can't possibly be active, so nothing
* needs to be done to disable it. * needs to be done to disable it.
*/ */
return SA_OK; return (SA_OK);
} }
return foreach_nfs_host(impl_share, nfs_disable_share_one, NULL); return (foreach_nfs_host(impl_share, nfs_disable_share_one, NULL));
} }
/** /*
* Checks whether the specified NFS share options are syntactically correct. * Checks whether the specified NFS share options are syntactically correct.
*/ */
static int static int
@ -505,14 +506,14 @@ nfs_validate_shareopts(const char *shareopts)
rc = get_linux_shareopts(shareopts, &linux_opts); rc = get_linux_shareopts(shareopts, &linux_opts);
if (rc != SA_OK) if (rc != SA_OK)
return rc; return (rc);
free(linux_opts); free(linux_opts);
return SA_OK; return (SA_OK);
} }
/** /*
* Checks whether a share is currently active. * Checks whether a share is currently active.
*/ */
static boolean_t static boolean_t
@ -523,17 +524,17 @@ nfs_is_share_active(sa_share_impl_t impl_share)
FILE *nfs_exportfs_temp_fp; FILE *nfs_exportfs_temp_fp;
if (!nfs_available()) if (!nfs_available())
return B_FALSE; return (B_FALSE);
nfs_exportfs_temp_fp = fdopen(dup(nfs_exportfs_temp_fd), "r"); nfs_exportfs_temp_fp = fdopen(dup(nfs_exportfs_temp_fd), "r");
if (nfs_exportfs_temp_fp == NULL || if (nfs_exportfs_temp_fp == NULL ||
fseek(nfs_exportfs_temp_fp, 0, SEEK_SET) < 0) { fseek(nfs_exportfs_temp_fp, 0, SEEK_SET) < 0) {
fclose(nfs_exportfs_temp_fp); fclose(nfs_exportfs_temp_fp);
return B_FALSE; return (B_FALSE);
} }
while (fgets(line, sizeof(line), nfs_exportfs_temp_fp) != NULL) { while (fgets(line, sizeof (line), nfs_exportfs_temp_fp) != NULL) {
/* /*
* exportfs uses separate lines for the share path * exportfs uses separate lines for the share path
* and the export options when the share path is longer * and the export options when the share path is longer
@ -564,16 +565,16 @@ nfs_is_share_active(sa_share_impl_t impl_share)
if (strcmp(line, impl_share->sharepath) == 0) { if (strcmp(line, impl_share->sharepath) == 0) {
fclose(nfs_exportfs_temp_fp); fclose(nfs_exportfs_temp_fp);
return B_TRUE; return (B_TRUE);
} }
} }
fclose(nfs_exportfs_temp_fp); fclose(nfs_exportfs_temp_fp);
return B_FALSE; return (B_FALSE);
} }
/** /*
* Called to update a share's options. A share's options might be out of * Called to update a share's options. A share's options might be out of
* date if the share was loaded from disk (i.e. /etc/dfs/sharetab) and the * date if the share was loaded from disk (i.e. /etc/dfs/sharetab) and the
* "sharenfs" dataset property has changed in the meantime. This function * "sharenfs" dataset property has changed in the meantime. This function
@ -604,7 +605,7 @@ nfs_update_shareopts(sa_share_impl_t impl_share, const char *resource,
shareopts_dup = strdup(shareopts); shareopts_dup = strdup(shareopts);
if (shareopts_dup == NULL) if (shareopts_dup == NULL)
return SA_NO_MEMORY; return (SA_NO_MEMORY);
if (old_shareopts != NULL) if (old_shareopts != NULL)
free(old_shareopts); free(old_shareopts);
@ -614,10 +615,10 @@ nfs_update_shareopts(sa_share_impl_t impl_share, const char *resource,
if (needs_reshare) if (needs_reshare)
nfs_enable_share(impl_share); nfs_enable_share(impl_share);
return SA_OK; return (SA_OK);
} }
/** /*
* Clears a share's NFS options. Used by libshare to * Clears a share's NFS options. Used by libshare to
* clean up shares that are about to be free()'d. * clean up shares that are about to be free()'d.
*/ */
@ -666,7 +667,7 @@ nfs_check_exportfs(void)
nfs_exportfs_temp_fd = mkstemp(nfs_exportfs_tempfile); nfs_exportfs_temp_fd = mkstemp(nfs_exportfs_tempfile);
if (nfs_exportfs_temp_fd < 0) if (nfs_exportfs_temp_fd < 0)
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
unlink(nfs_exportfs_tempfile); unlink(nfs_exportfs_tempfile);
@ -677,26 +678,25 @@ nfs_check_exportfs(void)
if (pid < 0) { if (pid < 0) {
(void) close(nfs_exportfs_temp_fd); (void) close(nfs_exportfs_temp_fd);
nfs_exportfs_temp_fd = -1; nfs_exportfs_temp_fd = -1;
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
} }
if (pid > 0) { if (pid > 0) {
while ((rc = waitpid(pid, &status, 0)) <= 0 && errno == EINTR) while ((rc = waitpid(pid, &status, 0)) <= 0 && errno == EINTR);
; /* empty loop body */
if (rc <= 0) { if (rc <= 0) {
(void) close(nfs_exportfs_temp_fd); (void) close(nfs_exportfs_temp_fd);
nfs_exportfs_temp_fd = -1; nfs_exportfs_temp_fd = -1;
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
} }
if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
(void) close(nfs_exportfs_temp_fd); (void) close(nfs_exportfs_temp_fd);
nfs_exportfs_temp_fd = -1; nfs_exportfs_temp_fd = -1;
return SA_CONFIG_ERR; return (SA_CONFIG_ERR);
} }
return SA_OK; return (SA_OK);
} }
/* child */ /* child */
@ -724,10 +724,10 @@ nfs_available(void)
if (nfs_exportfs_temp_fd == -1) if (nfs_exportfs_temp_fd == -1)
(void) nfs_check_exportfs(); (void) nfs_check_exportfs();
return (nfs_exportfs_temp_fd != -1) ? B_TRUE : B_FALSE; return ((nfs_exportfs_temp_fd != -1) ? B_TRUE : B_FALSE);
} }
/** /*
* Initializes the NFS functionality of libshare. * Initializes the NFS functionality of libshare.
*/ */
void void

View File

@ -26,7 +26,7 @@
* *
* This is an addition to the zfs device driver to add, modify and remove SMB * This is an addition to the zfs device driver to add, modify and remove SMB
* shares using the 'net share' command that comes with Samba. * shares using the 'net share' command that comes with Samba.
*
* TESTING * TESTING
* Make sure that samba listens to 'localhost' (127.0.0.1) and that the options * Make sure that samba listens to 'localhost' (127.0.0.1) and that the options
* 'usershare max shares' and 'usershare owner only' have been rewied/set * 'usershare max shares' and 'usershare owner only' have been rewied/set
@ -64,7 +64,7 @@ static boolean_t smb_available(void);
static sa_fstype_t *smb_fstype; static sa_fstype_t *smb_fstype;
/** /*
* Retrieve the list of SMB shares. * Retrieve the list of SMB shares.
*/ */
static int static int
@ -83,7 +83,7 @@ smb_retrieve_shares(void)
/* opendir(), stat() */ /* opendir(), stat() */
shares_dir = opendir(SHARE_DIR); shares_dir = opendir(SHARE_DIR);
if (shares_dir == NULL) if (shares_dir == NULL)
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
/* Go through the directory, looking for shares */ /* Go through the directory, looking for shares */
while ((directory = readdir(shares_dir))) { while ((directory = readdir(shares_dir))) {
@ -91,7 +91,7 @@ smb_retrieve_shares(void)
continue; continue;
snprintf(file_path, sizeof (file_path), snprintf(file_path, sizeof (file_path),
"%s/%s", SHARE_DIR, directory->d_name); "%s/%s", SHARE_DIR, directory->d_name);
if (stat(file_path, &eStat) == -1) { if (stat(file_path, &eStat) == -1) {
rc = SA_SYSTEM_ERR; rc = SA_SYSTEM_ERR;
@ -108,17 +108,17 @@ smb_retrieve_shares(void)
name = strdup(directory->d_name); name = strdup(directory->d_name);
if (name == NULL) { if (name == NULL) {
rc = SA_NO_MEMORY; rc = SA_NO_MEMORY;
goto out; goto out;
} }
while (fgets(line, sizeof(line), share_file_fp)) { while (fgets(line, sizeof (line), share_file_fp)) {
if (line[0] == '#') if (line[0] == '#')
continue; continue;
/* Trim trailing new-line character(s). */ /* Trim trailing new-line character(s). */
while (line[strlen(line) - 1] == '\r' || while (line[strlen(line) - 1] == '\r' ||
line[strlen(line) - 1] == '\n') line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = '\0'; line[strlen(line) - 1] = '\0';
/* Split the line in two, separated by '=' */ /* Split the line in two, separated by '=' */
@ -155,24 +155,25 @@ smb_retrieve_shares(void)
strncpy(shares->name, name, strncpy(shares->name, name,
sizeof (shares->name)); sizeof (shares->name));
shares->name [sizeof(shares->name)-1] = '\0'; shares->name [sizeof (shares->name) - 1] = '\0';
strncpy(shares->path, path, strncpy(shares->path, path,
sizeof (shares->path)); sizeof (shares->path));
shares->path [sizeof(shares->path)-1] = '\0'; shares->path [sizeof (shares->path) - 1] = '\0';
strncpy(shares->comment, comment, strncpy(shares->comment, comment,
sizeof (shares->comment)); sizeof (shares->comment));
shares->comment[sizeof(shares->comment)-1]='\0'; shares->comment[sizeof (shares->comment)-1] =
'\0';
shares->guest_ok = atoi(guest_ok); shares->guest_ok = atoi(guest_ok);
shares->next = new_shares; shares->next = new_shares;
new_shares = shares; new_shares = shares;
name = NULL; name = NULL;
path = NULL; path = NULL;
comment = NULL; comment = NULL;
guest_ok = NULL; guest_ok = NULL;
} }
} }
@ -190,10 +191,10 @@ out:
smb_shares = new_shares; smb_shares = new_shares;
return rc; return (rc);
} }
/** /*
* Used internally by smb_enable_share to enable sharing for a single host. * Used internally by smb_enable_share to enable sharing for a single host.
*/ */
static int static int
@ -204,8 +205,8 @@ smb_enable_share_one(const char *sharename, const char *sharepath)
int rc; int rc;
/* Support ZFS share name regexp '[[:alnum:]_-.: ]' */ /* Support ZFS share name regexp '[[:alnum:]_-.: ]' */
strncpy(name, sharename, sizeof(name)); strncpy(name, sharename, sizeof (name));
name [sizeof(name)-1] = '\0'; name [sizeof (name)-1] = '\0';
pos = name; pos = name;
while (*pos != '\0') { while (*pos != '\0') {
@ -220,32 +221,34 @@ smb_enable_share_one(const char *sharename, const char *sharepath)
++pos; ++pos;
} }
/* CMD: net -S NET_CMD_ARG_HOST usershare add Test1 /share/Test1 \ /*
* "Comment" "Everyone:F" */ * CMD: net -S NET_CMD_ARG_HOST usershare add Test1 /share/Test1 \
snprintf(comment, sizeof(comment), "Comment: %s", sharepath); * "Comment" "Everyone:F"
*/
snprintf(comment, sizeof (comment), "Comment: %s", sharepath);
argv[0] = NET_CMD_PATH; argv[0] = NET_CMD_PATH;
argv[1] = (char*)"-S"; argv[1] = (char *)"-S";
argv[2] = NET_CMD_ARG_HOST; argv[2] = NET_CMD_ARG_HOST;
argv[3] = (char*)"usershare"; argv[3] = (char *)"usershare";
argv[4] = (char*)"add"; argv[4] = (char *)"add";
argv[5] = (char*)name; argv[5] = (char *)name;
argv[6] = (char*)sharepath; argv[6] = (char *)sharepath;
argv[7] = (char*)comment; argv[7] = (char *)comment;
argv[8] = "Everyone:F"; argv[8] = "Everyone:F";
argv[9] = NULL; argv[9] = NULL;
rc = libzfs_run_process(argv[0], argv, 0); rc = libzfs_run_process(argv[0], argv, 0);
if (rc < 0) if (rc < 0)
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
/* Reload the share file */ /* Reload the share file */
(void) smb_retrieve_shares(); (void) smb_retrieve_shares();
return SA_OK; return (SA_OK);
} }
/** /*
* Enables SMB sharing for the specified share. * Enables SMB sharing for the specified share.
*/ */
static int static int
@ -254,20 +257,21 @@ smb_enable_share(sa_share_impl_t impl_share)
char *shareopts; char *shareopts;
if (!smb_available()) if (!smb_available())
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
shareopts = FSINFO(impl_share, smb_fstype)->shareopts; shareopts = FSINFO(impl_share, smb_fstype)->shareopts;
if (shareopts == NULL) /* on/off */ if (shareopts == NULL) /* on/off */
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
if (strcmp(shareopts, "off") == 0) if (strcmp(shareopts, "off") == 0)
return SA_OK; return (SA_OK);
/* Magic: Enable (i.e., 'create new') share */ /* Magic: Enable (i.e., 'create new') share */
return smb_enable_share_one(impl_share->dataset, impl_share->sharepath); return (smb_enable_share_one(impl_share->dataset,
impl_share->sharepath));
} }
/** /*
* Used internally by smb_disable_share to disable sharing for a single host. * Used internally by smb_disable_share to disable sharing for a single host.
*/ */
static int static int
@ -278,21 +282,21 @@ smb_disable_share_one(const char *sharename)
/* CMD: net -S NET_CMD_ARG_HOST usershare delete Test1 */ /* CMD: net -S NET_CMD_ARG_HOST usershare delete Test1 */
argv[0] = NET_CMD_PATH; argv[0] = NET_CMD_PATH;
argv[1] = (char*)"-S"; argv[1] = (char *)"-S";
argv[2] = NET_CMD_ARG_HOST; argv[2] = NET_CMD_ARG_HOST;
argv[3] = (char*)"usershare"; argv[3] = (char *)"usershare";
argv[4] = (char*)"delete"; argv[4] = (char *)"delete";
argv[5] = strdup(sharename); argv[5] = strdup(sharename);
argv[6] = NULL; argv[6] = NULL;
rc = libzfs_run_process(argv[0], argv, 0); rc = libzfs_run_process(argv[0], argv, 0);
if (rc < 0) if (rc < 0)
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
else else
return SA_OK; return (SA_OK);
} }
/** /*
* Disables SMB sharing for the specified share. * Disables SMB sharing for the specified share.
*/ */
static int static int
@ -305,20 +309,20 @@ smb_disable_share(sa_share_impl_t impl_share)
* The share can't possibly be active, so nothing * The share can't possibly be active, so nothing
* needs to be done to disable it. * needs to be done to disable it.
*/ */
return SA_OK; return (SA_OK);
} }
while (shares != NULL) { while (shares != NULL) {
if (strcmp(impl_share->sharepath, shares->path) == 0) if (strcmp(impl_share->sharepath, shares->path) == 0)
return smb_disable_share_one(shares->name); return (smb_disable_share_one(shares->name));
shares = shares->next; shares = shares->next;
} }
return SA_OK; return (SA_OK);
} }
/** /*
* Checks whether the specified SMB share options are syntactically correct. * Checks whether the specified SMB share options are syntactically correct.
*/ */
static int static int
@ -326,34 +330,34 @@ smb_validate_shareopts(const char *shareopts)
{ {
/* TODO: Accept 'name' and sec/acl (?) */ /* TODO: Accept 'name' and sec/acl (?) */
if ((strcmp(shareopts, "off") == 0) || (strcmp(shareopts, "on") == 0)) if ((strcmp(shareopts, "off") == 0) || (strcmp(shareopts, "on") == 0))
return SA_OK; return (SA_OK);
return SA_SYNTAX_ERR; return (SA_SYNTAX_ERR);
} }
/** /*
* Checks whether a share is currently active. * Checks whether a share is currently active.
*/ */
static boolean_t static boolean_t
smb_is_share_active(sa_share_impl_t impl_share) smb_is_share_active(sa_share_impl_t impl_share)
{ {
if (!smb_available()) if (!smb_available())
return B_FALSE; return (B_FALSE);
/* Retrieve the list of (possible) active shares */ /* Retrieve the list of (possible) active shares */
smb_retrieve_shares(); smb_retrieve_shares();
while (smb_shares != NULL) { while (smb_shares != NULL) {
if (strcmp(impl_share->sharepath, smb_shares->path) == 0) if (strcmp(impl_share->sharepath, smb_shares->path) == 0)
return B_TRUE; return (B_TRUE);
smb_shares = smb_shares->next; smb_shares = smb_shares->next;
} }
return B_FALSE; return (B_FALSE);
} }
/** /*
* Called to update a share's options. A share's options might be out of * Called to update a share's options. A share's options might be out of
* date if the share was loaded from disk and the "sharesmb" dataset * date if the share was loaded from disk and the "sharesmb" dataset
* property has changed in the meantime. This function also takes care * property has changed in the meantime. This function also takes care
@ -367,8 +371,8 @@ smb_update_shareopts(sa_share_impl_t impl_share, const char *resource,
boolean_t needs_reshare = B_FALSE; boolean_t needs_reshare = B_FALSE;
char *old_shareopts; char *old_shareopts;
if(!impl_share) if (!impl_share)
return SA_SYSTEM_ERR; return (SA_SYSTEM_ERR);
FSINFO(impl_share, smb_fstype)->active = FSINFO(impl_share, smb_fstype)->active =
smb_is_share_active(impl_share); smb_is_share_active(impl_share);
@ -384,7 +388,7 @@ smb_update_shareopts(sa_share_impl_t impl_share, const char *resource,
shareopts_dup = strdup(shareopts); shareopts_dup = strdup(shareopts);
if (shareopts_dup == NULL) if (shareopts_dup == NULL)
return SA_NO_MEMORY; return (SA_NO_MEMORY);
if (old_shareopts != NULL) if (old_shareopts != NULL)
free(old_shareopts); free(old_shareopts);
@ -394,10 +398,10 @@ smb_update_shareopts(sa_share_impl_t impl_share, const char *resource,
if (needs_reshare) if (needs_reshare)
smb_enable_share(impl_share); smb_enable_share(impl_share);
return SA_OK; return (SA_OK);
} }
/** /*
* Clears a share's SMB options. Used by libshare to * Clears a share's SMB options. Used by libshare to
* clean up shares that are about to be free()'d. * clean up shares that are about to be free()'d.
*/ */
@ -427,15 +431,15 @@ smb_available(void)
if (lstat(SHARE_DIR, &statbuf) != 0 || if (lstat(SHARE_DIR, &statbuf) != 0 ||
!S_ISDIR(statbuf.st_mode)) !S_ISDIR(statbuf.st_mode))
return B_FALSE; return (B_FALSE);
if (access(NET_CMD_PATH, F_OK) != 0) if (access(NET_CMD_PATH, F_OK) != 0)
return B_FALSE; return (B_FALSE);
return B_TRUE; return (B_TRUE);
} }
/** /*
* Initializes the SMB functionality of libshare. * Initializes the SMB functionality of libshare.
*/ */
void void

View File

@ -28,12 +28,12 @@
* references are hard to find. * references are hard to find.
*/ */
#define SMB_NAME_MAX 255 #define SMB_NAME_MAX 255
#define SMB_COMMENT_MAX 255 #define SMB_COMMENT_MAX 255
#define SHARE_DIR "/var/lib/samba/usershares" #define SHARE_DIR "/var/lib/samba/usershares"
#define NET_CMD_PATH "/usr/bin/net" #define NET_CMD_PATH "/usr/bin/net"
#define NET_CMD_ARG_HOST "127.0.0.1" #define NET_CMD_ARG_HOST "127.0.0.1"
typedef struct smb_share_s { typedef struct smb_share_s {
char name[SMB_NAME_MAX]; /* Share name */ char name[SMB_NAME_MAX]; /* Share name */

View File

@ -40,7 +40,7 @@ pthread_mutex_t atomic_lock = PTHREAD_MUTEX_INITIALIZER;
* Theses are the void returning variants * Theses are the void returning variants
*/ */
#define ATOMIC_INC(name, type) \ #define ATOMIC_INC(name, type) \
void atomic_inc_##name(volatile type *target) \ void atomic_inc_##name(volatile type *target) \
{ \ { \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
@ -59,7 +59,7 @@ ATOMIC_INC(ulong, ulong_t)
ATOMIC_INC(64, uint64_t) ATOMIC_INC(64, uint64_t)
#define ATOMIC_DEC(name, type) \ #define ATOMIC_DEC(name, type) \
void atomic_dec_##name(volatile type *target) \ void atomic_dec_##name(volatile type *target) \
{ \ { \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
@ -78,7 +78,7 @@ ATOMIC_DEC(ulong, ulong_t)
ATOMIC_DEC(64, uint64_t) ATOMIC_DEC(64, uint64_t)
#define ATOMIC_ADD(name, type1, type2) \ #define ATOMIC_ADD(name, type1, type2) \
void atomic_add_##name(volatile type1 *target, type2 bits) \ void atomic_add_##name(volatile type1 *target, type2 bits) \
{ \ { \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
@ -95,7 +95,8 @@ ATOMIC_ADD(int, uint_t, int)
ATOMIC_ADD(long, ulong_t, long) ATOMIC_ADD(long, ulong_t, long)
ATOMIC_ADD(64, uint64_t, int64_t) ATOMIC_ADD(64, uint64_t, int64_t)
void atomic_add_ptr(volatile void *target, ssize_t bits) void
atomic_add_ptr(volatile void *target, ssize_t bits)
{ {
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0);
*(caddr_t *)target += bits; *(caddr_t *)target += bits;
@ -103,7 +104,7 @@ void atomic_add_ptr(volatile void *target, ssize_t bits)
} }
#define ATOMIC_SUB(name, type1, type2) \ #define ATOMIC_SUB(name, type1, type2) \
void atomic_sub_##name(volatile type1 *target, type2 bits) \ void atomic_sub_##name(volatile type1 *target, type2 bits) \
{ \ { \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
@ -120,7 +121,8 @@ ATOMIC_SUB(int, uint_t, int)
ATOMIC_SUB(long, ulong_t, long) ATOMIC_SUB(long, ulong_t, long)
ATOMIC_SUB(64, uint64_t, int64_t) ATOMIC_SUB(64, uint64_t, int64_t)
void atomic_sub_ptr(volatile void *target, ssize_t bits) void
atomic_sub_ptr(volatile void *target, ssize_t bits)
{ {
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0);
*(caddr_t *)target -= bits; *(caddr_t *)target -= bits;
@ -128,7 +130,7 @@ void atomic_sub_ptr(volatile void *target, ssize_t bits)
} }
#define ATOMIC_OR(name, type) \ #define ATOMIC_OR(name, type) \
void atomic_or_##name(volatile type *target, type bits) \ void atomic_or_##name(volatile type *target, type bits) \
{ \ { \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
@ -146,7 +148,7 @@ ATOMIC_OR(ulong, ulong_t)
ATOMIC_OR(64, uint64_t) ATOMIC_OR(64, uint64_t)
#define ATOMIC_AND(name, type) \ #define ATOMIC_AND(name, type) \
void atomic_and_##name(volatile type *target, type bits) \ void atomic_and_##name(volatile type *target, type bits) \
{ \ { \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
@ -168,14 +170,14 @@ ATOMIC_AND(64, uint64_t)
* New value returning variants * New value returning variants
*/ */
#define ATOMIC_INC_NV(name, type) \ #define ATOMIC_INC_NV(name, type) \
type atomic_inc_##name##_nv(volatile type *target) \ type atomic_inc_##name##_nv(volatile type *target) \
{ \ { \
type rc; \ type rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (++(*target)); \ rc = (++(*target)); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
return rc; \ return (rc); \
} }
ATOMIC_INC_NV(long, unsigned long) ATOMIC_INC_NV(long, unsigned long)
@ -189,14 +191,14 @@ ATOMIC_INC_NV(ulong, ulong_t)
ATOMIC_INC_NV(64, uint64_t) ATOMIC_INC_NV(64, uint64_t)
#define ATOMIC_DEC_NV(name, type) \ #define ATOMIC_DEC_NV(name, type) \
type atomic_dec_##name##_nv(volatile type *target) \ type atomic_dec_##name##_nv(volatile type *target) \
{ \ { \
type rc; \ type rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (--(*target)); \ rc = (--(*target)); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
return rc; \ return (rc); \
} }
ATOMIC_DEC_NV(long, unsigned long) ATOMIC_DEC_NV(long, unsigned long)
@ -210,14 +212,14 @@ ATOMIC_DEC_NV(ulong, ulong_t)
ATOMIC_DEC_NV(64, uint64_t) ATOMIC_DEC_NV(64, uint64_t)
#define ATOMIC_ADD_NV(name, type1, type2) \ #define ATOMIC_ADD_NV(name, type1, type2) \
type1 atomic_add_##name##_nv(volatile type1 *target, type2 bits)\ type1 atomic_add_##name##_nv(volatile type1 *target, type2 bits)\
{ \ { \
type1 rc; \ type1 rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (*target += bits); \ rc = (*target += bits); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
return rc; \ return (rc); \
} }
ATOMIC_ADD_NV(8, uint8_t, int8_t) ATOMIC_ADD_NV(8, uint8_t, int8_t)
@ -229,7 +231,8 @@ ATOMIC_ADD_NV(int, uint_t, int)
ATOMIC_ADD_NV(long, ulong_t, long) ATOMIC_ADD_NV(long, ulong_t, long)
ATOMIC_ADD_NV(64, uint64_t, int64_t) ATOMIC_ADD_NV(64, uint64_t, int64_t)
void *atomic_add_ptr_nv(volatile void *target, ssize_t bits) void *
atomic_add_ptr_nv(volatile void *target, ssize_t bits)
{ {
void *ptr; void *ptr;
@ -237,18 +240,18 @@ void *atomic_add_ptr_nv(volatile void *target, ssize_t bits)
ptr = (*(caddr_t *)target += bits); ptr = (*(caddr_t *)target += bits);
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
return ptr; return (ptr);
} }
#define ATOMIC_SUB_NV(name, type1, type2) \ #define ATOMIC_SUB_NV(name, type1, type2) \
type1 atomic_sub_##name##_nv(volatile type1 *target, type2 bits)\ type1 atomic_sub_##name##_nv(volatile type1 *target, type2 bits)\
{ \ { \
type1 rc; \ type1 rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (*target -= bits); \ rc = (*target -= bits); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
return rc; \ return (rc); \
} }
ATOMIC_SUB_NV(8, uint8_t, int8_t) ATOMIC_SUB_NV(8, uint8_t, int8_t)
@ -260,7 +263,8 @@ ATOMIC_SUB_NV(int, uint_t, int)
ATOMIC_SUB_NV(long, ulong_t, long) ATOMIC_SUB_NV(long, ulong_t, long)
ATOMIC_SUB_NV(64, uint64_t, int64_t) ATOMIC_SUB_NV(64, uint64_t, int64_t)
void *atomic_sub_ptr_nv(volatile void *target, ssize_t bits) void *
atomic_sub_ptr_nv(volatile void *target, ssize_t bits)
{ {
void *ptr; void *ptr;
@ -268,18 +272,18 @@ void *atomic_sub_ptr_nv(volatile void *target, ssize_t bits)
ptr = (*(caddr_t *)target -= bits); ptr = (*(caddr_t *)target -= bits);
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
return ptr; return (ptr);
} }
#define ATOMIC_OR_NV(name, type) \ #define ATOMIC_OR_NV(name, type) \
type atomic_or_##name##_nv(volatile type *target, type bits) \ type atomic_or_##name##_nv(volatile type *target, type bits) \
{ \ { \
type rc; \ type rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (*target |= bits); \ rc = (*target |= bits); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
return rc; \ return (rc); \
} }
ATOMIC_OR_NV(long, unsigned long) ATOMIC_OR_NV(long, unsigned long)
@ -293,14 +297,14 @@ ATOMIC_OR_NV(ulong, ulong_t)
ATOMIC_OR_NV(64, uint64_t) ATOMIC_OR_NV(64, uint64_t)
#define ATOMIC_AND_NV(name, type) \ #define ATOMIC_AND_NV(name, type) \
type atomic_and_##name##_nv(volatile type *target, type bits) \ type atomic_and_##name##_nv(volatile type *target, type bits) \
{ \ { \
type rc; \ type rc; \
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); \
rc = (*target &= bits); \ rc = (*target &= bits); \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
return rc; \ return (rc); \
} }
ATOMIC_AND_NV(long, unsigned long) ATOMIC_AND_NV(long, unsigned long)
@ -318,7 +322,7 @@ ATOMIC_AND_NV(64, uint64_t)
* If *arg1 == arg2, set *arg1 = arg3; return old value * If *arg1 == arg2, set *arg1 = arg3; return old value
*/ */
#define ATOMIC_CAS(name, type) \ #define ATOMIC_CAS(name, type) \
type atomic_cas_##name(volatile type *target, type arg1, type arg2) \ type atomic_cas_##name(volatile type *target, type arg1, type arg2) \
{ \ { \
type old; \ type old; \
@ -327,7 +331,7 @@ ATOMIC_AND_NV(64, uint64_t)
if (old == arg1) \ if (old == arg1) \
*target = arg2; \ *target = arg2; \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
return old; \ return (old); \
} }
ATOMIC_CAS(8, uint8_t) ATOMIC_CAS(8, uint8_t)
@ -339,17 +343,18 @@ ATOMIC_CAS(uint, uint_t)
ATOMIC_CAS(ulong, ulong_t) ATOMIC_CAS(ulong, ulong_t)
ATOMIC_CAS(64, uint64_t) ATOMIC_CAS(64, uint64_t)
void *atomic_cas_ptr(volatile void *target, void *arg1, void *arg2) void *
atomic_cas_ptr(volatile void *target, void *arg1, void *arg2)
{ {
void *old; void *old;
VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0); VERIFY3S(pthread_mutex_lock(&atomic_lock), ==, 0);
old = *(void **)target; old = *(void **)target;
if (old == arg1) if (old == arg1)
*(void **)target = arg2; *(void **)target = arg2;
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
return old; return (old);
} }
@ -357,7 +362,7 @@ void *atomic_cas_ptr(volatile void *target, void *arg1, void *arg2)
* Swap target and return old value * Swap target and return old value
*/ */
#define ATOMIC_SWAP(name, type) \ #define ATOMIC_SWAP(name, type) \
type atomic_swap_##name(volatile type *target, type bits) \ type atomic_swap_##name(volatile type *target, type bits) \
{ \ { \
type old; \ type old; \
@ -365,7 +370,7 @@ void *atomic_cas_ptr(volatile void *target, void *arg1, void *arg2)
old = *target; \ old = *target; \
*target = bits; \ *target = bits; \
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \ VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); \
return old; \ return (old); \
} }
ATOMIC_SWAP(8, uint8_t) ATOMIC_SWAP(8, uint8_t)
@ -377,7 +382,8 @@ ATOMIC_SWAP(uint, uint_t)
ATOMIC_SWAP(ulong, ulong_t) ATOMIC_SWAP(ulong, ulong_t)
ATOMIC_SWAP(64, uint64_t) ATOMIC_SWAP(64, uint64_t)
void *atomic_swap_ptr(volatile void *target, void *bits) void *
atomic_swap_ptr(volatile void *target, void *bits)
{ {
void *old; void *old;
@ -386,11 +392,12 @@ void *atomic_swap_ptr(volatile void *target, void *bits)
*(void **)target = bits; *(void **)target = bits;
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
return old; return (old);
} }
int atomic_set_long_excl(volatile ulong_t *target, uint_t value) int
atomic_set_long_excl(volatile ulong_t *target, uint_t value)
{ {
ulong_t bit; ulong_t bit;
@ -398,15 +405,16 @@ int atomic_set_long_excl(volatile ulong_t *target, uint_t value)
bit = (1UL << value); bit = (1UL << value);
if ((*target & bit) != 0) { if ((*target & bit) != 0) {
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
return -1; return (-1);
} }
*target |= bit; *target |= bit;
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
return 0; return (0);
} }
int atomic_clear_long_excl(volatile ulong_t *target, uint_t value) int
atomic_clear_long_excl(volatile ulong_t *target, uint_t value)
{ {
ulong_t bit; ulong_t bit;
@ -414,67 +422,78 @@ int atomic_clear_long_excl(volatile ulong_t *target, uint_t value)
bit = (1UL << value); bit = (1UL << value);
if ((*target & bit) != 0) { if ((*target & bit) != 0) {
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
return -1; return (-1);
} }
*target &= ~bit; *target &= ~bit;
VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0); VERIFY3S(pthread_mutex_unlock(&atomic_lock), ==, 0);
return 0; return (0);
} }
void membar_enter(void) void
membar_enter(void)
{ {
/* XXX - Implement me */ /* XXX - Implement me */
} }
void membar_exit(void) void
membar_exit(void)
{ {
/* XXX - Implement me */ /* XXX - Implement me */
} }
void membar_producer(void) void
membar_producer(void)
{ {
/* XXX - Implement me */ /* XXX - Implement me */
} }
void membar_consumer(void) void
membar_consumer(void)
{ {
/* XXX - Implement me */ /* XXX - Implement me */
} }
/* Legacy kernel interfaces; they will go away (eventually). */ /* Legacy kernel interfaces; they will go away (eventually). */
uint8_t cas8(uint8_t *target, uint8_t arg1, uint8_t arg2) uint8_t
cas8(uint8_t *target, uint8_t arg1, uint8_t arg2)
{ {
return atomic_cas_8(target, arg1, arg2); return (atomic_cas_8(target, arg1, arg2));
} }
uint32_t cas32(uint32_t *target, uint32_t arg1, uint32_t arg2) uint32_t
cas32(uint32_t *target, uint32_t arg1, uint32_t arg2)
{ {
return atomic_cas_32(target, arg1, arg2); return (atomic_cas_32(target, arg1, arg2));
} }
uint64_t cas64(uint64_t *target, uint64_t arg1, uint64_t arg2) uint64_t
cas64(uint64_t *target, uint64_t arg1, uint64_t arg2)
{ {
return atomic_cas_64(target, arg1, arg2); return (atomic_cas_64(target, arg1, arg2));
} }
ulong_t caslong(ulong_t *target, ulong_t arg1, ulong_t arg2) ulong_t
caslong(ulong_t *target, ulong_t arg1, ulong_t arg2)
{ {
return atomic_cas_ulong(target, arg1, arg2); return (atomic_cas_ulong(target, arg1, arg2));
} }
void *casptr(void *target, void *arg1, void *arg2) void *
casptr(void *target, void *arg1, void *arg2)
{ {
return atomic_cas_ptr(target, arg1, arg2); return (atomic_cas_ptr(target, arg1, arg2));
} }
void atomic_and_long(ulong_t *target, ulong_t bits) void
atomic_and_long(ulong_t *target, ulong_t bits)
{ {
return atomic_and_ulong(target, bits); return (atomic_and_ulong(target, bits));
} }
void atomic_or_long(ulong_t *target, ulong_t bits) void
atomic_or_long(ulong_t *target, ulong_t bits)
{ {
return atomic_or_ulong(target, bits); return (atomic_or_ulong(target, bits));
} }

View File

@ -41,7 +41,8 @@ getexecname(void)
pthread_mutex_lock(&mtx); pthread_mutex_lock(&mtx);
if (strlen(execname) == 0) { if (strlen(execname) == 0) {
rc = readlink("/proc/self/exe", execname, sizeof(execname) - 1); rc = readlink("/proc/self/exe",
execname, sizeof (execname) - 1);
if (rc == -1) { if (rc == -1) {
execname[0] = '\0'; execname[0] = '\0';
} else { } else {
@ -53,5 +54,5 @@ getexecname(void)
} }
pthread_mutex_unlock(&mtx); pthread_mutex_unlock(&mtx);
return ptr; return (ptr);
} }

View File

@ -30,9 +30,9 @@
void void
gethrestime(timestruc_t *ts) gethrestime(timestruc_t *ts)
{ {
struct timeval tv; struct timeval tv;
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
ts->tv_sec = tv.tv_sec; ts->tv_sec = tv.tv_sec;
ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC; ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
} }

View File

@ -38,8 +38,8 @@ gethrtime(void)
rc = clock_gettime(CLOCK_MONOTONIC, &ts); rc = clock_gettime(CLOCK_MONOTONIC, &ts);
if (rc) { if (rc) {
fprintf(stderr, "Error: clock_gettime() = %d\n", rc); fprintf(stderr, "Error: clock_gettime() = %d\n", rc);
abort(); abort();
} }
return (((u_int64_t)ts.tv_sec) * NANOSEC) + ts.tv_nsec; return ((((u_int64_t)ts.tv_sec) * NANOSEC) + ts.tv_nsec);
} }

View File

@ -37,23 +37,25 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#define BUFSIZE (MNT_LINE_MAX + 2) #define BUFSIZE (MNT_LINE_MAX + 2)
__thread char buf[BUFSIZE]; __thread char buf[BUFSIZE];
#define DIFF(xx) ((mrefp->xx != NULL) && \ #define DIFF(xx) ( \
(mgetp->xx == NULL || strcmp(mrefp->xx, mgetp->xx) != 0)) (mrefp->xx != NULL) && \
(mgetp->xx == NULL || strcmp(mrefp->xx, mgetp->xx) != 0))
int int
getmntany(FILE *fp, struct mnttab *mgetp, struct mnttab *mrefp) getmntany(FILE *fp, struct mnttab *mgetp, struct mnttab *mrefp)
{ {
int ret; int ret;
while (((ret = _sol_getmntent(fp, mgetp)) == 0) && while (
(DIFF(mnt_special) || DIFF(mnt_mountp) || ((ret = _sol_getmntent(fp, mgetp)) == 0) && (
DIFF(mnt_fstype) || DIFF(mnt_mntopts))); DIFF(mnt_special) || DIFF(mnt_mountp) ||
DIFF(mnt_fstype) || DIFF(mnt_mntopts)));
return ret; return (ret);
} }
int int
@ -69,13 +71,13 @@ _sol_getmntent(FILE *fp, struct mnttab *mgetp)
mgetp->mnt_mountp = mntbuf.mnt_dir; mgetp->mnt_mountp = mntbuf.mnt_dir;
mgetp->mnt_fstype = mntbuf.mnt_type; mgetp->mnt_fstype = mntbuf.mnt_type;
mgetp->mnt_mntopts = mntbuf.mnt_opts; mgetp->mnt_mntopts = mntbuf.mnt_opts;
return 0; return (0);
} }
if (feof(fp)) if (feof(fp))
return -1; return (-1);
return MNT_TOOLONG; return (MNT_TOOLONG);
} }
int int
@ -89,11 +91,11 @@ getextmntent(FILE *fp, struct extmnttab *mp, int len)
if (stat64(mp->mnt_mountp, &st) != 0) { if (stat64(mp->mnt_mountp, &st) != 0) {
mp->mnt_major = 0; mp->mnt_major = 0;
mp->mnt_minor = 0; mp->mnt_minor = 0;
return ret; return (ret);
} }
mp->mnt_major = major(st.st_dev); mp->mnt_major = major(st.st_dev);
mp->mnt_minor = minor(st.st_dev); mp->mnt_minor = minor(st.st_dev);
} }
return ret; return (ret);
} }

View File

@ -27,7 +27,7 @@
#include_next <assert.h> #include_next <assert.h>
#ifndef _LIBSPL_ASSERT_H #ifndef _LIBSPL_ASSERT_H
#define _LIBSPL_ASSERT_H #define _LIBSPL_ASSERT_H
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _LIBSPL_DEVID_H #ifndef _LIBSPL_DEVID_H
#define _LIBSPL_DEVID_H #define _LIBSPL_DEVID_H
#include <stdlib.h> #include <stdlib.h>
@ -36,13 +36,73 @@ typedef struct devid_nmlist {
dev_t dev; dev_t dev;
} devid_nmlist_t; } devid_nmlist_t;
static inline int devid_str_decode(char *devidstr, ddi_devid_t *retdevid, char **retminor_name) { abort(); } static inline
static inline int devid_deviceid_to_nmlist(char *search_path, ddi_devid_t devid, char *minor_name, devid_nmlist_t **retlist) { abort(); } int
static inline void devid_str_free(char *str) { abort(); } devid_str_decode(
static inline void devid_free(ddi_devid_t devid) { abort(); } char *devidstr,
static inline void devid_free_nmlist(devid_nmlist_t *list) { abort(); } ddi_devid_t *retdevid,
static inline int devid_get(int fd, ddi_devid_t *retdevid) { return -1; } char **retminor_name)
static inline int devid_get_minor_name(int fd, char **retminor_name) { abort(); } {
static inline char *devid_str_encode(ddi_devid_t devid, char *minor_name) { abort(); } abort();
}
static inline
int
devid_deviceid_to_nmlist(
char *search_path,
ddi_devid_t devid,
char *minor_name,
devid_nmlist_t **retlist)
{
abort();
}
static inline
void
devid_str_free(char *str)
{
abort();
}
static inline
void
devid_free(ddi_devid_t devid)
{
abort();
}
static inline
void
devid_free_nmlist(devid_nmlist_t *list)
{
abort();
}
static inline
int
devid_get(
int fd,
ddi_devid_t *retdevid)
{
return (-1);
}
static inline
int
devid_get_minor_name(
int fd,
char **retminor_name)
{
abort();
}
static inline
char *
devid_str_encode(
ddi_devid_t devid,
char *minor_name)
{
abort();
}
#endif #endif

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_LIBDEVINFO_H #ifndef _LIBSPL_LIBDEVINFO_H
#define _LIBSPL_LIBDEVINFO_H #define _LIBSPL_LIBDEVINFO_H
#endif /* _LIBSPL_LIBDEVINFO_H */ #endif /* _LIBSPL_LIBDEVINFO_H */

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _LIBSPL_LIBGEN_H #ifndef _LIBSPL_LIBGEN_H
#define _LIBSPL_LIBGEN_H #define _LIBSPL_LIBGEN_H
#include <sys/types.h> #include <sys/types.h>

View File

@ -24,7 +24,7 @@
* Use is subject to license terms. * Use is subject to license terms.
*/ */
#ifndef _LIBSPL_LIBSHARE_H #ifndef _LIBSPL_LIBSHARE_H
#define _LIBSPL_LIBSHARE_H #define _LIBSPL_LIBSHARE_H
typedef void *sa_handle_t; /* opaque handle to access core functions */ typedef void *sa_handle_t; /* opaque handle to access core functions */
typedef void *sa_group_t; typedef void *sa_group_t;

View File

@ -27,14 +27,14 @@
#include_next <limits.h> #include_next <limits.h>
#ifndef _LIBSPL_LIMITS_H #ifndef _LIBSPL_LIMITS_H
#define _LIBSPL_LIMITS_H #define _LIBSPL_LIMITS_H
#define DBL_DIG 15 #define DBL_DIG 15
#define DBL_MAX 1.7976931348623157081452E+308 #define DBL_MAX 1.7976931348623157081452E+308
#define DBL_MIN 2.2250738585072013830903E-308 #define DBL_MIN 2.2250738585072013830903E-308
#define FLT_DIG 6 #define FLT_DIG 6
#define FLT_MAX 3.4028234663852885981170E+38F #define FLT_MAX 3.4028234663852885981170E+38F
#define FLT_MIN 1.1754943508222875079688E-38F #define FLT_MIN 1.1754943508222875079688E-38F
#endif /* _LIBSPL_LIMITS_H */ #endif /* _LIBSPL_LIMITS_H */

View File

@ -27,7 +27,7 @@
#include_next <locale.h> #include_next <locale.h>
#ifndef _LIBSPL_LOCALE_H #ifndef _LIBSPL_LOCALE_H
#define _LIBSPL_LOCALE_H #define _LIBSPL_LOCALE_H
#include <time.h> #include <time.h>
#include <sys/time.h> #include <sys/time.h>

View File

@ -36,7 +36,7 @@
*/ */
#ifndef _NOTE_H #ifndef _NOTE_H
#define _NOTE_H #define _NOTE_H
#include <sys/note.h> #include <sys/note.h>
@ -44,7 +44,7 @@
extern "C" { extern "C" {
#endif #endif
#define NOTE _NOTE #define NOTE _NOTE
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -25,12 +25,12 @@
*/ */
#ifndef _LIBSPL_PRIV_H #ifndef _LIBSPL_PRIV_H
#define _LIBSPL_PRIV_H #define _LIBSPL_PRIV_H
#include <sys/types.h> #include <sys/types.h>
/* Couldn't find this definition in OpenGrok */ /* Couldn't find this definition in OpenGrok */
#define PRIV_SYS_CONFIG "sys_config" #define PRIV_SYS_CONFIG "sys_config"
/* /*
* priv_op_t indicates a privilege operation type * priv_op_t indicates a privilege operation type

View File

@ -24,7 +24,7 @@
*/ */
#ifndef LIBSPL_RPC_TYPES_H #ifndef LIBSPL_RPC_TYPES_H
#define LIBSPL_RPC_TYPES_H #define LIBSPL_RPC_TYPES_H
#include_next <rpc/types.h> #include_next <rpc/types.h>
#include <sys/kmem.h> #include <sys/kmem.h>

View File

@ -30,7 +30,7 @@
*/ */
#ifndef LIBSPL_RPC_XDR_H #ifndef LIBSPL_RPC_XDR_H
#define LIBSPL_RPC_XDR_H #define LIBSPL_RPC_XDR_H
#include_next <rpc/xdr.h> #include_next <rpc/xdr.h>
@ -55,10 +55,10 @@ typedef struct xdr_bytesrec {
* XDR_RDMANOCHUNK - for xdr implementaion over RDMA, sets private flags in * XDR_RDMANOCHUNK - for xdr implementaion over RDMA, sets private flags in
* the XDR stream moving over RDMA. * the XDR stream moving over RDMA.
*/ */
#define XDR_PEEK 2 #define XDR_PEEK 2
#define XDR_SKIPBYTES 3 #define XDR_SKIPBYTES 3
#define XDR_RDMAGET 4 #define XDR_RDMAGET 4
#define XDR_RDMASET 5 #define XDR_RDMASET 5
extern bool_t xdr_control(XDR *xdrs, int request, void *info); extern bool_t xdr_control(XDR *xdrs, int request, void *info);

View File

@ -27,8 +27,8 @@
#include_next <stdio.h> #include_next <stdio.h>
#ifndef _LIBSPL_STDIO_H #ifndef _LIBSPL_STDIO_H
#define _LIBSPL_STDIO_H #define _LIBSPL_STDIO_H
#define enable_extended_FILE_stdio(fd, sig) ((void) 0) #define enable_extended_FILE_stdio(fd, sig) ((void) 0)
#endif #endif

View File

@ -27,7 +27,7 @@
#include_next <stdlib.h> #include_next <stdlib.h>
#ifndef _LIBSPL_STDLIB_H #ifndef _LIBSPL_STDLIB_H
#define _LIBSPL_STDLIB_H #define _LIBSPL_STDLIB_H
extern const char *getexecname(void); extern const char *getexecname(void);

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _LIBSPL_STRING_H #ifndef _LIBSPL_STRING_H
#define _LIBSPL_STRING_H #define _LIBSPL_STRING_H
#include_next <string.h> #include_next <string.h>

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _LIBSPL_STRINGS_H #ifndef _LIBSPL_STRINGS_H
#define _LIBSPL_STRINGS_H #define _LIBSPL_STRINGS_H
#include <string.h> #include <string.h>
#include_next <strings.h> #include_next <strings.h>

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYNCH_H #ifndef _LIBSPL_SYNCH_H
#define _LIBSPL_SYNCH_H #define _LIBSPL_SYNCH_H
#endif #endif

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYS_BITMAP_H #ifndef _LIBSPL_SYS_BITMAP_H
#define _LIBSPL_SYS_BITMAP_H #define _LIBSPL_SYS_BITMAP_H
#endif #endif

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _SYS_CALLB_H #ifndef _SYS_CALLB_H
#define _SYS_CALLB_H #define _SYS_CALLB_H
#endif #endif

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYS_CMN_ERR_H #ifndef _LIBSPL_SYS_CMN_ERR_H
#define _LIBSPL_SYS_CMN_ERR_H #define _LIBSPL_SYS_CMN_ERR_H
#endif #endif

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYS_COMPRESS_H #ifndef _LIBSPL_SYS_COMPRESS_H
#define _LIBSPL_SYS_COMPRESS_H #define _LIBSPL_SYS_COMPRESS_H
#endif /* _LIBSPL_SYS_COMPRESS_H */ #endif /* _LIBSPL_SYS_COMPRESS_H */

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _LIBSPL_SYS_CRED_H #ifndef _LIBSPL_SYS_CRED_H
#define _LIBSPL_SYS_CRED_H #define _LIBSPL_SYS_CRED_H
typedef struct cred cred_t; typedef struct cred cred_t;

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _LIBSPL_SYS_DEBUG_H #ifndef _LIBSPL_SYS_DEBUG_H
#define _LIBSPL_SYS_DEBUG_H #define _LIBSPL_SYS_DEBUG_H
#include <assert.h> #include <assert.h>

View File

@ -25,8 +25,8 @@
*/ */
#ifndef _SYS_FEATURE_TESTS_H #ifndef _SYS_FEATURE_TESTS_H
#define _SYS_FEATURE_TESTS_H #define _SYS_FEATURE_TESTS_H
#define __NORETURN __attribute__((__noreturn__)) #define __NORETURN __attribute__((__noreturn__))
#endif #endif

View File

@ -25,26 +25,26 @@
*/ */
#ifndef _LIBSPL_SYS_FILE_H #ifndef _LIBSPL_SYS_FILE_H
#define _LIBSPL_SYS_FILE_H #define _LIBSPL_SYS_FILE_H
#include_next <sys/file.h> #include_next <sys/file.h>
#include <sys/user.h> #include <sys/user.h>
#define FREAD 1 #define FREAD 1
#define FWRITE 2 #define FWRITE 2
//#define FAPPEND 8 // #define FAPPEND 8
#define FCREAT O_CREAT #define FCREAT O_CREAT
#define FTRUNC O_TRUNC #define FTRUNC O_TRUNC
#define FOFFMAX O_LARGEFILE #define FOFFMAX O_LARGEFILE
#define FSYNC O_SYNC #define FSYNC O_SYNC
#define FDSYNC O_DSYNC #define FDSYNC O_DSYNC
#define FRSYNC O_RSYNC #define FRSYNC O_RSYNC
#define FEXCL O_EXCL #define FEXCL O_EXCL
#define FNODSYNC 0x10000 /* fsync pseudo flag */ #define FNODSYNC 0x10000 /* fsync pseudo flag */
#define FNOFOLLOW 0x20000 /* don't follow symlinks */ #define FNOFOLLOW 0x20000 /* don't follow symlinks */
#define FIGNORECASE 0x80000 /* request case-insensitive lookups */ #define FIGNORECASE 0x80000 /* request case-insensitive lookups */
#endif #endif

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _SYS_FRAME_H #ifndef _SYS_FRAME_H
#define _SYS_FRAME_H #define _SYS_FRAME_H
#include <sys/types.h> #include <sys/types.h>

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYS_INT_LIMITS_H #ifndef _LIBSPL_SYS_INT_LIMITS_H
#define _LIBSPL_SYS_INT_LIMITS_H #define _LIBSPL_SYS_INT_LIMITS_H
#endif #endif

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _SOL_SYS_INT_TYPES_H #ifndef _SOL_SYS_INT_TYPES_H
#define _SOL_SYS_INT_TYPES_H #define _SOL_SYS_INT_TYPES_H
#include <inttypes.h> #include <inttypes.h>

View File

@ -25,10 +25,10 @@
*/ */
#ifndef _SOL_SYS_INTTYPES_H #ifndef _SOL_SYS_INTTYPES_H
#define _SOL_SYS_INTTYPES_H #define _SOL_SYS_INTTYPES_H
#include <inttypes.h> #include <inttypes.h>
#define _INT64_TYPE #define _INT64_TYPE
#endif #endif

View File

@ -35,91 +35,91 @@ extern "C" {
#if defined(__x86_64) || defined(__x86_64__) #if defined(__x86_64) || defined(__x86_64__)
#if !defined(__x86_64) #if !defined(__x86_64)
#define __x86_64 #define __x86_64
#endif #endif
#if !defined(__amd64) #if !defined(__amd64)
#define __amd64 #define __amd64
#endif #endif
#if !defined(__x86) #if !defined(__x86)
#define __x86 #define __x86
#endif #endif
#if !defined(_LP64) #if !defined(_LP64)
#define _LP64 #define _LP64
#endif #endif
#if !defined(_LITTLE_ENDIAN) #if !defined(_LITTLE_ENDIAN)
#define _LITTLE_ENDIAN #define _LITTLE_ENDIAN
#endif #endif
#define _SUNOS_VTOC_16 #define _SUNOS_VTOC_16
/* i386 arch specific defines */ /* i386 arch specific defines */
#elif defined(__i386) || defined(__i386__) #elif defined(__i386) || defined(__i386__)
#if !defined(__i386) #if !defined(__i386)
#define __i386 #define __i386
#endif #endif
#if !defined(__x86) #if !defined(__x86)
#define __x86 #define __x86
#endif #endif
#if !defined(_ILP32) #if !defined(_ILP32)
#define _ILP32 #define _ILP32
#endif #endif
#if !defined(_LITTLE_ENDIAN) #if !defined(_LITTLE_ENDIAN)
#define _LITTLE_ENDIAN #define _LITTLE_ENDIAN
#endif #endif
#define _SUNOS_VTOC_16 #define _SUNOS_VTOC_16
/* powerpc arch specific defines */ /* powerpc arch specific defines */
#elif defined(__powerpc) || defined(__powerpc__) #elif defined(__powerpc) || defined(__powerpc__)
#if !defined(__powerpc) #if !defined(__powerpc)
#define __powerpc #define __powerpc
#endif #endif
#if !defined(__powerpc__) #if !defined(__powerpc__)
#define __powerpc__ #define __powerpc__
#endif #endif
#if !defined(_LP64) #if !defined(_LP64)
#ifdef __powerpc64__ #ifdef __powerpc64__
#define _LP64 #define _LP64
#else #else
#define _LP32 #define _LP32
#endif #endif
#endif #endif
#if !defined(_BIG_ENDIAN) #if !defined(_BIG_ENDIAN)
#define _BIG_ENDIAN #define _BIG_ENDIAN
#endif #endif
#define _SUNOS_VTOC_16 #define _SUNOS_VTOC_16
/* arm arch specific defines */ /* arm arch specific defines */
#elif defined(__arm) || defined(__arm__) #elif defined(__arm) || defined(__arm__)
#if !defined(__arm) #if !defined(__arm)
#define __arm #define __arm
#endif #endif
#if !defined(__arm__) #if !defined(__arm__)
#define __arm__ #define __arm__
#endif #endif
#if defined(__ARMEL__) #if defined(__ARMEL__)
#define _LITTLE_ENDIAN #define _LITTLE_ENDIAN
#else #else
#define _BIG_ENDIAN #define _BIG_ENDIAN
#endif #endif
#define _SUNOS_VTOC_16 #define _SUNOS_VTOC_16
#else /* Currently only x86_64, i386, arm, and powerpc arches supported */ #else /* Currently only x86_64, i386, arm, and powerpc arches supported */
#error "Unsupported ISA type" #error "Unsupported ISA type"

View File

@ -35,8 +35,8 @@ extern "C" {
#define KM_SLEEP 0x00000000 /* same as KM_SLEEP */ #define KM_SLEEP 0x00000000 /* same as KM_SLEEP */
#define KM_NOSLEEP 0x00000001 /* same as KM_NOSLEEP */ #define KM_NOSLEEP 0x00000001 /* same as KM_NOSLEEP */
#define kmem_alloc(size, flags) malloc(size) #define kmem_alloc(size, flags) malloc(size)
#define kmem_free(ptr, size) free(ptr) #define kmem_free(ptr, size) free(ptr)
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYS_MKDEV_H #ifndef _LIBSPL_SYS_MKDEV_H
#define _LIBSPL_SYS_MKDEV_H #define _LIBSPL_SYS_MKDEV_H
#endif #endif

View File

@ -19,7 +19,7 @@
* *
* CDDL HEADER END * CDDL HEADER END
*/ */
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T*/ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */ /* All Rights Reserved */
/* /*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
@ -28,7 +28,7 @@
/* Copyright 2006 Ricardo Correia */ /* Copyright 2006 Ricardo Correia */
#ifndef _SYS_MNTTAB_H #ifndef _SYS_MNTTAB_H
#define _SYS_MNTTAB_H #define _SYS_MNTTAB_H
#include <stdio.h> #include <stdio.h>
#include <mntent.h> #include <mntent.h>
@ -77,10 +77,10 @@ static inline char *_sol_hasmntopt(struct mnttab *mnt, char *opt)
mnt_new.mnt_opts = mnt->mnt_mntopts; mnt_new.mnt_opts = mnt->mnt_mntopts;
return hasmntopt(&mnt_new, opt); return (hasmntopt(&mnt_new, opt));
} }
#define hasmntopt _sol_hasmntopt #define hasmntopt _sol_hasmntopt
#define getmntent _sol_getmntent #define getmntent _sol_getmntent
#endif #endif

View File

@ -27,7 +27,7 @@
#include_next <sys/mount.h> #include_next <sys/mount.h>
#ifndef _LIBSPL_SYS_MOUNT_H #ifndef _LIBSPL_SYS_MOUNT_H
#define _LIBSPL_SYS_MOUNT_H #define _LIBSPL_SYS_MOUNT_H
#include <sys/mntent.h> #include <sys/mntent.h>
#include <assert.h> #include <assert.h>
@ -39,7 +39,7 @@
* and we don't want to require the kernel headers * and we don't want to require the kernel headers
*/ */
#if !defined(BLKGETSIZE64) #if !defined(BLKGETSIZE64)
#define BLKGETSIZE64 _IOR(0x12, 114, size_t) #define BLKGETSIZE64 _IOR(0x12, 114, size_t)
#endif #endif
/* /*
@ -48,7 +48,7 @@
* headers define MS_DIRSYNC to be S_WRITE. * headers define MS_DIRSYNC to be S_WRITE.
*/ */
#if !defined(MS_DIRSYNC) #if !defined(MS_DIRSYNC)
#define MS_DIRSYNC S_WRITE #define MS_DIRSYNC S_WRITE
#endif #endif
/* /*
@ -71,15 +71,15 @@
* kernel back to 2.4.11 so we define them correctly if they are missing. * kernel back to 2.4.11 so we define them correctly if they are missing.
*/ */
#ifdef MNT_FORCE #ifdef MNT_FORCE
# define MS_FORCE MNT_FORCE #define MS_FORCE MNT_FORCE
#else #else
# define MS_FORCE 0x00000001 #define MS_FORCE 0x00000001
#endif /* MNT_FORCE */ #endif /* MNT_FORCE */
#ifdef MNT_DETACH #ifdef MNT_DETACH
# define MS_DETACH MNT_DETACH #define MS_DETACH MNT_DETACH
#else #else
# define MS_DETACH 0x00000002 #define MS_DETACH 0x00000002
#endif /* MNT_DETACH */ #endif /* MNT_DETACH */
/* /*
@ -87,6 +87,6 @@
* compatibility, MS_OVERLAY is defined to explicitly have the user * compatibility, MS_OVERLAY is defined to explicitly have the user
* provide a flag (-O) to mount over a non empty directory. * provide a flag (-O) to mount over a non empty directory.
*/ */
#define MS_OVERLAY 0x00000004 #define MS_OVERLAY 0x00000004
#endif /* _LIBSPL_SYS_MOUNT_H */ #endif /* _LIBSPL_SYS_MOUNT_H */

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _LIBSPL_SYS_PARAM_H #ifndef _LIBSPL_SYS_PARAM_H
#define _LIBSPL_SYS_PARAM_H #define _LIBSPL_SYS_PARAM_H
#include_next <sys/param.h> #include_next <sys/param.h>
#include <unistd.h> #include <unistd.h>
@ -43,20 +43,20 @@
* Note that the blocked devices are assumed to have DEV_BSIZE * Note that the blocked devices are assumed to have DEV_BSIZE
* "sectors" and that fragments must be some multiple of this size. * "sectors" and that fragments must be some multiple of this size.
*/ */
#define MAXBSIZE 8192 #define MAXBSIZE 8192
#define DEV_BSIZE 512 #define DEV_BSIZE 512
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
#define MAXNAMELEN 256 #define MAXNAMELEN 256
#define MAXOFFSET_T LLONG_MAX #define MAXOFFSET_T LLONG_MAX
#define UID_NOBODY 60001 /* user ID no body */ #define UID_NOBODY 60001 /* user ID no body */
#define GID_NOBODY UID_NOBODY #define GID_NOBODY UID_NOBODY
#define UID_NOACCESS 60002 /* user ID no access */ #define UID_NOACCESS 60002 /* user ID no access */
#define MAXUID UINT32_MAX /* max user id */ #define MAXUID UINT32_MAX /* max user id */
#define MAXPROJID MAXUID /* max project id */ #define MAXPROJID MAXUID /* max project id */
#define PAGESIZE (sysconf(_SC_PAGESIZE)) #define PAGESIZE (sysconf(_SC_PAGESIZE))
#endif #endif

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYS_PRIV_H #ifndef _LIBSPL_SYS_PRIV_H
#define _LIBSPL_SYS_PRIV_H #define _LIBSPL_SYS_PRIV_H
#endif #endif

View File

@ -25,9 +25,9 @@
*/ */
#ifndef _LIBSPL_SYS_PROCESSOR_H #ifndef _LIBSPL_SYS_PROCESSOR_H
#define _LIBSPL_SYS_PROCESSOR_H #define _LIBSPL_SYS_PROCESSOR_H
#define getcpuid() (-1) #define getcpuid() (-1)
typedef int processorid_t; typedef int processorid_t;

View File

@ -25,12 +25,12 @@
*/ */
#ifndef _LIBSPL_SYS_SDT_H #ifndef _LIBSPL_SYS_SDT_H
#define _LIBSPL_SYS_SDT_H #define _LIBSPL_SYS_SDT_H
#define DTRACE_PROBE(a) ((void) 0) #define DTRACE_PROBE(a) ((void) 0)
#define DTRACE_PROBE1(a,b,c) ((void) 0) #define DTRACE_PROBE1(a, b, c) ((void) 0)
#define DTRACE_PROBE2(a,b,c,d,e) ((void) 0) #define DTRACE_PROBE2(a, b, c, d, e) ((void) 0)
#define DTRACE_PROBE3(a,b,c,d,e,f,g) ((void) 0) #define DTRACE_PROBE3(a, b, c, d, e, f, g) ((void) 0)
#define DTRACE_PROBE4(a,b,c,d,e,f,g,h,i) ((void) 0) #define DTRACE_PROBE4(a, b, c, d, e, f, g, h, i) ((void) 0)
#endif #endif

View File

@ -23,11 +23,11 @@
* Portions Copyright 2008 Sun Microsystems, Inc. All Rights reserved. * Portions Copyright 2008 Sun Microsystems, Inc. All Rights reserved.
*/ */
#ifndef _SYS_STACK_H #ifndef _SYS_STACK_H
#define _SYS_STACK_H #define _SYS_STACK_H
#include <pthread.h> #include <pthread.h>
#define STACK_BIAS 0 #define STACK_BIAS 0
#ifdef __USE_GNU #ifdef __USE_GNU
@ -39,7 +39,7 @@ stack_getbounds(stack_t *sp)
rc = pthread_getattr_np(pthread_self(), &attr); rc = pthread_getattr_np(pthread_self(), &attr);
if (rc) if (rc)
return rc; return (rc);
rc = pthread_attr_getstack(&attr, &sp->ss_sp, &sp->ss_size); rc = pthread_attr_getstack(&attr, &sp->ss_sp, &sp->ss_size);
if (rc == 0) if (rc == 0)
@ -47,7 +47,7 @@ stack_getbounds(stack_t *sp)
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
return rc; return (rc);
} }
static inline int static inline int
@ -57,15 +57,17 @@ thr_stksegment(stack_t *sp)
rc = stack_getbounds(sp); rc = stack_getbounds(sp);
if (rc) if (rc)
return rc; return (rc);
/* thr_stksegment() is expected to set sp.ss_sp to the high stack /*
* address, but the stack_getbounds() interface is expected to * thr_stksegment() is expected to set sp.ss_sp to the high stack
* set sp.ss_sp to the low address. Adjust accordingly. */ * address, but the stack_getbounds() interface is expected to
* set sp.ss_sp to the low address. Adjust accordingly.
*/
sp->ss_sp = (void *)(((uintptr_t)sp->ss_sp) + sp->ss_size); sp->ss_sp = (void *)(((uintptr_t)sp->ss_sp) + sp->ss_size);
sp->ss_flags = 0; sp->ss_flags = 0;
return rc; return (rc);
} }
#endif /* __USE_GNU */ #endif /* __USE_GNU */

View File

@ -24,7 +24,7 @@
*/ */
#ifndef _LIBSPL_SYS_STAT_H #ifndef _LIBSPL_SYS_STAT_H
#define _LIBSPL_SYS_STAT_H #define _LIBSPL_SYS_STAT_H
#include_next <sys/stat.h> #include_next <sys/stat.h>
@ -37,14 +37,14 @@ static inline int
fstat64_blk(int fd, struct stat64 *st) fstat64_blk(int fd, struct stat64 *st)
{ {
if (fstat64(fd, st) == -1) if (fstat64(fd, st) == -1)
return -1; return (-1);
/* In Linux we need to use an ioctl to get the size of a block device */ /* In Linux we need to use an ioctl to get the size of a block device */
if (S_ISBLK(st->st_mode)) { if (S_ISBLK(st->st_mode)) {
if (ioctl(fd, BLKGETSIZE64, &st->st_size) != 0) if (ioctl(fd, BLKGETSIZE64, &st->st_size) != 0)
return -1; return (-1);
} }
return 0; return (0);
} }
#endif /* _LIBSPL_SYS_STAT_H */ #endif /* _LIBSPL_SYS_STAT_H */

View File

@ -24,6 +24,6 @@
*/ */
#ifndef _LIBSPL_SYS_STROPTS_H #ifndef _LIBSPL_SYS_STROPTS_H
#define _LIBSPL_SYS_STROPTS_H #define _LIBSPL_SYS_STROPTS_H
#endif /* _LIBSPL_SYS_STROPTS_H */ #endif /* _LIBSPL_SYS_STROPTS_H */

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYS_SYSEVENT_H #ifndef _LIBSPL_SYS_SYSEVENT_H
#define _LIBSPL_SYS_SYSEVENT_H #define _LIBSPL_SYS_SYSEVENT_H
#endif #endif

View File

@ -25,41 +25,41 @@
*/ */
#ifndef _LIBSPL_SYS_SYSMACROS_H #ifndef _LIBSPL_SYS_SYSMACROS_H
#define _LIBSPL_SYS_SYSMACROS_H #define _LIBSPL_SYS_SYSMACROS_H
#include_next <sys/sysmacros.h> #include_next <sys/sysmacros.h>
/* common macros */ /* common macros */
#ifndef MIN #ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif #endif
#ifndef MAX #ifndef MAX
#define MAX(a, b) ((a) < (b) ? (b) : (a)) #define MAX(a, b) ((a) < (b) ? (b) : (a))
#endif #endif
#ifndef ABS #ifndef ABS
#define ABS(a) ((a) < 0 ? -(a) : (a)) #define ABS(a) ((a) < 0 ? -(a) : (a))
#endif #endif
#define makedevice(maj,min) makedev(maj,min) #define makedevice(maj, min) makedev(maj, min)
#define _sysconf(a) sysconf(a) #define _sysconf(a) sysconf(a)
#define __NORETURN __attribute__ ((noreturn)) #define __NORETURN __attribute__((noreturn))
/* /*
* Compatibility macros/typedefs needed for Solaris -> Linux port * Compatibility macros/typedefs needed for Solaris -> Linux port
*/ */
#define P2ALIGN(x, align) ((x) & -(align)) #define P2ALIGN(x, align) ((x) & -(align))
#define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1) #define P2CROSS(x, y, align) (((x) ^ (y)) > (align) - 1)
#define P2ROUNDUP(x, align) (-(-(x) & -(align))) #define P2ROUNDUP(x, align) (-(-(x) & -(align)))
#define P2ROUNDUP_TYPED(x, align, type) \ #define P2ROUNDUP_TYPED(x, align, type) \
(-(-(type)(x) & -(type)(align))) (-(-(type)(x) & -(type)(align)))
#define P2BOUNDARY(off, len, align) \ #define P2BOUNDARY(off, len, align) \
(((off) ^ ((off) + (len) - 1)) > (align) - 1) (((off) ^ ((off) + (len) - 1)) > (align) - 1)
#define P2PHASE(x, align) ((x) & ((align) - 1)) #define P2PHASE(x, align) ((x) & ((align) - 1))
#define P2NPHASE(x, align) (-(x) & ((align) - 1)) #define P2NPHASE(x, align) (-(x) & ((align) - 1))
#define P2NPHASE_TYPED(x, align, type) \ #define P2NPHASE_TYPED(x, align, type) \
(-(type)(x) & ((type)(align) - 1)) (-(type)(x) & ((type)(align) - 1))
#define ISP2(x) (((x) & ((x) - 1)) == 0) #define ISP2(x) (((x) & ((x) - 1)) == 0)
#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0) #define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0)
/* /*
* Typed version of the P2* macros. These macros should be used to ensure * Typed version of the P2* macros. These macros should be used to ensure
@ -72,22 +72,22 @@
* or * or
* P2ROUNDUP_TYPED(x, PAGESIZE, uint64_t) * P2ROUNDUP_TYPED(x, PAGESIZE, uint64_t)
*/ */
#define P2ALIGN_TYPED(x, align, type) \ #define P2ALIGN_TYPED(x, align, type) \
((type)(x) & -(type)(align)) ((type)(x) & -(type)(align))
#define P2PHASE_TYPED(x, align, type) \ #define P2PHASE_TYPED(x, align, type) \
((type)(x) & ((type)(align) - 1)) ((type)(x) & ((type)(align) - 1))
#define P2NPHASE_TYPED(x, align, type) \ #define P2NPHASE_TYPED(x, align, type) \
(-(type)(x) & ((type)(align) - 1)) (-(type)(x) & ((type)(align) - 1))
#define P2ROUNDUP_TYPED(x, align, type) \ #define P2ROUNDUP_TYPED(x, align, type) \
(-(-(type)(x) & -(type)(align))) (-(-(type)(x) & -(type)(align)))
#define P2END_TYPED(x, align, type) \ #define P2END_TYPED(x, align, type) \
(-(~(type)(x) & -(type)(align))) (-(~(type)(x) & -(type)(align)))
#define P2PHASEUP_TYPED(x, align, phase, type) \ #define P2PHASEUP_TYPED(x, align, phase, type) \
((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align))) ((type)(phase) - (((type)(phase) - (type)(x)) & -(type)(align)))
#define P2CROSS_TYPED(x, y, align, type) \ #define P2CROSS_TYPED(x, y, align, type) \
(((type)(x) ^ (type)(y)) > (type)(align) - 1) (((type)(x) ^ (type)(y)) > (type)(align) - 1)
#define P2SAMEHIGHBIT_TYPED(x, y, type) \ #define P2SAMEHIGHBIT_TYPED(x, y, type) \
(((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y))) (((type)(x) ^ (type)(y)) < ((type)(x) & (type)(y)))
/* avoid any possibility of clashing with <stddef.h> version */ /* avoid any possibility of clashing with <stddef.h> version */

View File

@ -25,13 +25,13 @@
*/ */
#ifndef _LIBSPL_SYS_SYSTEMINFO_H #ifndef _LIBSPL_SYS_SYSTEMINFO_H
#define _LIBSPL_SYS_SYSTEMINFO_H #define _LIBSPL_SYS_SYSTEMINFO_H
#define HW_INVALID_HOSTID 0xFFFFFFFF /* an invalid hostid */ #define HW_INVALID_HOSTID 0xFFFFFFFF /* an invalid hostid */
#define HW_HOSTID_LEN 11 /* minimum buffer size needed */ #define HW_HOSTID_LEN 11 /* minimum buffer size needed */
/* to hold a decimal or hex */ /* to hold a decimal or hex */
/* hostid string */ /* hostid string */
#define sysinfo(cmd,buf,cnt) (-1) #define sysinfo(cmd, buf, cnt) (-1)
#endif #endif

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYS_SYSTM_H #ifndef _LIBSPL_SYS_SYSTM_H
#define _LIBSPL_SYS_SYSTM_H #define _LIBSPL_SYS_SYSTM_H
#endif /* _LIBSPL_SYS_SYSTM_H */ #endif /* _LIBSPL_SYS_SYSTM_H */

View File

@ -25,37 +25,37 @@
*/ */
#ifndef _LIBSPL_SYS_TIME_H #ifndef _LIBSPL_SYS_TIME_H
#define _LIBSPL_SYS_TIME_H #define _LIBSPL_SYS_TIME_H
#include_next <sys/time.h> #include_next <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#ifndef SEC #ifndef SEC
#define SEC 1 #define SEC 1
#endif #endif
#ifndef MILLISEC #ifndef MILLISEC
#define MILLISEC 1000 #define MILLISEC 1000
#endif #endif
#ifndef MICROSEC #ifndef MICROSEC
#define MICROSEC 1000000 #define MICROSEC 1000000
#endif #endif
#ifndef NANOSEC #ifndef NANOSEC
#define NANOSEC 1000000000 #define NANOSEC 1000000000
#endif #endif
#ifndef NSEC_PER_USEC #ifndef NSEC_PER_USEC
#define NSEC_PER_USEC 1000L #define NSEC_PER_USEC 1000L
#endif #endif
#ifndef MSEC2NSEC #ifndef MSEC2NSEC
#define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC)) #define MSEC2NSEC(m) ((hrtime_t)(m) * (NANOSEC / MILLISEC))
#endif #endif
#ifndef NSEC2MSEC #ifndef NSEC2MSEC
#define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC)) #define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC))
#endif #endif
extern hrtime_t gethrtime(void); extern hrtime_t gethrtime(void);

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _LIBSPL_SYS_TYPES_H #ifndef _LIBSPL_SYS_TYPES_H
#define _LIBSPL_SYS_TYPES_H #define _LIBSPL_SYS_TYPES_H
#include <sys/isa_defs.h> #include <sys/isa_defs.h>
#include <sys/feature_tests.h> #include <sys/feature_tests.h>
@ -53,9 +53,9 @@ typedef u_longlong_t u_offset_t;
typedef u_longlong_t len_t; typedef u_longlong_t len_t;
typedef longlong_t diskaddr_t; typedef longlong_t diskaddr_t;
typedef ulong_t pfn_t; /* page frame number */ typedef ulong_t pfn_t; /* page frame number */
typedef ulong_t pgcnt_t; /* number of pages */ typedef ulong_t pgcnt_t; /* number of pages */
typedef long spgcnt_t; /* signed number of pages */ typedef long spgcnt_t; /* signed number of pages */
typedef longlong_t hrtime_t; typedef longlong_t hrtime_t;
typedef struct timespec timestruc_t; typedef struct timespec timestruc_t;

View File

@ -45,14 +45,14 @@
typedef struct iovec iovec_t; typedef struct iovec iovec_t;
typedef enum uio_rw { typedef enum uio_rw {
UIO_READ = 0, UIO_READ = 0,
UIO_WRITE = 1, UIO_WRITE = 1,
} uio_rw_t; } uio_rw_t;
typedef enum uio_seg { typedef enum uio_seg {
UIO_USERSPACE = 0, UIO_USERSPACE = 0,
UIO_SYSSPACE = 1, UIO_SYSSPACE = 1,
UIO_USERISPACE= 2, UIO_USERISPACE = 2,
} uio_seg_t; } uio_seg_t;
typedef struct uio { typedef struct uio {
@ -102,7 +102,7 @@ typedef struct xuio {
} xu_ext; } xu_ext;
} xuio_t; } xuio_t;
#define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv #define XUIO_XUZC_PRIV(xuio) xuio->xu_ext.xu_zc.xu_zc_priv
#define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw #define XUIO_XUZC_RW(xuio) xuio->xu_ext.xu_zc.xu_zc_rw
#endif /* _SYS_UIO_H */ #endif /* _SYS_UIO_H */

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _LIBSPL_UTSNAME_H #ifndef _LIBSPL_UTSNAME_H
#define _LIBSPL_UTSNAME_H #define _LIBSPL_UTSNAME_H
#include_next <sys/utsname.h> #include_next <sys/utsname.h>

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _SYS_VA_LIST_H #ifndef _SYS_VA_LIST_H
#define _SYS_VA_LIST_H #define _SYS_VA_LIST_H
#include <stdarg.h> #include <stdarg.h>

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYS_VARARGS_H #ifndef _LIBSPL_SYS_VARARGS_H
#define _LIBSPL_SYS_VARARGS_H #define _LIBSPL_SYS_VARARGS_H
#endif #endif

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYS_VNODE_H #ifndef _LIBSPL_SYS_VNODE_H
#define _LIBSPL_SYS_VNODE_H #define _LIBSPL_SYS_VNODE_H
#endif /* _LIBSPL_SYS_VNODE_H */ #endif /* _LIBSPL_SYS_VNODE_H */

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_SYS_ZONE_H #ifndef _LIBSPL_SYS_ZONE_H
#define _LIBSPL_SYS_ZONE_H #define _LIBSPL_SYS_ZONE_H
#endif #endif

View File

@ -25,6 +25,6 @@
*/ */
#ifndef _LIBSPL_THREAD_H #ifndef _LIBSPL_THREAD_H
#define _LIBSPL_THREAD_H #define _LIBSPL_THREAD_H
#endif /* _LIBSPL_THREAD_H */ #endif /* _LIBSPL_THREAD_H */

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _LIBSPL_TZFILE_H #ifndef _LIBSPL_TZFILE_H
#define _LIBSPL_TZFILE_H #define _LIBSPL_TZFILE_H
#include <sys/tzfile.h> #include <sys/tzfile.h>

View File

@ -25,7 +25,7 @@
*/ */
#ifndef _LIBSPL_UCRED_H #ifndef _LIBSPL_UCRED_H
#define _LIBSPL_UCRED_H #define _LIBSPL_UCRED_H
typedef int ucred_t; typedef int ucred_t;

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