[PATCH blktests v1 2/5] nvme/rc: filter out errors from cat when reading files

Daniel Wagner dwagner at suse.de
Wed Feb 7 00:19:53 PST 2024


On Tue, Feb 06, 2024 at 11:07:06PM +0000, Chaitanya Kulkarni wrote:
> >   	for dev in /sys/class/nvme/nvme*; do
> >   		dev="$(basename "$dev")"
> > -		transport="$(cat "/sys/class/nvme/${dev}/transport")"
> > +		transport="$(cat "/sys/class/nvme/${dev}/transport" 2>/dev/null)"
> 
> do we have to do anything if there is in error ?

In this case transport will be '' and not match with '${nvme_trtype}'.
So we already handle this properly.

> >   		if [[ "$transport" == "${nvme_trtype}" ]]; then
> >   			echo "WARNING: Test did not clean up ${nvme_trtype} device: ${dev}"
> >   			_nvme_disconnect_ctrl "${dev}"
> > @@ -840,7 +840,7 @@ _find_nvme_dev() {
> >   	for dev in /sys/class/nvme/nvme*; do
> >   		[ -e "$dev" ] || continue
> >   		dev="$(basename "$dev")"
> > -		subsysnqn="$(cat "/sys/class/nvme/${dev}/subsysnqn")"
> > +		subsysnqn="$(cat "/sys/class/nvme/${dev}/subsysnqn" 2>/dev/null)"



More information about the Linux-nvme mailing list