From: Eric Biggers Date: Sun, 16 Dec 2012 19:14:01 +0000 (-0600) Subject: build_dentry_tree(): Allow root to be symlink X-Git-Tag: v1.2.1~46 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=61975c56f685c4ed003f3b8fd6b88a8dbfb4b696;ds=sidebyside build_dentry_tree(): Allow root to be symlink --- diff --git a/src/add_image.c b/src/add_image.c index 085fd044..8f3724cd 100644 --- a/src/add_image.c +++ b/src/add_image.c @@ -193,9 +193,20 @@ static int build_dentry_tree(struct dentry **root_ret, } if ((add_image_flags & WIMLIB_ADD_IMAGE_FLAG_ROOT) && - !S_ISDIR(root_stbuf.st_mode)) { - ERROR("`%s' is not a directory", root_disk_path); - return WIMLIB_ERR_NOTDIR; + !S_ISDIR(root_stbuf.st_mode)) + { + /* Do a dereference-stat in case the root is a symbolic link. + * This case is allowed, provided that the symbolic link points + * to a directory. */ + ret = stat(root_disk_path, &root_stbuf); + if (ret != 0) { + ERROR_WITH_ERRNO("Failed to stat `%s'", root_disk_path); + return WIMLIB_ERR_STAT; + } + if (!S_ISDIR(root_stbuf.st_mode)) { + ERROR("`%s' is not a directory", root_disk_path); + return WIMLIB_ERR_NOTDIR; + } } if (!S_ISREG(root_stbuf.st_mode) && !S_ISDIR(root_stbuf.st_mode) && !S_ISLNK(root_stbuf.st_mode)) {