sysprof/sysprof-1.0.9-warn-for-missing-module.patch
Gianluca Sforna 5359af473c - add subpackage with kernel module sources
- obsolete kmod-sysprof
- add patch for warning user about missing module
- add README.Fedora file with module build procedure
2007-12-27 10:07:36 +00:00

97 lines
2.8 KiB
Diff

Index: sysprof-1.0.9/sysprof.c
===================================================================
--- sysprof-1.0.9.orig/sysprof.c
+++ sysprof-1.0.9/sysprof.c
@@ -543,32 +543,67 @@ on_start_toggled (GtkWidget *widget, gpo
if (app->input_fd == -1)
{
- int fd;
- fd = open ("/proc/sysprof-trace", O_RDONLY);
- if (fd < 0)
- {
- load_module();
-
- fd = open ("/proc/sysprof-trace", O_RDONLY);
-
- if (fd < 0)
- {
- sorry (app->main_window,
- "Can't open /proc/sysprof-trace. You need to insert\n"
- "the sysprof kernel module. Run\n"
- "\n"
- " modprobe sysprof-module\n"
- "\n"
- "as root.");
-
- update_sensitivity (app);
- return;
- }
- }
+ // Check for kernel module existence
+ gchar * modules_path;
+ gchar * standard_output;
+ gchar * standard_error;
+ int exit_status = -1;
+ if (g_spawn_command_line_sync ("/bin/uname -r",
+ &standard_output, &standard_error,
+ &exit_status,
+ NULL))
+ {
+ g_strchomp( standard_output );
+ gchar * module_path;
+ module_path = g_strdup_printf( "/lib/modules/%s/extra/sysprof-module.ko", standard_output );
+
+ if ( ! g_file_test( module_path, G_FILE_TEST_EXISTS ))
+ {
+ sorry (app->main_window,
+ "Can not find sysprof kernel module in:\n\n"
+ " %s\n\n"
+ "Please see:\n"
+ "\n"
+ " %s/README.Fedora\n"
+ "\n"
+ "for more info about module installation.", module_path, PACKAGE_DOCDIR );
+ g_free( module_path );
+ update_sensitivity (app);
+ return;
+
+ }
+ g_free (standard_output);
+ g_free (standard_error);
+ g_free( module_path );
+ }
+
+ int fd;
+
+ fd = open ("/proc/sysprof-trace", O_RDONLY);
+ if (fd < 0)
+ {
+ load_module();
+
+ fd = open ("/proc/sysprof-trace", O_RDONLY);
+
+ if (fd < 0)
+ {
+ sorry (app->main_window,
+ "Can't open /proc/sysprof-trace. You need to insert\n"
+ "the sysprof kernel module. Run\n"
+ "\n"
+ " modprobe sysprof-module\n"
+ "\n"
+ "as root.");
+
+ update_sensitivity (app);
+ return;
+ }
+ }
- app->input_fd = fd;
- fd_add_watch (app->input_fd, app);
+ app->input_fd = fd;
+ fd_add_watch (app->input_fd, app);
}
fd_set_read_callback (app->input_fd, on_read);