generic_file_write_iter(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ generic_file_write_iter(9) ✨

okay bestie, welcome to the Kernel API Manual β€” this one's all about generic_file_write_iter, and it is literally the moment. πŸ’…


🌸 NAME 🌸

generic_file_write_iter β€” write data to a file, no cap


πŸŽ€ SYNOPSIS πŸŽ€

ssize_t generic_file_write_iter (struct kiocb *iocb , struct iov_iter
*from );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • iocb β€” the IO state structure, aka the vibe check for your IO 🫢
  • from β€” the iov_iter holding the data you wanna write ✨

πŸ’– DESCRIPTION πŸ’–

so basically this is a wrapper around __generic_file_write_iter, and it's the one most filesystems use. it's giving main character energy for sure. πŸ”₯

it handles syncing the file when you're doing an O_SYNC file, and it acquires i_rwsem as needed. iconic behavior, honestly. πŸ‘‘


⭐ RETURN ⭐

  • negative error code if no data has been written at all, or if vfs_fsync_range failed for a synchronous write 😭
  • number of bytes written β€” even for truncated writes, periodt πŸ’€

🌈 SEE ALSO 🌈

the Kernel file ./mm/filemap.c is the source, and honestly the whole friend group is here. say hi to: filemap_remove_folio(9), filemap_fdatawrite_range(9), filemap_flush_range(9), filemap_flush(9), filemap_range_has_page(9), filemap_fdatawait_range(9), filemap_fdatawait_range_keep_errors(9), file_fdatawait_range(9), filemap_fdatawait_keep_errors(9), filemap_write_and_wait_range(9), file_check_and_advance_wb_err(9), file_write_and_wait_range(9), replace_page_cache_folio(9), softleaf_entry_wait_on_locked(9), folio_put_wait_locked(9), folio_unlock(9), folio_end_read(9), folio_end_private_2(9), folio_wait_private_2(9), folio_wait_private_2_killable(9), folio_end_writeback_no_dropbehind(9), folio_end_writeback(9), __folio_lock(9), page_cache_next_miss(9), page_cache_prev_miss(9), __filemap_get_folio_mpol(9), find_get_entries(9), find_lock_entries(9), filemap_get_folios(9), filemap_get_folios_contig(9), filemap_get_folios_tag(9), filemap_get_folios_dirty(9), filemap_read(9), generic_file_read_iter(9), filemap_splice_read(9), mapping_seek_hole_data(9), filemap_fault(9), read_cache_folio(9), mapping_read_folio_gfp(9), read_cache_page_gfp(9), __generic_file_write_iter(9), filemap_release_folio(9), filemap_invalidate_inode(9), and filemap_cachestat(9). the whole squad, fr fr πŸ§šβ€β™€οΈπŸ’œ


and that's the page, bestie! this one's from ./mm, dated October 2026 β€” so yeah, it's fresh, it's relevant, and it ate. πŸ“πŸ‘‘πŸ’«

πŸ“¦ where this page comes from