FatFs

Started by tha, May 05, 2022, 10:00:40 AM

Previous topic - Next topic

tha

The allocation unit, หรือที่เรียกว่า cluster, คือ a unit of disk space allocation สำหรับ files. เมื่อ the size of allocation unit คือ 32768 bytes, a file ที่มีขนาด 100 bytes จะยึดครอง 32768 bytes of disk space. The space efficiency of disk usage จะแย่ลงตามการเพิ่มขึ้นของ size of allocation unit, แต่ในทางกลับกัน, the read/write performance จะเพิ่มขึ้น. ดังนั้น the size of allocation unit จึงเป็นการแลกเปลี่ยนระหว่าง space efficiency and performance. สำหรับ the large volumes ใน GB order, 32768 bytes หรือใหญ่กว่า, จะถูกเลือกโดยอัตโนมัติโดยเริ่มต้น, ขอแนะนำสำหรับกรณีส่วนใหญยกเว้น extremely many small files ถูกสร้างใน the volume.

tha

เมื่อ the logical drive ที่จะถูกฟอร์แมตมีความเกี่ยวข้องกับ a physical drive (FF_MULTI_PARTITION == 0 or VolToPart[].pt == 0) และ FM_SFD flag ไม่ถูกระบุ, a partition ที่ครอบครอง entire drive space ถูกสร้างและดังนั้น the FAT volume ถูกสร้างใน the partition. เมื่อ FM_SFD flag ถูกระบุ, the FAT volume ถูกสร้าง โดยไม่มี any disk partitioning.

tha

เมื่อ the logical drive ที่จะถูกฟอร์แมตมีความเกี่ยวข้องกับ a specific partition ด้วย multiple partition feature (FF_MULTI_PARTITION == 1 and VolToPart[].pt > 0), the FAT volume ถูกสร้างใน the partition of the physical drive ที่ระบุโดย volume mapping table และ FM_SFD flag ถูกละเว้น. The hosting physical drive จำเป็นต้องถูกแบ่งพาติชั่นด้วย f_fdisk function หรือ any partitioning tool ก่อนการสร้าง the FAT volume ด้วยฟังชั่นนี้. ถ้า the partition ไม่มีอยู่, the function จะยกเลิกด้วย FR_MKFS_ABORTED.


tha

มี three standard disk partitioning formats, MBR, GPT and SFD. The MBR format, หรือที่เรียกว่า FDISK format, มักจะถูกใช้สำหรับ harddisk, memory card and U disk. มันสามารถแบ่ง a physical drive ลงในอย่างน้อยหนึ่ง partitions ด้วย a partition table. The GPT, GUID Partition Table, เป็น a newly defined patitioning format สำหรับ large storage devices. FatFs รองรับ the GPT เฉพาะเมื่อ 64-bit LBA ถูกเปิดใช้งาน. The SFD, Super-Floppy Disk, เป็น non-partitioned disk format. The FAT volume ถูกวางตำแหน่งที่ LBA 0 และครอบครอง the entire physical drive โดยไม่มี any disk partitioning. มันมักจะถูกใช้สำหรับ floppy disk, optical disk and most super-floppy media. บางการผสมผสานของระบบและสื่อรองรับเฉพาะอย่างใดอย่างหนึ่ง partitioned format หรือ non-partitioned format และอย่างอื่นๆจะไม่ถูกรองรับ.

บาง systems จัดการ the partitions ใน the on-board storage ใน non-standard format. The partitions ถูกแม็ปเป็น physical drives ที่ระบุโดย pdrv ใน disk_* functions. สำหรับระบบดังกล่าว, SFD format เหมาะที่จะสร้าง the FAT volume ใน the partition.

QuickInfo
มีให้ใช้งานเมื่อ FF_FS_READOLNY == 0 and FF_USE_MKFS == 1.

Example


See Also
Example of volume size and format parameters, Volume management, f_fdisk

tha

http://elm-chan.org/fsw/ff/doc/fdisk.html



Parameters
   pdrv
       ระบุ the physical drive ที่จะถูกแบ่ง. นี้ไม่ใช่ the logical drive number แต่ the drive identifier ที่ผ่านไปยัง the low level
       disk functions.
   ptbl
       รายการของ partition size ที่จะสร้างบน the drive. The data type LBA_t เป็นนามแฝงของ DWORD or QWORD ขึ้นอยู่กับ
       the configuration option FF_LBA64.
   work
       ตัวชี้ไปยัง the function work area. The size ต้องเป็นอย่างน้อย FF_MAX_SS bytes. เมื่อ a null pointer ถูกให้ด้วย
       FF_USE_LFN = 3, a memory block ถูกรับในฟังชั่นนี้สำหรับ the working buffer.

Return Values
FR_OK, FR_DISK_ERR, FR_NOT_READY, FR_WRITE_PROTECTED, FR_INVALID_PARAMETER, FR_NOT_ENOUGH_CORE

tha

Description
The f_fdisk function สร้าง partitions บน the physical drive. The partitioning format อาจเป็น generic MBR or GPT. The partition map table ระบุวิธีแบ่ง the physical drive. The first item ระบุ the size of the first partition และ the partitions ถูกวางตำแหน่งบน the drive ตามลำดับจาก the first item. เมื่อ the value of item น้อยกว่าหรือเท่ากับ 100, มันระบุ the partition size เป็นเปอร์เซ็นต์ของ the entire drive space. เมื่อมันใหญ่กว่า 100, มันระบุ number of sectors. The partition map table ที่ถูกสิ้นสุดลงด้วยศูนย์, ไม่มี space เหลืออยู่สำหรับ next allocation หรือ 4th partition ถูกสร้างใน MBR format. ถ้า the specified size ใหญ่กว่า space ที่เหลืออยู่บน the drive, the partition จะถูกตัดยอดที่ end of the drive.

โดยค่าเริ่มต้น, partitions ถูกสร้างใน MBR format. มันสามารถสร้างได้สูงถึง four primary partitions บน a drive. GPT format ถูกใช้เพื่อสร้าง the partitions เมื่อ 64-bit LBA ถูกเปิดใช้งาน (FF_LBA64 = 1) และ the drive size เท่ากับหรือใหญ่กว่า FF_MIN_GPT sectors. มันสามารถสร้างมากกว่า ten partitions บน a drive.

QuickInfo
มีให้ใช้งานเมื่อ FF_FS_READOLNY == 0, FF_USE_MKFS == 1 and FF_MULTI_PARTITION == 1.

Example


See Also
Volume management, f_mkfs

tha

http://elm-chan.org/fsw/ff/doc/getfree.html



Parameters
   path
       ตัวชี้ไปยัง the null-terminated string ที่ระบุ the logical drive. A null-string หมายถึง the default drive.
   nclst
       ตัวชี้ไปยัง the DWORD variable เพื่อเก็บ number of free clusters.
   fatfs
       ตัวชี้ไปยัง pointer ที่จะเก็บ a pointer ไปยัง the corresponding filesystem object.

Return Values
FR_OK, FR_DISK_ERR, FR_INT_ERR, FR_NOT_READY, FR_INVALID_DRIVE, FR_NOT_ENABLED, FR_NO_FILESYSTEM, FR_TIMEOUT

Descriptions
The f_getfree function ได้รับ number of free clusters บน the volume. The member csize ใน the filesystem object แสดงให้เห็น number of sectors per cluster, ดังนั้น the free space ในหน่วยของ sector สามารถถูกคำนวณด้วยข้อมูลนี้. ในกรณีของ FSINFO structure บน the FAT32 volume ไม่อยู่ในซิงค์, ฟังชั่นนี้สามารถส่งคืนกลับ an incorrect free cluster count. เพื่อหลีกเลี่ยงปัญหานี้ , FatFs สามารถถูกบังคับ full FAT scan โดย FF_FS_NOFSINFO option.

QuickInfo
มีให้ใช้งานเมื่อ FF_FS_READONLY == 0 and FF_FS_MINIMIZE == 0.

Example


See Also
FATFS

tha

http://elm-chan.org/fsw/ff/doc/getlabel.html



Parameters
   path
       ตัวชี้ไปยัง the null-terminated string ที่ระบุ the logical drive. Null-string ระบุ the default drive.
   label
       ตัวชี้ไปยัง the buffer เพื่อเก็บ the volume label. ถ้า the volume ไม่มี label, a null-string จะถูกส่งคืนกลับ. เซ็ต null
       pointer ถ้าข้อมูลนี้ไม่ถูกต้องการ. อย่างน้อย The buffer size ควรถูกแสดงข้างล่างเพื่อหลีกเลี่ยง buffer overflow.   
   vsn
       ตัวชี้ไปยัง the DWORD variable เพื่อเก็บ the volume serial number. เซ็ต null pointer ถ้าข้อมูลนี้ไม่ถูกต้องการ.

Return Values
FR_OK, FR_DISK_ERR, FR_INT_ERR, FR_NOT_READY, FR_INVALID_DRIVE, FR_NOT_ENABLED, FR_NO_FILESYSTEM, FR_TIMEOUT

QuickInfo
Available when FF_USE_LABEL == 1.

Example


See Also
f_setlabel