[PATCH 2/3] filetype: Add type detection at an offset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add file_name_detect_type_offset to allow file system detection for loop
mounts at an offset.

Signed-off-by: Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>
---
 common/filetype.c  | 10 ++++++++--
 include/filetype.h |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/common/filetype.c b/common/filetype.c
index f9c034ff2a..71691fd813 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;
diff --git a/include/filetype.h b/include/filetype.h
index b98dcb5014..ec5aea2635 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -50,6 +50,7 @@ const char *file_type_to_short_string(enum filetype f);
 enum filetype file_detect_partition_table(const void *_buf, size_t bufsize);
 enum filetype file_detect_type(const void *_buf, size_t bufsize);
 enum filetype file_name_detect_type(const char *filename);
+enum filetype file_name_detect_type_offset(const char *filename, loff_t pos);
 enum filetype cdev_detect_type(const char *name);
 enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec);
 int is_fat_boot_sector(const void *_buf);
-- 
2.15.1


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux