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"
40 * @short_description: Mount management
42 * @see also: GVolume, GUnixMount
44 * The #GMount interface represents user-visible mounts. Note, when
45 * porting from GnomeVFS, #GMount is the moral equivalent of #GnomeVFSVolume.
47 * #GMount is a "mounted" filesystem that you can access. Mounted is in
48 * quotes because it's not the same as a unix mount, it might be a gvfs
49 * mount, but you can still access the files on it if you use GIO. Might or
50 * might not be related to a volume object.
52 * Unmounting a #GMount instance is an asynchronous operation. For
53 * more information about asynchronous operations, see #GAsyncReady
54 * and #GSimpleAsyncReady. To unmount a #GMount instance, first call
55 * g_mount_unmount_with_operation() with (at least) the #GMount instance and a
56 * #GAsyncReadyCallback. The callback will be fired when the
57 * operation has resolved (either with success or failure), and a
58 * #GAsyncReady structure will be passed to the callback. That
59 * callback should then call g_mount_unmount_with_operation_finish() with the #GMount
60 * and the #GAsyncReady data to see if the operation was completed
61 * successfully. If an @error is present when g_mount_unmount_with_operation_finish()
62 * is called, then it will be filled with any error information.
65 typedef GMountIface GMountInterface;
66 G_DEFINE_INTERFACE (GMount, g_mount, G_TYPE_OBJECT)
69 g_mount_default_init (GMountInterface *iface)
73 * @mount: the object on which the signal is emitted
75 * Emitted when the mount has been changed.
77 g_signal_new (I_("changed"),
80 G_STRUCT_OFFSET (GMountIface, changed),
82 g_cclosure_marshal_VOID__VOID,
87 * @mount: the object on which the signal is emitted
89 * This signal is emitted when the #GMount have been
90 * unmounted. If the recipient is holding references to the
91 * object they should release them so the object can be
94 g_signal_new (I_("unmounted"),
97 G_STRUCT_OFFSET (GMountIface, unmounted),
99 g_cclosure_marshal_VOID__VOID,
102 * GMount::pre-unmount:
103 * @mount: the object on which the signal is emitted
105 * This signal is emitted when the #GMount is about to be
110 g_signal_new (I_("pre-unmount"),
113 G_STRUCT_OFFSET (GMountIface, pre_unmount),
115 g_cclosure_marshal_VOID__VOID,
123 * Gets the root directory on @mount.
126 * The returned object should be unreffed with
127 * g_object_unref() when no longer needed.
130 g_mount_get_root (GMount *mount)
134 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
136 iface = G_MOUNT_GET_IFACE (mount);
138 return (* iface->get_root) (mount);
142 * g_mount_get_default_location:
145 * Gets the default location of @mount. The default location of the given
146 * @mount is a path that reflects the main entry point for the user (e.g.
147 * the home directory, or the root of the volume).
150 * The returned object should be unreffed with
151 * g_object_unref() when no longer needed.
154 g_mount_get_default_location (GMount *mount)
159 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
161 iface = G_MOUNT_GET_IFACE (mount);
163 /* Fallback to get_root when default_location () is not available */
164 if (iface->get_default_location)
165 file = (* iface->get_default_location) (mount);
167 file = (* iface->get_root) (mount);
176 * Gets the name of @mount.
178 * Returns: the name for the given @mount.
179 * The returned string should be freed with g_free()
180 * when no longer needed.
183 g_mount_get_name (GMount *mount)
187 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
189 iface = G_MOUNT_GET_IFACE (mount);
191 return (* iface->get_name) (mount);
198 * Gets the icon for @mount.
201 * The returned object should be unreffed with
202 * g_object_unref() when no longer needed.
205 g_mount_get_icon (GMount *mount)
209 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
211 iface = G_MOUNT_GET_IFACE (mount);
213 return (* iface->get_icon) (mount);
220 * Gets the UUID for the @mount. The reference is typically based on
221 * the file system UUID for the mount in question and should be
222 * considered an opaque string. Returns %NULL if there is no UUID
225 * Returns: the UUID for @mount or %NULL if no UUID can be computed.
226 * The returned string should be freed with g_free()
227 * when no longer needed.
230 g_mount_get_uuid (GMount *mount)
234 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
236 iface = G_MOUNT_GET_IFACE (mount);
238 return (* iface->get_uuid) (mount);
242 * g_mount_get_volume:
245 * Gets the volume for the @mount.
247 * Returns: a #GVolume or %NULL if @mount is not associated with a volume.
248 * The returned object should be unreffed with
249 * g_object_unref() when no longer needed.
252 g_mount_get_volume (GMount *mount)
256 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
258 iface = G_MOUNT_GET_IFACE (mount);
260 return (* iface->get_volume) (mount);
267 * Gets the drive for the @mount.
269 * This is a convenience method for getting the #GVolume and then
270 * using that object to get the #GDrive.
272 * Returns: a #GDrive or %NULL if @mount is not associated with a volume or a drive.
273 * The returned object should be unreffed with
274 * g_object_unref() when no longer needed.
277 g_mount_get_drive (GMount *mount)
281 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
283 iface = G_MOUNT_GET_IFACE (mount);
285 return (* iface->get_drive) (mount);
289 * g_mount_can_unmount:
292 * Checks if @mount can be mounted.
294 * Returns: %TRUE if the @mount can be unmounted.
297 g_mount_can_unmount (GMount *mount)
301 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
303 iface = G_MOUNT_GET_IFACE (mount);
305 return (* iface->can_unmount) (mount);
312 * Checks if @mount can be eject.
314 * Returns: %TRUE if the @mount can be ejected.
317 g_mount_can_eject (GMount *mount)
321 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
323 iface = G_MOUNT_GET_IFACE (mount);
325 return (* iface->can_eject) (mount);
331 * @flags: flags affecting the operation
332 * @cancellable: optional #GCancellable object, %NULL to ignore.
333 * @callback: a #GAsyncReadyCallback, or %NULL.
334 * @user_data: user data passed to @callback.
336 * Unmounts a mount. This is an asynchronous operation, and is
337 * finished by calling g_mount_unmount_finish() with the @mount
338 * and #GAsyncResult data returned in the @callback.
340 * Deprecated: 2.22: Use g_mount_unmount_with_operation() instead.
343 g_mount_unmount (GMount *mount,
344 GMountUnmountFlags flags,
345 GCancellable *cancellable,
346 GAsyncReadyCallback callback,
351 g_return_if_fail (G_IS_MOUNT (mount));
353 iface = G_MOUNT_GET_IFACE (mount);
355 if (iface->unmount == NULL)
357 g_simple_async_report_error_in_idle (G_OBJECT (mount),
359 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
360 /* Translators: This is an error
361 * message for mount objects that
362 * don't implement unmount. */
363 _("mount doesn't implement \"unmount\""));
368 (* iface->unmount) (mount, flags, cancellable, callback, user_data);
372 * g_mount_unmount_finish:
374 * @result: a #GAsyncResult.
375 * @error: a #GError location to store the error occuring, or %NULL to
378 * Finishes unmounting a mount. If any errors occurred during the operation,
379 * @error will be set to contain the errors and %FALSE will be returned.
381 * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise.
383 * Deprecated: 2.22: Use g_mount_unmount_with_operation_finish() instead.
386 g_mount_unmount_finish (GMount *mount,
387 GAsyncResult *result,
392 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
393 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
395 if (G_IS_SIMPLE_ASYNC_RESULT (result))
397 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
398 if (g_simple_async_result_propagate_error (simple, error))
402 iface = G_MOUNT_GET_IFACE (mount);
403 return (* iface->unmount_finish) (mount, result, error);
410 * @flags: flags affecting the unmount if required for eject
411 * @cancellable: optional #GCancellable object, %NULL to ignore.
412 * @callback: a #GAsyncReadyCallback, or %NULL.
413 * @user_data: user data passed to @callback.
415 * Ejects a mount. This is an asynchronous operation, and is
416 * finished by calling g_mount_eject_finish() with the @mount
417 * and #GAsyncResult data returned in the @callback.
419 * Deprecated: 2.22: Use g_mount_eject_with_operation() instead.
422 g_mount_eject (GMount *mount,
423 GMountUnmountFlags flags,
424 GCancellable *cancellable,
425 GAsyncReadyCallback callback,
430 g_return_if_fail (G_IS_MOUNT (mount));
432 iface = G_MOUNT_GET_IFACE (mount);
434 if (iface->eject == NULL)
436 g_simple_async_report_error_in_idle (G_OBJECT (mount),
438 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
439 /* Translators: This is an error
440 * message for mount objects that
441 * don't implement eject. */
442 _("mount doesn't implement \"eject\""));
447 (* iface->eject) (mount, flags, cancellable, callback, user_data);
451 * g_mount_eject_finish:
453 * @result: a #GAsyncResult.
454 * @error: a #GError location to store the error occuring, or %NULL to
457 * Finishes ejecting a mount. If any errors occurred during the operation,
458 * @error will be set to contain the errors and %FALSE will be returned.
460 * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise.
462 * Deprecated: 2.22: Use g_mount_eject_with_operation_finish() instead.
465 g_mount_eject_finish (GMount *mount,
466 GAsyncResult *result,
471 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
472 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
474 if (G_IS_SIMPLE_ASYNC_RESULT (result))
476 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
477 if (g_simple_async_result_propagate_error (simple, error))
481 iface = G_MOUNT_GET_IFACE (mount);
482 return (* iface->eject_finish) (mount, result, error);
486 * g_mount_unmount_with_operation:
488 * @flags: flags affecting the operation
489 * @mount_operation: a #GMountOperation or %NULL to avoid user interaction.
490 * @cancellable: optional #GCancellable object, %NULL to ignore.
491 * @callback: a #GAsyncReadyCallback, or %NULL.
492 * @user_data: user data passed to @callback.
494 * Unmounts a mount. This is an asynchronous operation, and is
495 * finished by calling g_mount_unmount_with_operation_finish() with the @mount
496 * and #GAsyncResult data returned in the @callback.
501 g_mount_unmount_with_operation (GMount *mount,
502 GMountUnmountFlags flags,
503 GMountOperation *mount_operation,
504 GCancellable *cancellable,
505 GAsyncReadyCallback callback,
510 g_return_if_fail (G_IS_MOUNT (mount));
512 iface = G_MOUNT_GET_IFACE (mount);
514 if (iface->unmount == NULL && iface->unmount_with_operation == NULL)
516 g_simple_async_report_error_in_idle (G_OBJECT (mount),
518 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
519 /* Translators: This is an error
520 * message for mount objects that
521 * don't implement any of unmount or unmount_with_operation. */
522 _("mount doesn't implement \"unmount\" or \"unmount_with_operation\""));
527 if (iface->unmount_with_operation != NULL)
528 (* iface->unmount_with_operation) (mount, flags, mount_operation, cancellable, callback, user_data);
530 (* iface->unmount) (mount, flags, cancellable, callback, user_data);
534 * g_mount_unmount_with_operation_finish:
536 * @result: a #GAsyncResult.
537 * @error: a #GError location to store the error occuring, or %NULL to
540 * Finishes unmounting a mount. If any errors occurred during the operation,
541 * @error will be set to contain the errors and %FALSE will be returned.
543 * Returns: %TRUE if the mount was successfully unmounted. %FALSE otherwise.
548 g_mount_unmount_with_operation_finish (GMount *mount,
549 GAsyncResult *result,
554 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
555 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
557 if (G_IS_SIMPLE_ASYNC_RESULT (result))
559 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
560 if (g_simple_async_result_propagate_error (simple, error))
564 iface = G_MOUNT_GET_IFACE (mount);
565 if (iface->unmount_with_operation_finish != NULL)
566 return (* iface->unmount_with_operation_finish) (mount, result, error);
568 return (* iface->unmount_finish) (mount, result, error);
573 * g_mount_eject_with_operation:
575 * @flags: flags affecting the unmount if required for eject
576 * @mount_operation: a #GMountOperation or %NULL to avoid user interaction.
577 * @cancellable: optional #GCancellable object, %NULL to ignore.
578 * @callback: a #GAsyncReadyCallback, or %NULL.
579 * @user_data: user data passed to @callback.
581 * Ejects a mount. This is an asynchronous operation, and is
582 * finished by calling g_mount_eject_with_operation_finish() with the @mount
583 * and #GAsyncResult data returned in the @callback.
588 g_mount_eject_with_operation (GMount *mount,
589 GMountUnmountFlags flags,
590 GMountOperation *mount_operation,
591 GCancellable *cancellable,
592 GAsyncReadyCallback callback,
597 g_return_if_fail (G_IS_MOUNT (mount));
599 iface = G_MOUNT_GET_IFACE (mount);
601 if (iface->eject == NULL && iface->eject_with_operation == NULL)
603 g_simple_async_report_error_in_idle (G_OBJECT (mount),
605 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
606 /* Translators: This is an error
607 * message for mount objects that
608 * don't implement any of eject or eject_with_operation. */
609 _("mount doesn't implement \"eject\" or \"eject_with_operation\""));
613 if (iface->eject_with_operation != NULL)
614 (* iface->eject_with_operation) (mount, flags, mount_operation, cancellable, callback, user_data);
616 (* iface->eject) (mount, flags, cancellable, callback, user_data);
620 * g_mount_eject_with_operation_finish:
622 * @result: a #GAsyncResult.
623 * @error: a #GError location to store the error occuring, or %NULL to
626 * Finishes ejecting a mount. If any errors occurred during the operation,
627 * @error will be set to contain the errors and %FALSE will be returned.
629 * Returns: %TRUE if the mount was successfully ejected. %FALSE otherwise.
634 g_mount_eject_with_operation_finish (GMount *mount,
635 GAsyncResult *result,
640 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
641 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
643 if (G_IS_SIMPLE_ASYNC_RESULT (result))
645 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
646 if (g_simple_async_result_propagate_error (simple, error))
650 iface = G_MOUNT_GET_IFACE (mount);
651 if (iface->eject_with_operation_finish != NULL)
652 return (* iface->eject_with_operation_finish) (mount, result, error);
654 return (* iface->eject_finish) (mount, result, error);
660 * @flags: flags affecting the operation
661 * @mount_operation: a #GMountOperation or %NULL to avoid user interaction.
662 * @cancellable: optional #GCancellable object, %NULL to ignore.
663 * @callback: a #GAsyncReadyCallback, or %NULL.
664 * @user_data: user data passed to @callback.
666 * Remounts a mount. This is an asynchronous operation, and is
667 * finished by calling g_mount_remount_finish() with the @mount
668 * and #GAsyncResults data returned in the @callback.
670 * Remounting is useful when some setting affecting the operation
671 * of the volume has been changed, as these may need a remount to
672 * take affect. While this is semantically equivalent with unmounting
673 * and then remounting not all backends might need to actually be
677 g_mount_remount (GMount *mount,
678 GMountMountFlags flags,
679 GMountOperation *mount_operation,
680 GCancellable *cancellable,
681 GAsyncReadyCallback callback,
686 g_return_if_fail (G_IS_MOUNT (mount));
688 iface = G_MOUNT_GET_IFACE (mount);
690 if (iface->remount == NULL)
692 g_simple_async_report_error_in_idle (G_OBJECT (mount),
694 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
695 /* Translators: This is an error
696 * message for mount objects that
697 * don't implement remount. */
698 _("mount doesn't implement \"remount\""));
703 (* iface->remount) (mount, flags, mount_operation, cancellable, callback, user_data);
707 * g_mount_remount_finish:
709 * @result: a #GAsyncResult.
710 * @error: a #GError location to store the error occuring, or %NULL to
713 * Finishes remounting a mount. If any errors occurred during the operation,
714 * @error will be set to contain the errors and %FALSE will be returned.
716 * Returns: %TRUE if the mount was successfully remounted. %FALSE otherwise.
719 g_mount_remount_finish (GMount *mount,
720 GAsyncResult *result,
725 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
726 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE);
728 if (G_IS_SIMPLE_ASYNC_RESULT (result))
730 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
731 if (g_simple_async_result_propagate_error (simple, error))
735 iface = G_MOUNT_GET_IFACE (mount);
736 return (* iface->remount_finish) (mount, result, error);
740 * g_mount_guess_content_type:
742 * @force_rescan: Whether to force a rescan of the content.
743 * Otherwise a cached result will be used if available
744 * @cancellable: optional #GCancellable object, %NULL to ignore
745 * @callback: a #GAsyncReadyCallback
746 * @user_data: user data passed to @callback
748 * Tries to guess the type of content stored on @mount. Returns one or
749 * more textual identifiers of well-known content types (typically
750 * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
751 * memory cards. See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink>
752 * specification for more on x-content types.
754 * This is an asynchronous operation (see
755 * g_mount_guess_content_type_sync() for the synchronous version), and
756 * is finished by calling g_mount_guess_content_type_finish() with the
757 * @mount and #GAsyncResult data returned in the @callback.
762 g_mount_guess_content_type (GMount *mount,
763 gboolean force_rescan,
764 GCancellable *cancellable,
765 GAsyncReadyCallback callback,
770 g_return_if_fail (G_IS_MOUNT (mount));
772 iface = G_MOUNT_GET_IFACE (mount);
774 if (iface->guess_content_type == NULL)
776 g_simple_async_report_error_in_idle (G_OBJECT (mount),
778 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
779 /* Translators: This is an error
780 * message for mount objects that
781 * don't implement content type guessing. */
782 _("mount doesn't implement content type guessing"));
787 (* iface->guess_content_type) (mount, force_rescan, cancellable, callback, user_data);
791 * g_mount_guess_content_type_finish:
793 * @result: a #GAsyncResult
794 * @error: a #GError location to store the error occuring, or %NULL to
797 * Finishes guessing content types of @mount. If any errors occured
798 * during the operation, @error will be set to contain the errors and
799 * %FALSE will be returned. In particular, you may get an
800 * %G_IO_ERROR_NOT_SUPPORTED if the mount does not support content
803 * Returns: a %NULL-terminated array of content types or %NULL on error.
804 * Caller should free this array with g_strfreev() when done with it.
809 g_mount_guess_content_type_finish (GMount *mount,
810 GAsyncResult *result,
815 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
816 g_return_val_if_fail (G_IS_ASYNC_RESULT (result), NULL);
818 if (G_IS_SIMPLE_ASYNC_RESULT (result))
820 GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result);
821 if (g_simple_async_result_propagate_error (simple, error))
825 iface = G_MOUNT_GET_IFACE (mount);
826 return (* iface->guess_content_type_finish) (mount, result, error);
830 * g_mount_guess_content_type_sync:
832 * @force_rescan: Whether to force a rescan of the content.
833 * Otherwise a cached result will be used if available
834 * @cancellable: optional #GCancellable object, %NULL to ignore
835 * @error: a #GError location to store the error occuring, or %NULL to
838 * Tries to guess the type of content stored on @mount. Returns one or
839 * more textual identifiers of well-known content types (typically
840 * prefixed with "x-content/"), e.g. x-content/image-dcf for camera
841 * memory cards. See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink>
842 * specification for more on x-content types.
844 * This is an synchronous operation and as such may block doing IO;
845 * see g_mount_guess_content_type() for the asynchronous version.
847 * Returns: a %NULL-terminated array of content types or %NULL on error.
848 * Caller should free this array with g_strfreev() when done with it.
853 g_mount_guess_content_type_sync (GMount *mount,
854 gboolean force_rescan,
855 GCancellable *cancellable,
860 g_return_val_if_fail (G_IS_MOUNT (mount), NULL);
862 iface = G_MOUNT_GET_IFACE (mount);
864 if (iface->guess_content_type_sync == NULL)
866 g_set_error_literal (error,
867 G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
868 /* Translators: This is an error
869 * message for mount objects that
870 * don't implement content type guessing. */
871 _("mount doesn't implement synchronous content type guessing"));
876 return (* iface->guess_content_type_sync) (mount, force_rescan, cancellable, error);
879 G_LOCK_DEFINE_STATIC (priv_lock);
881 /* only access this structure when holding priv_lock */
884 gint shadow_ref_count;
888 free_private (GMountPrivate *private)
892 G_UNLOCK (priv_lock);
895 /* may only be called when holding priv_lock */
896 static GMountPrivate *
897 get_private (GMount *mount)
899 GMountPrivate *private;
901 private = g_object_get_data (G_OBJECT (mount), "g-mount-private");
902 if (G_LIKELY (private != NULL))
905 private = g_new0 (GMountPrivate, 1);
906 g_object_set_data_full (G_OBJECT (mount),
909 (GDestroyNotify) free_private);
916 * g_mount_is_shadowed:
919 * Determines if @mount is shadowed. Applications or libraries should
920 * avoid displaying @mount in the user interface if it is shadowed.
922 * A mount is said to be shadowed if there exists one or more user
923 * visible objects (currently #GMount objects) with a root that is
924 * inside the root of @mount.
926 * One application of shadow mounts is when exposing a single file
927 * system that is used to address several logical volumes. In this
928 * situation, a #GVolumeMonitor implementation would create two
929 * #GVolume objects (for example, one for the camera functionality of
930 * the device and one for a SD card reader on the device) with
931 * activation URIs <literal>gphoto2://[usb:001,002]/store1/</literal>
932 * and <literal>gphoto2://[usb:001,002]/store2/</literal>. When the
933 * underlying mount (with root
934 * <literal>gphoto2://[usb:001,002]/</literal>) is mounted, said
935 * #GVolumeMonitor implementation would create two #GMount objects
936 * (each with their root matching the corresponding volume activation
937 * root) that would shadow the original mount.
939 * The proxy monitor in GVfs 2.26 and later, automatically creates and
940 * manage shadow mounts (and shadows the underlying mount) if the
941 * activation root on a #GVolume is set.
943 * Returns: %TRUE if @mount is shadowed.
948 g_mount_is_shadowed (GMount *mount)
953 g_return_val_if_fail (G_IS_MOUNT (mount), FALSE);
956 priv = get_private (mount);
957 ret = (priv->shadow_ref_count > 0);
958 G_UNLOCK (priv_lock);
967 * Increments the shadow count on @mount. Usually used by
968 * #GVolumeMonitor implementations when creating a shadow mount for
969 * @mount, see g_mount_is_shadowed() for more information. The caller
970 * will need to emit the #GMount::changed signal on @mount manually.
975 g_mount_shadow (GMount *mount)
979 g_return_if_fail (G_IS_MOUNT (mount));
982 priv = get_private (mount);
983 priv->shadow_ref_count += 1;
984 G_UNLOCK (priv_lock);
991 * Decrements the shadow count on @mount. Usually used by
992 * #GVolumeMonitor implementations when destroying a shadow mount for
993 * @mount, see g_mount_is_shadowed() for more information. The caller
994 * will need to emit the #GMount::changed signal on @mount manually.
999 g_mount_unshadow (GMount *mount)
1001 GMountPrivate *priv;
1003 g_return_if_fail (G_IS_MOUNT (mount));
1006 priv = get_private (mount);
1007 priv->shadow_ref_count -= 1;
1008 if (priv->shadow_ref_count < 0)
1009 g_warning ("Shadow ref count on GMount is negative");
1010 G_UNLOCK (priv_lock);