Clean up PFS

This commit is contained in:
Thomas Veerman 2010-05-28 09:39:18 +00:00
parent 8d06457241
commit 5d78cefaf2
22 changed files with 97 additions and 177 deletions

View file

@ -157,6 +157,7 @@
#define NO_ENTRY ((ino_t) 0) /* absence of a dir entry */
#define NO_ZONE ((zone_t) 0) /* absence of a zone number */
#define NO_DEV ((dev_t) 0) /* absence of a device numb */
#define NO_LINK ((nlink_t) 0) /* absence of incoming links */
#define SERVARNAME "cttyline"

View file

@ -34,7 +34,7 @@ typedef struct {
/* some Minix specific types that do not conflict with posix */
typedef u32_t zone_t; /* zone number */
typedef u32_t block_t; /* block number */
typedef u32_t bit_t; /* bit number in a bit map */
typedef u32_t bit_t; /* bit number in a bit map */
typedef u16_t zone1_t; /* zone number for V1 file systems */
typedef u16_t bitchunk_t; /* collection of bits in a bitmap */

View file

@ -14,7 +14,7 @@ struct stat {
dev_t st_dev; /* major/minor device number */
ino_t st_ino; /* i-node number */
mode_t st_mode; /* file mode, protection bits, etc. */
short int st_nlink; /* # links; TEMPORARY HACK: should be nlink_t*/
nlink_t st_nlink; /* # links; */
uid_t st_uid; /* uid of the file's owner */
short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */
dev_t st_rdev;

View file

@ -11,7 +11,4 @@ MAN=
BINDIR?= /usr/sbin
INSTALLFLAGS+= -S 128k
NR_BUFS= 256
CPPFLAGS+= -DNR_BUFS=${NR_BUFS}
.include <minix.prog.mk>

View file

@ -1,3 +1,6 @@
#ifndef __PFS_BUF_H__
#define __PFS_BUF_H__
/* Buffer (block) cache.
*/
@ -17,9 +20,7 @@ struct buf {
/* A block is free if b_dev == NO_DEV. */
#define BUFHASH(b) ((b) % NR_BUFS)
EXTERN struct buf *front; /* points to least recently used free block */
EXTERN struct buf *rear; /* points to most recently used free block */
EXTERN int bufs_in_use; /* # bufs currently in use (not on free list)*/
#endif

View file

@ -3,9 +3,9 @@
#include "inode.h"
#include <sys/types.h>
#include <stdlib.h>
#include <alloca.h>
#include <string.h>
FORWARD _PROTOTYPE( struct buf *new_block, (dev_t dev, ino_t inum) );
/*===========================================================================*
* buf_pool *
@ -43,7 +43,7 @@ PUBLIC struct buf *get_block(dev_t dev, ino_t inum)
/*===========================================================================*
* new_block *
*===========================================================================*/
PUBLIC struct buf *new_block(dev_t dev, ino_t inum)
PRIVATE struct buf *new_block(dev_t dev, ino_t inum)
{
/* Allocate a new buffer and add it to the double linked buffer list */
struct buf *bp;

View file

@ -1,16 +1,11 @@
/* Tables sizes */
#define V1_NR_DZONES 7 /* # direct zone numbers in a V1 inode */
#define V1_NR_TZONES 9 /* total # zone numbers in a V1 inode */
#define V2_NR_DZONES 7 /* # direct zone numbers in a V2 inode */
#define V2_NR_TZONES 10 /* total # zone numbers in a V2 inode */
#ifndef __PFS_CONST_H__
#define __PFS_CONST_H__
#define NR_INODES 256 /* # slots in "in core" inode table */
#define GETDENTS_BUFSIZ 257
#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)
#define INODE_MAP_SIZE INODE_HASH_LOG2
/* The type of sizeof may be (unsigned) long. Use the following macro for
@ -19,79 +14,22 @@
*/
#define usizeof(t) ((unsigned) sizeof(t))
/* File system types. */
#define SUPER_MAGIC 0x137F /* magic number contained in super-block */
#define SUPER_REV 0x7F13 /* magic # when 68000 disk read on PC or vv */
#define SUPER_V2 0x2468 /* magic # for V2 file systems */
#define SUPER_V2_REV 0x6824 /* V2 magic written on PC, read on 68K or vv */
#define SUPER_V3 0x4d5a /* magic # for V3 file systems */
#define V1 1 /* version number of V1 file systems */
#define V2 2 /* version number of V2 file systems */
#define V3 3 /* version number of V3 file systems */
/* Miscellaneous constants */
#define SU_UID ((uid_t) 0) /* super_user's uid_t */
#define SYS_UID ((uid_t) 0) /* uid_t for processes MM and INIT */
#define SYS_GID ((gid_t) 0) /* gid_t for processes MM and INIT */
#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 */
/* write_map() args */
#define WMAP_FREE (1 << 0)
#define IGN_PERM 0
#define CHK_PERM 1
#define CLEAN 0 /* disk and memory copies identical */
#define DIRTY 1 /* disk and memory copies differ */
#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 BYTE_SWAP 0 /* tells conv2/conv4 to swap bytes */
#define END_OF_FILE (-104) /* eof detected */
#define ROOT_INODE 1 /* inode number for root directory */
#define BOOT_BLOCK ((block_t) 0) /* block number of boot block */
#define SUPER_BLOCK_BYTES (1024) /* bytes offset */
#define START_BLOCK 2 /* first block of FS (not counting SB) */
#define DIR_ENTRY_SIZE usizeof (struct direct) /* # bytes/dir entry */
#define NR_DIR_ENTRIES(b) ((b)/DIR_ENTRY_SIZE) /* # dir entries/blk */
#define SUPER_SIZE usizeof (struct super_block) /* super_block size */
#define PIPE_SIZE(b) (V1_NR_DZONES*(b)) /* pipe size in bytes */
#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)
/* Derived sizes pertaining to the V1 file system. */
#define V1_ZONE_NUM_SIZE usizeof (zone1_t) /* # bytes in V1 zone */
#define V1_INODE_SIZE usizeof (d1_inode) /* bytes in V1 dsk ino */
/* # zones/indir block */
#define V1_INDIRECTS (_STATIC_BLOCK_SIZE/V1_ZONE_NUM_SIZE)
/* # V1 dsk inodes/blk */
#define V1_INODES_PER_BLOCK (_STATIC_BLOCK_SIZE/V1_INODE_SIZE)
/* Derived sizes pertaining to the V2 file system. */
#define V2_ZONE_NUM_SIZE usizeof (zone_t) /* # bytes in V2 zone */
#define V2_INODE_SIZE usizeof (d2_inode) /* bytes in V2 dsk ino */
#define V2_INDIRECTS(b) ((b)/V2_ZONE_NUM_SIZE) /* # zones/indir block */
#define V2_INODES_PER_BLOCK(b) ((b)/V2_INODE_SIZE)/* # V2 dsk inodes/blk */
#define PFS_MIN(a,b) pfs_min_f(__FILE__,__LINE__,(a), (b))
#define PFS_NUL(str,l,m) pfs_nul_f(__FILE__,__LINE__,(str), (l), (m))
/* Args to dev_bio/dev_io */
#define PFS_DEV_READ 10001
#define PFS_DEV_WRITE 10002
#define PFS_DEV_SCATTER 10003
#define PFS_DEV_GATHER 10004
#endif

View file

@ -1,9 +0,0 @@
/* Driver endpoints for major devices. Only the block devices
* are mapped here, it's a subset of the mapping in the VFS */
EXTERN struct driver_endpoints {
endpoint_t driver_e;
} driver_endpoints[NR_DEVICES];

View file

@ -1,3 +1,6 @@
#ifndef __PFS_FS_H__
#define __PFS_FS_H__
/* This is the master header for pfs. It includes some other files
* and defines the principal constants.
*/
@ -5,8 +8,6 @@
#define _MINIX 1 /* tell headers to include MINIX stuff */
#define _SYSTEM 1 /* tell headers that this is the kernel */
#define VERBOSE 0 /* show messages during initialization? */
/* The following are so basic, all the *.c files get them automatically. */
#include <minix/config.h> /* MUST be first */
#include <ansi.h> /* MUST be second */
@ -25,3 +26,5 @@
#include "const.h"
#include "proto.h"
#include "glo.h"
#endif

View file

@ -1,3 +1,6 @@
#ifndef __PFS_GLO_H__
#define __PFS_GLO_H__
/* EXTERN should be extern except for the table file */
#ifdef _TABLE
#undef EXTERN
@ -9,9 +12,7 @@
/* The following variables are used for returning results to the caller. */
EXTERN int err_code; /* temporary storage for error number */
EXTERN int cch[NR_INODES];
extern _PROTOTYPE (int (*fs_call_vec[]), (void) ); /* fs call table */
EXTERN _PROTOTYPE (int (*fs_call_vec[]), (void) ); /* fs call table */
EXTERN message fs_m_in;
EXTERN message fs_m_out;
@ -25,3 +26,5 @@ EXTERN int busy;
/* Inode map. */
EXTERN bitchunk_t inodemap[FS_BITMAP_CHUNKS(NR_INODES)];
#endif

View file

@ -19,8 +19,8 @@
#include "inode.h"
#include <minix/vfsif.h>
FORWARD _PROTOTYPE( int addhash_inode, (struct inode *node) );
FORWARD _PROTOTYPE( int unhash_inode, (struct inode *node) );
FORWARD _PROTOTYPE( void addhash_inode, (struct inode * const node) );
FORWARD _PROTOTYPE( void unhash_inode, (struct inode * const node) );
/*===========================================================================*
@ -35,11 +35,11 @@ PUBLIC int fs_putnode()
dev_t dev;
ino_t inum;
rip = find_inode(fs_m_in.REQ_INODE_NR);
rip = find_inode( (ino_t) fs_m_in.REQ_INODE_NR);
if(!rip) {
printf("%s:%d put_inode: inode #%d dev: %d not found\n", __FILE__,
__LINE__, fs_m_in.REQ_INODE_NR, fs_m_in.REQ_DEV);
printf("%s:%d put_inode: inode #%ld dev: %d not found\n", __FILE__,
__LINE__, fs_m_in.REQ_INODE_NR, (dev_t) fs_m_in.REQ_DEV);
panic("fs_putnode failed");
}
@ -82,7 +82,7 @@ PUBLIC void init_inode_cache()
/* add free inodes to unused/free list */
for (rip = &inode[0]; rip < &inode[NR_INODES]; ++rip) {
rip->i_num = 0;
rip->i_num = NO_ENTRY;
TAILQ_INSERT_HEAD(&unused_inodes, rip, i_unused);
}
@ -95,24 +95,22 @@ PUBLIC void init_inode_cache()
/*===========================================================================*
* addhash_inode *
*===========================================================================*/
PRIVATE int addhash_inode(struct inode *node)
PRIVATE void addhash_inode(struct inode * const node)
{
int hashi = node->i_num & INODE_HASH_MASK;
int hashi = (int) (node->i_num & INODE_HASH_MASK);
/* insert into hash table */
LIST_INSERT_HEAD(&hash_inodes[hashi], node, i_hash);
return(OK);
}
/*===========================================================================*
* unhash_inode *
*===========================================================================*/
PRIVATE int unhash_inode(struct inode *node)
PRIVATE void unhash_inode(struct inode * const node)
{
/* remove from hash table */
LIST_REMOVE(node, i_hash);
return(OK);
}
@ -121,7 +119,7 @@ PRIVATE int unhash_inode(struct inode *node)
*===========================================================================*/
PUBLIC struct inode *get_inode(
dev_t dev, /* device on which inode resides */
int numb /* inode number (ANSI: may not be unshort) */
ino_t numb /* inode number */
)
{
/* Find the inode in the hash table. If it is not there, get a free inode
@ -130,7 +128,7 @@ PUBLIC struct inode *get_inode(
register struct inode *rip;
int hashi;
hashi = numb & INODE_HASH_MASK;
hashi = (int) (numb & INODE_HASH_MASK);
/* Search inode in the hash table */
LIST_FOREACH(rip, &hash_inodes[hashi], i_hash) {
@ -153,7 +151,7 @@ PUBLIC struct inode *get_inode(
rip = TAILQ_FIRST(&unused_inodes);
/* If not free unhash it */
if (rip->i_num != 0) unhash_inode(rip);
if (rip->i_num != NO_ENTRY) unhash_inode(rip);
/* Inode is not unused any more */
TAILQ_REMOVE(&unused_inodes, rip, i_unused);
@ -176,14 +174,14 @@ PUBLIC struct inode *get_inode(
* find_inode *
*===========================================================================*/
PUBLIC struct inode *find_inode(numb)
int numb; /* inode number (ANSI: may not be unshort) */
ino_t numb; /* inode number */
{
/* Find the inode specified by the inode and device number.
*/
struct inode *rip;
int hashi;
hashi = numb & INODE_HASH_MASK;
hashi = (int) (numb & INODE_HASH_MASK);
/* Search inode in the hash table */
LIST_FOREACH(rip, &hash_inodes[hashi], i_hash) {
@ -200,7 +198,7 @@ int numb; /* inode number (ANSI: may not be unshort) */
* put_inode *
*===========================================================================*/
PUBLIC void put_inode(rip)
register struct inode *rip; /* pointer to inode to be released */
struct inode *rip; /* pointer to inode to be released */
{
/* The caller is no longer using this inode. If no one else is using it either
* write it back to the disk immediately. If it has no links, truncate it and
@ -213,19 +211,19 @@ register struct inode *rip; /* pointer to inode to be released */
panic("put_inode: i_count already below 1: %d", rip->i_count);
if (--rip->i_count == 0) { /* i_count == 0 means no one is using it now */
if (rip->i_nlinks == 0) {
/* i_nlinks == 0 means free the inode. */
if (rip->i_nlinks == NO_LINK) { /* Are there links to this file? */
/* no links, free the inode. */
truncate_inode(rip, 0); /* return all the disk blocks */
rip->i_mode = I_NOT_ALLOC; /* clear I_TYPE field */
free_inode(rip);
} else {
truncate_inode(rip, 0);
truncate_inode(rip, (off_t) 0);
}
if (rip->i_nlinks == 0) {
if (rip->i_nlinks == NO_LINK) {
/* free, put at the front of the LRU list */
unhash_inode(rip);
rip->i_num = 0;
rip->i_num = NO_ENTRY;
rip->i_dev = NO_DEV;
rip->i_rdev = NO_DEV;
TAILQ_INSERT_HEAD(&unused_inodes, rip, i_unused);
@ -265,7 +263,7 @@ PUBLIC struct inode *alloc_inode(dev_t dev, mode_t bits)
/* An inode slot is available. */
rip->i_mode = bits; /* set up RWX bits */
rip->i_nlinks = 0; /* initial no links */
rip->i_nlinks = NO_LINK; /* initial no links */
rip->i_uid = caller_uid; /* file's uid is owner's */
rip->i_gid = caller_gid; /* ditto group id */
@ -285,7 +283,7 @@ PUBLIC struct inode *alloc_inode(dev_t dev, mode_t bits)
* wipe_inode *
*===========================================================================*/
PUBLIC void wipe_inode(rip)
register struct inode *rip; /* the inode to be erased */
struct inode *rip; /* the inode to be erased */
{
/* Erase some fields in the inode. This function is called from alloc_inode()
* when a new inode is to be allocated, and from truncate(), when an existing
@ -307,8 +305,8 @@ struct inode *rip;
bit_t b;
if (rip->i_num <= 0 || rip->i_num >= NR_INODES) return;
b = rip->i_num;
if (rip->i_num <= (ino_t) 0 || rip->i_num >= (ino_t) NR_INODES) return;
b = (bit_t) rip->i_num;
free_bit(b);
}
@ -317,7 +315,7 @@ struct inode *rip;
* update_times *
*===========================================================================*/
PUBLIC void update_times(rip)
register struct inode *rip; /* pointer to inode to be read/written */
struct inode *rip; /* pointer to inode to be read/written */
{
/* Various system calls are required by the standard to update atime, ctime,
* or mtime. Since updating a time requires sending a message to the clock

View file

@ -1,3 +1,6 @@
#ifndef __PFS_INODE_H__
#define __PFS_INODE_H__
/* Inode table. This table holds inodes that are currently in use.
*/
@ -33,3 +36,4 @@ EXTERN TAILQ_HEAD(unused_inodes_t, inode) unused_inodes;
EXTERN LIST_HEAD(inodelist, inode) hash_inodes[INODE_HASH_SIZE];
#endif

View file

@ -1,5 +1,4 @@
#include "fs.h"
#include <string.h>
#include "buf.h"
#include "inode.h"
#include <minix/vfsif.h>
@ -13,7 +12,7 @@ PUBLIC int fs_ftrunc(void)
off_t start, end;
ino_t inumb;
inumb = fs_m_in.REQ_INODE_NR;
inumb = (ino_t) fs_m_in.REQ_INODE_NR;
if( (rip = find_inode(inumb)) == NULL) return(EINVAL);

View file

@ -6,7 +6,6 @@
#include <minix/vfsif.h>
#include "buf.h"
#include "inode.h"
#include "drivers.h"
FORWARD _PROTOTYPE(void get_work, (message *m_in) );
@ -38,19 +37,19 @@ PUBLIC int main(int argc, char *argv[])
src = fs_m_in.m_source;
error = OK;
caller_uid = -1; /* To trap errors */
caller_gid = -1;
caller_uid = INVAL_UID; /* To trap errors */
caller_gid = INVAL_GID;
req_nr = fs_m_in.m_type;
if (req_nr < VFS_BASE) {
fs_m_in.m_type += VFS_BASE;
req_nr = fs_m_in.m_type;
printf("PFS: bad request (no VFS_BASE) %d\n", req_nr);
}
ind = req_nr - VFS_BASE;
if (ind < 0 || ind >= NREQS) {
printf("pfs: bad request %d\n", req_nr);
printf("ind = %d\n", ind);
error = EINVAL;
} else {
error = (*fs_call_vec[ind])();
@ -96,15 +95,10 @@ PRIVATE int sef_cb_init_fresh(int type, sef_init_info_t *info)
/* Init inode table */
for (i = 0; i < NR_INODES; ++i) {
inode[i].i_count = 0;
cch[i] = 0;
}
init_inode_cache();
/* Init driver mapping */
for (i = 0; i < NR_DEVICES; ++i)
driver_endpoints[i].driver_e = NONE;
SELF_E = getprocnr();
buf_pool();
@ -148,7 +142,7 @@ message *m_in; /* pointer to message */
* reply *
*===========================================================================*/
PUBLIC void reply(who, m_out)
int who;
endpoint_t who;
message *m_out; /* report result */
{
if (OK != send(who, m_out)) /* send the message */

View file

@ -1,8 +1,4 @@
#include "fs.h"
#include <fcntl.h>
#include <minix/vfsif.h>
#include "buf.h"
#include "inode.h"
/*===========================================================================*

View file

@ -1,8 +1,5 @@
#include "fs.h"
#include <sys/stat.h>
#include <unistd.h>
#include <minix/callnr.h>
#include <minix/com.h>
#include "buf.h"
#include "inode.h"
#include <minix/vfsif.h>
@ -18,10 +15,10 @@ PUBLIC int fs_newnode()
struct inode *rip;
dev_t dev;
caller_uid = fs_m_in.REQ_UID;
caller_gid = fs_m_in.REQ_GID;
bits = fs_m_in.REQ_MODE;
dev = fs_m_in.REQ_DEV;
caller_uid = (uid_t) fs_m_in.REQ_UID;
caller_gid = (gid_t) fs_m_in.REQ_GID;
bits = (mode_t) fs_m_in.REQ_MODE;
dev = (dev_t) fs_m_in.REQ_DEV;
/* Try to allocate the inode */
if( (rip = alloc_inode(dev, bits) ) == NULL) return(err_code);

View file

@ -1,13 +1,14 @@
#ifndef __PFS_PROTO_H__
#define __PFS_PROTO_H__
/* Function prototypes. */
/* Structs used in prototypes must be declared as such first. */
struct buf;
struct filp;
struct inode;
/* buffer.c */
_PROTOTYPE( struct buf *get_block, (dev_t dev, ino_t inum) );
_PROTOTYPE( struct buf *new_block, (dev_t dev, ino_t inum) );
_PROTOTYPE( void put_block, (dev_t dev, ino_t inum) );
/* cache.c */
@ -16,11 +17,11 @@ _PROTOTYPE( void buf_pool, (void) );
/* inode.c */
_PROTOTYPE( struct inode *alloc_inode, (dev_t dev, mode_t mode) );
_PROTOTYPE( void dup_inode, (struct inode *ip) );
_PROTOTYPE( struct inode *find_inode, (int numb) );
_PROTOTYPE( struct inode *find_inode, (ino_t numb) );
_PROTOTYPE( void free_inode, (struct inode *rip) );
_PROTOTYPE( int fs_putnode, (void) );
_PROTOTYPE( void init_inode_cache, (void) );
_PROTOTYPE( struct inode *get_inode, (dev_t dev, int numb) );
_PROTOTYPE( struct inode *get_inode, (dev_t dev, ino_t numb) );
_PROTOTYPE( void put_inode, (struct inode *rip) );
_PROTOTYPE( void update_times, (struct inode *rip) );
_PROTOTYPE( void wipe_inode, (struct inode *rip) );
@ -31,7 +32,7 @@ _PROTOTYPE( int truncate_inode, (struct inode *rip, off_t newsize) );
/* main.c */
_PROTOTYPE( void reply, (int who, message *m_out) );
_PROTOTYPE( void reply, (endpoint_t who, message *m_out) );
/* misc.c */
_PROTOTYPE( int fs_sync, (void) );
@ -41,8 +42,6 @@ _PROTOTYPE( int fs_newnode, (void) );
/* read.c */
_PROTOTYPE( int fs_readwrite, (void) );
_PROTOTYPE( block_t read_map, (struct inode *rip, off_t pos) );
_PROTOTYPE( int read_write, (int rw_flag) );
/* utility.c */
_PROTOTYPE( time_t clock_time, (void) );
@ -54,3 +53,5 @@ _PROTOTYPE( int fs_stat, (void) );
/* super.c */
_PROTOTYPE( bit_t alloc_bit, (void) );
_PROTOTYPE( void free_bit, (bit_t bit_returned) );
#endif

View file

@ -1,8 +1,6 @@
#include "fs.h"
#include "buf.h"
#include <minix/com.h>
#include <string.h>
#include <minix/u64.h>
#include "inode.h"
@ -22,8 +20,7 @@ PUBLIC int fs_readwrite(void)
r = OK;
cum_io = 0;
inumb = fs_m_in.REQ_INODE_NR;
rw_flag = (fs_m_in.m_type == REQ_READ ? READING : WRITING);
inumb = (ino_t) fs_m_in.REQ_INODE_NR;
/* Find the inode referred */
if ((rip = find_inode(inumb)) == NULL) return(EINVAL);
@ -34,13 +31,18 @@ PUBLIC int fs_readwrite(void)
/* Get the values from the request message */
rw_flag = (fs_m_in.m_type == REQ_READ ? READING : WRITING);
gid = fs_m_in.REQ_GRANT;
gid = (cp_grant_id_t) fs_m_in.REQ_GRANT;
position = fs_m_in.REQ_SEEK_POS_LO;
nrbytes = (unsigned) fs_m_in.REQ_NBYTES;
/* We can't read beyond the max file position */
if (nrbytes > MAX_FILE_POS) return(EFBIG);
if (rw_flag == WRITING) {
/* Check in advance to see if file will grow too big. */
if (position > PIPE_BUF - nrbytes) return(EFBIG);
/* Casting nrbytes to signed is safe, because it's guaranteed not to
be beyond max signed value (i.e., MAX_FILE_POS). */
if (position > PIPE_BUF - (signed) nrbytes) return(EFBIG);
}
/* Mark inode in use */
@ -49,16 +51,16 @@ PUBLIC int fs_readwrite(void)
if (rw_flag == READING) {
/* Copy a chunk from the block buffer to user space. */
r = sys_safecopyto(FS_PROC_NR, gid, 0,
(vir_bytes) (bp->b_data+position), (phys_bytes) nrbytes, D);
r = sys_safecopyto(FS_PROC_NR, gid, (vir_bytes) 0,
(vir_bytes) (bp->b_data+position), (size_t) nrbytes, D);
} else {
/* Copy a chunk from user space to the block buffer. */
r = sys_safecopyfrom(FS_PROC_NR, gid, 0,
(vir_bytes) (bp->b_data+position), (phys_bytes) nrbytes, D);
r = sys_safecopyfrom(FS_PROC_NR, gid, (vir_bytes) 0,
(vir_bytes) (bp->b_data+position), (size_t) nrbytes, D);
}
if (r == OK) {
position += nrbytes; /* Update position */
position += (signed) nrbytes; /* Update position */
cum_io += nrbytes;
}
@ -79,7 +81,7 @@ PUBLIC int fs_readwrite(void)
bp->b_bytes = position;
if (rw_flag == READING) rip->i_update |= ATIME;
if (rw_flag == WRITING) rip->i_update |= CTIME | MTIME;
fs_m_out.RES_NBYTES = cum_io;
fs_m_out.RES_NBYTES = (size_t) cum_io;
put_inode(rip);
put_block(rip->i_dev, rip->i_num);

View file

@ -28,7 +28,7 @@ PRIVATE int stat_inode(
statbuf.st_mode = rip->i_mode;
statbuf.st_nlink = rip->i_nlinks;
statbuf.st_uid = rip->i_uid;
statbuf.st_gid = rip->i_gid;
statbuf.st_gid = (short int) rip->i_gid;
statbuf.st_rdev = (dev_t) (s ? rip->i_rdev : NO_DEV);
statbuf.st_size = rip->i_size;
if (!s) statbuf.st_mode &= ~I_REGULAR;/* wipe out I_REGULAR bit for pipes */
@ -37,8 +37,8 @@ PRIVATE int stat_inode(
statbuf.st_ctime = rip->i_ctime;
/* Copy the struct to user space. */
r = sys_safecopyto(who_e, gid, 0, (vir_bytes) &statbuf,
(phys_bytes) sizeof(statbuf), D);
r = sys_safecopyto(who_e, gid, (vir_bytes) 0, (vir_bytes) &statbuf,
(size_t) sizeof(statbuf), D);
return(r);
}
@ -54,7 +54,7 @@ PUBLIC int fs_stat()
if( (rip = find_inode(fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL);
get_inode(rip->i_dev, rip->i_num); /* mark inode in use */
r = stat_inode(rip, fs_m_in.m_source, fs_m_in.REQ_GRANT);
r = stat_inode(rip, fs_m_in.m_source, (cp_grant_id_t) fs_m_in.REQ_GRANT);
put_inode(rip); /* release the inode */
return(r);
}

View file

@ -9,9 +9,6 @@
*/
#include "fs.h"
#include <string.h>
#include <minix/com.h>
#include <minix/u64.h>
#include "buf.h"
#include "inode.h"
#include "const.h"
@ -25,7 +22,7 @@ PUBLIC bit_t alloc_bit(void)
/* Allocate a bit from a bit map and return its bit number. */
bitchunk_t *wptr, *wlim;
bit_t b;
int i, bcount;
unsigned int i, bcount;
bcount = FS_BITMAP_CHUNKS(NR_INODES); /* Inode map has this many chunks. */
wlim = &inodemap[bcount]; /* Point to last chunk in inodemap. */
@ -38,7 +35,7 @@ PUBLIC bit_t alloc_bit(void)
for (i = 0; (*wptr & (1 << i)) != 0; ++i) {}
/* Get inode number */
b = (wptr - &inodemap[0]) * FS_BITCHUNK_BITS + i;
b = (bit_t) ((wptr - &inodemap[0]) * FS_BITCHUNK_BITS + i);
/* Don't allocate bits beyond end of map. */
if (b >= NR_INODES) break;
@ -66,12 +63,12 @@ bit_t bit_returned; /* number of bit to insert into the inode map*/
unsigned word;
/* Get word offset and bit within offset */
word = bit_returned / FS_BITCHUNK_BITS;
bit = bit_returned % FS_BITCHUNK_BITS;
word = (unsigned) (bit_returned / (bit_t) FS_BITCHUNK_BITS);
bit = bit_returned % (bit_t) FS_BITCHUNK_BITS;
/* Unset bit */
k = &inodemap[word];
mask = 1 << bit;
mask = (unsigned) 1 << bit;
*k &= ~mask;
busy--; /* One inode less in use. */

View file

@ -6,11 +6,8 @@
#define _TABLE
#include "fs.h"
#include <minix/callnr.h>
#include <minix/com.h>
#include "inode.h"
#include "buf.h"
#include "drivers.h"
PUBLIC _PROTOTYPE (int (*fs_call_vec[]), (void) ) = {
no_sys, /* 0 not used */

View file

@ -23,9 +23,10 @@ PUBLIC time_t clock_time()
*/
int r;
clock_t uptime, boottime;
clock_t uptime; /* Uptime in ticks */
time_t boottime;
if ((r = getuptime2(&uptime,&boottime)) != OK)
if ((r = getuptime2(&uptime, &boottime)) != OK)
panic("clock_time: getuptme2 failed: %d", r);
return( (time_t) (boottime + (uptime/sys_hz())));