diff --git a/src/ioslaves/file/CMakeLists.txt b/src/ioslaves/file/CMakeLists.txt --- a/src/ioslaves/file/CMakeLists.txt +++ b/src/ioslaves/file/CMakeLists.txt @@ -33,3 +33,6 @@ set_target_properties(kio_file PROPERTIES OUTPUT_NAME "file") install(TARGETS kio_file DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kio) + +include(CheckSymbolExists) +check_symbol_exists(st_birthtime "sys/stat.h" HAVE_ST_BIRTHTIME) diff --git a/src/ioslaves/file/config-kioslave-file.h.cmake b/src/ioslaves/file/config-kioslave-file.h.cmake --- a/src/ioslaves/file/config-kioslave-file.h.cmake +++ b/src/ioslaves/file/config-kioslave-file.h.cmake @@ -10,3 +10,5 @@ /* Defined to if you have a d_type member in struct dirent */ #cmakedefine01 HAVE_DIRENT_D_TYPE +/* Defined if st_birthtime is defined */ +#cmakedefine01 HAVE_ST_BIRTHTIME diff --git a/src/ioslaves/file/file.cpp b/src/ioslaves/file/file.cpp --- a/src/ioslaves/file/file.cpp +++ b/src/ioslaves/file/file.cpp @@ -854,11 +854,22 @@ #pragma message("TODO: st_uid and st_gid are always zero, use GetSecurityInfo to find the owner") #endif entry.insert(KIO::UDSEntry::UDS_ACCESS_TIME, buff.st_atime); +#ifdef HAVE_ST_BIRTHTIME + /* For example FreeBSD's and NetBSD's stat contains a field for + * the inode birth time: st_birthtime + * This however only works on UFS and ZFS, and not, on say, NFS. + * Instead of setting a bogus fallback like st_mtime, only use + * it if it is greater than 0. */ + if (buff.st_birthtime > 0) { + entry.insert(KIO::UDSEntry::UDS_CREATION_TIME, buff.st_birthtime); + } +#endif } // Note: buff.st_ctime isn't the creation time ! // We made that mistake for KDE 2.0, but it's in fact the // "file status" change time, which we don't care about. + // For at least FreeBSD and NetBSD, use st_birthtime. return true; }