blob: 0bb0806de4ce2cc1023c8a39eb4133a3f4b5ee8d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#include <linux/kernel.h>
NeilBrownbff61972009-03-31 14:33:13 +11003#include <linux/blkdev.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <linux/init.h>
5#include <linux/syscalls.h>
6#include <linux/unistd.h>
7#include <linux/slab.h>
8#include <linux/mount.h>
9#include <linux/major.h>
10#include <linux/root_dev.h>
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012void change_floppy(char *fmt, ...);
13void mount_block_root(char *name, int flags);
14void mount_root(void);
15extern int root_mountflags;
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Greg Kroah-Hartmanbdaf8522005-06-20 21:15:16 -070017static inline int create_dev(char *name, dev_t dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070018{
Dominik Brodowski0f32ab82018-03-11 11:34:47 +010019 ksys_unlink(name);
Dominik Brodowski87c4e192018-03-11 11:34:50 +010020 return ksys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
Linus Torvalds1da177e2005-04-16 15:20:36 -070021}
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023static inline u32 bstat(char *name)
24{
Arnd Bergmann046aa122017-05-08 15:57:00 -070025 struct kstat stat;
26 if (vfs_stat(name, &stat) != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 return 0;
Arnd Bergmann046aa122017-05-08 15:57:00 -070028 if (!S_ISBLK(stat.mode))
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 return 0;
Arnd Bergmann046aa122017-05-08 15:57:00 -070030 return stat.rdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070031}
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33#ifdef CONFIG_BLK_DEV_RAM
34
35int __init rd_load_disk(int n);
36int __init rd_load_image(char *from);
37
38#else
39
40static inline int rd_load_disk(int n) { return 0; }
41static inline int rd_load_image(char *from) { return 0; }
42
43#endif
44
45#ifdef CONFIG_BLK_DEV_INITRD
46
Yaowei Baif057f3b2016-01-20 14:59:29 -080047bool __init initrd_load(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49#else
50
Yaowei Baif057f3b2016-01-20 14:59:29 -080051static inline bool initrd_load(void) { return false; }
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53#endif
54
55#ifdef CONFIG_BLK_DEV_MD
56
57void md_run_setup(void);
58
59#else
60
61static inline void md_run_setup(void) {}
62
63#endif