[PATCH blktests] common/null_blk: check FULL file availability before write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit e2805c7911a4 ("common/null_blk: Log null_blk configuration
parameters") introduced the write to the $FULL file in
_configure_null_blk(). However, the $FULL file is not available when
_configure_null_blk() is called in the fallback_device() context. In
this case, the write fails with the error "No such file or directory".
To avoid the error, confirm that $FULL is available before write to it.

Fixes: e2805c7911a4 ("common/null_blk: Log null_blk configuration parameters")
Link: https://github.com/linux-blktests/blktests/issues/187
Reported-by: Yi Zhang <yi.zhang@xxxxxxxxxx>
Suggested-by: Bart Van Assche <bvanassche@xxxxxxx>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx>
---
 common/null_blk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/null_blk b/common/null_blk
index 83f508f..7395754 100644
--- a/common/null_blk
+++ b/common/null_blk
@@ -64,7 +64,7 @@ _configure_null_blk() {
 	fi
 	params+=("$@")
 
-	echo "$nullb_path ${params[*]}" >>"${FULL}"
+	[[ -n "${FULL}" ]] && echo "$nullb_path ${params[*]}" >>"${FULL}"
 
 	for param in "${params[@]}"; do
 		local key="${param%%=*}" val="${param#*=}"
-- 
2.50.0





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux