. 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
43 lines
1.6 KiB
C
43 lines
1.6 KiB
C
#ifndef __PFS_CONST_H__
|
|
#define __PFS_CONST_H__
|
|
|
|
#define PFS_NR_INODES 512 /* # slots in "in core" inode table */
|
|
|
|
/* Size of descriptor table for unix domain sockets. This should be
|
|
* equal to the maximum number of minor devices (currently 256).
|
|
*/
|
|
#define NR_FDS 256
|
|
|
|
#define INODE_HASH_LOG2 7 /* 2 based logarithm of the inode hash size */
|
|
#define INODE_HASH_SIZE ((unsigned long)1<<INODE_HASH_LOG2)
|
|
#define INODE_HASH_MASK (((unsigned long)1<<INODE_HASH_LOG2)-1)
|
|
|
|
|
|
/* The type of sizeof may be (unsigned) long. Use the following macro for
|
|
* taking the sizes of small objects so that there are no surprises like
|
|
* (small) long constants being passed to routines expecting an int.
|
|
*/
|
|
#define usizeof(t) ((unsigned) sizeof(t))
|
|
|
|
/* Miscellaneous constants */
|
|
#define INVAL_UID ((uid_t) -1) /* Invalid user ID */
|
|
#define INVAL_GID ((gid_t) -1) /* Invalid group ID */
|
|
#define NORMAL 0 /* forces get_block to do disk read */
|
|
#define NO_READ 1 /* prevents get_block from doing disk read */
|
|
#define PREFETCH 2 /* tells get_block not to read or mark dev */
|
|
|
|
#define NO_BIT ((bit_t) 0) /* returned by alloc_bit() to signal failure */
|
|
|
|
#define ATIME 002 /* set if atime field needs updating */
|
|
#define CTIME 004 /* set if ctime field needs updating */
|
|
#define MTIME 010 /* set if mtime field needs updating */
|
|
|
|
#define FS_BITMAP_CHUNKS(b) ((b)/usizeof (bitchunk_t))/* # map chunks/blk */
|
|
#define FS_BITCHUNK_BITS (usizeof(bitchunk_t) * CHAR_BIT)
|
|
#define FS_BITS_PER_BLOCK(b) (FS_BITMAP_CHUNKS(b) * FS_BITCHUNK_BITS)
|
|
|
|
#define FS_CALL_VEC_SIZE 31
|
|
#define DEV_CALL_VEC_SIZE 25
|
|
|
|
#endif
|