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?

Thanks,
-- 
-- "Jonathan Thornburg [remove -color to reply]" <[email protected]>
   (he/him; currently on the west coast of Canada)
    "Totalitarianism in power invariably replaces all first-rate talents,
     regardless of their sympathies, with those crackpots and fools whose
     lack of intelligence and creativity is still the best guarantee of
     their loyalty."     -- Hannah Arendt, "The Origins of Totalitarianism"

Reply via email to