diff --git a/blockdev/linux/file_dev.c b/blockdev/linux/file_dev.c index dd0743b7..dbf43055 100644 --- a/blockdev/linux/file_dev.c +++ b/blockdev/linux/file_dev.c @@ -39,6 +39,12 @@ /**@brief Default filename.*/ static const char *fname = "ext2"; +/**@brief Default partition offset.*/ +static uint64_t part_offset = 0; + +/**@brief Default partition. Zero means the rest of the file.*/ +static uint64_t part_size = 0; + /**@brief Image block size.*/ #define EXT4_FILEDEV_BSIZE 512 @@ -73,8 +79,12 @@ static int file_dev_open(struct ext4_blockdev *bdev) if (fseeko(dev_file, 0, SEEK_END)) return EFAULT; - file_dev.part_offset = 0; - file_dev.part_size = ftello(dev_file); + file_dev.part_offset = part_offset; + if (part_size) { + file_dev.part_size = part_size; + } else { + file_dev.part_size = ftello(dev_file) - part_offset; + } file_dev.bdif->ph_bcnt = file_dev.part_size / file_dev.bdif->ph_bsize; return EOK; @@ -140,3 +150,13 @@ void file_dev_name_set(const char *n) fname = n; } /******************************************************************************/ +void file_dev_part_offset_set(const uint64_t n) +{ + part_offset = n; +} +/******************************************************************************/ +void file_dev_part_size_set(const uint64_t n) +{ + part_size = n; +} +/******************************************************************************/ diff --git a/blockdev/linux/file_dev.h b/blockdev/linux/file_dev.h index ce4690d9..77759509 100644 --- a/blockdev/linux/file_dev.h +++ b/blockdev/linux/file_dev.h @@ -40,4 +40,10 @@ struct ext4_blockdev *file_dev_get(void); /**@brief Set filename to open.*/ void file_dev_name_set(const char *n); +/**@brief Set partition offset .*/ +void file_dev_part_offset_set(const uint64_t n); + +/**@brief Set partition size .*/ +void file_dev_part_size_set(const uint64_t n); + #endif /* FILE_DEV_H_ */