Some comments about hardlink and attributes.

This commit is contained in:
Andrea Mazzoleni 2012-06-20 22:38:53 +02:00
parent 3449f0afc1
commit c8a1a12f6a
2 changed files with 18 additions and 0 deletions

17
mingw.h
View file

@ -79,6 +79,23 @@ int windows_fstat(int fd, struct windows_stat* st);
/**
* Like the C lstat() but without the inode information.
* In Windows the inode information is not reported.
* In Windows and in case of hardlinks, the size and the attributes of the file can
* be completely bogus, because changes made by other hardlinks are reported in the
* directory entry only when the file is opened.
*
* MSDN CreateHardLinks
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa363860%28v=vs.85%29.aspx
* 'When you create a hard link on the NTFS file system, the file attribute information'
* 'in the directory entry is refreshed only when the file is opened, or when'
* 'GetFileInformationByHandle is called with the handle of a specific file.'
*
* MSDN HardLinks and Junctions
* http://msdn.microsoft.com/en-us/library/windows/desktop/aa365006%28v=vs.85%29.aspx
* 'However, the directory entry size and attribute information is updated only'
* 'for the link through which the change was made.'
*
* Use lstat_ex() to override these limitations.
*/
int windows_lstat(const char* file, struct windows_stat* st);

1
scan.c
View file

@ -482,6 +482,7 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, i
#if HAVE_LSTAT_EX
/* get inode info about the file, Windows needs an additional step */
/* also for hardlink, the real size of the file is read only with this function */
if (lstat_ex(path_next, &st) != 0) {
fprintf(stderr, "Error in stat_inode file '%s'. %s.\n", path_next, strerror(errno));
exit(EXIT_FAILURE);