]>
git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blob - mm/prfile.c
1 // SPDX-License-Identifier: GPL-2.0
3 * Mainly for aufs which mmap(2) different file and wants to print different
4 * path in /proc/PID/maps.
5 * Call these functions via macros defined in linux/mm.h.
7 * See Documentation/filesystems/aufs/design/06mmap.txt
9 * Copyright (c) 2014-2020 Junjro R. Okajima
10 * Copyright (c) 2014 Ian Campbell
14 #include <linux/file.h>
17 /* #define PRFILE_TRACE */
18 static inline void prfile_trace(struct file
*f
, struct file
*pr
,
19 const char func
[], int line
, const char func2
[])
23 pr_info("%s:%d: %s, %pD2\n", func
, line
, func2
, f
);
27 void vma_do_file_update_time(struct vm_area_struct
*vma
, const char func
[],
30 struct file
*f
= vma
->vm_file
, *pr
= vma
->vm_prfile
;
32 prfile_trace(f
, pr
, func
, line
, __func__
);
38 struct file
*vma_do_pr_or_file(struct vm_area_struct
*vma
, const char func
[],
41 struct file
*f
= vma
->vm_file
, *pr
= vma
->vm_prfile
;
43 prfile_trace(f
, pr
, func
, line
, __func__
);
44 return (f
&& pr
) ? pr
: f
;
47 void vma_do_get_file(struct vm_area_struct
*vma
, const char func
[], int line
)
49 struct file
*f
= vma
->vm_file
, *pr
= vma
->vm_prfile
;
51 prfile_trace(f
, pr
, func
, line
, __func__
);
57 void vma_do_fput(struct vm_area_struct
*vma
, const char func
[], int line
)
59 struct file
*f
= vma
->vm_file
, *pr
= vma
->vm_prfile
;
61 prfile_trace(f
, pr
, func
, line
, __func__
);
68 struct file
*vmr_do_pr_or_file(struct vm_region
*region
, const char func
[],
71 struct file
*f
= region
->vm_file
, *pr
= region
->vm_prfile
;
73 prfile_trace(f
, pr
, func
, line
, __func__
);
74 return (f
&& pr
) ? pr
: f
;
77 void vmr_do_fput(struct vm_region
*region
, const char func
[], int line
)
79 struct file
*f
= region
->vm_file
, *pr
= region
->vm_prfile
;
81 prfile_trace(f
, pr
, func
, line
, __func__
);
86 #endif /* !CONFIG_MMU */