diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-02-16 14:39:40 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-02-16 14:39:40 +0000 |
commit | 6c92e0b11998dc315af7602ab8f9f98c2f5d8095 (patch) | |
tree | 430497a640a72b5615674ab051945ee57e8237a1 | |
parent | c46bb180adc2f59a65168c318cc52b3f82ff858d (diff) |
opendir, readdir, closedir (define NO_READDIR, if none required)
minor fix in cd9660
only ufs working, all the others are on the list....
-rw-r--r-- | sys/lib/libsa/cd9660.c | 19 | ||||
-rw-r--r-- | sys/lib/libsa/cd9660.h | 2 | ||||
-rw-r--r-- | sys/lib/libsa/nfs.c | 16 | ||||
-rw-r--r-- | sys/lib/libsa/nullfs.c | 40 | ||||
-rw-r--r-- | sys/lib/libsa/ufs.c | 50 |
5 files changed, 108 insertions, 19 deletions
diff --git a/sys/lib/libsa/cd9660.c b/sys/lib/libsa/cd9660.c index 2ee8ac91f0f..031ec03edb8 100644 --- a/sys/lib/libsa/cd9660.c +++ b/sys/lib/libsa/cd9660.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cd9660.c,v 1.2 1996/12/12 08:19:25 mickey Exp $ */ +/* $OpenBSD: cd9660.c,v 1.3 1997/02/16 14:39:38 mickey Exp $ */ /* $NetBSD: cd9660.c,v 1.1 1996/09/30 16:01:19 ws Exp $ */ /* @@ -162,6 +162,7 @@ cd9660_open(path, f) /* First find the volume descriptor */ buf = alloc(buf_size = ISO_DEFAULT_BLOCK_SIZE); + dp = (struct iso_directory_record *)buf; vd = buf; for (bno = 16;; bno++) { twiddle(); @@ -232,7 +233,7 @@ cd9660_open(path, f) /* Now bno has the start of the directory that supposedly contains the file */ bno--; - dsize = 1; /* Something stupid, but > 0 XXX */ + dsize = 1; /* Something stupid, but > 0 XXX */ for (psize = 0; psize < dsize;) { if (!(psize % ISO_DEFAULT_BLOCK_SIZE)) { bno++; @@ -398,3 +399,17 @@ cd9660_stat(f, sb) sb->st_size = fp->size; return 0; } + +/* + * Not implemented. + */ +#ifndef NO_READDIR +int +cd9660_readdir(f, name) + struct open_file *f; + char *name; +{ + return (EROFS); +} +#endif + diff --git a/sys/lib/libsa/cd9660.h b/sys/lib/libsa/cd9660.h index 6031323a380..94e9f2ed241 100644 --- a/sys/lib/libsa/cd9660.h +++ b/sys/lib/libsa/cd9660.h @@ -1,3 +1,4 @@ +/* $OpenBSD: cd9660.h,v 1.2 1997/02/16 14:39:39 mickey Exp $ */ /* $NetBSD: cd9660.h,v 1.1 1996/09/30 16:01:20 ws Exp $ */ /* @@ -39,3 +40,4 @@ int cd9660_write __P((struct open_file *f, void *buf, size_t size, size_t *resid)); off_t cd9660_seek __P((struct open_file *f, off_t offset, int where)); int cd9660_stat __P((struct open_file *f, struct stat *sb)); +int cd9660_readdir __P((struct open_file *f, char *name)); diff --git a/sys/lib/libsa/nfs.c b/sys/lib/libsa/nfs.c index a09d4698d0a..9e266aa86e7 100644 --- a/sys/lib/libsa/nfs.c +++ b/sys/lib/libsa/nfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs.c,v 1.6 1996/12/08 15:15:52 niklas Exp $ */ +/* $OpenBSD: nfs.c,v 1.7 1997/02/16 14:39:39 mickey Exp $ */ /* $NetBSD: nfs.c,v 1.19 1996/10/13 02:29:04 christos Exp $ */ /*- @@ -42,6 +42,7 @@ #include "nfsv2.h" #include "stand.h" +#include "saerrno.h" #include "net.h" #include "netif.h" #include "nfs.h" @@ -639,3 +640,16 @@ nfs_stat(f, sb) return (0); } + +/* + * Not implemented. + */ +#ifndef NO_READDIR +int +nfs_readdir(f, name) + struct open_file *f; + char *name; +{ + return (EROFS); +} +#endif diff --git a/sys/lib/libsa/nullfs.c b/sys/lib/libsa/nullfs.c index c7a55f92e7d..71f52022083 100644 --- a/sys/lib/libsa/nullfs.c +++ b/sys/lib/libsa/nullfs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nullfs.c,v 1.2 1996/09/23 14:19:00 mickey Exp $ */ +/* $OpenBSD: nullfs.c,v 1.3 1997/02/16 14:39:38 mickey Exp $ */ /* $NetBSD: open.c,v 1.9 1995/09/19 09:16:52 thorpej Exp $ */ /*- @@ -70,37 +70,47 @@ /* * Null filesystem */ -int null_open (char *path, struct open_file *f) +int +null_open (char *path, struct open_file *f) { - errno = EIO; - return -1; + return EIO; } -int null_close(struct open_file *f) +int +null_close(struct open_file *f) { return 0; } -ssize_t null_read (struct open_file *f, void *buf, size_t size, size_t *resid) +int +null_read (struct open_file *f, void *buf, size_t size, size_t *resid) { - errno = EIO; - return -1; + return EIO; } -ssize_t null_write (struct open_file *f, void *buf, size_t size, size_t *resid) +int +null_write (struct open_file *f, void *buf, size_t size, size_t *resid) { - errno = EIO; - return -1; + return EIO; } -off_t null_seek (struct open_file *f, off_t offset, int where) +off_t +null_seek (struct open_file *f, off_t offset, int where) { errno = EIO; return -1; } -int null_stat (struct open_file *f, struct stat *sb) +int +null_stat (struct open_file *f, struct stat *sb) { - errno = EIO; - return -1; + return EIO; +} + +#ifndef NO_READDIR +int +null_readdir (struct open_file *f, char *name) +{ + return EIO; } +#endif diff --git a/sys/lib/libsa/ufs.c b/sys/lib/libsa/ufs.c index 8adb7048477..dd41f56a9c9 100644 --- a/sys/lib/libsa/ufs.c +++ b/sys/lib/libsa/ufs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs.c,v 1.8 1996/12/08 15:15:58 niklas Exp $ */ +/* $OpenBSD: ufs.c,v 1.9 1997/02/16 14:39:37 mickey Exp $ */ /* $NetBSD: ufs.c,v 1.16 1996/09/30 16:01:22 ws Exp $ */ /*- @@ -679,6 +679,54 @@ ufs_stat(f, sb) return (0); } +#ifndef NO_READDIR +int +ufs_readdir(f, name) + struct open_file *f; + char *name; +{ + register struct file *fp = (struct file *)f->f_fsdata; + char *buf; + size_t buf_size; + register struct direct *dp, *edp; + int rc, namlen; + + if (name == NULL) + fp->f_seekp = 0; + else { + /* end of dir */ + if (fp->f_seekp >= fp->f_di.di_size) { + *name = '\0'; + return 0; + } + + do { + if ((rc = buf_read_file(f, &buf, &buf_size)) != 0) + return rc; + + dp = (struct direct *)buf; + edp = (struct direct *)(buf + buf_size); + while (dp < edp && dp->d_ino == (ino_t)0) + dp = (struct direct *)((char *)dp + dp->d_reclen); + fp->f_seekp += buf_size - + ((u_int8_t *)edp - (u_int8_t *)dp); + } while (dp >= edp); + +#if BYTE_ORDER == LITTLE_ENDIAN + if (fp->f_fs->fs_maxsymlinklen <= 0) + namlen = dp->d_type; + else +#endif + namlen = dp->d_namlen; + strncpy(name, dp->d_name, namlen + 1); + + fp->f_seekp += dp->d_reclen; + } + + return 0; +} +#endif + #ifdef COMPAT_UFS /* * Sanity checks for old file systems. |