-/* Transfers file attributes from a struct dentry to a `stat' buffer. */
-void dentry_to_stbuf(const struct dentry *dentry, struct stat *stbuf,
- const struct lookup_table *table)
-{
- struct lookup_table_entry *lte;
-
- if (dentry_is_symlink(dentry))
- stbuf->st_mode = S_IFLNK | 0777;
- else if (dentry_is_directory(dentry))
- stbuf->st_mode = S_IFDIR | 0755;
- else
- stbuf->st_mode = S_IFREG | 0644;
-
- /* Use the size of the unnamed (default) file stream. */
- if (table && (lte = __lookup_resource(table, dentry_hash(dentry))))
- stbuf->st_size = lte->resource_entry.original_size;
- else
- stbuf->st_size = 0;
-
- stbuf->st_nlink = dentry_link_group_size(dentry);
- stbuf->st_ino = dentry->hard_link;
- stbuf->st_uid = getuid();
- stbuf->st_gid = getgid();
- stbuf->st_atime = ms_timestamp_to_unix(dentry->last_access_time);
- stbuf->st_mtime = ms_timestamp_to_unix(dentry->last_write_time);
- stbuf->st_ctime = ms_timestamp_to_unix(dentry->creation_time);
- stbuf->st_blocks = (stbuf->st_size + 511) / 512;
-}