Some files containing more than one function are split. This reduces the

size of the resulting loader. The read_inode() function now returns the
result of the strategy function instead of success in all cases (ufs.c).
Fixes pr#1817
This commit is contained in:
leo 1996-01-13 22:25:32 +00:00
parent 0d6552d914
commit b7b97847ce
13 changed files with 320 additions and 120 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.10 1995/10/01 06:00:32 phil Exp $
# $NetBSD: Makefile,v 1.11 1996/01/13 22:25:32 leo Exp $
LIB= sa
@ -12,11 +12,11 @@ CFLAGS+=-DSTANDALONE -DCOMPAT_UFS $(DEBUGFLAGS) -I${DIR} -I${DIR}/../..
# stand routines
SRCS+= alloc.c bcopy.c exit.c exec.c getfile.c gets.c globals.c \
printf.c strerror.c
memcpy.c printf.c strerror.c
# io routines
SRCS+= close.c dev.c disklabel.c ioctl.c lseek.c open.c read.c \
stat.c write.c
SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c ioctl.c \
lseek.c open.c nullfs.c read.c stat.c fstat.c write.c
.if !defined(NO_NET)
# network routines

View File

@ -1,4 +1,4 @@
/* $NetBSD: bcopy.c,v 1.5 1995/04/22 13:46:50 cgd Exp $ */
/* $NetBSD: bcopy.c,v 1.6 1996/01/13 22:25:34 leo Exp $ */
/*-
* Copyright (c) 1993
@ -36,6 +36,7 @@
*/
#include <sys/types.h>
#include "stand.h"
/*
* This is designed to be small, not fast.
@ -58,13 +59,3 @@ bcopy(s1, s2, n)
while (n-- > 0)
*t++ = *f++;
}
void *
memcpy(s1, s2, n)
void *s1;
const void *s2;
size_t n;
{
bcopy(s2, s1, n);
return s1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: close.c,v 1.5 1995/09/06 19:53:29 pk Exp $ */
/* $NetBSD: close.c,v 1.6 1996/01/13 22:25:35 leo Exp $ */
/*-
* Copyright (c) 1993
@ -92,14 +92,3 @@ close(fd)
}
return (0);
}
void
closeall()
{
int i;
for (i = 0; i < SOPEN_MAX; i++)
if (files[i].f_flags != 0)
(void)close(i);
}

77
sys/lib/libsa/closeall.c Normal file
View File

@ -0,0 +1,77 @@
/* $NetBSD: closeall.c,v 1.1 1996/01/13 22:25:36 leo Exp $ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* The Mach Operating System project at Carnegie-Mellon University.
*
* 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 the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)close.c 8.1 (Berkeley) 6/11/93
*
*
* Copyright (c) 1989, 1990, 1991 Carnegie Mellon University
* All Rights Reserved.
*
* Author: Alessandro Forin
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include "stand.h"
void
closeall()
{
int i;
for (i = 0; i < SOPEN_MAX; i++)
if (files[i].f_flags != 0)
(void)close(i);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: disklabel.c,v 1.3 1994/10/26 05:44:42 cgd Exp $ */
/* $NetBSD: disklabel.c,v 1.4 1996/01/13 22:25:36 leo Exp $ */
/*-
* Copyright (c) 1993
@ -37,8 +37,7 @@
#include <sys/param.h>
#include <sys/disklabel.h>
int dkcksum __P((struct disklabel *));
#include "stand.h"
char *
getdisklabel(buf, lp)
@ -65,20 +64,3 @@ getdisklabel(buf, lp)
}
return (msg);
}
/*
* Compute checksum for disk label.
*/
int
dkcksum(lp)
register struct disklabel *lp;
{
register u_short *start, *end;
register u_short sum = 0;
start = (u_short *)lp;
end = (u_short *)&lp->d_partitions[lp->d_npartitions];
while (start < end)
sum ^= *start++;
return (sum);
}

57
sys/lib/libsa/dkcksum.c Normal file
View File

@ -0,0 +1,57 @@
/* $NetBSD: dkcksum.c,v 1.1 1996/01/13 22:25:37 leo Exp $ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. 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 the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)disklabel.c 8.1 (Berkeley) 6/11/93
*/
#include <sys/param.h>
#include <sys/disklabel.h>
#include "stand.h"
/*
* Compute checksum for disk label.
*/
int
dkcksum(lp)
register struct disklabel *lp;
{
register u_short *start, *end;
register u_short sum = 0;
start = (u_short *)lp;
end = (u_short *)&lp->d_partitions[lp->d_npartitions];
while (start < end)
sum ^= *start++;
return (sum);
}

60
sys/lib/libsa/fstat.c Normal file
View File

@ -0,0 +1,60 @@
/* $NetBSD: fstat.c,v 1.1 1996/01/13 22:25:38 leo Exp $ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. 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 the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)stat.c 8.1 (Berkeley) 6/11/93
*/
#include "stand.h"
int
fstat(fd, sb)
int fd;
struct stat *sb;
{
register struct open_file *f = &files[fd];
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
errno = EBADF;
return (-1);
}
/* operation not defined on raw devices */
if (f->f_flags & F_RAW) {
errno = EOPNOTSUPP;
return (-1);
}
errno = (f->f_ops->stat)(f, sb);
return (0);
}

105
sys/lib/libsa/nullfs.c Normal file
View File

@ -0,0 +1,105 @@
/* $NetBSD: nullfs.c,v 1.1 1996/01/13 22:25:39 leo Exp $ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* The Mach Operating System project at Carnegie-Mellon University.
*
* 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 the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
*
* @(#)open.c 8.1 (Berkeley) 6/11/93
*
*
* Copyright (c) 1989, 1990, 1991 Carnegie Mellon University
* All Rights Reserved.
*
* Author: Alessandro Forin
*
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
#include "stand.h"
/*
* Null filesystem
*/
int null_open (char *path, struct open_file *f)
{
errno = EIO;
return -1;
}
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)
{
errno = EIO;
return -1;
}
ssize_t null_write (struct open_file *f, void *buf, size_t size, size_t *resid)
{
errno = EIO;
return -1;
}
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)
{
errno = EIO;
return -1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: open.c,v 1.9 1995/09/19 09:16:52 thorpej Exp $ */
/* $NetBSD: open.c,v 1.10 1996/01/13 22:25:41 leo Exp $ */
/*-
* Copyright (c) 1993
@ -65,6 +65,7 @@
*/
#include "stand.h"
struct open_file files[SOPEN_MAX];
/*
@ -123,42 +124,3 @@ err:
errno = error;
return (-1);
}
/*
* Null filesystem
*/
int null_open (char *path, struct open_file *f)
{
errno = EIO;
return -1;
}
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)
{
errno = EIO;
return -1;
}
ssize_t null_write (struct open_file *f, void *buf, size_t size, size_t *resid)
{
errno = EIO;
return -1;
}
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)
{
errno = EIO;
return -1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: stand.h,v 1.12 1995/09/18 21:19:47 pk Exp $ */
/* $NetBSD: stand.h,v 1.13 1996/01/13 22:25:42 leo Exp $ */
/*-
* Copyright (c) 1993
@ -63,6 +63,7 @@ struct fs_ops {
};
extern struct fs_ops file_system[];
extern int nfsys;
/* where values for lseek(2) */
#define SEEK_SET 0 /* set file offset to offset */
@ -93,7 +94,6 @@ struct open_file {
#define SOPEN_MAX 4
extern struct open_file files[];
extern int nfsys;
/* f_flags values */
#define F_READ 0x0001 /* file opened for reading */
@ -111,18 +111,20 @@ void *alloc __P((unsigned int));
void free __P((void *, unsigned int));
struct disklabel;
char *getdisklabel __P((const char *, struct disklabel *));
int dkcksum __P((struct disklabel *));
void printf __P((const char *, ...));
void sprintf __P((char *, const char *, ...));
void twiddle __P((void));
void gets __P((char *));
__dead void panic __P((const char *, ...)) __attribute__((noreturn));
__dead void _rtt __P((void)) __attribute__((noreturn));
__dead void _rtt __P((void)) __attribute__((noreturn));
void bcopy __P((const void *, void *, size_t));
int getchar __P((void));
void *memcpy __P((void *, const void *, size_t));
void exec __P((char *, char *, int));
int open __P((const char *, int));
int close __P((int));
void closeall __P((void));
ssize_t read __P((int, void *, size_t));
ssize_t write __P((int, void *, size_t));

View File

@ -1,4 +1,4 @@
/* $NetBSD: stat.c,v 1.3 1994/10/26 05:45:07 cgd Exp $ */
/* $NetBSD: stat.c,v 1.4 1996/01/13 22:25:43 leo Exp $ */
/*-
* Copyright (c) 1993
@ -37,28 +37,6 @@
#include "stand.h"
int
fstat(fd, sb)
int fd;
struct stat *sb;
{
register struct open_file *f = &files[fd];
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
errno = EBADF;
return (-1);
}
/* operation not defined on raw devices */
if (f->f_flags & F_RAW) {
errno = EOPNOTSUPP;
return (-1);
}
errno = (f->f_ops->stat)(f, sb);
return (0);
}
int
stat(str, sb)
const char *str;

View File

@ -1,4 +1,4 @@
/* $NetBSD: strerror.c,v 1.8 1995/09/17 00:49:47 pk Exp $ */
/* $NetBSD: strerror.c,v 1.9 1996/01/13 22:25:43 leo Exp $ */
/*-
* Copyright (c) 1993
@ -37,9 +37,6 @@
#include "saerrno.h"
#include "stand.h"
size_t strlen __P((const char *)); /* XXX */
char *strcpy __P((char *, const char *)); /* XXX */
char *
strerror(err)
int err;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ufs.c,v 1.13 1995/10/20 00:42:21 cgd Exp $ */
/* $NetBSD: ufs.c,v 1.14 1996/01/13 22:25:44 leo Exp $ */
/*-
* Copyright (c) 1993
@ -152,7 +152,7 @@ read_inode(inumber, f)
}
out:
free(buf, fs->fs_bsize);
return (0);
return (rc);
}
/*