Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v0.6.0 #104

Merged
merged 81 commits into from
Oct 20, 2023
Merged

Release/v0.6.0 #104

merged 81 commits into from
Oct 20, 2023

Conversation

thejpster
Copy link
Member

Changed

  • Writing to a file no longer flushes file metadata to the Directory Entry.
    Instead closing a file now flushes file metadata to the Directory Entry.
    Requires mutable access to the Volume (#94).
  • Files now have the correct length when modified, not appended (#72).
  • Calling SdCard::get_card_type will now perform card initialisation (#87 and #90).
  • Removed warning about unused arguments.
  • Types are now documented at the top level (#86).
  • Renamed Cluster to ClusterId and stopped you adding two together

Added

  • New examples, append_file, create_file, delete_file, list_dir, shell
  • New test cases tests/directories.rs, tests/read_file.rs

Removed

  • Breaking Change: Controller alias for VolumeManager removed.
  • Breaking Change: VolumeManager::open_dir_entry removed, as it was unsafe to the user to randomly pick a starting cluster.
  • Old examples create_test, test_mount, write_test, delete_test

jbeaurivage and others added 30 commits October 6, 2022 11:49
Also remove unused AcquireOpt option
Signed-off-by: Lachezar Lechev <[email protected]>
Better reflects what it actually does.
Changed BlockSpi to AcquiredSdCard.
Changed SdMmcSpi to SdCard.
Avoids errors like 'info! not defined', or 'info! defined twice'.
Now there is only "SdCard" in the public API. Any attempt to use the SD card when the card type is unknown will force a re-initialisation of the SD card. You no longer need to acquire.
Matches the name of the primary type contained within it.
Now we store an Option<CardType>, and the user can unsafely declare a certain type of card to be fitted and initialised.
Matches the num_blocks command in the BlockDevice API.
Stops it hanging if the card is missing.
1. Now we try and batch up card byte reads/writes into as few SPI transfer/write calls as possible.
2. The option is now "use_crc" and if not set, we don't even try and enable CRC mode.
3. Note that the 74 bits are not to enable SPI mode but to clear card internal state
Now you need blocking::spi::Write as well as blocking::spi::Transfer
Also add the code from the README into an example so we can at least check it compiles.
Puts the keys into alphabetical order.
jonathanpallant and others added 22 commits September 15, 2023 21:11
Requires mutable access to the volume in order to do the write.
Gets you docs at the top level. Saves users a click. Also drops the deprecated Controller import. We need to do a breaking release anyway.
Now File and Directory are just integers, and they are joined by Volume. All the info is stored inside the volume manager.

The upside is you no longer have to pass the right volume along with your file handle! It also becomes much easier to implement a Drop trait on File if you want (although we don't for the reasons explained in the comments).

The downside is the File object no longer has any methods. The upside is that it's much easier to store files.
Now the tests unpack the gzipped disk automatically into RAM.

Need to add some write tests and get the tarpaulin coverage figure up a bit higher.
Volume Manager API also now takes things that are "convertible to a short file name", so you can use a ShortFileName, or a &str.
Test coverage at 56.2%.
- Cluster is now ClusterId
- Helper method for turning bytes to a block count
- Removed unsafe open_dir_entry API
This is because some files have no starting cluster and thus look like the same file when they are not.

Fixes #75
Co-authored-by: Ryan Summers <[email protected]>
Cleaning up some comments, and fixing the close file bug.
You can walk around a disk image and do directory listings. I had to make some more things 'Debug' so I could print the filesystem state. Also our handling of ".." was not right so I fixed that.
Also moved the code into a method so we can use ?. Although ? is a pain when your objects cannot safely be dropped.
@thejpster thejpster merged commit d362a6a into main Oct 20, 2023
8 checks passed
@thejpster thejpster deleted the release/v0.6.0 branch October 20, 2023 15:58
@Murmele
Copy link

Murmele commented May 22, 2024

  • Writing to a file no longer flushes file metadata to the Directory Entry.
    Instead closing a file now flushes file metadata to the Directory Entry.

But this means I have always to close the file. Currently I store a RawFile object (as filehandler) and execute only the write. In this case the file gets created but stays always empty (Currently I don't close the file for testing, but in real scenario this can also happen, so the data is lost?)

Usecase:

  • Open File and keep open
  • Write data to file (multiple times)
  • Device goes off without close -> Data lost?

The problem is when I have to close it, the RawFile "handler" is invalid in my understanding. Is that correct?

Reason why I don't like to close:

  • RawFile handler gets invalid
  • Slower than just writing

@thejpster
Copy link
Member Author

If closing/re-opening is a performance bottleneck, you could propose a PR containing a flush API, which just looks at the dirty flag and if required, writes to disk and then clears it.

@Murmele
Copy link

Murmele commented May 22, 2024

I thought about the same. I will have a look into it tomorrow and will create a pullrequest. Thanks for the project!

@Murmele
Copy link

Murmele commented May 23, 2024

@thejpster

  • Does it make sense to write on the first write also the DirEntry and then again at the end?
    I tested this. After the first write writing the information once has the effect that when opening the file on the computer, only the part of the first write is visible, but not the rest.

Since DOS 7.1 the two most-significant bits of this cluster entry may hold two optional bitflags representing the current volume status on FAT16 and FAT32, but not on FAT12 volumes. These bitflags are not supported by all operating systems, but operating systems supporting this feature would set these bits on shutdown and clear the most significant bit on startup:
If bit 15 (on FAT16) or bit 27 (on FAT32)[41] is not set when mounting the volume, the volume was not properly unmounted before shutdown or ejection and thus is in an unknown and possibly "dirty" state.[27] On FAT32 volumes, the FS Information Sector may hold outdated data and thus should not be used. The operating system would then typically run SCANDISK or CHKDSK on the next startup[nb 9][41] (but not on insertion of removable media) to ensure and possibly reestablish the volume's integrity.
Source: https://en.wikipedia.org/wiki/Design_of_the_FAT_file_system

Could this help? So the computer gets the indication that the filesystem was not properly closed and it should rescan?

@thejpster
Copy link
Member Author

There is always a trade off between performance and reliability with FAT.

I like the idea of being able to mark disks as dirty if they have open writable files, and non-dirty when the last writable file has been closed. I just wouldn't want to see read-only access (99% of my use case) mark the FS as dirty.

@Murmele
Copy link

Murmele commented May 24, 2024

There is always a trade off between performance and reliability with FAT.

I like the idea of being able to mark disks as dirty if they have open writable files, and non-dirty when the last writable file has been closed. I just wouldn't want to see read-only access (99% of my use case) mark the FS as dirty.

Haha then we have opposite usecases 😄 i have most of the time writing. Neverthless, I will check this flag out. I don't think during read the dirty flag will be set

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants