vm, kernel, top: report memory usage of vm, kernel
[minix.git] / servers / pfs / link.c
blob9fc2bfb47d9492aee9f39c682481441782a16c8d
1 #include "fs.h"
2 #include "buf.h"
3 #include "inode.h"
4 #include <minix/vfsif.h>
6 /*===========================================================================*
7 * fs_ftrunc *
8 *===========================================================================*/
9 int fs_ftrunc(message *fs_m_in, message *fs_m_out)
11 struct inode *rip;
12 off_t start;
13 ino_t inumb;
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 /*===========================================================================*
26 * truncate_inode *
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
38 * writing is done.
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. */
48 return(OK);