File: cr_proc.c

package info (click to toggle)
blcr 0.8.5-2.2
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 10,728 kB
  • ctags: 3,413
  • sloc: ansic: 31,999; sh: 12,633; makefile: 929; perl: 401; cpp: 79; java: 9
file content (79 lines) | stat: -rw-r--r-- 2,299 bytes parent folder | download | duplicates (4)
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
/*
 * Berkeley Lab Checkpoint/Restart (BLCR) for Linux is Copyright (c)
 * 2008, 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: cr_proc.c,v 1.19 2008/06/19 07:47:57 phargrov Exp $
 */

#include "cr_module.h"

#include <linux/proc_fs.h>
#include <linux/init.h>


/*
 * Our proc_fs entries
 */
static struct proc_dir_entry *proc_checkpoint;
static struct proc_dir_entry *proc_ctrl;

/**
 * cr_proc_init - Initialization code
 *
 * DESCRIPTION:
 * This function registers /proc/checkpoint and /proc/checkpoint/ctrl
 */
int __init cr_proc_init(void)
{
	CR_KTRACE_FUNC_ENTRY();

	proc_checkpoint = create_proc_entry("checkpoint", S_IFDIR, cr_proc_root);
	if (proc_checkpoint == NULL) {
		CR_ERR("proc_create_entry(/proc/checkpoint/) failed");
		return -ENOMEM;
	}

	proc_ctrl = create_proc_entry("ctrl", S_IFREG | S_IRUGO | S_IWUGO,
				      proc_checkpoint);
	if (proc_ctrl == NULL) {
		CR_ERR("proc_create_entry(/proc/checkpoint/ctrl) failed");
		return -ENOMEM;
	}

	proc_ctrl->proc_fops = &cr_ctrl_fops;

	return 0;
}

/**
 * cr_proc_cleanup - Initialization code
 *
 * DESCRIPTION:
 * This function removes /proc/checkpoint and /proc/checkpoint/ctrl
 */
void cr_proc_cleanup(void)
{
	CR_KTRACE_FUNC_ENTRY();

	remove_proc_entry("ctrl", proc_checkpoint);
	remove_proc_entry("checkpoint", cr_proc_root);
}