summaryrefslogtreecommitdiffstats
path: root/common/filetype.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-10-13 09:37:32 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-10-15 08:56:23 +0200
commit77073ab24d4e95e6d2f18ed1aecebdfed22f795b (patch)
treeb80b35a8e25b5816e53f9289c085d84a247131d9 /common/filetype.c
parent867ada484f883a3332012ba45de4082403091136 (diff)
downloadbarebox-77073ab24d4e95e6d2f18ed1aecebdfed22f795b.tar.gz
filetype: Use cdev_open
a cdev has to be opened before usage. Use cdev_open instead of cdev_by_name. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/filetype.c')
-rw-r--r--common/filetype.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/common/filetype.c b/common/filetype.c
index dc2ff3f..9ec8ebf 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -369,9 +369,10 @@ enum filetype cdev_detect_type(const char *name)
struct cdev *cdev;
void *buf;
- cdev = cdev_by_name(name);
+ cdev = cdev_open(name, O_RDONLY);
if (!cdev)
return type;
+
buf = xzalloc(FILE_TYPE_SAFE_BUFSIZE);
ret = cdev_read(cdev, buf, FILE_TYPE_SAFE_BUFSIZE, 0, 0);
if (ret < 0)
@@ -396,5 +397,6 @@ enum filetype cdev_detect_type(const char *name)
err_out:
free(buf);
+ cdev_close(cdev);
return type;
}