Skip to content

Commit da5e4ef

Browse files
jacmetgregkh
authored andcommitted
devtmpfs: support !CONFIG_TMPFS
Make devtmpfs available on (embedded) configurations without SHMEM/TMPFS, using ramfs instead. Saves ~15KB. Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk> Acked-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
1 parent 1653268 commit da5e4ef

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

‎drivers/base/Kconfig‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ config UEVENT_HELPER_PATH
1818

1919
config DEVTMPFS
2020
bool "Maintain a devtmpfs filesystem to mount at /dev"
21-
depends on HOTPLUG && SHMEM && TMPFS
21+
depends on HOTPLUG
2222
help
23-
This creates a tmpfs filesystem instance early at bootup.
23+
This creates a tmpfs/ramfs filesystem instance early at bootup.
2424
In this filesystem, the kernel driver core maintains device
2525
nodes with their default names and permissions for all
2626
registered devices with an assigned major/minor number.
@@ -33,6 +33,9 @@ config DEVTMPFS
3333
functional /dev without any further help. It also allows simple
3434
rescue systems, and reliably handles dynamic major/minor numbers.
3535

36+
Notice: if CONFIG_TMPFS isn't enabled, the simpler ramfs
37+
file system will be used instead.
38+
3639
config DEVTMPFS_MOUNT
3740
bool "Automount devtmpfs at /dev, after the kernel mounted the rootfs"
3841
depends on DEVTMPFS

‎drivers/base/devtmpfs.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/namei.h>
2121
#include <linux/fs.h>
2222
#include <linux/shmem_fs.h>
23+
#include <linux/ramfs.h>
2324
#include <linux/cred.h>
2425
#include <linux/sched.h>
2526
#include <linux/init_task.h>
@@ -45,7 +46,11 @@ __setup("devtmpfs.mount=", mount_param);
4546
static int dev_get_sb(struct file_system_type *fs_type, int flags,
4647
const char *dev_name, void *data, struct vfsmount *mnt)
4748
{
49+
#ifdef CONFIG_TMPFS
4850
return get_sb_single(fs_type, flags, data, shmem_fill_super, mnt);
51+
#else
52+
return get_sb_single(fs_type, flags, data, ramfs_fill_super, mnt);
53+
#endif
4954
}
5055

5156
static struct file_system_type dev_fs_type = {

‎fs/ramfs/inode.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static int ramfs_parse_options(char *data, struct ramfs_mount_opts *opts)
214214
return 0;
215215
}
216216

217-
static int ramfs_fill_super(struct super_block * sb, void * data, int silent)
217+
int ramfs_fill_super(struct super_block *sb, void *data, int silent)
218218
{
219219
struct ramfs_fs_info *fsi;
220220
struct inode *inode = NULL;

‎include/linux/ramfs.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,6 @@ extern const struct file_operations ramfs_file_operations;
2020
extern const struct vm_operations_struct generic_file_vm_ops;
2121
extern int __init init_rootfs(void);
2222

23+
int ramfs_fill_super(struct super_block *sb, void *data, int silent);
24+
2325
#endif

0 commit comments

Comments
 (0)