XenevaOS
Loading...
Searching...
No Matches
path.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef _LINUX_PATH_H
3#define _LINUX_PATH_H
4
5struct dentry;
6struct vfsmount;
7
8struct path {
9 struct vfsmount *mnt;
10 struct dentry *dentry;
11};
12
13extern void path_get(const struct path *);
14extern void path_put(const struct path *);
15
16/*
17 * d_path(path, buf, buflen) -- declared here rather than in mainline's home,
18 * <linux/dcache.h>, and the relocation is a consequence of this tree's header
19 * set rather than a preference.
20 *
21 * The only caller is lib/seq_buf.c:322, whose include list is bug.h, err.h,
22 * export.h, hex.h, minmax.h, printk.h, seq_buf.h, seq_file.h, sprintf.h,
23 * string.h, types.h and uaccess.h -- none of which is dcache.h. <linux/seq_buf.h>
24 * includes *this* header (for seq_buf_path()'s parameter), so a declaration
25 * here is the one that reaches that caller. Mainline needs no such care: its
26 * dcache.h is reached from mm.h, which is in every translation unit.
27 *
28 * A declaration and not a definition: the body is in DCL/linux_cdev_shim.c,
29 * beside the other fs-layer fops helpers, because it needs a struct file and
30 * this header deliberately forward-declares rather than defines dentries.
31 *
32 * Declared in DCL/linux_cdev_shim.c too, where the definition is, so the two
33 * cannot drift apart -- an identical redeclaration of a function is legal in
34 * C and this is the one place it is done on purpose.
35 */
36char *d_path(const struct path *path, char *buf, int buflen);
37
38static inline int path_equal(const struct path *path1, const struct path *path2)
39{
40 return path1->mnt == path2->mnt && path1->dentry == path2->dentry;
41}
42
43/*
44 * Cleanup macro for use with __free(path_put). Avoids dereference and
45 * copying @path unlike DEFINE_FREE(). path_put() will handle the empty
46 * path correct just ensure @path is initialized:
47 *
48 * struct path path __free(path_put) = {};
49 */
50#define __free_path_put path_put
51
52#endif /* _LINUX_PATH_H */
void path_put(const struct path *)
void path_get(const struct path *)
char * d_path(const struct path *path, char *buf, int buflen)
Definition path.h:8
struct dentry * dentry
Definition path.h:10
struct vfsmount * mnt
Definition path.h:9
Definition mount.h:53