1 /* VTreeFS - stadir.c - file and file system status management */
6 * Retrieve file status.
9 fs_stat(ino_t ino_nr
, struct stat
* buf
)
16 if ((node
= find_inode(ino_nr
)) == NULL
)
19 /* Fill in the basic info. */
20 buf
->st_mode
= node
->i_stat
.mode
;
21 buf
->st_nlink
= !is_inode_deleted(node
);
22 buf
->st_uid
= node
->i_stat
.uid
;
23 buf
->st_gid
= node
->i_stat
.gid
;
24 buf
->st_rdev
= (dev_t
) node
->i_stat
.dev
;
25 buf
->st_size
= node
->i_stat
.size
;
27 /* If it is a symbolic link, return the size of the link target. */
28 if (S_ISLNK(node
->i_stat
.mode
) && vtreefs_hooks
->rdlink_hook
!= NULL
) {
29 r
= vtreefs_hooks
->rdlink_hook(node
, path
, sizeof(path
),
30 get_inode_cbdata(node
));
33 buf
->st_size
= strlen(path
);
36 /* Take the current time as file time for all files. */
37 cur_time
= clock_time(NULL
);
38 buf
->st_atime
= cur_time
;
39 buf
->st_mtime
= cur_time
;
40 buf
->st_ctime
= cur_time
;
49 fs_chmod(ino_t ino_nr
, mode_t
* mode
)
52 struct inode_stat istat
;
55 if ((node
= find_inode(ino_nr
)) == NULL
)
58 if (vtreefs_hooks
->chstat_hook
== NULL
)
61 get_inode_stat(node
, &istat
);
63 istat
.mode
= (istat
.mode
& ~ALL_MODES
) | (*mode
& ALL_MODES
);
65 r
= vtreefs_hooks
->chstat_hook(node
, &istat
, get_inode_cbdata(node
));
70 get_inode_stat(node
, &istat
);
78 * Change file ownership.
81 fs_chown(ino_t ino_nr
, uid_t uid
, gid_t gid
, mode_t
* mode
)
84 struct inode_stat istat
;
87 if ((node
= find_inode(ino_nr
)) == NULL
)
90 if (vtreefs_hooks
->chstat_hook
== NULL
)
93 get_inode_stat(node
, &istat
);
97 istat
.mode
&= ~(S_ISUID
| S_ISGID
);
99 r
= vtreefs_hooks
->chstat_hook(node
, &istat
, get_inode_cbdata(node
));
104 get_inode_stat(node
, &istat
);
112 * Retrieve file system statistics.
115 fs_statvfs(struct statvfs
* buf
)
118 buf
->f_flag
= ST_NOTRUNC
;
119 buf
->f_namemax
= NAME_MAX
;