4 #include <minix/vfsif.h>
6 /*===========================================================================*
8 *===========================================================================*/
9 int fs_ftrunc(message
*fs_m_in
, message
*fs_m_out
)
15 inumb
= (ino_t
) fs_m_in
->REQ_INODE_NR
;
17 if( (rip
= find_inode(inumb
)) == NULL
) return(EINVAL
);
19 start
= fs_m_in
->REQ_TRC_START_LO
;
21 return truncate_inode(rip
, start
);
25 /*===========================================================================*
27 *===========================================================================*/
28 int truncate_inode(rip
, newsize
)
29 register struct inode
*rip
; /* pointer to inode to be truncated */
30 off_t newsize
; /* inode must become this size */
32 /* Set inode to a certain size, freeing any zones no longer referenced
33 * and updating the size in the inode. If the inode is extended, the
34 * extra space is a hole that reads as zeroes.
36 * Nothing special has to happen to file pointers if inode is opened in
37 * O_APPEND mode, as this is different per fd and is checked when
41 /* Pipes can shrink, so adjust size to make sure all zones are removed. */
42 if(newsize
!= 0) return(EINVAL
); /* Only truncate pipes to 0. */
43 rip
->i_size
= newsize
;
45 /* Next correct the inode size. */
46 wipe_inode(rip
); /* Pipes can only be truncated to 0. */