size_t and void*-arithmetic changes from sys/libsa/ufs.c.

This commit is contained in:
jonathan 1999-02-01 03:08:05 +00:00
parent 45f13be5cb
commit 9ec88780aa
1 changed files with 35 additions and 28 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs.c,v 1.4 1999/01/29 05:37:48 simonb Exp $ */
/* $NetBSD: ufs.c,v 1.5 1999/02/01 03:08:05 jonathan Exp $ */
/*-
* Copyright (c) 1993
@ -62,23 +62,25 @@
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*
* $Id: ufs.c,v 1.4 1999/01/29 05:37:48 simonb Exp $
*/
/*
* Stand-alone file reading package.
*/
#define bcopy(s, d, l) memcpy(d, s, l) /*XXX none of our copies overlap */
#include <string.h>
#include <sys/param.h>
#include <sys/time.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>
#include <ufs/ffs/fs.h>
#ifdef _STANDALONE
#include <lib/libkern/libkern.h>
#include <stand.h>
#endif
#include <machine/dec_prom.h>
/*
@ -93,16 +95,20 @@ struct file {
indirect block at level i */
char *f_blk[NIADDR]; /* buffer for indirect block at
level i */
u_long f_blksize[NIADDR];
size_t f_blksize[NIADDR];
/* size of buffer */
daddr_t f_blkno[NIADDR];/* disk address of block in buffer */
char *f_buf; /* buffer for data block */
u_int f_buf_size; /* size of data block */
size_t f_buf_size; /* size of data block */
daddr_t f_buf_blkno; /* block number of data block */
};
static int read_inode __P((ino_t, struct open_file *));
static int block_map __P((struct open_file *, daddr_t, daddr_t *));
static int buf_read_file __P((struct open_file *, char **, size_t *));
static int search_directory __P((char *, struct open_file *, ino_t *));
#ifdef COMPAT_UFS
void ffs_oldfscompat __P((struct fs *));
static void ffs_oldfscompat __P((struct fs *));
#endif
/*
@ -116,7 +122,7 @@ read_inode(inumber, f)
register struct file *fp = (struct file *)f->f_fsdata;
register struct fs *fs = fp->f_fs;
char *buf;
u_int rsize;
size_t rsize;
int rc;
#ifdef DEBUG
@ -128,7 +134,8 @@ read_inode(inumber, f)
*/
buf = alloc(fs->fs_bsize);
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
fsbtodb(fs, ino_to_fsba(fs, inumber)), fs->fs_bsize, buf, &rsize);
fsbtodb(fs, ino_to_fsba(fs, inumber)), fs->fs_bsize,
buf, &rsize);
if (rc)
goto out;
if (rsize != fs->fs_bsize) {
@ -155,7 +162,7 @@ read_inode(inumber, f)
}
out:
free(buf, fs->fs_bsize);
return (0);
return (rc);
}
/*
@ -242,7 +249,7 @@ block_map(f, file_block, disk_block_p)
fsbtodb(fp->f_fs, ind_block_num),
fs->fs_bsize,
fp->f_blk[level],
(u_int *)&fp->f_blksize[level]);
&fp->f_blksize[level]);
if (rc)
return (rc);
if (fp->f_blksize[level] != fs->fs_bsize)
@ -274,14 +281,14 @@ static int
buf_read_file(f, buf_p, size_p)
struct open_file *f;
char **buf_p; /* out */
u_int *size_p; /* out */
size_t *size_p; /* out */
{
register struct file *fp = (struct file *)f->f_fsdata;
register struct fs *fs = fp->f_fs;
long off;
register daddr_t file_block;
daddr_t disk_block;
long block_size;
size_t block_size;
int rc;
off = blkoff(fs, fp->f_seekp);
@ -345,7 +352,7 @@ search_directory(name, f, inumber_p)
register struct direct *dp;
struct direct *edp;
char *buf;
u_int buf_size;
size_t buf_size;
int namlen, length;
int rc;
@ -396,7 +403,7 @@ ufs_open(path, f)
struct file *fp;
struct fs *fs;
int rc;
u_int buf_size;
size_t buf_size;
#if 0
int nlinks = 0;
char namebuf[MAXPATHLEN+1];
@ -420,7 +427,6 @@ ufs_open(path, f)
rc = EINVAL;
goto out;
}
#ifdef COMPAT_UFS
ffs_oldfscompat(fs);
#endif
@ -521,7 +527,7 @@ ufs_open(path, f)
* Read file for symbolic link
*/
char *buf;
u_int buf_size;
size_t buf_size;
daddr_t disk_block;
register struct fs *fs = fp->f_fs;
@ -594,15 +600,16 @@ ufs_close(f)
int
ufs_read(f, start, size, resid)
struct open_file *f;
char *start;
u_int size;
u_int *resid; /* out */
void *start;
size_t size;
size_t *resid; /* out */
{
register struct file *fp = (struct file *)f->f_fsdata;
register u_int csize;
register size_t csize;
char *buf;
u_int buf_size;
size_t buf_size;
int rc = 0;
register char *addr = start;
while (size != 0) {
if (fp->f_seekp >= fp->f_di.di_size)
@ -616,10 +623,10 @@ ufs_read(f, start, size, resid)
if (csize > buf_size)
csize = buf_size;
bcopy(buf, start, csize);
bcopy(buf, addr, csize);
fp->f_seekp += csize;
start += csize;
addr += csize;
size -= csize;
}
if (resid)
@ -634,9 +641,9 @@ ufs_read(f, start, size, resid)
int
ufs_write(f, start, size, resid)
struct open_file *f;
char *start;
u_int size;
u_int *resid; /* out */
void *start;
size_t size;
size_t *resid; /* out */
{
return (EROFS);
@ -688,7 +695,7 @@ ufs_stat(f, sb)
*
* XXX - goes away some day.
*/
void
static void
ffs_oldfscompat(fs)
struct fs *fs;
{