+2004-10-05 Alexander Larsson + + * libgnomevfs/gnome-vfs-mime-handlers.c (gnome_vfs_mime_get_default_action_type): + Temporary workaround to make show_url handle folders. This needs + rethinking. + +2004-09-27 Ray Strode + * libgnomevfs/eggdesktopentries.c + (egg_desktop_entries_get_locale_encoding): + swap if and else clauses to prevent needlessly + misallocating gigabytes of memory (Spotted + by Nicholas Miell, bug 153759). + +2004-09-27 Ray Strode + * libgnomevfs/eggdesktopentries.c + (egg_find_file_in_data_dirs): use g_error_new + instead g_set_error. + (egg_find_file_in_data_dir): get rid of the + secondary error cruft. + (egg_desktop_entries_free): free + entries->default_group_name + (egg_desktop_entries_get_locale_country): + swap if and else clauses to prevent needlessly + misallocating gigabytes of memory (Spotted + by Nicholas Miell, bug 153759). + +2004-09-22 Alexander Larsson + + * libgnomevfs/gnome-vfs-unix-mounts.[ch]: + * libgnomevfs/gnome-vfs-volume-monitor-daemon.c: + Try to reuse children when getting dev_t by stating. + Fixes bug 151026. Patch from Morten Welinder. + + * configure.in: + Post release version bump. + +=== gnome-vfs 2.8.1 === + 2004-09-21 Alexander Larsson * NEWS: Index: libgnomevfs/eggdesktopentries.c =================================================================== RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/eggdesktopentries.c,v retrieving revision 1.8 retrieving revision 1.10 diff -u -p -r1.8 -r1.10 --- libgnomevfs/eggdesktopentries.c 3 Sep 2004 18:24:00 -0000 1.8 +++ libgnomevfs/eggdesktopentries.c 28 Sep 2004 03:41:12 -0000 1.10 @@ -224,7 +224,7 @@ egg_find_file_in_data_dirs (const gchar g_free (path); if (fd < 0 && file_error == NULL) - g_set_error (&file_error, G_FILE_ERROR, + file_error = g_error_new (G_FILE_ERROR, g_file_error_from_errno (errno), _("File could not be opened: %s"), g_strerror (errno)); @@ -261,10 +261,8 @@ egg_find_file_in_data_dir (const gchar * gint fd; gchar **data_dirs; GError *file_error; - GError *secondary_error; file_error = NULL; - secondary_error = NULL; data_dirs = g_new0 (char *, 2); @@ -275,20 +273,18 @@ egg_find_file_in_data_dir (const gchar * if (fd < 0) { data_dirs = egg_get_secondary_data_dirs (); - fd = egg_find_file_in_data_dirs (file, data_dirs, &secondary_error); + fd = egg_find_file_in_data_dirs (file, data_dirs, NULL); g_strfreev (data_dirs); if (fd >= 0) - { - g_error_free (file_error); - file_error = NULL; - } + { + g_error_free (file_error); + file_error = NULL; + } } if (file_error) g_propagate_error (error, file_error); - else if (secondary_error) - g_propagate_error (error, secondary_error); return fd; } @@ -405,6 +401,7 @@ egg_desktop_entries_free (EggDesktopEntr g_string_free (entries->parse_buffer, TRUE); g_strfreev (entries->legal_start_groups); + g_free (entries->default_group_name); tmp = entries->groups; while (tmp != NULL) @@ -1912,9 +1909,9 @@ egg_desktop_entries_get_locale_country ( q = strstr (p, "@"); if (!q) - country_len = q - p; - else country_len = strlen (p); + else + country_len = q - p; if (country_len <= 0) return NULL; @@ -1972,9 +1969,9 @@ egg_desktop_entries_get_locale_encoding q = strstr (p, "@"); if (!q) - encoding_len = q - p; - else encoding_len = strlen (p); + else + encoding_len = q - p; if (encoding_len <= 0) { Index: libgnomevfs/gnome-vfs-mime-handlers.c =================================================================== RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-mime-handlers.c,v retrieving revision 1.109 retrieving revision 1.110 diff -u -p -r1.109 -r1.110 --- libgnomevfs/gnome-vfs-mime-handlers.c 7 Sep 2004 15:31:35 -0000 1.109 +++ libgnomevfs/gnome-vfs-mime-handlers.c 5 Oct 2004 09:32:20 -0000 1.110 @@ -98,6 +98,13 @@ gnome_vfs_mime_get_default_action_type ( { const char *action_type_string; + /* TODO: gnome_vfs_mime_get_value below always returns NONE these days. + We need to figure out what to really do here. For now, special case folders. + */ + if (g_str_has_prefix (mime_type, "x-directory/")) { + return GNOME_VFS_MIME_ACTION_TYPE_COMPONENT; + } + action_type_string = gnome_vfs_mime_get_value (mime_type, "default_action_type"); if (action_type_string != NULL && g_ascii_strcasecmp (action_type_string, "application") == 0) { Index: libgnomevfs/gnome-vfs-unix-mounts.c =================================================================== RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-unix-mounts.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -p -r1.16 -r1.17 --- libgnomevfs/gnome-vfs-unix-mounts.c 21 Sep 2004 07:45:25 -0000 1.16 +++ libgnomevfs/gnome-vfs-unix-mounts.c 22 Sep 2004 08:38:38 -0000 1.17 @@ -91,98 +91,111 @@ * to avoid this... * Various ugly workarounds can be tried later. */ -dev_t -_gnome_vfs_unix_mount_get_unix_device (GnomeVFSUnixMount *mount) +GList * +_gnome_vfs_unix_mount_get_unix_device (GList *mounts) { - struct stat statbuf; - dev_t unix_device; - pid_t pid; - int pipes[2]; -#ifdef HAVE_POLL - struct pollfd poll_fd; -#else - struct timeval tv; - fd_set read_fds; -#endif - int res; - int status; + GList *result = NULL; - if (pipe (pipes) == -1) { - return 0; - } + while (mounts) { + dev_t unix_device = 0; + pid_t pid; + int pipes[2]; + int status; - pid = fork (); - - if (pid == -1) { - close (pipes[0]); - close (pipes[1]); - return 0; - } - - unix_device = 0; - - if (pid == 0) { - /* Child */ - close (pipes[0]); + if (pipe (pipes) == -1) + goto error; pid = fork (); + if (pid == -1) { + close (pipes[0]); + close (pipes[1]); + goto error; + } - /* Fork an intermediate child that immediately exits so - * we can waitpid it. This means the final process will get - * owned by init and not go zombie - */ if (pid == 0) { - /* Grandchild */ - if (stat (mount->mount_path, &statbuf) == 0) { - write (pipes[1], (char *)&statbuf.st_dev, sizeof (dev_t)); + /* Child */ + close (pipes[0]); + + /* Fork an intermediate child that immediately exits + * so we can waitpid it. This means the final process + * will get owned by init and not go zombie. + */ + pid = fork (); + + if (pid == 0) { + /* Grandchild */ + struct stat statbuf; + while (mounts) { + GnomeVFSUnixMount *mount = mounts->data; + unix_device = + stat (mount->mount_path, &statbuf) == 0 + ? statbuf.st_dev + : 0; + write (pipes[1], (char *)&unix_device, sizeof (dev_t)); + mounts = mounts->next; + } } - } else { close (pipes[1]); + _exit (0); + g_assert_not_reached (); } - _exit (0); - } else { /* Parent */ close (pipes[1]); - - wait_again: + + retry_waitpid: if (waitpid (pid, &status, 0) < 0) { if (errno == EINTR) - goto wait_again; + goto retry_waitpid; else if (errno == ECHILD) ; /* do nothing, child already reaped */ else g_warning ("waitpid() should not fail in gnome_vfs_unix_mount_get_unix_device"); } + while (mounts) { + int res; - do { + do { #ifdef HAVE_POLL - poll_fd.fd = pipes[0]; - poll_fd.events = POLLIN; - res = poll (&poll_fd, 1, STAT_TIMEOUT_SECONDS*1000); + struct pollfd poll_fd; + poll_fd.fd = pipes[0]; + poll_fd.events = POLLIN; + res = poll (&poll_fd, 1, STAT_TIMEOUT_SECONDS * 1000); #else - tv.tv_sec = STAT_TIMEOUT_SECONDS; - tv.tv_usec = 0; + struct timeval tv; + fd_set read_fds; + + tv.tv_sec = STAT_TIMEOUT_SECONDS; + tv.tv_usec = 0; - FD_ZERO(&read_fds); - FD_SET(pipes[0], &read_fds); + FD_ZERO(&read_fds); + FD_SET(pipes[0], &read_fds); - res = select (pipes[0] + 1, - &read_fds, NULL, NULL, &tv); + res = select (pipes[0] + 1, + &read_fds, NULL, NULL, &tv); #endif - } while (res == -1 && errno == EINTR); - - if (res > 0) { - if (read (pipes[0], (char *)&unix_device, sizeof (dev_t)) != sizeof (dev_t)) { - unix_device = 0; - } + } while (res == -1 && errno == EINTR); + + if (res <= 0 || + read (pipes[0], (char *)&unix_device, sizeof (dev_t)) != sizeof (dev_t)) + break; + + result = g_list_prepend (result, GUINT_TO_POINTER ((gulong)unix_device)); + mounts = mounts->next; } close (pipes[0]); + + error: + if (mounts) { + unix_device = 0; + result = g_list_prepend (result, GUINT_TO_POINTER ((gulong)unix_device)); + mounts = mounts->next; + } } - - return unix_device; + + return g_list_reverse (result); } #ifndef HAVE_SETMNTENT Index: libgnomevfs/gnome-vfs-unix-mounts.h =================================================================== RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-unix-mounts.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -r1.2 -r1.3 --- libgnomevfs/gnome-vfs-unix-mounts.h 5 Nov 2003 15:44:53 -0000 1.2 +++ libgnomevfs/gnome-vfs-unix-mounts.h 22 Sep 2004 08:38:38 -0000 1.3 @@ -59,7 +59,7 @@ gint _gnome_vfs_unix_mount_point_com GnomeVFSUnixMountPoint *mount_point2); gboolean _gnome_vfs_get_unix_mount_table (GList **return_list); gboolean _gnome_vfs_get_current_unix_mounts (GList **return_list); -dev_t _gnome_vfs_unix_mount_get_unix_device (GnomeVFSUnixMount *mount); +GList * _gnome_vfs_unix_mount_get_unix_device (GList *mounts); void _gnome_vfs_monitor_unix_mounts (GnomeVFSUnixMountCallback mount_table_changed, gpointer mount_table_changed_user_data, GnomeVFSUnixMountCallback current_mounts_changed, Index: libgnomevfs/gnome-vfs-volume-monitor-daemon.c =================================================================== RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-monitor-daemon.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -p -r1.14 -r1.15 --- libgnomevfs/gnome-vfs-volume-monitor-daemon.c 2 Sep 2004 15:51:48 -0000 1.14 +++ libgnomevfs/gnome-vfs-volume-monitor-daemon.c 22 Sep 2004 08:38:38 -0000 1.15 @@ -851,7 +851,7 @@ create_vol_from_mount (GnomeVFSVolumeMon vol->priv->volume_type = GNOME_VFS_VOLUME_TYPE_MOUNTPOINT; vol->priv->device_path = g_strdup (mount->device_path); - vol->priv->unix_device = _gnome_vfs_unix_mount_get_unix_device (mount); + vol->priv->unix_device = 0; /* Caller must fill in. */ vol->priv->activation_uri = gnome_vfs_get_uri_from_local_path (mount->mount_path); vol->priv->filesystem_type = g_strdup (mount->filesystem_type); vol->priv->is_read_only = mount->is_read_only; @@ -981,9 +981,8 @@ static void update_mtab_volumes (GnomeVFSVolumeMonitorDaemon *volume_monitor_daemon) { GList *new_mtab; - GList *removed, *added; - GList *l; - GnomeVFSUnixMount *mount; + GList *removed, *added, *devices; + GList *l, *ld; char *uri; GnomeVFSVolume *vol; GnomeVFSVolumeMonitor *volume_monitor; @@ -998,7 +997,7 @@ update_mtab_volumes (GnomeVFSVolumeMonit &added, &removed); for (l = removed; l != NULL; l = l->next) { - mount = l->data; + GnomeVFSUnixMount *mount = l->data; uri = gnome_vfs_get_uri_from_local_path (mount->mount_path); vol = _gnome_vfs_volume_monitor_find_mtab_volume_by_activation_uri (volume_monitor, uri); @@ -1011,15 +1010,22 @@ update_mtab_volumes (GnomeVFSVolumeMonit g_free (uri); } - - for (l = added; l != NULL; l = l->next) { - mount = l->data; + + devices = _gnome_vfs_unix_mount_get_unix_device (added); + + for (l = added, ld = devices; + l != NULL; + l = l->next, ld = ld->next) { + GnomeVFSUnixMount *mount = l->data; + dev_t unix_device = GPOINTER_TO_UINT (ld->data); vol = create_vol_from_mount (volume_monitor, mount); + vol->priv->unix_device = unix_device; _gnome_vfs_volume_monitor_mounted (volume_monitor, vol); gnome_vfs_volume_unref (vol); } - + + g_list_free (devices); g_list_free (added); g_list_free (removed); g_list_foreach (volume_monitor_daemon->last_mtab,