Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * kernfs.h - pseudo filesystem decoupled from vfs locking
0004  */
0005 
0006 #ifndef __LINUX_KERNFS_H
0007 #define __LINUX_KERNFS_H
0008 
0009 #include <linux/err.h>
0010 #include <linux/list.h>
0011 #include <linux/mutex.h>
0012 #include <linux/idr.h>
0013 #include <linux/lockdep.h>
0014 #include <linux/rbtree.h>
0015 #include <linux/atomic.h>
0016 #include <linux/bug.h>
0017 #include <linux/types.h>
0018 #include <linux/uidgid.h>
0019 #include <linux/wait.h>
0020 #include <linux/rwsem.h>
0021 #include <linux/cache.h>
0022 
0023 struct file;
0024 struct dentry;
0025 struct iattr;
0026 struct seq_file;
0027 struct vm_area_struct;
0028 struct vm_operations_struct;
0029 struct super_block;
0030 struct file_system_type;
0031 struct poll_table_struct;
0032 struct fs_context;
0033 
0034 struct kernfs_fs_context;
0035 struct kernfs_open_node;
0036 struct kernfs_iattrs;
0037 
0038 /*
0039  * NR_KERNFS_LOCK_BITS determines size (NR_KERNFS_LOCKS) of hash
0040  * table of locks.
0041  * Having a small hash table would impact scalability, since
0042  * more and more kernfs_node objects will end up using same lock
0043  * and having a very large hash table would waste memory.
0044  *
0045  * At the moment size of hash table of locks is being set based on
0046  * the number of CPUs as follows:
0047  *
0048  * NR_CPU      NR_KERNFS_LOCK_BITS      NR_KERNFS_LOCKS
0049  *   1                  1                       2
0050  *  2-3                 2                       4
0051  *  4-7                 4                       16
0052  *  8-15                6                       64
0053  *  16-31               8                       256
0054  *  32 and more         10                      1024
0055  *
0056  * The above relation between NR_CPU and number of locks is based
0057  * on some internal experimentation which involved booting qemu
0058  * with different values of smp, performing some sysfs operations
0059  * on all CPUs and observing how increase in number of locks impacts
0060  * completion time of these sysfs operations on each CPU.
0061  */
0062 #ifdef CONFIG_SMP
0063 #define NR_KERNFS_LOCK_BITS (2 * (ilog2(NR_CPUS < 32 ? NR_CPUS : 32)))
0064 #else
0065 #define NR_KERNFS_LOCK_BITS     1
0066 #endif
0067 
0068 #define NR_KERNFS_LOCKS     (1 << NR_KERNFS_LOCK_BITS)
0069 
0070 /*
0071  * There's one kernfs_open_file for each open file and one kernfs_open_node
0072  * for each kernfs_node with one or more open files.
0073  *
0074  * filp->private_data points to seq_file whose ->private points to
0075  * kernfs_open_file.
0076  *
0077  * kernfs_open_files are chained at kernfs_open_node->files, which is
0078  * protected by kernfs_global_locks.open_file_mutex[i].
0079  *
0080  * To reduce possible contention in sysfs access, arising due to single
0081  * locks, use an array of locks (e.g. open_file_mutex) and use kernfs_node
0082  * object address as hash keys to get the index of these locks.
0083  *
0084  * Hashed mutexes are safe to use here because operations using these don't
0085  * rely on global exclusion.
0086  *
0087  * In future we intend to replace other global locks with hashed ones as well.
0088  * kernfs_global_locks acts as a holder for all such hash tables.
0089  */
0090 struct kernfs_global_locks {
0091     struct mutex open_file_mutex[NR_KERNFS_LOCKS];
0092 };
0093 
0094 enum kernfs_node_type {
0095     KERNFS_DIR      = 0x0001,
0096     KERNFS_FILE     = 0x0002,
0097     KERNFS_LINK     = 0x0004,
0098 };
0099 
0100 #define KERNFS_TYPE_MASK        0x000f
0101 #define KERNFS_FLAG_MASK        ~KERNFS_TYPE_MASK
0102 #define KERNFS_MAX_USER_XATTRS      128
0103 #define KERNFS_USER_XATTR_SIZE_LIMIT    (128 << 10)
0104 
0105 enum kernfs_node_flag {
0106     KERNFS_ACTIVATED    = 0x0010,
0107     KERNFS_NS       = 0x0020,
0108     KERNFS_HAS_SEQ_SHOW = 0x0040,
0109     KERNFS_HAS_MMAP     = 0x0080,
0110     KERNFS_LOCKDEP      = 0x0100,
0111     KERNFS_SUICIDAL     = 0x0400,
0112     KERNFS_SUICIDED     = 0x0800,
0113     KERNFS_EMPTY_DIR    = 0x1000,
0114     KERNFS_HAS_RELEASE  = 0x2000,
0115 };
0116 
0117 /* @flags for kernfs_create_root() */
0118 enum kernfs_root_flag {
0119     /*
0120      * kernfs_nodes are created in the deactivated state and invisible.
0121      * They require explicit kernfs_activate() to become visible.  This
0122      * can be used to make related nodes become visible atomically
0123      * after all nodes are created successfully.
0124      */
0125     KERNFS_ROOT_CREATE_DEACTIVATED      = 0x0001,
0126 
0127     /*
0128      * For regular files, if the opener has CAP_DAC_OVERRIDE, open(2)
0129      * succeeds regardless of the RW permissions.  sysfs had an extra
0130      * layer of enforcement where open(2) fails with -EACCES regardless
0131      * of CAP_DAC_OVERRIDE if the permission doesn't have the
0132      * respective read or write access at all (none of S_IRUGO or
0133      * S_IWUGO) or the respective operation isn't implemented.  The
0134      * following flag enables that behavior.
0135      */
0136     KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK   = 0x0002,
0137 
0138     /*
0139      * The filesystem supports exportfs operation, so userspace can use
0140      * fhandle to access nodes of the fs.
0141      */
0142     KERNFS_ROOT_SUPPORT_EXPORTOP        = 0x0004,
0143 
0144     /*
0145      * Support user xattrs to be written to nodes rooted at this root.
0146      */
0147     KERNFS_ROOT_SUPPORT_USER_XATTR      = 0x0008,
0148 };
0149 
0150 /* type-specific structures for kernfs_node union members */
0151 struct kernfs_elem_dir {
0152     unsigned long       subdirs;
0153     /* children rbtree starts here and goes through kn->rb */
0154     struct rb_root      children;
0155 
0156     /*
0157      * The kernfs hierarchy this directory belongs to.  This fits
0158      * better directly in kernfs_node but is here to save space.
0159      */
0160     struct kernfs_root  *root;
0161     /*
0162      * Monotonic revision counter, used to identify if a directory
0163      * node has changed during negative dentry revalidation.
0164      */
0165     unsigned long       rev;
0166 };
0167 
0168 struct kernfs_elem_symlink {
0169     struct kernfs_node  *target_kn;
0170 };
0171 
0172 struct kernfs_elem_attr {
0173     const struct kernfs_ops *ops;
0174     struct kernfs_open_node __rcu   *open;
0175     loff_t          size;
0176     struct kernfs_node  *notify_next;   /* for kernfs_notify() */
0177 };
0178 
0179 /*
0180  * kernfs_node - the building block of kernfs hierarchy.  Each and every
0181  * kernfs node is represented by single kernfs_node.  Most fields are
0182  * private to kernfs and shouldn't be accessed directly by kernfs users.
0183  *
0184  * As long as count reference is held, the kernfs_node itself is
0185  * accessible.  Dereferencing elem or any other outer entity requires
0186  * active reference.
0187  */
0188 struct kernfs_node {
0189     atomic_t        count;
0190     atomic_t        active;
0191 #ifdef CONFIG_DEBUG_LOCK_ALLOC
0192     struct lockdep_map  dep_map;
0193 #endif
0194     /*
0195      * Use kernfs_get_parent() and kernfs_name/path() instead of
0196      * accessing the following two fields directly.  If the node is
0197      * never moved to a different parent, it is safe to access the
0198      * parent directly.
0199      */
0200     struct kernfs_node  *parent;
0201     const char      *name;
0202 
0203     struct rb_node      rb;
0204 
0205     const void      *ns;    /* namespace tag */
0206     unsigned int        hash;   /* ns + name hash */
0207     union {
0208         struct kernfs_elem_dir      dir;
0209         struct kernfs_elem_symlink  symlink;
0210         struct kernfs_elem_attr     attr;
0211     };
0212 
0213     void            *priv;
0214 
0215     /*
0216      * 64bit unique ID.  On 64bit ino setups, id is the ino.  On 32bit,
0217      * the low 32bits are ino and upper generation.
0218      */
0219     u64         id;
0220 
0221     unsigned short      flags;
0222     umode_t         mode;
0223     struct kernfs_iattrs    *iattr;
0224 };
0225 
0226 /*
0227  * kernfs_syscall_ops may be specified on kernfs_create_root() to support
0228  * syscalls.  These optional callbacks are invoked on the matching syscalls
0229  * and can perform any kernfs operations which don't necessarily have to be
0230  * the exact operation requested.  An active reference is held for each
0231  * kernfs_node parameter.
0232  */
0233 struct kernfs_syscall_ops {
0234     int (*show_options)(struct seq_file *sf, struct kernfs_root *root);
0235 
0236     int (*mkdir)(struct kernfs_node *parent, const char *name,
0237              umode_t mode);
0238     int (*rmdir)(struct kernfs_node *kn);
0239     int (*rename)(struct kernfs_node *kn, struct kernfs_node *new_parent,
0240               const char *new_name);
0241     int (*show_path)(struct seq_file *sf, struct kernfs_node *kn,
0242              struct kernfs_root *root);
0243 };
0244 
0245 struct kernfs_node *kernfs_root_to_node(struct kernfs_root *root);
0246 
0247 struct kernfs_open_file {
0248     /* published fields */
0249     struct kernfs_node  *kn;
0250     struct file     *file;
0251     struct seq_file     *seq_file;
0252     void            *priv;
0253 
0254     /* private fields, do not use outside kernfs proper */
0255     struct mutex        mutex;
0256     struct mutex        prealloc_mutex;
0257     int         event;
0258     struct list_head    list;
0259     char            *prealloc_buf;
0260 
0261     size_t          atomic_write_len;
0262     bool            mmapped:1;
0263     bool            released:1;
0264     const struct vm_operations_struct *vm_ops;
0265 };
0266 
0267 struct kernfs_ops {
0268     /*
0269      * Optional open/release methods.  Both are called with
0270      * @of->seq_file populated.
0271      */
0272     int (*open)(struct kernfs_open_file *of);
0273     void (*release)(struct kernfs_open_file *of);
0274 
0275     /*
0276      * Read is handled by either seq_file or raw_read().
0277      *
0278      * If seq_show() is present, seq_file path is active.  Other seq
0279      * operations are optional and if not implemented, the behavior is
0280      * equivalent to single_open().  @sf->private points to the
0281      * associated kernfs_open_file.
0282      *
0283      * read() is bounced through kernel buffer and a read larger than
0284      * PAGE_SIZE results in partial operation of PAGE_SIZE.
0285      */
0286     int (*seq_show)(struct seq_file *sf, void *v);
0287 
0288     void *(*seq_start)(struct seq_file *sf, loff_t *ppos);
0289     void *(*seq_next)(struct seq_file *sf, void *v, loff_t *ppos);
0290     void (*seq_stop)(struct seq_file *sf, void *v);
0291 
0292     ssize_t (*read)(struct kernfs_open_file *of, char *buf, size_t bytes,
0293             loff_t off);
0294 
0295     /*
0296      * write() is bounced through kernel buffer.  If atomic_write_len
0297      * is not set, a write larger than PAGE_SIZE results in partial
0298      * operations of PAGE_SIZE chunks.  If atomic_write_len is set,
0299      * writes upto the specified size are executed atomically but
0300      * larger ones are rejected with -E2BIG.
0301      */
0302     size_t atomic_write_len;
0303     /*
0304      * "prealloc" causes a buffer to be allocated at open for
0305      * all read/write requests.  As ->seq_show uses seq_read()
0306      * which does its own allocation, it is incompatible with
0307      * ->prealloc.  Provide ->read and ->write with ->prealloc.
0308      */
0309     bool prealloc;
0310     ssize_t (*write)(struct kernfs_open_file *of, char *buf, size_t bytes,
0311              loff_t off);
0312 
0313     __poll_t (*poll)(struct kernfs_open_file *of,
0314              struct poll_table_struct *pt);
0315 
0316     int (*mmap)(struct kernfs_open_file *of, struct vm_area_struct *vma);
0317 };
0318 
0319 /*
0320  * The kernfs superblock creation/mount parameter context.
0321  */
0322 struct kernfs_fs_context {
0323     struct kernfs_root  *root;      /* Root of the hierarchy being mounted */
0324     void            *ns_tag;    /* Namespace tag of the mount (or NULL) */
0325     unsigned long       magic;      /* File system specific magic number */
0326 
0327     /* The following are set/used by kernfs_mount() */
0328     bool            new_sb_created; /* Set to T if we allocated a new sb */
0329 };
0330 
0331 #ifdef CONFIG_KERNFS
0332 
0333 static inline enum kernfs_node_type kernfs_type(struct kernfs_node *kn)
0334 {
0335     return kn->flags & KERNFS_TYPE_MASK;
0336 }
0337 
0338 static inline ino_t kernfs_id_ino(u64 id)
0339 {
0340     /* id is ino if ino_t is 64bit; otherwise, low 32bits */
0341     if (sizeof(ino_t) >= sizeof(u64))
0342         return id;
0343     else
0344         return (u32)id;
0345 }
0346 
0347 static inline u32 kernfs_id_gen(u64 id)
0348 {
0349     /* gen is fixed at 1 if ino_t is 64bit; otherwise, high 32bits */
0350     if (sizeof(ino_t) >= sizeof(u64))
0351         return 1;
0352     else
0353         return id >> 32;
0354 }
0355 
0356 static inline ino_t kernfs_ino(struct kernfs_node *kn)
0357 {
0358     return kernfs_id_ino(kn->id);
0359 }
0360 
0361 static inline ino_t kernfs_gen(struct kernfs_node *kn)
0362 {
0363     return kernfs_id_gen(kn->id);
0364 }
0365 
0366 /**
0367  * kernfs_enable_ns - enable namespace under a directory
0368  * @kn: directory of interest, should be empty
0369  *
0370  * This is to be called right after @kn is created to enable namespace
0371  * under it.  All children of @kn must have non-NULL namespace tags and
0372  * only the ones which match the super_block's tag will be visible.
0373  */
0374 static inline void kernfs_enable_ns(struct kernfs_node *kn)
0375 {
0376     WARN_ON_ONCE(kernfs_type(kn) != KERNFS_DIR);
0377     WARN_ON_ONCE(!RB_EMPTY_ROOT(&kn->dir.children));
0378     kn->flags |= KERNFS_NS;
0379 }
0380 
0381 /**
0382  * kernfs_ns_enabled - test whether namespace is enabled
0383  * @kn: the node to test
0384  *
0385  * Test whether namespace filtering is enabled for the children of @ns.
0386  */
0387 static inline bool kernfs_ns_enabled(struct kernfs_node *kn)
0388 {
0389     return kn->flags & KERNFS_NS;
0390 }
0391 
0392 int kernfs_name(struct kernfs_node *kn, char *buf, size_t buflen);
0393 int kernfs_path_from_node(struct kernfs_node *root_kn, struct kernfs_node *kn,
0394               char *buf, size_t buflen);
0395 void pr_cont_kernfs_name(struct kernfs_node *kn);
0396 void pr_cont_kernfs_path(struct kernfs_node *kn);
0397 struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn);
0398 struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent,
0399                        const char *name, const void *ns);
0400 struct kernfs_node *kernfs_walk_and_get_ns(struct kernfs_node *parent,
0401                        const char *path, const void *ns);
0402 void kernfs_get(struct kernfs_node *kn);
0403 void kernfs_put(struct kernfs_node *kn);
0404 
0405 struct kernfs_node *kernfs_node_from_dentry(struct dentry *dentry);
0406 struct kernfs_root *kernfs_root_from_sb(struct super_block *sb);
0407 struct inode *kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn);
0408 
0409 struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
0410                   struct super_block *sb);
0411 struct kernfs_root *kernfs_create_root(struct kernfs_syscall_ops *scops,
0412                        unsigned int flags, void *priv);
0413 void kernfs_destroy_root(struct kernfs_root *root);
0414 
0415 struct kernfs_node *kernfs_create_dir_ns(struct kernfs_node *parent,
0416                      const char *name, umode_t mode,
0417                      kuid_t uid, kgid_t gid,
0418                      void *priv, const void *ns);
0419 struct kernfs_node *kernfs_create_empty_dir(struct kernfs_node *parent,
0420                         const char *name);
0421 struct kernfs_node *__kernfs_create_file(struct kernfs_node *parent,
0422                      const char *name, umode_t mode,
0423                      kuid_t uid, kgid_t gid,
0424                      loff_t size,
0425                      const struct kernfs_ops *ops,
0426                      void *priv, const void *ns,
0427                      struct lock_class_key *key);
0428 struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,
0429                        const char *name,
0430                        struct kernfs_node *target);
0431 void kernfs_activate(struct kernfs_node *kn);
0432 void kernfs_remove(struct kernfs_node *kn);
0433 void kernfs_break_active_protection(struct kernfs_node *kn);
0434 void kernfs_unbreak_active_protection(struct kernfs_node *kn);
0435 bool kernfs_remove_self(struct kernfs_node *kn);
0436 int kernfs_remove_by_name_ns(struct kernfs_node *parent, const char *name,
0437                  const void *ns);
0438 int kernfs_rename_ns(struct kernfs_node *kn, struct kernfs_node *new_parent,
0439              const char *new_name, const void *new_ns);
0440 int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr);
0441 __poll_t kernfs_generic_poll(struct kernfs_open_file *of,
0442                  struct poll_table_struct *pt);
0443 void kernfs_notify(struct kernfs_node *kn);
0444 
0445 int kernfs_xattr_get(struct kernfs_node *kn, const char *name,
0446              void *value, size_t size);
0447 int kernfs_xattr_set(struct kernfs_node *kn, const char *name,
0448              const void *value, size_t size, int flags);
0449 
0450 const void *kernfs_super_ns(struct super_block *sb);
0451 int kernfs_get_tree(struct fs_context *fc);
0452 void kernfs_free_fs_context(struct fs_context *fc);
0453 void kernfs_kill_sb(struct super_block *sb);
0454 
0455 void kernfs_init(void);
0456 
0457 struct kernfs_node *kernfs_find_and_get_node_by_id(struct kernfs_root *root,
0458                            u64 id);
0459 #else   /* CONFIG_KERNFS */
0460 
0461 static inline enum kernfs_node_type kernfs_type(struct kernfs_node *kn)
0462 { return 0; }   /* whatever */
0463 
0464 static inline void kernfs_enable_ns(struct kernfs_node *kn) { }
0465 
0466 static inline bool kernfs_ns_enabled(struct kernfs_node *kn)
0467 { return false; }
0468 
0469 static inline int kernfs_name(struct kernfs_node *kn, char *buf, size_t buflen)
0470 { return -ENOSYS; }
0471 
0472 static inline int kernfs_path_from_node(struct kernfs_node *root_kn,
0473                     struct kernfs_node *kn,
0474                     char *buf, size_t buflen)
0475 { return -ENOSYS; }
0476 
0477 static inline void pr_cont_kernfs_name(struct kernfs_node *kn) { }
0478 static inline void pr_cont_kernfs_path(struct kernfs_node *kn) { }
0479 
0480 static inline struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn)
0481 { return NULL; }
0482 
0483 static inline struct kernfs_node *
0484 kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name,
0485                const void *ns)
0486 { return NULL; }
0487 static inline struct kernfs_node *
0488 kernfs_walk_and_get_ns(struct kernfs_node *parent, const char *path,
0489                const void *ns)
0490 { return NULL; }
0491 
0492 static inline void kernfs_get(struct kernfs_node *kn) { }
0493 static inline void kernfs_put(struct kernfs_node *kn) { }
0494 
0495 static inline struct kernfs_node *kernfs_node_from_dentry(struct dentry *dentry)
0496 { return NULL; }
0497 
0498 static inline struct kernfs_root *kernfs_root_from_sb(struct super_block *sb)
0499 { return NULL; }
0500 
0501 static inline struct inode *
0502 kernfs_get_inode(struct super_block *sb, struct kernfs_node *kn)
0503 { return NULL; }
0504 
0505 static inline struct kernfs_root *
0506 kernfs_create_root(struct kernfs_syscall_ops *scops, unsigned int flags,
0507            void *priv)
0508 { return ERR_PTR(-ENOSYS); }
0509 
0510 static inline void kernfs_destroy_root(struct kernfs_root *root) { }
0511 
0512 static inline struct kernfs_node *
0513 kernfs_create_dir_ns(struct kernfs_node *parent, const char *name,
0514              umode_t mode, kuid_t uid, kgid_t gid,
0515              void *priv, const void *ns)
0516 { return ERR_PTR(-ENOSYS); }
0517 
0518 static inline struct kernfs_node *
0519 __kernfs_create_file(struct kernfs_node *parent, const char *name,
0520              umode_t mode, kuid_t uid, kgid_t gid,
0521              loff_t size, const struct kernfs_ops *ops,
0522              void *priv, const void *ns, struct lock_class_key *key)
0523 { return ERR_PTR(-ENOSYS); }
0524 
0525 static inline struct kernfs_node *
0526 kernfs_create_link(struct kernfs_node *parent, const char *name,
0527            struct kernfs_node *target)
0528 { return ERR_PTR(-ENOSYS); }
0529 
0530 static inline void kernfs_activate(struct kernfs_node *kn) { }
0531 
0532 static inline void kernfs_remove(struct kernfs_node *kn) { }
0533 
0534 static inline bool kernfs_remove_self(struct kernfs_node *kn)
0535 { return false; }
0536 
0537 static inline int kernfs_remove_by_name_ns(struct kernfs_node *kn,
0538                        const char *name, const void *ns)
0539 { return -ENOSYS; }
0540 
0541 static inline int kernfs_rename_ns(struct kernfs_node *kn,
0542                    struct kernfs_node *new_parent,
0543                    const char *new_name, const void *new_ns)
0544 { return -ENOSYS; }
0545 
0546 static inline int kernfs_setattr(struct kernfs_node *kn,
0547                  const struct iattr *iattr)
0548 { return -ENOSYS; }
0549 
0550 static inline void kernfs_notify(struct kernfs_node *kn) { }
0551 
0552 static inline int kernfs_xattr_get(struct kernfs_node *kn, const char *name,
0553                    void *value, size_t size)
0554 { return -ENOSYS; }
0555 
0556 static inline int kernfs_xattr_set(struct kernfs_node *kn, const char *name,
0557                    const void *value, size_t size, int flags)
0558 { return -ENOSYS; }
0559 
0560 static inline const void *kernfs_super_ns(struct super_block *sb)
0561 { return NULL; }
0562 
0563 static inline int kernfs_get_tree(struct fs_context *fc)
0564 { return -ENOSYS; }
0565 
0566 static inline void kernfs_free_fs_context(struct fs_context *fc) { }
0567 
0568 static inline void kernfs_kill_sb(struct super_block *sb) { }
0569 
0570 static inline void kernfs_init(void) { }
0571 
0572 #endif  /* CONFIG_KERNFS */
0573 
0574 /**
0575  * kernfs_path - build full path of a given node
0576  * @kn: kernfs_node of interest
0577  * @buf: buffer to copy @kn's name into
0578  * @buflen: size of @buf
0579  *
0580  * If @kn is NULL result will be "(null)".
0581  *
0582  * Returns the length of the full path.  If the full length is equal to or
0583  * greater than @buflen, @buf contains the truncated path with the trailing
0584  * '\0'.  On error, -errno is returned.
0585  */
0586 static inline int kernfs_path(struct kernfs_node *kn, char *buf, size_t buflen)
0587 {
0588     return kernfs_path_from_node(kn, NULL, buf, buflen);
0589 }
0590 
0591 static inline struct kernfs_node *
0592 kernfs_find_and_get(struct kernfs_node *kn, const char *name)
0593 {
0594     return kernfs_find_and_get_ns(kn, name, NULL);
0595 }
0596 
0597 static inline struct kernfs_node *
0598 kernfs_walk_and_get(struct kernfs_node *kn, const char *path)
0599 {
0600     return kernfs_walk_and_get_ns(kn, path, NULL);
0601 }
0602 
0603 static inline struct kernfs_node *
0604 kernfs_create_dir(struct kernfs_node *parent, const char *name, umode_t mode,
0605           void *priv)
0606 {
0607     return kernfs_create_dir_ns(parent, name, mode,
0608                     GLOBAL_ROOT_UID, GLOBAL_ROOT_GID,
0609                     priv, NULL);
0610 }
0611 
0612 static inline int kernfs_remove_by_name(struct kernfs_node *parent,
0613                     const char *name)
0614 {
0615     return kernfs_remove_by_name_ns(parent, name, NULL);
0616 }
0617 
0618 static inline int kernfs_rename(struct kernfs_node *kn,
0619                 struct kernfs_node *new_parent,
0620                 const char *new_name)
0621 {
0622     return kernfs_rename_ns(kn, new_parent, new_name, NULL);
0623 }
0624 
0625 #endif  /* __LINUX_KERNFS_H */