Changes v4: (1) When searching for substrings with strstr() also check for q >= lend to ensure that we limit our search to the current line.
+ if ((!(q = strstr(p, " overlay")) || q >= lend) && (!(q = strstr(p, " aufs")) || q >= lend)) + goto next; + if (!(q = strstr(p, olddir)) || (q >= lend)) + goto next; (2) Simplify clone_update_unexp_ovl_paths() by using gotos. (3) Fix indentation in update_ovl_paths(). (4) Replace old_work also when old_upper is not present: if (tmp_mnt_entry) new_mnt_entry = lxc_string_replace(old_work, new_work, tmp_mnt_entry); + else + new_mnt_entry = lxc_string_replace(old_work, new_work, mnt_entry); Changes v3: (1) Better names for functions: update_union_mount_entry_paths() becomes update_ovl_paths() and clone_update_unexp_ovl_dir() becomes clone_update_unexp_ovl_paths(). (2) Use the stricter check if (p >= lend) continue; in clone_update_unexp_ovl_paths(). (3) Insert comment into update_ovl_paths() that lxc_conf->unexpanded_config needs to be updated separately from lxc_conf->mount_list. Changes v2: (1) Fix calculations in update_unexp_ovl_dir(). (The function was modelled after update_unexp_hooks() and I'm pretty sure that things are wrong there too and need a thorough check but I'm in the Alps for the weekend so this will have to wait...) Most noticeably the calculation when olddirlen >= newdirlen becomes: memmove(q + newdirlen, q + newdirlen + diff, strlen(q) - newdirlen - diff + 1); and int the else-branch it becomes: memmove(new + poffset + newdirlen, new + poffset + olddirlen, oldlen - poffset - olddirlen + 1); The call to realloc() becomes: new = realloc(conf->unexpanded_config, newlen + 1); and we *need* to set: conf->unexpanded_alloced = newlen + 1; Changes: (1) Make updating lxc_conf->mnt_list and lxc_conf->unexpanded_config independent of each other so that users can include overlay mounts from other files. (2) Update lxc_conf->unexpanded_config by using a separate function clone_update_unexp_ovl_dir() in confile.c. (3) Move various temporary variables inside the lxc_list_for_each(iterator, &lxc_conf->mount_list) {*/ do stuff */} per Serge's request. (4) Use uniform exit strategy when the function fails or succeeds. Christian Brauner (3): Add clone_update_unexp_ovl_paths() function Update absolute paths for overlay and aufs mounts Fix wrong calculations in clone_update_unexp_hooks() src/lxc/confile.c | 126 ++++++++++++++++++++++++++++++++++++++++++++----- src/lxc/confile.h | 3 ++ src/lxc/lxccontainer.c | 100 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 216 insertions(+), 13 deletions(-) -- 2.6.2 _______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel