From 429864a69f7fe1c9cc61e7859673dd6949fbc130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Harabie=C5=84?= Date: Wed, 9 May 2018 15:34:41 +0200 Subject: [PATCH] Clarify that seeked filesystem is not handled by library --- src/fs.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/fs.rs b/src/fs.rs index e0a965d..cac93c7 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -224,9 +224,16 @@ pub struct FileSystem<'a> { impl <'a> FileSystem<'a> { /// Creates new filesystem object instance. /// + /// Supplied disk parameter cannot be seeked. If there is a need to read a fragment of disk image (e.g. partition) + /// library user should provide a custom implementation of ReadWriteSeek trait. + /// /// Note: creating multiple filesystem objects with one underlying device/disk image can /// cause filesystem corruption. pub fn new(disk: &'a mut T, options: FsOptions) -> io::Result> { + // Make sure given image is not seeked + debug_assert!(disk.seek(SeekFrom::Current(0))? == 0); + + // Read boot sector let bpb = { let boot = BootRecord::deserialize(disk)?; if boot.boot_sig != [0x55, 0xAA] {