Mount

class Mount(*args, **kwargs)

The GMount interface represents user-visible mounts. Note, when porting from GnomeVFS, GMount is the moral equivalent of GnomeVFSVolume.

GMount is a ‘mounted’ filesystem that you can access. Mounted is in quotes because it’s not the same as a UNIX mount, it might be a GVFS mount, but you can still access the files on it if you use GIO. Might or might not be related to a volume object.

Unmounting a GMount instance is an asynchronous operation. For more information about asynchronous operations, see AsyncResult and Task. To unmount a GMount instance, first call unmount_with_operation with (at least) the GMount instance and a AsyncReadyCallback. The callback will be fired when the operation has resolved (either with success or failure), and a AsyncResult structure will be passed to the callback. That callback should then call unmount_with_operation_finish with the GMount and the AsyncResult data to see if the operation was completed successfully. If an error is present when unmount_with_operation_finish is called, then it will be filled with any error information.

Methods

class Mount
can_eject() bool

Checks if mount can be ejected.

can_unmount() bool

Checks if mount can be unmounted.

eject(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Ejects a mount. This is an asynchronous operation, and is finished by calling eject_finish() with the mount and AsyncResult data returned in the callback.

Deprecated since version 2.22: Use eject_with_operation() instead.

Parameters:
  • flags – flags affecting the unmount if required for eject

  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback, or None.

  • user_data – user data passed to callback.

eject_finish(result: AsyncResult) bool

Finishes ejecting a mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned.

Deprecated since version 2.22: Use eject_with_operation_finish() instead.

Parameters:

result – a AsyncResult.

eject_with_operation(flags: MountUnmountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Ejects a mount. This is an asynchronous operation, and is finished by calling eject_with_operation_finish() with the mount and AsyncResult data returned in the callback.

Added in version 2.22.

Parameters:
  • flags – flags affecting the unmount if required for eject

  • mount_operation – a MountOperation or None to avoid user interaction.

  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback, or None.

  • user_data – user data passed to callback.

eject_with_operation_finish(result: AsyncResult) bool

Finishes ejecting a mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned.

Added in version 2.22.

Parameters:

result – a AsyncResult.

get_default_location() File

Gets the default location of mount. The default location of the given mount is a path that reflects the main entry point for the user (e.g. the home directory, or the root of the volume).

get_drive() Drive | None

Gets the drive for the mount.

This is a convenience method for getting the Volume and then using that object to get the Drive.

get_icon() Icon

Gets the icon for mount.

get_name() str

Gets the name of mount.

get_root() File

Gets the root directory on mount.

get_sort_key() str | None

Gets the sort key for mount, if any.

Added in version 2.32.

get_symbolic_icon() Icon

Gets the symbolic icon for mount.

Added in version 2.34.

get_uuid() str | None

Gets the UUID for the mount. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. Returns None if there is no UUID available.

get_volume() Volume | None

Gets the volume for the mount.

guess_content_type(force_rescan: bool, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Tries to guess the type of content stored on mount. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.

This is an asynchronous operation (see guess_content_type_sync() for the synchronous version), and is finished by calling guess_content_type_finish() with the mount and AsyncResult data returned in the callback.

Added in version 2.18.

Parameters:
  • force_rescan – Whether to force a rescan of the content. Otherwise a cached result will be used if available

  • cancellable – optional Cancellable object, None to ignore

  • callback – a AsyncReadyCallback

  • user_data – user data passed to callback

guess_content_type_finish(result: AsyncResult) list[str]

Finishes guessing content types of mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned. In particular, you may get an NOT_SUPPORTED if the mount does not support content guessing.

Added in version 2.18.

Parameters:

result – a AsyncResult

guess_content_type_sync(force_rescan: bool, cancellable: Cancellable | None = None) list[str]

Tries to guess the type of content stored on mount. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.

This is a synchronous operation and as such may block doing IO; see guess_content_type() for the asynchronous version.

Added in version 2.18.

Parameters:
  • force_rescan – Whether to force a rescan of the content. Otherwise a cached result will be used if available

  • cancellable – optional Cancellable object, None to ignore

is_shadowed() bool

Determines if mount is shadowed. Applications or libraries should avoid displaying mount in the user interface if it is shadowed.

A mount is said to be shadowed if there exists one or more user visible objects (currently Mount objects) with a root that is inside the root of mount.

One application of shadow mounts is when exposing a single file system that is used to address several logical volumes. In this situation, a VolumeMonitor implementation would create two Volume objects (for example, one for the camera functionality of the device and one for a SD card reader on the device) with activation URIs gphoto2://[usb:001,002]/store1/ and gphoto2://[usb:001,002]/store2/. When the underlying mount (with root gphoto2://[usb:001,002]/) is mounted, said VolumeMonitor implementation would create two Mount objects (each with their root matching the corresponding volume activation root) that would shadow the original mount.

The proxy monitor in GVfs 2.26 and later, automatically creates and manage shadow mounts (and shadows the underlying mount) if the activation root on a Volume is set.

Added in version 2.20.

remount(flags: MountMountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Remounts a mount. This is an asynchronous operation, and is finished by calling remount_finish() with the mount and AsyncResult data returned in the callback.

Remounting is useful when some setting affecting the operation of the volume has been changed, as these may need a remount to take affect. While this is semantically equivalent with unmounting and then remounting not all backends might need to actually be unmounted.

Parameters:
  • flags – flags affecting the operation

  • mount_operation – a MountOperation or None to avoid user interaction.

  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback, or None.

  • user_data – user data passed to callback.

remount_finish(result: AsyncResult) bool

Finishes remounting a mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned.

Parameters:

result – a AsyncResult.

shadow() None

Increments the shadow count on mount. Usually used by VolumeMonitor implementations when creating a shadow mount for mount, see is_shadowed() for more information. The caller will need to emit the Mount::changed signal on mount manually.

Added in version 2.20.

unmount(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Unmounts a mount. This is an asynchronous operation, and is finished by calling unmount_finish() with the mount and AsyncResult data returned in the callback.

Deprecated since version 2.22: Use unmount_with_operation() instead.

Parameters:
  • flags – flags affecting the operation

  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback, or None.

  • user_data – user data passed to callback.

unmount_finish(result: AsyncResult) bool

Finishes unmounting a mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned.

Deprecated since version 2.22: Use unmount_with_operation_finish() instead.

Parameters:

result – a AsyncResult.

unmount_with_operation(flags: MountUnmountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Unmounts a mount. This is an asynchronous operation, and is finished by calling unmount_with_operation_finish() with the mount and AsyncResult data returned in the callback.

Added in version 2.22.

Parameters:
  • flags – flags affecting the operation

  • mount_operation – a MountOperation or None to avoid user interaction.

  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback, or None.

  • user_data – user data passed to callback.

unmount_with_operation_finish(result: AsyncResult) bool

Finishes unmounting a mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned.

Added in version 2.22.

Parameters:

result – a AsyncResult.

unshadow() None

Decrements the shadow count on mount. Usually used by VolumeMonitor implementations when destroying a shadow mount for mount, see is_shadowed() for more information. The caller will need to emit the Mount::changed signal on mount manually.

Added in version 2.20.

Signals

class Mount.signals
changed() None

Emitted when the mount has been changed.

pre_unmount() None

This signal may be emitted when the Mount is about to be unmounted.

This signal depends on the backend and is only emitted if GIO was used to unmount.

Added in version 2.22.

unmounted() None

This signal is emitted when the Mount have been unmounted. If the recipient is holding references to the object they should release them so the object can be finalized.

Virtual Methods

class Mount
do_can_eject() bool

Checks if mount can be ejected.

do_can_unmount() bool

Checks if mount can be unmounted.

do_changed() None

Changed signal that is emitted when the mount’s state has changed.

do_eject(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Ejects a mount. This is an asynchronous operation, and is finished by calling eject_finish() with the mount and AsyncResult data returned in the callback.

Deprecated since version 2.22: Use eject_with_operation() instead.

Parameters:
  • flags – flags affecting the unmount if required for eject

  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback, or None.

  • user_data – user data passed to callback.

do_eject_finish(result: AsyncResult) bool

Finishes ejecting a mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned.

Deprecated since version 2.22: Use eject_with_operation_finish() instead.

Parameters:

result – a AsyncResult.

do_eject_with_operation(flags: MountUnmountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Ejects a mount. This is an asynchronous operation, and is finished by calling eject_with_operation_finish() with the mount and AsyncResult data returned in the callback.

Added in version 2.22.

Parameters:
  • flags – flags affecting the unmount if required for eject

  • mount_operation – a MountOperation or None to avoid user interaction.

  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback, or None.

  • user_data – user data passed to callback.

do_eject_with_operation_finish(result: AsyncResult) bool

Finishes ejecting a mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned.

Added in version 2.22.

Parameters:

result – a AsyncResult.

do_get_default_location() File

Gets the default location of mount. The default location of the given mount is a path that reflects the main entry point for the user (e.g. the home directory, or the root of the volume).

do_get_drive() Drive | None

Gets the drive for the mount.

This is a convenience method for getting the Volume and then using that object to get the Drive.

do_get_icon() Icon

Gets the icon for mount.

do_get_name() str

Gets the name of mount.

do_get_root() File

Gets the root directory on mount.

do_get_sort_key() str | None

Gets the sort key for mount, if any.

Added in version 2.32.

do_get_symbolic_icon() Icon

Gets the symbolic icon for mount.

Added in version 2.34.

do_get_uuid() str | None

Gets the UUID for the mount. The reference is typically based on the file system UUID for the mount in question and should be considered an opaque string. Returns None if there is no UUID available.

do_get_volume() Volume | None

Gets the volume for the mount.

do_guess_content_type(force_rescan: bool, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Tries to guess the type of content stored on mount. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.

This is an asynchronous operation (see guess_content_type_sync() for the synchronous version), and is finished by calling guess_content_type_finish() with the mount and AsyncResult data returned in the callback.

Added in version 2.18.

Parameters:
  • force_rescan – Whether to force a rescan of the content. Otherwise a cached result will be used if available

  • cancellable – optional Cancellable object, None to ignore

  • callback – a AsyncReadyCallback

  • user_data – user data passed to callback

do_guess_content_type_finish(result: AsyncResult) list[str]

Finishes guessing content types of mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned. In particular, you may get an NOT_SUPPORTED if the mount does not support content guessing.

Added in version 2.18.

Parameters:

result – a AsyncResult

do_guess_content_type_sync(force_rescan: bool, cancellable: Cancellable | None = None) list[str]

Tries to guess the type of content stored on mount. Returns one or more textual identifiers of well-known content types (typically prefixed with “x-content/”), e.g. x-content/image-dcf for camera memory cards. See the shared-mime-info specification for more on x-content types.

This is a synchronous operation and as such may block doing IO; see guess_content_type() for the asynchronous version.

Added in version 2.18.

Parameters:
  • force_rescan – Whether to force a rescan of the content. Otherwise a cached result will be used if available

  • cancellable – optional Cancellable object, None to ignore

do_pre_unmount() None

The ::pre-unmount signal that is emitted when the Mount will soon be emitted. If the recipient is somehow holding the mount open by keeping an open file on it it should close the file.

do_remount(flags: MountMountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Remounts a mount. This is an asynchronous operation, and is finished by calling remount_finish() with the mount and AsyncResult data returned in the callback.

Remounting is useful when some setting affecting the operation of the volume has been changed, as these may need a remount to take affect. While this is semantically equivalent with unmounting and then remounting not all backends might need to actually be unmounted.

Parameters:
  • flags – flags affecting the operation

  • mount_operation – a MountOperation or None to avoid user interaction.

  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback, or None.

  • user_data – user data passed to callback.

do_remount_finish(result: AsyncResult) bool

Finishes remounting a mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned.

Parameters:

result – a AsyncResult.

do_unmount(flags: MountUnmountFlags, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Unmounts a mount. This is an asynchronous operation, and is finished by calling unmount_finish() with the mount and AsyncResult data returned in the callback.

Deprecated since version 2.22: Use unmount_with_operation() instead.

Parameters:
  • flags – flags affecting the operation

  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback, or None.

  • user_data – user data passed to callback.

do_unmount_finish(result: AsyncResult) bool

Finishes unmounting a mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned.

Deprecated since version 2.22: Use unmount_with_operation_finish() instead.

Parameters:

result – a AsyncResult.

do_unmount_with_operation(flags: MountUnmountFlags, mount_operation: MountOperation | None = None, cancellable: Cancellable | None = None, callback: Callable[[...], None] | None = None, *user_data: Any) None

Unmounts a mount. This is an asynchronous operation, and is finished by calling unmount_with_operation_finish() with the mount and AsyncResult data returned in the callback.

Added in version 2.22.

Parameters:
  • flags – flags affecting the operation

  • mount_operation – a MountOperation or None to avoid user interaction.

  • cancellable – optional Cancellable object, None to ignore.

  • callback – a AsyncReadyCallback, or None.

  • user_data – user data passed to callback.

do_unmount_with_operation_finish(result: AsyncResult) bool

Finishes unmounting a mount. If any errors occurred during the operation, error will be set to contain the errors and False will be returned.

Added in version 2.22.

Parameters:

result – a AsyncResult.

do_unmounted() None

The unmounted signal that is emitted when the Mount have been unmounted. If the recipient is holding references to the object they should release them so the object can be finalized.