[lxc-devel] call to setup_dev_symlinks with lxc.autodev
William Dauchy
wdauchy at gmail.com
Fri Apr 25 14:50:34 UTC 2014
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.
Best regards,
--
William
More information about the lxc-devel
mailing list