sysfs, kernfs: prepare mount path for kernfs
[platform/adaptation/renesas_rcar/renesas_kernel.git] / fs / kernfs / kernfs-internal.h
index 31f0dbe..0d94988 100644 (file)
@@ -25,6 +25,12 @@ struct sysfs_elem_dir {
        unsigned long           subdirs;
        /* children rbtree starts here and goes through sd->s_rb */
        struct rb_root          children;
+
+       /*
+        * The kernfs hierarchy this directory belongs to.  This fits
+        * better directly in sysfs_dirent but is here to save space.
+        */
+       struct kernfs_root      *root;
 };
 
 struct sysfs_elem_symlink {
@@ -104,6 +110,20 @@ static inline unsigned int sysfs_type(struct sysfs_dirent *sd)
        return sd->s_flags & SYSFS_TYPE_MASK;
 }
 
+/**
+ * kernfs_root - find out the kernfs_root a sysfs_dirent belongs to
+ * @sd: sysfs_dirent of interest
+ *
+ * Return the kernfs_root @sd belongs to.
+ */
+static inline struct kernfs_root *kernfs_root(struct sysfs_dirent *sd)
+{
+       /* if parent exists, it's always a dir; otherwise, @sd is a dir */
+       if (sd->s_parent)
+               sd = sd->s_parent;
+       return sd->s_dir.root;
+}
+
 /*
  * Context structure to be used while adding/removing nodes.
  */
@@ -124,7 +144,7 @@ int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
                  struct kstat *stat);
 int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
                   size_t size, int flags);
-int sysfs_inode_init(void);
+void sysfs_inode_init(void);
 
 /*
  * dir.c
@@ -140,6 +160,19 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt);
 int sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd,
                  struct sysfs_dirent *parent_sd);
 void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
-struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type);
+struct sysfs_dirent *sysfs_new_dirent(struct kernfs_root *root,
+                                     const char *name, umode_t mode, int type);
+
+/*
+ * file.c
+ */
+extern const struct file_operations kernfs_file_operations;
+
+void sysfs_unmap_bin_file(struct sysfs_dirent *sd);
+
+/*
+ * symlink.c
+ */
+extern const struct inode_operations sysfs_symlink_inode_operations;
 
 #endif /* __KERNFS_INTERNAL_H */