@@ -980,15 +980,18 @@ impl OpenOptions {
980980 /// Note that setting `.write(true).append(true)` has the same effect as
981981 /// setting only `.append(true)`.
982982 ///
983- /// For most filesystems, the operating system guarantees that all writes are
984- /// atomic: no writes get mangled because another process writes at the same
985- /// time.
986- ///
987- /// One maybe obvious note when using append-mode: make sure that all data
988- /// that belongs together is written to the file in one operation. This
989- /// can be done by concatenating strings before passing them to [`write()`],
990- /// or using a buffered writer (with a buffer of adequate size),
991- /// and calling [`flush()`] when the message is complete.
983+ /// Append mode guarantees that writes will be positioned at the current end of file,
984+ /// even when there are other processes or threads appending to the same file. This is
985+ /// unlike <code>[seek]\([SeekFrom]::[End]\(0))</code>` followed by `write()`, which
986+ /// has a race between seeking and writing during which another writer can write, with
987+ /// our `write()` overwriting their data.
988+ ///
989+ /// Keep in mind that atomicity of `write()` in append mode is less useful than it
990+ /// appears at first. A successful `write()` is allowed to write only part of the
991+ /// given data, so even if you're careful to provide the whole message in a single
992+ /// call to `write()`, there is no guarantee that it will written out in full. Unless
993+ /// the data to append consists of a single byte, you can't append atomically without
994+ /// external locking.
992995 ///
993996 /// If a file is opened with both read and append access, beware that after
994997 /// opening, and after every write, the position for reading may be set at the
@@ -1003,6 +1006,9 @@ impl OpenOptions {
10031006 /// [`write()`]: Write::write "io::Write::write"
10041007 /// [`flush()`]: Write::flush "io::Write::flush"
10051008 /// [stream_position]: Seek::stream_position "io::Seek::stream_position"
1009+ /// [seek]: Seek::seek "io::Seek::seek"
1010+ /// [Current]: SeekFrom::Current "io::SeekFrom::Current"
1011+ /// [End]: SeekFrom::End "io::SeekFrom::End"
10061012 ///
10071013 /// # Examples
10081014 ///
0 commit comments