summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qfilesystemengine_unix.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Don't wrap feature detection macros with QT_HAS_FOO() variantsTor Arne Vestbø2019-12-101-1/+1
| | | | | | | | | | | | | | | | | Using wrappers for these macros is problematic when for example passing the -frewrite-includes flag to preprocess sources before shipping off to distcc or Icecream. It will also start producing warnings when compilers implement http://eel.is/c++draft/cpp.cond#7.sentence-2. See for example https://reviews.llvm.org/D49091 Both https://clang.llvm.org/docs/LanguageExtensions.html and the SD-6 document at https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations recommend defining '__has_foo(x) 0' as a fallback for compilers without the macros, so that's what we go for. Change-Id: I0298cd3b4a6ff6618821e34642a5ddd6728be767 Reviewed-by: Alex Richardson <arichardson.kde@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFileSystemEngine: Consistently check for invalid file namesUlf Hermann2019-10-241-33/+19
| | | | | | | | | | | | | | stat() and friends expect a null-terminated C string. There is no way to generate anything useful from a string that has null bytes in the middle. It's important to catch this early, as otherwise, for example, a QDir::exists() on such a path can return true, as the path is silently truncated. Extend the checks for empty file names to windows and add checks for null bytes. Change-Id: Ie9794c3a7c4fd57f9a66bdbbab8b45a08b6f9170 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFilesystemEngine: fix unused variable warning-turned-error on WASMMarc Mutz2019-07-131-0/+4
| | | | | | | ... and, presumably, Integrity. Change-Id: I54d35fd11b7df139022e2575c29b2d832f80f761 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Move away from using 0 as a pointer constantAllan Sandfeld Jensen2019-06-071-2/+2
| | | | | | | | | Cleans up most of corelib to use nullptr or default enums where appropriate. Change-Id: Ifcaac14ecdaaee730f87f10941db3ce407d71ef9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix canonicalFilePath() for files with trailing slashesVolker Hilsheimer2019-05-211-33/+17
| | | | | | | | | | | | | | | Such files do not exist (as per QFileInfo::exists), but on some platforms that rely on realpath(), QFileInfo::canonicalFilePath did not return the empty string. Use the same logic on macOS as we already did on Android, and include a test case. Remove the unnecessary dynamic memory allocation and use a stack-allocated array instead, unless we use modern POSIX in which case realpath() will alloc the memory for the result for us. Change-Id: Ide987c68ebf00cbb7b1a66c2e9245a12c7807128 Fixes: QTBUG-44242 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QFileSystemEngine: Fix typoOrgad Shaneh2019-04-051-3/+3
| | | | | Change-Id: I538ef771dcf6b757025c8d31f13a91222c2ebd3e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix ambiguous definition of atime/mtime/ctime on alphaDmitry Shachnev2018-11-121-1/+1
| | | | | | | | | | | | | | | | | One of the implementations is enabled when the stat struct has ::st_atim member, another — when it has ::st_atimensec member. On alpha, the stat struct has both members, defined as union here: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/alpha/bits/stat.h#l48 and then used here: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/alpha/bits/stat.h#l92 This commit forcefully disables the second implementation on alpha. Change-Id: Ifc284d72b68b9bac590b518f31960288df3a087d Done-with: Michael Cree <mcree@orcon.net.nz> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.11' into 5.12Qt Forward Merge Bot2018-10-211-39/+7
|\ | | | | | | Change-Id: Iaf28977e7ecf566b28b9406dcb005d48621169c2
| * Re-disable statx() on AndroidThiago Macieira2018-10-181-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit b7887f9b4faad2227691a2af589e9d7680d6ae08 removed this explicit disabling because it shouldn't be needed anymore. Turns out it was, as new Android SDK do include modern Linux headers and those define the structs and constants needed for statx(). Repeat of 8eb3944dac81b8c51d7bac7784204d457551b50c. Task-number: QTBUG-64490 Fixes: QTBUG-71200 Change-Id: If7e743cf8476463880ccfffd155e6d5c2b5a3da9 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
| * Linux: Remove our use of syscall() for statx(2) and renameat2(2)Thiago Macieira2018-10-121-42/+3
| | | | | | | | | | | | | | | | | | | | | | | | Those system calls are present in glibc 2.28. Instead of using syscall(3) to place the system calls directly, let's use only the glibc functions. That also means we no longer accept ENOSYS from either function, if they were detected in glibc. Change-Id: I44e7d800c68141bdaae0fffd1555b4b8fe63786b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
* | Remove codepaths and checks for unsupported Apple platformsTor Arne Vestbø2018-08-311-19/+13
| | | | | | | | | | | | | | We no longer support macOS 10.11, iOS/tvOS 10, or watchOS 3. Change-Id: Ide03d8fac06185ef4162ba75ee54a0adf6916905 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | WebAssembly for QtBaseMorten Johan Sørvig2018-08-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | This is the squashed diff from wip/webassembly to dev. Done-with: Peng Wu <peng.wu@intopalo.com> Done-with: Sami Enne <sami.enne@intopalo.com> Done-with: Morten Johan Sørvig <morten.sorvig@qt.io> Started-by: Andrew Knight <andrew.knight@intopalo.com> Change-Id: I6562433c0a38d6ec49ab675e0f104f2665f3392d Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* | Modernize the "thread" featureUlf Hermann2018-08-171-4/+4
| | | | | | | | | | | | | | | | | | | | Add it to configure.json and replace all occurrences of QT_NO_THREAD with QT_CONFIG(thread). Add conditions for other features that depend on thread support. Remove conditions where we can use the QMutex and QThreadStorage stubs. Change-Id: I284e5d794fda9a4c6f4a1ab29e55aa686272a0eb Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-08-161-1/+1
|\| | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qconfig-bootstrapped.h src/plugins/platforms/xcb/qxcbbackingstore.cpp Done-with: Gatis Paeglis <gatis.paeglis@qt.io> Change-Id: I4af138ffb2f5306373244523768209e8873b2798
| * Fix qmake build with glibc 2.28Thiago Macieira2018-08-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We haven't yet run the configure checks to see if statx and renameat2 are present in glibc, so this fails when we redefine the structures and functions. linux/stat.h:56:8: error: redefinition of 'struct statx_timestamp' bits/statx.h:25:8: note: previous definition of 'struct statx_timestamp' qfilesystemengine_unix.cpp:110:12: error: 'int renameat2(int, const char*, int, const char*, unsigned int)' was declared 'extern' and later 'static' [-fpermissive] Change-Id: Ia741b559c24d46c78fb2fffd1548a792d22e3368 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
* | canonicalFilePath: treat ENOTDIR as a case of file not existingEdward Welbourne2018-07-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | There is no such file, if one of the "directory" components of its path is not, in fact, a directory. Added a test for non-existent file (specified to give empty canonical file path) as well as a test for a file in a sub-directory of a known file. The former incidentally tests for QTBUG-29402, fixed long ago. Change-Id: I60b80acc0f99f0a88cdb1c4d191af7384f3a31c5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-07-171-15/+5
|\| | | | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/xcb/qxcbintegration.cpp Conflicts git missed: src/plugins/platforms/qnx/qqnxglcontext.cpp Change-Id: I0582cdc9e66e43efe79038b9c43d4f9572ac88fc
| * QFile::copy(): don't trust the old file metadata cacheThiago Macieira2018-07-121-15/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead, let's just use sendfile(2) in a loop until it returns 0, which indicates EOF. [ChangeLog][QtCore][QFile] Fixed a regression in QFile::copy() that caused the original file not to be copied entirely if it was modified outside of this QFile object between the last time we checked its size and the copy() call. Note this is not a prevention against race conditions. Task-number: QTBUG-69417 Change-Id: Id59bdd8f1a804b809e22fffd15406c8aa31f4a1e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devLiang Qi2018-05-241-0/+2
|\| | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/features/qt_common.prf src/corelib/tools/qstring.cpp src/plugins/platforms/windows/qwindowsmousehandler.cpp src/widgets/widgets/qmainwindowlayout_p.h Change-Id: I5df613008f6336f69b257d08e49a133d033a9d65
| * QFileSystemEngine: don't try to use statx(2) if SYS_statx isn't definedv5.11.0-rc2v5.11.0Thiago Macieira2018-05-141-0/+2
| | | | | | | | | | | | | | | | | | If glibc's <unistd.h> does not define SYS_statx but <linux/stat.h> did define struct statx and related constants, we failed to compile. Task-number: QTBUG-68205 Change-Id: I04a43ee94975482f9e32fffd151e66bbe6988554 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into devQt Forward Merge Bot2018-03-151-7/+16
|\| | | | | | | Change-Id: I8b5a10d897a926078895ae41f48cdbd2474902b8
| * Disable statx(2) and renameat2(2) system calls on AndroidThiago Macieira2018-03-141-7/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many Android systems come with a locked down system call list, causing the statx(2) system call to fail with an unexpected error code or by delivering a signal to the application. Because of the signal, we can't do runtime detection... This is not our bug: it's obviously a mistake in the SECCOMP rules in Android. But we work around the issue. Unfortunately, because of a few manufacturers who can't configure their rules properly, everyone will suffer. Task-number: QTBUG-64490 Change-Id: I39332e0a867442d58082fffd1507a49415917384 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* | Make QDir::tempPath() canonicalTor Arne Vestbø2018-03-071-1/+1
|/ | | | | | | | | | | | | | | | | | | To have a stable base for creating temporary files it's useful to have the temporary path be not just cleaned, but also the canonical path, so that any symlinks are resolved. This is e.g. the case on macOS, where /tmp is symlinked to /private/tmp. Fixes tests that compare paths, e.g: FAIL! : tst_QDir::current(startup) Compared values are not the same Actual (newCurrent.absolutePath()): "/private/var/folders/51/hhvngbjd36vbn1ncklb73g2h0000gn/T/tst_qdir-FACBOE" Expected (currentDir) : "/var/folders/51/hhvngbjd36vbn1ncklb73g2h0000gn/T/tst_qdir-FACBOE" [ChangeLog][QtCore] QDir::tempPath() now reports the canonical path of the temporary directory, with any symlinks removed. Change-Id: I20df9076c9869227f32740b196fd7ffb8b1b9ced Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace a few hardcoded paths with defaults from paths.hThiago Macieira2017-12-241-5/+11
| | | | | | | | This removes at least one special-case we had to have, in Android's lack of /etc/mnttab. Bionic's _PATH_MOUNTED is already /proc/mounts. Change-Id: I9407dcf22de6407c83b5fffd14fedc638586d0f9 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Merge remote-tracking branch 'origin/5.10.0' into 5.10Liang Qi2017-12-081-18/+27
|\ | | | | | | Change-Id: I6dcf85067ec226136c207ea69ca9d66736c84db5
| * Fix namespaced linux buildsAllan Sandfeld Jensen2017-11-281-1/+4
| | | | | | | | | | | | | | | | | | Using "struct statx" as argument type is forward declaration which then will expect the namespace where it was first encountered. Change-Id: I2d4ba930bd5b4e264228f2549bd6ef75e5cf3a67 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Fix the build if st_atimensec is definedThiago Macieira2017-11-231-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | It's a trick used by some C libraries to keep compatibility with BSD extensions while supporting POSIX.1-2008 API. st_atimensec is defined as st_atim.tv_nsec, so the code would expand to invalid C++ In substitution of 'template<class T> typename std::enable_if<((&T::st_atim.tv_nsec), true), long long int>::type{anonymous}::GetFileTimes::atime(const T&, int) [with T = stat]': error: invalid use of non-static data member 'stat::st_atim' Change-Id: I38341f8155354cc4a776fffd14e20f4fc0f6d5bb Reviewed-by: BogDan Vatra <bogdan@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
| * QFileSystemEngine/Linux: fix when qt_lstatx() succeedsThiago Macieira2017-11-201-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When qt_lstatx() succeeds and the target is not a link, we'd erroneously mark the file as non-existent during the pass to check qt_statx(). All flags besides the file's modes were cleared. This is unit-tested, but only happens on Linux kernels 4.12 or later. It didn't happen to me because I already had this fix applied as part of a later change relating to QSystemResult. Task-number: QTBUG-64514 Change-Id: I938b024e38bf4aac9154fffd14f893506a1ef55b Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QFileSystemEngine: Work around Android bug in rejecting hardlinksThiago Macieira2017-12-051-1/+16
|/ | | | | | | | | | | | | | | | Android Marshmellow intentionally forbids use of hard links. See https://code.google.com/archive/p/android-developer-preview/issues/3150 However, instead of using EPERM or another error code that indicates the hard linking operation itself has a problem but there are no other problems, Android developers stupidly chose to use EACCES, an errno code that only indicates permission problems. In any case, since the call will never succeed, we shouldn't even try. Task-number: QTBUG-64103 Change-Id: I9e2892cb6c374e93bcb7fffd14fc5d1082bd60a3 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* QFileSystemEngine: Fix renameat2() failures on non-local filesystemsThiago Macieira2017-10-291-1/+2
| | | | | | | | | | | | | | | | | | | The RENAME_NOREPLACE flag is supported for all Linux local filesystems, since that can be easily checked by the VFS layer (it knows which files exist and which ones don't). For non-local filesystems, the backend needs support and that might need server-side support too. So we may get EINVAL errors for those, in which case we fall back to link/unlink, which in turn can fall back to rename(). EINVAL can also happen if we attempt to make a directory a subdirectory of itself. In that case, we will attempt to link() it, which will result in EPERM as we can't hardlink directories. Then we try rename() again, which should result in the expected EINVAL. Task-number: QTBUG-64008 Change-Id: Icaa86fc7b54d4b368c0efffd14f09ca23602dd2e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Clean up OS version checks for Apple platformsJake Petroules2017-09-291-10/+2
| | | | | | | | | | Convert QSysInfo/QOperatingSystemVersion to __builtin_available where required or possible, or to QOperatingSystemVersion where __builtin_available cannot be used and is not needed (such as negated conditions, which are not supported by that construct). Change-Id: I83c0e7e777605b99ff4d24598bfcccf22126fdda Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QFileSystemEngine: Minor cleanup in unixOrgad Shaneh2017-09-281-7/+2
| | | | | Change-Id: I4a123484ea1f5e53af85a52e86d4a80cef1cd7bc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Don't read the statx struct in case of failureSérgio Martins2017-09-271-2/+5
| | | | | Change-Id: I62d98e4463003a1da8f28318d82635f6e0b2cc8c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-09-201-0/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/plugins/styles/mac/qmacstyle_mac.mm src/widgets/util/qcompleter.cpp src/widgets/widgets/qmainwindowlayout.cpp src/widgets/widgets/qmdisubwindow.cpp Change-Id: If0e96981af07ce36ac68f2e69211bc2120f93973
| * Add missing pwd.h includeJake Petroules2017-09-181-0/+1
| | | | | | | | | | | | | | | | | | This file uses functions declared in this header, and it is not pulled in transitively on all platforms. Change-Id: I6654118883a8dc22dacf1beb7b9b1c662719d25c Reviewed-by: Tuomas Heimonen <tuomas.heimonen@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-08-311-8/+6
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/examples.pro qmake/library/qmakebuiltins.cpp src/corelib/global/qglobal.cpp Re-apply b525ec2 to qrandom.cpp(code movement in 030782e) src/corelib/global/qnamespace.qdoc src/corelib/global/qrandom.cpp src/gui/kernel/qwindow.cpp Re-apply a3d59c7 to QWindowPrivate::setVisible() (code movement in d7a9e08) src/network/ssl/qsslkey_openssl.cpp src/plugins/platforms/android/androidjniinput.cpp src/plugins/platforms/xcb/qxcbconnection.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/widgets/widgets/qmenu.cpp tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp Change-Id: If7ab427804408877a93cbe02079fca58e568bfd3
| * Fix resolution of relative symlinks from relative path on unixOrgad Shaneh2017-08-271-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider the following: /root/target - a file /root/path/link -> ../target /root/path/other/exe - executable Running from /root/path/other. exe is: #include <QDebug> #include <QFileInfo> int main() { qDebug() << QFileInfo("../link").symLinkTarget() return 0; } The link references /root/target, but the current output is /root/path/target. The link doesn't depend on the PWD. It depends on its own directory. Change-Id: I61e95018154a75e0e0d795ee801068e18870a5df Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Android: Fix compile with unified headersBogDan Vatra2017-08-171-1/+1
| | | | | | | | | | | | | | | | Unified headers now defines _POSIX_THREAD_SAFE_FUNCTIONS but not all libc functions are available in all Android API versions. Change-Id: I01c94f0b89e7f8aa8575e7bbda28d9fe41a68ff1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QFileSystemEngine::cloneFile: expand the Linux cloning processThiago Macieira2017-08-221-3/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FICLONE only works on (currently) btrfs and xfs, and then only if it's the same mount, so it's of very limited use. There are a couple other techniques we may try that do not involve I/O through user-space, though not immediate: - sendfile(2) can be used on regular files, even across mountpoints - sendfile(2) can be used on block devices too, but we need to get the device's size first - splice(2) can be used on pipes (FIFOs) We only implement the first technique (earlier iterations of this patch implemented all). Change-Id: I81480fdb578d4d43b3fcfffd14d4b47cd70495a3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QFileSystemEngine::cloneFile: add support for fcopyfile(3) on macOSThiago Macieira2017-08-221-1/+16
| | | | | | | | | | | | | | | | For some reason, fcopyfile(3) works on directories, so we need to make we aren't operating in one. Change-Id: I81480fdb578d4d43b3fcfffd14d4f2f485348515 Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | Move the file-cloning code from QFSFileEngine to QFileSystemEngineThiago Macieira2017-08-221-0/+20
| | | | | | | | | | Change-Id: I02d22222fff64d4dbda4fffd14d1c1bbf48385ff Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QFileSystemEngine: verify that the file name isn't emptyThiago Macieira2017-08-171-2/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Making system calls with empty file names is not a good idea. When you run qmake $srcdir, you see this in strace: stat("", 0x7ffed229e250) = -1 ENOENT (No such file or directory) (twice) I've also inlined the isEmpty() function for better code generation. Some functions take QSystemError and some don't. That needs to be corrected at some point, possibly with something like std::expected. Change-Id: I1eba2b016de74620bfc8fffd14ccbfa162f93631 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QFileSystemEngine/Unix: support UF_HIDDEN on the other BSDsThiago Macieira2017-08-081-1/+3
| | | | | | | | | | | | | | | | | | | | The stat::st_flags and fchflags(2) syscall are marked: HISTORY The chflags() and fchflags functions first appeared in 4.4BSD. Change-Id: I81480fdb578d4d43b3fcfffd14d4fd23bd27e37e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Tobias C. Berner <tcberner@FreeBSD.org>
* | Add support for statx(2) on LinuxThiago Macieira2017-08-081-17/+165
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This system call, new in Linux 4.11, gives us the file birth time. It's also extensible, representing the fourth generation of stat(2) on Linux (the original sys_stat(), sys_newstat(), sys_stat64() and now sys_statx()), not to be confused with glibc's __xstat function, which wraps a call to stat64. Anyway, the new one is designed to be extensible. Now we get birth times on ext[34] on Linux too: Name: . Path: . (/home/tjmaciei/src/qt) Size: 4096 Type: Directory Attrs: readable writable executable hidden nativepath Mode: drwxr-xr-x Owner: tjmaciei (1000) Group: users (100) Access: 2017-07-02T14:47:49.608 Birth: 2016-05-02T13:20:33.097 Change: 2017-07-01T13:37:08.737 Modified: 2017-07-01T13:37:08.737 It's not supported in any other filesystems I have (Linux sources show xfs has the feature too). Even on ext4, it depends on whether the filesystem was created with 256-byte inodes, which my /boot fs wasn't. Change-Id: I8d96dea9955d4c749b99fffd14cda23ed60d5e72 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | QFileSystemEngine/Unix: rework the getting of nsec-precision file timesThiago Macieira2017-08-061-20/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was working on Linux because _GNU_SOURCE gets us POSIX.1-2008 compatibility, but not on macOS or the BSDs. There, we were still stuck to full second precision. This commit uses the template trick introduced by the futimes code (which itself was inspired by commit 2fb42eb4af3444b11e7b1210323637937ef in QtNetwork). Also note how it adds support for birth time, if the system's stat struct has that information. Tested to work on MacOS and FreeBSD. The manual filetest produces: Name: . Path: . (/usr/home/tjmaciei/src/qt/qt5) Size: 1536 Type: Directory Attrs: readable writable executable hidden nativepath Mode: drwxr-xr-x Owner: tjmaciei (1001) Group: tjmaciei (1001) Access: 2017-07-13T20:03:47.916 Birth: 2017-07-13T20:03:47.916 Change: 2017-07-13T20:04:41.648 Modified: 2017-07-13T20:04:41.648 Linux will require support for statx(2). Change-Id: I8d96dea9955d4c749b99fffd14cd97d7a8c6d45d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QFileSystemEngine::fillMetaData: simplify and comment the codeThiago Macieira2017-08-061-38/+65
| | | | | | | | | | | | | | | | | | | | | | Took me a long while to understand what it did. Now that I do, I can also answer the question left behind during the original implementation in Qt 4.8 (commit 4fd2aced96d9095254d89f9da9c911bd88f15245 in the old history): how to know if a file exists? Change-Id: I8d96dea9955d4c749b99fffd14cdae135499a0d3 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Move Unix code from qfilesystemengine.cpp to qfilesystemengine_unix.cppThiago Macieira2017-08-061-0/+218
| | | | | | | | | | | | | | The comment about Symbian no longer applies. Change-Id: I8d96dea9955d4c749b99fffd14cd966f07d95948 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | QFileSystemEngine::setFileTime/Unix: remove the fallback to futimesatThiago Macieira2017-08-051-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The use as in the code: futimesat(fd, NULL, &tv) is not documented to work. The file descriptor should be a directory's one, not an open file (though the Linux source code seems to handle that case). This call was done as a fallback to futimes, so it's very unlikely a system would have futimesat and not futimes. Both the Linux and the FreeBSD man pages say it's deprecated anyway. Change-Id: I8d96dea9955d4c749b99fffd14cd94068dc7668a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | Filesystem: Use "birth time" to avoid confusion with Unix ctimeThiago Macieira2017-08-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | The Unix stat fields "st_ctime" and "st_ctim" mean "change time", the last time that the file/inode status fields were changed. It does not mean "creation time". So this commit splits all of the internal API to "birth" and "metadata change" instead of "creation" to avoid the conflict. Change-Id: I149e0540c00745fe8119fffd1463fe78b619649e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Move platform-specific code from QFSFileEngine to QFileSystemEngineThiago Macieira2017-08-051-0/+106
| | | | | | | | | | Change-Id: I8d96dea9955d4c749b99fffd14cd9395174ba005 Reviewed-by: Lars Knoll <lars.knoll@qt.io>