The Stack Overflow podcast is back! Listen to an interview with our new CEO.
2 Code formatting is for code. Use bold and/or italics for normal text.
source | link

A disk should grant that a sectora sector is written atomically. The sector size was 512 bytes512 bytes and today is typically 4096 bytes4096 bytes for larger disks.

In order to get no problem from partially written "blocks", it is important to write everything in a special order.

Note that the only reason why there could be a partially writtenpartially written part in the filesystem is a power outage or something similar.

The method is:

  • First write all file content and verify that this worked

  • Then write the meta data and make sure that all data structures in the meta data fit in a single disk sector and do not span a sector boundary. This is e.g. important for variable length file names as directory content.

A disk should grant that a sector is written atomically. The sector size was 512 bytes and today is typically 4096 bytes for larger disks.

In order to get no problem from partially written "blocks", it is important to write everything in a special order.

Note that the only reason why there could be a partially written part in the filesystem is a power outage or something similar.

The method is:

  • First write all file content and verify that this worked

  • Then write the meta data and make sure that all data structures in the meta data fit in a single disk sector and do not span a sector boundary. This is e.g. important for variable length file names as directory content.

A disk should grant that a sector is written atomically. The sector size was 512 bytes and today is typically 4096 bytes for larger disks.

In order to get no problem from partially written "blocks", it is important to write everything in a special order.

Note that the only reason why there could be a partially written part in the filesystem is a power outage or something similar.

The method is:

  • First write all file content and verify that this worked

  • Then write the meta data and make sure that all data structures in the meta data fit in a single disk sector and do not span a sector boundary. This is e.g. important for variable length file names as directory content.

1
source | link

A disk should grant that a sector is written atomically. The sector size was 512 bytes and today is typically 4096 bytes for larger disks.

In order to get no problem from partially written "blocks", it is important to write everything in a special order.

Note that the only reason why there could be a partially written part in the filesystem is a power outage or something similar.

The method is:

  • First write all file content and verify that this worked

  • Then write the meta data and make sure that all data structures in the meta data fit in a single disk sector and do not span a sector boundary. This is e.g. important for variable length file names as directory content.