truncate

å称
     truncate, ftruncate — æå®ããé·ãã«ãã¡ã¤ã«ãåãæ¨ã¦ããæ¡å¼µããããã

ã©ã¤ãã©ãª
     Standard C Library (libc, -lc)

æ¸å¼
     <unistd.h> int truncate(const char *path, off_t length) int ftruncate(int
     fd, off_t length)

解説
     truncate() ã·ã¹ãã ã³ã¼ã«ã¯ã path ã§æå®ããããã¡ã¤ã«ã fd
     ã§åç§ããããã¡ã¤ã«ã®ãµã¤ãºãã length ãã¤ãã«ãªãããã«åãæ¨ã¦ããæ¡å¼µãã¾ãã
     ãã¡ã¤ã«ããã®ãµã¤ãºãã大ããå ´åã¯ãä½åãªãã¼ã¿ã失ããã¾ãã
     ãã¡ã¤ã«ããã®ãµã¤ãºããå°ããå ´åã¯ã0 ãæ¸ãè¾¼ã¾ããããã«æ¡å¼µããã¾ãã ftruncate()
     ã§ã¯ããã¡ã¤ã«ãæ¸è¾¼ã¿ç¨ã«éãã¦ããå¿è¦ãããã¾ãã

æ»ãå¤
     Upon successful completion, the value 0 is returned; otherwise the
     value -1 is returned and the global variable errno is set to indicate the
     error.

ã¨ã©ã¼
     truncate() ã·ã¹ãã ã³ã¼ã«ã¯ã以ä¸ã®ãããªå ´åã«å¦çã失æãã¾ã:

     [ENOTDIR]          ãã¹ã®æ§æè¦ç´ ä¸ã«ãã£ã¬ã¯ããªä»¥å¤ã®ãã®ãå«ã¾ãã¦ãã¾ãã

     [ENAMETOOLONG]     ãã¹åã®æ§æè¦ç´ ã 255 æåãè¶ãã¦ãããã ã¾ãã¯ãã¹åå¨ä½ã 1023
                        æåãè¶ãã¦ãã¾ãã

     [ENOENT]           æå®ããããã¡ã¤ã«ãåå¨ãã¾ããã

     [EACCES]           åç½®ãã¹åã®æ§æè¦ç´ ã«ã¤ãã¦æ¤ç´¢è¨±å¯ãæå¦ããã¦ãã¾ãã

     [EACCES]           æå®ããããã¡ã¤ã«ã«ã¦ã¼ã¶ãæ¸ãè¾¼ãã¾ããã

     [ELOOP]            ãã¹åãå¤æããã¨ãã«æ¤åºãããã·ã³ããªãã¯ãªã³ã¯ãå¤ããã¾ãã

     [EISDIR]           æå®ããããã¡ã¤ã«ããã£ã¬ã¯ããªã«ãªã£ã¦ãã¾ãã

     [EROFS]            æå®ããããã¡ã¤ã«ã¯èªåãå°ç¨ãã¡ã¤ã«ã·ã¹ãã ä¸ã«ããã¾ãã

     [ETXTBSY]          ãã¡ã¤ã«ããå®è¡ä¸ã®ãã¥ã¢ããã·ã¼ã¸ã£ (å±æããã¹ã)
                        ãã¡ã¤ã«ã§ãã

     [EIO]              inode ã®æ´æ°ããã¦ããéã«å¥åºåã¨ã©ã¼ãçºçãã¾ããã

     [EFAULT]           path å¼æ°ãããã‐
                        ã»ã¹ã«å²ãå½ã¦ãããã¢ãã¬ã¹ç©ºéã®ç¯å²å¤ãæãã¦ãã¾ãã

     ftruncate() ã·ã¹ãã ã³ã¼ã«ã¯ã以ä¸ã®ãããªå ´åã«å¦çã失æãã¾ã:

     [EBADF]            fd å¼æ°ãæå¹ãªè¨è¿°åã§ã¯ããã¾ããã

     [EINVAL]           fd å¼æ°ã¯ãã¡ã¤ã«ã§ã¯ãªãã½ã±ãããåç§ãã¦ãã¾ãã

     [EINVAL]           fd å¼æ°ãæ¸è¾¼ã¿ç¨ã«éãã¦ãã¾ããã

é¢é£é ç®
     open(2)

ãã°
     ãã®å¼åºãã¯ããã¡ã¤ã«ã®ããç¯å²ãæ¾æ£ã§ããããã«ä¸è¬åãã å¿è¦ãããã¾ãã

     truncate() ã使ç¨ãã¦ãã¡ã¤ã«ãæ¡å¼µããã¨ã移æ¤æ§ã失ããã¾ãã

æ´å²
     truncate() ã·ã¹ãã ã³ã¼ã«ã¯ã 4.2BSD ã§ç»å ´ãã¾ããã