summaryrefslogtreecommitdiffstats
path: root/common/filetype.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-06-11 11:33:34 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2019-06-11 11:33:34 +0200
commitad06295b2983cc46cb6c4dcf2b482f37731f7a3e (patch)
tree7c8aec2fb29c565dadcc40ef5b6b9dfc2d922fc9 /common/filetype.c
parent06b8bc4d708b8ff4eba1dd9b48ec110a8019d2c8 (diff)
parent25d6c568a867821e419e4a6b5cdb41a0c98b3ad8 (diff)
downloadbarebox-ad06295b2983cc46cb6c4dcf2b482f37731f7a3e.tar.gz
Merge branch 'for-next/ubootenv'
Diffstat (limited to 'common/filetype.c')
-rw-r--r--common/filetype.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/filetype.c b/common/filetype.c
index 9675009..329f514 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)
@@ -423,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)
@@ -432,6 +439,7 @@ enum filetype cdev_detect_type(const char *name)
err_out:
free(buf);
+cdev_close:
cdev_close(cdev);
return type;
}