1 /* VTreeFS - stadir.c - by Alen Stojanov and David van Moolenbroek */ 2 3 #include "inc.h" 4 5 /*===========================================================================* 6 * fs_stat * 7 *===========================================================================*/ 8 int fs_stat(ino_t ino_nr, struct stat *buf) 9 { 10 /* Retrieve file status. 11 */ 12 char path[PATH_MAX]; 13 time_t cur_time; 14 struct inode *node; 15 int r; 16 17 if ((node = find_inode(ino_nr)) == NULL) 18 return EINVAL; 19 20 /* Fill in the basic info. */ 21 buf->st_dev = fs_dev; 22 buf->st_ino = get_inode_number(node); 23 buf->st_mode = node->i_stat.mode; 24 buf->st_nlink = !is_inode_deleted(node); 25 buf->st_uid = node->i_stat.uid; 26 buf->st_gid = node->i_stat.gid; 27 buf->st_rdev = (dev_t) node->i_stat.dev; 28 buf->st_size = node->i_stat.size; 29 30 /* If it is a symbolic link, return the size of the link target. */ 31 if (S_ISLNK(node->i_stat.mode) && vtreefs_hooks->rdlink_hook != NULL) { 32 r = vtreefs_hooks->rdlink_hook(node, path, sizeof(path), 33 get_inode_cbdata(node)); 34 35 if (r == OK) 36 buf->st_size = strlen(path); 37 } 38 39 /* Take the current time as file time for all files. */ 40 cur_time = clock_time(NULL); 41 buf->st_atime = cur_time; 42 buf->st_mtime = cur_time; 43 buf->st_ctime = cur_time; 44 45 return OK; 46 } 47 48 /*===========================================================================* 49 * fs_statvfs * 50 *===========================================================================*/ 51 int fs_statvfs(struct statvfs *buf) 52 { 53 /* Retrieve file system statistics. 54 */ 55 56 buf->f_flag = ST_NOTRUNC; 57 buf->f_namemax = PNAME_MAX; 58 59 return OK; 60 } 61