Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/809310/?format=api
{ "id": 809310, "url": "http://patchwork.ozlabs.org/api/patches/809310/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20170903150031.18179-8-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-8-marek.behun@nic.cz>", "list_archive_url": null, "date": "2017-09-03T15:00:29", "name": "[U-Boot,7/9] fs: btrfs: Add U-Boot fs handlers.", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "1c9fa34bce02c65609892093e7cfe6403972067d", "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-8-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/809310/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/809310/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=\"l3vfuLkM\"; \n\tdkim-atps=neutral" ], "Received": [ "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xlbq569VKz9t2y\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 4 Sep 2017 01:04:17 +1000 (AEST)", "by lists.denx.de (Postfix, from userid 105)\n\tid 70B3BC21F2C; Sun, 3 Sep 2017 15:03:06 +0000 (UTC)", "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id A771DC21E6F;\n\tSun, 3 Sep 2017 15:01:39 +0000 (UTC)", "by lists.denx.de (Postfix, from userid 105)\n\tid 2B661C21D99; Sun, 3 Sep 2017 15:01:34 +0000 (UTC)", "from mail.nic.cz (mail.nic.cz [217.31.204.67])\n\tby lists.denx.de (Postfix) with ESMTPS id A5CFDC21C4F\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 61C3F62402;\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=h32KfZP7ciEXKKJojg4pfFRmKeH5uTzqOn8/8DJ2CZA=;\n\th=From:To:Date;\n\tb=l3vfuLkM2WVPl9v2ATJUqVL5EjxRFotfoe5IO9A5oiadhjk/sLxo1vP3KdEe2q2Uo\n\tRqRXp7wUhUN9CqbbShKyuCImzm+cgoQC9IYzvGw5U8JE23+SF42Rm+tgBTCXQQy4Zz\n\tEFRuH5Chof/Dh9mMw54KFNTyQi5fJbbVk4HiLFDg=", "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:29 +0200", "Message-Id": "<20170903150031.18179-8-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 7/9] fs: btrfs: Add U-Boot fs handlers.", "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": "Signed-off-by: Marek Behun <marek.behun@nic.cz>\n\n create mode 100644 fs/btrfs/Kconfig\n create mode 100644 fs/btrfs/Makefile\n create mode 100644 fs/btrfs/btrfs.c\n create mode 100644 include/btrfs.h", "diff": "diff --git a/fs/Kconfig b/fs/Kconfig\nindex e6803ac8cb..1cb9831be8 100644\n--- a/fs/Kconfig\n+++ b/fs/Kconfig\n@@ -4,6 +4,8 @@\n \n menu \"File systems\"\n \n+source \"fs/btrfs/Kconfig\"\n+\n source \"fs/cbfs/Kconfig\"\n \n source \"fs/ext4/Kconfig\"\ndiff --git a/fs/Makefile b/fs/Makefile\nindex e5bf0df26f..84d1d30f09 100644\n--- a/fs/Makefile\n+++ b/fs/Makefile\n@@ -12,6 +12,7 @@ obj-$(CONFIG_SPL_EXT_SUPPORT) += ext4/\n else\n obj-y\t\t\t\t+= fs.o fs_internal.o\n \n+obj-$(CONFIG_FS_BTRFS) += btrfs/\n obj-$(CONFIG_FS_CBFS) += cbfs/\n obj-$(CONFIG_CMD_CRAMFS) += cramfs/\n obj-$(CONFIG_FS_EXT4) += ext4/\ndiff --git a/fs/btrfs/Kconfig b/fs/btrfs/Kconfig\nnew file mode 100644\nindex 0000000000..22909d9fcc\n--- /dev/null\n+++ b/fs/btrfs/Kconfig\n@@ -0,0 +1,9 @@\n+config FS_BTRFS\n+\tbool \"Enable BTRFS filesystem support\"\n+\tselect CRC32C\n+\tselect LZO\n+\tselect RBTREE\n+\thelp\n+\t This provides a single-device read-only BTRFS support. BTRFS is a\n+\t next-generation Linux file system based on the copy-on-write\n+\t principle.\ndiff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile\nnew file mode 100644\nindex 0000000000..01731557e6\n--- /dev/null\n+++ b/fs/btrfs/Makefile\n@@ -0,0 +1,8 @@\n+#\n+# 2017 Marek Behun, CZ.NIC, marek.behun@nic.cz\n+#\n+# SPDX-License-Identifier:\tGPL-2.0+\n+#\n+\n+obj-y := btrfs.o chunk-map.o compression.o ctree.o dev.o dir-item.o \\\n+\textent-io.o hash.o inode.o root.o subvolume.o super.o\ndiff --git a/fs/btrfs/btrfs.c b/fs/btrfs/btrfs.c\nnew file mode 100644\nindex 0000000000..4140e2bc20\n--- /dev/null\n+++ b/fs/btrfs/btrfs.c\n@@ -0,0 +1,227 @@\n+/*\n+ * BTRFS filesystem implementation for U-Boot\n+ *\n+ * 2017 Marek Behun, CZ.NIC, marek.behun@nic.cz\n+ *\n+ * SPDX-License-Identifier:\tGPL-2.0+\n+ */\n+\n+#include \"btrfs.h\"\n+#include <config.h>\n+#include <malloc.h>\n+#include <linux/time.h>\n+\n+struct btrfs_info btrfs_info;\n+\n+static int readdir_callback(const struct btrfs_root *root,\n+\t\t\t struct btrfs_dir_item *item)\n+{\n+\tstatic const char typestr[BTRFS_FT_MAX][4] = {\n+\t\t[BTRFS_FT_UNKNOWN] = \" ? \",\n+\t\t[BTRFS_FT_REG_FILE] = \" \",\n+\t\t[BTRFS_FT_DIR] = \"DIR\",\n+\t\t[BTRFS_FT_CHRDEV] = \"CHR\",\n+\t\t[BTRFS_FT_BLKDEV] = \"BLK\",\n+\t\t[BTRFS_FT_FIFO] = \"FIF\",\n+\t\t[BTRFS_FT_SOCK] = \"SCK\",\n+\t\t[BTRFS_FT_SYMLINK] = \"SYM\",\n+\t\t[BTRFS_FT_XATTR] = \" ? \",\n+\t};\n+\tstruct btrfs_inode_item inode;\n+\tconst char *name = (const char *) (item + 1);\n+\tchar filetime[32], *target = NULL;\n+\ttime_t mtime;\n+\n+\tif (btrfs_lookup_inode(root, &item->location, &inode, NULL)) {\n+\t\tprintf(\"%s: Cannot find inode item for directory entry %.*s!\\n\",\n+\t\t __func__, item->name_len, name);\n+\t\treturn 0;\n+\t}\n+\n+\tmtime = inode.mtime.sec;\n+\tctime_r(&mtime, filetime);\n+\n+\tif (item->type == BTRFS_FT_SYMLINK) {\n+\t\ttarget = malloc(min(inode.size + 1,\n+\t\t\t\t (u64) btrfs_info.sb.sectorsize));\n+\n+\t\tif (target && btrfs_readlink(root, item->location.objectid,\n+\t\t\t\t\t target)) {\n+\t\t\tfree(target);\n+\t\t\ttarget = NULL;\n+\t\t}\n+\n+\t\tif (!target)\n+\t\t\tprintf(\"%s: Cannot read symlink target!\\n\", __func__);\n+\t}\n+\n+\tprintf(\"<%s> \", typestr[item->type]);\n+\tif (item->type == BTRFS_FT_CHRDEV || item->type == BTRFS_FT_BLKDEV)\n+\t\tprintf(\"%4u,%5u \", (unsigned int) (inode.rdev >> 20),\n+\t\t\t(unsigned int) (inode.rdev & 0xfffff));\n+\telse\n+\t\tprintf(\"%10llu \", inode.size);\n+\n+\tprintf(\"%24.24s %.*s\", filetime, item->name_len, name);\n+\n+\tif (item->type == BTRFS_FT_SYMLINK) {\n+\t\tprintf(\" -> %s\", target ? target : \"?\");\n+\t\tif (target)\n+\t\t\tfree(target);\n+\t}\n+\n+\tprintf(\"\\n\");\n+\n+\treturn 0;\n+}\n+\n+int btrfs_probe(struct blk_desc *fs_dev_desc, disk_partition_t *fs_partition)\n+{\n+\tbtrfs_blk_desc = fs_dev_desc;\n+\tbtrfs_part_info = fs_partition;\n+\n+\tmemset(&btrfs_info, 0, sizeof(btrfs_info));\n+\n+\tbtrfs_hash_init();\n+\tif (btrfs_read_superblock())\n+\t\treturn -1;\n+\n+\tif (btrfs_chunk_map_init()) {\n+\t\tprintf(\"%s: failed to init chunk map\\n\", __func__);\n+\t\treturn -1;\n+\t}\n+\n+\tbtrfs_info.tree_root.objectid = 0;\n+\tbtrfs_info.tree_root.bytenr = btrfs_info.sb.root;\n+\tbtrfs_info.chunk_root.objectid = 0;\n+\tbtrfs_info.chunk_root.bytenr = btrfs_info.sb.chunk_root;\n+\n+\tif (btrfs_read_chunk_tree()) {\n+\t\tprintf(\"%s: failed to read chunk tree\\n\", __func__);\n+\t\treturn -1;\n+\t}\n+\n+\tif (btrfs_find_root(btrfs_get_default_subvol_objectid(),\n+\t\t\t &btrfs_info.fs_root, NULL)) {\n+\t\tprintf(\"%s: failed to find default subvolume\\n\", __func__);\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int btrfs_ls(const char *path)\n+{\n+\tstruct btrfs_root root = btrfs_info.fs_root;\n+\tu64 inr;\n+\tu8 type;\n+\n+\tinr = btrfs_lookup_path(&root, root.root_dirid, path, &type, NULL, 40);\n+\n+\tif (inr == -1ULL) {\n+\t\tprintf(\"Cannot lookup path %s\\n\", path);\n+\t\treturn 1;\n+\t}\n+\n+\tif (type != BTRFS_FT_DIR) {\n+\t\tprintf(\"Not a directory: %s\\n\", path);\n+\t\treturn 1;\n+\t}\n+\n+\tif (btrfs_readdir(&root, inr, readdir_callback)) {\n+\t\tprintf(\"An error occured while listing directory %s\\n\", path);\n+\t\treturn 1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+int btrfs_exists(const char *file)\n+{\n+\tstruct btrfs_root root = btrfs_info.fs_root;\n+\tu64 inr;\n+\tu8 type;\n+\n+\tinr = btrfs_lookup_path(&root, root.root_dirid, file, &type, NULL, 40);\n+\n+\treturn (inr != -1ULL && type == BTRFS_FT_REG_FILE);\n+}\n+\n+int btrfs_size(const char *file, loff_t *size)\n+{\n+\tstruct btrfs_root root = btrfs_info.fs_root;\n+\tstruct btrfs_inode_item inode;\n+\tu64 inr;\n+\tu8 type;\n+\n+\tinr = btrfs_lookup_path(&root, root.root_dirid, file, &type, &inode,\n+\t\t\t\t40);\n+\n+\tif (inr == -1ULL) {\n+\t\tprintf(\"Cannot lookup file %s\\n\", file);\n+\t\treturn 1;\n+\t}\n+\n+\tif (type != BTRFS_FT_REG_FILE) {\n+\t\tprintf(\"Not a regular file: %s\\n\", file);\n+\t\treturn 1;\n+\t}\n+\n+\t*size = inode.size;\n+\treturn 0;\n+}\n+\n+int btrfs_read(const char *file, void *buf, loff_t offset, loff_t len,\n+\t loff_t *actread)\n+{\n+\tstruct btrfs_root root = btrfs_info.fs_root;\n+\tstruct btrfs_inode_item inode;\n+\tu64 inr, rd;\n+\tu8 type;\n+\n+\tinr = btrfs_lookup_path(&root, root.root_dirid, file, &type, &inode,\n+\t\t\t\t40);\n+\n+\tif (inr == -1ULL) {\n+\t\tprintf(\"Cannot lookup file %s\\n\", file);\n+\t\treturn 1;\n+\t}\n+\n+\tif (type != BTRFS_FT_REG_FILE) {\n+\t\tprintf(\"Not a regular file: %s\\n\", file);\n+\t\treturn 1;\n+\t}\n+\n+\tif (!len)\n+\t\tlen = inode.size;\n+\n+\tif (len > inode.size - offset)\n+\t\tlen = inode.size - offset;\n+\n+\trd = btrfs_file_read(&root, inr, offset, len, buf);\n+\tif (rd == -1ULL) {\n+\t\tprintf(\"An error occured while reading file %s\\n\", file);\n+\t\treturn 1;\n+\t}\n+\n+\t*actread = rd;\n+\treturn 0;\n+}\n+\n+void btrfs_close(void)\n+{\n+\tbtrfs_chunk_map_exit();\n+}\n+\n+int btrfs_uuid(char *uuid_str)\n+{\n+#ifdef CONFIG_LIB_UUID\n+\tuuid_bin_to_str(btrfs_info.sb.fsid, uuid_str, UUID_STR_FORMAT_STD);\n+\treturn 0;\n+#endif\n+\treturn -ENOSYS;\n+}\n+\n+/*\n+\t\tbtrfs_list_subvols();\n+*/\ndiff --git a/fs/fs.c b/fs/fs.c\nindex 13cd3626c6..6bb2531450 100644\n--- a/fs/fs.c\n+++ b/fs/fs.c\n@@ -14,6 +14,7 @@\n #include <fs.h>\n #include <sandboxfs.h>\n #include <ubifs_uboot.h>\n+#include <btrfs.h>\n #include <asm/io.h>\n #include <div64.h>\n #include <linux/math64.h>\n@@ -163,6 +164,21 @@ static struct fstype_info fstypes[] = {\n \t\t.uuid = fs_uuid_unsupported,\n \t},\n #endif\n+#ifdef CONFIG_FS_BTRFS\n+\t{\n+\t\t.fstype = FS_TYPE_BTRFS,\n+\t\t.name = \"btrfs\",\n+\t\t.null_dev_desc_ok = false,\n+\t\t.probe = btrfs_probe,\n+\t\t.close = btrfs_close,\n+\t\t.ls = btrfs_ls,\n+\t\t.exists = btrfs_exists,\n+\t\t.size = btrfs_size,\n+\t\t.read = btrfs_read,\n+\t\t.write = fs_write_unsupported,\n+\t\t.uuid = btrfs_uuid,\n+\t},\n+#endif\n \t{\n \t\t.fstype = FS_TYPE_ANY,\n \t\t.name = \"unsupported\",\ndiff --git a/include/btrfs.h b/include/btrfs.h\nnew file mode 100644\nindex 0000000000..7390975ea7\n--- /dev/null\n+++ b/include/btrfs.h\n@@ -0,0 +1,21 @@\n+/*\n+ * BTRFS filesystem implementation for U-Boot\n+ *\n+ * 2017 Marek Behun, CZ.NIC, marek.behun@nic.cz\n+ *\n+ * SPDX-License-Identifier:\tGPL-2.0+\n+ */\n+\n+#ifndef __U_BOOT_BTRFS_H__\n+#define __U_BOOT_BTRFS_H__\n+\n+int btrfs_probe(struct blk_desc *, disk_partition_t *);\n+int btrfs_ls(const char *);\n+int btrfs_exists(const char *);\n+int btrfs_size(const char *, loff_t *);\n+int btrfs_read(const char *, void *, loff_t, loff_t, loff_t *);\n+void btrfs_close(void);\n+int btrfs_uuid(char *);\n+void btrfs_list_subvols(void);\n+\n+#endif /* __U_BOOT_BTRFS_H__ */\ndiff --git a/include/fs.h b/include/fs.h\nindex 2f2aca8378..2e1b9a13ed 100644\n--- a/include/fs.h\n+++ b/include/fs.h\n@@ -13,6 +13,7 @@\n #define FS_TYPE_EXT\t2\n #define FS_TYPE_SANDBOX\t3\n #define FS_TYPE_UBIFS\t4\n+#define FS_TYPE_BTRFS\t5\n \n /*\n * Tell the fs layer which block device an partition to use for future\n", "prefixes": [ "U-Boot", "7/9" ] }