- if ((int) NAMLEN (entry) + name_length >= name_buffer_size)
- {
- while ((int) NAMLEN (entry) + name_length >= name_buffer_size)
- name_buffer_size += NAME_FIELD_SIZE;
- name_buffer = (char *)
- xrealloc (name_buffer, (size_t) (name_buffer_size + 2));
- }
- strcpy (name_buffer + name_length, entry->d_name);
-
- if (dereference_option
-#ifdef AIX
- ? statx (name_buffer, &stat_data, STATSIZE, STX_HIDDEN)
- : statx (name_buffer, &stat_data, STATSIZE, STX_HIDDEN | STX_LINK)
-#else
- ? stat (name_buffer, &stat_data)
- : lstat (name_buffer, &stat_data)
-#endif
- )
- {
- ERROR ((0, errno, _("Cannot stat %s"), name_buffer));
- continue;
- }
-
- if ((one_file_system_option && device != stat_data.st_dev)
- || (exclude_option && check_exclude (name_buffer)))
- add_to_accumulator (accumulator, "N", 1);
-
-#ifdef AIX
- else if (S_ISHIDDEN (stat_data.st_mode))
- {
- add_to_accumulator (accumulator, "D", 1);
- strcat (entry->d_name, "A");
- entry->d_namlen++;
- }
+ if (S_ISDIR (stat_data.st_mode))
+ {
+ bool nfs = NFS_FILE_STAT (stat_data);
+
+ if (directory = find_directory (name_buffer), directory)
+ {
+ /* With NFS, the same file can have two different devices
+ if an NFS directory is mounted in multiple locations,
+ which is relatively common when automounting.
+ To avoid spurious incremental redumping of
+ directories, consider all NFS devices as equal,
+ relying on the i-node to establish differences. */
+
+ if (! (((directory->nfs & nfs)
+ || directory->device_number == stat_data.st_dev)
+ && directory->inode_number == stat_data.st_ino))
+ {
+ if (verbose_option)
+ WARN ((0, 0, _("%s: Directory has been renamed"),
+ quotearg_colon (name_buffer)));
+ directory->children = ALL_CHILDREN;
+ directory->nfs = nfs;
+ directory->device_number = stat_data.st_dev;
+ directory->inode_number = stat_data.st_ino;
+ }
+ directory->found = 1;
+ }
+ else
+ {
+ if (verbose_option)
+ WARN ((0, 0, _("%s: Directory is new"),
+ quotearg_colon (name_buffer)));
+ directory = note_directory (name_buffer,
+ stat_data.st_dev,
+ stat_data.st_ino, nfs, 1);
+ directory->children =
+ ((listed_incremental_option
+ || newer_mtime_option <= stat_data.st_mtime
+ || (after_date_option &&
+ newer_ctime_option <= stat_data.st_ctime))
+ ? ALL_CHILDREN
+ : CHANGED_CHILDREN);
+ }
+
+ if (one_file_system_option && device != stat_data.st_dev)
+ directory->children = NO_CHILDREN;
+ else if (children == ALL_CHILDREN)
+ directory->children = ALL_CHILDREN;
+
+ add_to_accumulator (accumulator, "D", 1);
+ }
+
+ else if (one_file_system_option && device != stat_data.st_dev)
+ add_to_accumulator (accumulator, "N", 1);
+
+#ifdef S_ISHIDDEN
+ else if (S_ISHIDDEN (stat_data.st_mode))
+ {
+ add_to_accumulator (accumulator, "D", 1);
+ add_to_accumulator (accumulator, entry, entrylen);
+ add_to_accumulator (accumulator, "A", 2);
+ continue;
+ }