File: prfile.c

package info (click to toggle)
linux 3.16.56-1+deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 739,780 kB
  • sloc: ansic: 12,238,760; asm: 277,795; perl: 53,071; xml: 47,771; makefile: 30,548; sh: 7,977; python: 6,699; cpp: 5,132; yacc: 4,254; lex: 2,215; awk: 741; pascal: 231; lisp: 218; sed: 30
file content (86 lines) | stat: -rw-r--r-- 2,093 bytes parent folder | download | duplicates (10)
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
/*
 * Mainly for aufs which mmap(2) diffrent file and wants to print different path
 * in /proc/PID/maps.
 * Call these functions via macros defined in linux/mm.h.
 *
 * See Documentation/filesystems/aufs/design/06mmap.txt
 *
 * Copyright (c) 2014 Junjro R. Okajima
 * Copyright (c) 2014 Ian Campbell
 */

#include <linux/mm.h>
#include <linux/file.h>
#include <linux/fs.h>

/* #define PRFILE_TRACE */
static inline void prfile_trace(struct file *f, struct file *pr,
			      const char func[], int line, const char func2[])
{
#ifdef PRFILE_TRACE
	if (pr)
		pr_info("%s:%d: %s, %p\n", func, line, func2,
			f ? (char *)f->f_dentry->d_name.name : "(null)");
#endif
}

#ifdef CONFIG_MMU
void vma_do_file_update_time(struct vm_area_struct *vma, const char func[],
			     int line)
{
	struct file *f = vma->vm_file, *pr = vma->vm_prfile;

	prfile_trace(f, pr, func, line, __func__);
	file_update_time(f);
	if (f && pr)
		file_update_time(pr);
}

struct file *vma_do_pr_or_file(struct vm_area_struct *vma, const char func[],
			       int line)
{
	struct file *f = vma->vm_file, *pr = vma->vm_prfile;

	prfile_trace(f, pr, func, line, __func__);
	return (f && pr) ? pr : f;
}

void vma_do_get_file(struct vm_area_struct *vma, const char func[], int line)
{
	struct file *f = vma->vm_file, *pr = vma->vm_prfile;

	prfile_trace(f, pr, func, line, __func__);
	get_file(f);
	if (f && pr)
		get_file(pr);
}

void vma_do_fput(struct vm_area_struct *vma, const char func[], int line)
{
	struct file *f = vma->vm_file, *pr = vma->vm_prfile;

	prfile_trace(f, pr, func, line, __func__);
	fput(f);
	if (f && pr)
		fput(pr);
}
#else
struct file *vmr_do_pr_or_file(struct vm_region *region, const char func[],
			       int line)
{
	struct file *f = region->vm_file, *pr = region->vm_prfile;

	prfile_trace(f, pr, func, line, __func__);
	return (f && pr) ? pr : f;
}

void vmr_do_fput(struct vm_region *region, const char func[], int line)
{
	struct file *f = region->vm_file, *pr = region->vm_prfile;

	prfile_trace(f, pr, func, line, __func__);
	fput(f);
	if (f && pr)
		fput(pr);
}
#endif /* CONFIG_MMU */