tools/llvm: Do not build with symbols
[minix3.git] / minix / fs / pfs / link.c
blob7b1286d51fc4eb6a95e6fa07c7dbdbf86c9eaa5c
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 = fs_m_in->m_vfs_fs_ftrunc.inode;
17 if( (rip = find_inode(inumb)) == NULL) return(EINVAL);
19 start = fs_m_in->m_vfs_fs_ftrunc.trc_start;
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);