.\" -*- coding: UTF-8 -*- .\" Copyright (c) 2007 Silicon Graphics, Inc. All Rights Reserved .\" Written by Dave Chinner .\" .\" SPDX-License-Identifier: GPL-2.0-only .\" .\" 2011-09-19: Added FALLOC_FL_PUNCH_HOLE .\" 2011-09-19: Substantial restructuring of the page .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH fallocate 2 "17 ноября 2024 г." "Linux man\-pages 6.12" .SH НАИМЕНОВАНИЕ fallocate \- управление пространством файла .SH БИБЛИОТЕКА Standard C library (\fIlibc\fP,\ \fI\-lc\fP) .SH ОБЗОР .nf \fB#define _GNU_SOURCE\fP /* Смотрите feature_test_macros(7) */ \fB#include \fP .P \fBint fallocate(int \fP\fIfd\fP\fB, int \fP\fImode\fP\fB, off_t \fP\fIoffset\fP\fB, off_t \fP\fIsize\fP\fB);\fP .fi .SH ОПИСАНИЕ Это непереносимый системный вызов, существующий только в Linux. В POSIX.1 есть переносимый метод, обеспечивающий выделение пространства под файл (смотрите \fBposix_fallocate\fP(3)). .P \fBfallocate\fP() allows the caller to directly manipulate the allocated disk space for the file referred to by \fIfd\fP for the byte range starting at \fIoffset\fP and continuing for \fIsize\fP bytes. .P В аргументе \fImode\fP задаётся операция, выполняемая над указанным диапазоном. Детали о поддерживаемых операциях представлены в подразделах далее. .SS "Выделение дискового пространства" The default operation (i.e., \fImode\fP is zero) of \fBfallocate\fP() allocates the disk space within the range specified by \fIoffset\fP and \fIsize\fP. The file size (as reported by \fBstat\fP(2)) will be changed if \fIoffset\fP+\fIsize\fP is greater than the file size. Any subregion within the range specified by \fIoffset\fP and \fIsize\fP that did not contain data before the call will be initialized to zero. This default behavior closely resembles the behavior of the \fBposix_fallocate\fP(3) library function, and is intended as a method of optimally implementing that function. .P After a successful call, subsequent writes into the range specified by \fIoffset\fP and \fIsize\fP are guaranteed not to fail because of lack of disk space. .P If the \fBFALLOC_FL_KEEP_SIZE\fP flag is specified in \fImode\fP, the behavior of the call is similar, but the file size will not be changed even if \fIoffset\fP+\fIsize\fP is greater than the file size. Preallocating zeroed blocks beyond the end of the file in this manner is useful for optimizing append workloads. .P Если в \fImode\fPуказан флаг \fBFALLOC_FL_UNSHARE_RANGE\fP, то общие файловые extent\-данные будут сделаны частными для файла, чтобы гарантировать, что последующая запись не завершится ошибкой из\-за нехватки места. Обычно, это выполняется с помощью операции копирования при записи для всех общих данных файла. Данный флаг может поддерживаться не во всех файловых системах. .P Так как выделение выполняется кусками размером с блок, \fBfallocate\fP() может выделить больший диапазон дискового пространства, чем было указано. .SS "Освобождение файлового пространства" Specifying the \fBFALLOC_FL_PUNCH_HOLE\fP flag (available since Linux 2.6.38) in \fImode\fP deallocates space (i.e., creates a hole) in the byte range starting at \fIoffset\fP and continuing for \fIsize\fP bytes. Within the specified range, partial filesystem blocks are zeroed, and whole filesystem blocks are removed from the file. After a successful call, subsequent reads from this range will return zeros. .P Флаг \fBFALLOC_FL_PUNCH_HOLE\fP должен быть логически добавлен к флагу \fBFALLOC_FL_KEEP_SIZE\fP в \fImode\fP; другими словами, даже когда пробивание (punching) выходит за конец файла, размер файла (получаемый с помощью \fBstat\fP(2)) остаётся неизменным. .P Не все файловые системы поддерживают \fBFALLOC_FL_PUNCH_HOLE\fP; если файловая система не поддерживает эту операцию, то возвращается ошибка. Операция поддерживается, как минимум, следующими файловыми системами: .IP \[bu] 3 XFS (начиная с Linux 2.6.38) .IP \[bu] .\" commit a4bb6b64e39abc0e41ca077725f2a72c868e7622 ext4 (начиная с Linux 3.0) .IP \[bu] Btrfs (начиная с Linux 3.7) .IP \[bu] .\" commit 83e4fa9c16e4af7122e31be3eca5d57881d236fe \fBtmpfs\fP(5) (начиная с Linux 3.5) .IP \[bu] .\" commit 4e56a6411fbce6f859566e17298114c2434391a4 \fBgfs2\fP(5) (начиная с Linux 4.16) .SS "Сворачивание (Collapsing) файлового пространства" .\" commit 00f5e61998dd17f5375d9dfc01331f104b83f841 Specifying the \fBFALLOC_FL_COLLAPSE_RANGE\fP flag (available since Linux 3.15) in \fImode\fP removes a byte range from a file, without leaving a hole. The byte range to be collapsed starts at \fIoffset\fP and continues for \fIsize\fP bytes. At the completion of the operation, the contents of the file starting at the location \fIoffset+size\fP will be appended at the location \fIoffset\fP, and the file will be \fIsize\fP bytes smaller. .P A filesystem may place limitations on the granularity of the operation, in order to ensure efficient implementation. Typically, \fIoffset\fP and \fIsize\fP must be a multiple of the filesystem logical block size, which varies according to the filesystem type and configuration. If a filesystem has such a requirement, \fBfallocate\fP() fails with the error \fBEINVAL\fP if this requirement is violated. .P If the region specified by \fIoffset\fP plus \fIsize\fP reaches or passes the end of file, an error is returned; instead, use \fBftruncate\fP(2) to truncate a file. .P Вместе с \fBFALLOC_FL_COLLAPSE_RANGE\fP другие флаги в \fImode\fP указывать нельзя. .P .\" commit 9eb79482a97152930b113b51dff530aba9e28c8e .\" commit e1d8fb88a64c1f8094b9f6c3b6d2d9e6719c970d В Linux 3.15 флаг \fBFALLOC_FL_COLLAPSE_RANGE\fP поддерживается в ext4 (только для файлов на основе extent) и XFS. .SS "Зануление файлового пространства" .\" commit 409332b65d3ed8cfa7a8030f1e9d52f372219642 Specifying the \fBFALLOC_FL_ZERO_RANGE\fP flag (available since Linux 3.15) in \fImode\fP zeros space in the byte range starting at \fIoffset\fP and continuing for \fIsize\fP bytes. Within the specified range, blocks are preallocated for the regions that span the holes in the file. After a successful call, subsequent reads from this range will return zeros. .P Зануление, желательно, выполнять внутри файловой системы, преобразуя диапазон в незаписываемые extents. Этот подход означает, что указанный диапазон на устройстве в действительности не будет содержать нули на физическом уровне (за исключением неполных блоков в одном из концов диапазона), и ввод\-вывод требуется только для обновления метаданных. .P If the \fBFALLOC_FL_KEEP_SIZE\fP flag is additionally specified in \fImode\fP, the behavior of the call is similar, but the file size will not be changed even if \fIoffset\fP+\fIsize\fP is greater than the file size. This behavior is the same as when preallocating space with \fBFALLOC_FL_KEEP_SIZE\fP specified. .P Не все файловые системы поддерживают \fBFALLOC_FL_ZERO_RANGE\fP; если файловая система не поддерживает эту операцию, то возвращается ошибка. Операция поддерживается, как минимум, следующими файловыми системами: .IP \[bu] 3 .\" commit 376ba313147b4172f3e8cf620b9fb591f3e8cdfa XFS (начиная с Linux 3.15) .IP \[bu] .\" commit b8a8684502a0fc852afa0056c6bb2a9273f6fcc0 ext4, для файлов на основе extent (начиная с Linux 3.15) .IP \[bu] .\" commit 30175628bf7f521e9ee31ac98fa6d6fe7441a556 SMB3 (начиная с Linux 3.17) .IP \[bu] .\" commit f27451f229966874a8793995b8e6b74326d125df Btrfs (начиная с Linux 4.16) .SS "Увеличение файлового пространства" .\" commit dd46c787788d5bf5b974729d43e4c405814a4c7d Specifying the \fBFALLOC_FL_INSERT_RANGE\fP flag (available since Linux 4.1) in \fImode\fP increases the file space by inserting a hole within the file size without overwriting any existing data. The hole will start at \fIoffset\fP and continue for \fIsize\fP bytes. When inserting the hole inside file, the contents of the file starting at \fIoffset\fP will be shifted upward (i.e., to a higher file offset) by \fIsize\fP bytes. Inserting a hole inside a file increases the file size by \fIsize\fP bytes. .P Данный режим имеет те же ограничения что и \fBFALLOC_FL_COLLAPSE_RANGE\fP, независимо от детализации операции Если требования детализации не удовлетворяются, то \fBfallocate\fP() завершается ошибкой \fBEINVAL\fP. Если \fIoffset\fP больше или равно концу файла, то возвращается ошибка. Для таких операций (т. е., вставка дыры в конец файла) нужно использовать \fBftruncate\fP(2). .P Вместе с \fBFALLOC_FL_INSERT_RANGE\fP другие флаги в \fImode\fP указывать нельзя. .P .\" commit a904b1ca5751faf5ece8600e18cd3b674afcca1b .\" commit 331573febb6a224bc50322e3670da326cb7f4cfc .\" f2fs also has support since Linux 4.2 .\" commit f62185d0e283e9d311e3ac1020f159d95f0aab39 Для работы \fBFALLOC_FL_INSERT_RANGE\fP требуется поддержка в файловой системе; сейчас это XFS (начиная с Linux 4.1) и ext4 (начиная с Linux 4.2). .SH "ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ" При успешном выполнении \fBfallocate\fP() возвращается 0; при ошибке возвращается \-1, а в \fIerrno\fP содержится код ошибки. .SH ОШИБКИ .TP \fBEBADF\fP \fIfd\fP не является допустимым файловым дескриптором или не открыт на запись. .TP \fBEFBIG\fP \fIoffset\fP+\fIsize\fP exceeds the maximum file size. .TP \fBEFBIG\fP В \fImode\fP указан \fBFALLOC_FL_INSERT_RANGE\fP, и текущий размер файла+\fIlen\fP превышает максимальный файловый размер. .TP \fBEINTR\fP При выполнении поступил сигнал; смотрите \fBsignal\fP(7). .TP \fBEINVAL\fP .\" FIXME . (raise a kernel bug) Probably the size==0 case should be .\" a no-op, rather than an error. That would be consistent with .\" similar APIs for the size==0 case. .\" See "Re: [PATCH] fallocate.2: add FALLOC_FL_PUNCH_HOLE flag definition" .\" 21 Sep 2012 .\" http://thread.gmane.org/gmane.linux.file-systems/48331/focus=1193526 \fIoffset\fP was less than 0, or \fIsize\fP was less than or equal to 0. .TP \fBEINVAL\fP \fImode\fP is \fBFALLOC_FL_COLLAPSE_RANGE\fP and the range specified by \fIoffset\fP plus \fIsize\fP reaches or passes the end of the file. .TP \fBEINVAL\fP Значение \fImode\fP равно \fBFALLOC_FL_INSERT_RANGE\fP, но диапазон, указанный в \fIoffset\fP, достиг или перешагнул за конец файла. .TP \fBEINVAL\fP \fImode\fP is \fBFALLOC_FL_COLLAPSE_RANGE\fP or \fBFALLOC_FL_INSERT_RANGE\fP, but either \fIoffset\fP or \fIsize\fP is not a multiple of the filesystem block size. .TP \fBEINVAL\fP Значение \fImode\fP содержит \fBFALLOC_FL_COLLAPSE_RANGE\fP или \fBFALLOC_FL_INSERT_RANGE\fP, а также другие флаги; но с \fBFALLOC_FL_COLLAPSE_RANGE\fP или \fBFALLOC_FL_INSERT_RANGE\fP другие флаги указывать нельзя. .TP \fBEINVAL\fP .\" There was an inconsistency in Linux 3.15-rc1, that should be resolved so that all .\" filesystems use this error for this case. (Tytso says ex4 will change.) .\" http://thread.gmane.org/gmane.comp.file-systems.xfs.general/60485/focus=5521 .\" From: Michael Kerrisk (man-pages .\" Subject: Re: [PATCH v5 10/10] manpage: update FALLOC_FL_COLLAPSE_RANGE flag in fallocate .\" Newsgroups: gmane.linux.man, gmane.linux.file-systems .\" Date: 2014-04-17 13:40:05 GMT \fImode\fP is \fBFALLOC_FL_COLLAPSE_RANGE\fP, \fBFALLOC_FL_ZERO_RANGE\fP, or \fBFALLOC_FL_INSERT_RANGE\fP, but the file referred to by \fIfd\fP is not a regular file. .TP \fBEIO\fP При чтении или записи в файловую систему произошла ошибка ввода\-вывода. .TP \fBENODEV\fP Значение \fIfd\fP не указывает на обычный файл или каталог (если \fIfd\fP — канал или FIFO, то возникнет другая ошибка). .TP \fBENOSPC\fP Недостаточно дискового пространства на устройстве, на котором расположен файл, указанный в \fIfd\fP. .TP \fBENOSYS\fP В данном ядре вызов \fBfallocate\fP() не реализован. .TP \fBEOPNOTSUPP\fP Файловая система с файлом, на который указывает \fIfd\fP, не поддерживает данную операцию; или значение \fImode\fP не поддерживается файловой системой, в которой находится файл, на который указывает \fIfd\fP. .TP \fBEPERM\fP Файл, на который указывает \fIfd\fP, помечен как неизменяемый (immutable) (смотрите \fBchattr\fP(1)). .TP \fBEPERM\fP \fImode\fP specifies \fBFALLOC_FL_PUNCH_HOLE\fP, \fBFALLOC_FL_COLLAPSE_RANGE\fP, or \fBFALLOC_FL_INSERT_RANGE\fP and the file referred to by \fIfd\fP is marked append\-only (see \fBchattr\fP(1)). .TP \fBEPERM\fP Выполнение операции предотвращено опечатыванием (file seal); смотрите \fBfcntl\fP(2). .TP \fBESPIPE\fP Значение \fIfd\fP указывает на канал или FIFO. .TP \fBETXTBSY\fP Значение \fImode\fP равно \fBFALLOC_FL_COLLAPSE_RANGE\fP или \fBFALLOC_FL_INSERT_RANGE\fP, но файл, на который указывает \fIfd\fP, в данный момент выполняется. .SH СТАНДАРТЫ Linux. .SH ИСТОРИЯ .TP \fBfallocate\fP() Linux 2.6.23, glibc 2.10. .TP \fBFALLOC_FL_*\fP .\" See http://sourceware.org/bugzilla/show_bug.cgi?id=14964 glibc 2.18. .SH "СМОТРИТЕ ТАКЖЕ" \fBfallocate\fP(1), \fBftruncate\fP(2), \fBposix_fadvise\fP(3), \fBposix_fallocate\fP(3) .PP .SH ПЕРЕВОД Русский перевод этой страницы руководства разработал(и) Azamat Hackimov , Dmitry Bolkhovskikh , Yuri Kozlov , Иван Павлов и Kirill Rekhov . .PP Этот перевод является свободной программной документацией; он распространяется на условиях общедоступной лицензии GNU (GNU General Public License - GPL, .UR https://www.gnu.org/licenses/gpl-3.0.html .UE версии 3 или более поздней) в отношении авторского права, но БЕЗ КАКИХ-ЛИБО ГАРАНТИЙ. .PP Если вы обнаружите какие-либо ошибки в переводе этой страницы руководства, пожалуйста, сообщите об этом разработчику(ам) по его(их) адресу(ам) электронной почты или по адресу .MT списка рассылки русских переводчиков .ME .