Apply new hardlink behaviour also to NTFS in nix platforms

This is a specific NTFS behaviour, not limited to Windows.
This commit is contained in:
Andrea Mazzoleni 2017-10-29 18:07:01 +01:00
parent 58a7375661
commit f778fb691f
9 changed files with 88 additions and 33 deletions

View file

@ -644,7 +644,7 @@ int filephy(const char* path, uint64_t size, uint64_t* physical)
return 0;
}
int fsinfo(const char* path, int* has_persistent_inode, uint64_t* total_space, uint64_t* free_space)
int fsinfo(const char* path, int* has_persistent_inode, int* has_syncronized_hardlinks, uint64_t* total_space, uint64_t* free_space)
{
char type[64];
const char* ptype;
@ -693,11 +693,29 @@ int fsinfo(const char* path, int* has_persistent_inode, uint64_t* total_space, u
break;
}
#else
/* by default assume yes */
/* in Unix inodes are persistent by default */
*has_persistent_inode = 1;
#endif
}
if (has_syncronized_hardlinks) {
#if HAVE_STATFS && HAVE_STRUCT_STATFS_F_TYPE
switch (st.f_type) {
case 0x5346544E : /* NTFS */
case 0x4d44 : /* VFAT, "msdos" in the stat command */
*has_syncronized_hardlinks = 0;
break;
default :
/* by default assume yes */
*has_syncronized_hardlinks = 1;
break;
}
#else
/* in Unix hardlinks share the same metadata by default */
*has_syncronized_hardlinks = 1;
#endif
}
if (total_space) {
#if HAVE_STATFS
*total_space = st.f_bsize * (uint64_t)st.f_blocks;