Fixed extern declaration from pointer to array
[minix.git] / servers / pfs / link.c
blob12c8285ee4b1e02da0816f5aa447ea81f3538a41
1 #include "fs.h"
2 #include <sys/stat.h>
3 #include <string.h>
4 #include <minix/com.h>
5 #include <minix/callnr.h>
6 #include "buf.h"
7 #include "inode.h"
8 #include <minix/vfsif.h>
10 /*===========================================================================*
11 * fs_ftrunc *
12 *===========================================================================*/
13 PUBLIC int fs_ftrunc(void)
15 struct inode *rip;
16 off_t start, end;
17 int r;
18 ino_t inumb;
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 /*===========================================================================*
32 * truncate_inode *
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
44 * writing is done.
46 int scale;
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. */
55 return(OK);