Drop main() prototype. Syncs with NetBSD-8
[minix.git] / minix / lib / libpuffs / stadir.c
blobd6decd3649d672cbd46a7afddf6e905df30f5303
1 /* Created (MFS based):
2 * February 2010 (Evgeniy Ivanov)
3 */
5 #include "fs.h"
7 /*===========================================================================*
8 * fs_stat *
9 *===========================================================================*/
10 int fs_stat(ino_t ino_nr, struct stat *statbuf)
12 register struct puffs_node *pn; /* target pnode */
13 struct vattr va;
14 mode_t mo;
15 int s;
16 PUFFS_MAKECRED(pcr, &global_kcred);
18 if (global_pu->pu_ops.puffs_node_getattr == NULL) {
19 lpuffs_debug("fs_stat: puffs_node_getattr is missing\n");
20 return(EINVAL);
23 if ((pn = puffs_pn_nodewalk(global_pu, find_inode_cb, &ino_nr)) == NULL) {
24 lpuffs_debug("walk failed...\n");
25 return(EINVAL);
28 if (global_pu->pu_ops.puffs_node_getattr(global_pu, pn, &va, pcr) != 0) {
29 if (errno) {
30 if (errno > 0) errno = -errno;
31 return(errno);
33 return(EINVAL);
36 /* Fill in the statbuf struct. */
37 mo = va.va_mode & I_TYPE;
39 /* true iff special */
40 s = (mo == I_CHAR_SPECIAL || mo == I_BLOCK_SPECIAL);
42 statbuf->st_mode = va.va_mode;
43 statbuf->st_nlink = va.va_nlink;
44 statbuf->st_uid = va.va_uid;
45 statbuf->st_gid = va.va_gid;
46 statbuf->st_rdev = (s ? va.va_rdev : NO_DEV);
47 statbuf->st_size = va.va_size;
48 statbuf->st_atimespec = va.va_atime;
49 statbuf->st_mtimespec = va.va_mtime;
50 statbuf->st_ctimespec = va.va_ctime;
52 statbuf->st_birthtimespec = va.va_birthtime;
53 statbuf->st_blksize = va.va_blocksize;
54 statbuf->st_blocks = va.va_bytes / va.va_blocksize;
55 statbuf->st_flags = va.va_flags;
56 statbuf->st_gen = va.va_gen;
58 return(OK);
62 /*===========================================================================*
63 * fs_statvfs *
64 *===========================================================================*/
65 int fs_statvfs(struct statvfs *st)
68 if (global_pu->pu_ops.puffs_fs_statvfs(global_pu, st) != 0) {
69 lpuffs_debug("statvfs failed\n");
70 return(EINVAL);
73 /* libpuffs doesn't truncate filenames */
74 st->f_flag |= ST_NOTRUNC;
76 return(OK);