kernfs.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * kernfs.h - pseudo filesystem decoupled from vfs locking
  4. */
  5. #ifndef __LINUX_KERNFS_H
  6. #define __LINUX_KERNFS_H
  7. #include <linux/kernel.h>
  8. #include <linux/err.h>
  9. #include <linux/list.h>
  10. #include <linux/mutex.h>
  11. #include <linux/idr.h>
  12. #include <linux/lockdep.h>
  13. #include <linux/rbtree.h>
  14. #include <linux/atomic.h>
  15. #include <linux/uidgid.h>
  16. #include <linux/wait.h>
  17. #include <linux/android_kabi.h>
  18. struct file;
  19. struct dentry;
  20. struct iattr;
  21. struct seq_file;
  22. struct vm_area_struct;
  23. struct super_block;
  24. struct file_system_type;
  25. struct poll_table_struct;
  26. struct fs_context;
  27. struct kernfs_fs_context;
  28. struct kernfs_open_node;
  29. struct kernfs_iattrs;
  30. enum kernfs_node_type {
  31. KERNFS_DIR = 0x0001,
  32. KERNFS_FILE = 0x0002,
  33. KERNFS_LINK = 0x0004,
  34. };
  35. #define KERNFS_TYPE_MASK 0x000f
  36. #define KERNFS_FLAG_MASK ~KERNFS_TYPE_MASK
  37. #define KERNFS_MAX_USER_XATTRS 128
  38. #define KERNFS_USER_XATTR_SIZE_LIMIT (128 << 10)
  39. enum kernfs_node_flag {
  40. KERNFS_ACTIVATED = 0x0010,
  41. KERNFS_NS = 0x0020,
  42. KERNFS_HAS_SEQ_SHOW = 0x0040,
  43. KERNFS_HAS_MMAP = 0x0080,
  44. KERNFS_LOCKDEP = 0x0100,
  45. KERNFS_SUICIDAL = 0x0400,
  46. KERNFS_SUICIDED = 0x0800,
  47. KERNFS_EMPTY_DIR = 0x1000,
  48. KERNFS_HAS_RELEASE = 0x2000,
  49. };
  50. /* @flags for kernfs_create_root() */
  51. enum kernfs_root_flag {
  52. /*
  53. * kernfs_nodes are created in the deactivated state and invisible.
  54. * They require explicit kernfs_activate() to become visible. This
  55. * can be used to make related nodes become visible atomically
  56. * after all nodes are created successfully.
  57. */
  58. KERNFS_ROOT_CREATE_DEACTIVATED = 0x0001,
  59. /*
  60. * For regular files, if the opener has CAP_DAC_OVERRIDE, open(2)
  61. * succeeds regardless of the RW permissions. sysfs had an extra
  62. * layer of enforcement where open(2) fails with -EACCES regardless
  63. * of CAP_DAC_OVERRIDE if the permission doesn't have the
  64. * respective read or write access at all (none of S_IRUGO or
  65. * S_IWUGO) or the respective operation isn't implemented. The
  66. * following flag enables that behavior.
  67. */
  68. KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK = 0x0002,
  69. /*
  70. * The filesystem supports exportfs operation, so userspace can use
  71. * fhandle to access nodes of the fs.
  72. */
  73. KERNFS_ROOT_SUPPORT_EXPORTOP = 0x0004,
  74. /*
  75. * Support user xattrs to be written to nodes rooted at this root.
  76. */
  77. KERNFS_ROOT_SUPPORT_USER_XATTR = 0x0008,
  78. };
  79. /* type-specific structures for kernfs_node union members */
  80. struct kernfs_elem_dir {
  81. unsigned long subdirs;
  82. /* children rbtree starts here and goes through kn->rb */
  83. struct rb_root children;
  84. /*
  85. * The kernfs hierarchy this directory belongs to. This fits
  86. * better directly in kernfs_node but is here to save space.
  87. */
  88. struct kernfs_root *root;
  89. };
  90. struct kernfs_elem_symlink {
  91. struct kernfs_node *target_kn;
  92. };
  93. struct kernfs_elem_attr {
  94. const struct kernfs_ops *ops;
  95. struct kernfs_open_node *open;
  96. loff_t size;
  97. struct kernfs_node *notify_next; /* for kernfs_notify() */
  98. };
  99. /*
  100. * kernfs_node - the building block of kernfs hierarchy. Each and every
  101. * kernfs node is represented by single kernfs_node. Most fields are
  102. * private to kernfs and shouldn't be accessed directly by kernfs users.
  103. *
  104. * As long as s_count reference is held, the kernfs_node itself is
  105. * accessible. Dereferencing elem or any other outer entity requires
  106. * active reference.
  107. */
  108. struct kernfs_node {
  109. atomic_t count;
  110. atomic_t active;
  111. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  112. struct lockdep_map dep_map;
  113. #endif
  114. /*
  115. * Use kernfs_get_parent() and kernfs_name/path() instead of
  116. * accessing the following two fields directly. If the node is
  117. * never moved to a different parent, it is safe to access the
  118. * parent directly.
  119. */
  120. struct kernfs_node *parent;
  121. const char *name;
  122. struct rb_node rb;
  123. const void *ns; /* namespace tag */
  124. unsigned int hash; /* ns + name hash */
  125. union {
  126. struct kernfs_elem_dir dir;
  127. struct kernfs_elem_symlink symlink;
  128. struct kernfs_elem_attr attr;
  129. };
  130. void *priv;
  131. /*
  132. * 64bit unique ID. On 64bit ino setups, id is the ino. On 32bit,
  133. * the low 32bits are ino and upper generation.
  134. */
  135. u64 id;
  136. unsigned short flags;
  137. umode_t mode;
  138. struct kernfs_iattrs *iattr;
  139. ANDROID_KABI_RESERVE(1);
  140. };
  141. /*
  142. * kernfs_syscall_ops may be specified on kernfs_create_root() to support
  143. * syscalls. These optional callbacks are invoked on the matching syscalls
  144. * and can perform any kernfs operations which don't necessarily have to be
  145. * the exact operation requested. An active reference is held for each
  146. * kernfs_node parameter.
  147. */
  148. struct kernfs_syscall_ops {
  149. int (*show_options)(struct seq_file *sf, struct kernfs_root *root);
  150. int (*mkdir)(struct kernfs_node *parent, const char *name,
  151. umode_t mode);
  152. int (*rmdir)(struct kernfs_node *kn);
  153. int (*rename)(struct kernfs_node *kn, struct kernfs_node *new_parent,
  154. const char *new_name);
  155. int (*show_path)(struct seq_file *sf, struct kernfs_node *kn,
  156. struct kernfs_root *root);
  157. ANDROID_KABI_RESERVE(1);
  158. ANDROID_KABI_RESERVE(2);
  159. ANDROID_KABI_RESERVE(3);
  160. ANDROID_KABI_RESERVE(4);
  161. };
  162. struct kernfs_root {
  163. /* published fields */
  164. struct kernfs_node *kn;
  165. unsigned int flags; /* KERNFS_ROOT_* flags */
  166. /* private fields, do not use outside kernfs proper */
  167. struct idr ino_idr;
  168. u32 last_id_lowbits;
  169. u32 id_highbits;
  170. struct kernfs_syscall_ops *syscall_ops;
  171. /* list of kernfs_super_info of this root, protected by kernfs_mutex */
  172. struct list_head supers;
  173. wait_queue_head_t deactivate_waitq;
  174. ANDROID_KABI_RESERVE(1);
  175. };
  176. struct kernfs_open_file {
  177. /* published fields */
  178. struct kernfs_node *kn;
  179. struct file *file;
  180. struct seq_file *seq_file;
  181. void *priv;
  182. /* private fields, do not use outside kernfs proper */
  183. struct mutex mutex;
  184. struct mutex prealloc_mutex;
  185. int event;
  186. struct list_head list;
  187. char *prealloc_buf;
  188. size_t atomic_write_len;
  189. bool mmapped:1;
  190. bool released:1;
  191. const struct vm_operations_struct *vm_ops;
  192. ANDROID_KABI_RESERVE(1);
  193. };
  194. struct kernfs_ops {
  195. /*
  196. * Optional open/release methods. Both are called with
  197. * @of->seq_file populated.
  198. */
  199. int (*open)(struct kernfs_open_file *of);
  200. void (*release)(struct kernfs_open_file *of);
  201. /*
  202. * Read is handled by either seq_file or raw_read().
  203. *
  204. * If seq_show() is present, seq_file path is active. Other seq
  205. * operations are optional and if not implemented, the behavior is
  206. * equivalent to single_open(). @sf->private points to the
  207. * associated kernfs_open_file.
  208. *
  209. * read() is bounced through kernel buffer and a read larger than
  210. * PAGE_SIZE results in partial operation of PAGE_SIZE.
  211. */
  212. int (*seq_show)(struct seq_file *sf, void *v);
  213. void *(*seq_start)(struct seq_file *sf, loff_t *ppos);
  214. void *(*seq_next)(struct seq_file *sf, void *v, loff_t *ppos);
  215. void (*seq_stop)(struct seq_file *sf, void *v);
  216. ssize_t (*read)(struct kernfs_open_file *of, char *buf, size_t bytes,
  217. loff_t off);
  218. /*
  219. * write() is bounced through kernel buffer. If atomic_write_len
  220. * is not set, a write larger than PAGE_SIZE results in partial
  221. * operations of PAGE_SIZE chunks. If atomic_write_len is set,
  222. * writes upto the specified size are executed atomically but
  223. * larger ones are rejected with -E2BIG.
  224. */
  225. size_t atomic_write_len;
  226. /*
  227. * "prealloc" causes a buffer to be allocated at open for
  228. * all read/write requests. As ->seq_show uses seq_read()
  229. * which does its own allocation, it is incompatible with
  230. * ->prealloc. Provide ->read and ->write with ->prealloc.
  231. */
  232. bool prealloc;
  233. ssize_t (*write)(struct kernfs_open_file *of, char *buf, size_t bytes,
  234. loff_t off);
  235. __poll_t (*poll)(struct kernfs_open_file *of,
  236. struct poll_table_struct *pt);
  237. int (*mmap)(struct kernfs_open_file *of, struct vm_area_struct *vma);
  238. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  239. struct lock_class_key lockdep_key;
  240. #endif
  241. ANDROID_KABI_RESERVE(1);
  242. ANDROID_KABI_RESERVE(2);
  243. };
  244. /*
  245. * The kernfs superblock creation/mount parameter context.
  246. */
  247. struct kernfs_fs_context {
  248. struct kernfs_root *root; /* Root of the hierarchy being mounted */
  249. void *ns_tag; /* Namespace tag of the mount (or NULL) */
  250. unsigned long magic; /* File system specific magic number */
  251. /* The following are set/used by kernfs_mount() */
  252. bool new_sb_created; /* Set to T if we allocated a new sb */
  253. };
  254. #ifdef CONFIG_KERNFS
  255. static inline enum kernfs_node_type kernfs_type(struct kernfs_node *kn)
  256. {
  257. return kn->flags & KERNFS_TYPE_MASK;
  258. }
  259. static inline ino_t kernfs_id_ino(u64 id)
  260. {
  261. /* id is ino if ino_t is 64bit; otherwise, low 32bits */
  262. if (sizeof(ino_t) >= sizeof(u64))
  263. return id;
  264. else
  265. return (u32)id;
  266. }
  267. static inline u32 kernfs_id_gen(u64 id)
  268. {
  269. /* gen is fixed at 1 if ino_t is 64bit; otherwise, high 32bits */
  270. if (sizeof(ino_t) >= sizeof(u64))
  271. return 1;
  272. else
  273. return id >> 32;
  274. }
  275. static inline ino_t kernfs_ino(struct kernfs_node *kn)
  276. {
  277. return kernfs_id_ino(kn->id);
  278. }
  279. static inline ino_t kernfs_gen(struct kernfs_node *kn)
  280. {
  281. return kernfs_id_gen(kn->id);
  282. }
  283. /**
  284. * kernfs_enable_ns - enable namespace under a directory
  285. * @kn: directory of interest, should be empty
  286. *
  287. * This is to be called right after @kn is created to enable namespace
  288. * under it. All children of @kn must have non-NULL namespace tags and
  289. * only the ones which match the super_block's tag will be visible.
  290. */
  291. static inline void kernfs_enable_ns(struct kernfs_node *kn)
  292. {
  293. WARN_ON_ONCE(kernfs_type(kn) != KERNFS_DIR);
  294. WARN_ON_ONCE(!RB_EMPTY_ROOT(&kn->dir.children));
  295. kn->flags |= KERNFS_NS;
  296. }
  297. /**
  298. * kernfs_ns_enabled - test whether namespace is enabled
  299. * @kn: the node to test
  300. *
  301. * Test whether namespace filtering is enabled for the children of @ns.
  302. */
  303. static inline bool kernfs_ns_enabled(struct kernfs_node *kn)
  304. {
  305. return kn->flags & KERNFS_NS;
  306. }
  307. int kernfs_name(struct kernfs_node *kn, char *buf, size_t buflen);
  308. int kernfs_path_from_node(struct kernfs_node *root_kn, struct kernfs_node *kn,
  309. char *buf, size_t buflen);
  310. void pr_cont_kernfs_name(struct kernfs_node *kn);
  311. void pr_cont_kernfs_path(struct kernfs_node *kn);
  312. struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn);
  313. struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
  314. const char *name, const void *ns);
  315. struct kernfs_node *kernfs_walk_and_get_ns(struct kernfs_node *parent,
  316. const char *path, const void *ns);
  317. void kernfs_get(struct kernfs_node *kn);
  318. void kernfs_put(struct kernfs_node *kn);
  319. struct kernfs_node *kernfs_node_from_dentry(struct dentry *dentry);
  320. struct kernfs_root *kernfs_root_from_sb(struct super_block *sb);
  321. struct inode *kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn);
  322. struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
  323. struct super_block *sb);
  324. struct kernfs_root *kernfs_create_root(struct kernfs_syscall_ops *scops,
  325. unsigned int flags, void *priv);
  326. void kernfs_destroy_root(struct kernfs_root *root);
  327. struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
  328. const char *name, umode_t mode,
  329. kuid_t uid, kgid_t gid,
  330. void *priv, const void *ns);
  331. struct kernfs_node *kernfs_create_empty_dir(struct kernfs_node *parent,
  332. const char *name);
  333. struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
  334. const char *name, umode_t mode,
  335. kuid_t uid, kgid_t gid,
  336. loff_t size,
  337. const struct kernfs_ops *ops,
  338. void *priv, const void *ns,
  339. struct lock_class_key *key);
  340. struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
  341. const char *name,
  342. struct kernfs_node *target);
  343. void kernfs_activate(struct kernfs_node *kn);
  344. void kernfs_remove(struct kernfs_node *kn);
  345. void kernfs_break_active_protection(struct kernfs_node *kn);
  346. void kernfs_unbreak_active_protection(struct kernfs_node *kn);
  347. bool kernfs_remove_self(struct kernfs_node *kn);
  348. int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,
  349. const void *ns);
  350. int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
  351. const char *new_name, const void *new_ns);
  352. int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr);
  353. __poll_t kernfs_generic_poll(struct kernfs_open_file *of,
  354. struct poll_table_struct *pt);
  355. void kernfs_notify(struct kernfs_node *kn);
  356. int kernfs_xattr_get(struct kernfs_node *kn, const char *name,
  357. void *value, size_t size);
  358. int kernfs_xattr_set(struct kernfs_node *kn, const char *name,
  359. const void *value, size_t size, int flags);
  360. const void *kernfs_super_ns(struct super_block *sb);
  361. int kernfs_get_tree(struct fs_context *fc);
  362. void kernfs_free_fs_context(struct fs_context *fc);
  363. void kernfs_kill_sb(struct super_block *sb);
  364. void kernfs_init(void);
  365. struct kernfs_node *kernfs_find_and_get_node_by_id(struct kernfs_root *root,
  366. u64 id);
  367. #else /* CONFIG_KERNFS */
  368. static inline enum kernfs_node_type kernfs_type(struct kernfs_node *kn)
  369. { return 0; } /* whatever */
  370. static inline void kernfs_enable_ns(struct kernfs_node *kn) { }
  371. static inline bool kernfs_ns_enabled(struct kernfs_node *kn)
  372. { return false; }
  373. static inline int kernfs_name(struct kernfs_node *kn, char *buf, size_t buflen)
  374. { return -ENOSYS; }
  375. static inline int kernfs_path_from_node(struct kernfs_node *root_kn,
  376. struct kernfs_node *kn,
  377. char *buf, size_t buflen)
  378. { return -ENOSYS; }
  379. static inline void pr_cont_kernfs_name(struct kernfs_node *kn) { }
  380. static inline void pr_cont_kernfs_path(struct kernfs_node *kn) { }
  381. static inline struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)
  382. { return NULL; }
  383. static inline struct kernfs_node *
  384. kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name,
  385. const void *ns)
  386. { return NULL; }
  387. static inline struct kernfs_node *
  388. kernfs_walk_and_get_ns(struct kernfs_node *parent, const char *path,
  389. const void *ns)
  390. { return NULL; }
  391. static inline void kernfs_get(struct kernfs_node *kn) { }
  392. static inline void kernfs_put(struct kernfs_node *kn) { }
  393. static inline struct kernfs_node *kernfs_node_from_dentry(struct dentry *dentry)
  394. { return NULL; }
  395. static inline struct kernfs_root *kernfs_root_from_sb(struct super_block *sb)
  396. { return NULL; }
  397. static inline struct inode *
  398. kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn)
  399. { return NULL; }
  400. static inline struct kernfs_root *
  401. kernfs_create_root(struct kernfs_syscall_ops *scops, unsigned int flags,
  402. void *priv)
  403. { return ERR_PTR(-ENOSYS); }
  404. static inline void kernfs_destroy_root(struct kernfs_root *root) { }
  405. static inline struct kernfs_node *
  406. kernfs_create_dir_ns(struct kernfs_node *parent, const char *name,
  407. umode_t mode, kuid_t uid, kgid_t gid,
  408. void *priv, const void *ns)
  409. { return ERR_PTR(-ENOSYS); }
  410. static inline struct kernfs_node *
  411. __kernfs_create_file(struct kernfs_node *parent, const char *name,
  412. umode_t mode, kuid_t uid, kgid_t gid,
  413. loff_t size, const struct kernfs_ops *ops,
  414. void *priv, const void *ns, struct lock_class_key *key)
  415. { return ERR_PTR(-ENOSYS); }
  416. static inline struct kernfs_node *
  417. kernfs_create_link(struct kernfs_node *parent, const char *name,
  418. struct kernfs_node *target)
  419. { return ERR_PTR(-ENOSYS); }
  420. static inline void kernfs_activate(struct kernfs_node *kn) { }
  421. static inline void kernfs_remove(struct kernfs_node *kn) { }
  422. static inline bool kernfs_remove_self(struct kernfs_node *kn)
  423. { return false; }
  424. static inline int kernfs_remove_by_name_ns(struct kernfs_node *kn,
  425. const char *name, const void *ns)
  426. { return -ENOSYS; }
  427. static inline int kernfs_rename_ns(struct kernfs_node *kn,
  428. struct kernfs_node *new_parent,
  429. const char *new_name, const void *new_ns)
  430. { return -ENOSYS; }
  431. static inline int kernfs_setattr(struct kernfs_node *kn,
  432. const struct iattr *iattr)
  433. { return -ENOSYS; }
  434. static inline void kernfs_notify(struct kernfs_node *kn) { }
  435. static inline int kernfs_xattr_get(struct kernfs_node *kn, const char *name,
  436. void *value, size_t size)
  437. { return -ENOSYS; }
  438. static inline int kernfs_xattr_set(struct kernfs_node *kn, const char *name,
  439. const void *value, size_t size, int flags)
  440. { return -ENOSYS; }
  441. static inline const void *kernfs_super_ns(struct super_block *sb)
  442. { return NULL; }
  443. static inline int kernfs_get_tree(struct fs_context *fc)
  444. { return -ENOSYS; }
  445. static inline void kernfs_free_fs_context(struct fs_context *fc) { }
  446. static inline void kernfs_kill_sb(struct super_block *sb) { }
  447. static inline void kernfs_init(void) { }
  448. #endif /* CONFIG_KERNFS */
  449. /**
  450. * kernfs_path - build full path of a given node
  451. * @kn: kernfs_node of interest
  452. * @buf: buffer to copy @kn's name into
  453. * @buflen: size of @buf
  454. *
  455. * If @kn is NULL result will be "(null)".
  456. *
  457. * Returns the length of the full path. If the full length is equal to or
  458. * greater than @buflen, @buf contains the truncated path with the trailing
  459. * '\0'. On error, -errno is returned.
  460. */
  461. static inline int kernfs_path(struct kernfs_node *kn, char *buf, size_t buflen)
  462. {
  463. return kernfs_path_from_node(kn, NULL, buf, buflen);
  464. }
  465. static inline struct kernfs_node *
  466. kernfs_find_and_get(struct kernfs_node *kn, const char *name)
  467. {
  468. return kernfs_find_and_get_ns(kn, name, NULL);
  469. }
  470. static inline struct kernfs_node *
  471. kernfs_walk_and_get(struct kernfs_node *kn, const char *path)
  472. {
  473. return kernfs_walk_and_get_ns(kn, path, NULL);
  474. }
  475. static inline struct kernfs_node *
  476. kernfs_create_dir(struct kernfs_node *parent, const char *name, umode_t mode,
  477. void *priv)
  478. {
  479. return kernfs_create_dir_ns(parent, name, mode,
  480. GLOBAL_ROOT_UID, GLOBAL_ROOT_GID,
  481. priv, NULL);
  482. }
  483. static inline struct kernfs_node *
  484. kernfs_create_file_ns(struct kernfs_node *parent, const char *name,
  485. umode_t mode, kuid_t uid, kgid_t gid,
  486. loff_t size, const struct kernfs_ops *ops,
  487. void *priv, const void *ns)
  488. {
  489. struct lock_class_key *key = NULL;
  490. #ifdef CONFIG_DEBUG_LOCK_ALLOC
  491. key = (struct lock_class_key *)&ops->lockdep_key;
  492. #endif
  493. return __kernfs_create_file(parent, name, mode, uid, gid,
  494. size, ops, priv, ns, key);
  495. }
  496. static inline struct kernfs_node *
  497. kernfs_create_file(struct kernfs_node *parent, const char *name, umode_t mode,
  498. loff_t size, const struct kernfs_ops *ops, void *priv)
  499. {
  500. return kernfs_create_file_ns(parent, name, mode,
  501. GLOBAL_ROOT_UID, GLOBAL_ROOT_GID,
  502. size, ops, priv, NULL);
  503. }
  504. static inline int kernfs_remove_by_name(struct kernfs_node *parent,
  505. const char *name)
  506. {
  507. return kernfs_remove_by_name_ns(parent, name, NULL);
  508. }
  509. static inline int kernfs_rename(struct kernfs_node *kn,
  510. struct kernfs_node *new_parent,
  511. const char *new_name)
  512. {
  513. return kernfs_rename_ns(kn, new_parent, new_name, NULL);
  514. }
  515. #endif /* __LINUX_KERNFS_H */