Skip to content

Commit 5935a4b

Browse files
committed
Merge remote-tracking branch 'zfsonlinux/master' into zcrnomem
2 parents bf60809 + e723838 commit 5935a4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+460
-311
lines changed

Makefile.am

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ filter_executable = -exec test -x '{}' \; -print
126126
PHONY += shellcheck
127127
shellcheck:
128128
@if type shellcheck > /dev/null 2>&1; then \
129-
shellcheck --exclude=SC1090 --exclude=SC1117 --format=gcc \
130-
$$(find ${top_srcdir}/scripts/*.sh -type f) \
131-
$$(find ${top_srcdir}/cmd/zed/zed.d/*.sh -type f) \
129+
shellcheck --exclude=SC1090,SC1117,SC1091 --format=gcc \
130+
$$(find ${top_srcdir} -name "config*" -prune -name tests -prune \
131+
-o -name "*.sh" -o -name "*.sh.in" -type f) \
132132
$$(find ${top_srcdir}/cmd/zpool/zpool.d/* \
133133
-type f ${filter_executable}); \
134134
else \

cmd/fsck_zfs/fsck.zfs.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ for dataset in "$@"; do
2626

2727
case "$(@sbindir@/zpool list -Ho health "$pool")" in
2828
DEGRADED)
29-
ret=$(( $ret | 4 ))
29+
ret=$(( ret | 4 ))
3030
;;
3131
FAULTED)
3232
awk '!/^([[:space:]]*#.*)?$/ && $1 == "'"$dataset"'" && $3 == "zfs" {exit 1}' /etc/fstab || \
33-
ret=$(( $ret | 8 ))
33+
ret=$(( ret | 8 ))
3434
;;
3535
"")
3636
# Pool not found, error printed by zpool(8)
37-
ret=$(( $ret | 8 ))
37+
ret=$(( ret | 8 ))
3838
;;
3939
*)
4040
;;

cmd/raidz_test/raidz_test.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
static int *rand_data;
3838
raidz_test_opts_t rto_opts;
3939

40-
static char gdb[256];
41-
static const char gdb_tmpl[] = "gdb -ex \"set pagination 0\" -p %d";
40+
static char pid_s[16];
4241

4342
static void sig_handler(int signo)
4443
{
44+
int old_errno = errno;
4545
struct sigaction action;
4646
/*
4747
* Restore default action and re-raise signal so SIGSEGV and
@@ -52,10 +52,19 @@ static void sig_handler(int signo)
5252
action.sa_flags = 0;
5353
(void) sigaction(signo, &action, NULL);
5454

55-
if (rto_opts.rto_gdb)
56-
if (system(gdb)) { }
55+
if (rto_opts.rto_gdb) {
56+
pid_t pid = fork();
57+
if (pid == 0) {
58+
execlp("gdb", "gdb", "-ex", "set pagination 0",
59+
"-p", pid_s, NULL);
60+
_exit(-1);
61+
} else if (pid > 0)
62+
while (waitpid(pid, NULL, 0) == -1 && errno == EINTR)
63+
;
64+
}
5765

5866
raise(signo);
67+
errno = old_errno;
5968
}
6069

6170
static void print_opts(raidz_test_opts_t *opts, boolean_t force)
@@ -978,8 +987,8 @@ main(int argc, char **argv)
978987
struct sigaction action;
979988
int err = 0;
980989

981-
/* init gdb string early */
982-
(void) sprintf(gdb, gdb_tmpl, getpid());
990+
/* init gdb pid string early */
991+
(void) sprintf(pid_s, "%d", getpid());
983992

984993
action.sa_handler = sig_handler;
985994
sigemptyset(&action.sa_mask);

cmd/zed/zed.d/zed-functions.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@ zed_lock()
127127
# Obtain a lock on the file bound to the given file descriptor.
128128
#
129129
eval "exec ${fd}> '${lockfile}'"
130-
err="$(flock --exclusive "${fd}" 2>&1)"
131-
# shellcheck disable=SC2181
132-
if [ $? -ne 0 ]; then
130+
if ! err="$(flock --exclusive "${fd}" 2>&1)"; then
133131
zed_log_err "failed to lock \"${lockfile}\": ${err}"
134132
fi
135133

@@ -165,9 +163,7 @@ zed_unlock()
165163
fi
166164

167165
# Release the lock and close the file descriptor.
168-
err="$(flock --unlock "${fd}" 2>&1)"
169-
# shellcheck disable=SC2181
170-
if [ $? -ne 0 ]; then
166+
if ! err="$(flock --unlock "${fd}" 2>&1)"; then
171167
zed_log_err "failed to unlock \"${lockfile}\": ${err}"
172168
fi
173169
eval "exec ${fd}>&-"
@@ -271,7 +267,7 @@ zed_notify_email()
271267
-e "s/@SUBJECT@/${subject}/g")"
272268

273269
# shellcheck disable=SC2086
274-
eval "${ZED_EMAIL_PROG}" ${ZED_EMAIL_OPTS} < "${pathname}" >/dev/null 2>&1
270+
${ZED_EMAIL_PROG} ${ZED_EMAIL_OPTS} < "${pathname}" >/dev/null 2>&1
275271
rv=$?
276272
if [ "${rv}" -ne 0 ]; then
277273
zed_log_err "$(basename "${ZED_EMAIL_PROG}") exit=${rv}"

cmd/zgenhostid/zgenhostid.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
#include <time.h>
3737
#include <unistd.h>
3838

39-
static void usage(void);
40-
4139
static void
4240
usage(void)
4341
{
@@ -60,27 +58,19 @@ int
6058
main(int argc, char **argv)
6159
{
6260
/* default file path, can be optionally set by user */
63-
char path[PATH_MAX] = "/etc/hostid";
61+
const char *path = "/etc/hostid";
6462
/* holds converted user input or lrand48() generated value */
6563
unsigned long input_i = 0;
6664

6765
int opt;
68-
int pathlen;
6966
int force_fwrite = 0;
7067
while ((opt = getopt_long(argc, argv, "fo:h?", 0, 0)) != -1) {
7168
switch (opt) {
7269
case 'f':
7370
force_fwrite = 1;
7471
break;
7572
case 'o':
76-
pathlen = snprintf(path, sizeof (path), "%s", optarg);
77-
if (pathlen >= sizeof (path)) {
78-
fprintf(stderr, "%s\n", strerror(EOVERFLOW));
79-
exit(EXIT_FAILURE);
80-
} else if (pathlen < 1) {
81-
fprintf(stderr, "%s\n", strerror(EINVAL));
82-
exit(EXIT_FAILURE);
83-
}
73+
path = optarg;
8474
break;
8575
case 'h':
8676
case '?':
@@ -118,7 +108,7 @@ main(int argc, char **argv)
118108
if (force_fwrite == 0 && stat(path, &fstat) == 0 &&
119109
S_ISREG(fstat.st_mode)) {
120110
fprintf(stderr, "%s: %s\n", path, strerror(EEXIST));
121-
exit(EXIT_FAILURE);
111+
exit(EXIT_FAILURE);
122112
}
123113

124114
/*

cmd/zvol_wait/zvol_wait

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ filter_out_deleted_zvols() {
2020
OIFS="$IFS"
2121
IFS="
2222
"
23+
# shellcheck disable=SC2086
2324
zfs list -H -o name $zvols 2>/dev/null
2425
IFS="$OIFS"
2526
}

config/ax_python_devel.m4

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ variable to configure. See ``configure --help'' for reference.
148148
# Check if you have distutils, else fail
149149
#
150150
AC_MSG_CHECKING([for the distutils Python package])
151-
ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
152-
if test $? -eq 0; then
151+
if ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`; then
153152
AC_MSG_RESULT([yes])
154153
else
155154
AC_MSG_RESULT([no])

config/kernel-tmpfile.m4

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,43 @@ dnl # 3.11 API change
33
dnl # Add support for i_op->tmpfile
44
dnl #
55
AC_DEFUN([ZFS_AC_KERNEL_SRC_TMPFILE], [
6-
ZFS_LINUX_TEST_SRC([inode_operations_tmpfile], [
6+
dnl #
7+
dnl # 5.11 API change
8+
dnl # add support for userns parameter to tmpfile
9+
dnl #
10+
ZFS_LINUX_TEST_SRC([inode_operations_tmpfile_userns], [
711
#include <linux/fs.h>
8-
int tmpfile(struct inode *inode, struct dentry *dentry,
12+
int tmpfile(struct user_namespace *userns,
13+
struct inode *inode, struct dentry *dentry,
914
umode_t mode) { return 0; }
1015
static struct inode_operations
1116
iops __attribute__ ((unused)) = {
1217
.tmpfile = tmpfile,
1318
};
1419
],[])
20+
ZFS_LINUX_TEST_SRC([inode_operations_tmpfile], [
21+
#include <linux/fs.h>
22+
int tmpfile(struct inode *inode, struct dentry *dentry,
23+
umode_t mode) { return 0; }
24+
static struct inode_operations
25+
iops __attribute__ ((unused)) = {
26+
.tmpfile = tmpfile,
27+
};
28+
],[])
1529
])
1630

1731
AC_DEFUN([ZFS_AC_KERNEL_TMPFILE], [
1832
AC_MSG_CHECKING([whether i_op->tmpfile() exists])
19-
ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile], [
33+
ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile_userns], [
2034
AC_MSG_RESULT(yes)
2135
AC_DEFINE(HAVE_TMPFILE, 1, [i_op->tmpfile() exists])
36+
AC_DEFINE(HAVE_TMPFILE_USERNS, 1, [i_op->tmpfile() has userns])
2237
],[
23-
AC_MSG_RESULT(no)
38+
ZFS_LINUX_TEST_RESULT([inode_operations_tmpfile], [
39+
AC_MSG_RESULT(yes)
40+
AC_DEFINE(HAVE_TMPFILE, 1, [i_op->tmpfile() exists])
41+
],[
42+
AC_MSG_RESULT(no)
43+
])
2444
])
2545
])

contrib/bash_completion.d/zfs.in

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,25 @@ __zfs_list_filesystems()
6262

6363
__zfs_match_snapshot()
6464
{
65-
local base_dataset=${cur%@*}
66-
if [[ $base_dataset != $cur ]]
65+
local base_dataset="${cur%@*}"
66+
if [ "$base_dataset" != "$cur" ]
6767
then
68-
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 $base_dataset
68+
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 "$base_dataset"
6969
else
70-
if [[ $cur != "" ]] && __zfs_list_datasets $cur &> /dev/null
70+
if [ "$cur" != "" ] && __zfs_list_datasets "$cur" &> /dev/null
7171
then
72-
$__ZFS_CMD list -H -o name -s name -t filesystem -r $cur | tail -n +2
72+
$__ZFS_CMD list -H -o name -s name -t filesystem -r "$cur" | tail -n +2
7373
# We output the base dataset name even though we might be
7474
# completing a command that can only take a snapshot, because it
7575
# prevents bash from considering the completion finished when it
7676
# ends in the bare @.
77-
echo $cur
78-
echo $cur@
77+
echo "$cur"
78+
echo "$cur@"
7979
else
80-
local datasets=$(__zfs_list_datasets)
80+
local datasets
81+
datasets="$(__zfs_list_datasets)"
8182
# As above
82-
echo $datasets
83+
echo "$datasets"
8384
if [[ "$cur" == */ ]]
8485
then
8586
# If the current command ends with a slash, then the only way
@@ -89,54 +90,56 @@ __zfs_match_snapshot()
8990
local num_children
9091
# This is actually off by one as zfs list includes the named
9192
# dataset in addition to its children
92-
num_children=$(__zfs_list_datasets -d 1 ${cur%/} 2> /dev/null | wc -l)
93+
num_children=$(__zfs_list_datasets -d 1 "${cur%/}" 2> /dev/null | wc -l)
9394
if [[ $num_children != 2 ]]
9495
then
9596
return 0
9697
fi
9798
fi
98-
echo "$datasets" | awk '{print $1"@"}'
99+
echo "$datasets" | awk '{print $1 "@"}'
99100
fi
100101
fi
101102
}
102103

103104
__zfs_match_snapshot_or_bookmark()
104105
{
105-
local base_dataset=${cur%[#@]*}
106-
if [[ $base_dataset != $cur ]]
106+
local base_dataset="${cur%[#@]*}"
107+
if [ "$base_dataset" != "$cur" ]
107108
then
108109
if [[ $cur == *@* ]]
109110
then
110-
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 $base_dataset
111+
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 "$base_dataset"
111112
else
112-
$__ZFS_CMD list -H -o name -s name -t bookmark -d 1 $base_dataset
113+
$__ZFS_CMD list -H -o name -s name -t bookmark -d 1 "$base_dataset"
113114
fi
114115
else
115116
$__ZFS_CMD list -H -o name -s name -t filesystem,volume
116-
if [[ $cur != "" ]] && $__ZFS_CMD list -H -o name -s name -t filesystem,volume $cur &> /dev/null
117+
if [ -e "$cur" ] && $__ZFS_CMD list -H -o name -s name -t filesystem,volume "$cur" &> /dev/null
117118
then
118-
echo $cur@
119-
echo $cur#
119+
echo "$cur@"
120+
echo "$cur#"
120121
fi
121122
fi
122123
}
123124

124125
__zfs_match_multiple_snapshots()
125126
{
126-
local existing_opts=$(expr "$cur" : '\(.*\)[%,]')
127-
if [[ $existing_opts ]]
127+
local existing_opts
128+
existing_opts="$(expr "$cur" : '\(.*\)[%,]')"
129+
if [ -e "$existing_opts" ]
128130
then
129-
local base_dataset=${cur%@*}
130-
if [[ $base_dataset != $cur ]]
131+
local base_dataset="${cur%@*}"
132+
if [ "$base_dataset" != "$cur" ]
131133
then
132-
local cur=${cur##*,}
134+
local cur="${cur##*,}"
133135
if [[ $cur =~ ^%|%.*% ]]
134136
then
135137
# correct range syntax is start%end
136138
return 1
137139
fi
138-
local range_start=$(expr "$cur" : '\(.*%\)')
139-
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 $base_dataset | sed 's$.*@$'$range_start'$g'
140+
local range_start
141+
range_start="$(expr "$cur" : '\(.*%\)')"
142+
$__ZFS_CMD list -H -o name -s name -t snapshot -d 1 "$base_dataset" | sed 's$.*@$'"$range_start"'$g'
140143
fi
141144
else
142145
__zfs_match_snapshot_or_bookmark

0 commit comments

Comments
 (0)