iterate_and_advance2(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ iterate_and_advance2 β€” a whole mood (Kernel API Manual, bestie)

okay so picture this: you're deep in the Kernel API Manual and you stumble on iterate_and_advance2, and honestly? it's giving "let me walk your iterator through its next chunk, hand in hand." obsessed. let's get into it πŸ’…


✨ NAME ✨

iterate_and_advance2 β€” literally just iterate over an iterator, that's the whole vibe πŸŽ€


🌸 SYNOPSIS 🌸

size_t iterate_and_advance2 (struct iov_iter *iter , size_t len , void
*priv , void *priv2 , iov_ustep_f ustep , iov_step_f step );

like, that's the signature, no cap, copy it exactly bestie πŸ’–


πŸ’« ARGUMENTS πŸ’«

  • iter β€” the iterator you're iterating over. the main character, fr.
  • len β€” how much of it you wanna iterate over. the amount, the length, the whole deal.
  • priv β€” data for the step functions 🫢
  • priv2 β€” more data for the step functions. yes there's two. she contains multitudes.
  • ustep β€” the function for UBUF/IOVEC iterators; these ones get handed __user addresses.
  • step β€” the function for all the other iterators; these get kernel addresses.

πŸ”₯ DESCRIPTION πŸ”₯

So here's the tea β˜• β€” you iterate over the next part of an iterator, up to the length you specified. And the buffer? It shows up in segments. For kernel iteration, those segments get broken up by physical pages and mapped, and the mapped address is what gets presented to you. slay.

You must provide two step functions, step and ustep. One handles the mapped kernel addresses, and the other one gets the user addresses β€” and bestie, listen, those user addresses have the potential to fault, because no pinning is performed. so like, be aware πŸ‘€

The step functions get passed:

  • the address and length of the segment
  • priv
  • priv2
  • and the amount of data so far iterated over β€” which you can, for example, add to priv so it points to the right part of a second buffer. iykyk 🧚

The step functions should return the amount of the segment they didn't process (ie. 0 indicates complete processsing).

And what does the whole thing give you back? The function returns the amount of data processed β€” so 0 means nothing was processed, and the value of len means processes to completion. periodt. πŸ’€βœ¨


πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./include/linux/iov_iter.h iterate_and_advance(9), iterate_and_advance_kernel(9) β€” go read those next, bestie, they're right there 🌈


kk that's the whole page!! πŸ“ this one's fresh out of ./include/linux, dated October 2026, and you can find it filed under iterate_and_advance2(9) β€” mwah, love u, bye πŸ’œπŸŽ€

πŸ“¦ where this page comes from