summaryrefslogtreecommitdiff
path: root/sys/lib/libsa/ufs.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/lib/libsa/ufs.c')
-rw-r--r--sys/lib/libsa/ufs.c134
1 files changed, 46 insertions, 88 deletions
diff --git a/sys/lib/libsa/ufs.c b/sys/lib/libsa/ufs.c
index b9eb7ae8fe6..196b2f2f53c 100644
--- a/sys/lib/libsa/ufs.c
+++ b/sys/lib/libsa/ufs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs.c,v 1.15 2003/06/02 23:28:10 millert Exp $ */
+/* $OpenBSD: ufs.c,v 1.16 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: ufs.c,v 1.16 1996/09/30 16:01:22 ws Exp $ */
/*-
@@ -72,6 +72,7 @@
#include <lib/libkern/libkern.h>
#include "stand.h"
+#include "ufs.h"
/*
* In-core open file.
@@ -105,12 +106,10 @@ static void ffs_oldfscompat(struct fs *);
* Read a new inode into a file structure.
*/
static int
-read_inode(inumber, f)
- ino_t inumber;
- struct open_file *f;
+read_inode(ino_t inumber, struct open_file *f)
{
- register struct file *fp = (struct file *)f->f_fsdata;
- register struct fs *fs = fp->f_fs;
+ struct file *fp = (struct file *)f->f_fsdata;
+ struct fs *fs = fp->f_fs;
char *buf;
size_t rsize;
int rc;
@@ -131,7 +130,7 @@ read_inode(inumber, f)
}
{
- register struct dinode *dp;
+ struct dinode *dp;
dp = (struct dinode *)buf;
fp->f_di = dp[ino_to_fsbo(fs, inumber)];
@@ -141,7 +140,7 @@ read_inode(inumber, f)
* Clear out the old buffers
*/
{
- register int level;
+ int level;
for (level = 0; level < NIADDR; level++)
fp->f_blkno[level] = -1;
@@ -157,18 +156,12 @@ out:
* contains that block.
*/
static int
-block_map(f, file_block, disk_block_p)
- struct open_file *f;
- daddr_t file_block;
- daddr_t *disk_block_p; /* out */
+block_map(struct open_file *f, daddr_t file_block, daddr_t *disk_block_p)
{
- register struct file *fp = (struct file *)f->f_fsdata;
- register struct fs *fs = fp->f_fs;
- int level;
- int idx;
- daddr_t ind_block_num;
- daddr_t *ind_p;
- int rc;
+ struct file *fp = (struct file *)f->f_fsdata;
+ daddr_t ind_block_num, *ind_p;
+ struct fs *fs = fp->f_fs;
+ int level, idx, rc;
/*
* Index structure of an inode:
@@ -252,7 +245,6 @@ block_map(f, file_block, disk_block_p)
}
*disk_block_p = ind_block_num;
-
return (0);
}
@@ -261,17 +253,13 @@ block_map(f, file_block, disk_block_p)
* the location in the buffer and the amount in the buffer.
*/
static int
-buf_read_file(f, buf_p, size_p)
- struct open_file *f;
- char **buf_p; /* out */
- size_t *size_p; /* out */
+buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
{
- 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;
+ struct file *fp = (struct file *)f->f_fsdata;
+ struct fs *fs = fp->f_fs;
+ daddr_t file_block, disk_block;
size_t block_size;
+ long off;
int rc;
off = blkoff(fs, fp->f_seekp);
@@ -323,18 +311,13 @@ buf_read_file(f, buf_p, size_p)
* i_number.
*/
static int
-search_directory(name, f, inumber_p)
- char *name;
- struct open_file *f;
- ino_t *inumber_p; /* out */
+search_directory(char *name, struct open_file *f, ino_t *inumber_p)
{
- register struct file *fp = (struct file *)f->f_fsdata;
- register struct direct *dp;
- struct direct *edp;
- char *buf;
+ struct file *fp = (struct file *)f->f_fsdata;
+ int namlen, length, rc;
+ struct direct *dp, *edp;
size_t buf_size;
- int namlen, length;
- int rc;
+ char *buf;
length = strlen(name);
@@ -373,20 +356,14 @@ search_directory(name, f, inumber_p)
* Open a file.
*/
int
-ufs_open(path, f)
- char *path;
- struct open_file *f;
+ufs_open(char *path, struct open_file *f)
{
- register char *cp, *ncp;
- register int c;
+ char namebuf[MAXPATHLEN+1], *cp, *ncp, *buf = NULL;
ino_t inumber, parent_inumber;
+ int rc, c, nlinks = 0;
struct file *fp;
- struct fs *fs;
- int rc;
size_t buf_size;
- int nlinks = 0;
- char namebuf[MAXPATHLEN+1];
- char *buf = NULL;
+ struct fs *fs;
/* allocate file system specific data structure */
fp = alloc(sizeof(struct file));
@@ -415,8 +392,8 @@ ufs_open(path, f)
* Calculate indirect block levels.
*/
{
- register int mult;
- register int level;
+ int mult;
+ int level;
mult = 1;
for (level = 0; level < NIADDR; level++) {
@@ -452,7 +429,7 @@ ufs_open(path, f)
* Get next component of path name.
*/
{
- register int len = 0;
+ int len = 0;
ncp = cp;
while ((c = *cp) != '\0' && c != '/') {
@@ -508,7 +485,7 @@ ufs_open(path, f)
*/
size_t buf_size;
daddr_t disk_block;
- register struct fs *fs = fp->f_fs;
+ struct fs *fs = fp->f_fs;
if (!buf)
buf = alloc(fs->fs_bsize);
@@ -556,10 +533,9 @@ out:
}
int
-ufs_close(f)
- struct open_file *f;
+ufs_close(struct open_file *f)
{
- register struct file *fp = (struct file *)f->f_fsdata;
+ struct file *fp = (struct file *)f->f_fsdata;
int level;
f->f_fsdata = (void *)0;
@@ -582,18 +558,12 @@ ufs_close(f)
* Cross block boundaries when necessary.
*/
int
-ufs_read(f, start, size, resid)
- struct open_file *f;
- void *start;
- size_t size;
- size_t *resid; /* out */
+ufs_read(struct open_file *f, void *start, size_t size, size_t *resid)
{
- register struct file *fp = (struct file *)f->f_fsdata;
- register size_t csize;
- char *buf;
- size_t buf_size;
+ struct file *fp = (struct file *)f->f_fsdata;
+ char *buf, *addr = start;
+ size_t csize, buf_size;
int rc = 0;
- register char *addr = start;
while (size != 0) {
if (fp->f_seekp >= fp->f_di.di_size)
@@ -622,23 +592,16 @@ ufs_read(f, start, size, resid)
* Not implemented.
*/
int
-ufs_write(f, start, size, resid)
- struct open_file *f;
- void *start;
- size_t size;
- size_t *resid; /* out */
+ufs_write(struct open_file *f, void *start, size_t size, size_t *resid)
{
return (EROFS);
}
off_t
-ufs_seek(f, offset, where)
- struct open_file *f;
- off_t offset;
- int where;
+ufs_seek(struct open_file *f, off_t offset, int where)
{
- register struct file *fp = (struct file *)f->f_fsdata;
+ struct file *fp = (struct file *)f->f_fsdata;
switch (where) {
case SEEK_SET:
@@ -657,11 +620,9 @@ ufs_seek(f, offset, where)
}
int
-ufs_stat(f, sb)
- struct open_file *f;
- struct stat *sb;
+ufs_stat(struct open_file *f, struct stat *sb)
{
- register struct file *fp = (struct file *)f->f_fsdata;
+ struct file *fp = (struct file *)f->f_fsdata;
/* only important stuff */
sb->st_mode = fp->f_di.di_mode;
@@ -673,15 +634,13 @@ ufs_stat(f, sb)
#ifndef NO_READDIR
int
-ufs_readdir(f, name)
- struct open_file *f;
- char *name;
+ufs_readdir(struct open_file *f, char *name)
{
- register struct file *fp = (struct file *)f->f_fsdata;
- char *buf;
+ struct file *fp = (struct file *)f->f_fsdata;
+ struct direct *dp, *edp;
size_t buf_size;
- register struct direct *dp, *edp;
int rc, namlen;
+ char *buf;
if (name == NULL)
fp->f_seekp = 0;
@@ -726,8 +685,7 @@ ufs_readdir(f, name)
* XXX - goes away some day.
*/
static void
-ffs_oldfscompat(fs)
- struct fs *fs;
+ffs_oldfscompat(struct fs *fs)
{
int i;