forked from M-Labs/rust-fatfs
parent
954c68457f
commit
75bb9d1293
@ -1,6 +1,11 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
0.3.6 (not released yet)
|
||||||
|
------------------------
|
||||||
|
Bug fixes:
|
||||||
|
* Create directory entry with `VOLUME_ID` attribute when formatting if volume label was set in `FormatVolumeOptions`.
|
||||||
|
|
||||||
0.3.5 (2021-01-23)
|
0.3.5 (2021-01-23)
|
||||||
------------------------
|
------------------------
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
@ -15,6 +15,7 @@ use byteorder_ext::{ReadBytesExt, WriteBytesExt};
|
|||||||
|
|
||||||
use boot_sector::{format_boot_sector, BiosParameterBlock, BootSector};
|
use boot_sector::{format_boot_sector, BiosParameterBlock, BootSector};
|
||||||
use dir::{Dir, DirRawStream};
|
use dir::{Dir, DirRawStream};
|
||||||
|
use dir_entry::{DirFileEntryData, FileAttributes};
|
||||||
use file::File;
|
use file::File;
|
||||||
use table::{alloc_cluster, count_free_clusters, format_fat, read_fat_flags, ClusterIterator, RESERVED_FAT_ENTRIES};
|
use table::{alloc_cluster, count_free_clusters, format_fat, read_fat_flags, ClusterIterator, RESERVED_FAT_ENTRIES};
|
||||||
use time::{TimeProvider, DEFAULT_TIME_PROVIDER};
|
use time::{TimeProvider, DEFAULT_TIME_PROVIDER};
|
||||||
@ -997,7 +998,12 @@ pub fn format_volume<T: ReadWriteSeek>(mut disk: T, options: FormatVolumeOptions
|
|||||||
write_zeros(&mut disk, boot.bpb.cluster_size() as u64)?;
|
write_zeros(&mut disk, boot.bpb.cluster_size() as u64)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: create volume label dir entry if volume label is set
|
// Create volume label directory entry if volume label is specified in options
|
||||||
|
if let Some(volume_label) = options.volume_label {
|
||||||
|
disk.seek(SeekFrom::Start(root_dir_pos))?;
|
||||||
|
let volume_entry = DirFileEntryData::new(volume_label, FileAttributes::VOLUME_ID);
|
||||||
|
volume_entry.serialize(&mut disk)?;
|
||||||
|
}
|
||||||
|
|
||||||
disk.seek(SeekFrom::Start(0))?;
|
disk.seek(SeekFrom::Start(0))?;
|
||||||
trace!("format_volume end");
|
trace!("format_volume end");
|
||||||
|
@ -108,3 +108,27 @@ fn test_format_512mb_4096sec() {
|
|||||||
let fs = test_format_fs(opts, total_bytes);
|
let fs = test_format_fs(opts, total_bytes);
|
||||||
assert_eq!(fs.fat_type(), fatfs::FatType::Fat32);
|
assert_eq!(fs.fat_type(), fatfs::FatType::Fat32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_format_empty_volume_label() {
|
||||||
|
let total_bytes = 2 * 1024 * MB;
|
||||||
|
let opts = fatfs::FormatVolumeOptions::new();
|
||||||
|
let fs = test_format_fs(opts, total_bytes);
|
||||||
|
assert_eq!(fs.volume_label(), "NO NAME");
|
||||||
|
assert_eq!(fs.read_volume_label_from_root_dir().unwrap(), None);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_format_volume_label_and_id() {
|
||||||
|
let total_bytes = 2 * 1024 * MB;
|
||||||
|
let opts = fatfs::FormatVolumeOptions::new()
|
||||||
|
.volume_id(1234)
|
||||||
|
.volume_label(*b"VOLUMELABEL");
|
||||||
|
let fs = test_format_fs(opts, total_bytes);
|
||||||
|
assert_eq!(fs.volume_label(), "VOLUMELABEL");
|
||||||
|
assert_eq!(
|
||||||
|
fs.read_volume_label_from_root_dir().unwrap(),
|
||||||
|
Some("VOLUMELABEL".to_string())
|
||||||
|
);
|
||||||
|
assert_eq!(fs.volume_id(), 1234);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user