From c8a1a12f6afa5b11dead9cf42394cef6d66326c6 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Wed, 20 Jun 2012 22:38:53 +0200 Subject: [PATCH] Some comments about hardlink and attributes. --- mingw.h | 17 +++++++++++++++++ scan.c | 1 + 2 files changed, 18 insertions(+) diff --git a/mingw.h b/mingw.h index 2d7b2420..6af01fbc 100644 --- a/mingw.h +++ b/mingw.h @@ -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); diff --git a/scan.c b/scan.c index d1cddb75..dbb6cf01 100644 --- a/scan.c +++ b/scan.c @@ -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);