- if (LSTAT(*path, &st) < 0) {
- fprintf(stderr, "%s: lstat: %s\n", *path, strerror(errno));
+ /*
+ * Special case: at the very top of the scan, we follow a
+ * symlink.
+ */
+ if (toplevel)
+ statret = STAT(*path, &st);
+ else
+ statret = LSTAT(*path, &st);
+ if (statret < 0) {
+ err(gotdata_ctx, "%s: lstat: %s\n", *path, strerror(errno));