A pathname is not an open file
A path names a target through directories. When open succeeds on Linux, it returns a file descriptor, an integer through which the process refers to that open target in later operations such as read and write. It is not necessary to imagine that every operation repeats the original pathname lookup.
The descriptor is an entry point to open-file state, including an offset and relevant flags. Opening the same path twice differs from duplicating a descriptor with an operation such as dup: the latter can share an open-file description and offset. Identical path strings do not imply that every piece of state is the same.
Use the returned length
Requesting one hundred bytes with read does not guarantee a return value of one hundred. Short reads can occur near the end of a file, through a pipe or socket, or under other documented conditions. Account for the returned count and continue with the remaining portion when the application requires more bytes.
For an ordinary file read with a positive requested length, zero indicates end of file. Treat errors separately, including interruption and nonblocking operations that cannot currently proceed. A library may handle some retries internally, so check the abstraction you are using rather than assuming one universal loop around every I/O API.
Write completion is a different boundary from durability
Application buffering, operating-system caching, and storage completion are distinct stages. A successful write does not by itself establish every durability requirement under power loss. Check the synchronization API, return values, and filesystem guarantees for the persistence promised by the application.
A configuration update might write a temporary file, synchronize it appropriately, and replace the original name. Atomic visibility of the name replacement is not the same as persistence after a crash. On Linux, synchronizing file data can also leave a separate directory-entry persistence requirement, so consider directory synchronization where needed.
Connect the model to the workload
A stream of small durable log records and a batch transfer of large images have different latency and operation-count requirements. Buffering can reduce calls, but it does not define how much recent data the application may lose. Removing synchronization to improve a benchmark can change the meaning of a successful save.
This lesson focuses on ordinary Linux file I/O. Network filesystems, devices, direct I/O, and other operating systems can impose different constraints. A fast read may also be a cache hit. Record size, buffering, cache state, and synchronization settings in a measurement, and keep observed speed separate from documented persistence guarantees.