SEEK(3)
π 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
typeis0, the offset is set tonbytes. just straight upn. no math, no drama π - if
typeis1, the pointer is set to its current location plusn. so you're moving relative to where you already are, iykyk π§ - if
typeis2, the pointer is set to the size of the file plusn. 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 π¦
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms