Commit c4b8cdd4 authored by Darin Adler's avatar Darin Adler
Browse files

A pass at cleaning up the volume monitor. Made all the details of

	NautilusVolume private.

	* libnautilus-private/filesystem-attributes.xml: Changed the
	"description" string to be named "default_volume_name" and also
	marked it to be localized.

	* libnautilus-private/nautilus-file-utilities.h:
	* libnautilus-private/nautilus-file-utilities.c:
	(nautilus_get_data_file_path):
	Added a new utility function to locate a file that's either in the
	user's directory or in the Nautilus datadir.

	* src/nautilus-property-browser.c: (read_browser_xml): Use
	nautilus_get_data_file_path.

	* libnautilus-private/nautilus-trash-directory.c:
	(get_trash_volume):
	* libnautilus-private/nautilus-trash-monitor.c:
	(add_one_volume_trash):
	* src/file-manager/fm-desktop-icon-view.c: (volume_in_black_list),
	(create_unique_volume_name), (create_mount_link),
	(volume_unmounted_callback), (update_disks_menu):
	* src/nautilus-application.c: (volume_mounted_callback),
	(volume_unmounted_callback):
	* src/nautilus-bookmark-list.c:
	(nautilus_bookmark_list_get_file_path):
	Use only calls from the NautilusVolume public API -- no getting at
	the structure directly. Also fix callers that were using
	nautilus_volume_monitor_get_volume_mount_uri to correctly
	understand that they get the mount path, not the mount URI.

	* libnautilus-private/nautilus-volume-monitor.h:
	* libnautilus-private/nautilus-volume-monitor.c:
	(load_file_system_table): Fix storage leaks. Use the new
	nautilus_get_data_file_path. Translate the default volume names as
	they are loaded. Check for duplicate entries while loading the
	table. Don't bother checking the name of the root node, since
	there are plenty of other things about the file that we don't
	check and there's no reason we particularly need to check that.
	Fix some storage leaks. Free the doc, since I'm not seeing a
	"nautilus --quit" segfault.
	(nautilus_volume_monitor_initialize): Only initialize stuff that
	g_new0 won't set up for us.
	(nautilus_volume_is_removable): Rename so it's a call on
	NautilusVolume, not the NautilusVolumeMonitor.
	(volume_is_removable): Fix logic so we don't have to have so many
	different calls to fclose.
	(nautilus_volume_get_name): Rename so it's a call on
	NautilusVolume, not the NautilusVolumeMonitor.
	(modify_volume_name_for_display): Don't bother supplying a name if
	passed NULL, since that won't ever be helpful the way this is used.
	(nautilus_volume_get_target_uri): Rename so it's a call on
	NautilusVolume, not the NautilusVolumeMonitor.
	(nautilus_volume_should_integrate_trash): Rename so it's a call on
	NautilusVolume, not the NautilusVolumeMonitor. Get the information
	from the file system type, so we don't have to copy it into each
	NautilusVolume object.
	(nautilus_volume_get_mount_path): Rename so it's a call on
	NautilusVolume, and don't call it a URI since it's really a path.
	(nautilus_volume_get_device_type): New call.
	(make_volume_name_from_path): Get the default from the file system
	type rather than passing it in.
	(free_mount_list): Get rid of some dumb extra code.
	(copy_volume), (nautilus_volume_free): Update for smaller set of
	fields.
	(create_volume), (finish_creating_volume),
	(finish_creating_volume_and_prepend): Restructure so we don't need
	to keep so much stuff around in the NautilusVolume object.

	* src/nautilus-first-time-druid.c:
	(druid_set_first_time_file_flag): Some tiny tweaking.
parent bda50441
2001-08-15 Darin Adler <darin@bentspoon.com>
A pass at cleaning up the volume monitor. Made all the details of
NautilusVolume private.
* libnautilus-private/filesystem-attributes.xml: Changed the
"description" string to be named "default_volume_name" and also
marked it to be localized.
* libnautilus-private/nautilus-file-utilities.h:
* libnautilus-private/nautilus-file-utilities.c:
(nautilus_get_data_file_path):
Added a new utility function to locate a file that's either in the
user's directory or in the Nautilus datadir.
* src/nautilus-property-browser.c: (read_browser_xml): Use
nautilus_get_data_file_path.
* libnautilus-private/nautilus-trash-directory.c:
(get_trash_volume):
* libnautilus-private/nautilus-trash-monitor.c:
(add_one_volume_trash):
* src/file-manager/fm-desktop-icon-view.c: (volume_in_black_list),
(create_unique_volume_name), (create_mount_link),
(volume_unmounted_callback), (update_disks_menu):
* src/nautilus-application.c: (volume_mounted_callback),
(volume_unmounted_callback):
* src/nautilus-bookmark-list.c:
(nautilus_bookmark_list_get_file_path):
Use only calls from the NautilusVolume public API -- no getting at
the structure directly. Also fix callers that were using
nautilus_volume_monitor_get_volume_mount_uri to correctly
understand that they get the mount path, not the mount URI.
* libnautilus-private/nautilus-volume-monitor.h:
* libnautilus-private/nautilus-volume-monitor.c:
(load_file_system_table): Fix storage leaks. Use the new
nautilus_get_data_file_path. Translate the default volume names as
they are loaded. Check for duplicate entries while loading the
table. Don't bother checking the name of the root node, since
there are plenty of other things about the file that we don't
check and there's no reason we particularly need to check that.
Fix some storage leaks. Free the doc, since I'm not seeing a
"nautilus --quit" segfault.
(nautilus_volume_monitor_initialize): Only initialize stuff that
g_new0 won't set up for us.
(nautilus_volume_is_removable): Rename so it's a call on
NautilusVolume, not the NautilusVolumeMonitor.
(volume_is_removable): Fix logic so we don't have to have so many
different calls to fclose.
(nautilus_volume_get_name): Rename so it's a call on
NautilusVolume, not the NautilusVolumeMonitor.
(modify_volume_name_for_display): Don't bother supplying a name if
passed NULL, since that won't ever be helpful the way this is used.
(nautilus_volume_get_target_uri): Rename so it's a call on
NautilusVolume, not the NautilusVolumeMonitor.
(nautilus_volume_should_integrate_trash): Rename so it's a call on
NautilusVolume, not the NautilusVolumeMonitor. Get the information
from the file system type, so we don't have to copy it into each
NautilusVolume object.
(nautilus_volume_get_mount_path): Rename so it's a call on
NautilusVolume, and don't call it a URI since it's really a path.
(nautilus_volume_get_device_type): New call.
(make_volume_name_from_path): Get the default from the file system
type rather than passing it in.
(free_mount_list): Get rid of some dumb extra code.
(copy_volume), (nautilus_volume_free): Update for smaller set of
fields.
(create_volume), (finish_creating_volume),
(finish_creating_volume_and_prepend): Restructure so we don't need
to keep so much stuff around in the NautilusVolume object.
* src/nautilus-first-time-druid.c:
(druid_set_first_time_file_flag): Some tiny tweaking.
2001-08-15 Maciej Stachowiak <mjs@noisehavoc.org>
* components/music/Makefile.am: Revert accidental commit of not
......
<?xml version="1.0"?>
<FilesystemAttributes>
<filesystem name="affs" trash="no" description="affs"/>
<filesystem name="afs" trash="yes" description="AFS Network Volume"/>
<filesystem name="auto" trash="no" description="Auto-detected Volume"/>
<filesystem name="cdda" trash="no" description="CD Digital Audio"/>
<filesystem name="cdrom" trash="no" description="CDROM Drive"/>
<filesystem name="devfs" trash="no" description="Hardware Device Volume"/>
<filesystem name="ext2" trash="yes" description="Ext2 Linux Volume"/>
<filesystem name="ext3" trash="yes" description="Ext3 Linux Volume"/>
<filesystem name="fat" trash="yes" description="MSDOS Volume"/>
<filesystem name="iso9660" trash="no" description="CDROM Volume"/>
<filesystem name="hpfs" trash="no" description="Windows NT Volume"/>
<filesystem name="minix" trash="no" description="Minix Volume"/>
<filesystem name="msdos" trash="no" description="MSDOS Volume"/>
<filesystem name="nfs" trash="yes" description="NFS Network Volume"/>
<filesystem name="proc" trash="no" description="System Volume"/>
<filesystem name="reiserfs" trash="yes" description="ReiserFS Linux Volume"/>
<filesystem name="smb" trash="yes" description="Windows Fileshare Volume"/>
<filesystem name="udf" trash="no" description="DVD Volume"/>
<filesystem name="ufs" trash="yes" description="Solaris/BSD Volume"/>
<filesystem name="umsdos" trash="no" description="Enhanced DOS Volume"/>
<filesystem name="vfat" trash="yes" description="Windows Volume"/>
<filesystem name="xenix" trash="no" description="Xenix Volume"/>
<filesystem name="xfs" trash="yes" description="XFS Linux Volume"/>
<filesystem name="xiafs" trash="no" description="xiafs"/>
<filesystem name="unknown" trash="no" description="Unknown Filesystem"/>
<filesystem name="affs" _default_volume_name="AFFS Volume"/>
<filesystem name="afs" _default_volume_name="AFS Network Volume" trash="yes"/>
<filesystem name="auto" _default_volume_name="Auto-detected Volume"/>
<filesystem name="cdda" _default_volume_name="CD Digital Audio"/>
<filesystem name="cdrom" _default_volume_name="CD-ROM Drive"/>
<filesystem name="devfs" _default_volume_name="Hardware Device Volume"/>
<filesystem name="ext2" _default_volume_name="Ext2 Linux Volume" trash="yes"/>
<filesystem name="ext3" _default_volume_name="Ext3 Linux Volume" trash="yes"/>
<filesystem name="fat" _default_volume_name="MSDOS Volume" trash="yes"/>
<filesystem name="iso9660" _default_volume_name="CDROM Volume"/>
<filesystem name="hpfs" _default_volume_name="Windows NT Volume"/>
<filesystem name="minix" _default_volume_name="Minix Volume"/>
<filesystem name="msdos" _default_volume_name="MSDOS Volume"/>
<filesystem name="nfs" _default_volume_name="NFS Network Volume" trash="yes"/>
<filesystem name="proc" _default_volume_name="System Volume"/>
<filesystem name="reiserfs" _default_volume_name="ReiserFS Linux Volume" trash="yes"/>
<filesystem name="smb" _default_volume_name="Windows Shared Volume" trash="yes"/>
<filesystem name="udf" _default_volume_name="DVD Volume"/>
<filesystem name="ufs" _default_volume_name="Solaris/BSD Volume" trash="yes"/>
<filesystem name="umsdos" _default_volume_name="Enhanced DOS Volume"/>
<filesystem name="vfat" _default_volume_name="Windows VFAT Volume" trash="yes"/>
<filesystem name="xenix" _default_volume_name="Xenix Volume"/>
<filesystem name="xfs" _default_volume_name="XFS Linux Volume" trash="yes"/>
<filesystem name="xiafs" _default_volume_name="XIAFS Volume"/>
</FilesystemAttributes>
......@@ -287,6 +287,31 @@ nautilus_pixmap_file (const char *partial_path)
return NULL;
}
char *
nautilus_get_data_file_path (const char *partial_path)
{
char *path;
char *user_directory;
/* first try the user's home directory */
user_directory = nautilus_get_user_directory ();
path = nautilus_make_path (user_directory, partial_path);
g_free (user_directory);
if (g_file_exists (path)) {
return path;
}
g_free (path);
/* next try the shared directory */
path = nautilus_make_path (NAUTILUS_DATADIR, partial_path);
if (g_file_exists (path)) {
return path;
}
g_free (path);
return NULL;
}
char *
nautilus_unique_temporary_file_name (void)
{
......
......@@ -47,7 +47,6 @@ char * nautilus_get_desktop_directory (void);
char * nautilus_get_gmc_desktop_directory (void);
char * nautilus_get_pixmap_directory (void);
/* See if the user_main_directory exists. This should be called before
* nautilus_get_user_main_directory, which creates the directory.
*/
......@@ -63,6 +62,9 @@ gboolean nautilus_user_main_directory_exists (void);
*/
char * nautilus_pixmap_file (const char *partial_path);
/* Locate a file in either the uers directory or the datadir. */
char * nautilus_get_data_file_path (const char *partial_path);
/* Returns the build time stamp the Nautilus binary.
* This is useful to be able to tell builds apart.
* A return value of NULL means unknown time stamp.
......
......@@ -140,6 +140,8 @@ get_trash_volume (NautilusTrashDirectory *trash,
TrashVolume **trash_volume,
GnomeVFSURI **volume_mount_uri)
{
char *uri_str;
/* Quick out if we already know about this volume. */
*trash_volume = g_hash_table_lookup (trash->details->volumes,
volume);
......@@ -148,12 +150,13 @@ get_trash_volume (NautilusTrashDirectory *trash,
return FALSE;
}
if (!nautilus_volume_monitor_should_integrate_trash (volume)) {
if (!nautilus_volume_should_integrate_trash (volume)) {
return FALSE;
}
*volume_mount_uri = gnome_vfs_uri_new
(nautilus_volume_monitor_get_volume_mount_uri (volume));
uri_str = gnome_vfs_get_uri_from_local_path (nautilus_volume_get_mount_path (volume));
*volume_mount_uri = gnome_vfs_uri_new (uri_str);
g_free (uri_str);
if (*trash_volume == NULL) {
/* Make the structure used to track the trash for this volume. */
......
......@@ -215,19 +215,21 @@ static gboolean
add_one_volume_trash (const NautilusVolume *volume,
gpointer callback_data)
{
char *uri_str;
GnomeVFSURI *volume_mount_point_uri;
GnomeVFSURI *trash_uri;
GList **result;
result = (GList **)callback_data;
result = (GList **) callback_data;
if (nautilus_volume_monitor_should_integrate_trash (volume)) {
if (nautilus_volume_should_integrate_trash (volume)) {
/* Get the uri of the volume mount point as the place
* "near" which to look for trash on the given volume.
*/
volume_mount_point_uri = gnome_vfs_uri_new (
nautilus_volume_monitor_get_volume_mount_uri (volume));
*/
uri_str = gnome_vfs_get_uri_from_local_path (nautilus_volume_get_mount_path (volume));
volume_mount_point_uri = gnome_vfs_uri_new (uri_str);
g_free (uri_str);
g_assert (volume_mount_point_uri != NULL);
......@@ -236,9 +238,9 @@ add_one_volume_trash (const NautilusVolume *volume,
* already don't know where it is) do not cause any IO.
*/
if (gnome_vfs_find_directory (volume_mount_point_uri,
GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri,
FALSE, FALSE, 0777) == GNOME_VFS_OK) {
GNOME_VFS_DIRECTORY_KIND_TRASH, &trash_uri,
FALSE, FALSE, 0777) == GNOME_VFS_OK) {
/* found trash, put it on the list */
*result = g_list_prepend (*result, trash_uri);
}
......
......@@ -37,6 +37,7 @@
#include <eel/eel-stock-dialogs.h>
#include <eel/eel-string-list.h>
#include <eel/eel-string.h>
#include <eel/eel-xml-extensions.h>
#include <errno.h>
#include <fcntl.h>
#include <gnome-xml/parser.h>
......@@ -122,7 +123,6 @@
#include <cdda_paranoia.h>
#define CD_AUDIO_PATH "/dev/cdrom"
#define CDDA_SCHEME "cdda"
/* This is here to work around a broken header file. cdda_interface.h
* has a statically defined array of chars that is unused. This will
......@@ -144,8 +144,23 @@ typedef struct statfs MountTableEntry;
typedef struct mntent MountTableEntry;
#endif
typedef void (* ChangeNautilusVolumeFunction) (NautilusVolumeMonitor *view,
NautilusVolume *volume);
typedef struct {
char *name;
char *default_volume_name;
gboolean can_handle_trash;
} NautilusFileSystemType;
struct NautilusVolume {
NautilusDeviceType device_type;
NautilusFileSystemType *file_system_type;
char *device_path;
char *mount_path;
char *volume_name;
gboolean is_removable;
gboolean is_audio_cd;
};
struct NautilusVolumeMonitorDetails
{
......@@ -153,9 +168,12 @@ struct NautilusVolumeMonitorDetails
GList *removable_volumes;
guint mount_volume_timer_id;
GHashTable *readable_mount_point_names;
GHashTable *filesystem_attribute_table;
GHashTable *file_system_table;
};
typedef void (* ChangeNautilusVolumeFunction) (NautilusVolumeMonitor *view,
NautilusVolume *volume);
static NautilusVolumeMonitor *global_volume_monitor = NULL;
static const char *floppy_device_path_prefix;
static const char *noauto_string;
......@@ -178,120 +196,81 @@ static void nautilus_volume_monitor_initialize_class (NautilusVolumeM
static void nautilus_volume_monitor_destroy (GtkObject *object);
static char * get_iso9660_volume_name (NautilusVolume *volume,
int volume_fd);
static GHashTable * load_filesystem_attributes_table (void);
static GHashTable * load_file_system_table (void);
static void mount_volume_activate (NautilusVolumeMonitor *view,
NautilusVolume *volume);
static void mount_volume_deactivate (NautilusVolumeMonitor *monitor,
NautilusVolume *volume);
static void load_additional_mount_list_info (GList *volume_list);
static GList * mount_volume_prepend_filesystem (GList *volume_list,
NautilusVolume *volume);
static NautilusVolume *create_volume (GHashTable *fs_attribute_table,
const char *device_path,
const char *mount_path,
const char *filesystem);
static NautilusVolume *copy_volume (NautilusVolume *volume);
static NautilusVolume *create_volume (const char *device_path,
const char *mount_path);
static GList * finish_creating_volume_and_prepend (NautilusVolumeMonitor *monitor,
NautilusVolume *volume,
const char *file_system_type_name,
GList *volume_list);
static NautilusVolume *copy_volume (const NautilusVolume *volume);
static void find_volumes (NautilusVolumeMonitor *monitor);
static void free_mount_list (GList *mount_list);
static GList * get_removable_volumes (GHashTable *fs_attribute_table);
static GList * get_removable_volumes (NautilusVolumeMonitor *monitor);
static GHashTable * create_readable_mount_point_name_table (void);
static int get_cdrom_type (const char *vol_dev_path,
int *fd);
static void nautilus_volume_free (NautilusVolume *volume);
#ifdef HAVE_CDDA
static gboolean locate_audio_cd (void);
#endif
EEL_DEFINE_CLASS_BOILERPLATE (NautilusVolumeMonitor,
nautilus_volume_monitor,
GTK_TYPE_OBJECT)
static char*
get_xml_path (const char *file_name)
{
char *xml_path;
char *user_directory;
user_directory = nautilus_get_user_directory ();
/* first try the user's home directory */
xml_path = nautilus_make_path (user_directory,
file_name);
g_free (user_directory);
if (g_file_exists (xml_path)) {
return xml_path;
}
g_free (xml_path);
/* next try the shared directory */
xml_path = nautilus_make_path (NAUTILUS_DATADIR,
file_name);
if (g_file_exists (xml_path)) {
return xml_path;
}
g_free (xml_path);
return NULL;
}
nautilus_volume_monitor,
GTK_TYPE_OBJECT)
static GHashTable *
load_filesystem_attributes_table (void)
load_file_system_table (void)
{
xmlDocPtr doc;
xmlNodePtr node;
GHashTable *table;
char *filesystem_attributes_file;
xmlChar *name, *trash_str;
NautilusVolumeInfo *filesystem;
filesystem_attributes_file = get_xml_path ("filesystem-attributes.xml");
char *file_system_attributes_file;
xmlChar *name, *default_volume_name, *trash;
NautilusFileSystemType *type;
if (filesystem_attributes_file == NULL) {
return NULL;
}
doc = xmlParseFile (filesystem_attributes_file);
table = g_hash_table_new (g_str_hash, g_str_equal);
g_free (filesystem_attributes_file);
if (doc == NULL
|| doc->xmlRootNode == NULL
|| doc->xmlRootNode->name == NULL
|| g_strcasecmp (doc->xmlRootNode->name, "FileSystemAttributes") != 0) {
xmlFreeDoc(doc);
return NULL;
file_system_attributes_file = nautilus_get_data_file_path ("filesystem-attributes.xml");
if (file_system_attributes_file == NULL) {
return table;
}
doc = xmlParseFile (file_system_attributes_file);
g_free (file_system_attributes_file);
if (doc == NULL) {
return table;
}
table = g_hash_table_new (g_str_hash, g_str_equal);
for (node = doc->xmlRootNode->xmlChildrenNode; node != NULL; node = node->next) {
name = xmlGetProp (node, "name");
if (name == NULL) {
continue;
}
filesystem = g_new0 (NautilusVolumeInfo, 1);
filesystem->name = strdup (name);
filesystem->description = strdup (xmlGetProp (node, "description"));
if (name != NULL) {
default_volume_name = eel_xml_get_property_translated (node, "default_volume_name");
trash = xmlGetProp (node, "trash");
trash_str = xmlGetProp (node, "trash");
if (trash_str != NULL && (strcmp (trash_str, "yes") == 0)) {
filesystem->use_trash = TRUE;
} else {
filesystem->use_trash = FALSE;
if (g_hash_table_lookup (table, name) != NULL) {
g_message ("duplicate entry for file system type %s", name);
}
type = g_new (NautilusFileSystemType, 1);
type->name = g_strdup (name);
type->default_volume_name = g_strdup (default_volume_name);
type->can_handle_trash = eel_str_is_equal (trash, "yes");
g_hash_table_insert (table, type->name, type);
xmlFree (default_volume_name);
xmlFree (trash);
}
g_hash_table_insert (table, filesystem->name, filesystem);
xmlFree (name);
xmlFree (trash_str);
/* printf ("Found filesystem %s (%s), trash support is %d.\n", filesystem->description, filesystem->name, filesystem->use_trash); */
}
/* FIXME: if I do this xmlFreeDoc, then "nautilus --quit" segfaults somewhere in OAF.
Why? It looks like memory trashing, but the xmlFreeDoc here sure looks correct to me.
Leaving it commented out currently, though that will leak a little memory, it should be
a fixed amount since this function should be (and is) only called once */
/* xmlFreeDoc (doc); */
xmlFreeDoc (doc);
return table;
}
......@@ -301,13 +280,9 @@ nautilus_volume_monitor_initialize (NautilusVolumeMonitor *monitor)
{
/* Set up details */
monitor->details = g_new0 (NautilusVolumeMonitorDetails, 1);
monitor->details->mounts = NULL;
monitor->details->removable_volumes = NULL;
monitor->details->readable_mount_point_names = create_readable_mount_point_name_table ();
monitor->details->filesystem_attribute_table = load_filesystem_attributes_table ();
monitor->details->removable_volumes = get_removable_volumes (monitor->details->filesystem_attribute_table);
monitor->details->file_system_table = load_file_system_table ();
monitor->details->removable_volumes = get_removable_volumes (monitor);
find_volumes (monitor);
}
......@@ -439,12 +414,11 @@ floppy_sort (const NautilusVolume *volume1, const NautilusVolume *volume2)
}
gboolean
nautilus_volume_monitor_volume_is_removable (const NautilusVolume *volume)
nautilus_volume_is_removable (const NautilusVolume *volume)
{
return volume->is_removable;
}
/* nautilus_volume_monitor_get_removable_volumes
*
* Accessor. List and internal data is not to be freed.
......@@ -489,7 +463,7 @@ has_removable_mntent_options (MountTableEntry *ent)
*/
static GList *
get_removable_volumes (GHashTable *fs_attribute_table)
get_removable_volumes (NautilusVolumeMonitor *monitor)
{
FILE *file;
GList *volumes;
......@@ -509,13 +483,11 @@ get_removable_volumes (GHashTable *fs_attribute_table)
/* getmentinfo returns a pointer to static data. Do not free. */
for (index = 0; index < count; index++) {
if (has_removable_mntent_options (ent + 1)) {
create_volume (fs_attribute_table,
ent[index].f_mntfromname,
ent[index].f_mntoname,
ent[index].f_fstyename);
volume = create_volume (ent[index].f_mntfromname,
ent[index].f_mntoname);
volume->is_removable = TRUE;
volume->is_read_only = ((ent[index].f_flags & MNT_RDONLY) != 0);
volumes = mount_volume_prepend_filesystem (volumes, volume);
volumes = finish_creating_volume_and_prepend
(monitor, volume, ent[index].f_fstyename, volumes);
}
}
#endif
......@@ -528,21 +500,19 @@ get_removable_volumes (GHashTable *fs_attribute_table)
#ifdef HAVE_SYS_MNTTAB_H
ent = &ent_storage;
while (! getmntent (file, ent)) {
/* On Solaris look for /vol/ for determining a removable volume */
if (eel_str_has_prefix (ent->mnt_special, noauto_string)) {
volume = create_volume (fs_attribute_table, ent->mnt_special,
ent->mnt_mountp, ent->mnt_fstype);
volume = create_volume (ent->mnt_special, ent->mnt_mountp);
volume->is_removable = TRUE;
volume->is_read_only = hasmntopt (ent, MNTOPT_RO) != NULL;
volumes = mount_volume_prepend_filesystem (volumes, volume);
volumes = finish_creating_volume_and_prepend
(monitor, volume, ent->mnt_fstype, volumes);
}
}
#elif defined (HAVE_MNTENT_H)
while ((ent = getmntent (file)) != NULL) {
if (has_removable_mntent_options (ent)) {
volume = create_volume (fs_attribute_table, ent->mnt_fsname,
ent->mnt_dir, ent->mnt_type);
volumes = mount_volume_prepend_filesystem (volumes, volume);
volume = create_volume (ent->mnt_fsname, ent->mnt_dir);
volumes = finish_creating_volume_and_prepend
(monitor, volume, ent->mnt_type, volumes);
}
}
#endif
......@@ -550,8 +520,8 @@ get_removable_volumes (GHashTable *fs_attribute_table)
fclose (file);
#ifdef HAVE_CDDA
volume = create_volume (NULL, CD_AUDIO_PATH, CD_AUDIO_PATH, CDDA_SCHEME);
volumes = mount_volume_prepend_filesystem (volumes, volume);
volume = create_volume (CD_AUDIO_PATH, CD_AUDIO_PATH);
volumes = finish_creating_volume_and_prepend (monitor, volume, "cdda", volumes);
#endif
load_additional_mount_list_info (volumes);
......@@ -565,6 +535,7 @@ get_removable_volumes (GHashTable *fs_attribute_table)
static gboolean
volume_is_removable (const NautilusVolume *volume)
{
gboolean removable;
FILE *file;
MountTableEntry *ent;
#ifdef HAVE_SYS_MNTTAB_H
......@@ -577,17 +548,17 @@ volume_is_removable (const NautilusVolume *volume)
if (file == NULL) {
return FALSE;
}
removable = FALSE;
/* Search for our device in the fstab */
#ifdef HAVE_SYS_MNTTAB_H
ent = &ent_storage;
while (!getmntent (file, ent)) {
if (strcmp (volume->device_path, ent->mnt_special) == 0) {
/* On Solaris look for /vol/ for determining
a removable volume */
if (eel_str_has_prefix (ent->mnt_special, noauto_string)) {
fclose (file);
return TRUE;
removable = TRUE;
break;
}
}
}
......@@ -595,73 +566,24 @@ volume_is_removable (const NautilusVolume *volume)
while ((ent = getmntent (file)) != NULL) {
if (strcmp (volume->device_path, ent->mnt_fsname) == 0
&& has_removable_mntent_options (ent)) {
fclose (file);
return TRUE;
removable = TRUE;
break;
}
}