Merge branch 'rmobile' of git://git.denx.de/u-boot-sh
[oweals/u-boot.git] / fs / ext4 / ext4_write.c
index 3db22f8f93dadefb74af58b4ad3fa379daa47d62..e027916763f9b52937c7fe13f1698b67b94eb901 100644 (file)
@@ -23,6 +23,7 @@
 
 
 #include <common.h>
+#include <memalign.h>
 #include <linux/stat.h>
 #include <div64.h>
 #include "ext4_common.h"
@@ -562,6 +563,7 @@ static int ext4fs_delete_file(int inodeno)
 
        ext4fs_update();
        ext4fs_deinit();
+       ext4fs_reinit_global();
 
        if (ext4fs_init() != 0) {
                printf("error in File System init\n");
@@ -839,7 +841,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
        unsigned int ibmap_idx;
        struct ext_filesystem *fs = get_fs();
        ALLOC_CACHE_ALIGN_BUFFER(char, filename, 256);
-       memset(filename, 0x00, sizeof(filename));
+       memset(filename, 0x00, 256);
 
        g_parent_inode = zalloc(sizeof(struct ext2_inode));
        if (!g_parent_inode)
@@ -974,3 +976,29 @@ fail:
 
        return -1;
 }
+
+int ext4_write_file(const char *filename, void *buf, loff_t offset,
+                   loff_t len, loff_t *actwrite)
+{
+       int ret;
+
+       if (offset != 0) {
+               printf("** Cannot support non-zero offset **\n");
+               return -1;
+       }
+
+       ret = ext4fs_write(filename, buf, len);
+       if (ret) {
+               printf("** Error ext4fs_write() **\n");
+               goto fail;
+       }
+
+       *actwrite = len;
+
+       return 0;
+
+fail:
+       *actwrite = 0;
+
+       return -1;
+}