+ DEBUG("%s", root_disk_path);
+ struct stat root_stbuf;
+ int ret;
+ int (*stat_fn)(const char *restrict, struct stat *restrict);
+
+ if (add_flags & WIMLIB_ADD_IMAGE_FLAG_DEREFERENCE)
+ stat_fn = stat;
+ else
+ stat_fn = lstat;
+
+
+ ret = (*stat_fn)(root_disk_path, &root_stbuf);
+ if (ret != 0) {
+ ERROR_WITH_ERRNO("Failed to stat `%s'", root_disk_path);
+ return WIMLIB_ERR_STAT;
+ }
+
+ if ((add_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;
+ }
+ stbuf_to_dentry(&root_stbuf, root);
+ add_flags &= ~WIMLIB_ADD_IMAGE_FLAG_ROOT;