diff options
Diffstat (limited to 'fs/ext4/ext_barebox.c')
-rw-r--r-- | fs/ext4/ext_barebox.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/fs/ext4/ext_barebox.c b/fs/ext4/ext_barebox.c index 82d4c581e0..df82b629cd 100644 --- a/fs/ext4/ext_barebox.c +++ b/fs/ext4/ext_barebox.c @@ -3,9 +3,6 @@ * * Copyright (c) 2012 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix * - * See file CREDITS for list of people who contributed to this - * project. - * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. @@ -30,15 +27,15 @@ #include <fcntl.h> #include "ext4_common.h" -int ext4fs_devread(struct ext_filesystem *fs, int __sector, int byte_offset, - int byte_len, char *buf) +ssize_t ext4fs_devread(struct ext_filesystem *fs, sector_t __sector, int byte_offset, + size_t byte_len, char *buf) { ssize_t size; uint64_t sector = __sector; size = cdev_read(fs->cdev, buf, byte_len, sector * SECTOR_SIZE + byte_offset, 0); if (size < 0) { - dev_err(fs->dev, "read error at sector %d: %s\n", __sector, + dev_err(fs->dev, "read error at sector %llu: %s\n", __sector, strerror(-size)); return size; } @@ -51,7 +48,7 @@ static inline struct ext2fs_node *to_ext2_node(struct inode *inode) return container_of(inode, struct ext2fs_node, i); } -static int ext_read(struct device_d *_dev, FILE *f, void *buf, size_t insize) +static int ext_read(struct device *_dev, FILE *f, void *buf, size_t insize) { struct inode *inode = f->f_inode; struct ext2fs_node *node = to_ext2_node(inode); @@ -61,7 +58,7 @@ static int ext_read(struct device_d *_dev, FILE *f, void *buf, size_t insize) static struct inode *ext_alloc_inode(struct super_block *sb) { - struct fs_device_d *fsdev = container_of(sb, struct fs_device_d, sb); + struct fs_device *fsdev = container_of(sb, struct fs_device, sb); struct ext_filesystem *fs = fsdev->dev.priv; struct ext2fs_node *node; @@ -121,7 +118,7 @@ static struct dentry *ext_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) { struct ext2fs_node *e2dir = to_ext2_node(dir); - int ret, ino; + int ret, ino = 0; struct inode *inode; ret = ext4fs_get_ino(e2dir, &dentry->d_name, &ino); @@ -130,8 +127,8 @@ static struct dentry *ext_lookup(struct inode *dir, struct dentry *dentry, if (ino) { inode = ext_get_inode(dir->i_sb, ino); - - d_add(dentry, inode); + if (inode) + d_add(dentry, inode); } return NULL; @@ -212,7 +209,7 @@ struct inode *ext_get_inode(struct super_block *sb, int ino) { struct inode *inode; struct ext2fs_node *node; - struct fs_device_d *fsdev = container_of(sb, struct fs_device_d, sb); + struct fs_device *fsdev = container_of(sb, struct fs_device, sb); struct ext_filesystem *fs = fsdev->dev.priv; int ret; @@ -221,10 +218,12 @@ struct inode *ext_get_inode(struct super_block *sb, int ino) node = container_of(inode, struct ext2fs_node, i); ret = ext4fs_read_inode(fs->data, ino, &node->inode); + if (ret) + return NULL; inode->i_ino = ino; inode->i_mode = le16_to_cpu(node->inode.mode); - inode->i_size = le32_to_cpu(node->inode.size); + inode->i_size = ext4_isize(node); switch (inode->i_mode & S_IFMT) { default: @@ -250,9 +249,9 @@ struct inode *ext_get_inode(struct super_block *sb, int ino) return inode; } -static int ext_probe(struct device_d *dev) +static int ext_probe(struct device *dev) { - struct fs_device_d *fsdev = dev_to_fs_device(dev); + struct fs_device *fsdev = dev_to_fs_device(dev); int ret; struct ext_filesystem *fs; struct super_block *sb = &fsdev->sb; @@ -265,29 +264,33 @@ static int ext_probe(struct device_d *dev) ret = fsdev_open_cdev(fsdev); if (ret) - goto err_open; + goto err; fs->cdev = fsdev->cdev; ret = ext4fs_mount(fs); if (ret) - goto err_mount; + goto err; sb->s_op = &ext_ops; inode = ext_get_inode(sb, 2); + if (!inode) { + ret = -EINVAL; + goto err; + } + sb->s_root = d_make_root(inode); return 0; -err_mount: -err_open: +err: free(fs); return ret; } -static void ext_remove(struct device_d *dev) +static void ext_remove(struct device *dev) { struct ext_filesystem *fs = dev->priv; @@ -295,7 +298,7 @@ static void ext_remove(struct device_d *dev) free(fs); } -static struct fs_driver_d ext_driver = { +static struct fs_driver ext_driver = { .read = ext_read, .type = filetype_ext, .flags = 0, |