Pages
API Documentation
On this page

KMountPoint Class

The KMountPoint class provides information about mounted and unmounted disks. More...

  • Header: #include <KMountPoint>
  • CMake: find_package(KF6 REQUIRED COMPONENTS KIO)
    target_link_libraries(mytarget PRIVATE KF6::KIOCore)
  • Inherits: QSharedData

List of all members, including inherited members

Public Types

Public Functions

Static Public Members

Detailed Description

It provides a system independent interface to fstab or libmount.

Member Type Documentation

enum KMountPoint::DetailsNeededFlag

flags KMountPoint::DetailsNeededFlags

Flags that specify which additional details should be fetched for each mountpoint.

Constant Value Description
KMountPoint::BasicInfoNeeded 0 Only the basic details: mountedFrom, mountPoint, mountType.
KMountPoint::NeedMountOptions 1 Also fetch the options used when mounting, see KMountPoint::mountOptions().
KMountPoint::NeedRealDeviceName 2 Also fetch the device name (with symlinks resolved), see KMountPoint::realDeviceName().

The DetailsNeededFlags type is a typedef for QFlags<DetailsNeededFlag>. It stores an OR combination of DetailsNeededFlag values.

enum KMountPoint::FileSystemFlag

Constant Value
KMountPoint::SupportsChmod 0
KMountPoint::SupportsChown 1
KMountPoint::SupportsUTime 2
KMountPoint::SupportsSymlinks 3
KMountPoint::CaseInsensitive 4
KMountPoint::SupportsFileCloning (since Qt 6.30) 5 Copy-on-write filesystem, where a file can be copied with the FICLONE ioctl.

Member Function Documentation

[static, since 6.30] KMountPoint::Ptr KMountPoint::currentMountPointForPath(const QString &path)

Returns the current mount point that path resides on, using the same cache as currentMountPointForUniqueId(). Falls back to currentMountPoints().findByPath() when unique mount ids are not available.

Returns the mount point, or nullptr if none matches.

This function was introduced in Qt 6.30.

[static, since 6.30] KMountPoint::Ptr KMountPoint::currentMountPointForUniqueId(quint64 uniqueMountId)

Returns the current mount point that has the given unique mount id, as reported by statx() with STATX_MNT_ID_UNIQUE, or nullptr if no current mount has this id.

It is guaranteed to return for any mounted mountpoint on Linux 6.8+.

Note: This is only useful on Linux; elsewhere it re-reads the mount table on every call, like currentMountPoints().

Warning: uniqueMountId must not be zero.

This function was introduced in Qt 6.30.

See also KIO::UDSEntry::UDS_MOUNT_ID

[static] KMountPoint::List KMountPoint::currentMountPoints(KMountPoint::DetailsNeededFlags infoNeeded = BasicInfoNeeded)

Returns a list of all current mountpoints.

infoNeeded Flags that specify which additional information should be fetched.

Note: This method will return an empty list on Android

dev_t KMountPoint::deviceId() const

Returns the device ID (dev_t, major, minor) of this mount point. This ID is unique per device (including network mounts).

[since 6.24] bool KMountPoint::isEncryptedFs() const

Returns true if this mount points to a filesystem that is encrypting its content (e.g. gocryptfs), otherwise returns false.

This function was introduced in Qt 6.24.

bool KMountPoint::isOnNetwork() const

Returns true if this mount point represents a network filesystem (e.g. NFS, CIFS, etc.), otherwise returns false.

[since 6.24] bool KMountPoint::isPseudoFs() const

Returns true if this mount points to a pseudo filesystem (e.g. devfs, proc, tmpfs, fuse, etc.), otherwise returns false.

This function was introduced in Qt 6.24.

[since 6.24] quint64 KMountPoint::mountId() const

Returns the mount ID of this mount point.

If the system supports MNT_ID_UNIQUE, it will be returned. It is guaranteed to be unique until the next boot. If the system doesn't support that, the MNT_ID property will be returned. It is unique for a point in time, but is not guaranteed to be unique until next boot.

On systems without statmount() (exists since Linux 6.8) this will return 0.

This function was introduced in Qt 6.24.

QStringList KMountPoint::mountOptions() const

Options used to mount the filesystem. Only available if the NeedMountOptions flag was set.

QString KMountPoint::mountPoint() const

Path where the filesystem is mounted (if you used currentMountPoints()), or can be mounted (if you used possibleMountPoints()).

QString KMountPoint::mountType() const

Type of filesystem

QString KMountPoint::mountedFrom() const

Where this filesystem gets mounted from. This can refer to a device, a remote server or something else.

[static] KMountPoint::List KMountPoint::possibleMountPoints(KMountPoint::DetailsNeededFlags infoNeeded = BasicInfoNeeded)

This function gives a list of all possible mountpoints. (fstab)

infoNeeded Flags that specify which additional information should be fetched.

bool KMountPoint::probablySlow() const

Returns true if the filesystem is "probably" slow, e.g. a network mount, false otherwise.

QString KMountPoint::realDeviceName() const

Canonical name of the device where the filesystem got mounted from. (Or empty, if not a device) Only available when the NeedRealDeviceName flag was set.

bool KMountPoint::testFileSystemFlag(KMountPoint::FileSystemFlag flag) const

Checks the capabilities of the filesystem.

flag the flag to check

Returns true if the filesystem has that flag, false if not

The available flags are:

  • SupportsChmod: returns true if the filesystem supports chmod (e.g. msdos filesystems return false)
  • SupportsChown: returns true if the filesystem supports chown (e.g. msdos filesystems return false)
  • SupportsUtime: returns true if the filesystems supports utime (e.g. msdos filesystems return false)
  • SupportsSymlinks: returns true if the filesystems supports symlinks (e.g. msdos filesystems return false)
  • CaseInsensitive: returns true if the filesystem treats "foo" and "FOO" as being the same file (true for msdos filesystems)
  • SupportsFileCloning: returns true on a copy-on-write filesystem, where a file can be copied with the FICLONE ioctl, which only ever works within one filesystem. Such a filesystem may still turn a single request down, XFS for one only clones when it was made with reflink support, so a caller has to be ready for the request to fail and copy the contents instead.
We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.