File: proc_fs_compatibility.h

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (75 lines) | stat: -rw-r--r-- 2,228 bytes parent folder | download | duplicates (2)
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
/* -*- linux-c -*-
 *
 * procfs compatibility defines and functions
 * Copyright (C) 2013 Red Hat Inc.
 *
 * This file is part of systemtap, and is free software.  You can
 * redistribute it and/or modify it under the terms of the GNU General
 * Public License (GPL); either version 2, or (at your option) any
 * later version.
 */

#ifndef _STP_PROC_FS_COMPATIBILITY_H_
#define _STP_PROC_FS_COMPATIBILITY_H_

#include <linux/proc_fs.h>

/* If STAPCONF_PDE_DATA isn't defined, we're using the original /proc
 * interface (where 'struct proc_dir_entry' isn't opaque). Provide
 * some of the new interface's functions. */
#if !defined(STAPCONF_PDE_DATA) && !defined(STAPCONF_PDE_DATA2)

#ifndef STAPCONF_LINUX_UIDGID_H
static void proc_set_user(struct proc_dir_entry *de, uid_t uid, gid_t gid)
{
	de->uid = uid;
	de->gid = gid;
}
#else
static void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid)
{
	de->uid = __kuid_val(uid);
	de->gid = __kgid_val(gid);
}
#endif

// 2.6.24 fixed proc_dir_entry refcounting.
#define LAST_ENTRY_COUNT 1

/* Notice that this proc_remove() compatibility function isn't
 * exactly like the original, since it can remove entire
 * subtrees. Since we don't call proc_remove() to remove subtrees,
 * this is OK. */
static void proc_remove(struct proc_dir_entry *de)
{
	if (de && de->subdir == NULL) {
		if (atomic_read(&de->count) != LAST_ENTRY_COUNT)
			printk(KERN_ERR "Removal of %s from /proc"
			       " is deferred until it is no longer in use.\n"
			       "Systemtap module removal will block.\n",
			       de->name);
		remove_proc_entry(de->name, de->parent);
	}
}

/* The 'proc_create_data()' function was present before the new /proc
 * interface make 'struct proc_dir_entry' opaque. */
#ifndef STAPCONF_PROC_CREATE_DATA
static struct proc_dir_entry *
proc_create_data(const char *name, umode_t mode,
		 struct proc_dir_entry *parent,
		 const struct file_operations *proc_fops, void *data)
{
	struct proc_dir_entry *de;
	de = proc_create(name, mode, parent, proc_fops);
	if (de)
		de->data = data;
	return de;
}
#endif  /* STAPCONF_PROC_CREATE_DATA */

#define PDE_DATA(inode) (PDE(inode)->data)

#endif  /* STAPCONF_PDE_DATA */

#endif	/* _STP_PROC_FS_COMPATIBILITY_H_ */