From 0a46c9013b52d3e8924dae954d00c9a2a5f5993a Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 3 Jun 2019 22:19:57 -0700 Subject: filetype: Add "U-Boot environmemnt variable data" filetype Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- common/filetype.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common/filetype.c') diff --git a/common/filetype.c b/common/filetype.c index e2d707b156..429911533a 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -77,6 +77,8 @@ static const struct filetype_str filetype_str[] = { [filetype_imx_image_v2] = { "i.MX image (v2)", "imx-image-v2" }, [filetype_layerscape_image] = { "Layerscape image", "layerscape-PBL" }, [filetype_layerscape_qspi_image] = { "Layerscape QSPI image", "layerscape-qspi-PBL" }, + [filetype_ubootvar] = { "U-Boot environmemnt variable data", + "ubootvar" }, }; const char *file_type_to_string(enum filetype f) -- cgit v1.2.3 From ed6cb64c24540475763257d651d83804506d419b Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 3 Jun 2019 22:19:58 -0700 Subject: filetype: Allow specifying cdev's filetype explicitly Allow specifying cdev's filetype explicitly to support the cases where the type of a cdev is known apriori, yet cannot be determined by reading the cdev's content. Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- common/filetype.c | 6 ++++++ include/driver.h | 2 ++ 2 files changed, 8 insertions(+) (limited to 'common/filetype.c') diff --git a/common/filetype.c b/common/filetype.c index 429911533a..e4c8005b56 100644 --- a/common/filetype.c +++ b/common/filetype.c @@ -425,6 +425,11 @@ enum filetype cdev_detect_type(const char *name) if (!cdev) return type; + if (cdev->filetype != filetype_unknown) { + type = cdev->filetype; + goto cdev_close; + } + buf = xzalloc(FILE_TYPE_SAFE_BUFSIZE); ret = cdev_read(cdev, buf, FILE_TYPE_SAFE_BUFSIZE, 0, 0); if (ret < 0) @@ -434,6 +439,7 @@ enum filetype cdev_detect_type(const char *name) err_out: free(buf); +cdev_close: cdev_close(cdev); return type; } diff --git a/include/driver.h b/include/driver.h index 3479e18194..ba1047392d 100644 --- a/include/driver.h +++ b/include/driver.h @@ -22,6 +22,7 @@ #include #include #include +#include #define FORMAT_DRIVER_NAME_ID "%s%d" @@ -464,6 +465,7 @@ struct cdev { struct list_head link_entry, links; struct list_head partition_entry, partitions; struct cdev *master; + enum filetype filetype; }; int devfs_create(struct cdev *); -- cgit v1.2.3