mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
initramfs: remove clean_rootfs
There is no point in trying to clean up after unpacking the initramfs
failed, as it should never get past the magic number check. In addition
the current code only removes file that are direct children of the root
entry, which wasn't complete anyway
Fixes: df52092f3c
("fastboot: remove duplicate unpack_to_rootfs()")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
9ab6b71849
commit
b2a74d5f9d
@ -11,6 +11,7 @@
|
||||
#include <linux/utime.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/memblock.h>
|
||||
#include <linux/namei.h>
|
||||
|
||||
static ssize_t __init xwrite(int fd, const char *p, size_t count)
|
||||
{
|
||||
@ -572,53 +573,6 @@ static inline bool kexec_free_initrd(void)
|
||||
#endif /* CONFIG_KEXEC_CORE */
|
||||
|
||||
#ifdef CONFIG_BLK_DEV_RAM
|
||||
#define BUF_SIZE 1024
|
||||
static void __init clean_rootfs(void)
|
||||
{
|
||||
int fd;
|
||||
void *buf;
|
||||
struct linux_dirent64 *dirp;
|
||||
int num;
|
||||
|
||||
fd = ksys_open("/", O_RDONLY, 0);
|
||||
WARN_ON(fd < 0);
|
||||
if (fd < 0)
|
||||
return;
|
||||
buf = kzalloc(BUF_SIZE, GFP_KERNEL);
|
||||
WARN_ON(!buf);
|
||||
if (!buf) {
|
||||
ksys_close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
dirp = buf;
|
||||
num = ksys_getdents64(fd, dirp, BUF_SIZE);
|
||||
while (num > 0) {
|
||||
while (num > 0) {
|
||||
struct kstat st;
|
||||
int ret;
|
||||
|
||||
ret = vfs_lstat(dirp->d_name, &st);
|
||||
WARN_ON_ONCE(ret);
|
||||
if (!ret) {
|
||||
if (S_ISDIR(st.mode))
|
||||
ksys_rmdir(dirp->d_name);
|
||||
else
|
||||
ksys_unlink(dirp->d_name);
|
||||
}
|
||||
|
||||
num -= dirp->d_reclen;
|
||||
dirp = (void *)dirp + dirp->d_reclen;
|
||||
}
|
||||
dirp = buf;
|
||||
memset(buf, 0, BUF_SIZE);
|
||||
num = ksys_getdents64(fd, dirp, BUF_SIZE);
|
||||
}
|
||||
|
||||
ksys_close(fd);
|
||||
kfree(buf);
|
||||
}
|
||||
|
||||
static void __init populate_initrd_image(char *err)
|
||||
{
|
||||
ssize_t written;
|
||||
@ -658,7 +612,6 @@ static int __init populate_rootfs(void)
|
||||
err = unpack_to_rootfs((char *)initrd_start, initrd_end - initrd_start);
|
||||
if (err) {
|
||||
#ifdef CONFIG_BLK_DEV_RAM
|
||||
clean_rootfs();
|
||||
populate_initrd_image(err);
|
||||
#else
|
||||
printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err);
|
||||
|
Loading…
Reference in New Issue
Block a user