Group :: System/Kernel and hardware
RPM: latencytop
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: latencytop-misc.patch
Download
Download
--- latencytop-0.4.orig/latencytop.c
+++ latencytop-0.4/latencytop.c
@@ -47,6 +47,7 @@
int firsttime = 1;
int noui;
int dump_unknown;
+static void disable_sysctl(void);
static void add_to_global(struct latency_line *line)
{
@@ -95,10 +96,14 @@
size_t dummy;
file = fopen("/proc/latency_stats","r+");
if (!file) {
- cleanup_curses() ;
- fprintf(stderr, "Please enable the CONFIG_LATENCYTOP configuration in your kernel.\n");
- fprintf(stderr, "Exiting...\n");
- exit(EXIT_FAILURE);
+ cleanup_curses();
+ disable_sysctl();
+ fputs( "Are you root?\n"
+ "Please enable the CONFIG_LATENCYTOP configuration in your kernel.\n"
+ "Exiting...\n", stderr);
+ /*exit(EXIT_FAILURE); would call atexit function:
+ * cleanup_curses, so deleting above message.*/
+ _exit(EXIT_FAILURE);
}
/* wipe first line */
ln = NULL;
@@ -474,9 +479,14 @@
{
FILE *file;
file = fopen("/proc/sys/kernel/latencytop", "w");
- if (!file)
+ if (!file) {
+ perror("Error writing to /proc/sys/kernel/latencytop");
+ return;
+ }
+ if (putc('1', file) == EOF) {
+ perror("Error writing to /proc/sys/kernel/latencytop");
return;
- fprintf(file, "1");
+ }
fclose(file);
}
@@ -484,9 +494,14 @@
{
FILE *file;
file = fopen("/proc/sys/kernel/latencytop", "w");
- if (!file)
+ if (!file) {
+ perror("Error writing to /proc/sys/kernel/latencytop");
return;
- fprintf(file, "0");
+ }
+ if (putc('0', file) == EOF) {
+ perror("Error writing to /proc/sys/kernel/latencytop");
+ return;
+ }
fclose(file);
}
@@ -494,8 +509,9 @@
{
int ret = 1;
enable_sysctl();
+ atexit(disable_sysctl);
if (argc>1 && strcmp(argv[1],"-d")==0) {
- init_translations("latencytop.trans");
+ init_translations("/usr/share/latencytop/latencytop.trans");
parse_global_list();
sort_list();
dump_global_to_console();
@@ -508,7 +524,7 @@
if (argc>1 && strcmp(argv[1],"--block")==0) {
printf("Doing block tracing\n");
- init_translations("latencytop.block");
+ init_translations("/usr/share/latencytop/latencytop.block");
noui = 1;
dump_unknown = 1;
}
@@ -531,7 +547,5 @@
}
prune_unused_procs();
delete_list();
- cleanup_curses();
- disable_sysctl();
return EXIT_SUCCESS;
}
--- latencytop-0.4.orig/translate.c
+++ latencytop-0.4/translate.c
@@ -97,8 +97,10 @@
FILE *file;
file = fopen(filename, "r");
- if (!file)
+ if (!file) {
+ perror("Could not read translation file");
return;
+ }
while (!feof(file)) {
struct translate_line *trans;
size_t dummy;