Make a bunch of backward-compatible changes to the boot blocks which allow
size to be reduced substantially. (backward compatibility verified by compiling one of the alpha boot blocks which uses all of the code before and after, diffing the object files, and manually verifying that the differences were 'correct'. some differences were "unavoidable," it wanting to avoid a double-commit, because e.g. local variables which were previously used were no longer used.) a README which describes supported options (or at least the ones mentioned below) is forthcoming. add support for the preprocessor macro LIBSA_NO_TWIDDLE, which causes calls to twiddle() to be omitted if it's defined. add support for the preprocessor macros: LIBSA_NO_FS_CLOSE LIBSA_NO_FS_WRITE LIBSA_NO_FS_SEEK which, if defined, cause the corresponding file system operations in the individual file system implementations to be omitted. (note that all of those macros are not supported by all file systems at this point. comments were added to individual file system files to indicate lack of support, and should be cleaned up later. Backward compatibility options e.g. UFS_NOCLOSE, etc., are supported.) add support for the preprocessor macro LIBSA_NO_FS_SYMLINK, which removes support for symbolic links from the file system support functions. (same notes as for the macros above apply.) add support for the preprocessor macro LIBSA_FS_SINGLECOMPONENT which removes all subdirectory and symlink support from the file system support functions. (same notes as for the macros above apply.) add support for the preprocessor macro LIBSA_NO_FD_CHECKING, which causes code relating to libsa file descriptor checks (e.g. range checking and checking that a file descriptor is valid) to be omitted if it's defined. add support for the preprocessor macro LIBSA_NO_RAW_ACCESS, which causes code relating to raw device access to be omitted if it's defined. change some structure copies to use bcopy() instead. that way use of bcopy vs. memcpy() can easily be selected by LIBSA_USE_MEMCPY. (without changes like these, you could end up having both bcopy() and memcpy() included. eventually, all calls to bcopy should be changed to calls to memcpy() or memmove() as appropriate -- hopefully never the latter -- with an option to use bcopy instead.) add support for the preprocessor macro LIBSA_NO_DISKLABEL_MSGS, which causes disklabel() to return '1' as msg rather than a string. Can be used if the boot blocks don't care about the string, and need to save the space. add support for the preprocessor macro LIBSA_SINGLE_FILESYSTEM, which if defined causes all of the file system switch code to be removed. Its value should be the name of the file system supported by the boot block, e.g. "ufs" for the FFS file system. calls to the file system functions open, close, etc., which were previously done through a function switch are then done via direct invocation of <fs>_open, <fs>_close, etc. (e.g. ufs_open, ...). add support for the preprocessor macro LIBSA_SINGLE_DEVICE, which does the equivalent of LIBSA_SINGLE_FILESYSTEM but for the device switch table. Device entry pointes are expected to be named <dev>foo, e.g. the 'strategy' routine used when LIBSA_SINGLE_DEVICE is set to 'disk' is diskstrategy. make ufs.c f_nindir array be unsigned ints. the fact that it was signed caused ufs.c to require signed division routines (which were otherwise unnecessary for a small boot block).
This commit is contained in:
parent
e5ce91e0f3
commit
309213477a
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cd9660.c,v 1.7 1999/03/26 15:41:38 dbj Exp $ */
|
||||
/* $NetBSD: cd9660.c,v 1.8 1999/03/31 01:50:25 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1996 Wolfgang Solfrank.
|
||||
|
@ -48,6 +48,13 @@
|
|||
#include "stand.h"
|
||||
#include "cd9660.h"
|
||||
|
||||
/*
|
||||
* XXX Does not currently implement:
|
||||
* XXX
|
||||
* XXX LIBSA_NO_FS_SYMLINK (does this even make sense?)
|
||||
* XXX LIBSA_FS_SINGLECOMPONENT
|
||||
*/
|
||||
|
||||
struct file {
|
||||
off_t off; /* Current offset within file */
|
||||
daddr_t bno; /* Starting block number */
|
||||
|
@ -153,8 +160,10 @@ cd9660_open(path, f)
|
|||
buf = alloc(buf_size = ISO_DEFAULT_BLOCK_SIZE);
|
||||
vd = buf;
|
||||
for (bno = 16;; bno++) {
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
rc = f->f_dev->dv_strategy(f->f_devdata, F_READ, cdb2devb(bno),
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, cdb2devb(bno),
|
||||
ISO_DEFAULT_BLOCK_SIZE, buf, &read);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
@ -182,8 +191,10 @@ cd9660_open(path, f)
|
|||
buf = alloc(buf_size = roundup(psize, ISO_DEFAULT_BLOCK_SIZE));
|
||||
}
|
||||
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
rc = f->f_dev->dv_strategy(f->f_devdata, F_READ, cdb2devb(bno),
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, cdb2devb(bno),
|
||||
buf_size, buf, &read);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
@ -225,8 +236,10 @@ cd9660_open(path, f)
|
|||
for (psize = 0; psize < dsize;) {
|
||||
if (!(psize % ISO_DEFAULT_BLOCK_SIZE)) {
|
||||
bno++;
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
rc = f->f_dev->dv_strategy(f->f_devdata, F_READ,
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
|
||||
cdb2devb(bno),
|
||||
ISO_DEFAULT_BLOCK_SIZE,
|
||||
buf, &read);
|
||||
|
@ -278,6 +291,7 @@ out:
|
|||
return rc;
|
||||
}
|
||||
|
||||
#if !defined(LIBSA_NO_FS_CLOSE)
|
||||
int
|
||||
cd9660_close(f)
|
||||
struct open_file *f;
|
||||
|
@ -289,6 +303,7 @@ cd9660_close(f)
|
|||
|
||||
return 0;
|
||||
}
|
||||
#endif /* !defined(LIBSA_NO_FS_CLOSE) */
|
||||
|
||||
int
|
||||
cd9660_read(f, start, size, resid)
|
||||
|
@ -313,8 +328,10 @@ cd9660_read(f, start, size, resid)
|
|||
dp = buf;
|
||||
else
|
||||
dp = start;
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
rc = f->f_dev->dv_strategy(f->f_devdata, F_READ, cdb2devb(bno),
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, cdb2devb(bno),
|
||||
ISO_DEFAULT_BLOCK_SIZE, dp, &read);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
@ -340,6 +357,7 @@ cd9660_read(f, start, size, resid)
|
|||
return rc;
|
||||
}
|
||||
|
||||
#if !defined(LIBSA_NO_FS_WRITE)
|
||||
int
|
||||
cd9660_write(f, start, size, resid)
|
||||
struct open_file *f;
|
||||
|
@ -349,7 +367,9 @@ cd9660_write(f, start, size, resid)
|
|||
{
|
||||
return EROFS;
|
||||
}
|
||||
#endif /* !defined(LIBSA_NO_FS_WRITE) */
|
||||
|
||||
#if !defined(LIBSA_NO_FS_SEEK)
|
||||
off_t
|
||||
cd9660_seek(f, offset, where)
|
||||
struct open_file *f;
|
||||
|
@ -373,6 +393,7 @@ cd9660_seek(f, offset, where)
|
|||
}
|
||||
return fp->off;
|
||||
}
|
||||
#endif /* !defined(LIBSA_NO_FS_SEEK) */
|
||||
|
||||
int
|
||||
cd9660_stat(f, sb)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: close.c,v 1.7 1997/01/22 00:38:09 cgd Exp $ */
|
||||
/* $NetBSD: close.c,v 1.8 1999/03/31 01:50:25 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -77,14 +77,24 @@ oclose(fd)
|
|||
register struct open_file *f = &files[fd];
|
||||
int err1 = 0, err2 = 0;
|
||||
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
}
|
||||
if (!(f->f_flags & F_RAW) && f->f_ops)
|
||||
err1 = (f->f_ops->close)(f);
|
||||
if (!(f->f_flags & F_NODEV) && f->f_dev)
|
||||
err2 = (f->f_dev->dv_close)(f);
|
||||
#endif
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
if (!(f->f_flags & F_RAW))
|
||||
#endif
|
||||
#if !defined(LIBSA_SINGLE_FILESYSTEM)
|
||||
if (f->f_ops != NULL)
|
||||
#endif
|
||||
err1 = FS_CLOSE(f->f_ops)(f);
|
||||
if (!(f->f_flags & F_NODEV))
|
||||
#if !defined(LIBSA_SINGLE_DEVICE)
|
||||
if (f->f_dev != NULL)
|
||||
#endif
|
||||
err2 = DEV_CLOSE(f->f_dev)(f);
|
||||
f->f_flags = 0;
|
||||
if (err1) {
|
||||
errno = err1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: cread.c,v 1.8 1999/02/12 10:44:07 drochner Exp $ */
|
||||
/* $NetBSD: cread.c,v 1.9 1999/03/31 01:50:25 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
|
@ -277,10 +277,12 @@ close(fd)
|
|||
struct open_file *f;
|
||||
struct sd *s;
|
||||
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
f = &files[fd];
|
||||
|
||||
if ((f->f_flags & F_READ) == 0)
|
||||
|
@ -396,10 +398,12 @@ lseek(fd, offset, where)
|
|||
struct open_file *f;
|
||||
struct sd *s;
|
||||
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
f = &files[fd];;
|
||||
|
||||
if ((f->f_flags & F_READ) == 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: disklabel.c,v 1.4 1996/01/13 22:25:36 leo Exp $ */
|
||||
/* $NetBSD: disklabel.c,v 1.5 1999/03/31 01:50:25 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -51,13 +51,21 @@ getdisklabel(buf, lp)
|
|||
for (dlp = (struct disklabel *)buf; dlp <= elp;
|
||||
dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
|
||||
if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
|
||||
#if defined(LIBSA_NO_DISKLABEL_MSGS)
|
||||
msg = (char *)1;
|
||||
#else
|
||||
if (msg == (char *)0)
|
||||
msg = "no disk label";
|
||||
#endif
|
||||
} else if (dlp->d_npartitions > MAXPARTITIONS ||
|
||||
dkcksum(dlp) != 0)
|
||||
#if defined(LIBSA_NO_DISKLABEL_MSGS)
|
||||
msg = (char *)1;
|
||||
#else
|
||||
msg = "disk label corrupted";
|
||||
#endif
|
||||
else {
|
||||
*lp = *dlp;
|
||||
bcopy(dlp, lp, sizeof *lp);
|
||||
msg = (char *)0;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fstat.c,v 1.1 1996/01/13 22:25:38 leo Exp $ */
|
||||
/* $NetBSD: fstat.c,v 1.2 1999/03/31 01:50:25 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -44,17 +44,21 @@ fstat(fd, sb)
|
|||
{
|
||||
register struct open_file *f = &files[fd];
|
||||
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
/* operation not defined on raw devices */
|
||||
if (f->f_flags & F_RAW) {
|
||||
errno = EOPNOTSUPP;
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
errno = (f->f_ops->stat)(f, sb);
|
||||
errno = FS_STAT(f->f_ops)(f, sb); /* XXX no point setting errno */
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ioctl.c,v 1.4 1994/10/30 21:48:24 cgd Exp $ */
|
||||
/* $NetBSD: ioctl.c,v 1.5 1999/03/31 01:50:25 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -72,18 +72,24 @@ ioctl(fd, cmd, arg)
|
|||
u_long cmd;
|
||||
char *arg;
|
||||
{
|
||||
#if !defined(LIBSA_NO_FD_CHECKING) || !defined(LIBSA_NO_RAW_ACCESS)
|
||||
register struct open_file *f = &files[fd];
|
||||
#endif
|
||||
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
if (f->f_flags & F_RAW) {
|
||||
errno = (f->f_dev->dv_ioctl)(f, cmd, arg);
|
||||
errno = DEV_IOCTL(f->f_dev)(f, cmd, arg);
|
||||
if (errno)
|
||||
return (-1);
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
errno = EIO;
|
||||
return (-1);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lseek.c,v 1.4 1997/01/22 00:38:10 cgd Exp $ */
|
||||
/* $NetBSD: lseek.c,v 1.5 1999/03/31 01:50:25 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -78,11 +78,14 @@ olseek(fd, offset, where)
|
|||
{
|
||||
register struct open_file *f = &files[fd];
|
||||
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
if (f->f_flags & F_RAW) {
|
||||
/*
|
||||
* On RAW devices, update internal offset.
|
||||
|
@ -101,6 +104,7 @@ olseek(fd, offset, where)
|
|||
}
|
||||
return (f->f_offset);
|
||||
}
|
||||
#endif
|
||||
|
||||
return (f->f_ops->seek)(f, offset, where);
|
||||
return FS_SEEK(f->f_ops)(f, offset, where);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: netif.c,v 1.11 1999/02/11 09:10:44 pk Exp $ */
|
||||
/* $NetBSD: netif.c,v 1.12 1999/03/31 01:50:25 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1993 Adam Glass
|
||||
|
@ -289,10 +289,12 @@ struct iodesc *
|
|||
socktodesc(sock)
|
||||
int sock;
|
||||
{
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if (sock >= SOPEN_MAX) {
|
||||
errno = EBADF;
|
||||
return (NULL);
|
||||
}
|
||||
#endif
|
||||
return (&sockets[sock]);
|
||||
}
|
||||
|
||||
|
@ -332,10 +334,12 @@ int
|
|||
netif_close(sock)
|
||||
int sock;
|
||||
{
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if (sock >= SOPEN_MAX) {
|
||||
errno = EBADF;
|
||||
return(-1);
|
||||
}
|
||||
#endif
|
||||
netif_detach(sockets[sock].io_netif);
|
||||
sockets[sock].io_netif = (struct netif *)0;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nfs.c,v 1.24 1999/02/11 09:10:44 pk Exp $ */
|
||||
/* $NetBSD: nfs.c,v 1.25 1999/03/31 01:50:25 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993 John Brezak
|
||||
|
@ -28,6 +28,16 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* XXX Does not currently implement:
|
||||
* XXX
|
||||
* XXX LIBSA_NO_FS_CLOSE
|
||||
* XXX LIBSA_NO_FS_SEEK
|
||||
* XXX LIBSA_NO_FS_WRITE
|
||||
* XXX LIBSA_NO_FS_SYMLINK (does this even make sense?)
|
||||
* XXX LIBSA_FS_SINGLECOMPONENT (does this even make sense?)
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -573,7 +583,9 @@ nfs_read(f, buf, size, resid)
|
|||
(int)fp->off);
|
||||
#endif
|
||||
while ((int)size > 0) {
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
#endif
|
||||
cc = nfs_readdata(fp, fp->off, (void *)addr, size);
|
||||
/* XXX maybe should retry on certain errors */
|
||||
if (cc == -1) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: nullfs.c,v 1.1 1996/01/13 22:25:39 leo Exp $ */
|
||||
/* $NetBSD: nullfs.c,v 1.2 1999/03/31 01:50:25 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -64,6 +64,16 @@
|
|||
* rights to redistribute these changes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* XXX Does not currently implement:
|
||||
* XXX
|
||||
* XXX LIBSA_NO_FS_CLOSE
|
||||
* XXX LIBSA_NO_FS_SEEK
|
||||
* XXX LIBSA_NO_FS_WRITE
|
||||
* XXX LIBSA_NO_FS_SYMLINK (does this even make sense?)
|
||||
* XXX LIBSA_FS_SINGLECOMPONENT (does this even make sense?)
|
||||
*/
|
||||
|
||||
#include "stand.h"
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: open.c,v 1.18 1999/03/26 03:16:15 simonb Exp $ */
|
||||
/* $NetBSD: open.c,v 1.19 1999/03/31 01:50:26 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -86,7 +86,10 @@ oopen(fname, mode)
|
|||
int mode;
|
||||
{
|
||||
register struct open_file *f;
|
||||
register int fd, i, error, besterror;
|
||||
register int fd, error;
|
||||
#if !defined(LIBSA_SINGLE_FILESYSTEM)
|
||||
register int i, besterror;
|
||||
#endif
|
||||
char *file;
|
||||
|
||||
/* find a free file descriptor */
|
||||
|
@ -101,26 +104,38 @@ fnd:
|
|||
* Convert open mode (0,1,2) to F_READ, F_WRITE.
|
||||
*/
|
||||
f->f_flags = mode + 1;
|
||||
#if !defined(LIBSA_SINGLE_DEVICE)
|
||||
f->f_dev = (struct devsw *)0;
|
||||
#endif
|
||||
#if !defined(LIBSA_SINGLE_FILESYSTEM)
|
||||
f->f_ops = (struct fs_ops *)0;
|
||||
#endif
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
f->f_offset = 0;
|
||||
#endif
|
||||
file = (char *)0;
|
||||
error = devopen(f, fname, &file);
|
||||
if (error ||
|
||||
(((f->f_flags & F_NODEV) == 0) && f->f_dev == (struct devsw *)0))
|
||||
if (error
|
||||
#if !defined(LIBSA_SINGLE_DEVICE)
|
||||
|| (((f->f_flags & F_NODEV) == 0) &&
|
||||
f->f_dev == (struct devsw *)0)
|
||||
#endif
|
||||
)
|
||||
goto err;
|
||||
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
/* see if we opened a raw device; otherwise, 'file' is the file name. */
|
||||
if (file == (char *)0 || *file == '\0') {
|
||||
f->f_flags |= F_RAW;
|
||||
return (fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* pass file name to the different filesystem open routines */
|
||||
#if !defined(LIBSA_SINGLE_FILESYSTEM)
|
||||
besterror = ENOENT;
|
||||
for (i = 0; i < nfsys; i++) {
|
||||
/* convert mode (0,1,2) to FREAD, FWRITE. */
|
||||
error = (file_system[i].open)(file, f);
|
||||
error = FS_OPEN(&file_system[i])(file, f);
|
||||
if (error == 0) {
|
||||
f->f_ops = &file_system[i];
|
||||
return (fd);
|
||||
|
@ -129,9 +144,19 @@ fnd:
|
|||
besterror = error;
|
||||
}
|
||||
error = besterror;
|
||||
#else
|
||||
error = FS_OPEN(&file_system[i])(file, f);
|
||||
if (error == 0)
|
||||
return (fd);
|
||||
else if (error == EINVAL)
|
||||
error = ENOENT;
|
||||
#endif
|
||||
|
||||
if ((f->f_flags & F_NODEV) == 0 && f->f_dev->dv_close != NULL)
|
||||
f->f_dev->dv_close(f);
|
||||
if ((f->f_flags & F_NODEV) == 0)
|
||||
#if !defined(LIBSA_SINGLE_DEVICE)
|
||||
if (DEV_CLOSE(f->f_dev) != NULL)
|
||||
#endif
|
||||
(void)DEV_CLOSE(f->f_dev)(f);
|
||||
err:
|
||||
f->f_flags = 0;
|
||||
errno = error;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: read.c,v 1.8 1997/01/22 00:38:12 cgd Exp $ */
|
||||
/* $NetBSD: read.c,v 1.9 1999/03/31 01:50:26 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -80,21 +80,27 @@ oread(fd, dest, bcount)
|
|||
register struct open_file *f = &files[fd];
|
||||
size_t resid;
|
||||
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
if (f->f_flags & F_RAW) {
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
errno = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
|
||||
#endif
|
||||
errno = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
|
||||
btodb(f->f_offset), bcount, dest, &resid);
|
||||
if (errno)
|
||||
return (-1);
|
||||
f->f_offset += resid;
|
||||
return (resid);
|
||||
}
|
||||
#endif
|
||||
resid = bcount;
|
||||
if ((errno = (f->f_ops->read)(f, dest, bcount, &resid)))
|
||||
if ((errno = FS_READ(f->f_ops)(f, dest, bcount, &resid)))
|
||||
return (-1);
|
||||
return (ssize_t)(bcount - resid);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,34 @@
|
|||
/* $NetBSD: stand.h,v 1.30 1999/02/22 10:08:42 simonb Exp $ */
|
||||
/* $NetBSD: stand.h,v 1.31 1999/03/31 01:50:26 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christopher G. Demetriou
|
||||
* for the NetBSD Project.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -58,6 +88,7 @@ struct open_file;
|
|||
* This structure is used to define file system operations in a file system
|
||||
* independent way.
|
||||
*/
|
||||
#if !defined(LIBSA_SINGLE_FILESYSTEM)
|
||||
struct fs_ops {
|
||||
int (*open) __P((char *path, struct open_file *f));
|
||||
int (*close) __P((struct open_file *f));
|
||||
|
@ -72,12 +103,41 @@ struct fs_ops {
|
|||
extern struct fs_ops file_system[];
|
||||
extern int nfsys;
|
||||
|
||||
#define FS_OPEN(fs) ((fs)->open)
|
||||
#define FS_CLOSE(fs) ((fs)->close)
|
||||
#define FS_READ(fs) ((fs)->read)
|
||||
#define FS_WRITE(fs) ((fs)->write)
|
||||
#define FS_SEEK(fs) ((fs)->seek)
|
||||
#define FS_STAT(fs) ((fs)->stat)
|
||||
|
||||
#else
|
||||
|
||||
#define FS_OPEN(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_open)
|
||||
#define FS_CLOSE(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_close)
|
||||
#define FS_READ(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_read)
|
||||
#define FS_WRITE(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_write)
|
||||
#define FS_SEEK(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_seek)
|
||||
#define FS_STAT(fs) ___CONCAT(LIBSA_SINGLE_FILESYSTEM,_stat)
|
||||
|
||||
int FS_OPEN(unused) __P((char *path, struct open_file *f));
|
||||
int FS_CLOSE(unused) __P((struct open_file *f));
|
||||
int FS_READ(unused) __P((struct open_file *f, void *buf,
|
||||
size_t size, size_t *resid));
|
||||
int FS_WRITE(unused) __P((struct open_file *f, void *buf,
|
||||
size_t size, size_t *resid));
|
||||
off_t FS_SEEK(unused) __P((struct open_file *f, off_t offset, int where));
|
||||
int FS_STAT(unused) __P((struct open_file *f, struct stat *sb));
|
||||
|
||||
#endif
|
||||
|
||||
/* where values for lseek(2) */
|
||||
#define SEEK_SET 0 /* set file offset to offset */
|
||||
#define SEEK_CUR 1 /* set file offset to current plus offset */
|
||||
#define SEEK_END 2 /* set file offset to EOF plus offset */
|
||||
|
||||
/* Device switch */
|
||||
#if !defined(LIBSA_SINGLE_DEVICE)
|
||||
|
||||
struct devsw {
|
||||
char *dv_name;
|
||||
int (*dv_strategy) __P((void *devdata, int rw,
|
||||
|
@ -91,13 +151,41 @@ struct devsw {
|
|||
extern struct devsw devsw[]; /* device array */
|
||||
extern int ndevs; /* number of elements in devsw[] */
|
||||
|
||||
#define DEV_NAME(d) ((d)->dv_name)
|
||||
#define DEV_STRATEGY(d) ((d)->dv_strategy)
|
||||
#define DEV_OPEN(d) ((d)->dv_open)
|
||||
#define DEV_CLOSE(d) ((d)->dv_close)
|
||||
#define DEV_IOCTL(d) ((d)->dv_ioctl)
|
||||
|
||||
#else
|
||||
|
||||
#define DEV_NAME(d) ___STRING(LIBSA_SINGLE_DEVICE)
|
||||
#define DEV_STRATEGY(d) ___CONCAT(LIBSA_SINGLE_DEVICE,strategy)
|
||||
#define DEV_OPEN(d) ___CONCAT(LIBSA_SINGLE_DEVICE,open)
|
||||
#define DEV_CLOSE(d) ___CONCAT(LIBSA_SINGLE_DEVICE,close)
|
||||
#define DEV_IOCTL(d) ___CONCAT(LIBSA_SINGLE_DEVICE,ioctl)
|
||||
|
||||
int DEV_STRATEGY(unused) __P((void *devdata, int rw, daddr_t blk,
|
||||
size_t size, void *buf, size_t *rsize));
|
||||
int DEV_OPEN(unused) __P((struct open_file *f, ...));
|
||||
int DEV_CLOSE(unused) __P((struct open_file *f));
|
||||
int DEV_IOCTL(unused) __P((struct open_file *f, u_long cmd, void *data));
|
||||
|
||||
#endif
|
||||
|
||||
struct open_file {
|
||||
int f_flags; /* see F_* below */
|
||||
#if !defined(LIBSA_SINGLE_DEVICE)
|
||||
struct devsw *f_dev; /* pointer to device operations */
|
||||
#endif
|
||||
void *f_devdata; /* device specific data */
|
||||
#if !defined(LIBSA_SINGLE_FILESYSTEM)
|
||||
struct fs_ops *f_ops; /* pointer to file system operations */
|
||||
#endif
|
||||
void *f_fsdata; /* file system specific data */
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
off_t f_offset; /* current file offset (F_RAW) */
|
||||
#endif
|
||||
};
|
||||
|
||||
#define SOPEN_MAX 4
|
||||
|
@ -106,7 +194,9 @@ extern struct open_file files[];
|
|||
/* f_flags values */
|
||||
#define F_READ 0x0001 /* file opened for reading */
|
||||
#define F_WRITE 0x0002 /* file opened for writing */
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
#define F_RAW 0x0004 /* raw device open - no file system */
|
||||
#endif
|
||||
#define F_NODEV 0x0008 /* network open - no device */
|
||||
|
||||
#define isupper(c) ((c) >= 'A' && (c) <= 'Z')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tftp.c,v 1.5 1999/03/26 15:41:38 dbj Exp $ */
|
||||
/* $NetBSD: tftp.c,v 1.6 1999/03/31 01:50:26 cgd Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996
|
||||
|
@ -43,6 +43,16 @@
|
|||
* - no big time differences between transfers (<tftp timeout)
|
||||
*/
|
||||
|
||||
/*
|
||||
* XXX Does not currently implement:
|
||||
* XXX
|
||||
* XXX LIBSA_NO_FS_CLOSE
|
||||
* XXX LIBSA_NO_FS_SEEK
|
||||
* XXX LIBSA_NO_FS_WRITE
|
||||
* XXX LIBSA_NO_FS_SYMLINK (does this even make sense?)
|
||||
* XXX LIBSA_FS_SINGLECOMPONENT (does this even make sense?)
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <netinet/in.h>
|
||||
|
@ -294,14 +304,18 @@ tftp_read(f, addr, size, resid)
|
|||
size_t *resid; /* out */
|
||||
{
|
||||
struct tftp_handle *tftpfile;
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
static int tc = 0;
|
||||
#endif
|
||||
tftpfile = (struct tftp_handle *) f->f_fsdata;
|
||||
|
||||
while (size > 0) {
|
||||
int needblock, count;
|
||||
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
if (!(tc++ % 16))
|
||||
twiddle();
|
||||
#endif
|
||||
|
||||
needblock = tftpfile->off / SEGSIZE + 1;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ufs.c,v 1.22 1999/02/22 07:59:09 simonb Exp $ */
|
||||
/* $NetBSD: ufs.c,v 1.23 1999/03/31 01:50:26 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -86,6 +86,21 @@ max(a, b)
|
|||
#include "stand.h"
|
||||
#include "ufs.h"
|
||||
|
||||
#if defined(UFS_NOSYMLINK) && !defined(LIBSA_NO_FS_SYMLINK)
|
||||
#define LIBSA_NO_FS_SYMLINK /* XXX COMPAT */
|
||||
#endif
|
||||
#if defined(UFS_NOCLOSE) && !defined(LIBSA_NO_FS_CLOSE)
|
||||
#define LIBSA_NO_FS_CLOSE /* XXX COMPAT */
|
||||
#endif
|
||||
#if defined(UFS_NOWRITE) && !defined(LIBSA_NO_FS_WRITE)
|
||||
#define LIBSA_NO_FS_WRITE /* XXX COMPAT */
|
||||
#endif
|
||||
|
||||
#if defined(LIBSA_FS_SINGLECOMPONENT) && !defined(LIBSA_NO_FS_SYMLINK)
|
||||
#define LIBSA_NO_FS_SYMLINK
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* In-core open file.
|
||||
*/
|
||||
|
@ -93,7 +108,7 @@ struct file {
|
|||
off_t f_seekp; /* seek pointer */
|
||||
struct fs *f_fs; /* pointer to super-block */
|
||||
struct dinode f_di; /* copy of on-disk inode */
|
||||
int f_nindir[NIADDR];
|
||||
unsigned int f_nindir[NIADDR];
|
||||
/* number of blocks mapped by
|
||||
indirect block at level i */
|
||||
char *f_blk[NIADDR]; /* buffer for indirect block at
|
||||
|
@ -132,8 +147,10 @@ read_inode(inumber, f)
|
|||
* Read inode and save it.
|
||||
*/
|
||||
buf = alloc(fs->fs_bsize);
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
|
||||
fsbtodb(fs, ino_to_fsba(fs, inumber)), fs->fs_bsize,
|
||||
buf, &rsize);
|
||||
if (rc)
|
||||
|
@ -242,8 +259,10 @@ block_map(f, file_block, disk_block_p)
|
|||
if (fp->f_blk[level] == (char *)0)
|
||||
fp->f_blk[level] =
|
||||
alloc(fs->fs_bsize);
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
|
||||
fsbtodb(fp->f_fs, ind_block_num),
|
||||
fs->fs_bsize,
|
||||
fp->f_blk[level],
|
||||
|
@ -305,8 +324,10 @@ buf_read_file(f, buf_p, size_p)
|
|||
bzero(fp->f_buf, block_size);
|
||||
fp->f_buf_size = block_size;
|
||||
} else {
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
|
||||
fsbtodb(fs, disk_block),
|
||||
block_size, fp->f_buf, &fp->f_buf_size);
|
||||
if (rc)
|
||||
|
@ -392,14 +413,17 @@ ufs_open(path, f)
|
|||
char *path;
|
||||
struct open_file *f;
|
||||
{
|
||||
#ifndef LIBSA_FS_SINGLECOMPONENT
|
||||
register char *cp, *ncp;
|
||||
register int c;
|
||||
ino_t inumber, parent_inumber;
|
||||
#endif
|
||||
ino_t inumber;
|
||||
struct file *fp;
|
||||
struct fs *fs;
|
||||
int rc;
|
||||
size_t buf_size;
|
||||
#ifndef UFS_NOSYMLINK
|
||||
#ifndef LIBSA_NO_FS_SYMLINK
|
||||
ino_t parent_inumber;
|
||||
int nlinks = 0;
|
||||
char namebuf[MAXPATHLEN+1];
|
||||
char *buf = NULL;
|
||||
|
@ -413,8 +437,10 @@ ufs_open(path, f)
|
|||
/* allocate space and read super block */
|
||||
fs = alloc(SBSIZE);
|
||||
fp->f_fs = fs;
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
|
||||
SBLOCK, SBSIZE, (char *)fs, &buf_size);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
@ -446,6 +472,7 @@ ufs_open(path, f)
|
|||
if ((rc = read_inode(inumber, f)) != 0)
|
||||
goto out;
|
||||
|
||||
#ifndef LIBSA_FS_SINGLECOMPONENT
|
||||
cp = path;
|
||||
while (*cp) {
|
||||
|
||||
|
@ -487,7 +514,9 @@ ufs_open(path, f)
|
|||
* Save directory inumber in case we find a
|
||||
* symbolic link.
|
||||
*/
|
||||
#ifndef LIBSA_NO_FS_SYMLINK
|
||||
parent_inumber = inumber;
|
||||
#endif
|
||||
rc = search_directory(ncp, f, &inumber);
|
||||
*cp = c;
|
||||
if (rc)
|
||||
|
@ -499,7 +528,7 @@ ufs_open(path, f)
|
|||
if ((rc = read_inode(inumber, f)) != 0)
|
||||
goto out;
|
||||
|
||||
#ifndef UFS_NOSYMLINK
|
||||
#ifndef LIBSA_NO_FS_SYMLINK
|
||||
/*
|
||||
* Check for symbolic link.
|
||||
*/
|
||||
|
@ -534,8 +563,10 @@ ufs_open(path, f)
|
|||
if (rc)
|
||||
goto out;
|
||||
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
rc = (f->f_dev->dv_strategy)(f->f_devdata,
|
||||
#endif
|
||||
rc = DEV_STRATEGY(f->f_dev)(f->f_devdata,
|
||||
F_READ, fsbtodb(fs, disk_block),
|
||||
fs->fs_bsize, buf, &buf_size);
|
||||
if (rc)
|
||||
|
@ -557,15 +588,28 @@ ufs_open(path, f)
|
|||
if ((rc = read_inode(inumber, f)) != 0)
|
||||
goto out;
|
||||
}
|
||||
#endif /* !UFS_NOSYMLINK */
|
||||
#endif /* !LIBSA_NO_FS_SYMLINK */
|
||||
}
|
||||
|
||||
/*
|
||||
* Found terminal component.
|
||||
*/
|
||||
rc = 0;
|
||||
|
||||
#else /* !LIBSA_FS_SINGLECOMPONENT */
|
||||
|
||||
/* look up component in the current (root) directory */
|
||||
rc = search_directory(path, f, &inumber);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
/* open it */
|
||||
rc = read_inode(inumber, f);
|
||||
|
||||
#endif /* !LIBSA_FS_SINGLECOMPONENT */
|
||||
|
||||
out:
|
||||
#ifndef UFS_NOSYMLINK
|
||||
#ifndef LIBSA_NO_FS_SYMLINK
|
||||
if (buf)
|
||||
free(buf, fs->fs_bsize);
|
||||
#endif
|
||||
|
@ -578,7 +622,7 @@ out:
|
|||
return (rc);
|
||||
}
|
||||
|
||||
#ifndef UFS_NOCLOSE
|
||||
#ifndef LIBSA_NO_FS_CLOSE
|
||||
int
|
||||
ufs_close(f)
|
||||
struct open_file *f;
|
||||
|
@ -600,7 +644,7 @@ ufs_close(f)
|
|||
free(fp, sizeof(struct file));
|
||||
return (0);
|
||||
}
|
||||
#endif /* !UFS_NOCLOSE */
|
||||
#endif /* !LIBSA_NO_FS_CLOSE */
|
||||
|
||||
/*
|
||||
* Copy a portion of a file into kernel memory.
|
||||
|
@ -646,7 +690,7 @@ ufs_read(f, start, size, resid)
|
|||
/*
|
||||
* Not implemented.
|
||||
*/
|
||||
#ifndef UFS_NOWRITE
|
||||
#ifndef LIBSA_NO_FS_WRITE
|
||||
int
|
||||
ufs_write(f, start, size, resid)
|
||||
struct open_file *f;
|
||||
|
@ -657,8 +701,9 @@ ufs_write(f, start, size, resid)
|
|||
|
||||
return (EROFS);
|
||||
}
|
||||
#endif /* !UFS_NOWRITE */
|
||||
#endif /* !LIBSA_NO_FS_WRITE */
|
||||
|
||||
#ifndef LIBSA_NO_FS_SEEK
|
||||
off_t
|
||||
ufs_seek(f, offset, where)
|
||||
struct open_file *f;
|
||||
|
@ -682,6 +727,7 @@ ufs_seek(f, offset, where)
|
|||
}
|
||||
return (fp->f_seekp);
|
||||
}
|
||||
#endif /* !LIBSA_NO_FS_SEEK */
|
||||
|
||||
int
|
||||
ufs_stat(f, sb)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ustarfs.c,v 1.7 1999/03/26 15:41:38 dbj Exp $ */
|
||||
/* $NetBSD: ustarfs.c,v 1.8 1999/03/31 01:50:26 cgd Exp $ */
|
||||
|
||||
/* [Notice revision 2.2]
|
||||
* Copyright (c) 1997, 1998 Avalon Computer Systems, Inc.
|
||||
|
@ -53,6 +53,13 @@
|
|||
* XXX - stop hardwiring FS metadata for floppies...embed it in a file,
|
||||
* file name, or something. (Remember __SYMDEF? :-)
|
||||
*
|
||||
* XXX Does not currently implement:
|
||||
* XXX
|
||||
* XXX LIBSA_NO_FS_CLOSE
|
||||
* XXX LIBSA_NO_FS_SEEK
|
||||
* XXX LIBSA_NO_FS_WRITE
|
||||
* XXX LIBSA_NO_FS_SYMLINK (does this even make sense?)
|
||||
* XXX LIBSA_FS_SINGLECOMPONENT
|
||||
*/
|
||||
|
||||
#ifdef _STANDALONE
|
||||
|
@ -195,7 +202,7 @@ ustarfs_cylinder_read(f, seek2, forcelabel)
|
|||
} else
|
||||
ustf->uas_offset = 0;
|
||||
while(xferrqst > 0) {
|
||||
e = f->f_dev->dv_strategy(f->f_devdata, F_READ, seek2 / 512,
|
||||
e = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ, seek2 / 512,
|
||||
xferrqst, xferbase, &xfercount);
|
||||
if (e)
|
||||
break;
|
||||
|
@ -395,6 +402,7 @@ ustarfs_open(path, f)
|
|||
return e;
|
||||
}
|
||||
|
||||
#ifndef LIBSA_NO_FS_WRITE
|
||||
int
|
||||
ustarfs_write(f, start, size, resid)
|
||||
struct open_file *f;
|
||||
|
@ -404,7 +412,9 @@ ustarfs_write(f, start, size, resid)
|
|||
{
|
||||
return (EROFS);
|
||||
}
|
||||
#endif /* !LIBSA_NO_FS_WRITE */
|
||||
|
||||
#ifndef LIBSA_NO_FS_SEEK
|
||||
off_t
|
||||
ustarfs_seek(f, offs, whence)
|
||||
struct open_file *f;
|
||||
|
@ -429,6 +439,7 @@ ustarfs_seek(f, offs, whence)
|
|||
}
|
||||
return ustf->uas_fseek;
|
||||
}
|
||||
#endif /* !LIBSA_NO_FS_CLOSE */
|
||||
|
||||
int
|
||||
ustarfs_read(f, start, size, resid)
|
||||
|
@ -499,6 +510,7 @@ ustarfs_stat(f, sb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#ifndef LIBSA_NO_FS_CLOSE
|
||||
int
|
||||
ustarfs_close(f)
|
||||
struct open_file *f;
|
||||
|
@ -509,3 +521,4 @@ ustarfs_close(f)
|
|||
f->f_fsdata = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif /* !LIBSA_NO_FS_CLOSE */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: write.c,v 1.7 1996/06/21 20:29:30 pk Exp $ */
|
||||
/* $NetBSD: write.c,v 1.8 1999/03/31 01:50:26 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
|
@ -76,21 +76,27 @@ write(fd, dest, bcount)
|
|||
register struct open_file *f = &files[fd];
|
||||
size_t resid;
|
||||
|
||||
#if !defined(LIBSA_NO_FD_CHECKING)
|
||||
if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_WRITE)) {
|
||||
errno = EBADF;
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
#if !defined(LIBSA_NO_RAW_ACCESS)
|
||||
if (f->f_flags & F_RAW) {
|
||||
#if !defined(LIBSA_NO_TWIDDLE)
|
||||
twiddle();
|
||||
errno = (f->f_dev->dv_strategy)(f->f_devdata, F_WRITE,
|
||||
#endif
|
||||
errno = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_WRITE,
|
||||
btodb(f->f_offset), bcount, dest, &resid);
|
||||
if (errno)
|
||||
return (-1);
|
||||
f->f_offset += resid;
|
||||
return (resid);
|
||||
}
|
||||
#endif
|
||||
resid = bcount;
|
||||
if ((errno = (f->f_ops->write)(f, dest, bcount, &resid)))
|
||||
if ((errno = FS_WRITE(f->f_ops)(f, dest, bcount, &resid)))
|
||||
return (-1);
|
||||
return (0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue