1 /* VTreeFS - stadir.c - by Alen Stojanov and David van Moolenbroek */
6 #include <sys/statfs.h>
7 #include <sys/statvfs.h>
10 /*===========================================================================*
12 *===========================================================================*/
15 /* Retrieve file status.
23 if ((node
= find_inode(fs_m_in
.REQ_INODE_NR
)) == NULL
)
26 memset(&statbuf
, 0, sizeof(struct stat
));
28 /* Fill in the basic info. */
29 statbuf
.st_dev
= fs_dev
;
30 statbuf
.st_ino
= get_inode_number(node
);
31 statbuf
.st_mode
= node
->i_stat
.mode
;
32 statbuf
.st_nlink
= !is_inode_deleted(node
);
33 statbuf
.st_uid
= node
->i_stat
.uid
;
34 statbuf
.st_gid
= node
->i_stat
.gid
;
35 statbuf
.st_rdev
= (dev_t
) node
->i_stat
.dev
;
36 statbuf
.st_size
= node
->i_stat
.size
;
38 /* If it is a symbolic link, return the size of the link target. */
39 if (S_ISLNK(node
->i_stat
.mode
) && vtreefs_hooks
->rdlink_hook
!= NULL
) {
40 r
= vtreefs_hooks
->rdlink_hook(node
, path
, sizeof(path
),
41 get_inode_cbdata(node
));
44 statbuf
.st_size
= strlen(path
);
47 /* Take the current time as file time for all files. */
48 cur_time
= time(NULL
);
49 statbuf
.st_atime
= cur_time
;
50 statbuf
.st_mtime
= cur_time
;
51 statbuf
.st_ctime
= cur_time
;
53 /* Copy the struct to user space. */
54 return sys_safecopyto(fs_m_in
.m_source
, fs_m_in
.REQ_GRANT
, 0,
55 (vir_bytes
) &statbuf
, (phys_bytes
) sizeof(statbuf
));
58 /*===========================================================================*
60 *===========================================================================*/
63 /* Retrieve file system statistics.
67 memset(&statfs
, 0, sizeof(statfs
));
69 /* Copy the struct to user space. */
70 return sys_safecopyto(fs_m_in
.m_source
, fs_m_in
.REQ_GRANT
, 0,
71 (vir_bytes
) &statfs
, (phys_bytes
) sizeof(statfs
));
74 /*===========================================================================*
76 *===========================================================================*/
79 /* Retrieve file system statistics.
81 struct statvfs statvfs
;
83 memset(&statvfs
, 0, sizeof(statvfs
));
85 statvfs
.f_fsid
= fs_dev
;
86 statvfs
.f_flag
= ST_RDONLY
| ST_NOTRUNC
;
87 statvfs
.f_namemax
= PNAME_MAX
;
89 return sys_safecopyto(fs_m_in
.m_source
, fs_m_in
.REQ_GRANT
, 0,
90 (vir_bytes
) &statvfs
, sizeof(statvfs
));