summaryrefslogtreecommitdiffstats
path: root/lib/libstand/ufs.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libstand/ufs.c')
-rw-r--r--lib/libstand/ufs.c60
1 files changed, 14 insertions, 46 deletions
diff --git a/lib/libstand/ufs.c b/lib/libstand/ufs.c
index a32fe06..bd7f8c7 100644
--- a/lib/libstand/ufs.c
+++ b/lib/libstand/ufs.c
@@ -84,7 +84,6 @@ struct fs_ops ufs_fsops = {
"ufs", ufs_open, ufs_close, ufs_read, null_write, ufs_seek, ufs_stat
};
-
/*
* In-core open file.
*/
@@ -113,39 +112,6 @@ static int search_directory(char *, struct open_file *, ino_t *);
static void ffs_oldfscompat(struct fs *);
#endif
-static void *buffers4 = 0;
-static void *buffers8 = 0;
-
-static void *
-getbuf(size_t size)
-{
- void *p = 0;
- if (size == 8192 && buffers8) {
- p = buffers8;
- buffers8 = *(void **) p;
- }
- if (size == 4096 && buffers4) {
- p = buffers4;
- buffers4 = *(void **) p;
- }
- if (!p)
- p = malloc(size);
- return p;
-}
-
-static void
-relbuf(void *p, size_t size)
-{
- if (size == 8192) {
- *(void**) p = buffers8;
- buffers8 = p;
- } else if (size == 4096) {
- *(void**) p = buffers4;
- buffers8 = p;
- } else
- free(p);
-}
-
/*
* Read a new inode into a file structure.
*/
@@ -160,10 +126,13 @@ read_inode(inumber, f)
size_t rsize;
int rc;
+ if (fs == NULL)
+ panic("fs == NULL");
+
/*
* Read inode and save it.
*/
- buf = getbuf(fs->fs_bsize);
+ buf = malloc(fs->fs_bsize);
twiddle();
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
fsbtodb(fs, ino_to_fsba(fs, inumber)), fs->fs_bsize,
@@ -193,7 +162,7 @@ read_inode(inumber, f)
fp->f_buf_blkno = -1;
}
out:
- relbuf(buf, fs->fs_bsize);
+ free(buf);
return (rc);
}
@@ -273,7 +242,7 @@ block_map(f, file_block, disk_block_p)
if (fp->f_blkno[level] != ind_block_num) {
if (fp->f_blk[level] == (char *)0)
fp->f_blk[level] =
- getbuf(fs->fs_bsize);
+ malloc(fs->fs_bsize);
twiddle();
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
fsbtodb(fp->f_fs, ind_block_num),
@@ -331,7 +300,7 @@ buf_read_file(f, buf_p, size_p)
return (rc);
if (fp->f_buf == (char *)0)
- fp->f_buf = getbuf(fs->fs_bsize);
+ fp->f_buf = malloc(fs->fs_bsize);
if (disk_block == 0) {
bzero(fp->f_buf, block_size);
@@ -442,7 +411,7 @@ ufs_open(upath, f)
f->f_fsdata = (void *)fp;
/* allocate space and read super block */
- fs = getbuf(SBSIZE);
+ fs = malloc(SBSIZE);
fp->f_fs = fs;
twiddle();
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
@@ -563,7 +532,7 @@ ufs_open(upath, f)
register struct fs *fs = fp->f_fs;
if (!buf)
- buf = getbuf(fs->fs_bsize);
+ buf = malloc(fs->fs_bsize);
rc = block_map(f, (daddr_t)0, &disk_block);
if (rc)
goto out;
@@ -599,12 +568,12 @@ ufs_open(upath, f)
rc = 0;
out:
if (buf)
- relbuf(buf, fs->fs_bsize);
+ free(buf);
if (path)
free(path);
if (rc) {
if (fp->f_buf)
- relbuf(fp->f_buf, fs->fs_bsize);
+ free(fp->f_buf);
free(fp->f_fs);
free(fp);
}
@@ -616,7 +585,6 @@ ufs_close(f)
struct open_file *f;
{
register struct file *fp = (struct file *)f->f_fsdata;
- struct fs *fs = fp->f_fs;
int level;
f->f_fsdata = (void *)0;
@@ -625,11 +593,11 @@ ufs_close(f)
for (level = 0; level < NIADDR; level++) {
if (fp->f_blk[level])
- relbuf(fp->f_blk[level], fs->fs_bsize);
+ free(fp->f_blk[level]);
}
if (fp->f_buf)
- relbuf(fp->f_buf, fs->fs_bsize);
- relbuf(fp->f_fs, SBSIZE);
+ free(fp->f_buf);
+ free(fp->f_fs);
free(fp);
return (0);
}
OpenPOWER on IntegriCloud