diff options
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/dev.c | 1 | ||||
-rw-r--r-- | fs/ext4/ext4_common.c | 16 | ||||
-rw-r--r-- | fs/ext4/ext4_write.c | 10 |
3 files changed, 13 insertions, 14 deletions
diff --git a/fs/ext4/dev.c b/fs/ext4/dev.c index c77c02c..20f5256 100644 --- a/fs/ext4/dev.c +++ b/fs/ext4/dev.c @@ -25,6 +25,7 @@ #include <common.h> #include <config.h> +#include <memalign.h> #include <ext4fs.h> #include <ext_common.h> #include "ext4_common.h" diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index cab5465..727a2f7 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -24,6 +24,7 @@ #include <ext4fs.h> #include <inttypes.h> #include <malloc.h> +#include <memalign.h> #include <stddef.h> #include <linux/stat.h> #include <linux/time.h> @@ -614,8 +615,7 @@ static int parse_path(char **arr, char *dirname) arr[i] = zalloc(strlen("/") + 1); if (!arr[i]) return -ENOMEM; - - arr[i++] = "/"; + memcpy(arr[i++], "/", strlen("/")); /* add each path entry after root */ while (token != NULL) { @@ -745,6 +745,11 @@ end: fail: free(depth_dirname); free(parse_dirname); + for (i = 0; i < depth; i++) { + if (!ptr[i]) + break; + free(ptr[i]); + } free(ptr); free(parent_inode); free(first_inode); @@ -765,6 +770,7 @@ static int check_filename(char *filename, unsigned int blknr) struct ext2_dirent *previous_dir = NULL; char *ptr = NULL; struct ext_filesystem *fs = get_fs(); + int ret = -1; /* get the first block of root */ first_block_no_of_root = blknr; @@ -818,12 +824,12 @@ static int check_filename(char *filename, unsigned int blknr) if (ext4fs_put_metadata(root_first_block_addr, first_block_no_of_root)) goto fail; - return inodeno; + ret = inodeno; } fail: free(root_first_block_buffer); - return -1; + return ret; } int ext4fs_filename_check(char *filename) @@ -2040,7 +2046,7 @@ static char *ext4fs_read_symlink(struct ext2fs_node *node) status = ext4fs_read_file(diro, 0, __le32_to_cpu(diro->inode.size), symlink, &actread); - if (status == 0) { + if ((status < 0) || (actread == 0)) { free(symlink); return 0; } diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c index fbc4c4b..e027916 100644 --- a/fs/ext4/ext4_write.c +++ b/fs/ext4/ext4_write.c @@ -23,6 +23,7 @@ #include <common.h> +#include <memalign.h> #include <linux/stat.h> #include <div64.h> #include "ext4_common.h" @@ -986,26 +987,17 @@ int ext4_write_file(const char *filename, void *buf, loff_t offset, return -1; } - /* mount the filesystem */ - if (!ext4fs_mount(0)) { - printf("** Error Bad ext4 partition **\n"); - goto fail; - } - ret = ext4fs_write(filename, buf, len); - if (ret) { printf("** Error ext4fs_write() **\n"); goto fail; } - ext4fs_close(); *actwrite = len; return 0; fail: - ext4fs_close(); *actwrite = 0; return -1; |