5 #include <minix/callnr.h>
8 #include <minix/vfsif.h>
10 /*===========================================================================*
12 *===========================================================================*/
13 PUBLIC
int fs_ftrunc(void)
20 inumb
= fs_m_in
.REQ_INODE_NR
;
22 if( (rip
= find_inode(inumb
)) == NIL_INODE
) return(EINVAL
);
24 start
= fs_m_in
.REQ_TRC_START_LO
;
25 end
= fs_m_in
.REQ_TRC_END_LO
;
27 return truncate_inode(rip
, start
);
31 /*===========================================================================*
33 *===========================================================================*/
34 PUBLIC
int truncate_inode(rip
, newsize
)
35 register struct inode
*rip
; /* pointer to inode to be truncated */
36 off_t newsize
; /* inode must become this size */
38 /* Set inode to a certain size, freeing any zones no longer referenced
39 * and updating the size in the inode. If the inode is extended, the
40 * extra space is a hole that reads as zeroes.
42 * Nothing special has to happen to file pointers if inode is opened in
43 * O_APPEND mode, as this is different per fd and is checked when
48 /* Pipes can shrink, so adjust size to make sure all zones are removed. */
49 if(newsize
!= 0) return(EINVAL
); /* Only truncate pipes to 0. */
50 rip
->i_size
= newsize
;
52 /* Next correct the inode size. */
53 wipe_inode(rip
); /* Pipes can only be truncated to 0. */