This file is indexed.

/usr/src/blcr-0.8.2/vmadump4/vmadstress.c is in blcr-dkms 0.8.2-15ubuntu2.

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
/*-------------------------------------------------------------------------
 *  vmadtest.c: vmadump test 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: vmadstress.c,v 1.3 2004/12/07 22:20:35 phargrov Exp $
 *-----------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <errno.h>

#include "vmadump.h"

#define GROWCHUNK 10240

#define DEFAULT_FILE "dump"
#if HAVE_BINFMT_VMADUMP
#define DUMPMODE 0777
#else
#define DUMPMODE 0666
#endif

#ifdef __NR_vmadump
int vmadump(int fd, int flags) {
    return syscall(__NR_vmadump, VMAD_DO_DUMP, fd, flags);
}

int vmaundump(int fd) {
    return syscall(__NR_vmadump, VMAD_DO_UNDUMP, fd);
}

#else
#include <sys/bproc.h>
int vmadump(int fd, int flags) {
    return bproc_dump(fd, flags);
}

int vmaundump(int fd) {
    return bproc_undump(fd);
}
#endif


void test_mm(void) {
    fprintf(stderr, "Testing basic memory ops like growing my stack\n"
	    "and malloc'ing new RAM.\n");
    while(1) {
	char *foo;
	foo = alloca(GROWCHUNK);
	memset(foo, 0, GROWCHUNK);
	fprintf(stderr, "."); fflush(stderr);
	
	foo = malloc(GROWCHUNK);
	memset(foo, 0, GROWCHUNK);
	fprintf(stderr, "+"); fflush(stderr);
	
	sleep(1);		/* lets not use all memory instantly, ok? */
    }
}

int do_dump(char *filename, int flags) {
    int fd, r;
    fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, DUMPMODE);
    if (fd == -1) { perror("open"); exit(1); }
    r = vmadump(fd,flags);
    if (r == -1) {
	perror("VMAD_DO_DUMP");
	exit(1);
    }
    close(fd);
    return r;
}

void do_undump(char *filename) {
    int fd, r;
    fd = open(filename, O_RDONLY);
    if (fd == -1) { perror("open"); exit(1); }
    r = vmaundump(fd);
    /* not reached if no error */
    perror("VMAD_DO_DUMP");
    exit(1);
}

void usage(char *arg0) {
    printf(
"Usage: %s -d [-f file] [-e] [-l] [-o]\n"
"       %s -u [-f file]\n"
"\n"
"       This program is a simple test program for the Beowulf VMAdump\n"
"       system.  It will try to dump itself (with -d) or restore a dump\n"
"       with -u.\n"
"\n"
"       -f file    Dump to/from file instead of the default (%s)\n"
"\n"
"       The following options only affect dumping.  (-d)\n"
"       -e         Use VMAD_DUMP_EXEC flag.\n"
"       -l         Use VMAD_DUMP_LIBS flag.\n"
"       -o         Use VMAD_DUMP_OTHER flag.\n"
, arg0, arg0, DEFAULT_FILE);
}

int main(int argc, char *argv[]) {
    int c;
    int dump_flags = 0;
    char *filename = DEFAULT_FILE;
    
    while ((c=getopt(argc, argv, "hvf:elo")) != EOF) {
	switch (c) {
	case 'h':
	case 'v': usage(argv[0]); exit(0);
	case 'f': filename = optarg; break;
	case 'e': dump_flags |= VMAD_DUMP_EXEC; break;
	case 'l': dump_flags |= VMAD_DUMP_LIBS; break;
	case 'o': dump_flags |= VMAD_DUMP_OTHER; break;
	default: exit(1);
	}
    }

    while (1) {
	int r;
	printf("Doing vmadump(\"%s\", 0x%x)=", filename, dump_flags); fflush(stdout);
	r = do_dump(filename, dump_flags);
	if (r > 0) {
	    printf("%d\n", r);
	    printf("Doing vmaundump(\"%s\")\n", filename);
	    fflush(stdout);
	    do_undump(filename);
	    /* not reached */
	}
	close(3); /* hack to deal with the lack of close_on_exec */
    }
}

/*
 * Local variables:
 * c-basic-offset: 4
 * End:
 */