This file is indexed.

/usr/src/blcr-0.8.2/tests/cwd.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*
 * Berkeley Lab Checkpoint/Restart (BLCR) for Linux is Copyright (c)
 * 2003, The Regents of the University of California, through Lawrence
 * Berkeley National Laboratory (subject to receipt of any required
 * approvals from the U.S. Dept. of Energy).  All rights reserved.
 *
 * Portions may be copyrighted by others, as may be noted in specific
 * copyright notices within specific files.
 *
 * 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: cwd.c,v 1.7 2008/08/29 21:36:53 phargrov Exp $
 *
 * Simple example for using crut
 */

#ifndef _GNU_SOURCE
  #define _GNU_SOURCE // for get_current_dir_name() in unistd
#endif

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>

#include <linux/limits.h>

#include "crut.h"

#define TMP_DIR_NAME "tstdir"
#define TMP_DIR_MODE 0755

char checkpoint_cwd[PATH_MAX+1];

static int
cwd_setup(void **testdata)
{
    int retval;

    (void)rmdir(TMP_DIR_NAME);

    retval = mkdir(TMP_DIR_NAME, TMP_DIR_MODE);
    if (retval < 0) {
	perror("mkdir");
        goto out;
    }

    retval = chdir(TMP_DIR_NAME);
    if (retval < 0) {
	perror("mkdir");
        goto out;
    }

    if (getcwd(checkpoint_cwd, sizeof(checkpoint_cwd)) == NULL) {
	perror("getcwd");
        goto out_unlink;
    }
    retval = 0;
    *testdata = NULL;

    return retval;

out_unlink:
    if (unlink(TMP_DIR_NAME) < 0) {
	perror("unlink");
	retval = -1;
    }
out:
    return retval;
}

static int
cwd_precheckpoint(void *p)
{
    return 0;
}

static int
cwd_continue(void *p)
{
    return 0;
}

static int
cwd_restart(void *p)
{
    int retval = -1;
    char new_cwd[PATH_MAX+1];

    if (getcwd(new_cwd, PATH_MAX) == NULL) {
	perror("getcwd");
        goto out;
    }

    if (strncmp(checkpoint_cwd, new_cwd, sizeof(checkpoint_cwd))) {
	CRUT_FAIL("Did not restore cwd %s", checkpoint_cwd);
	retval = -1;
    } else {
	retval = 0;
    }

out:
    return retval;
}

static int
cwd_teardown(void *p)
{
    int retval;

    /* go back to where we started */
    retval = chdir("..");
    CRUT_DEBUG("cwd = %s", get_current_dir_name());
    if (retval < 0) {
        perror("chdir");
	goto out;
    }

    /* now kill the test directory */
retry:
    retval = rmdir(TMP_DIR_NAME);
    if (retval < 0) {
        CRUT_FAIL("rmdir(%s): %s", TMP_DIR_NAME, strerror(errno));
	// XXX
        sync();
	goto retry;
	goto out;
    }

    retval = 0;

out:
    return retval;
}

int
main(int argc, char *argv[])
{
    int ret;
    struct crut_operations cwd_test_ops = {
	test_scope:CR_SCOPE_PROC,
	test_name:"cwd_rw",
        test_description:"Simple example test.",
	test_setup:cwd_setup,
	test_precheckpoint:cwd_precheckpoint,
	test_continue:cwd_continue,
	test_restart:cwd_restart,
	test_teardown:cwd_teardown,
    };

    /* add the basic tests */
    crut_add_test(&cwd_test_ops);

    ret = crut_main(argc, argv);

    return ret;
}