When an OS creates/overwrites a file on a disk formatted using a FAT file system (e.g. FAT12 for simplicity), it needs to write to the directory region, to the cluster chain, and to the data region.
Is there a restriction on the order in which those writes happen? For example, is it safe to assume that upon creation of a new file on disk, the OS will first write the directory entry and update the cluster chain before it writes to the data region.
Or is it, to the contrary, possible that the OS first fills hitherto unallocated clusters in the data region with the file's content before it updates the cluster chain to mark those clusters allocated?
Observation: I think I'm seeing MacOS write to the directory region and the cluster chain first, but haven't found any information that would hint at whether that's always the case and for all OSes.
Goal: I'm redirecting writes to the data region of a ramdisk that presents itself as FAT12 formatted disk. I've got this working in principle. To develop the approach further, I would have to rely on knowing the new directory entry and cluster chain first. However, I obviously cannot control the order of OS-side writes. I'm just listening, capturing, and replying to them as they come in.