]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
proc: Move directory functions into internal.h
authorEric Snowberg <eric.snowberg@oracle.com>
Thu, 12 Jan 2017 23:05:23 +0000 (15:05 -0800)
committerAllen Pais <allen.pais@oracle.com>
Tue, 18 Jul 2017 12:25:00 +0000 (17:55 +0530)
Move directory macros and define proc_pident_lookup,
proc_pident_readdir and struct pid_entry within
fs/proc/internal.h. These were originally statically defined within
fs/proc/base.c and couldn't be used elsewhere.

Orabug: 26051178

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
Reviewed-by: Chris Hyser <chris.hyser@oracle.com>
Reviewed-by: Khalid Aziz <khalid.aziz@oracle.com>
fs/proc/base.c
fs/proc/internal.h

index 779e3e07ef91c6b0faa7338921238974e01715eb..7bb83f30eac599f020560e0701711a0821a334af 100644 (file)
  *     in /proc for a task before it execs a suid executable.
  */
 
-struct pid_entry {
-       const char *name;
-       int len;
-       umode_t mode;
-       const struct inode_operations *iop;
-       const struct file_operations *fop;
-       union proc_op op;
-};
-
-#define NOD(NAME, MODE, IOP, FOP, OP) {                        \
-       .name = (NAME),                                 \
-       .len  = sizeof(NAME) - 1,                       \
-       .mode = MODE,                                   \
-       .iop  = IOP,                                    \
-       .fop  = FOP,                                    \
-       .op   = OP,                                     \
-}
-
-#define DIR(NAME, MODE, iops, fops)    \
-       NOD(NAME, (S_IFDIR|(MODE)), &iops, &fops, {} )
-#define LNK(NAME, get_link)                                    \
-       NOD(NAME, (S_IFLNK|S_IRWXUGO),                          \
-               &proc_pid_link_inode_operations, NULL,          \
-               { .proc_get_link = get_link } )
-#define REG(NAME, MODE, fops)                          \
-       NOD(NAME, (S_IFREG|(MODE)), NULL, &fops, {})
-#define ONE(NAME, MODE, show)                          \
-       NOD(NAME, (S_IFREG|(MODE)),                     \
-               NULL, &proc_single_file_operations,     \
-               { .proc_show = show } )
-
 /*
  * Count the number of hardlinks for the pid_entry table, excluding the .
  * and .. links.
@@ -2371,10 +2340,9 @@ out:
        return -ENOENT;
 }
 
-static struct dentry *proc_pident_lookup(struct inode *dir, 
-                                        struct dentry *dentry,
-                                        const struct pid_entry *ents,
-                                        unsigned int nents)
+struct dentry *proc_pident_lookup(struct inode *dir, struct dentry *dentry,
+                                 const struct pid_entry *ents,
+                                 unsigned int nents)
 {
        int error;
        struct task_struct *task = get_proc_task(dir);
@@ -2406,8 +2374,8 @@ out_no_task:
        return ERR_PTR(error);
 }
 
-static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
-               const struct pid_entry *ents, unsigned int nents)
+int proc_pident_readdir(struct file *file, struct dir_context *ctx,
+                       const struct pid_entry *ents, unsigned int nents)
 {
        struct task_struct *task = get_proc_task(file_inode(file));
        const struct pid_entry *p;
index bdd272258913200d402f731b3849c32cc75a8590..77010bda9dc24b1b756091e90e0651518d4519df 100644 (file)
 #include <linux/atomic.h>
 #include <linux/binfmts.h>
 
+#define NOD(NAME, MODE, IOP, FOP, OP) {                        \
+       .name = (NAME),                                 \
+       .len  = sizeof(NAME) - 1,                       \
+       .mode = MODE,                                   \
+       .iop  = IOP,                                    \
+       .fop  = FOP,                                    \
+       .op   = OP,                                     \
+}
+
+#define DIR(NAME, MODE, iops, fops)    \
+       NOD(NAME, (S_IFDIR | (MODE)), &iops, &fops, {})
+#define LNK(NAME, get_link)                                    \
+       NOD(NAME, (S_IFLNK | S_IRWXUGO),                                \
+               &proc_pid_link_inode_operations, NULL,          \
+               { .proc_get_link = get_link })
+#define REG(NAME, MODE, fops)                          \
+       NOD(NAME, (S_IFREG | (MODE)), NULL, &fops, {})
+#define ONE(NAME, MODE, show)                          \
+               NOD(NAME, (S_IFREG | (MODE)),                   \
+               NULL, &proc_single_file_operations,     \
+               { .proc_show = show })
+
 struct ctl_table_header;
 struct mempolicy;
 
@@ -69,6 +91,15 @@ struct proc_inode {
        struct inode vfs_inode;
 };
 
+struct pid_entry {
+       const char *name;
+       int len;
+       umode_t mode;
+       const struct inode_operations *iop;
+       const struct file_operations *fop;
+       union proc_op op;
+};
+
 /*
  * General functions
  */
@@ -168,6 +199,13 @@ extern int pid_delete_dentry(const struct dentry *);
 extern int proc_pid_readdir(struct file *, struct dir_context *);
 extern struct dentry *proc_pid_lookup(struct inode *, struct dentry *, unsigned int);
 extern loff_t mem_lseek(struct file *, loff_t, int);
+struct dentry *proc_pident_lookup(struct inode *dir,
+                                 struct dentry *dentry,
+                                 const struct pid_entry *ents,
+                                 unsigned int nents);
+int proc_pident_readdir(struct file *file, struct dir_context *ctx,
+                       const struct pid_entry *ents,
+                       unsigned int nents);
 
 /* Lookups */
 typedef int instantiate_t(struct inode *, struct dentry *,