* absolute, hence it is not necessary to prefix with the root. When "root" points to
* a non-root directory, the result path is always normalized and relative, hence
* we can simply call path_join() and not necessary to call path_simplify().
- * Note that the result of chaseat() may start with "." (more specifically, it may be
- * "." or "./"), and we need to drop "." in that case. */
+ * As a special case, chaseat() may return "." or "./", which are normalized too,
+ * but we need to drop "." before merging with root. */
if (empty_or_root(root))
assert(path_is_absolute(p));
assert(!path_is_absolute(p));
- q = path_join(root, p + (*p == '.'));
+ q = path_join(root, p + STR_IN_SET(p, ".", "./"));
if (!q)
return -ENOMEM;
ASSERT_STREQ(result, "/test-chase.fsldajfl");
result = mfree(result);
+ r = chase("/.path/with/dot", temp, CHASE_PREFIX_ROOT|CHASE_NONEXISTENT, &result, NULL);
+ ASSERT_OK(r);
+ q = strjoina(temp, "/.path/with/dot");
+ ASSERT_STREQ(result, q);
+ result = mfree(result);
+
r = chase("/etc/machine-id/foo", NULL, 0, &result, NULL);
assert_se(IN_SET(r, -ENOTDIR, -ENOENT));
result = mfree(result);