|
11 | 11 | #include <linux/utime.h>
|
12 | 12 | #include <linux/file.h>
|
13 | 13 | #include <linux/memblock.h>
|
| 14 | +#include <linux/namei.h> |
14 | 15 |
|
15 | 16 | static ssize_t __init xwrite(int fd, const char *p, size_t count)
|
16 | 17 | {
|
@@ -572,53 +573,6 @@ static inline bool kexec_free_initrd(void)
|
572 | 573 | #endif /* CONFIG_KEXEC_CORE */
|
573 | 574 |
|
574 | 575 | #ifdef CONFIG_BLK_DEV_RAM
|
575 |
| -#define BUF_SIZE 1024 |
576 |
| -static void __init clean_rootfs(void) |
577 |
| -{ |
578 |
| - int fd; |
579 |
| - void *buf; |
580 |
| - struct linux_dirent64 *dirp; |
581 |
| - int num; |
582 |
| - |
583 |
| - fd = ksys_open("/", O_RDONLY, 0); |
584 |
| - WARN_ON(fd < 0); |
585 |
| - if (fd < 0) |
586 |
| - return; |
587 |
| - buf = kzalloc(BUF_SIZE, GFP_KERNEL); |
588 |
| - WARN_ON(!buf); |
589 |
| - if (!buf) { |
590 |
| - ksys_close(fd); |
591 |
| - return; |
592 |
| - } |
593 |
| - |
594 |
| - dirp = buf; |
595 |
| - num = ksys_getdents64(fd, dirp, BUF_SIZE); |
596 |
| - while (num > 0) { |
597 |
| - while (num > 0) { |
598 |
| - struct kstat st; |
599 |
| - int ret; |
600 |
| - |
601 |
| - ret = vfs_lstat(dirp->d_name, &st); |
602 |
| - WARN_ON_ONCE(ret); |
603 |
| - if (!ret) { |
604 |
| - if (S_ISDIR(st.mode)) |
605 |
| - ksys_rmdir(dirp->d_name); |
606 |
| - else |
607 |
| - ksys_unlink(dirp->d_name); |
608 |
| - } |
609 |
| - |
610 |
| - num -= dirp->d_reclen; |
611 |
| - dirp = (void *)dirp + dirp->d_reclen; |
612 |
| - } |
613 |
| - dirp = buf; |
614 |
| - memset(buf, 0, BUF_SIZE); |
615 |
| - num = ksys_getdents64(fd, dirp, BUF_SIZE); |
616 |
| - } |
617 |
| - |
618 |
| - ksys_close(fd); |
619 |
| - kfree(buf); |
620 |
| -} |
621 |
| - |
622 | 576 | static void __init populate_initrd_image(char *err)
|
623 | 577 | {
|
624 | 578 | ssize_t written;
|
@@ -658,7 +612,6 @@ static int __init populate_rootfs(void)
|
658 | 612 | err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start);
|
659 | 613 | if (err) {
|
660 | 614 | #ifdef CONFIG_BLK_DEV_RAM
|
661 |
| - clean_rootfs(); |
662 | 615 | populate_initrd_image(err);
|
663 | 616 | #else
|
664 | 617 | printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err);
|
|
0 commit comments