This file is indexed.

/usr/src/blcr-0.8.5/vmadump4/vmadlib.c is in blcr-dkms 0.8.5-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*-------------------------------------------------------------------------
 *  vmadlib.c: vmadump library management program
 *
 *  Copyright (C) 1999-2001 by Erik Hendriks <erik@hendriks.cx>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * $Id: vmadlib.c,v 1.3 2004/12/07 22:20:35 phargrov Exp $
 *-----------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <syscall.h>
#include <limits.h>

#include "vmadump.h"

void usage(char *arg0) {
    printf(
"Usage: %s -c\n"
"       %s -a [libs...] \n"
"       %s -d [libs...] \n"
"       %s -l\n"
"\n"
"       This program manages the VMAdump in-kernel library list.\n"
"       -h            Display this message and exit.\n"
"       -v            Display version information and exit.\n"
"       -c            Clear kernel library list.\n"
"       -a [libs...]  Add to the kernel library list.\n"
"       -d [libs...]  Delete from the kernel library list.\n"
"       -l            Print the contents of the kernel library list.\n",
        arg0, arg0, arg0, arg0);
}

enum { MODE_CLEAR, MODE_ADD, MODE_DEL, MODE_LIST };

#ifdef __NR_vmadump
static
void add_lib(char *libname) {
    if (syscall(__NR_vmadump, VMAD_LIB_ADD, libname) == -1) {
	perror(libname);
	exit(1);
    }
}

static
void remove_lib(char *libname) {
    if (syscall(__NR_vmadump, VMAD_LIB_DEL, libname) == -1) {
	perror(libname);
	/*exit(1);*/
    }
}
static
void clear_libs(void) {
    if (syscall(__NR_vmadump, VMAD_LIB_CLEAR) == -1) {
	perror("VMAD_LIB_CLEAR");
	exit(1);
    }
}
#else

static
void add_lib(char *libname) {
    if (bproc_libadd(libname)) {
	perror(libname);
	exit(1);
    }
}
static
void remove_lib(char *libname) {
    if (bproc_libdel(libname)) {
	perror(libname);
    }
}
static
void clear_libs(vois) {
    if (bproc_libclear()) {
	perror("VMAD_LIB_CLEAR");
	exit(1);
    }
}
#endif


static
void remove_trailing_newline(char *line) {
    int len;
    len = strlen(line);
    if (line[len-1] == '\n') line[len-1] = 0;
}

int main(int argc, char *argv[]) {
    int c,i;
    int mode = -1;
    int len;
    char buf[PATH_MAX];
    char *listbuf, *p;
    
    while((c=getopt(argc, argv, "hvclad")) != EOF) {
	switch(c) {
	case 'h': usage(argv[0]); exit(0);
	case 'v': printf("%s version %s\n", argv[0], PACKAGE_VERSION); exit(0);
	case 'c': mode = MODE_CLEAR; break;
	case 'l': mode = MODE_LIST; break;
	case 'a': mode = MODE_ADD; break;
	case 'd': mode = MODE_DEL; break;
	default: exit(1);
	}
    }

    switch(mode) {
    case MODE_CLEAR:
	if (argc - optind != 0) {
	    fprintf(stderr, "No library names allowed with -c\n");
	    exit(1);
	}
	clear_libs();
	break;
    case MODE_ADD:
	for (i=optind; i < argc; i++) {
	    if (strcmp(argv[i], "-") == 0) {
		while (fgets(buf, PATH_MAX, stdin)) {
		    remove_trailing_newline(buf);
		    add_lib(buf);
		}
	    } else
		add_lib(argv[i]);
	}
	break;
    case MODE_DEL:
	for (i=optind; i < argc; i++) {
	    if (strcmp(argv[i], "-") == 0) {
		while (fgets(buf, PATH_MAX, stdin)) {
		    remove_trailing_newline(buf);
		    remove_lib(buf);
		}
	    } else {
		remove_lib(argv[i]);
	    }
	}
	break;
    case MODE_LIST:
	len = syscall(__NR_vmadump, VMAD_LIB_SIZE);
	if (len == -1) {
	    perror("VMAD_LIB_SIZE");
	    exit(1);
	}
	listbuf = malloc(len);
	if (!listbuf) {
	    fprintf(stderr, "Out of memory.\n");
	    exit(1);
	}
	if (syscall(__NR_vmadump, VMAD_LIB_LIST, listbuf, len) == -1) {
	    perror("VMAD_LIB_LIST");
	    exit(1);
	}
	/* print out the null delimited list of libraries */
	for (p = listbuf; *p; p += strlen(p)+1)
	    printf("%s\n", p);
	break;
    default:
	usage(argv[0]);
    }
    exit(0);
}
/*
 * Local variables:
 * c-basic-offset: 4
 * End:
 */