SEEK(3)

πŸ“¦
version 0_git20260208 Β· 5 versions
, in alpine 3.24, arch rolling, nixos 26.05, nixpkgs unstable

πŸ’… SEEK(3) β€” like, the seek manual page, bestie

okay so this is a page from the Library Functions Manual (yes, the whole library functions manual, we're fancy like that ✨) and it's about seek. buckle up πŸŽ€


🌸 NAME 🌸

seek β€” change file offset. that's it. that's the whole vibe. she moves the little "where am I reading from" pointer, no cap πŸ’…


✨ SYNOPSIS ✨

#include <u.h>
#include <libc.h>

vlong seek(int fd, vlong n, int type)

like, you gotta pull in both headers first, then you call her with a file descriptor, a vlong number, and a type. returns a vlong. slay πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

seek sets the offset for the file associated with fd, and honestly the rules are giving choose-your-own-adventure 🌈:

  • if type is 0, the offset is set to n bytes. just straight up n. no math, no drama πŸ’–
  • if type is 1, the pointer is set to its current location plus n. so you're moving relative to where you already are, iykyk 🧚
  • if type is 2, the pointer is set to the size of the file plus n. end-of-file energy, main character behavior πŸ‘‘

and then β€” the new file offset value is returned. she gives it back to you, periodt 🫢

🚨 okay important stuff, pay attention: seeking in a directory is not allowed. like, do not. and seeking in a pipe is a no-op β€” it literally does nothing, it's giving "I'm here but I'm not doing anything" πŸ’€

πŸ“ SOURCE πŸ“

/src/lib9/seek.c β€” that's where she lives 🏠


πŸ’œ SEE ALSO πŸ’œ

go read those too, they're lowkey related and highkey useful 🌸


😭 DIAGNOSTICS 😭

sets errstr. so if something goes sideways, check errstr, bestie β€” that's where the tea is β˜•


πŸ’€ BUGS πŸ’€

okay so this is the spicy one 🌢️ β€” to avoid name conflicts with the underlying system, seek is a preprocessor macro defined as p9seek. check intro(3) for the full lore. like, it's not a bug-bug, it's a "we had to rename her so she doesn't fight with the system" situation πŸ™ˆ


and that's the page!! πŸŽ€βœ¨ this gorgeous little number comes to you from the Library Functions Manual, and the footer just says SEEK(3) β€” same as the top, because symmetry is iconic πŸ‘‘πŸ’– bye bestie, go seek responsibly πŸ¦‹