. libc: add vfs_mmap, a way for vfs to initiate mmap()s. This is a good special case to have as vfs is a slightly different client from regular user processes. It doesn't do it for itself, and has the dev & inode info already so the callback to VFS for the lookup isn't necessary. So it has different info to have to give to VM. . libc: also add minix_mmap64() that accepts a 64-bit offset, even though our off_t is still 32 bit now. . to support mmap, we need to create new references to FD's (such as an FD) so that the mmapped object can never be removed even if all FD's are closed. To do that we conceptually dup the filedescriptor into a new range that is only visible to the system. So there are FDS_PER_PROCESS fd's, which is more than OPEN_MAX, per process, and user processes can still use up to OPEN_MAX FD's. mmap()ped objects then get extra reference in the invisible range so user processes can't close them. The in-vfs fd_set is of size FDS_PER_PROCESS. . On exec() time, try to mmap() in the executable if available. (It is not yet available in this commit.) . To support mmap(), add do_vm_call that allows VM to lookup (to ino+dev), do i/o from and close FD's on behalf of other processes. . To make this possible, a few functions have 2 more arguments to make the target process explicit (instead of the implicit global fp) and to specify whether the request is from a user process or the system (which implies whether FD's starting at OPEN_MAX are valid). These are close_fd, common_open, actual_llseek, actual_read_write_peek, get_fd and get_filp2. Change-Id: I831551e45a6781c74313c450eb9c967a68505932
40 lines
1.2 KiB
C
40 lines
1.2 KiB
C
#ifndef __PFS_INODE_H__
|
|
#define __PFS_INODE_H__
|
|
|
|
/* Inode table. This table holds inodes that are currently in use.
|
|
*/
|
|
|
|
#include <sys/queue.h>
|
|
|
|
EXTERN struct inode {
|
|
mode_t i_mode; /* file type, protection, etc. */
|
|
nlink_t i_nlinks; /* how many links to this file */
|
|
uid_t i_uid; /* user id of the file's owner */
|
|
gid_t i_gid; /* group number */
|
|
off_t i_size; /* current file size in bytes */
|
|
time_t i_atime; /* time of last access (V2 only) */
|
|
time_t i_mtime; /* when was file data last changed */
|
|
time_t i_ctime; /* when was inode itself changed (V2 only)*/
|
|
|
|
/* The following items are not present on the disk. */
|
|
dev_t i_dev; /* which device is the inode on */
|
|
dev_t i_rdev; /* which special device is the inode on */
|
|
ino_t i_num; /* inode number on its (minor) device */
|
|
int i_count; /* # times inode used; 0 means slot is free */
|
|
char i_update; /* the ATIME, CTIME, and MTIME bits are here */
|
|
|
|
LIST_ENTRY(inode) i_hash; /* hash list */
|
|
TAILQ_ENTRY(inode) i_unused; /* free and unused list */
|
|
|
|
|
|
} inode[PFS_NR_INODES];
|
|
|
|
/* list of unused/free inodes */
|
|
EXTERN TAILQ_HEAD(unused_inodes_t, inode) unused_inodes;
|
|
|
|
/* inode hashtable */
|
|
EXTERN LIST_HEAD(inodelist, inode) hash_inodes[INODE_HASH_SIZE];
|
|
|
|
|
|
#endif
|