summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qstorageinfo_unix.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QStorageInfo: update the algorithm for ignored filesystems on UnixThiago Macieira2016-07-061-14/+30
| | | | | | | | | | | | | | | | | | | | | | | | | Use the criterion that GNU coreutils' df uses: if the total size of the filesystem is zero, then it's pseudo. After all, if it contains files in a zero-sized volume, it has to be pseudo; if it contains nothing, then it's not very useful anyway. This would have caught most Linux pseudo-fs anyway, but the mount point check beforehand allows us to skip quite a few statfs() syscalls. The new algorithm also solves the following cases which had been mistakenly interpreted: * fuse and ZFS (source devices don't usually start with /) * pseudo-fs that were mounted from a device starting with / (the source device is usually ignored by the OS) This change is not testable automatically. Manual testing shows it still reports the same entries it used to on Linux, plus now shows FUSE (sshfs) mounts. Task-number: QTBUG-54235 Change-Id: Ib57b52598e2f452985e9fffd1459f06dcefcc5c6 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-06-061-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf config.tests/unix/nis/nis.cpp mkspecs/unsupported/freebsd-g++/qplatformdefs.h src/corelib/tools/qdatetime.cpp src/corelib/tools/qsimd.cpp src/corelib/tools/qsimd_p.h src/network/access/access.pri src/network/access/qnetworkreplynsurlconnectionimpl.mm src/network/access/qnetworkreplynsurlconnectionimpl_p.h src/plugins/platforms/cocoa/qnsview.mm src/plugins/printsupport/windows/qwindowsprintdevice.cpp tests/auto/corelib/kernel/qobject/tst_qobject.cpp tests/auto/network/access/qnetworkreply/BLACKLIST tests/auto/widgets/widgets/qopenglwidget/BLACKLIST Change-Id: I4b32055bbf922392ef0264fd403405416fffee57
| * Compile fix for NetBSD: only BSD using statvfs, disable f_flags defineRalf Nolden2016-05-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Compile fix for NetBSD's use of statvfs having f_flags.All other BSDs use statfs instead of statvfs, so the f_flags define needs to be prevented on NetBSD. Fix obtained from Kamil Rytarowski <n54@gmx.com>, NetBSD qt ports maintainer. Change-Id: Ifbd7ba0cba7f6cf280f5984c64abd7649f667332 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-05-191-26/+40
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure src/3rdparty/angle/src/libANGLE/renderer/d3d/d3d11/Renderer11.cpp src/network/access/qnetworkaccessmanager.cpp src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.h src/widgets/widgets/qlineedit_p.cpp src/widgets/widgets/qlineedit_p.h src/winmain/winmain.pro tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp tests/auto/dbus/qdbusconnection/tst_qdbusconnection.cpp tests/auto/dbus/qdbusconnection/tst_qdbusconnection.h tests/auto/testlib/selftests/expected_cmptest.teamcity tests/auto/testlib/selftests/expected_cmptest.txt tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp tools/configure/configureapp.cpp Change-Id: Ib9997b0d0f91946e4081d36c0c6b696c5c983b2a
| * QStorageInfo: allow getting the info of pseudo filesystems tooThiago Macieira2016-05-091-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | They won't be listed in QStorageInfo::mountedVolumes, but we can now obtain their info if you know their mountpoint. For example, on Linux: $ ./qstorageinfo /dev /proc /sys Filesystem (Type) Size Available BSize Label Mounted on devtmpfs (devtmpfs) RW 4029772 4029764 4096 /dev proc (proc) RW 0 0 4096 /proc sysfs (sysfs) RW 0 0 4096 /sys Change-Id: I3e15a26e0e424169ac2bffff1417ba2429d6d9f4 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * QStorageInfo: get the label properly if the mounted device is a symlinkThiago Macieira2016-05-091-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This happens for me with LVM: $ ls -l /dev/mapper/system-root /dev/system/root /dev/disk/by-label/* lrwxrwxrwx 1 root root 10 Nov 17 22:45 /dev/disk/by-label/system -> ../../dm-1 lrwxrwxrwx 1 root root 7 Nov 17 22:45 /dev/mapper/system-root -> ../dm-1 lrwxrwxrwx 1 root root 7 Nov 17 22:45 /dev/system/root -> ../dm-1 The mounted device according to /etc/mtab (/proc/self/mounts) is /dev/mapper/system-root. Change-Id: I3e15a26e0e424169ac2bffff1417b96779d84246 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * QStorageInfo: update the detection of pseudo filesystemsThiago Macieira2016-05-091-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Allow tmpfs filesystems to be reported, as they're often usable by the user, mounted in /tmp and in /run (the fs for $XDG_RUNTIME_DIR). But disallow anything whose device is not a pathname. This catches most of everything else that wasn't specifically tested for before, like virtual fuse filesystems, like GVFS. Change-Id: I3e15a26e0e424169ac2bffff1417b7cee0f8ec97 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * QStorageInfo: fix matching of mountpoints to sibling directoriesThiago Macieira2016-05-091-24/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The path "/usrfoo" starts with "/usr", so if you tried to get QStorageInfo("/usrfoo") when "/usr" is a mount point, you'd get the wrong filesystem. [ChangeLog][QtCore][QStorageInfo] Fixed a bug that caused QStorageInfo to report information for the wrong filesystem if there is a mounted filesystem at a path that is a prefix of the requested path (e.g., it would report "/usr" filesystem for "/usrfoo"). Task-number: QTBUG-49498 Change-Id: I3e15a26e0e424169ac2bffff1417b7a27cd0132d Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | Use BSD-style statfs members for INTEGRITY.Rolland Dudemaine2016-03-311-2/+2
| | | | | | | | | | Change-Id: I898f3c026923536f74a467564c204db837efbcd7 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | Updated license headersJani Heikkinen2016-01-151-13/+19
|/ | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2015-11-041-2/+8
|\ | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qstorageinfo_unix.cpp src/plugins/platforms/windows/qwindowsmousehandler.cpp src/widgets/styles/qwindowsvistastyle.cpp Change-Id: Ie1725933815891cc8c86258d4c0e8ed0ab386edf
| * Fix QStorageInfo on BSD4 systemsDmitry Shachnev2015-10-271-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | - On NetBSD, the defines were not properly defined; - On all other BSD systems, we use statfs which does not have f_frsize member, revert to using f_bsize there. Task-number: QTBUG-48267 Change-Id: Ia1ed484ac61a615fcbb5b45affb516b5e86a64b0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Lisandro Damián Nicanor Pérez Meyer <perezmeyer@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Android: Warnings--BogDan Vatra2015-10-201-1/+1
| | | | | | | | | | Change-Id: I79bef1e5e73fedf2bae61d6cfc9634a14958ba0e Reviewed-by: Christian Stromme <christian.stromme@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2015-08-261-3/+3
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/doc/snippets/code/doc_src_qmake-manual.pro qmake/doc/src/qmake-manual.qdoc src/corelib/io/qstorageinfo_unix.cpp src/corelib/tools/qbytearray.cpp src/widgets/kernel/qwidgetwindow.cpp tests/auto/corelib/io/qprocess/tst_qprocess.cpp tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp tests/auto/network/access/qnetworkreply/BLACKLIST Change-Id: I9efcd7e1cce1c394eed425c43aa6fce7d2edf31c
| * Merge remote-tracking branch 'origin/5.4' into 5.5Oswald Buddenhagen2015-07-171-3/+3
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: doc/global/manifest-meta.qdocconf src/corelib/global/qnamespace.qdoc src/corelib/io/qstorageinfo_unix.cpp src/corelib/tools/qtools_p.h src/sql/drivers/psql/qsql_psql.cpp Change-Id: I23a15ac84e03ad61d865e3df872b013eb0752949
| | * Correct calculation of filesystem data on unusual filesystemsThiago Macieira2015-05-301-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | POSIX.1 says f_blocks, f_bfree, f_bavail are calculated in terms of f_frsize, not of the regular block size f_bsize. On most systems, it's the same, which is why we didn't catch it. I don't have any filesystem to test this on to confirm. Reference: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_statvfs.h.html Task-number: QTBUG-45137 Change-Id: I27eaacb532114dd188c4ffff13d3e13016bed4e6 Reviewed-by: Dmitry Shachnev <mitya57@gmail.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com>
* | | Add QStorageInfo::blockSizeThiago Macieira2015-07-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore][QStorageInfo] Added QStorageInfo::blockSize(), which returns the optimal block size for data transfer to and from the storage. Change-Id: Ib306f8f647014b399b87ffff13f4eba6000452d4 Reviewed-by: Jake Petroules <jake.petroules@petroules.com> Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
* | | Merge remote-tracking branch 'origin/5.5' into devSimon Hausmann2015-06-031-8/+16
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qnamespace.qdoc src/corelib/io/qwindowspipereader.cpp src/corelib/io/qwindowspipereader_p.h src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/plugins/platforms/xcb/qxcbconnection.h tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp tests/auto/tools/qmake/tst_qmake.cpp tests/manual/touch/main.cpp Change-Id: I917d694890e79ee3da7d65134b5b085e23e0dd62
| * | Fix statfs usage for BSD4 systems in QStorageInfoIvan Komissarov2015-06-011-8/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to NETBSD manual pages, there's no statfs structure; statvfs should be used instead, change introduces defines for the stat(v)fs struct/function. Task-number: QTBUG-40785 Change-Id: I98599e4635e46f90ffcc99c768f4c250f09f914f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Merge remote-tracking branch 'origin/5.5' into devLiang Qi2015-04-221-1/+5
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/statemachine/qstatemachine.cpp src/corelib/statemachine/qstatemachine_p.h src/gui/painting/qdrawhelper.cpp src/plugins/platforms/xcb/qxcbnativeinterface.cpp src/plugins/platforms/xcb/qxcbwindow.cpp src/plugins/platforms/xcb/qxcbwindow.h src/testlib/qtestblacklist.cpp src/tools/qdoc/node.cpp src/tools/qdoc/node.h tests/auto/gui/painting/qcolor/tst_qcolor.cpp Change-Id: I6c78b7b162001712d5774293f501b06b4ff32684
| * | qstorageinfo_unix.cpp: fixes for NetBSD and solarisNiclas Rosenvik2015-04-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NetBSD uses struct statvfs ** as first argument to getmntinfo. see: http://netbsd.gw.com/cgi-bin/man-cgi?getmntinfo getmntent on solaris and sunos returns an integer not a pointer. see: http://www.unix.com/man-page/opensolaris/3c/getmntent/ see: https://smartos.org/man/3C/getmntent Change-Id: Ic01da0edcf1f55617294e5a86b8459669e82c1b1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | Hurd: Implement QStorageInfo for HurdPino Toscano2015-04-021-4/+5
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | Make use of the Linux implementation for Hurd as well, as the mntent API is available there too (including getmntent_r, specific to GNU libc). Since PATH_MAX is not available on Hurd, and the current bufferSize is a lot more larger than it is needed, restrict bufferSize to 1024 bytes, which should be enough to cover 3 paths in mtab and it is usually used also in other projects. Change-Id: Ied43be2ab1eb95b48eb9f55a92064e7549efaefd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Merge remote-tracking branch 'origin/5.4' into 5.5Frederik Gladhorn2015-02-241-3/+4
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/xml/htmlinfo/simpleexample.html examples/xml/rsslisting/rsslisting.cpp qmake/generators/win32/msbuild_objectmodel.cpp src/3rdparty/harfbuzz-ng/src/hb-private.hh src/corelib/global/qlogging.cpp src/corelib/io/qstorageinfo_unix.cpp src/corelib/thread/qwaitcondition_unix.cpp src/gui/kernel/qguiapplication.cpp src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp src/testlib/doc/src/qt-webpages.qdoc tests/auto/other/qaccessibility/tst_qaccessibility.cpp Change-Id: Ib272ff0bc30a1a5d51275eb3cd2f201dc82c11ff
| * qstorageinfo_unix.cpp: Fix build on SolarisDmitry Shachnev2015-02-201-3/+4
| | | | | | | | | | | | | | | | Task-number: QTBUG-44556 Change-Id: I22d791011866175ca88de88c0b1a7c4d9d397d8f Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Haiku: Extend QStorageInfo implementationTobias Koenig2015-02-201-2/+25
| | | | | | | | | | | | | | | | | | | | Provide the file system type, the name (label) of the volume and the path to the associated device (if available). Change-Id: I7dd0d314d3f757e0f57c8f82beaf8ee21da86167 Reviewed-by: Augustin Cavalier <waddlesplash@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Haiku: Implement QStorageInfo for HaikuTobias Koenig2015-02-141-0/+60
| | | | | | | | | | | | | | | | | | Use Haiku's BVolumeRoster API to provide information about available mount points in QStorageInfo. Change-Id: I058bbb5f3f33372edc55d3e51079d3e16815f29f Reviewed-by: Augustin Cavalier <waddlesplash@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Update copyright headersJani Heikkinen2015-02-111-21/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* | Haiku: Make corelib compile on HaikuTobias Koenig2015-01-101-0/+3
| | | | | | | | | | Change-Id: I66bc492390eedd723ab7866d3c7a38539d708727 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.4' into devFrederik Gladhorn2014-12-291-3/+4
|\| | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qbytearray.cpp src/gui/kernel/qplatformsystemtrayicon.cpp src/gui/kernel/qplatformsystemtrayicon.h src/plugins/platforms/xcb/xcb-plugin.pro Change-Id: I00355d3908b678af8a61c38f9e814a63df808c79
| * qstorageinfo_unix.cpp: Fix build on BSD and other unicesDmitry Shachnev2014-12-231-3/+4
| | | | | | | | | | | | | | | | | | | | | | * Include statvfs.h on all non-Linux and non-Solaris systems. * Fix type of stat_buf structure on BSD. Change-Id: I6336503082fafd7f6108cf95c079bdd329d2ea0f Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> Reviewed-by: Lisandro Damián Nicanor Pérez Meyer <perezmeyer@gmail.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
* | Merge remote-tracking branch 'origin/5.4' into devFrederik Gladhorn2014-11-241-4/+3
|\| | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qiodevice.cpp src/plugins/bearer/linux_common/qofonoservice_linux.cpp src/plugins/bearer/linux_common/qofonoservice_linux_p.h src/plugins/platforms/android/qandroidplatformtheme.cpp src/tools/bootstrap/bootstrap.pro src/widgets/styles/qmacstyle_mac.mm Change-Id: Ia02aab6c4598ce74e9c30bb4666d5e2ef000f99b
| * Handle mounts under /runAllan Sandfeld Jensen2014-10-311-4/+3
| | | | | | | | | | | | | | | | | | | | | | We shouldn't excluded all volumes under /run since some distos will mount filesystems there. Instead we should exclude all filesystems with the type "tmpfs" that /run has, and rpc_pipefs that is mounted below /run. Tmpfs" is excluded for all UNIX systems since the BSDs have a similarly named filesystem. Change-Id: I03fdac515c0bfb1b824b2e3eae1022dd699c0998 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Fix spelling errors in method names in QStorageInfo.Jeff Tranter2014-10-221-2/+2
|/ | | | | | | | | | The methods retreiveVolumeInfo() and retreiveDiskFreeSpace() should be retrieveVolumeInfo() and retrieveDiskFreeSpace(). Task-number: QTBUG-42068 Change-Id: I86137fbff26c42c8cc8bad366a4733118d6ca292 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Don't use QStringLiteral in startsWith/endsWidthMarc Mutz2014-10-091-6/+6
| | | | | | | | | | | | | | | For QLatin1String, startsWith/endsWith is overloaded, so comparing to a latin-1 (C) string literal is efficient, since strlen() is comparatively fast. OTOH, QStringLiteral, when not using RVO, litters the code with QString dtor calls, which are not inline. Worse, absent lambdas, it even allocates memory. So, just use QLatin1String instead. Change-Id: I7eaf464c67b55116f970fe7f58a85f19ce4d254e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Compile on Android without statfs.f_flagsAllan Sandfeld Jensen2014-08-161-0/+2
| | | | | | | | | | Not all Android versions appear to have f_flags in statfs, but we can check for the presence using a feature define. Change-Id: Ib2acf6063d6211b871f462ee491459ac8675aa37 Reviewed-by: Ivan Komissarov <ABBAPOH@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add the QStorageInfo classIvan Komissarov2014-08-131-0/+454
Allows to retrieve information about mounted volumes such as label, total/available size, filesystem type and so on. Possible use cases are: - allows to do checks about filesystem before performing actual operation (such as available/maximum volume size) - allows to retrive information about volume that can be shown in file dialogs - allows to retrieve volume for specific path and check if two or more paths belong to the same volume or not [ChangeLog][QtCore] Added QStorageInfo class to retrive information about mounted volumes and drives Change-Id: Ibf9c2e6b53ef39c5605894a4422acdbbca4030c4 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>