From: Eric Snowberg Date: Thu, 12 Jan 2017 23:05:23 +0000 (-0800) Subject: proc: Move directory functions into internal.h X-Git-Tag: v4.1.12-106.0.20170720_1900~17 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=ec408e852f74f497b56115ff0eca346d64ff7d85;p=users%2Fjedix%2Flinux-maple.git proc: Move directory functions into internal.h 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 Signed-off-by: Allen Pais Reviewed-by: Chris Hyser Reviewed-by: Khalid Aziz --- diff --git a/fs/proc/base.c b/fs/proc/base.c index 779e3e07ef91..7bb83f30eac5 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -104,37 +104,6 @@ * 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; diff --git a/fs/proc/internal.h b/fs/proc/internal.h index bdd272258913..77010bda9dc2 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -15,6 +15,28 @@ #include #include +#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 *,