diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2019-06-03 22:19:58 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-06-07 09:04:44 +0200 |
commit | ed6cb64c24540475763257d651d83804506d419b (patch) | |
tree | 3edcc65db2a5733c2675166719da517247791631 /common/filetype.c | |
parent | 0a46c9013b52d3e8924dae954d00c9a2a5f5993a (diff) | |
download | barebox-ed6cb64c24540475763257d651d83804506d419b.tar.gz barebox-ed6cb64c24540475763257d651d83804506d419b.tar.xz |
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 <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/filetype.c')
-rw-r--r-- | common/filetype.c | 6 |
1 files changed, 6 insertions, 0 deletions
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; } |