- if (one_file_system && st.st_dev != filesystem_dev
- && S_ISDIR(st.st_mode)) {
- if (one_file_system > 1)
- return NULL;
- flags |= FLAG_MOUNT_POINT;
+ if (one_file_system && S_ISDIR(st.st_mode) && !(flags & FLAG_TOP_DIR)) {
+ STRUCT_STAT st2;
+ unsigned int len = strlcat(thisname, "/..", sizeof thisname);
+ /* If the directory's .. dir is on a different filesystem,
+ * either mark this dir as a mount-point or skip it. */
+ if (len < sizeof thisname && do_stat(thisname, &st2) == 0
+ && (st.st_dev != st2.st_dev || st.st_ino != st2.st_ino)) {
+ if (one_file_system > 1) {
+ if (verbose > 2) {
+ rprintf(FINFO,
+ "skipping mount-point dir %s\n",
+ thisname);
+ }
+ return NULL;
+ }
+ flags |= FLAG_MOUNT_POINT;
+ }
+ thisname[len-3] = '\0';