~ubuntu-branches/ubuntu/karmic/rsyslog/karmic-200908151517

« back to all changes in this revision

Viewing changes to plugins/imklog/imklog.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2008-04-23 16:46:39 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080423164639-5acmt8a4vpxjgnxw
Tags: 3.14.2-3
* debian/rsyslog-doc.install
  - Fix a typo in the install path of the dia files. Closes: #477489
    Thanks to Justin B Rye for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* The kernel log input module for Linux. This file heavily
 
2
 * borrows from the klogd daemon provided by the sysklogd project.
 
3
 * Many thanks for this piece of software.
 
4
 *
 
5
 * Please note that this file replaces the klogd daemon that was
 
6
 * also present in pre-v3 versions of rsyslog.
 
7
 *
 
8
 * I have begun to convert this to an input module on 2007-12-17.
 
9
 * IMPORTANT: more than a single instance is currently not supported. This
 
10
 * needs to be revisited once the config file and input module interface
 
11
 * supports multiple instances!
 
12
 *
 
13
 * This file is part of rsyslog.
 
14
 *
 
15
 * Rsyslog is free software: you can redistribute it and/or modify
 
16
 * it under the terms of the GNU General Public License as published by
 
17
 * the Free Software Foundation, either version 3 of the License, or
 
18
 * (at your option) any later version.
 
19
 *
 
20
 * Rsyslog is distributed in the hope that it will be useful,
 
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
 * GNU General Public License for more details.
 
24
 *
 
25
 * You should have received a copy of the GNU General Public License
 
26
 * along with Rsyslog.  If not, see <http://www.gnu.org/licenses/>.
 
27
 *
 
28
 * A copy of the GPL can be found in the file "COPYING" in this distribution.
 
29
*/
 
30
#include "config.h"
 
31
#include "rsyslog.h"
 
32
#include <stdlib.h>
 
33
#include <stdio.h>
 
34
#include <assert.h>
 
35
#include <signal.h>
 
36
#include <string.h>
 
37
#include <pthread.h>
 
38
#include "syslogd.h"
 
39
#include "cfsysline.h"
 
40
#include "template.h"
 
41
#include "msg.h"
 
42
#include "module-template.h"
 
43
#include "imklog.h"
 
44
 
 
45
MODULE_TYPE_INPUT
 
46
 
 
47
/* Module static data */
 
48
DEF_IMOD_STATIC_DATA
 
49
 
 
50
/* configuration settings TODO: move to instance data? */
 
51
int dbgPrintSymbols = 0; /* this one is extern so the helpers can access it! */
 
52
static int symbols_twice = 0;
 
53
static int use_syscall = 0;
 
54
static int symbol_lookup = 1;
 
55
/* TODO: configuration for the following directives must be implemented. It 
 
56
 * was not done yet because we either do not yet have a config handler for
 
57
 * that type or I thought it was acceptable to push it to a later stage when
 
58
 * I gained more handson experience with the input module interface (and the
 
59
 * changes resulting from that). -- rgerhards, 2007-12-20
 
60
 */
 
61
static char *symfile = NULL; 
 
62
static int console_log_level = -1;
 
63
 
 
64
 
 
65
/* Includes. */
 
66
#include <unistd.h>
 
67
#include <errno.h>
 
68
#include <sys/fcntl.h>
 
69
#include <sys/stat.h>
 
70
 
 
71
#if HAVE_TIME_H
 
72
#       include <time.h>
 
73
#endif
 
74
 
 
75
#include <stdarg.h>
 
76
#include <paths.h>
 
77
#include "ksyms.h"
 
78
 
 
79
#define __LIBRARY__
 
80
#include <unistd.h>
 
81
 
 
82
 
 
83
#if !defined(__GLIBC__)
 
84
# define __NR_ksyslog __NR_syslog
 
85
_syscall3(int,ksyslog,int, type, char *, buf, int, len);
 
86
#else
 
87
#include <sys/klog.h>
 
88
#define ksyslog klogctl
 
89
#endif
 
90
 
 
91
 
 
92
 
 
93
#ifndef _PATH_KLOG
 
94
#define _PATH_KLOG  "/proc/kmsg"
 
95
#endif
 
96
 
 
97
#define LOG_BUFFER_SIZE 4096
 
98
#define LOG_LINE_LENGTH 1000
 
99
 
 
100
static int      kmsg;
 
101
static char     log_buffer[LOG_BUFFER_SIZE];
 
102
 
 
103
static enum LOGSRC {none, proc, kernel} logsrc;
 
104
 
 
105
 
 
106
 
 
107
/* Function prototypes. */
 
108
extern int ksyslog(int type, char *buf, int len);
 
109
 
 
110
 
 
111
/* Write a message to the message queue.
 
112
 * returns -1 if it fails, something else otherwise
 
113
 */
 
114
static rsRetVal writeSyslogV(int iPRI, const char *szFmt, va_list va)
 
115
{
 
116
        DEFiRet;
 
117
        int iChars;
 
118
        int iLen;
 
119
        time_t tNow;
 
120
        char msgBuf[2048]; /* we use the same size as sysklogd to remain compatible */
 
121
 
 
122
        assert(szFmt != NULL);
 
123
 
 
124
        /* build the message */
 
125
        time(&tNow);
 
126
        /* we can use sprintf safely below, because we know the size of the constants.
 
127
         * By doing so, we save some cpu cycles and code complexity (for unnecessary
 
128
         * error checking).
 
129
         */
 
130
        iLen = sprintf(msgBuf, "<%d>%.15s kernel: ", iPRI, ctime(&tNow) + 4);
 
131
 
 
132
        iChars = vsnprintf(msgBuf + iLen, sizeof(msgBuf) / sizeof(char) - iLen, szFmt, va);
 
133
 
 
134
        /* here we must create our message object and supply it to the message queue
 
135
         */
 
136
        CHKiRet(parseAndSubmitMessage(LocalHostName, msgBuf, strlen(msgBuf), MSG_DONT_PARSE_HOSTNAME, NOFLAG, eFLOWCTL_LIGHT_DELAY));
 
137
 
 
138
finalize_it:
 
139
        RETiRet;
 
140
}
 
141
 
 
142
/* And now the same with variable arguments */
 
143
static int writeSyslog(int iPRI, const char *szFmt, ...)
 
144
{
 
145
        int iRet;
 
146
        va_list va;
 
147
 
 
148
        assert(szFmt != NULL);
 
149
        va_start(va, szFmt);
 
150
        iRet = writeSyslogV(iPRI, szFmt, va);
 
151
        va_end(va);
 
152
 
 
153
        return(iRet);
 
154
}
 
155
 
 
156
rsRetVal Syslog(int priority, char *fmt, ...) __attribute__((format(printf,2, 3)));
 
157
rsRetVal Syslog(int priority, char *fmt, ...)
 
158
{
 
159
        DEFiRet;
 
160
        va_list ap;
 
161
        char *argl;
 
162
 
 
163
        /* Output using syslog. */
 
164
        if (!strcmp(fmt, "%s")) {
 
165
                va_start(ap, fmt);
 
166
                argl = va_arg(ap, char *);
 
167
                if (argl[0] == '<' && argl[1] && argl[2] == '>') {
 
168
                        switch ( argl[1] )
 
169
                        {
 
170
                        case '0':
 
171
                                priority = LOG_EMERG;
 
172
                                break;
 
173
                        case '1':
 
174
                                priority = LOG_ALERT;
 
175
                                break;
 
176
                        case '2':
 
177
                                priority = LOG_CRIT;
 
178
                                break;
 
179
                        case '3':
 
180
                                priority = LOG_ERR;
 
181
                                break;
 
182
                        case '4':
 
183
                                priority = LOG_WARNING;
 
184
                                break;
 
185
                        case '5':
 
186
                                priority = LOG_NOTICE;
 
187
                                break;
 
188
                        case '6':
 
189
                                priority = LOG_INFO;
 
190
                                break;
 
191
                        case '7':
 
192
                        default:
 
193
                                priority = LOG_DEBUG;
 
194
                        }
 
195
                        argl += 3;
 
196
                }
 
197
                iRet = writeSyslog(priority, fmt, argl);
 
198
                va_end(ap);
 
199
        } else {
 
200
                va_start(ap, fmt);
 
201
                iRet = writeSyslogV(priority, fmt, ap);
 
202
                va_end(ap);
 
203
        }
 
204
 
 
205
        RETiRet;
 
206
}
 
207
 
 
208
 
 
209
static void CloseLogSrc(void)
 
210
{
 
211
        /* Turn on logging of messages to console, but only if we had the -c
 
212
         * option -- rgerhards, 2007-08-01
 
213
         */
 
214
        if (console_log_level != -1)
 
215
                ksyslog(7, NULL, 0);
 
216
  
 
217
        /* Shutdown the log sources. */
 
218
        switch ( logsrc )
 
219
        {
 
220
            case kernel:
 
221
                ksyslog(0, 0, 0);
 
222
                Syslog(LOG_INFO, "Kernel logging (ksyslog) stopped.");
 
223
                break;
 
224
            case proc:
 
225
                close(kmsg);
 
226
                Syslog(LOG_INFO, "Kernel logging (proc) stopped.");
 
227
                break;
 
228
            case none:
 
229
                break;
 
230
        }
 
231
 
 
232
        return;
 
233
}
 
234
 
 
235
 
 
236
static enum LOGSRC GetKernelLogSrc(void)
 
237
{
 
238
        auto struct stat sb;
 
239
 
 
240
        /* Set level of kernel console messaging.. */
 
241
        if (   (console_log_level != -1) &&
 
242
               (ksyslog(8, NULL, console_log_level) < 0) &&
 
243
             (errno == EINVAL) )
 
244
        {
 
245
                /*
 
246
                 * An invalid arguement error probably indicates that
 
247
                 * a pre-0.14 kernel is being run.  At this point we
 
248
                 * issue an error message and simply shut-off console
 
249
                 * logging completely.
 
250
                 */
 
251
                Syslog(LOG_WARNING, "Cannot set console log level - disabling "
 
252
                       "console output.");
 
253
        }
 
254
 
 
255
        /*
 
256
         * First do a stat to determine whether or not the proc based
 
257
         * file system is available to get kernel messages from.
 
258
         */
 
259
        if ( use_syscall ||
 
260
            ((stat(_PATH_KLOG, &sb) < 0) && (errno == ENOENT)) )
 
261
        {
 
262
                /* Initialize kernel logging. */
 
263
                ksyslog(1, NULL, 0);
 
264
                Syslog(LOG_INFO, "imklogd %s, log source = ksyslog "
 
265
                       "started.", VERSION);
 
266
                return(kernel);
 
267
        }
 
268
 
 
269
        if ( (kmsg = open(_PATH_KLOG, O_RDONLY)) < 0 )
 
270
        {
 
271
                char sz[512];
 
272
                snprintf(sz, sizeof(sz), "imklog: Cannot open proc file system, %d - %s.\n", errno, strerror(errno));
 
273
                logmsgInternal(LOG_SYSLOG|LOG_ERR, sz, ADDDATE);
 
274
                ksyslog(7, NULL, 0); /* TODO: check this, implement more */
 
275
                return(none);
 
276
        }
 
277
 
 
278
        Syslog(LOG_INFO, "imklog %s, log source = %s started.", \
 
279
               VERSION, _PATH_KLOG);
 
280
        return(proc);
 
281
}
 
282
 
 
283
 
 
284
/*     Copy characters from ptr to line until a char in the delim
 
285
 *     string is encountered or until min( space, len ) chars have
 
286
 *     been copied.
 
287
 *
 
288
 *     Returns the actual number of chars copied.
 
289
 */
 
290
static int copyin( char *line,      int space,
 
291
                   const char *ptr, int len,
 
292
                   const char *delim )
 
293
{
 
294
    auto int i;
 
295
    auto int count;
 
296
 
 
297
    count = len < space ? len : space;
 
298
 
 
299
    for(i=0; i<count && !strchr(delim, *ptr); i++ ) {
 
300
        *line++ = *ptr++;
 
301
    }
 
302
 
 
303
    return(i);
 
304
}
 
305
 
 
306
/*
 
307
 * Messages are separated by "\n".  Messages longer than
 
308
 * LOG_LINE_LENGTH are broken up.
 
309
 *
 
310
 * Kernel symbols show up in the input buffer as : "[<aaaaaa>]",
 
311
 * where "aaaaaa" is the address.  These are replaced with
 
312
 * "[symbolname+offset/size]" in the output line - symbolname,
 
313
 * offset, and size come from the kernel symbol table.
 
314
 *
 
315
 * If a kernel symbol happens to fall at the end of a message close
 
316
 * in length to LOG_LINE_LENGTH, the symbol will not be expanded.
 
317
 * (This should never happen, since the kernel should never generate
 
318
 * messages that long.
 
319
 *
 
320
 * To preserve the original addresses, lines containing kernel symbols
 
321
 * are output twice.  Once with the symbols converted and again with the
 
322
 * original text.  Just in case somebody wants to run their own Oops
 
323
 * analysis on the syslog, e.g. ksymoops.
 
324
 */
 
325
static void LogLine(char *ptr, int len)
 
326
{
 
327
    enum parse_state_enum {
 
328
        PARSING_TEXT,
 
329
        PARSING_SYMSTART,      /* at < */
 
330
        PARSING_SYMBOL,        
 
331
        PARSING_SYMEND         /* at ] */
 
332
    };
 
333
 
 
334
    static char line_buff[LOG_LINE_LENGTH];
 
335
 
 
336
    static char *line                        =line_buff;
 
337
    static enum parse_state_enum parse_state = PARSING_TEXT;
 
338
    static int space                         = sizeof(line_buff)-1;
 
339
 
 
340
    static char *sym_start;            /* points at the '<' of a symbol */
 
341
 
 
342
    auto   int delta = 0;              /* number of chars copied        */
 
343
    auto   int symbols_expanded = 0;   /* 1 if symbols were expanded */
 
344
    auto   int skip_symbol_lookup = 0; /* skip symbol lookup on this pass */
 
345
    auto   char *save_ptr = ptr;       /* save start of input line */
 
346
    auto   int save_len = len;         /* save length at start of input line */
 
347
 
 
348
    while( len > 0 )
 
349
    {
 
350
        if( space == 0 )    /* line buffer is full */
 
351
        {
 
352
            /*
 
353
            ** Line too long.  Start a new line.
 
354
            */
 
355
            *line = 0;   /* force null terminator */
 
356
 
 
357
            dbgprintf("Line buffer full:\n");
 
358
            dbgprintf("\tLine: %s\n", line);
 
359
 
 
360
            Syslog( LOG_INFO, "%s", line_buff );
 
361
            line  = line_buff;
 
362
            space = sizeof(line_buff)-1;
 
363
            parse_state = PARSING_TEXT;
 
364
            symbols_expanded = 0;
 
365
            skip_symbol_lookup = 0;
 
366
            save_ptr = ptr;
 
367
            save_len = len;
 
368
        }
 
369
 
 
370
        switch( parse_state )
 
371
        {
 
372
        case PARSING_TEXT:
 
373
               delta = copyin( line, space, ptr, len, "\n[" );
 
374
               line  += delta;
 
375
               ptr   += delta;
 
376
               space -= delta;
 
377
               len   -= delta;
 
378
 
 
379
               if( space == 0 || len == 0 )
 
380
               {
 
381
                  break;  /* full line_buff or end of input buffer */
 
382
               }
 
383
 
 
384
               if( *ptr == '\0' )  /* zero byte */
 
385
               {
 
386
                  ptr++;        /* skip zero byte */
 
387
                  space -= 1;
 
388
                  len   -= 1;
 
389
 
 
390
                  break;
 
391
               }
 
392
 
 
393
               if( *ptr == '\n' )  /* newline */
 
394
               {
 
395
                  ptr++;        /* skip newline */
 
396
                  space -= 1;
 
397
                  len   -= 1;
 
398
 
 
399
                  *line = 0;  /* force null terminator */
 
400
                  Syslog( LOG_INFO, "%s", line_buff );
 
401
                  line  = line_buff;
 
402
                  space = sizeof(line_buff)-1;
 
403
                  if (symbols_twice) {
 
404
                      if (symbols_expanded) {
 
405
                          /* reprint this line without symbol lookup */
 
406
                          symbols_expanded = 0;
 
407
                          skip_symbol_lookup = 1;
 
408
                          ptr = save_ptr;
 
409
                          len = save_len;
 
410
                      }
 
411
                      else
 
412
                      {
 
413
                          skip_symbol_lookup = 0;
 
414
                          save_ptr = ptr;
 
415
                          save_len = len;
 
416
                      }
 
417
                  }
 
418
                  break;
 
419
               }
 
420
               if( *ptr == '[' )   /* possible kernel symbol */
 
421
               {
 
422
                  *line++ = *ptr++;
 
423
                  space -= 1;
 
424
                  len   -= 1;
 
425
                  if (!skip_symbol_lookup)
 
426
                     parse_state = PARSING_SYMSTART;      /* at < */
 
427
                  break;
 
428
               }
 
429
               /* Now that line_buff is no longer fed to *printf as format
 
430
                * string, '%'s are no longer "dangerous".
 
431
                */
 
432
               break;
 
433
        
 
434
        case PARSING_SYMSTART:
 
435
               if( *ptr != '<' )
 
436
               {
 
437
                  parse_state = PARSING_TEXT;        /* not a symbol */
 
438
                  break;
 
439
               }
 
440
 
 
441
               /*
 
442
               ** Save this character for now.  If this turns out to
 
443
               ** be a valid symbol, this char will be replaced later.
 
444
               ** If not, we'll just leave it there.
 
445
               */
 
446
 
 
447
               sym_start = line; /* this will point at the '<' */
 
448
 
 
449
               *line++ = *ptr++;
 
450
               space -= 1;
 
451
               len   -= 1;
 
452
               parse_state = PARSING_SYMBOL;     /* symbol... */
 
453
               break;
 
454
 
 
455
        case PARSING_SYMBOL:
 
456
               delta = copyin( line, space, ptr, len, ">\n[" );
 
457
               line  += delta;
 
458
               ptr   += delta;
 
459
               space -= delta;
 
460
               len   -= delta;
 
461
               if( space == 0 || len == 0 )
 
462
               {
 
463
                  break;  /* full line_buff or end of input buffer */
 
464
               }
 
465
               if( *ptr != '>' )
 
466
               {
 
467
                  parse_state = PARSING_TEXT;
 
468
                  break;
 
469
               }
 
470
 
 
471
               *line++ = *ptr++;  /* copy the '>' */
 
472
               space -= 1;
 
473
               len   -= 1;
 
474
 
 
475
               parse_state = PARSING_SYMEND;
 
476
 
 
477
               break;
 
478
 
 
479
        case PARSING_SYMEND:
 
480
               if( *ptr != ']' )
 
481
               {
 
482
                  parse_state = PARSING_TEXT;        /* not a symbol */
 
483
                  break;
 
484
               }
 
485
 
 
486
               /*
 
487
               ** It's really a symbol!  Replace address with the
 
488
               ** symbol text.
 
489
               */
 
490
           {
 
491
               auto int sym_space;
 
492
 
 
493
               unsigned long value;
 
494
               auto struct symbol sym;
 
495
               auto char *symbol;
 
496
 
 
497
               *(line-1) = 0;    /* null terminate the address string */
 
498
               value  = strtoul(sym_start+1, (char **) 0, 16);
 
499
               *(line-1) = '>';  /* put back delim */
 
500
 
 
501
               if ( !symbol_lookup || (symbol = LookupSymbol(value, &sym)) == (char *)0 )
 
502
               {
 
503
                  parse_state = PARSING_TEXT;
 
504
                  break;
 
505
               }
 
506
 
 
507
               /*
 
508
               ** verify there is room in the line buffer
 
509
               */
 
510
               sym_space = space + ( line - sym_start );
 
511
               if( (unsigned) sym_space < strlen(symbol) + 30 ) /*(30 should be overkill)*/
 
512
               {
 
513
                  parse_state = PARSING_TEXT;  /* not enough space */
 
514
                  break;
 
515
               }
 
516
 
 
517
               delta = sprintf( sym_start, "%s+%d/%d]",
 
518
                                symbol, sym.offset, sym.size );
 
519
 
 
520
               space = sym_space + delta;
 
521
               line  = sym_start + delta;
 
522
               symbols_expanded = 1;
 
523
           }
 
524
               ptr++;
 
525
               len--;
 
526
               parse_state = PARSING_TEXT;
 
527
               break;
 
528
 
 
529
        default: /* Can't get here! */
 
530
               parse_state = PARSING_TEXT;
 
531
 
 
532
        }
 
533
    }
 
534
 
 
535
    return;
 
536
}
 
537
 
 
538
 
 
539
static void LogKernelLine(void)
 
540
{
 
541
        auto int rdcnt;
 
542
 
 
543
        /*
 
544
         * Zero-fill the log buffer.  This should cure a multitude of
 
545
         * problems with klogd logging the tail end of the message buffer
 
546
         * which will contain old messages.  Then read the kernel log
 
547
         * messages into this fresh buffer.
 
548
         */
 
549
        memset(log_buffer, '\0', sizeof(log_buffer));
 
550
        if ( (rdcnt = ksyslog(2, log_buffer, sizeof(log_buffer)-1)) < 0 )
 
551
        {
 
552
                char sz[512];
 
553
                if(errno == EINTR)
 
554
                        return;
 
555
                snprintf(sz, sizeof(sz), "imklog: Error return from sys_sycall: %d - %s\n", errno, strerror(errno));
 
556
                logmsgInternal(LOG_SYSLOG|LOG_ERR, sz, ADDDATE);
 
557
        }
 
558
        else
 
559
                LogLine(log_buffer, rdcnt);
 
560
        return;
 
561
}
 
562
 
 
563
 
 
564
static void LogProcLine(void)
 
565
{
 
566
        auto int rdcnt;
 
567
 
 
568
        /*
 
569
         * Zero-fill the log buffer.  This should cure a multitude of
 
570
         * problems with klogd logging the tail end of the message buffer
 
571
         * which will contain old messages.  Then read the kernel messages
 
572
         * from the message pseudo-file into this fresh buffer.
 
573
         */
 
574
        memset(log_buffer, '\0', sizeof(log_buffer));
 
575
        if ( (rdcnt = read(kmsg, log_buffer, sizeof(log_buffer)-1)) < 0 )
 
576
        {
 
577
                if ( errno == EINTR )
 
578
                        return;
 
579
                Syslog(LOG_ERR, "Cannot read proc file system: %d - %s.", errno, strerror(errno));
 
580
        }
 
581
        else
 
582
                LogLine(log_buffer, rdcnt);
 
583
 
 
584
        return;
 
585
}
 
586
 
 
587
 
 
588
BEGINrunInput
 
589
CODESTARTrunInput
 
590
        /* this is an endless loop - it is terminated when the thread is
 
591
         * signalled to do so. This, however, is handled by the framework,
 
592
         * right into the sleep below.
 
593
         */
 
594
        while(!pThrd->bShallStop) {
 
595
                /* we do not need to handle the RS_RET_TERMINATE_NOW case any
 
596
                 * special because we just need to terminate. This may be different
 
597
                 * if a cleanup is needed. But for now, we can just use CHKiRet().
 
598
                 * rgerhards, 2007-12-17
 
599
                 */
 
600
                switch ( logsrc )
 
601
                {
 
602
                        case kernel:
 
603
                                LogKernelLine();
 
604
                                break;
 
605
                        case proc:
 
606
                                LogProcLine();
 
607
                                break;
 
608
                        case none:
 
609
                                /* TODO: We need to handle this case here somewhat more intelligent 
 
610
                                 * This is now at least partly done - code should never reach this point
 
611
                                 * as willRun() already checked for the "none" status -- rgerhards, 2007-12-17
 
612
                                 */
 
613
                                pause();
 
614
                                break;
 
615
                }
 
616
        }
 
617
        RETiRet;
 
618
ENDrunInput
 
619
 
 
620
 
 
621
BEGINwillRun
 
622
        /* Initialize this module. If that fails, we tell the engine we don't like to run */
 
623
        /* Determine where kernel logging information is to come from. */
 
624
        logsrc = GetKernelLogSrc();
 
625
        if(logsrc == none) {
 
626
                iRet = RS_RET_NO_KERNEL_LOGSRC;
 
627
        } else {
 
628
                if (symbol_lookup) {
 
629
                        symbol_lookup  = (InitKsyms(symfile) == 1);
 
630
                        symbol_lookup |= InitMsyms();
 
631
                        if (symbol_lookup == 0) {
 
632
                                Syslog(LOG_WARNING, "cannot find any symbols, turning off symbol lookups\n");
 
633
                        }
 
634
                }
 
635
        }
 
636
CODESTARTwillRun
 
637
ENDwillRun
 
638
 
 
639
 
 
640
BEGINafterRun
 
641
CODESTARTafterRun
 
642
        /* cleanup here */
 
643
        if(logsrc != none)
 
644
                CloseLogSrc();
 
645
 
 
646
        DeinitKsyms();
 
647
        DeinitMsyms();
 
648
ENDafterRun
 
649
 
 
650
 
 
651
BEGINmodExit
 
652
CODESTARTmodExit
 
653
ENDmodExit
 
654
 
 
655
 
 
656
BEGINqueryEtryPt
 
657
CODESTARTqueryEtryPt
 
658
CODEqueryEtryPt_STD_IMOD_QUERIES
 
659
ENDqueryEtryPt
 
660
 
 
661
static rsRetVal resetConfigVariables(uchar __attribute__((unused)) *pp, void __attribute__((unused)) *pVal)
 
662
{
 
663
        dbgPrintSymbols = 0;
 
664
        symbols_twice = 0;
 
665
        use_syscall = 0;
 
666
        symfile = NULL;
 
667
        symbol_lookup = 1;
 
668
        return RS_RET_OK;
 
669
}
 
670
 
 
671
BEGINmodInit()
 
672
CODESTARTmodInit
 
673
        *ipIFVersProvided = CURR_MOD_IF_VERSION; /* we only support the current interface specification */
 
674
CODEmodInit_QueryRegCFSLineHdlr
 
675
        CHKiRet(omsdRegCFSLineHdlr((uchar *)"debugprintkernelsymbols", 0, eCmdHdlrBinary, NULL, &dbgPrintSymbols, STD_LOADABLE_MODULE_ID));
 
676
        CHKiRet(omsdRegCFSLineHdlr((uchar *)"klogsymbollookup", 0, eCmdHdlrBinary, NULL, &symbol_lookup, STD_LOADABLE_MODULE_ID));
 
677
        CHKiRet(omsdRegCFSLineHdlr((uchar *)"klogsymbolstwice", 0, eCmdHdlrBinary, NULL, &symbols_twice, STD_LOADABLE_MODULE_ID));
 
678
        CHKiRet(omsdRegCFSLineHdlr((uchar *)"klogusesyscallinterface", 0, eCmdHdlrBinary, NULL, &use_syscall, STD_LOADABLE_MODULE_ID));
 
679
        CHKiRet(omsdRegCFSLineHdlr((uchar *)"resetconfigvariables", 1, eCmdHdlrCustomHandler, resetConfigVariables, NULL, STD_LOADABLE_MODULE_ID));
 
680
ENDmodInit
 
681
/*
 
682
 * Local variables:
 
683
 *  c-indent-level: 8
 
684
 *  c-basic-offset: 8
 
685
 *  tab-width: 8
 
686
 * End:
 
687
 * vi:set ai:
 
688
 */