Blame view

fs/kernfs/kernfs-internal.h 3.46 KB
55716d264   Thomas Gleixner   treewide: Replace...
1
  /* SPDX-License-Identifier: GPL-2.0-only */
ae6621b07   Tejun Heo   sysfs, kernfs: mo...
2
3
4
5
6
7
  /*
   * fs/kernfs/kernfs-internal.h - kernfs internal header file
   *
   * Copyright (c) 2001-3 Patrick Mochel
   * Copyright (c) 2007 SUSE Linux Products GmbH
   * Copyright (c) 2007, 2013 Tejun Heo <teheo@suse.de>
ae6621b07   Tejun Heo   sysfs, kernfs: mo...
8
9
10
11
12
13
14
   */
  
  #ifndef __KERNFS_INTERNAL_H
  #define __KERNFS_INTERNAL_H
  
  #include <linux/lockdep.h>
  #include <linux/fs.h>
fd7b9f7b9   Tejun Heo   sysfs, kernfs: mo...
15
  #include <linux/mutex.h>
2322392b0   Tejun Heo   kernfs: implement...
16
  #include <linux/xattr.h>
ae6621b07   Tejun Heo   sysfs, kernfs: mo...
17
18
  
  #include <linux/kernfs.h>
23bf1b6be   David Howells   kernfs, sysfs, cg...
19
  #include <linux/fs_context.h>
ae6621b07   Tejun Heo   sysfs, kernfs: mo...
20

c525aaddc   Tejun Heo   kernfs: s/sysfs/k...
21
  struct kernfs_iattrs {
058952196   Ondrej Mosnacek   kernfs: clean up ...
22
23
24
25
26
  	kuid_t			ia_uid;
  	kgid_t			ia_gid;
  	struct timespec64	ia_atime;
  	struct timespec64	ia_mtime;
  	struct timespec64	ia_ctime;
2322392b0   Tejun Heo   kernfs: implement...
27
28
  
  	struct simple_xattrs	xattrs;
ae6621b07   Tejun Heo   sysfs, kernfs: mo...
29
  };
81c173cb5   Tejun Heo   kernfs: remove KE...
30
31
  /* +1 to avoid triggering overflow warning when negating it */
  #define KN_DEACTIVATED_BIAS		(INT_MIN + 1)
ae6621b07   Tejun Heo   sysfs, kernfs: mo...
32

df23fc39b   Tejun Heo   kernfs: s/sysfs/k...
33
  /* KERNFS_TYPE_MASK and types are defined in include/linux/kernfs.h */
ae6621b07   Tejun Heo   sysfs, kernfs: mo...
34

ba7443bc6   Tejun Heo   sysfs, kernfs: im...
35
  /**
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
36
37
   * kernfs_root - find out the kernfs_root a kernfs_node belongs to
   * @kn: kernfs_node of interest
ba7443bc6   Tejun Heo   sysfs, kernfs: im...
38
   *
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
39
   * Return the kernfs_root @kn belongs to.
ba7443bc6   Tejun Heo   sysfs, kernfs: im...
40
   */
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
41
  static inline struct kernfs_root *kernfs_root(struct kernfs_node *kn)
ba7443bc6   Tejun Heo   sysfs, kernfs: im...
42
43
  {
  	/* if parent exists, it's always a dir; otherwise, @sd is a dir */
adc5e8b58   Tejun Heo   kernfs: drop s_ p...
44
45
46
  	if (kn->parent)
  		kn = kn->parent;
  	return kn->dir.root;
ba7443bc6   Tejun Heo   sysfs, kernfs: im...
47
  }
ae6621b07   Tejun Heo   sysfs, kernfs: mo...
48
  /*
fa736a951   Tejun Heo   sysfs, kernfs: mo...
49
50
   * mount.c
   */
c525aaddc   Tejun Heo   kernfs: s/sysfs/k...
51
  struct kernfs_super_info {
7d568a838   Tejun Heo   kernfs: implement...
52
  	struct super_block	*sb;
fa736a951   Tejun Heo   sysfs, kernfs: mo...
53
54
55
56
57
58
59
  	/*
  	 * The root associated with this super_block.  Each super_block is
  	 * identified by the root and ns it's associated with.
  	 */
  	struct kernfs_root	*root;
  
  	/*
324a56e16   Tejun Heo   kernfs: s/sysfs_d...
60
  	 * Each sb is associated with one namespace tag, currently the
c525aaddc   Tejun Heo   kernfs: s/sysfs/k...
61
62
63
  	 * network namespace of the task which mounted this kernfs
  	 * instance.  If multiple tags become necessary, make the following
  	 * an array and compare kernfs_node tag against every entry.
fa736a951   Tejun Heo   sysfs, kernfs: mo...
64
65
  	 */
  	const void		*ns;
7d568a838   Tejun Heo   kernfs: implement...
66
67
68
  
  	/* anchored at kernfs_root->supers, protected by kernfs_mutex */
  	struct list_head	node;
fa736a951   Tejun Heo   sysfs, kernfs: mo...
69
  };
c525aaddc   Tejun Heo   kernfs: s/sysfs/k...
70
  #define kernfs_info(SB) ((struct kernfs_super_info *)(SB->s_fs_info))
fa736a951   Tejun Heo   sysfs, kernfs: mo...
71

319ba91d3   Shaohua Li   kernfs: don't set...
72
73
74
75
76
77
  static inline struct kernfs_node *kernfs_dentry_node(struct dentry *dentry)
  {
  	if (d_really_is_negative(dentry))
  		return NULL;
  	return d_inode(dentry)->i_private;
  }
f41c59345   Li Zefan   kernfs: fix kernf...
78
  extern const struct super_operations kernfs_sops;
26e28d68b   Ayush Mittal   kernfs: Allocatin...
79
  extern struct kmem_cache *kernfs_node_cache, *kernfs_iattrs_cache;
fa736a951   Tejun Heo   sysfs, kernfs: mo...
80
81
  
  /*
ffed24e22   Tejun Heo   sysfs, kernfs: mo...
82
83
   * inode.c
   */
e72a1a8b3   Andreas Gruenbacher   kernfs: Switch to...
84
  extern const struct xattr_handler *kernfs_xattr_handlers[];
c637b8acb   Tejun Heo   kernfs: s/sysfs/k...
85
86
87
  void kernfs_evict_inode(struct inode *inode);
  int kernfs_iop_permission(struct inode *inode, int mask);
  int kernfs_iop_setattr(struct dentry *dentry, struct iattr *iattr);
a528d35e8   David Howells   statx: Add a syst...
88
89
  int kernfs_iop_getattr(const struct path *path, struct kstat *stat,
  		       u32 request_mask, unsigned int query_flags);
c637b8acb   Tejun Heo   kernfs: s/sysfs/k...
90
  ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
488dee96b   Dmitry Torokhov   kernfs: allow cre...
91
  int __kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr);
ffed24e22   Tejun Heo   sysfs, kernfs: mo...
92

fd7b9f7b9   Tejun Heo   sysfs, kernfs: mo...
93
94
95
  /*
   * dir.c
   */
a797bfc30   Tejun Heo   kernfs: s/sysfs/k...
96
97
98
99
  extern struct mutex kernfs_mutex;
  extern const struct dentry_operations kernfs_dops;
  extern const struct file_operations kernfs_dir_fops;
  extern const struct inode_operations kernfs_dir_iops;
fd7b9f7b9   Tejun Heo   sysfs, kernfs: mo...
100

c637b8acb   Tejun Heo   kernfs: s/sysfs/k...
101
102
  struct kernfs_node *kernfs_get_active(struct kernfs_node *kn);
  void kernfs_put_active(struct kernfs_node *kn);
988cd7afb   Tejun Heo   kernfs: remove ke...
103
  int kernfs_add_one(struct kernfs_node *kn);
db4aad209   Tejun Heo   kernfs: associate...
104
105
  struct kernfs_node *kernfs_new_node(struct kernfs_node *parent,
  				    const char *name, umode_t mode,
488dee96b   Dmitry Torokhov   kernfs: allow cre...
106
  				    kuid_t uid, kgid_t gid,
db4aad209   Tejun Heo   kernfs: associate...
107
  				    unsigned flags);
ba16b2846   Shaohua Li   kernfs: add an AP...
108
109
  struct kernfs_node *kernfs_find_and_get_node_by_ino(struct kernfs_root *root,
  						    unsigned int ino);
fd7b9f7b9   Tejun Heo   sysfs, kernfs: mo...
110

414985ae2   Tejun Heo   sysfs, kernfs: mo...
111
112
113
  /*
   * file.c
   */
a797bfc30   Tejun Heo   kernfs: s/sysfs/k...
114
  extern const struct file_operations kernfs_file_fops;
414985ae2   Tejun Heo   sysfs, kernfs: mo...
115

0e67db2f9   Tejun Heo   kernfs: add kernf...
116
  void kernfs_drain_open_files(struct kernfs_node *kn);
414985ae2   Tejun Heo   sysfs, kernfs: mo...
117

2072f1afd   Tejun Heo   sysfs, kernfs: mo...
118
119
120
  /*
   * symlink.c
   */
a797bfc30   Tejun Heo   kernfs: s/sysfs/k...
121
  extern const struct inode_operations kernfs_symlink_iops;
2072f1afd   Tejun Heo   sysfs, kernfs: mo...
122

ae6621b07   Tejun Heo   sysfs, kernfs: mo...
123
  #endif	/* __KERNFS_INTERNAL_H */