linux/fs/proc/generic.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * proc/fs/generic.c --- generic routines for the proc-fs
 *
 * This file contains generic proc-fs routines for handling
 * directories and files.
 * 
 * Copyright (C) 1991, 1992 Linus Torvalds.
 * Copyright (C) 1997 Theodore Ts'o
 */

#include <linux/cache.h>
#include <linux/errno.h>
#include <linux/time.h>
#include <linux/proc_fs.h>
#include <linux/stat.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/namei.h>
#include <linux/slab.h>
#include <linux/printk.h>
#include <linux/mount.h>
#include <linux/init.h>
#include <linux/idr.h>
#include <linux/bitops.h>
#include <linux/spinlock.h>
#include <linux/completion.h>
#include <linux/uaccess.h>
#include <linux/seq_file.h>

#include "internal.h"

static DEFINE_RWLOCK(proc_subdir_lock);

struct kmem_cache *proc_dir_entry_cache __ro_after_init;

void pde_free(struct proc_dir_entry *pde)
{}

static int proc_match(const char *name, struct proc_dir_entry *de, unsigned int len)
{}

static struct proc_dir_entry *pde_subdir_first(struct proc_dir_entry *dir)
{}

static struct proc_dir_entry *pde_subdir_next(struct proc_dir_entry *dir)
{}

static struct proc_dir_entry *pde_subdir_find(struct proc_dir_entry *dir,
					      const char *name,
					      unsigned int len)
{}

static bool pde_subdir_insert(struct proc_dir_entry *dir,
			      struct proc_dir_entry *de)
{}

static int proc_notify_change(struct mnt_idmap *idmap,
			      struct dentry *dentry, struct iattr *iattr)
{}

static int proc_getattr(struct mnt_idmap *idmap,
			const struct path *path, struct kstat *stat,
			u32 request_mask, unsigned int query_flags)
{}

static const struct inode_operations proc_file_inode_operations =;

/*
 * This function parses a name such as "tty/driver/serial", and
 * returns the struct proc_dir_entry for "/proc/tty/driver", and
 * returns "serial" in residual.
 */
static int __xlate_proc_name(const char *name, struct proc_dir_entry **ret,
			     const char **residual)
{}

static int xlate_proc_name(const char *name, struct proc_dir_entry **ret,
			   const char **residual)
{}

static DEFINE_IDA(proc_inum_ida);

#define PROC_DYNAMIC_FIRST

/*
 * Return an inode number between PROC_DYNAMIC_FIRST and
 * 0xffffffff, or zero on failure.
 */
int proc_alloc_inum(unsigned int *inum)
{}

void proc_free_inum(unsigned int inum)
{}

static int proc_misc_d_revalidate(struct dentry *dentry, unsigned int flags)
{}

static int proc_misc_d_delete(const struct dentry *dentry)
{}

static const struct dentry_operations proc_misc_dentry_ops =;

/*
 * Don't create negative dentries here, return -ENOENT by hand
 * instead.
 */
struct dentry *proc_lookup_de(struct inode *dir, struct dentry *dentry,
			      struct proc_dir_entry *de)
{}

struct dentry *proc_lookup(struct inode *dir, struct dentry *dentry,
		unsigned int flags)
{}

/*
 * This returns non-zero if at EOF, so that the /proc
 * root directory can use this and check if it should
 * continue with the <pid> entries..
 *
 * Note that the VFS-layer doesn't care about the return
 * value of the readdir() call, as long as it's non-negative
 * for success..
 */
int proc_readdir_de(struct file *file, struct dir_context *ctx,
		    struct proc_dir_entry *de)
{}

int proc_readdir(struct file *file, struct dir_context *ctx)
{}

/*
 * These are the generic /proc directory operations. They
 * use the in-memory "struct proc_dir_entry" tree to parse
 * the /proc directory.
 */
static const struct file_operations proc_dir_operations =;

static int proc_net_d_revalidate(struct dentry *dentry, unsigned int flags)
{}

const struct dentry_operations proc_net_dentry_ops =;

/*
 * proc directories can do almost nothing..
 */
static const struct inode_operations proc_dir_inode_operations =;

/* returns the registered entry, or frees dp and returns NULL on failure */
struct proc_dir_entry *proc_register(struct proc_dir_entry *dir,
		struct proc_dir_entry *dp)
{}

static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
					  const char *name,
					  umode_t mode,
					  nlink_t nlink)
{}

struct proc_dir_entry *proc_symlink(const char *name,
		struct proc_dir_entry *parent, const char *dest)
{}
EXPORT_SYMBOL();

struct proc_dir_entry *_proc_mkdir(const char *name, umode_t mode,
		struct proc_dir_entry *parent, void *data, bool force_lookup)
{}
EXPORT_SYMBOL_GPL();

struct proc_dir_entry *proc_mkdir_data(const char *name, umode_t mode,
		struct proc_dir_entry *parent, void *data)
{}
EXPORT_SYMBOL_GPL();

struct proc_dir_entry *proc_mkdir_mode(const char *name, umode_t mode,
				       struct proc_dir_entry *parent)
{}
EXPORT_SYMBOL();

struct proc_dir_entry *proc_mkdir(const char *name,
		struct proc_dir_entry *parent)
{}
EXPORT_SYMBOL();

struct proc_dir_entry *proc_create_mount_point(const char *name)
{}
EXPORT_SYMBOL();

struct proc_dir_entry *proc_create_reg(const char *name, umode_t mode,
		struct proc_dir_entry **parent, void *data)
{}

static inline void pde_set_flags(struct proc_dir_entry *pde)
{}

struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
		struct proc_dir_entry *parent,
		const struct proc_ops *proc_ops, void *data)
{}
EXPORT_SYMBOL();
 
struct proc_dir_entry *proc_create(const char *name, umode_t mode,
				   struct proc_dir_entry *parent,
				   const struct proc_ops *proc_ops)
{}
EXPORT_SYMBOL();

static int proc_seq_open(struct inode *inode, struct file *file)
{}

static int proc_seq_release(struct inode *inode, struct file *file)
{}

static const struct proc_ops proc_seq_ops =;

struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode,
		struct proc_dir_entry *parent, const struct seq_operations *ops,
		unsigned int state_size, void *data)
{}
EXPORT_SYMBOL();

static int proc_single_open(struct inode *inode, struct file *file)
{}

static const struct proc_ops proc_single_ops =;

struct proc_dir_entry *proc_create_single_data(const char *name, umode_t mode,
		struct proc_dir_entry *parent,
		int (*show)(struct seq_file *, void *), void *data)
{}
EXPORT_SYMBOL();

void proc_set_size(struct proc_dir_entry *de, loff_t size)
{}
EXPORT_SYMBOL();

void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid)
{}
EXPORT_SYMBOL();

void pde_put(struct proc_dir_entry *pde)
{}

/*
 * Remove a /proc entry and free it if it's not currently in use.
 */
void remove_proc_entry(const char *name, struct proc_dir_entry *parent)
{}
EXPORT_SYMBOL();

int remove_proc_subtree(const char *name, struct proc_dir_entry *parent)
{}
EXPORT_SYMBOL();

void *proc_get_parent_data(const struct inode *inode)
{}
EXPORT_SYMBOL_GPL();

void proc_remove(struct proc_dir_entry *de)
{}
EXPORT_SYMBOL();

/*
 * Pull a user buffer into memory and pass it to the file's write handler if
 * one is supplied.  The ->write() method is permitted to modify the
 * kernel-side buffer.
 */
ssize_t proc_simple_write(struct file *f, const char __user *ubuf, size_t size,
			  loff_t *_pos)
{}