seekdir(3)
๐ seekdir(3) โ the glow-up your directory stream needed ๐
okay bestie, settle in, because we're talking about seekdir from the Library Functions Manual, and honestly? It's giving "tiny function, big main character energy." ๐
๐ธ NAME ๐ธ
seekdir โ set the position of the next readdir() call in the directory stream.
No cap, that's the whole job. One job. She does it. ๐
๐ LIBRARY ๐
Standard C library (libc, -lc) โ the OG, the blueprint, the one you already linked against, bestie. ๐ซถ
โจ SYNOPSIS โจ
#include <dirent.h>
void seekdir(DIR *dirp, long loc);
Feature Test Macro Requirements for glibc (go peek at feature_test_macros(7) if you're curious ๐):
seekdir():
_XOPEN_SOURCE
|| /* glibc >= 2.19: */ _DEFAULT_SOURCE
|| /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
๐ lowkey important: you gotta have one of these macros defined or glibc will not even acknowledge your existence, and that's just not the vibe.
๐ฆ DESCRIPTION ๐ฆ
So the seekdir() function sets the location in the directory stream where the next readdir(2) call is gonna start reading from. It's literally the "okay babe, rewind to HERE" button for your directory stream. โช
And the loc argument? It should be a value that came back from a previous call to telldir(3). Like, telldir() gives you the bookmark, seekdir() takes you back to it. They're a duo. A friendship bracelet situation. ๐ซถโจ
Do not just make up a number and pass it in. That is not the move, bestie. ๐ญ
๐ซ RETURN VALUE ๐ซ
The seekdir() function returns no value. She gives you nothing. She's not here to hand out return codes, she's here to move the pointer. Iconic behaviour honestly. ๐
๐ง ATTRIBUTES ๐ง
Wanna know what all these fancy terms mean? Go read attributes(7), it explains everything, you got this. ๐
seekdir()โ Thread safety:MT-Safe๐ฅ
So yes, she's thread-safe. Go be multithreaded, you chaotic little legend. ๐
โญ STANDARDS โญ
POSIX.1-2008. Certified. Official. Sanctioned by the standards girlies. ๐
๐ HISTORY ๐
POSIX.1-20014.3BSD
Ancient lore, bestie. She's been around. She's a legacy icon. ๐๏ธ
๐ CAVEATS ๐
okay this part actually matters so LISTEN. ๐
Up to glibc 2.1.1, the type of the loc argument was off_t. Then POSIX.1-2001 came through and specified long, and that's the type used since glibc 2.1.2. โจ
And fr fr โ go check out telldir(3) for the tea on why you should be careful in making any assumptions about the value in this argument. Do NOT assume loc is a cute little file offset you can do math on. It is not. It's opaque. Treat it like a mystery. ๐ฎ
๐ real talk: pass back exactly what telldir() gave you, and nothing else. No arithmetic. No guessing. No "well it's just a number." She's a number-shaped secret, periodt.
๐ SEE ALSO ๐
The whole directory-op girl squad. Go read them all, you'll be unstoppable. ๐ โจ
That's the whole page, bestie โ brought to you by Linux man-pages 6.20, dated 2026-02-08. Go forth and seek responsibly. ๐ฆ๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: Linux-man-pages-copyleft
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms