.\" -*- coding: UTF-8 -*- .\" Copyright Drew Eckhardt .\" Copyright 1995, Nicolai Langfeldt .\" Copyright 2006-2014, Michael Kerrisk .\" Copyright, the authors of the Linux man-pages project .\" .\" SPDX-License-Identifier: Linux-man-pages-copyleft .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH stat 2 "8 februari 2026" "Linux man\-pages 6.18" .SH NAAM stat, fstat, lstat, fstatat \- verkrijg bestand status. .SH BIBLIOTHEEK Standaard C bibliotheek (\fIlibc\fP, \fI\-lc\fP) .SH SAMENVATTING .nf \fB#include \fP .P \fBint stat(const char *restrict \fP\fIpath\fP\fB,\fP \fB struct stat *restrict \fP\fIstatbuf\fP\fB);\fP \fBint fstat(int \fP\fIfd\fP\fB, struct stat *\fP\fIstatbuf\fP\fB);\fP \fBint lstat(const char *restrict \fP\fIpath\fP\fB,\fP \fB struct stat *restrict \fP\fIstatbuf\fP\fB);\fP .P \fB#include \fP/* Definitie van \fBAT_*\fP constanten */ \fB#include \fP .P \fBint fstatat(int \fP\fIdirfd\fP\fB, const char *restrict \fP\fIpath\fP\fB,\fP \fB struct stat *restrict \fP\fIstatbuf\fP\fB, int \fP\fIflags\fP\fB);\fP .fi .P .RS -4 Feature Test Macro Requirements voor glibc (zie \fBfeature_test_macros\fP(7)): .RE .P \fBlstat\fP(): .nf .\" _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED /* Vanaf glibc 2.20 */ _DEFAULT_SOURCE || _XOPEN_SOURCE >= 500 || /* Vanaf glibc 2.10: */ _POSIX_C_SOURCE >= 200112L || /* glibc 2.19 en eerder */ _BSD_SOURCE .fi .P \fBfstatat\fP(): .nf Vanaf glibc 2.10: _POSIX_C_SOURCE >= 200809L Voor glibc 2.10: _ATFILE_SOURCE .fi .SH BESCHRIJVING These functions return information about a file, in the buffer pointed to by \fIstatbuf\fP. No permissions are required on the file itself, but\[em]in the case of \fBstat\fP(), \fBfstatat\fP(), and \fBlstat\fP()\[em]execute (search) permission is required on all of the directories in \fIpath\fP that lead to the file. .P \fBstat\fP() and \fBfstatat\fP() retrieve information about the file pointed to by \fIpath\fP; the differences for \fBfstatat\fP() are described below. .P \fBlstat\fP() is identical to \fBstat\fP(), except that if \fIpath\fP is a symbolic link, then it returns information about the link itself, not the file that the link refers to. .P .\" \fBfstat\fP() is gelijk aan \fBstat\fP(), behalve dat het bestand van welk de informatie wordt opgevraagd wordt gespecificeerd door de bestandsindicator \fIfd\fP. .SS "De stat structuur" Al deze systeem aanroepen retourneren een \fIstat\fP structure (zie \fBstat\fP(3type)): .P .\" Background: inode attributes are modified with i_mutex held, but .\" read by stat() without taking the mutex. \fIOpmerking\fP: vanwege prestatie redenen en vanwege de eenvoud, mogen diverse velden in de \fIstat\fP structuur status informatie bevatten over verschillende momenten gedurende de uitvoer van de systeem aanroep. Bijvoorbeeld, als \fIst_mode\fP of \fIst_uid\fP werd veranderd door een ander proces door de aanroep van \fBchmod\fP(2) of \fBchown\fP(2), dan mag \fBstat\fP(2) de oude \fIst_mode\fP teruggeven, samen met de nieuwe \fIst_uid\fP, of de oude \fIst_uid\fP samen met de nieuwe \fIst_mode\fP. .SS fstatat() De \fBfstatat\fP() systeem aanroep is een meer algemeen interface voor het verkrijgen van bestandsinformatie dat nog steeds exact hetzelfde gedrag kan bieden van elk van \fBstat\fP(), \fBlstat\fP(), and \fBfstat\fP(). .P If \fIpath\fP is relative, then it is interpreted relative to the directory referred to by the file descriptor \fIdirfd\fP (rather than relative to the current working directory of the calling process, as is done by \fBstat\fP() and \fBlstat\fP() for a relative pathname). .P If \fIpath\fP is relative and \fIdirfd\fP is the special value \fBAT_FDCWD\fP, then \fIpath\fP is interpreted relative to the current working directory of the calling process (like \fBstat\fP() and \fBlstat\fP()). .P Als \fIpadnaam\fP absoluut is, dan wordt \fImapbi\fP genegeerd. .P \fIvlaggen\fP kan ofwel 0 zijn, of kan een of meer van de volgende vlaggen ORed bevatten: .TP \fBAT_EMPTY_PATH\fP (vanaf Linux 2.6.39) .\" commit 65cfc6722361570bfe255698d9cd4dccaf47570d .\" Before glibc 2.16, defining _ATFILE_SOURCE sufficed If \fIpath\fP is an empty string (or NULL, since Linux 6.11) operate on the file referred to by \fIdirfd\fP (which may have been obtained using the \fBopen\fP(2) \fBO_PATH\fP flag). In this case, \fIdirfd\fP can refer to any type of file, not just a directory, and the behavior of \fBfstatat\fP() is similar to that of \fBfstat\fP(). If \fIdirfd\fP is \fBAT_FDCWD\fP, the call operates on the current working directory. This flag is Linux\-specific; define \fB_GNU_SOURCE\fP to obtain its definition. .TP \fBAT_NO_AUTOMOUNT\fP (vanaf Linux 2.6.38) Don't automount the terminal ("basename") component of \fIpath.\fP Since Linux 3.1 this flag is ignored. Since Linux 4.11 this flag is implied. .TP \fBAT_SYMLINK_NOFOLLOW\fP If \fIpath\fP is a symbolic link, do not dereference it: instead return information about the link itself, like \fBlstat\fP(). (By default, \fBfstatat\fP() dereferences symbolic links, like \fBstat\fP().) .P Zie \fBopenat\fP(2) voor een uitleg over de noodzaak van \fBfstatat\fP(). .SH "EIND WAARDE" Bij succes wordt nul teruggegeven. Bij falen wordt \-1 teruggegeven en wordt \fIerrno\fP overeenkomstig gezet. .SH FOUTEN .TP \fBEACCES\fP Search permission is denied for one of the directories in the path prefix of \fIpath\fP. (See also \fBpath_resolution\fP(7).) .TP \fBEBADF\fP \fIbi\fP is niet een geldige open\-voor\-schrijven bestandindicator. .TP \fBEBADF\fP (\fBfstatat\fP()) \fIpath\fP is relative but \fIdirfd\fP is neither \fBAT_FDCWD\fP nor a valid file descriptor. .TP \fBEFAULT\fP Verkeerd adres. .TP \fBEINVAL\fP (\fBfstatat\fP()) Ongeldige vlag opgegeven in \fIvlaggen\fP. .TP \fBELOOP\fP Teveel symbolische koppelingen werden tegengekomen bij het doorlopen van \fIpadnaam\fP. .TP \fBENAMETOOLONG\fP \fIpad\fP is te lang. .TP \fBENOENT\fP A component of \fIpath\fP does not exist or is a dangling symbolic link. .TP \fBENOENT\fP \fIpath\fP is an empty string and \fBAT_EMPTY_PATH\fP was not specified in \fIflags\fP. .TP \fBENOMEM\fP Geheugen is op (kernel geheugen). .TP \fBENOTDIR\fP A component of the path prefix of \fIpath\fP is not a directory. .TP \fBENOTDIR\fP (\fBfstatat\fP()) \fIpath\fP is relative and \fIdirfd\fP is a file descriptor referring to a file other than a directory. .TP \fBEOVERFLOW\fP \fIpath\fP or \fIfd\fP refers to a file whose size, inode number, or number of blocks cannot be represented in, respectively, the types \fIoff_t\fP, \fIino_t\fP, or \fIblkcnt_t\fP. This error can occur when, for example, an application compiled on a 32\-bit platform without \fI\-D_FILE_OFFSET_BITS=64\fP calls \fBstat\fP() on a file whose size exceeds \fI(1<<31)\-1\fP bytes. .SH STANDAARDEN POSIX.1\-2024. .SH HISTORIE .TP \fBstat\fP() .TQ \fBfstat\fP() .TQ \fBlstat\fP() .\" SVr4 documents additional .\" .BR fstat () .\" error conditions EINTR, ENOLINK, and EOVERFLOW. SVr4 .\" documents additional .\" .BR stat () .\" and .\" .BR lstat () .\" error conditions EINTR, EMULTIHOP, ENOLINK, and EOVERFLOW. SVr4, 4.3BSD, POSIX.1\-2001. .TP \fBfstatat\fP() POSIX.1\-2008. Linux 2.6.16, glibc 2.4. .P Volgens POSIX.1\-2001, moet \fBlstat\fP() voor een symbolische koppeling geldige informatie retourneren in het \fIst_size\fP veld en het bestandstype van het \fIst_mode\fP veld van de \fIstat\fP structure. POSIX.1\-2008 vernauwt deze specificatie door te vereisen dat \fBlstat\fP() geldige informatie moet retourneren in alle velden behalve de mode bits in \fIst_mode\fP. .P Gebruik van de \fIst_blocks\fP en \fIst_blksize\fP velden is minder overdraagbaar. (Deze werden geïntroduceerd in BSD. De interpretatie verschilt tussen systemen, en mogelijk zelfs op een enkel systeem waar NFS koppelingen gebruikt worden.) .SS "C library/kernel verschillen" .\" See include/asm-i386/stat.h in the Linux 2.4 source code for the .\" various versions of the structure definitions In de loop van de tijd hebben vergrotingen van de \fIstat\fP structure geleid tot drie opeenvolgende versies van \fBstat\fP(0: \fIsys_stat\fP() (slot \fI__NR_oldstat\fP), \fIsys_newstat\fP() (slot \fI__NR_stat\fP), en \fIsys_stat64()\fP (slot \fI__NR_stat64\fP) op 32\-bit platformen zoals i386. De eerste twee versies waren al aanwezig in Linux 1.0 (hoewel met verschillende namen); de laatste werd toegevoegd in Linux 2.4. Vergelijkbare opmerkingen zijn van toepassing op \fBfstat\fP() en \fBlstat\fP(). .P De interne kernel versies van de \fIstat\fP structure die behandelt worden door de verschillende versies, zijn respectievelijk: .TP \fI__old_kernel_stat\fP De originele structure, met nogal kleine velden en zonder opvulling. .TP \fIstat\fP Een groter \fIst_ino\fP veld en opvulling toegevoegd aan verschillende delen van de structure om toekomstige uitbreidingen toe te staan. .TP \fIstat64\fP Een nog groter \fIst_ino\fP veld, grotere \fIst_uid\fP en \fIst_gid\fP velden om in de expansie van UID´s EN GID´s naar 32 bits door Linux\-2.4 te voorzien, en verschillende andere vergrote velden en meer opvulling in de structure. (Diverse opvul bytes werden geconsumeerd in Linux 2.6, met de aankomst van 32\-bit apparaat ID´s en nanoseconden componenten in de tijdstempel velden.) .P .\" .\" A note from Andries Brouwer, July 2007 .\" .\" > Is the story not rather more complicated for some calls like .\" > stat(2)? .\" .\" Yes and no, mostly no. See "/usr/include/sys/stat.h". .\" .\" The idea is here not so much that syscalls change, but that .\" the definitions of struct stat and of the types dev_t and mode_t change. .\" This means that libc (even if it does not call the kernel .\" but only calls some internal function) must know what the .\" format of dev_t or of struct stat is. .\" The communication between the application and libc goes via .\" the include file that defines a _STAT_VER and .\" _MKNOD_VER describing the layout of the data that user space .\" uses. Each (almost each) occurrence of stat() is replaced by .\" an occurrence of xstat() where the first parameter of xstat() .\" is this version number _STAT_VER. .\" .\" Now, also the definitions used by the kernel change. .\" But glibc copes with this in the standard way, and the .\" struct stat as returned by the kernel is repacked into .\" the struct stat as expected by the application. .\" Thus, _STAT_VER and this setup cater for the application-libc .\" interface, rather than the libc-kernel interface. .\" .\" (Note that the details depend on gcc being used as c compiler.) De glibc \fBstat\fP() omwikkel functies verbergen deze details van de applicaties, door het aanroepen van de meest recente versie van de systeem aanroep die door de kernel beschikbaar wordt gesteld en het opnieuw inpakken van de verkregen informatie indien nodig voor oude toepassingen. .P Op moderne 64\-bit systemen is het leven eenvoudiger: daar bestaat een enkele \fBstat\fP() systeem aanroep en de kernel werkt met een \fIstat\fP structure die velden van voldoende grootte bevat. .P .\" strace(1) shows the name "newfstatat" on x86-64 De onderliggende systeem aanroep gebruikt door de glibc \fBfstatat\fP() omwikkel functie heet eigenlijk \fBfstatat64\fP() of op sommige architecturen \fBnewfstatat\fP(). .SH VOORBEELDEN Het volgende programma roept \fBlstat\fP() aan en toont geselecteerde velden in de teruggegeven \fIstat\fP structure. .P .\" SRC BEGIN (stat.c) .EX #include #include #include #include #include #include \& int main(int argc, char *argv[]) { struct stat sb; \& if (argc != 2) { fprintf(stderr, "Usage: %s \[rs]n", argv[0]); exit(EXIT_FAILURE); } \& if (lstat(argv[1], &sb) == \-1) { perror("lstat"); exit(EXIT_FAILURE); } \& printf("ID of containing device: [%x,%x]\[rs]n", major(sb.st_dev), minor(sb.st_dev)); \& printf("File type: "); \& switch (sb.st_mode & S_IFMT) { case S_IFBLK: printf("block device\[rs]n"); break; case S_IFCHR: printf("character device\[rs]n"); break; case S_IFDIR: printf("directory\[rs]n"); break; case S_IFIFO: printf("FIFO/pipe\[rs]n"); break; case S_IFLNK: printf("symlink\[rs]n"); break; case S_IFREG: printf("regular file\[rs]n"); break; case S_IFSOCK: printf("socket\[rs]n"); break; default: printf("unknown?\[rs]n"); break; } \& printf("I\-node number: %ju\[rs]n", (uintmax_t) sb.st_ino); \& printf("Mode: %jo (octal)\[rs]n", (uintmax_t) sb.st_mode); \& printf("Link count: %ju\[rs]n", (uintmax_t) sb.st_nlink); printf("Ownership: UID=%ju GID=%ju\[rs]n", (uintmax_t) sb.st_uid, (uintmax_t) sb.st_gid); \& printf("Preferred I/O block size: %jd bytes\[rs]n", (intmax_t) sb.st_blksize); printf("File size: %jd bytes\[rs]n", (intmax_t) sb.st_size); printf("Blocks allocated: %jd\[rs]n", (intmax_t) sb.st_blocks); \& printf("Last status change: %s", ctime(&sb.st_ctime)); printf("Last file access: %s", ctime(&sb.st_atime)); printf("Last file modification: %s", ctime(&sb.st_mtime)); \& exit(EXIT_SUCCESS); } .EE .\" SRC END .SH "ZIE OOK" \fBls\fP(1), \fBstat\fP(1), \fBaccess\fP(2), \fBchmod\fP(2), \fBchown\fP(2), \fBreadlink\fP(2), \fBstatx\fP(2), \fButime\fP(2), \fBstat\fP(3type), \fBcapabilities\fP(7), \fBinode\fP(7), \fBsymlink\fP(7) .PP .SH VERTALING De Nederlandse vertaling van deze handleiding is geschreven door Jos Boersema , Mario Blättermann en Luc Castermans . .PP Deze vertaling is vrije documentatie; lees de .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3 .UE of later over de Copyright-voorwaarden. Er is geen AANSPRAKELIJKHEID. .PP Indien U fouten in de vertaling van deze handleiding zou vinden, stuur een e-mail naar .MT debian-l10n-dutch@lists.debian.org .ME .