Rechercher une page de manuel
truncate
Langue: pl
Version: 1998-12-21 (openSuse - 09/10/07)
Section: 2 (Appels système)
NAZWA
truncate, ftruncate - ustawienie d³ugo¶ci plikuSK£ADNIA
#include <unistd.h>#include <sys/types.h>
int truncate(const char *path, off_t length);
int ftruncate(int fd, off_t length);
OPIS
Funkcje truncate i ftruncate powoduj± ustawienie d³ugo¶ci pliku wskazanego przez nazwê path lub wskazanego przez deskryptor fd na dok³adnie length bajtów d³ugo¶ci.Je¿eli plik przed operacj± by³ d³u¿szy to odciête dane zostan± utracone. Je¿eli plik przed operacja by³ krótszy zostanie on wyd³u¿ony bajtami o warto¶ci zero.
Bie¿±cy wska¼nik pliku nie jest zmieniany.
Je¿eli zmieni³ siê rozmiar pliku to ctime i mtime pliku s± aktualizowane, a bity suid i sgid atrybutów pliku s± kasowane.
Deskryptor pliku przekazywany do ftruncate, musi byæ otwarty do zapisu, a plik którego nazwa przekazywana jest do truncate, musi byæ dostêpny do zapisu.
WARTO¦Æ ZWRACANA
Przy pomy¶lnym zakoñczeniu funkcje zwracaj± warto¶æ zero. Przy wyst±pieniu b³êdu zwracane jest -1 a w³a¶ciwa informacja o b³êdzie jest w errno.B£ÊDY
Dla truncate:- EACCES
- Search permission is denied for a component of the path prefix, or the named file is not writable by the user.
- EFAULT
- Path points outside the process's allocated address space.
- EFBIG
- Argument length jest wiêkszy ni¿ maksymalna d³ugo¶æ pliku. (XSI)
- EINTR
- A signal was caught during execution.
- EINVAL
- The argument length is negative or larger than the maximum file size.
- EIO
- An I/O error occurred updating the inode.
- EISDIR
- Wskazana nazwa pliku jest nazw± katalogu.
- ELOOP
- Too many symbolic links were encountered in translating the pathname.
- ENAMETOOLONG
- A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters.
- ENOENT
- Plik wskazywany przez nazwê nie istnieje.
- ENOTDIR
- A component of the path prefix is not a directory.
- EROFS
- The named file resides on a read-only file system.
- ETXTBSY
- The file is a pure procedure (shared text) file that is being executed.
For ftruncate the same errors apply, but instead of things that can be wrong with path, we now have things that can be wrong with fd:
- EBADF
- The fd is not a valid descriptor.
- EBADF or EINVAL
- The fd is not open for writing.
- EINVAL
- The fd does not reference a regular file.
ZGODNE Z
4.4BSD, SVr4 (these function calls first appeared in BSD 4.2). POSIX 1003.1-1996 has ftruncate. POSIX 1003.1-2001 also has truncate, as an XSI extension.SVr4 documents additional truncate error conditions EMFILE, EMULTIHP, ENFILE, ENOLINK. SVr4 documents for ftruncate an additional EAGAIN error condition.
UWAGI
The above description is for XSI-compliant systems. For non-XSI-compliant systems, the POSIX standard allows two behaviours for ftruncate when length exceeds the file length (note that truncate is not specified at all in such an environment): either returning an error, or extending the file. (Most Unices follow the XSI requirement.)ZOBACZ TAK¯E
open(2)Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre