Scroll to navigation

POSIX_FALLOCATE(3) Manuel du programmeur Linux POSIX_FALLOCATE(3)

NOM

posix_fallocate - Allouer de l'espace pour un fichier

SYNOPSIS

#include <fcntl.h>
int posix_fallocate(int fd, off_t offset, off_t len);

Exigences de macros de test de fonctionnalités pour la glibc (consulter feature_test_macros(7)) :

posix_fallocate() :

_POSIX_C_SOURCE >= 200112L

DESCRIPTION

The function posix_fallocate() ensures that disk space is allocated for the file referred to by the file descriptor fd for the bytes in the range starting at offset and continuing for len bytes. After a successful call to posix_fallocate(), subsequent writes to bytes in the specified range are guaranteed not to fail because of lack of disk space.

Si la taille du fichier est inférieure offset+len, le fichier est agrandi à cette taille ; autrement, la taille du fichier n'est pas modifiée.

VALEUR RENVOYÉE

posix_fallocate() renvoie 0 si elle réussit et un numéro d'erreur si elle échoue. Notez que errno n'est pas écrite.

ERREURS

fd n'est pas un descripteur de fichier valable ou n'est pas ouvert en écriture.
offset+len dépasse la taille maximale du fichier.
Un signal a été capturé pendant l'exécution.
offset was less than 0, or len was less than or equal to 0, or the underlying filesystem does not support the operation.
fd ne fait pas référence à un fichier régulier.
Il n'y a pas suffisamment d'espace disponible sur le périphérique où se trouve le fichier référencé par fd.
The filesystem containing the file referred to by fd does not support this operation. This error code can be returned by C libraries that don't perform the emulation shown in NOTES, such as musl libc.
fd fait référence à un tube.

VERSIONS

posix_fallocate() est disponible depuis la glibc 2.1.94.

ATTRIBUTS

Pour une explication des termes utilisés dans cette section, consulter attributes(7).

Interface Attribut Valeur
posix_fallocate() Sécurité des threads MT-Safe (but see NOTES)

CONFORMITÉ

POSIX.1-2001.

POSIX.1-2008 indique qu'une implémentation doit renvoyer l'erreur EINVAL si len valait 0 ou si offset était inférieur à 0. POSIX.1-2001 indique qu'une implémentation doit renvoyer l'erreur EINVAL était inférieur à 0 ou si offset était inférieur à 0 et peut renvoyer cette erreur si len est égal à 0.

NOTES

In the glibc implementation, posix_fallocate() is implemented using the fallocate(2) system call, which is MT-safe. If the underlying filesystem does not support fallocate(2), then the operation is emulated with the following caveats:

  • The emulation is inefficient.
  • There is a race condition where concurrent writes from another thread or process could be overwritten with null bytes.
  • There is a race condition where concurrent file size increases by another thread or process could result in a file whose size is smaller than expected.
  • If fd has been opened with the O_APPEND or O_WRONLY flags, the function fails with the error EBADF.

In general, the emulation is not MT-safe. On Linux, applications may use fallocate(2) if they cannot tolerate the emulation caveats. In general, this is only recommended if the application plans to terminate the operation if EOPNOTSUPP is returned, otherwise the application itself will need to implement a fallback with all the same problems as the emulation provided by glibc.

VOIR AUSSI

fallocate(1), fallocate(2), lseek(2), posix_fadvise(2)

COLOPHON

Cette page fait partie de la publication 5.10 du projet man-pages Linux. Une description du projet et des instructions pour signaler des anomalies et la dernière version de cette page peuvent être trouvées à l'adresse https://www.kernel.org/doc/man-pages/.

TRADUCTION

La traduction française de cette page de manuel a été créée par Christophe Blaess <https://www.blaess.fr/christophe/>, Stéphan Rafin <stephan.rafin@laposte.net>, Thierry Vignaud <tvignaud@mandriva.com>, François Micaux, Alain Portal <aportal@univ-montp2.fr>, Jean-Philippe Guérard <fevrier@tigreraye.org>, Jean-Luc Coulon (f5ibh) <jean-luc.coulon@wanadoo.fr>, Julien Cristau <jcristau@debian.org>, Thomas Huriaux <thomas.huriaux@gmail.com>, Nicolas François <nicolas.francois@centraliens.net>, Florentin Duneau <fduneau@gmail.com>, Simon Paillard <simon.paillard@resel.enst-bretagne.fr>, Denis Barbier <barbier@debian.org> et David Prévot <david@tilapin.org>

Cette traduction est une documentation libre ; veuillez vous reporter à la GNU General Public License version 3 concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE.

Si vous découvrez un bogue dans la traduction de cette page de manuel, veuillez envoyer un message à debian-l10n-french@lists.debian.org.

1 novembre 2020 GNU