[lxc-devel] call to setup_dev_symlinks with lxc.autodev
Michael H. Warfield
mhw at WittsEnd.com
Fri Apr 25 15:53:53 UTC 2014
On Fri, 2014-04-25 at 16:50 +0200, William Dauchy wrote:
> On Thu, Apr 17, 2014 at 9:04 PM, Michael H. Warfield <mhw at wittsend.com> wrote:
> > -- diff --git a/src/lxc/conf.c b/src/lxc/conf.c
> > index 06235fb..65f1f85 100644
> > --- a/src/lxc/conf.c
> > +++ b/src/lxc/conf.c
> > @@ -828,19 +828,38 @@ static int setup_dev_symlinks(const struct lxc_rootfs *rootfs)
> > {
> > char path[MAXPATHLEN];
> > int ret,i;
> > + struct stat s;
> >
> >
> > + INFO("Entering setup_dev_symlinks");
> > for (i = 0; i < sizeof(dev_symlinks) / sizeof(dev_symlinks[0]); i++) {
> > const struct dev_symlinks *d = &dev_symlinks[i];
> > ret = snprintf(path, sizeof(path), "%s/dev/%s", rootfs->mount, d->name);
> > if (ret < 0 || ret >= MAXPATHLEN)
> > return -1;
> > +
> > + /*
> > + * Stat the path first. If we don't get an error
> > + * accept it as is and don't try to create it
> > + */
> > + if (!stat(path, &s)) {
> > + INFO("Symlink to %s exists", path);
> > + continue;
> > + }
> > +
>
> When using stat, it obviously fixes the issue; my workaround was
> indeed to list the /dev directory before starting in order to make the
> `symlink` function return EEXIST.
>
> > + INFO("Creating symlink from %s to %s", d->oldpath, path);
> > ret = symlink(d->oldpath, path);
> > +
> > if (ret && errno != EEXIST) {
> > - SYSERROR("Error creating %s", path);
> > - return -1;
> > + if ( errno == EROFS ) {
> > + SYSERROR("Warning: Read Only file system while creating %s", path);
> > + } else {
> > + SYSERROR("Error creating %s", path);
> > + return -1;
> > + }
> If I remove the `stat`call, I'm getting EROFS. That explains the issue.
Bingo! I guess my conjecture about it being a quirk in the kernel VFS
must be pretty close.
Ok... I'll submit a formal patch shortly.
Thanks!
> Best regards,
> --
> William
Regards,
Mike
--
Michael H. Warfield (AI4NB) | (770) 978-7061 | mhw at WittsEnd.com
/\/\|=mhw=|\/\/ | (678) 463-0932 | http://www.wittsend.com/mhw/
NIC whois: MHW9 | An optimist believes we live in the best of all
PGP Key: 0x674627FF | possible worlds. A pessimist is sure of it!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140425/672e122f/attachment.sig>
More information about the lxc-devel
mailing list