1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
3 /* GIO - GLib Input, Output and Streaming Library
5 * Copyright (C) 2006-2008 Red Hat, Inc.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General
18 * Public License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 * Boston, MA 02111-1307, USA.
22 * Author: Alexander Larsson <alexl@redhat.com>
23 * David Zeuthen <davidz@redhat.com>
31 #include "gmountprivate.h"
32 #include "gthemedicon.h"
33 #include "gasyncresult.h"
34 #include "gsimpleasyncresult.h"
41 * @short_description: Mount management
43 * @see_also: GVolume, GUnixMountEntry, GUnixMountPoint
45 * The #GMount interface represents user-visible mounts. Note, when
46 * porting from GnomeVFS, #GMount is the moral equivalent of #GnomeVFSVolume.
48 * #GMount is a "mounted" filesystem that you can access. Mounted is in
49 * quotes because it's not the same as a unix mount, it might be a gvfs
50 * mount, but you can still access the files on it if you use GIO. Might or
51 * might not be related to a volume object.
53 * Unmounting a #GMount instance is an asynchronous operation. For
54 * more information about asynchronous operations, see #GAsyncResult
55 * and #GSimpleAsyncResult. To unmount a #GMount instance, first call
56 * g_mount_unmount_with_operation() with (at least) the #GMount instance and a
57 * #GAsyncReadyCallback. The callback will be fired when the
58 * operation has resolved (either with success or failure), and a
59 * #GAsyncReady structure will be passed to the callback. That
60 * callback should then call g_mount_unmount_with_operation_finish() with the #GMount
61 * and the #GAsyncReady data to see if the operation was completed
62 * successfully. If an @error is present when g_mount_unmount_with_operation_finish()
63 * is called, then it will be filled with any error information.
66 typedef GMountIface GMountInterface;
67 G_DEFINE_INTERFACE (GMount, g_mount, G_TYPE_OBJECT)
70 g_mount_default_init (GMountInterface *iface)
74 * @mount: the object on which the signal is emitted
76 * Emitted when the mount has been changed.
78 g_signal_new (I_("changed"),
81 G_STRUCT_OFFSET (GMountIface, changed),
83 g_cclosure_marshal_VOID__VOID,
88 * @mount: the object on which the signal is emitted
90 * This signal is emitted when the #GMount have been
91 * unmounted. If the recipient is holding references to the
92 * object they should release them so the object can be
95 g_signal_new (I_("unmounted"),
98 G_STRUCT_OFFSET (GMountIface, unmounted),
100 g_cclosure_marshal_VOID__VOID,
103 * GMount::pre-unmount:
104 * @mount: the object on which the signal is emitted
106 * This signal is emitted when the #GMount is about to be
111 g_signal_new (I_("pre-unmount"),
114 G_STRUCT_OFFSET (GMountIface, pre_unmount),
116 g_cclosure_marshal_VOID__VOID,
124 * Gets the root directory on @mount.
126 * Returns: (transfer full): a #GFile.
127 * The returned object should be unreffed with
128 * g_object_unref() when no longer needed.
131 g_mount_get_root (GMount *mount)
135 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
137 iface = G_MOUNT_GET_IFACE (mount);
139 return (* iface->get_root) (mount);
143 * g_mount_get_default_location:
146 * Gets the default location of @mount. The default location of the given
147 * @mount is a path that reflects the main entry point for the user (e.g.
148 * the home directory, or the root of the volume).
150 * Returns: (transfer full): a #GFile.
151 * The returned object should be unreffed with
152 * g_object_unref() when no longer needed.
155 g_mount_get_default_location (GMount *mount)
160 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
162 iface = G_MOUNT_GET_IFACE (mount);
164 /* Fallback to get_root when default_location () is not available */
165 if (iface->get_default_location)
166 file = (* iface->get_default_location) (mount);
168 file = (* iface->get_root) (mount);
177 * Gets the name of @mount.
179 * Returns: the name for the given @mount.
180 * The returned string should be freed with g_free()
181 * when no longer needed.
184 g_mount_get_name (GMount *mount)
188 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
190 iface = G_MOUNT_GET_IFACE (mount);
192 return (* iface->get_name) (mount);
199 * Gets the icon for @mount.
201 * Returns: (transfer full): a #GIcon.
202 * The returned object should be unreffed with
203 * g_object_unref() when no longer needed.
206 g_mount_get_icon (GMount *mount)
210 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
212 iface = G_MOUNT_GET_IFACE (mount);
214 return (* iface->get_icon) (mount);
219 * g_mount_get_symbolic_icon:
222 * Gets the symbolic icon for @mount.
224 * Returns: (transfer full): a #GIcon.
225 * The returned object should be unreffed with
226 * g_object_unref() when no longer needed.
231 g_mount_get_symbolic_icon (GMount *mount)
236 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
238 iface = G_MOUNT_GET_IFACE (mount);
240 if (iface->get_symbolic_icon != NULL)
241 ret = iface->get_symbolic_icon (mount);
243 ret = g_themed_icon_new_with_default_fallbacks ("folder-remote-symbolic");
252 * Gets the UUID for the @mount. The reference is typically based on
253 * the file system UUID for the mount in question and should be
254 * considered an opaque string. Returns %NULL if there is no UUID
257 * Returns: the UUID for @mount or %NULL if no UUID can be computed.
258 * The returned string should be freed with g_free()
259 * when no longer needed.
262 g_mount_get_uuid (GMount *mount)
266 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
268 iface = G_MOUNT_GET_IFACE (mount);
270 return (* iface->get_uuid) (mount);
274 * g_mount_get_volume:
277 * Gets the volume for the @mount.
279 * Returns: (transfer full): a #GVolume or %NULL if @mount is not associated with a volume.
280 * The returned object should be unreffed with
281 * g_object_unref() when no longer needed.
284 g_mount_get_volume (GMount *mount)
288 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
290 iface = G_MOUNT_GET_IFACE (mount);
292 return (* iface->get_volume) (mount);
299 * Gets the drive for the @mount.
301 * This is a convenience method for getting the #GVolume and then
302 * using that object to get the #GDrive.
304 * Returns: (transfer full): a #GDrive or %NULL if @mount is not associated with a volume or a drive.
305 * The returned object should be unreffed with
306 * g_object_unref() when no longer needed.
309 g_mount_get_drive (GMount *mount)
313 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
315 iface = G_MOUNT_GET_IFACE (mount);
317 return (* iface->get_drive) (mount);
321 * g_mount_can_unmount:
324 * Checks if @mount can be mounted.
326 * Returns: %TRUE if the @mount can be unmounted.
329 g_mount_can_unmount (GMount *mount)
333 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
335 iface = G_MOUNT_GET_IFACE (mount);
337 return (* iface->can_unmount) (mount);
344 * Checks if @mount can be eject.
346 * Returns: %TRUE if the @mount can be ejected.
349 g_mount_can_eject (GMount *mount)
353 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
355 iface = G_MOUNT_GET_IFACE (mount);
357 return (* iface->can_eject) (mount);
363 * @flags: flags affecting the operation
364 * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
365 * @callback: (allow-none): a #GAsyncReadyCallback, or %NULL.
366 * @user_data: user data passed to @callback.
368 * Unmounts a mount. This is an asynchronous operation, and is
369 * finished by calling g_mount_unmount_finish() with the @mount
370 * and #GAsyncResult data returned in the @callback.
372 * Deprecated: 2.22: Use g_mount_unmount_with_operation() instead.
375 g_mount_unmount (GMount *mount,
376 GMountUnmountFlags flags,
377 GCancellable *cancellable,
378 GAsyncReadyCallback callback,
383 g_return_if_fail (G_IS_MOUNT (mount));
385 iface = G_MOUNT_GET_IFACE (mount);
387 if (iface->unmount == NULL)
389 g_simple_async_report_error_in_idle (G_OBJECT (mount),
391 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
392 /* Translators: This is an error
393 * message for mount objects that
394 * don't implement unmount. */
395 _("mount doesn't implement \"unmount\""));
400 (* iface->unmount) (mount, flags, cancellable, callback, user_data);
404 * g_mount_unmount_finish:
406 * @result: a #GAsyncResult.
407 * @error: a #GError location to store the error occurring, or %NULL to
410 * Finishes unmounting a mount. If any errors occurred during the operation,
411 * @error will be set to contain the errors and %FALSE will be returned.
413 * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise.
415 * Deprecated: 2.22: Use g_mount_unmount_with_operation_finish() instead.
418 g_mount_unmount_finish (GMount *mount,
419 GAsyncResult *result,
424 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
425 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
427 if (g_async_result_legacy_propagate_error (result, error))
430 iface = G_MOUNT_GET_IFACE (mount);
431 return (* iface->unmount_finish) (mount, result, error);
438 * @flags: flags affecting the unmount if required for eject
439 * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
440 * @callback: (allow-none): a #GAsyncReadyCallback, or %NULL.
441 * @user_data: user data passed to @callback.
443 * Ejects a mount. This is an asynchronous operation, and is
444 * finished by calling g_mount_eject_finish() with the @mount
445 * and #GAsyncResult data returned in the @callback.
447 * Deprecated: 2.22: Use g_mount_eject_with_operation() instead.
450 g_mount_eject (GMount *mount,
451 GMountUnmountFlags flags,
452 GCancellable *cancellable,
453 GAsyncReadyCallback callback,
458 g_return_if_fail (G_IS_MOUNT (mount));
460 iface = G_MOUNT_GET_IFACE (mount);
462 if (iface->eject == NULL)
464 g_simple_async_report_error_in_idle (G_OBJECT (mount),
466 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
467 /* Translators: This is an error
468 * message for mount objects that
469 * don't implement eject. */
470 _("mount doesn't implement \"eject\""));
475 (* iface->eject) (mount, flags, cancellable, callback, user_data);
479 * g_mount_eject_finish:
481 * @result: a #GAsyncResult.
482 * @error: a #GError location to store the error occurring, or %NULL to
485 * Finishes ejecting a mount. If any errors occurred during the operation,
486 * @error will be set to contain the errors and %FALSE will be returned.
488 * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise.
490 * Deprecated: 2.22: Use g_mount_eject_with_operation_finish() instead.
493 g_mount_eject_finish (GMount *mount,
494 GAsyncResult *result,
499 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
500 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
502 if (g_async_result_legacy_propagate_error (result, error))
505 iface = G_MOUNT_GET_IFACE (mount);
506 return (* iface->eject_finish) (mount, result, error);
510 * g_mount_unmount_with_operation:
512 * @flags: flags affecting the operation
513 * @mount_operation: (allow-none): a #GMountOperation or %NULL to avoid
515 * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
516 * @callback: (allow-none): a #GAsyncReadyCallback, or %NULL.
517 * @user_data: user data passed to @callback.
519 * Unmounts a mount. This is an asynchronous operation, and is
520 * finished by calling g_mount_unmount_with_operation_finish() with the @mount
521 * and #GAsyncResult data returned in the @callback.
526 g_mount_unmount_with_operation (GMount *mount,
527 GMountUnmountFlags flags,
528 GMountOperation *mount_operation,
529 GCancellable *cancellable,
530 GAsyncReadyCallback callback,
535 g_return_if_fail (G_IS_MOUNT (mount));
537 iface = G_MOUNT_GET_IFACE (mount);
539 if (iface->unmount == NULL && iface->unmount_with_operation == NULL)
541 g_simple_async_report_error_in_idle (G_OBJECT (mount),
543 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
544 /* Translators: This is an error
545 * message for mount objects that
546 * don't implement any of unmount or unmount_with_operation. */
547 _("mount doesn't implement \"unmount\" or \"unmount_with_operation\""));
552 if (iface->unmount_with_operation != NULL)
553 (* iface->unmount_with_operation) (mount, flags, mount_operation, cancellable, callback, user_data);
555 (* iface->unmount) (mount, flags, cancellable, callback, user_data);
559 * g_mount_unmount_with_operation_finish:
561 * @result: a #GAsyncResult.
562 * @error: a #GError location to store the error occurring, or %NULL to
565 * Finishes unmounting a mount. If any errors occurred during the operation,
566 * @error will be set to contain the errors and %FALSE will be returned.
568 * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise.
573 g_mount_unmount_with_operation_finish (GMount *mount,
574 GAsyncResult *result,
579 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
580 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
582 if (g_async_result_legacy_propagate_error (result, error))
585 iface = G_MOUNT_GET_IFACE (mount);
586 if (iface->unmount_with_operation_finish != NULL)
587 return (* iface->unmount_with_operation_finish) (mount, result, error);
589 return (* iface->unmount_finish) (mount, result, error);
594 * g_mount_eject_with_operation:
596 * @flags: flags affecting the unmount if required for eject
597 * @mount_operation: (allow-none): a #GMountOperation or %NULL to avoid
599 * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
600 * @callback: (allow-none): a #GAsyncReadyCallback, or %NULL.
601 * @user_data: user data passed to @callback.
603 * Ejects a mount. This is an asynchronous operation, and is
604 * finished by calling g_mount_eject_with_operation_finish() with the @mount
605 * and #GAsyncResult data returned in the @callback.
610 g_mount_eject_with_operation (GMount *mount,
611 GMountUnmountFlags flags,
612 GMountOperation *mount_operation,
613 GCancellable *cancellable,
614 GAsyncReadyCallback callback,
619 g_return_if_fail (G_IS_MOUNT (mount));
621 iface = G_MOUNT_GET_IFACE (mount);
623 if (iface->eject == NULL && iface->eject_with_operation == NULL)
625 g_simple_async_report_error_in_idle (G_OBJECT (mount),
627 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
628 /* Translators: This is an error
629 * message for mount objects that
630 * don't implement any of eject or eject_with_operation. */
631 _("mount doesn't implement \"eject\" or \"eject_with_operation\""));
635 if (iface->eject_with_operation != NULL)
636 (* iface->eject_with_operation) (mount, flags, mount_operation, cancellable, callback, user_data);
638 (* iface->eject) (mount, flags, cancellable, callback, user_data);
642 * g_mount_eject_with_operation_finish:
644 * @result: a #GAsyncResult.
645 * @error: a #GError location to store the error occurring, or %NULL to
648 * Finishes ejecting a mount. If any errors occurred during the operation,
649 * @error will be set to contain the errors and %FALSE will be returned.
651 * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise.
656 g_mount_eject_with_operation_finish (GMount *mount,
657 GAsyncResult *result,
662 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
663 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
665 if (g_async_result_legacy_propagate_error (result, error))
668 iface = G_MOUNT_GET_IFACE (mount);
669 if (iface->eject_with_operation_finish != NULL)
670 return (* iface->eject_with_operation_finish) (mount, result, error);
672 return (* iface->eject_finish) (mount, result, error);
678 * @flags: flags affecting the operation
679 * @mount_operation: (allow-none): a #GMountOperation or %NULL to avoid
681 * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore.
682 * @callback: (allow-none): a #GAsyncReadyCallback, or %NULL.
683 * @user_data: user data passed to @callback.
685 * Remounts a mount. This is an asynchronous operation, and is
686 * finished by calling g_mount_remount_finish() with the @mount
687 * and #GAsyncResults data returned in the @callback.
689 * Remounting is useful when some setting affecting the operation
690 * of the volume has been changed, as these may need a remount to
691 * take affect. While this is semantically equivalent with unmounting
692 * and then remounting not all backends might need to actually be
696 g_mount_remount (GMount *mount,
697 GMountMountFlags flags,
698 GMountOperation *mount_operation,
699 GCancellable *cancellable,
700 GAsyncReadyCallback callback,
705 g_return_if_fail (G_IS_MOUNT (mount));
707 iface = G_MOUNT_GET_IFACE (mount);
709 if (iface->remount == NULL)
711 g_simple_async_report_error_in_idle (G_OBJECT (mount),
713 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
714 /* Translators: This is an error
715 * message for mount objects that
716 * don't implement remount. */
717 _("mount doesn't implement \"remount\""));
722 (* iface->remount) (mount, flags, mount_operation, cancellable, callback, user_data);
726 * g_mount_remount_finish:
728 * @result: a #GAsyncResult.
729 * @error: a #GError location to store the error occurring, or %NULL to
732 * Finishes remounting a mount. If any errors occurred during the operation,
733 * @error will be set to contain the errors and %FALSE will be returned.
735 * Returns: %TRUE if the mount was successfully remounted. %FALSE otherwise.
738 g_mount_remount_finish (GMount *mount,
739 GAsyncResult *result,
744 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
745 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
747 if (g_async_result_legacy_propagate_error (result, error))
750 iface = G_MOUNT_GET_IFACE (mount);
751 return (* iface->remount_finish) (mount, result, error);
755 * g_mount_guess_content_type:
757 * @force_rescan: Whether to force a rescan of the content.
758 * Otherwise a cached result will be used if available
759 * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore
760 * @callback: a #GAsyncReadyCallback
761 * @user_data: user data passed to @callback
763 * Tries to guess the type of content stored on @mount. Returns one or
764 * more textual identifiers of well-known content types (typically
765 * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
766 * memory cards. See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink>
767 * specification for more on x-content types.
769 * This is an asynchronous operation (see
770 * g_mount_guess_content_type_sync() for the synchronous version), and
771 * is finished by calling g_mount_guess_content_type_finish() with the
772 * @mount and #GAsyncResult data returned in the @callback.
777 g_mount_guess_content_type (GMount *mount,
778 gboolean force_rescan,
779 GCancellable *cancellable,
780 GAsyncReadyCallback callback,
785 g_return_if_fail (G_IS_MOUNT (mount));
787 iface = G_MOUNT_GET_IFACE (mount);
789 if (iface->guess_content_type == NULL)
791 g_simple_async_report_error_in_idle (G_OBJECT (mount),
793 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
794 /* Translators: This is an error
795 * message for mount objects that
796 * don't implement content type guessing. */
797 _("mount doesn't implement content type guessing"));
802 (* iface->guess_content_type) (mount, force_rescan, cancellable, callback, user_data);
806 * g_mount_guess_content_type_finish:
808 * @result: a #GAsyncResult
809 * @error: a #GError location to store the error occurring, or %NULL to
812 * Finishes guessing content types of @mount. If any errors occurred
813 * during the operation, @error will be set to contain the errors and
814 * %FALSE will be returned. In particular, you may get an
815 * %G_IO_ERROR_NOT_SUPPORTED if the mount does not support content
818 * Returns: (transfer full) (element-type utf8): a %NULL-terminated array of content types or %NULL on error.
819 * Caller should free this array with g_strfreev() when done with it.
824 g_mount_guess_content_type_finish (GMount *mount,
825 GAsyncResult *result,
830 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
831 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
833 if (g_async_result_legacy_propagate_error (result, error))
836 iface = G_MOUNT_GET_IFACE (mount);
837 return (* iface->guess_content_type_finish) (mount, result, error);
841 * g_mount_guess_content_type_sync:
843 * @force_rescan: Whether to force a rescan of the content.
844 * Otherwise a cached result will be used if available
845 * @cancellable: (allow-none): optional #GCancellable object, %NULL to ignore
846 * @error: a #GError location to store the error occurring, or %NULL to
849 * Tries to guess the type of content stored on @mount. Returns one or
850 * more textual identifiers of well-known content types (typically
851 * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
852 * memory cards. See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink>
853 * specification for more on x-content types.
855 * This is an synchronous operation and as such may block doing IO;
856 * see g_mount_guess_content_type() for the asynchronous version.
858 * Returns: (transfer full) (element-type utf8): a %NULL-terminated array of content types or %NULL on error.
859 * Caller should free this array with g_strfreev() when done with it.
864 g_mount_guess_content_type_sync (GMount *mount,
865 gboolean force_rescan,
866 GCancellable *cancellable,
871 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
873 iface = G_MOUNT_GET_IFACE (mount);
875 if (iface->guess_content_type_sync == NULL)
877 g_set_error_literal (error,
878 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
879 /* Translators: This is an error
880 * message for mount objects that
881 * don't implement content type guessing. */
882 _("mount doesn't implement synchronous content type guessing"));
887 return (* iface->guess_content_type_sync) (mount, force_rescan, cancellable, error);
890 G_LOCK_DEFINE_STATIC (priv_lock);
892 /* only access this structure when holding priv_lock */
895 gint shadow_ref_count;
899 free_private (GMountPrivate *private)
903 G_UNLOCK (priv_lock);
906 /* may only be called when holding priv_lock */
907 static GMountPrivate *
908 get_private (GMount *mount)
910 GMountPrivate *private;
912 private = g_object_get_data (G_OBJECT (mount), "g-mount-private");
913 if (G_LIKELY (private != NULL))
916 private = g_new0 (GMountPrivate, 1);
917 g_object_set_data_full (G_OBJECT (mount),
920 (GDestroyNotify) free_private);
927 * g_mount_is_shadowed:
930 * Determines if @mount is shadowed. Applications or libraries should
931 * avoid displaying @mount in the user interface if it is shadowed.
933 * A mount is said to be shadowed if there exists one or more user
934 * visible objects (currently #GMount objects) with a root that is
935 * inside the root of @mount.
937 * One application of shadow mounts is when exposing a single file
938 * system that is used to address several logical volumes. In this
939 * situation, a #GVolumeMonitor implementation would create two
940 * #GVolume objects (for example, one for the camera functionality of
941 * the device and one for a SD card reader on the device) with
942 * activation URIs <literal>gphoto2://[usb:001,002]/store1/</literal>
943 * and <literal>gphoto2://[usb:001,002]/store2/</literal>. When the
944 * underlying mount (with root
945 * <literal>gphoto2://[usb:001,002]/</literal>) is mounted, said
946 * #GVolumeMonitor implementation would create two #GMount objects
947 * (each with their root matching the corresponding volume activation
948 * root) that would shadow the original mount.
950 * The proxy monitor in GVfs 2.26 and later, automatically creates and
951 * manage shadow mounts (and shadows the underlying mount) if the
952 * activation root on a #GVolume is set.
954 * Returns: %TRUE if @mount is shadowed.
959 g_mount_is_shadowed (GMount *mount)
964 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
967 priv = get_private (mount);
968 ret = (priv->shadow_ref_count > 0);
969 G_UNLOCK (priv_lock);
978 * Increments the shadow count on @mount. Usually used by
979 * #GVolumeMonitor implementations when creating a shadow mount for
980 * @mount, see g_mount_is_shadowed() for more information. The caller
981 * will need to emit the #GMount::changed signal on @mount manually.
986 g_mount_shadow (GMount *mount)
990 g_return_if_fail (G_IS_MOUNT (mount));
993 priv = get_private (mount);
994 priv->shadow_ref_count += 1;
995 G_UNLOCK (priv_lock);
1000 * @mount: A #GMount.
1002 * Decrements the shadow count on @mount. Usually used by
1003 * #GVolumeMonitor implementations when destroying a shadow mount for
1004 * @mount, see g_mount_is_shadowed() for more information. The caller
1005 * will need to emit the #GMount::changed signal on @mount manually.
1010 g_mount_unshadow (GMount *mount)
1012 GMountPrivate *priv;
1014 g_return_if_fail (G_IS_MOUNT (mount));
1017 priv = get_private (mount);
1018 priv->shadow_ref_count -= 1;
1019 if (priv->shadow_ref_count < 0)
1020 g_warning ("Shadow ref count on GMount is negative");
1021 G_UNLOCK (priv_lock);
1025 * g_mount_get_sort_key:
1026 * @mount: A #GMount.
1028 * Gets the sort key for @mount, if any.
1030 * Returns: Sorting key for @mount or %NULL if no such key is available.
1035 g_mount_get_sort_key (GMount *mount)
1037 const gchar *ret = NULL;
1040 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
1042 iface = G_MOUNT_GET_IFACE (mount);
1043 if (iface->get_sort_key != NULL)
1044 ret = iface->get_sort_key (mount);