mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
selftests/nolibc: prepare: create /dev/zero
/dev/zero is commonly used to allocate anonymous memory, it is a very good file for tests, let's prepare it. Suggested-by: Willy Tarreau <w@1wt.eu> Link: https://lore.kernel.org/lkml/20230702193306.GK16233@1wt.eu/ Signed-off-by: Zhangjin Wu <falcon@tinylab.org> Signed-off-by: Willy Tarreau <w@1wt.eu>
This commit is contained in:
parent
938b5b9833
commit
82e339c230
1 changed files with 3 additions and 1 deletions
|
@ -894,11 +894,13 @@ int prepare(void)
|
|||
*/
|
||||
if (stat("/dev/.", &stat_buf) == 0 || mkdir("/dev", 0755) == 0) {
|
||||
if (stat("/dev/console", &stat_buf) != 0 ||
|
||||
stat("/dev/null", &stat_buf) != 0) {
|
||||
stat("/dev/null", &stat_buf) != 0 ||
|
||||
stat("/dev/zero", &stat_buf) != 0) {
|
||||
/* try devtmpfs first, otherwise fall back to manual creation */
|
||||
if (mount("/dev", "/dev", "devtmpfs", 0, 0) != 0) {
|
||||
mknod("/dev/console", 0600 | S_IFCHR, makedev(5, 1));
|
||||
mknod("/dev/null", 0666 | S_IFCHR, makedev(1, 3));
|
||||
mknod("/dev/zero", 0666 | S_IFCHR, makedev(1, 5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue