summaryrefslogtreecommitdiffstats
path: root/lib/libstand/ufs.c
diff options
context:
space:
mode:
authorjlemon <jlemon@FreeBSD.org>2000-04-29 20:47:10 +0000
committerjlemon <jlemon@FreeBSD.org>2000-04-29 20:47:10 +0000
commit9f5d586c97f0c69480f51fa40d06e6720f36dd6d (patch)
tree2a80882b8e07436637e0729c87a7192a50231dbd /lib/libstand/ufs.c
parent0340a88f8a7d13623dc70269b23cf87bc47decff (diff)
downloadFreeBSD-src-9f5d586c97f0c69480f51fa40d06e6720f36dd6d.zip
FreeBSD-src-9f5d586c97f0c69480f51fa40d06e6720f36dd6d.tar.gz
Add a readdir function to the loader fsops vector, and implement the
functionality for some of the filesystesms.
Diffstat (limited to 'lib/libstand/ufs.c')
-rw-r--r--lib/libstand/ufs.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/libstand/ufs.c b/lib/libstand/ufs.c
index 8511422..0db2393 100644
--- a/lib/libstand/ufs.c
+++ b/lib/libstand/ufs.c
@@ -1,3 +1,4 @@
+/* $FreeBSD$ */
/* $NetBSD: ufs.c,v 1.20 1998/03/01 07:15:39 ross Exp $ */
/*-
@@ -83,9 +84,17 @@ static int ufs_close(struct open_file *f);
static int ufs_read(struct open_file *f, void *buf, size_t size, size_t *resid);
static off_t ufs_seek(struct open_file *f, off_t offset, int where);
static int ufs_stat(struct open_file *f, struct stat *sb);
+static int ufs_readdir(struct open_file *f, struct dirent *d);
struct fs_ops ufs_fsops = {
- "ufs", ufs_open, ufs_close, ufs_read, null_write, ufs_seek, ufs_stat
+ "ufs",
+ ufs_open,
+ ufs_close,
+ ufs_read,
+ null_write,
+ ufs_seek,
+ ufs_stat,
+ ufs_readdir
};
/*
@@ -686,6 +695,33 @@ ufs_stat(f, sb)
return (0);
}
+static int
+ufs_readdir(struct open_file *f, struct dirent *d)
+{
+ struct file *fp = (struct file *)f->f_fsdata;
+ struct direct *dp;
+ char *buf;
+ size_t buf_size;
+ int error;
+
+ /*
+ * assume that a directory entry will not be split across blocks
+ */
+again:
+ if (fp->f_seekp >= fp->f_di.di_size)
+ return (ENOENT);
+ error = buf_read_file(f, &buf, &buf_size);
+ if (error)
+ return (error);
+ dp = (struct direct *)buf;
+ fp->f_seekp += dp->d_reclen;
+ if (dp->d_ino == (ino_t)0)
+ goto again;
+ d->d_type = dp->d_type;
+ strcpy(d->d_name, dp->d_name);
+ return (0);
+}
+
#ifdef COMPAT_UFS
/*
* Sanity checks for old file systems.
OpenPOWER on IntegriCloud