trace_seq_to_user(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’« trace_seq_to_user (9) πŸ’«

okay so bestie, you found a kernel API manpage β€” and not just any, this one is from the Kernel API Manual and it's literally called trace_seq_to_user. Yes, kernel people have their own manual section, iykyk. Let's get into it 🫢


🌸 NAME 🌸

trace_seq_to_user β€” copy the sequence buffer to user space ✨


πŸŽ€ SYNOPSIS πŸŽ€

int trace_seq_to_user (struct trace_seq *s , char __user *ubuf , int cnt
);

that's the whole vibe. three args, one int coming back at you πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • s β€” the trace sequence descriptor, aka the main character of this whole operation πŸ‘‘
  • ubuf β€” the userspace memory location you're copying to 🎯
  • cnt β€” the amount to copy, like how much you're willing to share πŸ“

πŸ’– DESCRIPTION πŸ’–

So here's the tea: this function copies the sequence buffer into the userspace memory that ubuf points at. Not complicated, but the way it does it is lowkey kind of iconic 😭

It starts from the last read position β€” that's s->readpos β€” and writes up to cnt characters, or it keeps going till it hits the end of the content in the buffer (s->len), whichever comes first. Literally whichever one shows up to the party first πŸŽ‰

On success? It returns a positive number β€” that's the number of bytes it copied. Slay πŸ’…

On failure it returns -EBUSY if all of the content in the sequence has already been read. And yes, that includes when there's nothing in the sequence at all, meaning s->len == s->readpos 🫠 like babe there is nothing left to read, the buffer is empty, go home.

It also returns -EFAULT if the copy to userspace fails 😭 that's the "something went wrong on the way out" error.

ngl the two failure modes are very different vibes: -EBUSY is "already read everything," -EFAULT is "the copy itself broke." don't mix them up bestie πŸ’€

🌈 SEE ALSO 🌈

go check out the kernel file ./kernel/trace/trace_seq.c β€” plus these absolute icons:


and that's the whole page, bestie 🧚 this one lives in ./kernel/trace and it's dated October 2026 β€” so yeah, it's giving future energy ⭐ go forth and copy those bytes responsibly πŸ’œ

πŸ“¦ where this page comes from