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 "gasyncresult.h"
33 #include "gsimpleasyncresult.h"
41 * @short_description: Mount management
43 * @see also: GVolume, GUnixMount
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 #GAsyncReady
55 * and #GSimpleAsyncReady. 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 static void g_mount_base_init (gpointer g_class);
67 static void g_mount_class_init (gpointer g_class,
71 g_mount_get_type (void)
73 static volatile gsize g_define_type_id__volatile = 0;
75 if (g_once_init_enter (&g_define_type_id__volatile))
77 const GTypeInfo mount_info =
79 sizeof (GMountIface), /* class_size */
80 g_mount_base_init, /* base_init */
81 NULL, /* base_finalize */
83 NULL, /* class_finalize */
84 NULL, /* class_data */
89 GType g_define_type_id =
90 g_type_register_static (G_TYPE_INTERFACE, I_("GMount"),
93 g_type_interface_add_prerequisite (g_define_type_id, G_TYPE_OBJECT);
95 g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
98 return g_define_type_id__volatile;
102 g_mount_class_init (gpointer g_class,
108 g_mount_base_init (gpointer g_class)
110 static gboolean initialized = FALSE;
116 * @mount: the object on which the signal is emitted
118 * Emitted when the mount has been changed.
120 g_signal_new (I_("changed"),
123 G_STRUCT_OFFSET (GMountIface, changed),
125 g_cclosure_marshal_VOID__VOID,
130 * @mount: the object on which the signal is emitted
132 * This signal is emitted when the #GMount have been
133 * unmounted. If the recipient is holding references to the
134 * object they should release them so the object can be
137 g_signal_new (I_("unmounted"),
140 G_STRUCT_OFFSET (GMountIface, unmounted),
142 g_cclosure_marshal_VOID__VOID,
145 * GMount::pre-unmount:
146 * @mount: the object on which the signal is emitted
148 * This signal is emitted when the #GMount is about to be
153 g_signal_new (I_("pre-unmount"),
156 G_STRUCT_OFFSET (GMountIface, pre_unmount),
158 g_cclosure_marshal_VOID__VOID,
169 * Gets the root directory on @mount.
172 * The returned object should be unreffed with
173 * g_object_unref() when no longer needed.
176 g_mount_get_root (GMount *mount)
180 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
182 iface = G_MOUNT_GET_IFACE (mount);
184 return (* iface->get_root) (mount);
191 * Gets the name of @mount.
193 * Returns: the name for the given @mount.
194 * The returned string should be freed with g_free()
195 * when no longer needed.
198 g_mount_get_name (GMount *mount)
202 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
204 iface = G_MOUNT_GET_IFACE (mount);
206 return (* iface->get_name) (mount);
213 * Gets the icon for @mount.
216 * The returned object should be unreffed with
217 * g_object_unref() when no longer needed.
220 g_mount_get_icon (GMount *mount)
224 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
226 iface = G_MOUNT_GET_IFACE (mount);
228 return (* iface->get_icon) (mount);
235 * Gets the UUID for the @mount. The reference is typically based on
236 * the file system UUID for the mount in question and should be
237 * considered an opaque string. Returns %NULL if there is no UUID
240 * Returns: the UUID for @mount or %NULL if no UUID can be computed.
241 * The returned string should be freed with g_free()
242 * when no longer needed.
245 g_mount_get_uuid (GMount *mount)
249 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
251 iface = G_MOUNT_GET_IFACE (mount);
253 return (* iface->get_uuid) (mount);
257 * g_mount_get_volume:
260 * Gets the volume for the @mount.
262 * Returns: a #GVolume or %NULL if @mount is not associated with a volume.
263 * The returned object should be unreffed with
264 * g_object_unref() when no longer needed.
267 g_mount_get_volume (GMount *mount)
271 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
273 iface = G_MOUNT_GET_IFACE (mount);
275 return (* iface->get_volume) (mount);
282 * Gets the drive for the @mount.
284 * This is a convenience method for getting the #GVolume and then
285 * using that object to get the #GDrive.
287 * Returns: a #GDrive or %NULL if @mount is not associated with a volume or a drive.
288 * The returned object should be unreffed with
289 * g_object_unref() when no longer needed.
292 g_mount_get_drive (GMount *mount)
296 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
298 iface = G_MOUNT_GET_IFACE (mount);
300 return (* iface->get_drive) (mount);
304 * g_mount_can_unmount:
307 * Checks if @mount can be mounted.
309 * Returns: %TRUE if the @mount can be unmounted.
312 g_mount_can_unmount (GMount *mount)
316 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
318 iface = G_MOUNT_GET_IFACE (mount);
320 return (* iface->can_unmount) (mount);
327 * Checks if @mount can be eject.
329 * Returns: %TRUE if the @mount can be ejected.
332 g_mount_can_eject (GMount *mount)
336 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
338 iface = G_MOUNT_GET_IFACE (mount);
340 return (* iface->can_eject) (mount);
346 * @flags: flags affecting the operation
347 * @cancellable: optional #GCancellable object, %NULL to ignore.
348 * @callback: a #GAsyncReadyCallback, or %NULL.
349 * @user_data: user data passed to @callback.
351 * Unmounts a mount. This is an asynchronous operation, and is
352 * finished by calling g_mount_unmount_finish() with the @mount
353 * and #GAsyncResult data returned in the @callback.
355 * Deprecated: 2.22: Use g_mount_unmount_with_operation() instead.
358 g_mount_unmount (GMount *mount,
359 GMountUnmountFlags flags,
360 GCancellable *cancellable,
361 GAsyncReadyCallback callback,
366 g_return_if_fail (G_IS_MOUNT (mount));
368 iface = G_MOUNT_GET_IFACE (mount);
370 if (iface->unmount == NULL)
372 g_simple_async_report_error_in_idle (G_OBJECT (mount),
374 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
375 /* Translators: This is an error
376 * message for mount objects that
377 * don't implement unmount. */
378 _("mount doesn't implement unmount"));
383 (* iface->unmount) (mount, flags, cancellable, callback, user_data);
387 * g_mount_unmount_finish:
389 * @result: a #GAsyncResult.
390 * @error: a #GError location to store the error occuring, or %NULL to
393 * Finishes unmounting a mount. If any errors occurred during the operation,
394 * @error will be set to contain the errors and %FALSE will be returned.
396 * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise.
398 * Deprecated: 2.22: Use g_mount_unmount_with_operation_finish() instead.
401 g_mount_unmount_finish (GMount *mount,
402 GAsyncResult *result,
407 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
408 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
410 if (G_IS_SIMPLE_ASYNC_RESULT (result))
412 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
413 if (g_simple_async_result_propagate_error (simple, error))
417 iface = G_MOUNT_GET_IFACE (mount);
418 return (* iface->unmount_finish) (mount, result, error);
425 * @flags: flags affecting the unmount if required for eject
426 * @cancellable: optional #GCancellable object, %NULL to ignore.
427 * @callback: a #GAsyncReadyCallback, or %NULL.
428 * @user_data: user data passed to @callback.
430 * Ejects a mount. This is an asynchronous operation, and is
431 * finished by calling g_mount_eject_finish() with the @mount
432 * and #GAsyncResult data returned in the @callback.
434 * Deprecated: 2.22: Use g_mount_eject_with_operation() instead.
437 g_mount_eject (GMount *mount,
438 GMountUnmountFlags flags,
439 GCancellable *cancellable,
440 GAsyncReadyCallback callback,
445 g_return_if_fail (G_IS_MOUNT (mount));
447 iface = G_MOUNT_GET_IFACE (mount);
449 if (iface->eject == NULL)
451 g_simple_async_report_error_in_idle (G_OBJECT (mount),
453 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
454 /* Translators: This is an error
455 * message for mount objects that
456 * don't implement eject. */
457 _("mount doesn't implement eject"));
462 (* iface->eject) (mount, flags, cancellable, callback, user_data);
466 * g_mount_eject_finish:
468 * @result: a #GAsyncResult.
469 * @error: a #GError location to store the error occuring, or %NULL to
472 * Finishes ejecting a mount. If any errors occurred during the operation,
473 * @error will be set to contain the errors and %FALSE will be returned.
475 * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise.
477 * Deprecated: 2.22: Use g_mount_eject_with_operation_finish() instead.
480 g_mount_eject_finish (GMount *mount,
481 GAsyncResult *result,
486 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
487 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
489 if (G_IS_SIMPLE_ASYNC_RESULT (result))
491 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
492 if (g_simple_async_result_propagate_error (simple, error))
496 iface = G_MOUNT_GET_IFACE (mount);
497 return (* iface->eject_finish) (mount, result, error);
501 * g_mount_unmount_with_operation:
503 * @flags: flags affecting the operation
504 * @mount_operation: a #GMountOperation or %NULL to avoid user interaction.
505 * @cancellable: optional #GCancellable object, %NULL to ignore.
506 * @callback: a #GAsyncReadyCallback, or %NULL.
507 * @user_data: user data passed to @callback.
509 * Unmounts a mount. This is an asynchronous operation, and is
510 * finished by calling g_mount_unmount_with_operation_finish() with the @mount
511 * and #GAsyncResult data returned in the @callback.
516 g_mount_unmount_with_operation (GMount *mount,
517 GMountUnmountFlags flags,
518 GMountOperation *mount_operation,
519 GCancellable *cancellable,
520 GAsyncReadyCallback callback,
525 g_return_if_fail (G_IS_MOUNT (mount));
527 iface = G_MOUNT_GET_IFACE (mount);
529 if (iface->unmount == NULL && iface->unmount_with_operation == NULL)
531 g_simple_async_report_error_in_idle (G_OBJECT (mount),
533 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
534 /* Translators: This is an error
535 * message for mount objects that
536 * don't implement any of unmount or unmount_with_operation. */
537 _("mount doesn't implement unmount or unmount_with_operation"));
542 if (iface->unmount_with_operation != NULL)
543 (* iface->unmount_with_operation) (mount, flags, mount_operation, cancellable, callback, user_data);
545 (* iface->unmount) (mount, flags, cancellable, callback, user_data);
549 * g_mount_unmount_with_operation_finish:
551 * @result: a #GAsyncResult.
552 * @error: a #GError location to store the error occuring, or %NULL to
555 * Finishes unmounting a mount. If any errors occurred during the operation,
556 * @error will be set to contain the errors and %FALSE will be returned.
558 * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise.
563 g_mount_unmount_with_operation_finish (GMount *mount,
564 GAsyncResult *result,
569 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
570 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
572 if (G_IS_SIMPLE_ASYNC_RESULT (result))
574 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
575 if (g_simple_async_result_propagate_error (simple, error))
579 iface = G_MOUNT_GET_IFACE (mount);
580 if (iface->unmount_with_operation_finish != NULL)
581 return (* iface->unmount_with_operation_finish) (mount, result, error);
583 return (* iface->unmount_finish) (mount, result, error);
588 * g_mount_eject_with_operation:
590 * @flags: flags affecting the unmount if required for eject
591 * @mount_operation: a #GMountOperation or %NULL to avoid user interaction.
592 * @cancellable: optional #GCancellable object, %NULL to ignore.
593 * @callback: a #GAsyncReadyCallback, or %NULL.
594 * @user_data: user data passed to @callback.
596 * Ejects a mount. This is an asynchronous operation, and is
597 * finished by calling g_mount_eject_with_operation_finish() with the @mount
598 * and #GAsyncResult data returned in the @callback.
603 g_mount_eject_with_operation (GMount *mount,
604 GMountUnmountFlags flags,
605 GMountOperation *mount_operation,
606 GCancellable *cancellable,
607 GAsyncReadyCallback callback,
612 g_return_if_fail (G_IS_MOUNT (mount));
614 iface = G_MOUNT_GET_IFACE (mount);
616 if (iface->eject == NULL && iface->eject_with_operation == NULL)
618 g_simple_async_report_error_in_idle (G_OBJECT (mount),
620 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
621 /* Translators: This is an error
622 * message for mount objects that
623 * don't implement any of eject or eject_with_operation. */
624 _("mount doesn't implement eject or eject_with_operation"));
628 if (iface->eject_with_operation != NULL)
629 (* iface->eject_with_operation) (mount, flags, mount_operation, cancellable, callback, user_data);
631 (* iface->eject) (mount, flags, cancellable, callback, user_data);
635 * g_mount_eject_with_operation_finish:
637 * @result: a #GAsyncResult.
638 * @error: a #GError location to store the error occuring, or %NULL to
641 * Finishes ejecting a mount. If any errors occurred during the operation,
642 * @error will be set to contain the errors and %FALSE will be returned.
644 * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise.
649 g_mount_eject_with_operation_finish (GMount *mount,
650 GAsyncResult *result,
655 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
656 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
658 if (G_IS_SIMPLE_ASYNC_RESULT (result))
660 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
661 if (g_simple_async_result_propagate_error (simple, error))
665 iface = G_MOUNT_GET_IFACE (mount);
666 if (iface->eject_with_operation_finish != NULL)
667 return (* iface->eject_with_operation_finish) (mount, result, error);
669 return (* iface->eject_finish) (mount, result, error);
675 * @flags: flags affecting the operation
676 * @mount_operation: a #GMountOperation or %NULL to avoid user interaction.
677 * @cancellable: optional #GCancellable object, %NULL to ignore.
678 * @callback: a #GAsyncReadyCallback, or %NULL.
679 * @user_data: user data passed to @callback.
681 * Remounts a mount. This is an asynchronous operation, and is
682 * finished by calling g_mount_remount_finish() with the @mount
683 * and #GAsyncResults data returned in the @callback.
685 * Remounting is useful when some setting affecting the operation
686 * of the volume has been changed, as these may need a remount to
687 * take affect. While this is semantically equivalent with unmounting
688 * and then remounting not all backends might need to actually be
692 g_mount_remount (GMount *mount,
693 GMountMountFlags flags,
694 GMountOperation *mount_operation,
695 GCancellable *cancellable,
696 GAsyncReadyCallback callback,
701 g_return_if_fail (G_IS_MOUNT (mount));
703 iface = G_MOUNT_GET_IFACE (mount);
705 if (iface->remount == NULL)
707 g_simple_async_report_error_in_idle (G_OBJECT (mount),
709 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
710 /* Translators: This is an error
711 * message for mount objects that
712 * don't implement remount. */
713 _("mount doesn't implement remount"));
718 (* iface->remount) (mount, flags, mount_operation, cancellable, callback, user_data);
722 * g_mount_remount_finish:
724 * @result: a #GAsyncResult.
725 * @error: a #GError location to store the error occuring, or %NULL to
728 * Finishes remounting a mount. If any errors occurred during the operation,
729 * @error will be set to contain the errors and %FALSE will be returned.
731 * Returns: %TRUE if the mount was successfully remounted. %FALSE otherwise.
734 g_mount_remount_finish (GMount *mount,
735 GAsyncResult *result,
740 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
741 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
743 if (G_IS_SIMPLE_ASYNC_RESULT (result))
745 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
746 if (g_simple_async_result_propagate_error (simple, 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: 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 occuring, or %NULL to
812 * Finishes guessing content types of @mount. If any errors occured
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: 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), FALSE);
831 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
833 if (G_IS_SIMPLE_ASYNC_RESULT (result))
835 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
836 if (g_simple_async_result_propagate_error (simple, error))
840 iface = G_MOUNT_GET_IFACE (mount);
841 return (* iface->guess_content_type_finish) (mount, result, error);
845 * g_mount_guess_content_type_sync:
847 * @force_rescan: Whether to force a rescan of the content.
848 * Otherwise a cached result will be used if available
849 * @cancellable: optional #GCancellable object, %NULL to ignore
850 * @error: a #GError location to store the error occuring, or %NULL to
853 * Tries to guess the type of content stored on @mount. Returns one or
854 * more textual identifiers of well-known content types (typically
855 * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
856 * memory cards. See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink>
857 * specification for more on x-content types.
859 * This is an synchronous operation and as such may block doing IO;
860 * see g_mount_guess_content_type() for the asynchronous version.
862 * Returns: a %NULL-terminated array of content types or %NULL on error.
863 * Caller should free this array with g_strfreev() when done with it.
868 g_mount_guess_content_type_sync (GMount *mount,
869 gboolean force_rescan,
870 GCancellable *cancellable,
875 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
877 iface = G_MOUNT_GET_IFACE (mount);
879 if (iface->guess_content_type_sync == NULL)
881 g_set_error_literal (error,
882 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
883 /* Translators: This is an error
884 * message for mount objects that
885 * don't implement content type guessing. */
886 _("mount doesn't implement synchronous content type guessing"));
891 return (* iface->guess_content_type_sync) (mount, force_rescan, cancellable, error);
894 G_LOCK_DEFINE_STATIC (priv_lock);
896 /* only access this structure when holding priv_lock */
899 gint shadow_ref_count;
903 free_private (GMountPrivate *private)
907 G_UNLOCK (priv_lock);
910 /* may only be called when holding priv_lock */
911 static GMountPrivate *
912 get_private (GMount *mount)
914 GMountPrivate *private;
916 private = g_object_get_data (G_OBJECT (mount), "g-mount-private");
917 if (G_LIKELY (private != NULL))
920 private = g_new0 (GMountPrivate, 1);
921 g_object_set_data_full (G_OBJECT (mount),
924 (GDestroyNotify) free_private);
931 * g_mount_is_shadowed:
934 * Determines if @mount is shadowed. Applications or libraries should
935 * avoid displaying @mount in the user interface if it is shadowed.
937 * A mount is said to be shadowed if there exists one or more user
938 * visible objects (currently #GMount objects) with a root that is
939 * inside the root of @mount.
941 * One application of shadow mounts is when exposing a single file
942 * system that is used to address several logical volumes. In this
943 * situation, a #GVolumeMonitor implementation would create two
944 * #GVolume objects (for example, one for the camera functionality of
945 * the device and one for a SD card reader on the device) with
946 * activation URIs <literal>gphoto2://[usb:001,002]/store1/</literal>
947 * and <literal>gphoto2://[usb:001,002]/store2/</literal>. When the
948 * underlying mount (with root
949 * <literal>gphoto2://[usb:001,002]/</literal>) is mounted, said
950 * #GVolumeMonitor implementation would create two #GMount objects
951 * (each with their root matching the corresponding volume activation
952 * root) that would shadow the original mount.
954 * The proxy monitor in GVfs 2.26 and later, automatically creates and
955 * manage shadow mounts (and shadows the underlying mount) if the
956 * activation root on a #GVolume is set.
958 * Returns: %TRUE if @mount is shadowed.
963 g_mount_is_shadowed (GMount *mount)
968 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
971 priv = get_private (mount);
972 ret = (priv->shadow_ref_count > 0);
973 G_UNLOCK (priv_lock);
982 * Increments the shadow count on @mount. Usually used by
983 * #GVolumeMonitor implementations when creating a shadow mount for
984 * @mount, see g_mount_is_shadowed() for more information. The caller
985 * will need to emit the #GMount::changed signal on @mount manually.
990 g_mount_shadow (GMount *mount)
994 g_return_if_fail (G_IS_MOUNT (mount));
997 priv = get_private (mount);
998 priv->shadow_ref_count += 1;
999 G_UNLOCK (priv_lock);
1004 * @mount: A #GMount.
1006 * Decrements the shadow count on @mount. Usually used by
1007 * #GVolumeMonitor implementations when destroying a shadow mount for
1008 * @mount, see g_mount_is_shadowed() for more information. The caller
1009 * will need to emit the #GMount::changed signal on @mount manually.
1014 g_mount_unshadow (GMount *mount)
1016 GMountPrivate *priv;
1018 g_return_if_fail (G_IS_MOUNT (mount));
1021 priv = get_private (mount);
1022 priv->shadow_ref_count -= 1;
1023 if (priv->shadow_ref_count < 0)
1024 g_warning ("Shadow ref count on GMount is negative");
1025 G_UNLOCK (priv_lock);
1028 #define __G_MOUNT_C__
1029 #include "gioaliasdef.c"