summaryrefslogtreecommitdiffstats
path: root/common/filetype.c
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2018-02-01 11:37:16 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-02-05 08:26:22 +0100
commit119147ebfd2827558b6d27e525c2d8da6bf2865a (patch)
treeb14c0062c78a231906e9795a8488a49967ee942e /common/filetype.c
parent9eb45f4f3c3f038abbd32890c9fa95a1ebb302cb (diff)
downloadbarebox-119147ebfd2827558b6d27e525c2d8da6bf2865a.tar.gz
filetype: Add type detection at an offset
Add file_name_detect_type_offset to allow file system detection for loop mounts at an offset. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/filetype.c')
-rw-r--r--common/filetype.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/common/filetype.c b/common/filetype.c
index f9c034f..71691fd 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -21,6 +21,7 @@
#include <asm/unaligned.h>
#include <fcntl.h>
#include <fs.h>
+#include <libfile.h>
#include <malloc.h>
#include <errno.h>
#include <envfs.h>
@@ -343,13 +344,13 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
return filetype_unknown;
}
-enum filetype file_name_detect_type(const char *filename)
+enum filetype file_name_detect_type_offset(const char *filename, loff_t pos)
{
int fd, ret;
void *buf;
enum filetype type = filetype_unknown;
- fd = open(filename, O_RDONLY);
+ fd = open_and_lseek(filename, O_RDONLY, pos);
if (fd < 0)
return fd;
@@ -368,6 +369,11 @@ err_out:
return type;
}
+enum filetype file_name_detect_type(const char *filename)
+{
+ return file_name_detect_type_offset(filename, 0);
+}
+
enum filetype cdev_detect_type(const char *name)
{
enum filetype type = filetype_unknown;