Commit Graph

188 Commits

Author SHA1 Message Date
Rafał Harabień
6271741d24 Add changelog 2018-10-20 13:52:30 +02:00
Rafał Harabień
534781963b Simplify file size related code 2018-10-10 22:03:00 +02:00
Rafał Harabień
1724a54536 Fix formatting
Immprovements by hand + rustfmt
2018-10-10 21:26:31 +02:00
Rafał
83b5971045
Enable warnings and backtrace in Travis CI build (#20) 2018-10-06 17:37:48 +02:00
Rafał
9acd6ed6df
Separate sanity checks into validate() methods (#19) 2018-10-06 17:27:52 +02:00
Rafał
3590f43013
Try to fix build without std and alloc (#18) 2018-10-06 17:16:15 +02:00
Henry Gabryjelski
2a4c01082a Preserve 4 MSB in FAT32 entries and add more sanity checks (#13)
* Update compatibility maximum cluster size when sector size is larger than 512 bytes.

* Additional validation of values in FsInfo sector.
* next_free_cluster cannot be 0 or 1, as these are reserved clusters
* next_free_cluster must be a valid cluster (using BPB to validate)
* free_cluster_count must be possible value (using BPB to validate)

* Avoid data-loss edge-case on volumes over 138GB in size.

Specifically, if the volume has more
than 0x0FFF_FFF4 clusters, then the FAT
will include an entry for clusters that
are reserved values.  Specifically, cluster
number 0x0FFF_FFF7 is defined to mean
BAD_SECTOR, while numbers 0x0FFF_FFF8 ..
0x0FFF_FFFF are defined to mean end-of-chain.

This prevents these clusters from being part
of any valid cluster chain.  Therefore:
1. prevent setting these clusters to point to
   a valid next cluster
2. prevent reading these clusters as pointing
   to a valid next cluster

Instead, always read/write these FAT entries
to have next cluster value of BAD_SECTOR.

* Reduce noisy warnings on FAT32.

* The reserved bits in FAT entry must be preserved on update.

* Change the set() implementation for FAT32 entries to return an actual Err(),
when attempting to set values for cluster numbers that have special meaning.
2018-10-06 16:42:31 +02:00
Rafał Harabień
829b9c5f3f Fix warnings for file entries without LFN entries
Fixes #12 and #14.
2018-09-29 15:19:46 +02:00
Henry Gabryjelski
2d689a668d Add more sanity checks and fix size formatting in ls example (#11)
* Fix copy/paste errors in ls example so file sizes are correctly output.
* BPB updates.

Fix bug in bpb.active_fat(), because active_fat is
only valid when mirroring is disabled.

Add additional santiy checks to BPB deserialization:
1. bytes per sector must be a power of 2
2. 512 <= bytes per sector <= 4096
3. sectors per cluster must be a power of 2
4. 1 <= sectors per cluster <= 128

Also added some comments relating to conditions that
may be useful to WARN about for BPB deserialization:
Z. bpb.reserved_sectors should be 1
Y. bpb.fats should be either 1 or 2
X. bpb.fs_version should be validated as zero

Add syntactic sugar for:
A. bpb.is_fat32()
B. bpb.sectors_per_fat()
C. bpb.total_sectors()
2018-09-24 20:58:02 +02:00
Rafał Harabień
8c9d476c2f Fix build 2018-08-05 17:21:08 +02:00
Rafał Harabień
dce8b32577 Simplify code dealing with LFN entries generation 2018-08-05 17:12:03 +02:00
Rafał Harabień
a503cb4562 Fix build on Rust 1.24 2018-08-05 03:09:48 +02:00
Rafał Harabień
6f10042784 Support reading volume label from root directory 2018-08-05 00:14:49 +02:00
Rafał Harabień
5dea8b5f8a Test dirty flags on all FAT variants
Flags field offset is different is it makes sense.
2018-06-29 15:38:27 +02:00
Rafał Harabień
dc1ad7d2f7 Mark volume dirty on first write and not-dirty on unmount 2018-06-29 15:35:37 +02:00
Rafał Harabień
1f2427d371 Implement the same traits for FsOptions as in current stable release 2018-06-28 19:16:04 +02:00
Rafał Harabień
759758c1f2 Improve OemCpConverter and TimeProvider docs 2018-06-28 19:01:07 +02:00
Rafał Harabień
881cf7709d Deprecate set_created. set_accessed, set_modified methods on File 2018-06-28 18:58:29 +02:00
Rafał Harabień
ecef2627a7 Move time related code to 'time' module 2018-06-28 18:53:51 +02:00
Rafał Harabień
1f8f8365d6 Add TimeProvider trait and time_provider option
This functionality is very useful for embedded usage where chrono feature
cannot be enabled.
2018-06-28 18:43:02 +02:00
Rafał Harabień
30f3f96537 Improve code style using rustfmt 2018-06-28 18:13:07 +02:00
Rafał Harabień
98c0fa528c Fix no_std build 2018-06-25 23:56:46 +02:00
Rafał Harabień
4528aedc6e Add oem_cp_converter option allowing to provide custom short name decoder
Encoder is not yet used but will be in future.
This is implemented as static reference for now to avoid adding additional
type parameters to all main types. It should be enough for most of cases
where encoder/decoder does not have any state and can be implemented as
static variable.
2018-06-25 23:51:09 +02:00
Rafał Harabień
cd7e77e1b4 Rename directory entry flags and add some internal docs 2018-06-25 00:22:34 +02:00
Rafał Harabień
f9ca0f95ce Fix decoding 0xE5 character in first byte of short name 2018-06-25 00:16:14 +02:00
Rafał Harabień
be96ba8122 Properly handle short names with spaces in the middle 2018-06-25 00:07:11 +02:00
Rafał Harabień
f5bf959aa7 Update TODO list 2018-06-24 17:15:53 +02:00
Rafał Harabień
a672add4e7 Remove unnecessary clone() calls 2018-06-23 14:49:16 +02:00
Rafał Harabień
099434c45d Improve file creation time resolution to 1/100s 2018-06-23 14:17:58 +02:00
Rafał Harabień
fda4b5ca5b Add docs for FatType variants 2018-06-20 19:56:16 +02:00
Rafał Harabień
fe90d952bf Fix doc-tests 2018-06-20 19:52:18 +02:00
Rafał Harabień
00b5ee52d3 Update TODO list 2018-06-20 19:19:49 +02:00
Rafał Harabień
60d517a951 Add millis field to Time struct (BREAKING CHANGE) 2018-06-20 19:19:41 +02:00
Rafał Harabień
04887faaea Improve docs 2018-06-20 19:08:50 +02:00
Rafał Harabień
8be8c68eab Remove update_fs_info option
FSInfo sector should always be saved if it has changed.
2018-06-20 18:03:12 +02:00
Rafał Harabień
0077ee43e4 Improve README a bit more. 2018-06-20 17:58:45 +02:00
Rafał Harabień
eca77b6118 Change version to 0.3.0 2018-06-20 17:56:03 +02:00
Rafał Harabień
0dc643f7fe Improve README file a bit 2018-06-20 17:55:46 +02:00
Rafał Harabień
c4a1bc70ec Rename methods: bytes -> as_bytes 2018-06-20 17:38:04 +02:00
Rafał Harabień
69b7675940 Fix no_std build 2018-06-20 17:28:46 +02:00
Rafał Harabień
7a53215a57 No longer return &str for short names in no_std mode
Instead methods returning &[u8] were added.
It is API preparation for proper OEM codepage decoding.
Previous behavior would require to store duplicated short names
(one lossy and one real).
2018-06-20 17:17:01 +02:00
Rafał Harabień
d99ba96f72 Update TODO list 2018-06-20 17:10:53 +02:00
Rafał Harabień
f68996925f Make sure short name generation never fails 2018-06-17 23:21:33 +02:00
Rafał Harabień
a6b66f9434 Make errors more consistent with std::fs 2018-06-17 23:11:53 +02:00
Rafał Harabień
8995a43bc4 Allow renaming to the same name 2018-06-17 22:26:07 +02:00
Rafał Harabień
8c1dae9f0c Do not remove source file in Dir::rename if destination already exists
Previous code removed source file before returning an error.
It also caused a clusters leak. Now it returns error before doing any
modifications on the partition.
2018-06-17 22:25:22 +02:00
Rafał Harabień
4afd38a150 Fix possible overflow when calculating short name checksum
Affects debug build only. Overflow was not handled when calculating
checksum used for short name generation when avoiding a conflict.
LFN checksum was working properly but got refactored in this commit to
use num::Wrapping as well.
2018-06-17 21:58:39 +02:00
Rafał Harabień
674d1f8182 Fix failing in Dir::create_file/dir if existing destination entry has wrong type 2018-06-17 21:46:54 +02:00
Rafał Harabień
4f08acf4ab Do not mount volume if fs_version field in BPB is not zero 2018-06-17 16:34:08 +02:00
Rafał Harabień
8a5491a919 Doc improvements 2018-06-17 16:27:59 +02:00