explain_lseek(3)
π explain_lseek β the manual, but make it make sense π
okay bestie, gather round, because today we're decoding explain_lseek(3) from the Library Functions Manual and honestly? it's giving "your syscall ghosted you and left no note." this whole page is about getting a human-readable explanation of what went wrong in an lseek(2) call. no cap. π¦
β¨ NAME β¨
explain_lseek β explain lseek(2) errors π
πΈ SYNOPSIS πΈ
#include <libexplain/lseek.h>
const char *explain_lseek(int fildes, long long offset, int whence);
const char *explain_errno_lseek(int errnum, int fildes, long long offset, int whence);
void explain_message_lseek(char *message, int message_size, int fildes, long long offset, int whence);
void explain_message_errno_lseek(char *message, int message_size, int errnum, int fildes, long long offset, int whence);
four functions, one mission: tell you why your lseek(2) flopped. π
π DESCRIPTION π
so like, these functions exist so you can pull out explanations for lseek(2) errors. they're your little error-decoding besties. π«Ά
π explain_lseek
const char *explain_lseek(int fildes, long long offset, int whence);
explain_lseek is the one you call when you want a human readable explanation of what went wrong in an lseek(2) system call. the least it will give you is the value of strerror(errno), but usually it does so much better and points at the underlying cause in way more detail. lowkey overachiever behavior and we love that. β¨
the errno global variable gets used to obtain the error value to be decoded.
it's meant to be used in a fashion similar to this example:
if (lseek(fd, offset, whence) == (off_t)-1)
{
fprintf(stderr, '%s0, explain_lseek(fd, offset, whence);
exit(EXIT_FAILURE);
}
fildesβ the originalfildes, exactly as passed to thelseek(2)system call.offsetβ the originaloffset, exactly as passed to thelseek(2)system call.whenceβ the originalwhence, exactly as passed to thelseek(2)system call.
Returns:
the message explaining the error. β οΈ this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function that shares this buffer β including calls from other threads. yes, it's that kind of situationship. π
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library do too.
π explain_errno_lseek
const char *explain_errno_lseek(int errnum, int fildes, long long offset, int whence);
explain_errno_lseek does the same job β human readable explanation of what went wrong in an lseek(2) system call. the least the message will contain is the value of strerror(errnum), but usually it goes way harder and indicates the underlying cause in more detail. π
used in a fashion similar to this:
if (lseek(fd, offset, whence) == (off_t)-1)
{
int errnum = errno;
fprintf(stderr, '%s0, explain_errno_lseek(fd, eernum, offset,
whence);
exit(EXIT_FAILURE);
}
errnumβ the error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno. so like, grab it early, bestie, it will not wait for you. πfildesβ the originalfildes, exactly as passed to thelseek(2)system call.offsetβ the originaloffset, exactly as passed to thelseek(2)system call.whenceβ the originalwhence, exactly as passed to thelseek(2)system call.
Returns:
the message explaining the error. β οΈ this message buffer is shared by all libexplain functions that don't supply a buffer in their argument list. it will be overwritten by the next call to any libexplain function that shares this buffer, including other threads.
Note: this function is not thread safe, because it shares a return buffer across all threads, and many other functions in this library.
π¦ explain_message_lseek
void explain_message_lseek(char *message, int message_size, int fildes, long long offset, int whence);
explain_message_lseek β you guessed it β gets you a human readable explanation of what went wrong in an lseek(2) system call. the least the message will contain is the value of strerror(errno), but usually it does much better and indicates the underlying cause in more detail. iconic. β¨
the errno global variable will be used to obtain the error value to be decoded.
use it in a fashion similar to this:
if (lseek(fd, offset, whence) == (off_t)-1)
{
char message[3000];
explain_message_lseek(message, sizeof(message), fd, offset, whence);
fprintf(stderr, '%s0, message);
exit(EXIT_FAILURE);
}
messageβ the location in which to store the returned message. because a message return buffer has been supplied, this function is thread safe. π (yes ma'am, you brought your own buffer, you get thread safety, main character energy fr fr)message_sizeβ the size in bytes of the location in which to store the returned message.fildesβ the originalfildes, exactly as passed to thelseek(2)system call.offsetβ the originaloffset, exactly as passed to thelseek(2)system call.whenceβ the originalwhence, exactly as passed to thelseek(2)system call.
π§ explain_message_errno_lseek
void explain_message_errno_lseek(char *message, int message_size, int errnum, int fildes, long long offset, int whence);
explain_message_errno_lseek β human readable explanation of what went wrong in an lseek(2) system call, same deal. the least the message will contain is the value of strerror(errnum), but usually it will do much better and indicate the underlying cause in more detail. π«Ά
the vibe, as an example:
if (lseek(fd, offset, whence) == (off_t)-1)
{
char message[3000];
int errnum = errno;
explain_message_errno_lseek(message, sizeof(message), errnum, fd,
offset, whence);
fprintf(stderr, '%s0, message);
exit(EXIT_FAILURE);
}
messageβ the location in which to store the returned message. because a message return buffer has been supplied, this function is thread safe. πmessage_sizeβ the size in bytes of the location in which to store the returned message.errnumβ the error value to be decoded, usually obtained from theerrnoglobal variable just before this function is called. this is necessary if you need to call any code between the system call to be explained and this function, because many libc functions will alter the value oferrno.fildesβ the originalfildes, exactly as passed to thelseek(2)system call.offsetβ the originaloffset, exactly as passed to thelseek(2)system call.whenceβ the originalwhence, exactly as passed to thelseek(2)system call.
π COPYRIGHT π
libexplain version 1.4 Copyright (C) 2008 Peter Miller
π AUTHOR π
Written by Peter Miller <pmiller@opensource.org.au>
and that's the whole page, bestie!! π this was explain_lseek(3) from libexplain version 1.4, copyright Β© 2008 Peter Miller, authored by Peter Miller <pmiller@opensource.org.au> β go forth and decode your errnos, you absolute legend. mwah. ππ
β¨
π¦ where this page comes from
- debian bookworm: libexplain-dev 1.4.D001-12+b1 Β· LGPL-3.0-or-later
- debian trixie: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- ubuntu jammy: libexplain-dev 1.4.D001-12 Β· LGPL-3.0-or-later
- ubuntu noble: libexplain-dev 1.4.D001-13 Β· LGPL-3.0-or-later
- ubuntu resolute: libexplain-dev 1.4.D001-16 Β· LGPL-3.0-or-later
- Copyright (C) 2008-2011 Peter Miller
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms