summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorSuriyan Ramasami <suriyan.r@gmail.com>2014-11-17 14:39:36 -0800
committerTom Rini <trini@ti.com>2014-11-23 06:49:04 -0500
commit9f12cd0e062614e19734b2ab37842d387457c5e5 (patch)
tree81a892f216918c8a7904cd8adcc5a485f4f23288 /fs
parent1ad0b98a067a133c0e8a182649a76a4afd739594 (diff)
ext4: Prepare API change for files greater than 2GB
Change the internal EXT4 functions to use loff_t for offsets. Signed-off-by: Suriyan Ramasami <suriyan.r@gmail.com> Acked-by: Simon Glass <sjg@chromium.org> [trini: Update common/spl/spl_ext.c] Signed-off-by: Tom Rini <trini@ti.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/ext4_common.c24
-rw-r--r--fs/ext4/ext4_common.h4
-rw-r--r--fs/ext4/ext4_write.c32
-rw-r--r--fs/ext4/ext4fs.c43
4 files changed, 75 insertions, 28 deletions
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c
index cccc06a8889..cab5465b9d4 100644
--- a/fs/ext4/ext4_common.c
+++ b/fs/ext4/ext4_common.c
@@ -1892,6 +1892,7 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
{
unsigned int fpos = 0;
int status;
+ loff_t actread;
struct ext2fs_node *diro = (struct ext2fs_node *) dir;
#ifdef DEBUG
@@ -1909,8 +1910,8 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
status = ext4fs_read_file(diro, fpos,
sizeof(struct ext2_dirent),
- (char *) &dirent);
- if (status < 1)
+ (char *)&dirent, &actread);
+ if (status < 0)
return 0;
if (dirent.namelen != 0) {
@@ -1921,8 +1922,9 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
status = ext4fs_read_file(diro,
fpos +
sizeof(struct ext2_dirent),
- dirent.namelen, filename);
- if (status < 1)
+ dirent.namelen, filename,
+ &actread);
+ if (status < 0)
return 0;
fdiro = zalloc(sizeof(struct ext2fs_node));
@@ -2004,8 +2006,8 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
printf("< ? > ");
break;
}
- printf("%10d %s\n",
- __le32_to_cpu(fdiro->inode.size),
+ printf("%10u %s\n",
+ __le32_to_cpu(fdiro->inode.size),
filename);
}
free(fdiro);
@@ -2020,6 +2022,7 @@ static char *ext4fs_read_symlink(struct ext2fs_node *node)
char *symlink;
struct ext2fs_node *diro = node;
int status;
+ loff_t actread;
if (!diro->inode_read) {
status = ext4fs_read_inode(diro->data, diro->ino, &diro->inode);
@@ -2036,7 +2039,7 @@ static char *ext4fs_read_symlink(struct ext2fs_node *node)
} else {
status = ext4fs_read_file(diro, 0,
__le32_to_cpu(diro->inode.size),
- symlink);
+ symlink, &actread);
if (status == 0) {
free(symlink);
return 0;
@@ -2170,11 +2173,10 @@ int ext4fs_find_file(const char *path, struct ext2fs_node *rootnode,
return 1;
}
-int ext4fs_open(const char *filename)
+int ext4fs_open(const char *filename, loff_t *len)
{
struct ext2fs_node *fdiro = NULL;
int status;
- int len;
if (ext4fs_root == NULL)
return -1;
@@ -2191,10 +2193,10 @@ int ext4fs_open(const char *filename)
if (status == 0)
goto fail;
}
- len = __le32_to_cpu(fdiro->inode.size);
+ *len = __le32_to_cpu(fdiro->inode.size);
ext4fs_file = fdiro;
- return len;
+ return 0;
fail:
ext4fs_free_node(fdiro, &ext4fs_root->diropen);
diff --git a/fs/ext4/ext4_common.h b/fs/ext4/ext4_common.h
index 5fa1719f2ee..48fd2ac51db 100644
--- a/fs/ext4/ext4_common.h
+++ b/fs/ext4/ext4_common.h
@@ -50,8 +50,8 @@ static inline void *zalloc(size_t size)
int ext4fs_read_inode(struct ext2_data *data, int ino,
struct ext2_inode *inode);
-int ext4fs_read_file(struct ext2fs_node *node, int pos,
- unsigned int len, char *buf);
+int ext4fs_read_file(struct ext2fs_node *node, loff_t pos, loff_t len,
+ char *buf, loff_t *actread);
int ext4fs_find_file(const char *path, struct ext2fs_node *rootnode,
struct ext2fs_node **foundnode, int expecttype);
int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 648a59672c3..f7c52cc4cc1 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -975,3 +975,35 @@ 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;
+ }
+
+ /* 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();
+
+ return 0;
+
+fail:
+ ext4fs_close();
+
+ return -1;
+}
diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c
index 87d51285184..d82266f7f39 100644
--- a/fs/ext4/ext4fs.c
+++ b/fs/ext4/ext4fs.c
@@ -45,8 +45,8 @@ void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot)
* Optimized read file API : collects and defers contiguous sector
* reads into one potentially more efficient larger sequential read action
*/
-int ext4fs_read_file(struct ext2fs_node *node, int pos,
- unsigned int len, char *buf)
+int ext4fs_read_file(struct ext2fs_node *node, loff_t pos,
+ loff_t len, char *buf, loff_t *actread)
{
struct ext_filesystem *fs = get_fs();
int i;
@@ -150,7 +150,8 @@ int ext4fs_read_file(struct ext2fs_node *node, int pos,
previous_block_number = -1;
}
- return len;
+ *actread = len;
+ return 0;
}
int ext4fs_ls(const char *dirname)
@@ -176,23 +177,31 @@ int ext4fs_ls(const char *dirname)
int ext4fs_exists(const char *filename)
{
- int file_len;
+ loff_t file_len;
+ int ret;
- file_len = ext4fs_open(filename);
- return file_len >= 0;
+ ret = ext4fs_open(filename, &file_len);
+ return ret == 0;
}
int ext4fs_size(const char *filename)
{
- return ext4fs_open(filename);
+ loff_t size;
+ int ret;
+
+ ret = ext4fs_open(filename, &size);
+ if (ret)
+ return ret;
+ else
+ return size;
}
-int ext4fs_read(char *buf, unsigned len)
+int ext4fs_read(char *buf, loff_t len, loff_t *actread)
{
if (ext4fs_root == NULL || ext4fs_file == NULL)
return 0;
- return ext4fs_read_file(ext4fs_file, 0, len, buf);
+ return ext4fs_read_file(ext4fs_file, 0, len, buf, actread);
}
int ext4fs_probe(block_dev_desc_t *fs_dev_desc,
@@ -210,16 +219,17 @@ int ext4fs_probe(block_dev_desc_t *fs_dev_desc,
int ext4_read_file(const char *filename, void *buf, int offset, int len)
{
- int file_len;
- int len_read;
+ loff_t file_len;
+ loff_t len_read;
+ int ret;
if (offset != 0) {
printf("** Cannot support non-zero offset **\n");
return -1;
}
- file_len = ext4fs_open(filename);
- if (file_len < 0) {
+ ret = ext4fs_open(filename, &file_len);
+ if (ret < 0) {
printf("** File not found %s **\n", filename);
return -1;
}
@@ -227,9 +237,12 @@ int ext4_read_file(const char *filename, void *buf, int offset, int len)
if (len == 0)
len = file_len;
- len_read = ext4fs_read(buf, len);
+ ret = ext4fs_read(buf, len, &len_read);
- return len_read;
+ if (ret)
+ return ret;
+ else
+ return len_read;
}
int ext4fs_uuid(char *uuid_str)