Remove building with NOCRYPTO option
[minix3.git] / minix / fs / ext2 / stadir.c
blob56bbdfae6d09c17da1200a1b2a3874815ab14afe
1 /* Created (MFS based):
2 * February 2010 (Evgeniy Ivanov)
3 */
5 #include "fs.h"
6 #include <string.h>
7 #include <sys/stat.h>
8 #include <sys/statvfs.h>
9 #include "inode.h"
10 #include "super.h"
13 /*===========================================================================*
14 * fs_stat *
15 *===========================================================================*/
16 int fs_stat(ino_t ino_nr, struct stat *statbuf)
18 struct inode *rip;
19 mode_t mo;
20 int s;
22 if ((rip = get_inode(fs_dev, ino_nr)) == NULL)
23 return(EINVAL);
25 /* Update the atime, ctime, and mtime fields in the inode, if need be. */
26 if (rip->i_update) update_times(rip);
28 /* Fill in the statbuf struct. */
29 mo = rip->i_mode & I_TYPE;
31 /* true iff special */
32 s = (mo == I_CHAR_SPECIAL || mo == I_BLOCK_SPECIAL);
34 statbuf->st_mode = rip->i_mode;
35 statbuf->st_nlink = rip->i_links_count;
36 statbuf->st_uid = rip->i_uid;
37 statbuf->st_gid = rip->i_gid;
38 statbuf->st_rdev = (s ? (dev_t)rip->i_block[0] : NO_DEV);
39 statbuf->st_size = rip->i_size;
40 statbuf->st_atime = rip->i_atime;
41 statbuf->st_mtime = rip->i_mtime;
42 statbuf->st_ctime = rip->i_ctime;
43 statbuf->st_blksize = rip->i_sp->s_block_size;
44 statbuf->st_blocks = rip->i_blocks;
46 put_inode(rip); /* release the inode */
48 return(OK);
51 /*===========================================================================*
52 * fs_statvfs *
53 *===========================================================================*/
54 int fs_statvfs(struct statvfs *st)
56 struct super_block *sp;
58 sp = get_super(fs_dev);
60 st->f_flag = ST_NOTRUNC;
61 st->f_bsize = sp->s_block_size;
62 st->f_frsize = sp->s_block_size;
63 st->f_iosize = sp->s_block_size;
64 st->f_blocks = sp->s_blocks_count;
65 st->f_bfree = sp->s_free_blocks_count;
66 st->f_bavail = sp->s_free_blocks_count - sp->s_r_blocks_count;
67 st->f_files = sp->s_inodes_count;
68 st->f_ffree = sp->s_free_inodes_count;
69 st->f_favail = sp->s_free_inodes_count;
70 st->f_namemax = EXT2_NAME_MAX;
72 return(OK);