Jonathan Thornburg <[email protected]> writes:

> Suppose I have a shell or perl script which is running /bioctl/ to
> create a new softraid device, e.g., which is executing something like
>
>   bioctl -c C -r 123456 -l /dev/sd0a softraid0
>
> If everything works correctly, this will create a new softraid crypto
> disk /sdN/.  My question is, what's the best way for my script to find
> out the newly-created /sdN/ device (so that it can do error-checking,
> and if all is well, do an appropriate /mount/ command on that device)?
>
> The /sdN/ information is printed by the kernel, but that's not readily
> accessible to my script.
>
> I can see two options:
> * execute /sysctl hw.disknames/ before and after the /bioctl/, parse each
>   of these for the set of disks in use, and see what changed.
> * execute /dmesg | tail -2/ after the /bioctl/, parse this to check that
>   it shows a new /sdN/ of the appropriate type/, and use that /sdN/
>
> (Either option has a race condition with other system activity, but for
> my use cases I think I can probably ignore this.)
>
> Is there an easier/cleaner way?

Hi,

I would use bioctl(8) itself for query information about softraid0.

# bioctl -cC -l /dev/sd1a softraid0
# bioctl -i softraid0
Volume      Status               Size Device
softraid0 0 Online       249786400256 sd2     CRYPTO
          0 Online       249786400256 0:0.0   noencl <sd1a>

with some awk, you should be able to extract the /sdN/

# bioctl -i softraid0 | awk '/CRYPTO$/ { print $5 }'
sd2

Regards.
-- 
Sebastien Marie

Reply via email to