Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/809108/?format=api
{ "id": 809108, "url": "http://patchwork.ozlabs.org/api/patches/809108/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20170902163806.27265-5-robdclark@gmail.com/", "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": "<20170902163806.27265-5-robdclark@gmail.com>", "list_archive_url": null, "date": "2017-09-02T16:37:59", "name": "[U-Boot,v2,4/8] fs: add fs_readdir()", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "762813cdb50c213f67768cd68fd044d2ec8b7752", "submitter": { "id": 18760, "url": "http://patchwork.ozlabs.org/api/people/18760/?format=api", "name": "Rob Clark", "email": "robdclark@gmail.com" }, "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/20170902163806.27265-5-robdclark@gmail.com/mbox/", "series": [ { "id": 1165, "url": "http://patchwork.ozlabs.org/api/series/1165/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=1165", "date": "2017-09-02T16:37:55", "name": "fs/fat: cleanups + readdir implementation", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/1165/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/809108/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/809108/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\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"ZYE4oSBt\"; dkim-atps=neutral" ], "Received": [ "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xl21k5lKPz9sRW\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 3 Sep 2017 02:41:30 +1000 (AEST)", "by lists.denx.de (Postfix, from userid 105)\n\tid 7B610C21E2F; Sat, 2 Sep 2017 16:40:05 +0000 (UTC)", "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 18DC4C21C5C;\n\tSat, 2 Sep 2017 16:39:12 +0000 (UTC)", "by lists.denx.de (Postfix, from userid 105)\n\tid 6DD78C21ECF; Sat, 2 Sep 2017 16:38:43 +0000 (UTC)", "from mail-qk0-f196.google.com (mail-qk0-f196.google.com\n\t[209.85.220.196])\n\tby lists.denx.de (Postfix) with ESMTPS id 3A4ACC21F82\n\tfor <u-boot@lists.denx.de>; Sat, 2 Sep 2017 16:38:40 +0000 (UTC)", "by mail-qk0-f196.google.com with SMTP id p67so2035126qkd.2\n\tfor <u-boot@lists.denx.de>; Sat, 02 Sep 2017 09:38:40 -0700 (PDT)", "from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a])\n\tby smtp.gmail.com with ESMTPSA id\n\tt71sm1037868qka.61.2017.09.02.09.38.37\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSat, 02 Sep 2017 09:38:37 -0700 (PDT)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-0.0 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=YOttKJPLLjBeI3Rk+e0xlp0yyotywLZ6H6HV9FsdAO8=;\n\tb=ZYE4oSBt6owhNqjSwRfsQO+Hh5/zwyhisxyPUciX9WC0tqjbwiBCfnP9/oBA9V7T4F\n\t81YxIG1Y+O5UEOeCJk1L6Ku/neRkeImZIuRXxNpmEueYPG+iQ/GT9Iz5gVnM70CuV+y4\n\tL7bPs4LtkvcoKHeXeQLccMmUE9q/xWdiGiBLVubMy58FNI+VzPs723nBL+bfQKWQweh1\n\tk74ptfq5deWxg2h8AOKMzZ+gMpzHoFHmzAnjikTSLscT3T9NbiRouHPwV37Q3ZomX07g\n\t47/+roI0yvMNvWTxuOHTS76AEKNpECz5kq32FN7R4FvHfO4XLEJxsVoqqNa/fnTk6wDQ\n\t/PSg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=YOttKJPLLjBeI3Rk+e0xlp0yyotywLZ6H6HV9FsdAO8=;\n\tb=S2okEUnl9g1gdEng0AqbtZRuDVSHdrOK5XJWfCOZqoEZJJAP3Fg6KuLSDUKeg+r6ev\n\tb5Z7BAdIncPHYDYFnQfBEySZStKz7DTCHmAyluPRUH0OAv4/IycSpfDqHo2E5mMVOiNz\n\tqyLy2/l4dTkNL+APcgQ6Nf6KoEqm67Ku6myK8guWN3dV7P4HpXmnQ5flLZCzMYY2OrzI\n\t3S9EBV4D4qNUKm+2SEsugxMbCwPQy9np+3OqItQNedtzsUct0QBWt3dMWzYj9PFped/Q\n\tx6WqkVvVvjT/BtlJHgEf7ip7+oOcZA3Cs+/a2ijEmDafjqlVm95pq86bWObmR0uWyf21\n\td6+A==", "X-Gm-Message-State": "AHPjjUgcZDUy8uK6kO7Dj8kUnWmGAWzOIymIzMQMmqHq0etnUZLAt5RP\n\tETCINPc1orAA8mkA208=", "X-Google-Smtp-Source": "ADKCNb7c0Vch7CVEpd8UsTcnypsqfVgCZV5kXRUGpaTa0TBya8maeM13id0PCrjUFkog7wAURrBEWg==", "X-Received": "by 10.55.78.77 with SMTP id c74mr7230794qkb.51.1504370318843;\n\tSat, 02 Sep 2017 09:38:38 -0700 (PDT)", "From": "Rob Clark <robdclark@gmail.com>", "To": "U-Boot Mailing List <u-boot@lists.denx.de>", "Date": "Sat, 2 Sep 2017 12:37:59 -0400", "Message-Id": "<20170902163806.27265-5-robdclark@gmail.com>", "X-Mailer": "git-send-email 2.13.5", "In-Reply-To": "<20170902163806.27265-1-robdclark@gmail.com>", "References": "<20170902163806.27265-1-robdclark@gmail.com>", "Cc": "Petr Kulhavy <brain@jikos.cz>, Zhikang Zhang <zhikang.zhang@nxp.com>,\n\tAlison Chaiken <alison@peloton-tech.com>,\n\tSteve Rae <steve.rae@raedomain.com>", "Subject": "[U-Boot] [PATCH v2 4/8] fs: add fs_readdir()", "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": "Needed to support efi file protocol. The fallback.efi loader wants\nto be able to read the contents of the /EFI directory to find an OS\nto boot.\n\nModelled after POSIX opendir()/readdir()/closedir(). Unlike the other\nfs APIs, this is stateful (ie. state is held in the FS_DIR \"directory\nstream\"), to avoid re-traversing of the directory structure at each\nstep. The directory stream must be released with closedir() when it\nis no longer needed.\n\nSigned-off-by: Rob Clark <robdclark@gmail.com>\n---\n disk/part.c | 31 ++++++++++++--------\n fs/fs.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n include/fs.h | 55 +++++++++++++++++++++++++++++++++++\n include/part.h | 4 +++\n 4 files changed, 169 insertions(+), 12 deletions(-)", "diff": "diff --git a/disk/part.c b/disk/part.c\nindex c67fdacc79..aa9183d696 100644\n--- a/disk/part.c\n+++ b/disk/part.c\n@@ -331,6 +331,24 @@ int part_get_info(struct blk_desc *dev_desc, int part,\n \treturn -1;\n }\n \n+int part_get_info_whole_disk(struct blk_desc *dev_desc, disk_partition_t *info)\n+{\n+\tinfo->start = 0;\n+\tinfo->size = dev_desc->lba;\n+\tinfo->blksz = dev_desc->blksz;\n+\tinfo->bootable = 0;\n+\tstrcpy((char *)info->type, BOOT_PART_TYPE);\n+\tstrcpy((char *)info->name, \"Whole Disk\");\n+#if CONFIG_IS_ENABLED(PARTITION_UUIDS)\n+\tinfo->uuid[0] = 0;\n+#endif\n+#ifdef CONFIG_PARTITION_TYPE_GUID\n+\tinfo->type_guid[0] = 0;\n+#endif\n+\n+\treturn 0;\n+}\n+\n int blk_get_device_by_str(const char *ifname, const char *dev_hwpart_str,\n \t\t\t struct blk_desc **dev_desc)\n {\n@@ -523,18 +541,7 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str,\n \n \t\t(*dev_desc)->log2blksz = LOG2((*dev_desc)->blksz);\n \n-\t\tinfo->start = 0;\n-\t\tinfo->size = (*dev_desc)->lba;\n-\t\tinfo->blksz = (*dev_desc)->blksz;\n-\t\tinfo->bootable = 0;\n-\t\tstrcpy((char *)info->type, BOOT_PART_TYPE);\n-\t\tstrcpy((char *)info->name, \"Whole Disk\");\n-#if CONFIG_IS_ENABLED(PARTITION_UUIDS)\n-\t\tinfo->uuid[0] = 0;\n-#endif\n-#ifdef CONFIG_PARTITION_TYPE_GUID\n-\t\tinfo->type_guid[0] = 0;\n-#endif\n+\t\tpart_get_info_whole_disk(*dev_desc, info);\n \n \t\tret = 0;\n \t\tgoto cleanup;\ndiff --git a/fs/fs.c b/fs/fs.c\nindex 13cd3626c6..441c880654 100644\n--- a/fs/fs.c\n+++ b/fs/fs.c\n@@ -21,6 +21,7 @@\n DECLARE_GLOBAL_DATA_PTR;\n \n static struct blk_desc *fs_dev_desc;\n+static int fs_dev_part;\n static disk_partition_t fs_partition;\n static int fs_type = FS_TYPE_ANY;\n \n@@ -69,6 +70,11 @@ static inline int fs_uuid_unsupported(char *uuid_str)\n \treturn -1;\n }\n \n+static inline int fs_opendir_unsupported(const char *filename, FS_DIR **dirp)\n+{\n+\treturn -EACCES;\n+}\n+\n struct fstype_info {\n \tint fstype;\n \tchar *name;\n@@ -92,6 +98,9 @@ struct fstype_info {\n \t\t loff_t len, loff_t *actwrite);\n \tvoid (*close)(void);\n \tint (*uuid)(char *uuid_str);\n+\tint (*opendir)(const char *filename, FS_DIR **dirp);\n+\tint (*readdir)(FS_DIR *dirp);\n+\tvoid (*closedir)(FS_DIR *dirp);\n };\n \n static struct fstype_info fstypes[] = {\n@@ -112,6 +121,7 @@ static struct fstype_info fstypes[] = {\n \t\t.write = fs_write_unsupported,\n #endif\n \t\t.uuid = fs_uuid_unsupported,\n+\t\t.opendir = fs_opendir_unsupported,\n \t},\n #endif\n #ifdef CONFIG_FS_EXT4\n@@ -131,6 +141,7 @@ static struct fstype_info fstypes[] = {\n \t\t.write = fs_write_unsupported,\n #endif\n \t\t.uuid = ext4fs_uuid,\n+\t\t.opendir = fs_opendir_unsupported,\n \t},\n #endif\n #ifdef CONFIG_SANDBOX\n@@ -146,6 +157,7 @@ static struct fstype_info fstypes[] = {\n \t\t.read = fs_read_sandbox,\n \t\t.write = fs_write_sandbox,\n \t\t.uuid = fs_uuid_unsupported,\n+\t\t.opendir = fs_opendir_unsupported,\n \t},\n #endif\n #ifdef CONFIG_CMD_UBIFS\n@@ -161,6 +173,7 @@ static struct fstype_info fstypes[] = {\n \t\t.read = ubifs_read,\n \t\t.write = fs_write_unsupported,\n \t\t.uuid = fs_uuid_unsupported,\n+\t\t.opendir = fs_opendir_unsupported,\n \t},\n #endif\n \t{\n@@ -175,6 +188,7 @@ static struct fstype_info fstypes[] = {\n \t\t.read = fs_read_unsupported,\n \t\t.write = fs_write_unsupported,\n \t\t.uuid = fs_uuid_unsupported,\n+\t\t.opendir = fs_opendir_unsupported,\n \t},\n };\n \n@@ -228,6 +242,31 @@ int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype)\n \n \t\tif (!info->probe(fs_dev_desc, &fs_partition)) {\n \t\t\tfs_type = info->fstype;\n+\t\t\tfs_dev_part = part;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\treturn -1;\n+}\n+\n+/* set current blk device w/ blk_desc + partition # */\n+int fs_set_blk_dev2(struct blk_desc *desc, int part)\n+{\n+\tstruct fstype_info *info;\n+\tint ret, i;\n+\n+\tif (part >= 1)\n+\t\tret = part_get_info(desc, part, &fs_partition);\n+\telse\n+\t\tret = part_get_info_whole_disk(desc, &fs_partition);\n+\tif (ret)\n+\t\treturn ret;\n+\tfs_dev_desc = desc;\n+\n+\tfor (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes); i++, info++) {\n+\t\tif (!info->probe(fs_dev_desc, &fs_partition)) {\n+\t\t\tfs_type = info->fstype;\n \t\t\treturn 0;\n \t\t}\n \t}\n@@ -334,6 +373,58 @@ int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len,\n \treturn ret;\n }\n \n+FS_DIR *fs_opendir(const char *filename)\n+{\n+\tstruct fstype_info *info = fs_get_info(fs_type);\n+\tFS_DIR *dirp = NULL;\n+\tint ret;\n+\n+\tret = info->opendir(filename, &dirp);\n+\tfs_close();\n+\tif (ret) {\n+\t\terrno = -ret;\n+\t\treturn NULL;\n+\t}\n+\n+\tdirp->desc = fs_dev_desc;\n+\tdirp->part = fs_dev_part;\n+\n+\treturn dirp;\n+}\n+\n+struct fs_dirent *fs_readdir(FS_DIR *dirp)\n+{\n+\tstruct fstype_info *info;\n+\tint ret;\n+\n+\tfs_set_blk_dev2(dirp->desc, dirp->part);\n+\tinfo = fs_get_info(fs_type);\n+\n+\tmemset(&dirp->dirent, 0, sizeof(dirp->dirent));\n+\n+\tret = info->readdir(dirp);\n+\tfs_close();\n+\tif (ret)\n+\t\treturn NULL;\n+\n+\treturn &dirp->dirent;;\n+}\n+\n+void fs_closedir(FS_DIR *dirp)\n+{\n+\tstruct fstype_info *info;\n+\n+\tif (!dirp)\n+\t\treturn;\n+\n+\tfs_set_blk_dev2(dirp->desc, dirp->part);\n+\tinfo = fs_get_info(fs_type);\n+\n+\tinfo->closedir(dirp);\n+\tfs_close();\n+}\n+\n+\n int do_size(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[],\n \t\tint fstype)\n {\ndiff --git a/include/fs.h b/include/fs.h\nindex 2f2aca8378..0a6a366078 100644\n--- a/include/fs.h\n+++ b/include/fs.h\n@@ -26,6 +26,8 @@\n */\n int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype);\n \n+int fs_set_blk_dev2(struct blk_desc *desc, int part);\n+\n /*\n * Print the list of files on the partition previously set by fs_set_blk_dev(),\n * in directory \"dirname\".\n@@ -78,6 +80,59 @@ int fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,\n int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len,\n \t loff_t *actwrite);\n \n+/* Add additional FS_DT_* as supported by additional filesystems:*/\n+#define FS_DT_DIR 0x4 /* directory */\n+#define FS_DT_REG 0x8 /* regular file */\n+\n+/*\n+ * A directory entry.\n+ */\n+struct fs_dirent {\n+\tunsigned type; /* one of FS_DT_* */\n+\tloff_t size;\n+\tchar name[256];\n+};\n+\n+typedef struct _FS_DIR FS_DIR;\n+\n+/*\n+ * fs_opendir - Open a directory\n+ *\n+ * @filename: the path to directory to open\n+ * @return a pointer to the directory stream or NULL on error and errno\n+ * set appropriately\n+ */\n+FS_DIR *fs_opendir(const char *filename);\n+\n+/*\n+ * fs_readdir - Read the next directory entry in the directory stream.\n+ *\n+ * @dirp: the directory stream\n+ * @return the next directory entry (only valid until next fs_readdir() or\n+ * fs_closedir() call, do not attempt to free()) or NULL if the end of\n+ * the directory is reached.\n+ */\n+struct fs_dirent *fs_readdir(FS_DIR *dirp);\n+\n+/*\n+ * fs_closedir - close a directory stream\n+ *\n+ * @dirp: the directory stream\n+ */\n+void fs_closedir(FS_DIR *dirp);\n+\n+/*\n+ * private to fs implementations, would be in fs.c but we need to let\n+ * implementations subclass:\n+ */\n+\n+struct _FS_DIR {\n+\tstruct fs_dirent dirent;\n+\t/* private to fs layer: */\n+\tstruct blk_desc *desc;\n+\tint part;\n+};\n+\n /*\n * Common implementation for various filesystem commands, optionally limited\n * to a specific filesystem type via the fstype parameter.\ndiff --git a/include/part.h b/include/part.h\nindex 0cd803a933..48e8ff6d8a 100644\n--- a/include/part.h\n+++ b/include/part.h\n@@ -98,6 +98,7 @@ int host_get_dev_err(int dev, struct blk_desc **blk_devp);\n \n /* disk/part.c */\n int part_get_info(struct blk_desc *dev_desc, int part, disk_partition_t *info);\n+int part_get_info_whole_disk(struct blk_desc *dev_desc, disk_partition_t *info);\n void part_print(struct blk_desc *dev_desc);\n void part_init(struct blk_desc *dev_desc);\n void dev_print(struct blk_desc *dev_desc);\n@@ -203,6 +204,9 @@ static inline struct blk_desc *mg_disk_get_dev(int dev) { return NULL; }\n \n static inline int part_get_info(struct blk_desc *dev_desc, int part,\n \t\t\t\tdisk_partition_t *info) { return -1; }\n+static inline int part_get_info_whole_disk(struct blk_desc *dev_desc,\n+\t\t\t\t\t disk_partition_t *info)\n+{ return -1; }\n static inline void part_print(struct blk_desc *dev_desc) {}\n static inline void part_init(struct blk_desc *dev_desc) {}\n static inline void dev_print(struct blk_desc *dev_desc) {}\n", "prefixes": [ "U-Boot", "v2", "4/8" ] }