glib/gio/gunixvolume.c

442 lines
12 KiB
C
Raw Permalink Normal View History

Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* GIO - GLib Input, Output and Streaming Library
*
* Copyright (C) 2006-2007 Red Hat, Inc.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
2014-01-23 12:58:29 +01:00
* Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Alexander Larsson <alexl@redhat.com>
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
* David Zeuthen <davidz@redhat.com>
*/
#include "config.h"
#include <string.h>
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
#include <sys/wait.h>
#include <unistd.h>
#include <glib.h>
#include "gunixvolume.h"
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
#include "gunixmount.h"
#include "gunixmounts.h"
#include "gthemedicon.h"
#include "gvolume.h"
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
#include "gvolumemonitor.h"
#include "gtask.h"
#include "gioerror.h"
#include "glibintl.h"
/* for BUFSIZ */
#include <stdio.h>
struct _GUnixVolume {
GObject parent;
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
GVolumeMonitor *volume_monitor;
GUnixMount *mount; /* owned by volume monitor */
char *device_path;
char *mount_path;
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
gboolean can_eject;
char *identifier;
char *identifier_type;
char *name;
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
GIcon *icon;
GIcon *symbolic_icon;
};
static void g_unix_volume_volume_iface_init (GVolumeIface *iface);
#define g_unix_volume_get_type _g_unix_volume_get_type
G_DEFINE_TYPE_WITH_CODE (GUnixVolume, g_unix_volume, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_VOLUME,
g_unix_volume_volume_iface_init))
static void
g_unix_volume_finalize (GObject *object)
{
GUnixVolume *volume;
volume = G_UNIX_VOLUME (object);
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
if (volume->volume_monitor != NULL)
g_object_unref (volume->volume_monitor);
if (volume->mount)
_g_unix_mount_unset_volume (volume->mount, volume);
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
g_object_unref (volume->icon);
g_object_unref (volume->symbolic_icon);
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
g_free (volume->name);
g_free (volume->mount_path);
g_free (volume->device_path);
g_free (volume->identifier);
g_free (volume->identifier_type);
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
G_OBJECT_CLASS (g_unix_volume_parent_class)->finalize (object);
}
static void
g_unix_volume_class_init (GUnixVolumeClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = g_unix_volume_finalize;
}
static void
g_unix_volume_init (GUnixVolume *unix_volume)
{
}
GUnixVolume *
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
_g_unix_volume_new (GVolumeMonitor *volume_monitor,
GUnixMountPoint *mountpoint)
{
GUnixVolume *volume;
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
if (!(g_unix_mount_point_is_user_mountable (mountpoint) ||
g_str_has_prefix (g_unix_mount_point_get_device_path (mountpoint), "/vol/")) ||
g_unix_mount_point_is_loopback (mountpoint))
return NULL;
volume = g_object_new (G_TYPE_UNIX_VOLUME, NULL);
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
volume->volume_monitor = volume_monitor != NULL ? g_object_ref (volume_monitor) : NULL;
volume->mount_path = g_strdup (g_unix_mount_point_get_mount_path (mountpoint));
volume->device_path = g_strdup (g_unix_mount_point_get_device_path (mountpoint));
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
volume->can_eject = g_unix_mount_point_guess_can_eject (mountpoint);
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
volume->name = g_unix_mount_point_guess_name (mountpoint);
volume->icon = g_unix_mount_point_guess_icon (mountpoint);
volume->symbolic_icon = g_unix_mount_point_guess_symbolic_icon (mountpoint);
if (strcmp (g_unix_mount_point_get_fs_type (mountpoint), "nfs") == 0)
{
volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT);
volume->identifier = g_strdup (volume->device_path);
}
else if (g_str_has_prefix (volume->device_path, "LABEL="))
{
volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_LABEL);
volume->identifier = g_strdup (volume->device_path + 6);
}
else if (g_str_has_prefix (volume->device_path, "UUID="))
{
volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_UUID);
volume->identifier = g_strdup (volume->device_path + 5);
}
else if (g_path_is_absolute (volume->device_path))
{
volume->identifier_type = g_strdup (G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);
volume->identifier = g_strdup (volume->device_path);
}
return volume;
}
void
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
_g_unix_volume_disconnected (GUnixVolume *volume)
{
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
if (volume->mount)
{
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
_g_unix_mount_unset_volume (volume->mount, volume);
volume->mount = NULL;
}
}
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
void
2009-11-30 04:54:16 +01:00
_g_unix_volume_set_mount (GUnixVolume *volume,
GUnixMount *mount)
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
{
if (volume->mount == mount)
return;
if (volume->mount)
_g_unix_mount_unset_volume (volume->mount, volume);
volume->mount = mount;
/* TODO: Emit changed in idle to avoid locking issues */
g_signal_emit_by_name (volume, "changed");
if (volume->volume_monitor != NULL)
g_signal_emit_by_name (volume->volume_monitor, "volume-changed", volume);
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
}
void
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
_g_unix_volume_unset_mount (GUnixVolume *volume,
GUnixMount *mount)
{
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
if (volume->mount == mount)
{
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
volume->mount = NULL;
/* TODO: Emit changed in idle to avoid locking issues */
g_signal_emit_by_name (volume, "changed");
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
if (volume->volume_monitor != NULL)
g_signal_emit_by_name (volume->volume_monitor, "volume-changed", volume);
}
}
static GIcon *
g_unix_volume_get_icon (GVolume *volume)
{
GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
return g_object_ref (unix_volume->icon);
}
static GIcon *
g_unix_volume_get_symbolic_icon (GVolume *volume)
{
GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
return g_object_ref (unix_volume->symbolic_icon);
}
static char *
g_unix_volume_get_name (GVolume *volume)
{
GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
return g_strdup (unix_volume->name);
}
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
static char *
g_unix_volume_get_uuid (GVolume *volume)
{
return NULL;
}
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
static gboolean
g_unix_volume_can_mount (GVolume *volume)
{
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
return TRUE;
}
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
static gboolean
g_unix_volume_can_eject (GVolume *volume)
{
GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
return unix_volume->can_eject;
}
static gboolean
g_unix_volume_should_automount (GVolume *volume)
{
/* We automount all local volumes because we don't even
2009-11-30 04:54:16 +01:00
* make the internal stuff visible
*/
return TRUE;
}
static GDrive *
g_unix_volume_get_drive (GVolume *volume)
{
return NULL;
}
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
static GMount *
g_unix_volume_get_mount (GVolume *volume)
{
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
if (unix_volume->mount != NULL)
return g_object_ref (G_MOUNT (unix_volume->mount));
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
return NULL;
}
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
gboolean
_g_unix_volume_has_mount_path (GUnixVolume *volume,
2009-11-30 04:54:16 +01:00
const char *mount_path)
{
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
return strcmp (volume->mount_path, mount_path) == 0;
}
static void
eject_mount_done (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
GSubprocess *subprocess = G_SUBPROCESS (source);
GTask *task = user_data;
GError *error = NULL;
gchar *stderr_str;
GUnixVolume *unix_volume;
if (!g_subprocess_communicate_utf8_finish (subprocess, result, NULL, &stderr_str, &error))
{
g_task_return_error (task, error);
g_error_free (error);
}
else /* successful communication */
{
if (!g_subprocess_get_successful (subprocess))
/* ...but bad exit code */
g_task_return_new_error_literal (task, G_IO_ERROR, G_IO_ERROR_FAILED, stderr_str);
else
{
/* ...and successful exit code */
unix_volume = G_UNIX_VOLUME (g_task_get_source_object (task));
_g_unix_volume_monitor_update (G_UNIX_VOLUME_MONITOR (unix_volume->volume_monitor));
g_task_return_boolean (task, TRUE);
}
g_free (stderr_str);
}
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
g_object_unref (task);
}
static void
eject_mount_do (GVolume *volume,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data,
const gchar * const *argv,
const gchar *task_name)
{
GSubprocess *subprocess;
GError *error = NULL;
GTask *task;
task = g_task_new (volume, cancellable, callback, user_data);
g_task_set_source_tag (task, eject_mount_do);
g_task_set_name (task, task_name);
if (g_task_return_error_if_cancelled (task))
{
g_object_unref (task);
return;
}
subprocess = g_subprocess_newv (argv, G_SUBPROCESS_FLAGS_STDOUT_SILENCE | G_SUBPROCESS_FLAGS_STDERR_PIPE, &error);
g_assert_no_error (error);
g_subprocess_communicate_utf8_async (subprocess, NULL,
g_task_get_cancellable (task),
eject_mount_done, task);
}
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
static void
2009-11-30 04:54:16 +01:00
g_unix_volume_mount (GVolume *volume,
GMountMountFlags flags,
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
GMountOperation *mount_operation,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
const gchar *argv[] = { "mount", NULL, NULL };
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
if (unix_volume->mount_path != NULL)
argv[1] = unix_volume->mount_path;
else
argv[1] = unix_volume->device_path;
eject_mount_do (volume, cancellable, callback, user_data, argv, "[gio] mount volume");
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
}
static gboolean
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
g_unix_volume_mount_finish (GVolume *volume,
2009-11-30 04:54:16 +01:00
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, volume), FALSE);
return g_task_propagate_boolean (G_TASK (result), error);
}
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
static void
2009-11-30 04:54:16 +01:00
g_unix_volume_eject (GVolume *volume,
GMountUnmountFlags flags,
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
const gchar *argv[] = { "eject", NULL, NULL };
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
argv[1] = unix_volume->device_path;
eject_mount_do (volume, cancellable, callback, user_data, argv, "[gio] eject volume");
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
}
static gboolean
2009-11-30 04:54:16 +01:00
g_unix_volume_eject_finish (GVolume *volume,
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
GAsyncResult *result,
GError **error)
{
g_return_val_if_fail (g_task_is_valid (result, volume), FALSE);
return g_task_propagate_boolean (G_TASK (result), error);
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
}
2009-11-30 04:54:16 +01:00
static gchar *
g_unix_volume_get_identifier (GVolume *volume,
const gchar *kind)
{
GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
if (unix_volume->identifier_type != NULL &&
strcmp (kind, unix_volume->identifier_type) == 0)
return g_strdup (unix_volume->identifier);
2009-11-30 04:54:16 +01:00
return NULL;
}
2009-11-30 04:54:16 +01:00
static gchar **
g_unix_volume_enumerate_identifiers (GVolume *volume)
{
GUnixVolume *unix_volume = G_UNIX_VOLUME (volume);
2009-11-30 04:54:16 +01:00
gchar **res;
if (unix_volume->identifier_type)
{
2009-11-30 04:54:16 +01:00
res = g_new (gchar *, 2);
res[0] = g_strdup (unix_volume->identifier_type);
res[1] = NULL;
}
else
{
2009-11-30 04:54:16 +01:00
res = g_new (gchar *, 1);
res[0] = NULL;
}
return res;
}
static void
g_unix_volume_volume_iface_init (GVolumeIface *iface)
{
iface->get_name = g_unix_volume_get_name;
iface->get_icon = g_unix_volume_get_icon;
iface->get_symbolic_icon = g_unix_volume_get_symbolic_icon;
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
iface->get_uuid = g_unix_volume_get_uuid;
iface->get_drive = g_unix_volume_get_drive;
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
iface->get_mount = g_unix_volume_get_mount;
iface->can_mount = g_unix_volume_can_mount;
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
iface->can_eject = g_unix_volume_can_eject;
iface->should_automount = g_unix_volume_should_automount;
Rework how volumes, drives and volume monitoring is done. Previosly the 2007-12-11 David Zeuthen <davidz@redhat.com> Rework how volumes, drives and volume monitoring is done. Previosly the model was GDrive <1-1> GVolume where a GDrive instance represented a mount point and a GVolume instance represented a mounted file system. This patch changes it the model to GDrive <1-N> GVolume <1-1> GMount where GMount now serves the purpose of the old GVolume and the new GVolume serves the purpose of the old GDrive. In addition the new GDrive interface is used to represent a collection of GVolume instances (typically partitions) and also contains utility to query the state of the physical drive the GDrive object represents (such as checking for media, polling the drive, ejecting the media etc.). Also implement mounting and unmounting in the Unix volume monitor backend. A subquent patch will introduce GDrive support for ejection of media. * Makefile.am: * gdrive.c: (g_drive_is_media_check_automatic), (g_drive_is_media_removable), (g_drive_has_media), (g_drive_can_poll_for_media), (g_drive_eject), (g_drive_eject_finish), (g_drive_poll_for_media), (g_drive_poll_for_media_finish): * gdrive.h: * gfile.c: (g_file_find_enclosing_mount): * gfile.h: * gio.symbols: * glocaldirectorymonitor.c: (g_local_directory_monitor_constructor), (mounts_changed): * glocalfile.c: (get_mount_info), (g_local_file_find_enclosing_mount), (g_local_file_file_iface_init): * gnativevolumemonitor.h: * gunionvolumemonitor.c: (get_mounts), (get_volumes), (get_connected_drives), (g_union_volume_monitor_class_init), (child_volume_added), (child_volume_removed), (child_volume_changed), (child_mount_added), (child_mount_removed), (child_mount_pre_unmount), (child_mount_changed), (child_drive_changed), (g_union_volume_monitor_add_monitor), (g_union_volume_monitor_remove_monitor), (_g_mount_get_for_mount_path): * gunixmounts.c: (g_unix_is_mount_path_system_internal), (guess_system_internal), (_g_get_unix_mounts), (_g_get_unix_mount_points), (g_get_unix_mount_at), (g_unix_mount_free), (g_unix_mount_compare), (g_unix_mount_get_mount_path), (g_unix_mount_get_device_path), (g_unix_mount_get_fs_type), (g_unix_mount_is_readonly), (g_unix_mount_is_system_internal), (g_unix_mount_guess_type), (type_to_icon), (g_unix_mount_guess_name), (g_unix_mount_guess_icon), (g_unix_mount_point_guess_name), (g_unix_mount_point_guess_icon), (_canonicalize_filename), (_resolve_symlink), (_resolve_dev_root): * gunixmounts.h: * gunixvolume.c: (g_unix_volume_finalize), (_g_unix_volume_new), (_g_unix_volume_disconnected), (_g_unix_volume_set_mount), (_g_unix_volume_unset_mount), (g_unix_volume_get_icon), (g_unix_volume_get_name), (g_unix_volume_can_mount), (g_unix_volume_get_drive), (g_unix_volume_get_mount), (_g_unix_volume_has_mount_path), (mount_cb), (mount_read_error), (g_unix_volume_mount), (g_unix_volume_mount_finish), (g_unix_volume_volume_iface_init): * gunixvolume.h: * gunixvolumemonitor.c: (g_unix_volume_monitor_finalize), (get_mounts), (get_volumes), (get_connected_drives), (get_mount_for_mount_path), (g_unix_volume_monitor_class_init), (mountpoints_changed), (mounts_changed), (g_unix_volume_monitor_init), (_g_unix_volume_monitor_lookup_volume_for_mount_path), (find_mount_by_mountpath), (update_volumes), (update_mounts): * gunixvolumemonitor.h: * gvolume.c: (g_volume_get_mount), (g_volume_can_mount), (g_volume_mount), (g_volume_mount_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_class_init), (g_volume_monitor_get_connected_drives), (g_volume_monitor_get_volumes), (g_volume_monitor_get_mounts): * gvolumemonitor.h: svn path=/trunk/; revision=6095
2007-12-11 22:23:55 +01:00
iface->mount_fn = g_unix_volume_mount;
iface->mount_finish = g_unix_volume_mount_finish;
Provide eject() on both GMount and GVolume and utility functions to guess 2007-12-14 David Zeuthen <davidz@redhat.com> * Makefile.am: * gio.symbols: * gmount.c: (g_mount_get_uuid), (g_mount_can_eject), (g_mount_eject), (g_mount_eject_finish): * gmount.h: * gunionvolumemonitor.c: (g_union_volume_monitor_finalize), (get_volume_for_uuid), (get_mount_for_uuid), (g_union_volume_monitor_class_init), (get_default_native_type_with_exclude), (get_default_native_type), (get_native_type), (update_native_type), (g_union_volume_monitor_init), (_g_mount_get_for_mount_path): * gunixmount.c: (_g_unix_mount_new), (g_unix_mount_get_uuid), (g_unix_mount_can_eject), (eject_unmount_cb), (eject_unmount_read_error), (eject_unmount_do), (g_unix_mount_unmount), (g_unix_mount_eject), (g_unix_mount_eject_finish), (g_unix_mount_mount_iface_init): * gunixmounts.c: (g_unix_mount_guess_can_eject), (g_unix_mount_point_guess_can_eject): * gunixmounts.h: * gunixvolume.c: (_g_unix_volume_new), (g_unix_volume_get_uuid), (g_unix_volume_can_eject), (g_unix_volume_get_drive), (eject_mount_cb), (eject_mount_read_error), (eject_mount_do), (g_unix_volume_mount), (g_unix_volume_eject), (g_unix_volume_eject_finish), (g_unix_volume_volume_iface_init): * gunixvolumemonitor.c: (get_volume_for_uuid), (get_mount_for_uuid), (g_unix_volume_monitor_class_init), (update_mounts): * gvolume.c: (g_volume_get_uuid), (g_volume_can_eject), (g_volume_eject), (g_volume_eject_finish): * gvolume.h: * gvolumemonitor.c: (g_volume_monitor_get_volume_for_uuid), (g_volume_monitor_get_mount_for_uuid): * gvolumemonitor.h: Provide eject() on both GMount and GVolume and utility functions to guess whether a GUnixMountPoint or GUnixMountEntry should be ejected. Introduce the concept of UUID's and wire it into GVolume and GMount and provide API on GVolumeMonitor to find such instances. Also handle the case where an external GNativeVolumeMonitor fails to initialize. Lock around the _g_get_mount_for_mount_path() function such that volume monitor implementations won't have to do locking themselves. svn path=/trunk/; revision=6140
2007-12-17 10:31:08 +01:00
iface->eject = g_unix_volume_eject;
iface->eject_finish = g_unix_volume_eject_finish;
iface->get_identifier = g_unix_volume_get_identifier;
iface->enumerate_identifiers = g_unix_volume_enumerate_identifiers;
}