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

Public Types

class List
enum DetailsNeededFlag { BasicInfoNeeded, NeedMountOptions, NeedRealDeviceName }
flags DetailsNeededFlags
enum FileSystemFlag { SupportsChmod, SupportsChown, SupportsUTime, SupportsSymlinks, CaseInsensitive }

Public Functions

dev_t deviceId() const
(since 6.24) bool isEncryptedFs() const
bool isOnNetwork() const
(since 6.24) bool isPseudoFs() const
(since 6.24) quint64 mountId() const
QStringList mountOptions() const
QString mountPoint() const
QString mountType() const
QString mountedFrom() const
bool probablySlow() const
QString realDeviceName() const
bool testFileSystemFlag(KMountPoint::FileSystemFlag flag) const

Static Public Members

KMountPoint::List currentMountPoints(KMountPoint::DetailsNeededFlags infoNeeded = BasicInfoNeeded)
KMountPoint::List possibleMountPoints(KMountPoint::DetailsNeededFlags infoNeeded = BasicInfoNeeded)

Detailed Description

It provides a system independent interface to fstab.

Member Type Documentation

enum KMountPoint::DetailsNeededFlag
flags KMountPoint::DetailsNeededFlags

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

ConstantValueDescription
KMountPoint::BasicInfoNeeded0Only the basic details: mountedFrom, mountPoint, mountType.
KMountPoint::NeedMountOptions1Also fetch the options used when mounting, see KMountPoint::mountOptions().
KMountPoint::NeedRealDeviceName2Also 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

ConstantValue
KMountPoint::SupportsChmod0
KMountPoint::SupportsChown1
KMountPoint::SupportsUTime2
KMountPoint::SupportsSymlinks3
KMountPoint::CaseInsensitive4

Member Function Documentation

[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 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 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 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)