1 // SPDX-License-Identifier: GPL-2.0 2 #include <linux/async.h> 3 #include <linux/delay.h> 4 #include <linux/dirent.h> 5 #include <linux/export.h> 6 #include <linux/fcntl.h> 7 #include <linux/file.h> 8 #include <linux/fs.h> 9 #include <linux/fs_struct.h> 10 #include <linux/hex.h> 11 #include <linux/init.h> 12 #include <linux/init_syscalls.h> 13 #include <linux/kstrtox.h> 14 #include <linux/memblock.h> 15 #include <linux/mm.h> 16 #include <linux/namei.h> 17 #include <linux/overflow.h> 18 #include <linux/security.h> 19 #include <linux/slab.h> 20 #include <linux/string.h> 21 #include <linux/syscalls.h> 22 #include <linux/types.h> 23 #include <linux/umh.h> 24 #include <linux/utime.h> 25 26 #include <asm/byteorder.h> 27 28 #include "do_mounts.h" 29 #include "initramfs_internal.h" 30 31 static __initdata bool csum_present; 32 static __initdata u32 io_csum; 33 34 static ssize_t __init xwrite(struct file *file, const unsigned char *p, 35 size_t count, loff_t *pos) 36 { 37 ssize_t out = 0; 38 39 /* sys_write only can write MAX_RW_COUNT aka 2G-4K bytes at most */ 40 while (count) { 41 ssize_t rv = kernel_write(file, p, count, pos); 42 43 if (rv < 0) { 44 if (rv == -EINTR || rv == -EAGAIN) 45 continue; 46 return out ? out : rv; 47 } else if (rv == 0) 48 break; 49 50 if (csum_present) { 51 ssize_t i; 52 53 for (i = 0; i < rv; i++) 54 io_csum += p[i]; 55 } 56 57 p += rv; 58 out += rv; 59 count -= rv; 60 } 61 62 return out; 63 } 64 65 static __initdata char *message; 66 static void __init error(char *x) 67 { 68 if (!message) 69 message = x; 70 } 71 72 #define panic_show_mem(fmt, ...) \ 73 ({ show_mem(); panic(fmt, ##__VA_ARGS__); }) 74 75 /* link hash */ 76 77 #define N_ALIGN(len) ((((len) + 1) & ~3) + 2) 78 79 static __initdata struct hash { 80 int ino, minor, major; 81 umode_t mode; 82 struct hash *next; 83 char name[]; 84 } *head[32]; 85 static __initdata bool hardlink_seen; 86 87 static inline int hash(int major, int minor, int ino) 88 { 89 unsigned long tmp = ino + minor + (major << 3); 90 tmp += tmp >> 5; 91 return tmp & 31; 92 } 93 94 static char __init *find_link(int major, int minor, int ino, 95 umode_t mode, const char *name, size_t nlen) 96 { 97 struct hash **p, *q; 98 for (p = head + hash(major, minor, ino); *p; p = &(*p)->next) { 99 if ((*p)->ino != ino) 100 continue; 101 if ((*p)->minor != minor) 102 continue; 103 if ((*p)->major != major) 104 continue; 105 if (((*p)->mode ^ mode) & S_IFMT) 106 continue; 107 return (*p)->name; 108 } 109 110 q = kmalloc_flex(struct hash, name, nlen); 111 if (!q) 112 panic_show_mem("can't allocate link hash entry"); 113 q->major = major; 114 q->minor = minor; 115 q->ino = ino; 116 q->mode = mode; 117 strscpy(q->name, name, nlen); 118 q->next = NULL; 119 *p = q; 120 hardlink_seen = true; 121 return NULL; 122 } 123 124 static void __init free_hash(void) 125 { 126 struct hash **p, *q; 127 for (p = head; hardlink_seen && p < head + 32; p++) { 128 while (*p) { 129 q = *p; 130 *p = q->next; 131 kfree(q); 132 } 133 } 134 hardlink_seen = false; 135 } 136 137 #ifdef CONFIG_INITRAMFS_PRESERVE_MTIME 138 static void __init do_utime(char *filename, time64_t mtime) 139 { 140 struct timespec64 t[2] = { { .tv_sec = mtime }, { .tv_sec = mtime } }; 141 init_utimes(filename, t); 142 } 143 144 static void __init do_utime_path(const struct path *path, time64_t mtime) 145 { 146 struct timespec64 t[2] = { { .tv_sec = mtime }, { .tv_sec = mtime } }; 147 vfs_utimes(path, t); 148 } 149 150 static __initdata LIST_HEAD(dir_list); 151 struct dir_entry { 152 struct list_head list; 153 time64_t mtime; 154 char name[]; 155 }; 156 157 static void __init dir_add(const char *name, size_t nlen, time64_t mtime) 158 { 159 struct dir_entry *de; 160 161 de = kmalloc_flex(*de, name, nlen); 162 if (!de) 163 panic_show_mem("can't allocate dir_entry buffer"); 164 INIT_LIST_HEAD(&de->list); 165 strscpy(de->name, name, nlen); 166 de->mtime = mtime; 167 list_add(&de->list, &dir_list); 168 } 169 170 static void __init dir_utime(void) 171 { 172 struct dir_entry *de, *tmp; 173 list_for_each_entry_safe(de, tmp, &dir_list, list) { 174 list_del(&de->list); 175 do_utime(de->name, de->mtime); 176 kfree(de); 177 } 178 } 179 #else 180 static void __init do_utime(char *filename, time64_t mtime) {} 181 static void __init do_utime_path(const struct path *path, time64_t mtime) {} 182 static void __init dir_add(const char *name, size_t nlen, time64_t mtime) {} 183 static void __init dir_utime(void) {} 184 #endif 185 186 static __initdata time64_t mtime; 187 188 /* cpio header parsing */ 189 190 static __initdata unsigned long ino, major, minor, nlink; 191 static __initdata umode_t mode; 192 static __initdata unsigned long body_len, name_len; 193 static __initdata uid_t uid; 194 static __initdata gid_t gid; 195 static __initdata unsigned rdev; 196 static __initdata u32 hdr_csum; 197 198 static int __init parse_header(char *s) 199 { 200 __be32 header[13]; 201 int ret; 202 203 ret = hex2bin((u8 *)header, s + 6, sizeof(header)); 204 if (ret) { 205 error("damaged header"); 206 return ret; 207 } 208 209 ino = be32_to_cpu(header[0]); 210 mode = be32_to_cpu(header[1]); 211 uid = be32_to_cpu(header[2]); 212 gid = be32_to_cpu(header[3]); 213 nlink = be32_to_cpu(header[4]); 214 mtime = be32_to_cpu(header[5]); /* breaks in y2106 */ 215 body_len = be32_to_cpu(header[6]); 216 major = be32_to_cpu(header[7]); 217 minor = be32_to_cpu(header[8]); 218 rdev = new_encode_dev(MKDEV(be32_to_cpu(header[9]), be32_to_cpu(header[10]))); 219 name_len = be32_to_cpu(header[11]); 220 hdr_csum = be32_to_cpu(header[12]); 221 return 0; 222 } 223 224 /* Finite-state machine */ 225 226 static __initdata enum state { 227 Start, 228 Collect, 229 GotHeader, 230 SkipIt, 231 GotName, 232 CopyFile, 233 GotSymlink, 234 Reset 235 } state, next_state; 236 237 static __initdata char *victim; 238 static unsigned long byte_count __initdata; 239 static __initdata loff_t this_header, next_header; 240 241 static inline void __init eat(unsigned n) 242 { 243 victim += n; 244 this_header += n; 245 byte_count -= n; 246 } 247 248 static __initdata char *collected; 249 static long remains __initdata; 250 static __initdata char *collect; 251 252 static void __init read_into(char *buf, unsigned size, enum state next) 253 { 254 if (byte_count >= size) { 255 collected = victim; 256 eat(size); 257 state = next; 258 } else { 259 collect = collected = buf; 260 remains = size; 261 next_state = next; 262 state = Collect; 263 } 264 } 265 266 static __initdata char *header_buf, *symlink_buf, *name_buf; 267 268 static int __init do_start(void) 269 { 270 read_into(header_buf, CPIO_HDRLEN, GotHeader); 271 return 0; 272 } 273 274 static int __init do_collect(void) 275 { 276 unsigned long n = remains; 277 if (byte_count < n) 278 n = byte_count; 279 memcpy(collect, victim, n); 280 eat(n); 281 collect += n; 282 if ((remains -= n) != 0) 283 return 1; 284 state = next_state; 285 return 0; 286 } 287 288 static int __init do_header(void) 289 { 290 if (!memcmp(collected, "070701", 6)) { 291 csum_present = false; 292 } else if (!memcmp(collected, "070702", 6)) { 293 csum_present = true; 294 } else { 295 if (memcmp(collected, "070707", 6) == 0) 296 error("incorrect cpio method used: use -H newc option"); 297 else 298 error("no cpio magic"); 299 return 1; 300 } 301 if (parse_header(collected)) 302 return 1; 303 next_header = this_header + N_ALIGN(name_len) + body_len; 304 next_header = (next_header + 3) & ~3; 305 state = SkipIt; 306 if (name_len <= 0 || name_len > PATH_MAX) 307 return 0; 308 if (S_ISLNK(mode)) { 309 if (body_len > PATH_MAX) 310 return 0; 311 collect = collected = symlink_buf; 312 remains = N_ALIGN(name_len) + body_len; 313 next_state = GotSymlink; 314 state = Collect; 315 return 0; 316 } 317 if (S_ISREG(mode) || !body_len) 318 read_into(name_buf, N_ALIGN(name_len), GotName); 319 return 0; 320 } 321 322 static int __init do_skip(void) 323 { 324 if (this_header + byte_count < next_header) { 325 eat(byte_count); 326 return 1; 327 } else { 328 eat(next_header - this_header); 329 state = next_state; 330 return 0; 331 } 332 } 333 334 static int __init do_reset(void) 335 { 336 while (byte_count && *victim == '\0') 337 eat(1); 338 if (byte_count && (this_header & 3)) 339 error("broken padding"); 340 return 1; 341 } 342 343 static void __init clean_path(char *path, umode_t fmode) 344 { 345 struct kstat st; 346 347 if (!init_stat(path, &st, AT_SYMLINK_NOFOLLOW) && 348 (st.mode ^ fmode) & S_IFMT) { 349 if (S_ISDIR(st.mode)) 350 init_rmdir(path); 351 else 352 init_unlink(path); 353 } 354 } 355 356 static int __init maybe_link(void) 357 { 358 if (nlink >= 2) { 359 char *old = find_link(major, minor, ino, mode, collected, name_len); 360 if (old) { 361 clean_path(collected, 0); 362 return (init_link(old, collected) < 0) ? -1 : 1; 363 } 364 } 365 return 0; 366 } 367 368 static __initdata struct file *wfile; 369 static __initdata loff_t wfile_pos; 370 371 static int __init do_name(void) 372 { 373 state = SkipIt; 374 next_state = Reset; 375 376 /* name_len > 0 && name_len <= PATH_MAX checked in do_header */ 377 if (collected[name_len - 1] != '\0') { 378 pr_err("initramfs name without nulterm: %.*s\n", 379 (int)name_len, collected); 380 error("malformed archive"); 381 return 1; 382 } 383 384 if (strcmp(collected, "TRAILER!!!") == 0) { 385 free_hash(); 386 return 0; 387 } 388 clean_path(collected, mode); 389 if (S_ISREG(mode)) { 390 int ml = maybe_link(); 391 if (ml >= 0) { 392 int openflags = O_WRONLY|O_CREAT|O_LARGEFILE; 393 if (ml != 1) 394 openflags |= O_TRUNC; 395 wfile = filp_open(collected, openflags, mode); 396 if (IS_ERR(wfile)) 397 return 0; 398 wfile_pos = 0; 399 io_csum = 0; 400 401 vfs_fchown(wfile, uid, gid); 402 vfs_fchmod(wfile, mode); 403 if (body_len) 404 vfs_truncate(&wfile->f_path, body_len); 405 state = CopyFile; 406 } 407 } else if (S_ISDIR(mode)) { 408 init_mkdir(collected, mode); 409 init_chown(collected, uid, gid, 0); 410 init_chmod(collected, mode); 411 dir_add(collected, name_len, mtime); 412 } else if (S_ISBLK(mode) || S_ISCHR(mode) || 413 S_ISFIFO(mode) || S_ISSOCK(mode)) { 414 if (maybe_link() == 0) { 415 init_mknod(collected, mode, rdev); 416 init_chown(collected, uid, gid, 0); 417 init_chmod(collected, mode); 418 do_utime(collected, mtime); 419 } 420 } 421 return 0; 422 } 423 424 static int __init do_copy(void) 425 { 426 if (byte_count >= body_len) { 427 if (xwrite(wfile, victim, body_len, &wfile_pos) != body_len) 428 error("write error"); 429 430 do_utime_path(&wfile->f_path, mtime); 431 fput(wfile); 432 if (csum_present && io_csum != hdr_csum) 433 error("bad data checksum"); 434 eat(body_len); 435 state = SkipIt; 436 return 0; 437 } else { 438 if (xwrite(wfile, victim, byte_count, &wfile_pos) != byte_count) 439 error("write error"); 440 body_len -= byte_count; 441 eat(byte_count); 442 return 1; 443 } 444 } 445 446 static int __init do_symlink(void) 447 { 448 if (collected[name_len - 1] != '\0') { 449 pr_err("initramfs symlink without nulterm: %.*s\n", 450 (int)name_len, collected); 451 error("malformed archive"); 452 return 1; 453 } 454 collected[N_ALIGN(name_len) + body_len] = '\0'; 455 clean_path(collected, 0); 456 init_symlink(collected + N_ALIGN(name_len), collected); 457 init_chown(collected, uid, gid, AT_SYMLINK_NOFOLLOW); 458 do_utime(collected, mtime); 459 state = SkipIt; 460 next_state = Reset; 461 return 0; 462 } 463 464 static __initdata int (*actions[])(void) = { 465 [Start] = do_start, 466 [Collect] = do_collect, 467 [GotHeader] = do_header, 468 [SkipIt] = do_skip, 469 [GotName] = do_name, 470 [CopyFile] = do_copy, 471 [GotSymlink] = do_symlink, 472 [Reset] = do_reset, 473 }; 474 475 static long __init write_buffer(char *buf, unsigned long len) 476 { 477 byte_count = len; 478 victim = buf; 479 480 while (!actions[state]()) 481 ; 482 return len - byte_count; 483 } 484 485 static long __init flush_buffer(void *bufv, unsigned long len) 486 { 487 char *buf = bufv; 488 long written; 489 long origLen = len; 490 if (message) 491 return -1; 492 while ((written = write_buffer(buf, len)) < len && !message) { 493 char c = buf[written]; 494 if (c == '0') { 495 buf += written; 496 len -= written; 497 state = Start; 498 } else if (c == 0) { 499 buf += written; 500 len -= written; 501 state = Reset; 502 } else 503 error("junk within compressed archive"); 504 } 505 return origLen; 506 } 507 508 static unsigned long my_inptr __initdata; /* index of next byte to be processed in inbuf */ 509 510 #include <linux/decompress/generic.h> 511 512 /** 513 * unpack_to_rootfs - decompress and extract an initramfs archive 514 * @buf: input initramfs archive to extract 515 * @len: length of initramfs data to process 516 * 517 * Returns: NULL for success or an error message string 518 * 519 * This symbol shouldn't be used externally. It's available for unit tests. 520 */ 521 char * __init unpack_to_rootfs(char *buf, unsigned long len) 522 { 523 long written; 524 decompress_fn decompress; 525 const char *compress_name; 526 struct { 527 char header[CPIO_HDRLEN]; 528 char symlink[PATH_MAX + N_ALIGN(PATH_MAX) + 1]; 529 char name[N_ALIGN(PATH_MAX)]; 530 } *bufs = kmalloc_obj(*bufs); 531 532 if (!bufs) 533 panic_show_mem("can't allocate buffers"); 534 535 header_buf = bufs->header; 536 symlink_buf = bufs->symlink; 537 name_buf = bufs->name; 538 539 state = Start; 540 this_header = 0; 541 message = NULL; 542 while (!message && len) { 543 loff_t saved_offset = this_header; 544 if (*buf == '0' && !(this_header & 3)) { 545 state = Start; 546 written = write_buffer(buf, len); 547 buf += written; 548 len -= written; 549 continue; 550 } 551 if (!*buf) { 552 buf++; 553 len--; 554 this_header++; 555 continue; 556 } 557 this_header = 0; 558 decompress = decompress_method(buf, len, &compress_name); 559 pr_debug("Detected %s compressed data\n", compress_name); 560 if (decompress) { 561 int res = decompress(buf, len, NULL, flush_buffer, NULL, 562 &my_inptr, error); 563 if (res) 564 error("decompressor failed"); 565 } else if (compress_name) { 566 pr_err("compression method %s not configured\n", 567 compress_name); 568 error("decompressor failed"); 569 } else 570 error("invalid magic at start of compressed archive"); 571 if (state != Reset) 572 error("junk at the end of compressed archive"); 573 this_header = saved_offset + my_inptr; 574 buf += my_inptr; 575 len -= my_inptr; 576 } 577 dir_utime(); 578 /* free any hardlink state collected without optional TRAILER!!! */ 579 free_hash(); 580 kfree(bufs); 581 return message; 582 } 583 584 static int __initdata do_retain_initrd; 585 unsigned long initrd_mem_end __initdata; 586 587 static int __init retain_initrd_param(char *str) 588 { 589 if (*str) 590 return 0; 591 do_retain_initrd = 1; 592 return 1; 593 } 594 __setup("retain_initrd", retain_initrd_param); 595 596 #ifdef CONFIG_ARCH_HAS_KEEPINITRD 597 static int __init keepinitrd_setup(char *__unused) 598 { 599 do_retain_initrd = 1; 600 return 1; 601 } 602 __setup("keepinitrd", keepinitrd_setup); 603 #endif 604 605 static bool __initdata initramfs_async = true; 606 static int __init initramfs_async_setup(char *str) 607 { 608 return kstrtobool(str, &initramfs_async) == 0; 609 } 610 __setup("initramfs_async=", initramfs_async_setup); 611 612 extern char __initramfs_start[]; 613 extern unsigned long __initramfs_size; 614 #include <linux/initrd.h> 615 #include <linux/kexec.h> 616 617 static BIN_ATTR(initrd, 0440, sysfs_bin_attr_simple_read, NULL, 0); 618 619 void __init reserve_initrd_mem(void) 620 { 621 phys_addr_t start; 622 unsigned long size; 623 624 /* Ignore the virtual address computed during device tree parsing */ 625 initrd_start = initrd_end = 0; 626 627 if (!phys_initrd_size) 628 return; 629 /* 630 * Round the memory region to page boundaries as per free_initrd_mem() 631 * This allows us to detect whether the pages overlapping the initrd 632 * are in use, but more importantly, reserves the entire set of pages 633 * as we don't want these pages allocated for other purposes. 634 */ 635 start = round_down(phys_initrd_start, PAGE_SIZE); 636 size = phys_initrd_size + (phys_initrd_start - start); 637 size = round_up(size, PAGE_SIZE); 638 639 if (!memblock_is_region_memory(start, size)) { 640 pr_err("INITRD: 0x%08llx+0x%08lx is not a memory region", 641 (u64)start, size); 642 goto disable; 643 } 644 645 if (memblock_is_region_reserved(start, size)) { 646 pr_err("INITRD: 0x%08llx+0x%08lx overlaps in-use memory region\n", 647 (u64)start, size); 648 goto disable; 649 } 650 651 memblock_reserve(start, size); 652 /* Now convert initrd to virtual addresses */ 653 initrd_start = (unsigned long)__va(phys_initrd_start); 654 initrd_end = initrd_start + phys_initrd_size; 655 initrd_below_start_ok = 1; 656 657 return; 658 disable: 659 pr_cont(" - disabling initrd\n"); 660 initrd_start = 0; 661 initrd_end = 0; 662 } 663 664 void __weak __init free_initrd_mem(unsigned long start, unsigned long end) 665 { 666 free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM, 667 "initrd"); 668 } 669 670 #ifdef CONFIG_CRASH_RESERVE 671 static bool __init kexec_free_initrd(void) 672 { 673 unsigned long crashk_start = (unsigned long)__va(crashk_res.start); 674 unsigned long crashk_end = (unsigned long)__va(crashk_res.end); 675 676 /* 677 * If the initrd region is overlapped with crashkernel reserved region, 678 * free only memory that is not part of crashkernel region. 679 */ 680 if (initrd_start >= crashk_end || initrd_end <= crashk_start) 681 return false; 682 683 /* 684 * Initialize initrd memory region since the kexec boot does not do. 685 */ 686 memset((void *)initrd_start, 0, initrd_end - initrd_start); 687 if (initrd_start < crashk_start) 688 free_initrd_mem(initrd_start, crashk_start); 689 if (initrd_end > crashk_end) 690 free_initrd_mem(crashk_end, initrd_end); 691 return true; 692 } 693 #else 694 static inline bool kexec_free_initrd(void) 695 { 696 return false; 697 } 698 #endif /* CONFIG_KEXEC_CORE */ 699 700 #ifdef CONFIG_BLK_DEV_RAM 701 static void __init populate_initrd_image(char *err) 702 { 703 ssize_t written; 704 struct file *file; 705 loff_t pos = 0; 706 707 printk(KERN_INFO "rootfs image is not initramfs (%s); looks like an initrd\n", 708 err); 709 file = filp_open("/initrd.image", O_WRONLY|O_CREAT|O_LARGEFILE, 0700); 710 if (IS_ERR(file)) 711 return; 712 713 written = xwrite(file, (char *)initrd_start, initrd_end - initrd_start, 714 &pos); 715 if (written != initrd_end - initrd_start) 716 pr_err("/initrd.image: incomplete write (%zd != %ld)\n", 717 written, initrd_end - initrd_start); 718 fput(file); 719 } 720 #endif /* CONFIG_BLK_DEV_RAM */ 721 722 static void __init unpack_initramfs(async_cookie_t cookie) 723 { 724 /* Load the built in initramfs */ 725 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size); 726 if (err) 727 panic_show_mem("%s", err); /* Failed to decompress INTERNAL initramfs */ 728 729 if (!initrd_start || IS_ENABLED(CONFIG_INITRAMFS_FORCE)) 730 return; 731 732 if (IS_ENABLED(CONFIG_BLK_DEV_RAM)) 733 printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n"); 734 else 735 printk(KERN_INFO "Unpacking initramfs...\n"); 736 737 err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start); 738 if (err) { 739 #ifdef CONFIG_BLK_DEV_RAM 740 populate_initrd_image(err); 741 #else 742 printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err); 743 #endif 744 } 745 } 746 747 static void __init do_populate_rootfs(void *unused, async_cookie_t cookie) 748 { 749 scoped_with_init_fs() { 750 unpack_initramfs(cookie); 751 security_initramfs_populated(); 752 } 753 754 /* 755 * The bootconfig loader trims the bootconfig off initrd_end. Restore 756 * it to free the memory used by the bootconfig too, unless the initrd 757 * is retained (which must not expose the bootconfig). 758 */ 759 if (!do_retain_initrd && initrd_start && initrd_end < initrd_mem_end) 760 initrd_end = initrd_mem_end; 761 initrd_mem_end = 0; 762 763 /* 764 * If the initrd region is overlapped with crashkernel reserved region, 765 * free only memory that is not part of crashkernel region. 766 */ 767 if (!do_retain_initrd && initrd_start && !kexec_free_initrd()) { 768 free_initrd_mem(initrd_start, initrd_end); 769 } else if (do_retain_initrd && initrd_start) { 770 bin_attr_initrd.size = initrd_end - initrd_start; 771 bin_attr_initrd.private = (void *)initrd_start; 772 if (sysfs_create_bin_file(firmware_kobj, &bin_attr_initrd)) 773 pr_err("Failed to create initrd sysfs file"); 774 } 775 initrd_start = 0; 776 initrd_end = 0; 777 778 init_flush_fput(); 779 } 780 781 static ASYNC_DOMAIN_EXCLUSIVE(initramfs_domain); 782 static async_cookie_t initramfs_cookie; 783 784 void wait_for_initramfs(void) 785 { 786 if (!initramfs_cookie) { 787 /* 788 * Something before rootfs_initcall wants to access 789 * the filesystem/initramfs. Probably a bug. Make a 790 * note, avoid deadlocking the machine, and let the 791 * caller's access fail as it used to. 792 */ 793 pr_warn_once("wait_for_initramfs() called before rootfs_initcalls\n"); 794 return; 795 } 796 async_synchronize_cookie_domain(initramfs_cookie + 1, &initramfs_domain); 797 } 798 EXPORT_SYMBOL_GPL(wait_for_initramfs); 799 800 static int __init populate_rootfs(void) 801 { 802 initramfs_cookie = async_schedule_domain(do_populate_rootfs, NULL, 803 &initramfs_domain); 804 usermodehelper_enable(); 805 if (!initramfs_async) 806 wait_for_initramfs(); 807 return 0; 808 } 809 rootfs_initcall(populate_rootfs); 810