Skip to content

Commit

Permalink
zfs-functions.in: is_mounted() always returns 1
Browse files Browse the repository at this point in the history
The 'while read line; ...; done' loop is run in a piped subshell 
therefore the 'return 0' would not cause a return from the 
is_mounted() function.  In all cases, this function will 
always return 1.

The fix is to 'return 1' from the subshell on a successful match 
(no match == return 0), and then negating the final return value.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: TerraTech <TerraTech@users.noreply.github.com>
Closes #8151
  • Loading branch information
TerraTech authored and behlendorf committed Dec 4, 2018
1 parent fedef6d commit a0cc372
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions etc/init.d/zfs-functions.in
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,14 @@ is_mounted()
mount | \
while read line; do
if echo "$line" | grep -q " on $mntpt "; then
return 0
# returns:
# 0 on unsuccessful match
# 1 on a successful match
return 1
fi
done

return 1
# The negation will flip the subshell return result where the default
# return value is 0 when a match is not found.
return $(( !$? ))
}

0 comments on commit a0cc372

Please sign in to comment.