AN1045

Started by tha, May 05, 2022, 03:04:40 PM

Previous topic - Next topic

tha

ตัวอย่างนี้ถูกแสดงใน Figure 2. เป็นสิ่งสำคัญให้สังเกตว่าค่าที่จะชี้ไปที่ Clusters 0 and 1 ถูกสงวนไว้เพื่อระบุเงื่อนไขพิเศษ. ด้วยเหตุนี้, the first cluster ใน the data region จึงถูกทำเครื่องหมายเป็น Cluster 2. The FAT entries ที่ตรงกันกับ Clusters 0 and 1 บรรจุ the media descriptor, ถูกตามโดย bytes ที่บรรจุค่า, FFh.


tha

The "คลัสเตอร์แรกในไฟล์" values ใน root directory entries ทั้งสามแสดงให้เห็นการสตาร์ทของไฟล์ทั้งสาม. The FAT แสดงการเชื่อมโยงระหว่าง the files. File 1 and File 3 เล็กกว่าขนาดของ a cluster, ดังนั้นพวกมันถูกกำหนด one cluster เท่านั้น. The cluster entries ใน the FAT ที่ตรงกันกับไฟล์เหล่านั้นบรรจุเฉพาะ the End-Of-File value. File 2 ใหญ่กว่าสาม clusters, แต่เล็กกว่าสี่, ดังนั้นมันถูกกำหนดสี่ clusters. เนื่องจากไม่มีสาม clusters ติดต่อกันมีให้ใช้ประโยชน์เมื่อตอน File 2 ถูกสร้าง, มันถูกกำหนด clusters ที่ไม่ติดต่อกัน. นี้ถูกเรียกว่า "fragmentation". The values of the cluster entries ใน the FAT สำหรับr File 2 ชี้ไปยัง the next cluster ใน the file. The last cluster entry ใน the FAT สำหรับ File 2 บรรจุ the End-Of-File value.

tha

Directories

Directories ในระบบไฟล์นี้, ยกเว้น the root directory, ถูกเขียนในวิธีเดียวกันที่ไฟล์ถูกเขียน. แต่ละ directory ครอบครองอย่างน้อยหนึ่ง clusters ใน the data section of the partition, และแต่ละตัวมี directory entry และ chain of FAT entries ของมันเอง. Bit สี่ของ the attribute field ใน the directory entry ของ a directory ถูกเซ็ต, แสดงให้เห็นว่า the entry เป็นของ a directory. Directory names ใน library นี้เป็นไปตาม short file name format (8.3 format). Directories แตกต่างไปจากไฟล์ตรงที่พวกมันไม่มีส่วนขยาย, แม้ว่า.


tha

แต่ละ directory บรรจุ 32-byte directory entries. Two directory entries, the dot entry และ the dotdot entry, มีอยู่ในทุกๆ directory ยกเว้น the root directory. The dot entry เป็น the first entry ใน any subdirectory. The name value ใน entry นี้คือ a single dot (2Eh) ที่ตามโดย ten space characters (20h). The first-cluster-in-file value ของ entry นี้จะชี้ไปยัง the cluster ที่ the entry นี้อยู่ใน. The dotdot entry ก็คล้ายกัน, ยกเว้น the name บรรจุ two dots ที่ตามโดย nine spaces, และ the first-cluster-in-file value ชี้ไปยัง the directory ที่บรรจุ entry สำหรับ the directory (ที่) the dotdot entry อยู่ใน (the previous directory).

tha

เมื่อ directories ถูกเปิดการใช้งานใน library นี้, การแก้ไขไฟล์ทั้งหมดจะถูกทำใน the Current Working Directory (CWD). เมื่อผู้ใช้เริ่มต้น the card โดยการเรียก FSInit, the current working directory จะถูกเซ็ตไปเป็น the root directory โดยอัตโนมัติ. หลังจากนี้, the current working directory สามารถถูกเปลี่ยนด้วย the FSchdir function.

tha

เมื่อระบุ path names ใน the directory manipulation functions, มีกติกาหลายอย่างที่ควรถูกทำตาม. Directory names ใน a path string ถูกกำหนดเขตโดย the backslash character (\). โปรดทราบว่าเมื่อแสดง a backslash character ใน a string, an additional backslash ต้องถูกเพิ่มเป็นส่วนหนึ่งของ an escape sequence, เนื่องจาก the backslash ตัวมันเองถูกใช้โดย C เพื่อเริ่ม escape sequences. ถ้า the first character ของ a path string คือ a backslash, the path จะถูกถือว่าถูกระบุเกี่ยวข้องกับ the root directory. ถ้า a path string เริ่มด้วย a directory name, the path จะถูกถือว่าถูกระบุเกี่ยวข้องกับ the current working directory. ถ้า a dot (.) or dotdot (..) ถูกรวมใน the path เป็น a directory name, the code จะทำงานโดยใช้ directory entries เหล่านั้น. ตัวอย่างเช่น, ถ้าผู้ใช้เปลี่ยน the CWD เป็น ".\\TEST\..\\TEST\\..\\.\\.", พวกมันจะลงท้ายใน the same directory ที่พวกมันเริ่มต้น, ถือว่า the directory “TEST” มีอยู่ใน the original directory. ตัวอย่างเพิ่มเติมของ path strings สามารถถูกดูได้ใน Table 7.