Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/809309/?format=api
{ "id": 809309, "url": "http://patchwork.ozlabs.org/api/patches/809309/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20170903150031.18179-3-marek.behun@nic.cz/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170903150031.18179-3-marek.behun@nic.cz>", "list_archive_url": null, "date": "2017-09-03T15:00:24", "name": "[U-Boot,2/9] fs: Create a common fs_devread for ext4/reiserfs/zfs", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "cdfbadcdf26dc6931d930cb6086911b7c3efeaf6", "submitter": { "id": 71605, "url": "http://patchwork.ozlabs.org/api/people/71605/?format=api", "name": "Marek Behún", "email": "marek.behun@nic.cz" }, "delegate": { "id": 3651, "url": "http://patchwork.ozlabs.org/api/users/3651/?format=api", "username": "trini", "first_name": "Tom", "last_name": "Rini", "email": "trini@ti.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20170903150031.18179-3-marek.behun@nic.cz/mbox/", "series": [ { "id": 1246, "url": "http://patchwork.ozlabs.org/api/series/1246/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=1246", "date": "2017-09-03T15:00:25", "name": "Add single-device read-only BTRFS support", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/1246/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/809309/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/809309/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tsecure) header.d=nic.cz header.i=@nic.cz header.b=\"e1VW1md9\"; \n\tdkim-atps=neutral" ], "Received": [ "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xlbpj5bQ5z9t2y\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 4 Sep 2017 01:03:57 +1000 (AEST)", "by lists.denx.de (Postfix, from userid 105)\n\tid 6A1FAC21EE1; Sun, 3 Sep 2017 15:02:40 +0000 (UTC)", "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 5D3CBC21DBD;\n\tSun, 3 Sep 2017 15:01:38 +0000 (UTC)", "by lists.denx.de (Postfix, from userid 105)\n\tid F2597C21DBD; Sun, 3 Sep 2017 15:01:33 +0000 (UTC)", "from mail.nic.cz (mail.nic.cz [217.31.204.67])\n\tby lists.denx.de (Postfix) with ESMTPS id 4F7A8C21D65\n\tfor <u-boot@lists.denx.de>; Sun, 3 Sep 2017 15:01:33 +0000 (UTC)", "from dellmb.labs.office.nic.cz (unknown\n\t[IPv6:2001:1488:fffe:6:8982:ed8c:62b1:c0c8])\n\tby mail.nic.cz (Postfix) with ESMTP id 0A7FF6228B;\n\tSun, 3 Sep 2017 17:01:33 +0200 (CEST)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,\n\tT_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default;\n\tt=1504450893; bh=oo0F1Ywf6puzx+B0YFgF6cHiNY8e37YNSjxDTuRoZlo=;\n\th=From:To:Date;\n\tb=e1VW1md97JAJ6Cta06gHS/1xxw5q42G5UQJPDS8udSVtZxR/ma82mOJvpQs+pkJud\n\t0hoJvmUf2Ui5yFnp1snu5iDuSsPVFk5+d4LuGGmhrVULdZk/TEi66db1MTgIkHgqwT\n\to240jBlpbFhD1kAYix+HE74NZ3+XaLkxnbBO/X04=", "From": "=?utf-8?q?Marek_Beh=C3=BAn?= <marek.behun@nic.cz>", "To": "u-boot@lists.denx.de", "Date": "Sun, 3 Sep 2017 17:00:24 +0200", "Message-Id": "<20170903150031.18179-3-marek.behun@nic.cz>", "X-Mailer": "git-send-email 2.13.5", "In-Reply-To": "<20170903150031.18179-1-marek.behun@nic.cz>", "References": "<20170903150031.18179-1-marek.behun@nic.cz>", "X-Virus-Scanned": "clamav-milter 0.99.2 at mail", "X-Virus-Status": "Clean", "Cc": "Tomas Hlavacek <tomas.hlavacek@nic.cz>, Stefan Roese <sr@denx.de>,\n\t=?utf-8?q?Andreas_F=C3=A4rber?= <afaerber@suse.de>", "Subject": "[U-Boot] [PATCH 2/9] fs: Create a common fs_devread for\n\text4/reiserfs/zfs", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.18", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<http://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>" }, "content": "The ext4, reiserfs and zfs filesystems all have their own implementation\nof the same function, *_devread. Generalize this function into fs_devread\nand put the code into fs/fs_internal.c.\n\nSigned-off-by: Marek Behun <marek.behun@nic.cz>\n\n create mode 100644 fs/fs_internal.c\n create mode 100644 include/fs_internal.h", "diff": "diff --git a/fs/Makefile b/fs/Makefile\nindex 5770f41c0b..e5bf0df26f 100644\n--- a/fs/Makefile\n+++ b/fs/Makefile\n@@ -10,7 +10,7 @@ ifdef CONFIG_SPL_BUILD\n obj-$(CONFIG_SPL_FAT_SUPPORT) += fat/\n obj-$(CONFIG_SPL_EXT_SUPPORT) += ext4/\n else\n-obj-y\t\t\t\t+= fs.o\n+obj-y\t\t\t\t+= fs.o fs_internal.o\n \n obj-$(CONFIG_FS_CBFS) += cbfs/\n obj-$(CONFIG_CMD_CRAMFS) += cramfs/\ndiff --git a/fs/ext4/dev.c b/fs/ext4/dev.c\nindex ae2ba6a901..f04fa08f64 100644\n--- a/fs/ext4/dev.c\n+++ b/fs/ext4/dev.c\n@@ -26,7 +26,7 @@\n #include <common.h>\n #include <blk.h>\n #include <config.h>\n-#include <memalign.h>\n+#include <fs_internal.h>\n #include <ext4fs.h>\n #include <ext_common.h>\n #include \"ext4_common.h\"\n@@ -47,85 +47,11 @@ void ext4fs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info)\n \t\tget_fs()->dev_desc->log2blksz;\n }\n \n-int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf)\n+int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len,\n+\t\t char *buffer)\n {\n-\tunsigned block_len;\n-\tint log2blksz = ext4fs_blk_desc->log2blksz;\n-\tALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, (ext4fs_blk_desc ?\n-\t\t\t\t\t\t ext4fs_blk_desc->blksz :\n-\t\t\t\t\t\t 0));\n-\tif (ext4fs_blk_desc == NULL) {\n-\t\tprintf(\"** Invalid Block Device Descriptor (NULL)\\n\");\n-\t\treturn 0;\n-\t}\n-\n-\t/* Check partition boundaries */\n-\tif ((sector + ((byte_offset + byte_len - 1) >> log2blksz))\n-\t >= part_info->size) {\n-\t\tprintf(\"%s read outside partition \" LBAFU \"\\n\", __func__,\n-\t\t sector);\n-\t\treturn 0;\n-\t}\n-\n-\t/* Get the read to the beginning of a partition */\n-\tsector += byte_offset >> log2blksz;\n-\tbyte_offset &= ext4fs_blk_desc->blksz - 1;\n-\n-\tdebug(\" <\" LBAFU \", %d, %d>\\n\", sector, byte_offset, byte_len);\n-\n-\tif (byte_offset != 0) {\n-\t\tint readlen;\n-\t\t/* read first part which isn't aligned with start of sector */\n-\t\tif (blk_dread(ext4fs_blk_desc, part_info->start + sector, 1,\n-\t\t\t (void *)sec_buf) != 1) {\n-\t\t\tprintf(\" ** ext2fs_devread() read error **\\n\");\n-\t\t\treturn 0;\n-\t\t}\n-\t\treadlen = min((int)ext4fs_blk_desc->blksz - byte_offset,\n-\t\t\t byte_len);\n-\t\tmemcpy(buf, sec_buf + byte_offset, readlen);\n-\t\tbuf += readlen;\n-\t\tbyte_len -= readlen;\n-\t\tsector++;\n-\t}\n-\n-\tif (byte_len == 0)\n-\t\treturn 1;\n-\n-\t/* read sector aligned part */\n-\tblock_len = byte_len & ~(ext4fs_blk_desc->blksz - 1);\n-\n-\tif (block_len == 0) {\n-\t\tALLOC_CACHE_ALIGN_BUFFER(u8, p, ext4fs_blk_desc->blksz);\n-\n-\t\tblock_len = ext4fs_blk_desc->blksz;\n-\t\tblk_dread(ext4fs_blk_desc, part_info->start + sector, 1,\n-\t\t\t (void *)p);\n-\t\tmemcpy(buf, p, byte_len);\n-\t\treturn 1;\n-\t}\n-\n-\tif (blk_dread(ext4fs_blk_desc, part_info->start + sector,\n-\t\t block_len >> log2blksz, (void *)buf) !=\n-\t\t\tblock_len >> log2blksz) {\n-\t\tprintf(\" ** %s read error - block\\n\", __func__);\n-\t\treturn 0;\n-\t}\n-\tblock_len = byte_len & ~(ext4fs_blk_desc->blksz - 1);\n-\tbuf += block_len;\n-\tbyte_len -= block_len;\n-\tsector += block_len / ext4fs_blk_desc->blksz;\n-\n-\tif (byte_len != 0) {\n-\t\t/* read rest of data which are not in whole sector */\n-\t\tif (blk_dread(ext4fs_blk_desc, part_info->start + sector, 1,\n-\t\t\t (void *)sec_buf) != 1) {\n-\t\t\tprintf(\"* %s read error - last part\\n\", __func__);\n-\t\t\treturn 0;\n-\t\t}\n-\t\tmemcpy(buf, sec_buf, byte_len);\n-\t}\n-\treturn 1;\n+\treturn fs_devread(get_fs()->dev_desc, part_info, sector, byte_offset,\n+\t\t\t byte_len, buffer);\n }\n \n int ext4_read_superblock(char *buffer)\ndiff --git a/fs/fs_internal.c b/fs/fs_internal.c\nnew file mode 100644\nindex 0000000000..58b441030c\n--- /dev/null\n+++ b/fs/fs_internal.c\n@@ -0,0 +1,92 @@\n+/*\n+ * 2017 by Marek Behun <marek.behun@nic.cz>\n+ *\n+ * Derived from code in ext4/dev.c, which was based on reiserfs/dev.c\n+ *\n+ * SPDX-License-Identifier:\tGPL-2.0\n+ */\n+\n+#include <common.h>\n+#include <compiler.h>\n+#include <part.h>\n+#include <memalign.h>\n+\n+int fs_devread(struct blk_desc *blk, disk_partition_t *partition,\n+\t lbaint_t sector, int byte_offset, int byte_len, char *buf)\n+{\n+\tunsigned block_len;\n+\tint log2blksz = blk->log2blksz;\n+\tALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, (blk ? blk->blksz : 0));\n+\tif (blk == NULL) {\n+\t\tprintf(\"** Invalid Block Device Descriptor (NULL)\\n\");\n+\t\treturn 0;\n+\t}\n+\n+\t/* Check partition boundaries */\n+\tif ((sector + ((byte_offset + byte_len - 1) >> log2blksz))\n+\t >= partition->size) {\n+\t\tprintf(\"%s read outside partition \" LBAFU \"\\n\", __func__,\n+\t\t sector);\n+\t\treturn 0;\n+\t}\n+\n+\t/* Get the read to the beginning of a partition */\n+\tsector += byte_offset >> log2blksz;\n+\tbyte_offset &= blk->blksz - 1;\n+\n+\tdebug(\" <\" LBAFU \", %d, %d>\\n\", sector, byte_offset, byte_len);\n+\n+\tif (byte_offset != 0) {\n+\t\tint readlen;\n+\t\t/* read first part which isn't aligned with start of sector */\n+\t\tif (blk_dread(blk, partition->start + sector, 1,\n+\t\t\t (void *)sec_buf) != 1) {\n+\t\t\tprintf(\" ** %s read error **\\n\", __func__);\n+\t\t\treturn 0;\n+\t\t}\n+\t\treadlen = min((int)blk->blksz - byte_offset,\n+\t\t\t byte_len);\n+\t\tmemcpy(buf, sec_buf + byte_offset, readlen);\n+\t\tbuf += readlen;\n+\t\tbyte_len -= readlen;\n+\t\tsector++;\n+\t}\n+\n+\tif (byte_len == 0)\n+\t\treturn 1;\n+\n+\t/* read sector aligned part */\n+\tblock_len = byte_len & ~(blk->blksz - 1);\n+\n+\tif (block_len == 0) {\n+\t\tALLOC_CACHE_ALIGN_BUFFER(u8, p, blk->blksz);\n+\n+\t\tblock_len = blk->blksz;\n+\t\tblk_dread(blk, partition->start + sector, 1,\n+\t\t\t (void *)p);\n+\t\tmemcpy(buf, p, byte_len);\n+\t\treturn 1;\n+\t}\n+\n+\tif (blk_dread(blk, partition->start + sector,\n+\t\t block_len >> log2blksz, (void *)buf) !=\n+\t\t\tblock_len >> log2blksz) {\n+\t\tprintf(\" ** %s read error - block\\n\", __func__);\n+\t\treturn 0;\n+\t}\n+\tblock_len = byte_len & ~(blk->blksz - 1);\n+\tbuf += block_len;\n+\tbyte_len -= block_len;\n+\tsector += block_len / blk->blksz;\n+\n+\tif (byte_len != 0) {\n+\t\t/* read rest of data which are not in whole sector */\n+\t\tif (blk_dread(blk, partition->start + sector, 1,\n+\t\t\t (void *)sec_buf) != 1) {\n+\t\t\tprintf(\"* %s read error - last part\\n\", __func__);\n+\t\t\treturn 0;\n+\t\t}\n+\t\tmemcpy(buf, sec_buf, byte_len);\n+\t}\n+\treturn 1;\n+}\ndiff --git a/fs/reiserfs/dev.c b/fs/reiserfs/dev.c\nindex 5a1ab0a364..7b786e4ed3 100644\n--- a/fs/reiserfs/dev.c\n+++ b/fs/reiserfs/dev.c\n@@ -9,7 +9,7 @@\n #include <common.h>\n #include <config.h>\n #include <reiserfs.h>\n-\n+#include <fs_internal.h>\n #include \"reiserfs_private.h\"\n \n static struct blk_desc *reiserfs_blk_desc;\n@@ -22,78 +22,8 @@ void reiserfs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info)\n \tpart_info = info;\n }\n \n-\n-int reiserfs_devread (int sector, int byte_offset, int byte_len, char *buf)\n+int reiserfs_devread(int sector, int byte_offset, int byte_len, char *buf)\n {\n-\tchar sec_buf[SECTOR_SIZE];\n-\tunsigned block_len;\n-/*\n-\tunsigned len = byte_len;\n-\tu8 *start = buf;\n-*/\n-\t/*\n-\t* Check partition boundaries\n-\t*/\n-\tif (sector < 0\n-\t || ((sector + ((byte_offset + byte_len - 1) >> SECTOR_BITS))\n-\t >= part_info->size)) {\n-/*\t\terrnum = ERR_OUTSIDE_PART; */\n-\t\tprintf (\" ** reiserfs_devread() read outside partition\\n\");\n-\t\treturn 0;\n-\t}\n-\n-\t/*\n-\t * Get the read to the beginning of a partition.\n-\t */\n-\tsector += byte_offset >> SECTOR_BITS;\n-\tbyte_offset &= SECTOR_SIZE - 1;\n-\n-#if defined(DEBUG)\n-\tprintf (\" <%d, %d, %d> \", sector, byte_offset, byte_len);\n-#endif\n-\n-\n-\tif (reiserfs_blk_desc == NULL)\n-\t\treturn 0;\n-\n-\n-\tif (byte_offset != 0) {\n-\t\t/* read first part which isn't aligned with start of sector */\n-\t\tif (reiserfs_blk_desc->block_read(reiserfs_blk_desc,\n-\t\t\t\t\t\t part_info->start + sector,\n-\t\t\t\t\t\t 1, (void *)sec_buf) != 1) {\n-\t\t\tprintf (\" ** reiserfs_devread() read error\\n\");\n-\t\t\treturn 0;\n-\t\t}\n-\t\tmemcpy(buf, sec_buf+byte_offset, min(SECTOR_SIZE-byte_offset, byte_len));\n-\t\tbuf+=min(SECTOR_SIZE-byte_offset, byte_len);\n-\t\tbyte_len-=min(SECTOR_SIZE-byte_offset, byte_len);\n-\t\tsector++;\n-\t}\n-\n-\t/* read sector aligned part */\n-\tblock_len = byte_len & ~(SECTOR_SIZE-1);\n-\tif (reiserfs_blk_desc->block_read(reiserfs_blk_desc,\n-\t\t\t\t\t part_info->start + sector,\n-\t\t\t\t\t block_len / SECTOR_SIZE, (void *)buf)\n-\t\t\t!= block_len/SECTOR_SIZE) {\n-\t\tprintf (\" ** reiserfs_devread() read error - block\\n\");\n-\t\treturn 0;\n-\t}\n-\tbuf+=block_len;\n-\tbyte_len-=block_len;\n-\tsector+= block_len/SECTOR_SIZE;\n-\n-\tif ( byte_len != 0 ) {\n-\t\t/* read rest of data which are not in whole sector */\n-\t\tif (reiserfs_blk_desc->block_read(reiserfs_blk_desc,\n-\t\t\t\t\t\t part_info->start + sector,\n-\t\t\t\t\t\t 1, (void *)sec_buf) != 1) {\n-\t\t\tprintf (\" ** reiserfs_devread() read error - last part\\n\");\n-\t\t\treturn 0;\n-\t\t}\n-\t\tmemcpy(buf, sec_buf, byte_len);\n-\t}\n-\n-\treturn 1;\n+\treturn fs_devread(reiserfs_blk_desc, part_info, sector, byte_offset,\n+\t\t\t byte_len, buf);\n }\ndiff --git a/fs/zfs/dev.c b/fs/zfs/dev.c\nindex 2f409e66cd..7dda42b48b 100644\n--- a/fs/zfs/dev.c\n+++ b/fs/zfs/dev.c\n@@ -11,6 +11,7 @@\n \n #include <common.h>\n #include <config.h>\n+#include <fs_internal.h>\n #include <zfs_common.h>\n \n static struct blk_desc *zfs_blk_desc;\n@@ -25,87 +26,6 @@ void zfs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info)\n /* err */\n int zfs_devread(int sector, int byte_offset, int byte_len, char *buf)\n {\n-\tshort sec_buffer[SECTOR_SIZE/sizeof(short)];\n-\tchar *sec_buf = (char *)sec_buffer;\n-\tunsigned block_len;\n-\n-\t/*\n-\t *\tCheck partition boundaries\n-\t */\n-\tif ((sector < 0) ||\n-\t\t((sector + ((byte_offset + byte_len - 1) >> SECTOR_BITS)) >=\n-\t\t part_info->size)) {\n-\t\t/*\t\terrnum = ERR_OUTSIDE_PART; */\n-\t\tprintf(\" ** zfs_devread() read outside partition sector %d\\n\", sector);\n-\t\treturn 1;\n-\t}\n-\n-\t/*\n-\t *\tGet the read to the beginning of a partition.\n-\t */\n-\tsector += byte_offset >> SECTOR_BITS;\n-\tbyte_offset &= SECTOR_SIZE - 1;\n-\n-\tdebug(\" <%d, %d, %d>\\n\", sector, byte_offset, byte_len);\n-\n-\tif (zfs_blk_desc == NULL) {\n-\t\tprintf(\"** Invalid Block Device Descriptor (NULL)\\n\");\n-\t\treturn 1;\n-\t}\n-\n-\tif (byte_offset != 0) {\n-\t\t/* read first part which isn't aligned with start of sector */\n-\t\tif (zfs_blk_desc->block_read(zfs_blk_desc,\n-\t\t\t\t\t part_info->start + sector, 1,\n-\t\t\t\t\t (void *)sec_buf) != 1) {\n-\t\t\tprintf(\" ** zfs_devread() read error **\\n\");\n-\t\t\treturn 1;\n-\t\t}\n-\t\tmemcpy(buf, sec_buf + byte_offset,\n-\t\t\t min(SECTOR_SIZE - byte_offset, byte_len));\n-\t\tbuf += min(SECTOR_SIZE - byte_offset, byte_len);\n-\t\tbyte_len -= min(SECTOR_SIZE - byte_offset, byte_len);\n-\t\tsector++;\n-\t}\n-\n-\tif (byte_len == 0)\n-\t\treturn 0;\n-\n-\t/*\tread sector aligned part */\n-\tblock_len = byte_len & ~(SECTOR_SIZE - 1);\n-\n-\tif (block_len == 0) {\n-\t\tu8 p[SECTOR_SIZE];\n-\n-\t\tblock_len = SECTOR_SIZE;\n-\t\tzfs_blk_desc->block_read(zfs_blk_desc,\n-\t\t\t\t\t part_info->start + sector,\n-\t\t\t\t\t 1, (void *)p);\n-\t\tmemcpy(buf, p, byte_len);\n-\t\treturn 0;\n-\t}\n-\n-\tif (zfs_blk_desc->block_read(zfs_blk_desc, part_info->start + sector,\n-\t\t\t\t block_len / SECTOR_SIZE,\n-\t\t\t\t (void *)buf) != block_len / SECTOR_SIZE) {\n-\t\tprintf(\" ** zfs_devread() read error - block\\n\");\n-\t\treturn 1;\n-\t}\n-\n-\tblock_len = byte_len & ~(SECTOR_SIZE - 1);\n-\tbuf += block_len;\n-\tbyte_len -= block_len;\n-\tsector += block_len / SECTOR_SIZE;\n-\n-\tif (byte_len != 0) {\n-\t\t/* read rest of data which are not in whole sector */\n-\t\tif (zfs_blk_desc->block_read(zfs_blk_desc,\n-\t\t\t\t\t part_info->start + sector,\n-\t\t\t\t\t 1, (void *)sec_buf) != 1) {\n-\t\t\tprintf(\" ** zfs_devread() read error - last part\\n\");\n-\t\t\treturn 1;\n-\t\t}\n-\t\tmemcpy(buf, sec_buf, byte_len);\n-\t}\n-\treturn 0;\n+\treturn fs_devread(zfs_blk_desc, part_info, sector, byte_offset,\n+\t\t\t byte_len, buf);\n }\ndiff --git a/include/fs_internal.h b/include/fs_internal.h\nnew file mode 100644\nindex 0000000000..9d6dddd841\n--- /dev/null\n+++ b/include/fs_internal.h\n@@ -0,0 +1,17 @@\n+/*\n+ * 2017 by Marek Behun <marek.behun@nic.cz>\n+ *\n+ * Derived from code in ext4/dev.c, which was based on reiserfs/dev.c\n+ *\n+ * SPDX-License-Identifier:\tGPL-2.0\n+ */\n+\n+#ifndef __U_BOOT_FS_INTERNAL_H__\n+#define __U_BOOT_FS_INTERNAL_H__\n+\n+#include <part.h>\n+\n+int fs_devread(struct blk_desc *, disk_partition_t *, lbaint_t, int, int,\n+\t char *);\n+\n+#endif /* __U_BOOT_FS_INTERNAL_H__ */\n", "prefixes": [ "U-Boot", "2/9" ] }