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

Re: [Nbd] [w@...112...: Re: nbd-client started at boot (for root device) is not persistent]



Hi Victor,

On Fri, Nov 25, 2016 at 01:23:04PM +0200, Victor wrote:
> I have found an idea that seems to work fine - at least for me: if the process
> cannot find /dev and /sys anymore, it means it was started from initramfs. So i
> recreate /sys and /dev and mount sysfs and devtmpfs again. The VFS tree of
> nbd-client will get a duplicate mount of /dev and /sys but i don't think
> there's any harm in that.

I think there is; it can interfere with proper shutdown, depending on
the init system in use.

A better way is to:

- Check if /sys exists; if not, wait a second rather than checking for a
  pid file (perhaps best to ensure we don't fork() until the connection
  has been made then, though)
- Check if /dev exists; if not, run mknod(2) on a name in /tmp (or some
  such) with the correct attributes, open it, and unlink the file again

This doesn't leave any traces around anymore, and should allow
nbd-client to do what it needs to do.

I'll look into making the necessary changes when next I have time to
work on NBD.

-- 
< ron> I mean, the main *practical* problem with C++, is there's like a dozen
       people in the world who think they really understand all of its rules,
       and pretty much all of them are just lying to themselves too.
 -- #debian-devel, OFTC, 2016-02-12



Reply to: