Skip to content

Commit

Permalink
proc: Add CONFIG_PROC_FS_MIN
Browse files Browse the repository at this point in the history
Add an option for a minimal proc, basically what's needed for a
bootable and functionally useful system.

This means /proc/mounts and /proc/filesystems at minimum,
/proc/modules for a system with modules enabled.

Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
  • Loading branch information
tzanussi committed Apr 24, 2014
1 parent 4bad1d8 commit 6837943
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 22 deletions.
4 changes: 2 additions & 2 deletions block/genhd.c
Expand Up @@ -252,7 +252,7 @@ static inline int major_to_index(unsigned major)
return major % BLKDEV_MAJOR_HASH_SIZE;
}

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN
void blkdev_show(struct seq_file *seqf, off_t offset)
{
struct blk_major_name *dp;
Expand All @@ -264,7 +264,7 @@ void blkdev_show(struct seq_file *seqf, off_t offset)
mutex_unlock(&block_class_lock);
}
}
#endif /* CONFIG_PROC_FS */
#endif /* CONFIG_PROC_FS_MIN */

/**
* register_blkdev - register a new block device
Expand Down
4 changes: 4 additions & 0 deletions drivers/mtd/mtdcore.c
Expand Up @@ -1187,7 +1187,9 @@ static int __init init_mtd(void)
if (ret)
goto err_bdi3;

#ifdef CONFIG_PROC_FS
proc_mtd = proc_create("mtd", 0, NULL, &mtd_proc_ops);
#endif

ret = init_mtdchar();
if (ret)
Expand All @@ -1196,8 +1198,10 @@ static int __init init_mtd(void)
return 0;

out_procfs:
#ifdef CONFIG_PROC_FS
if (proc_mtd)
remove_proc_entry("mtd", NULL);
#endif
err_bdi3:
bdi_destroy(&mtd_bdi_ro_mappable);
err_bdi2:
Expand Down
4 changes: 2 additions & 2 deletions fs/Makefile
Expand Up @@ -19,7 +19,7 @@ else
obj-y += no-block.o
endif

obj-$(CONFIG_PROC_FS) += proc_namespace.o
obj-$(CONFIG_PROC_FS_MIN) += proc_namespace.o

obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o
obj-y += notify/
Expand Down Expand Up @@ -51,7 +51,7 @@ obj-$(CONFIG_FHANDLE) += fhandle.o

obj-y += quota/

obj-$(CONFIG_PROC_FS) += proc/
obj-$(CONFIG_PROC_FS_MIN) += proc/
obj-$(CONFIG_SYSFS) += sysfs/ kernfs/
obj-$(CONFIG_CONFIGFS_FS) += configfs/
obj-y += devpts/
Expand Down
4 changes: 2 additions & 2 deletions fs/char_dev.c
Expand Up @@ -64,7 +64,7 @@ static inline int major_to_index(unsigned major)
return major % CHRDEV_MAJOR_HASH_SIZE;
}

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN

void chrdev_show(struct seq_file *f, off_t offset)
{
Expand All @@ -78,7 +78,7 @@ void chrdev_show(struct seq_file *f, off_t offset)
}
}

#endif /* CONFIG_PROC_FS */
#endif /* CONFIG_PROC_FS_MIN */

/*
* Register a single major with a specified minor range.
Expand Down
2 changes: 1 addition & 1 deletion fs/filesystems.c
Expand Up @@ -217,7 +217,7 @@ int __init get_filesystem_list(char *buf)
return len;
}

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN
static int filesystems_proc_show(struct seq_file *m, void *v)
{
struct file_system_type * tmp;
Expand Down
4 changes: 2 additions & 2 deletions fs/namespace.c
Expand Up @@ -1094,7 +1094,7 @@ void replace_mount_options(struct super_block *sb, char *options)
}
EXPORT_SYMBOL(replace_mount_options);

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN
/* iterator; we want it to have access to namespace_sem, thus here... */
static void *m_start(struct seq_file *m, loff_t *pos)
{
Expand Down Expand Up @@ -1129,7 +1129,7 @@ const struct seq_operations mounts_op = {
.stop = m_stop,
.show = m_show,
};
#endif /* CONFIG_PROC_FS */
#endif /* CONFIG_PROC_FS_MIN */

/**
* may_umount_tree - check if a mount tree is busy
Expand Down
13 changes: 13 additions & 0 deletions fs/proc/Kconfig
@@ -1,5 +1,6 @@
config PROC_FS
bool "/proc file system support" if EXPERT
select PROC_FS_MIN
default y
help
This is a virtual file system providing information about the status
Expand Down Expand Up @@ -28,6 +29,18 @@ config PROC_FS
This option will enlarge your kernel by about 67 KB. Several
programs depend on this, so everyone should say Y here.

config PROC_FS_MIN
bool "minimal /proc file system support" if EXPERT
default n
help
This is a minimal subset of proc, basically what's needed to
boot.

This option will enlarge your kernel by about 60 KB, in
comparison to full PROC_FS of 170 KB. PROC_FS selects this,
so unless you know what you're doing, you can safely ignore
this.

config PROC_KCORE
bool "/proc/kcore support" if !ARM
depends on PROC_FS && MMU
Expand Down
2 changes: 1 addition & 1 deletion include/linux/interrupt.h
Expand Up @@ -599,7 +599,7 @@ extern int probe_irq_off(unsigned long); /* returns 0 or negative on failure */
extern unsigned int probe_irq_mask(unsigned long); /* returns mask of ISA interrupts */
#endif

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN
/* Initialize /proc/irq/ */
extern void init_irq_proc(void);
#else
Expand Down
2 changes: 1 addition & 1 deletion include/linux/irqdesc.h
Expand Up @@ -64,7 +64,7 @@ struct irq_desc {
unsigned long threads_oneshot;
atomic_t threads_active;
wait_queue_head_t wait_for_threads;
#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN
struct proc_dir_entry *dir;
#endif
int parent_irq;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/pid_namespace.h
Expand Up @@ -30,7 +30,7 @@ struct pid_namespace {
struct kmem_cache *pid_cachep;
unsigned int level;
struct pid_namespace *parent;
#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN
struct vfsmount *proc_mnt;
struct dentry *proc_self;
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/linux/proc_fs.h
Expand Up @@ -9,7 +9,7 @@

struct proc_dir_entry;

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN

extern void proc_root_init(void);
extern void proc_flush_task(struct task_struct *);
Expand Down
4 changes: 2 additions & 2 deletions include/linux/proc_ns.h
Expand Up @@ -39,7 +39,7 @@ enum {
PROC_PID_INIT_INO = 0xEFFFFFFCU,
};

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN

extern int pid_ns_prepare_proc(struct pid_namespace *ns);
extern void pid_ns_release_proc(struct pid_namespace *ns);
Expand All @@ -49,7 +49,7 @@ extern int proc_alloc_inum(unsigned int *pino);
extern void proc_free_inum(unsigned int inum);
extern bool proc_ns_inode(struct inode *inode);

#else /* CONFIG_PROC_FS */
#else /* CONFIG_PROC_FS_MIN */

static inline int pid_ns_prepare_proc(struct pid_namespace *ns) { return 0; }
static inline void pid_ns_release_proc(struct pid_namespace *ns) {}
Expand Down
2 changes: 1 addition & 1 deletion include/linux/tty.h
Expand Up @@ -688,7 +688,7 @@ static inline void tty_wait_until_sent_from_close(struct tty_struct *tty,
schedule(); \
tty_lock(tty))

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN
extern void proc_tty_register_driver(struct tty_driver *);
extern void proc_tty_unregister_driver(struct tty_driver *);
#else
Expand Down
2 changes: 1 addition & 1 deletion init/Kconfig
Expand Up @@ -1745,7 +1745,7 @@ config HAVE_GENERIC_DMA_COHERENT

config SLABINFO
bool
depends on PROC_FS
depends on PROC_FS_MIN
depends on SLAB || SLUB_DEBUG
default y

Expand Down
2 changes: 1 addition & 1 deletion init/main.c
Expand Up @@ -629,7 +629,7 @@ asmlinkage void __init start_kernel(void)
signals_init();
/* rootfs populating might need page-writeback */
page_writeback_init();
#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN
proc_root_init();
#endif
cgroup_init();
Expand Down
2 changes: 1 addition & 1 deletion kernel/irq/Makefile
Expand Up @@ -3,6 +3,6 @@ obj-y := irqdesc.o handle.o manage.o spurious.o resend.o chip.o dummychip.o devr
obj-$(CONFIG_GENERIC_IRQ_CHIP) += generic-chip.o
obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o
obj-$(CONFIG_IRQ_DOMAIN) += irqdomain.o
obj-$(CONFIG_PROC_FS) += proc.o
obj-$(CONFIG_PROC_FS_MIN) += proc.o
obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o
obj-$(CONFIG_PM_SLEEP) += pm.o
2 changes: 1 addition & 1 deletion kernel/irq/internals.h
Expand Up @@ -83,7 +83,7 @@ irqreturn_t handle_irq_event(struct irq_desc *desc);
void check_irq_resend(struct irq_desc *desc, unsigned int irq);
bool irq_wait_for_poll(struct irq_desc *desc);

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN
extern void register_irq_proc(unsigned int irq, struct irq_desc *desc);
extern void unregister_irq_proc(unsigned int irq, struct irq_desc *desc);
extern void register_handler_proc(unsigned int irq, struct irqaction *action);
Expand Down
2 changes: 1 addition & 1 deletion kernel/module.c
Expand Up @@ -3617,7 +3617,7 @@ static char *module_flags(struct module *mod, char *buf)
return buf;
}

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN
/* Called by the /proc file system to return a list of modules. */
static void *m_start(struct seq_file *m, loff_t *pos)
{
Expand Down
2 changes: 1 addition & 1 deletion mm/vmalloc.c
Expand Up @@ -2522,7 +2522,7 @@ void pcpu_free_vm_areas(struct vm_struct **vms, int nr_vms)
}
#endif /* CONFIG_SMP */

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_PROC_FS_MIN
static void *s_start(struct seq_file *m, loff_t *pos)
__acquires(&vmap_area_lock)
{
Expand Down
4 changes: 4 additions & 0 deletions net/packet/af_packet.c
Expand Up @@ -4110,15 +4110,19 @@ static int __net_init packet_net_init(struct net *net)
mutex_init(&net->packet.sklist_lock);
INIT_HLIST_HEAD(&net->packet.sklist);

#ifdef CONFIG_PROC_FS
if (!proc_create("packet", 0, net->proc_net, &packet_seq_fops))
return -ENOMEM;
#endif

return 0;
}

static void __net_exit packet_net_exit(struct net *net)
{
#ifdef CONFIG_PROC_FS
remove_proc_entry("packet", net->proc_net);
#endif
}

static struct pernet_operations packet_net_ops = {
Expand Down

0 comments on commit 6837943

Please sign in to comment.