diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-12-07 03:27:47 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-12-07 03:27:47 +0000 |
commit | 3358712e68d0e01b1964e9fffbc9ce7a573e6dd1 (patch) | |
tree | c7be0607bd88620a8f8840a17fab047fb34a1e93 | |
parent | d7fe77d409b59d5cd7ab6c78c920bdc9a41dd2c2 (diff) |
shrink bootblocks by splitting libsa contents into more files. from
waldi@moacs.indiv.nl.net, netbsd pr#1817
-rw-r--r-- | sys/lib/libsa/Makefile | 4 | ||||
-rw-r--r-- | sys/lib/libsa/bcopy.c | 1 | ||||
-rw-r--r-- | sys/lib/libsa/close.c | 11 | ||||
-rw-r--r-- | sys/lib/libsa/closeall.c | 77 | ||||
-rw-r--r-- | sys/lib/libsa/disklabel.c | 20 | ||||
-rw-r--r-- | sys/lib/libsa/dkcksum.c | 57 | ||||
-rw-r--r-- | sys/lib/libsa/fstat.c | 60 | ||||
-rw-r--r-- | sys/lib/libsa/nullfs.c | 105 | ||||
-rw-r--r-- | sys/lib/libsa/open.c | 42 | ||||
-rw-r--r-- | sys/lib/libsa/stand.h | 7 | ||||
-rw-r--r-- | sys/lib/libsa/stat.c | 22 | ||||
-rw-r--r-- | sys/lib/libsa/strerror.c | 3 | ||||
-rw-r--r-- | sys/lib/libsa/ufs.c | 2 |
13 files changed, 311 insertions, 100 deletions
diff --git a/sys/lib/libsa/Makefile b/sys/lib/libsa/Makefile index 7cd73ed1884..f6a56fa2d42 100644 --- a/sys/lib/libsa/Makefile +++ b/sys/lib/libsa/Makefile @@ -15,8 +15,8 @@ SRCS+= alloc.c bcopy.c exit.c exec.c getfile.c gets.c globals.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 diff --git a/sys/lib/libsa/bcopy.c b/sys/lib/libsa/bcopy.c index 3cf86106a32..3b670da7a86 100644 --- a/sys/lib/libsa/bcopy.c +++ b/sys/lib/libsa/bcopy.c @@ -36,6 +36,7 @@ */ #include <sys/types.h> +#include "stand.h" /* * This is designed to be small, not fast. diff --git a/sys/lib/libsa/close.c b/sys/lib/libsa/close.c index ffcef14f05c..388309b47a7 100644 --- a/sys/lib/libsa/close.c +++ b/sys/lib/libsa/close.c @@ -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); -} diff --git a/sys/lib/libsa/closeall.c b/sys/lib/libsa/closeall.c new file mode 100644 index 00000000000..b55e4d87c07 --- /dev/null +++ b/sys/lib/libsa/closeall.c @@ -0,0 +1,77 @@ +/* $NetBSD: close.c,v 1.5 1995/09/06 19:53:29 pk 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); +} diff --git a/sys/lib/libsa/disklabel.c b/sys/lib/libsa/disklabel.c index 5c1a5199eac..81b655d8375 100644 --- a/sys/lib/libsa/disklabel.c +++ b/sys/lib/libsa/disklabel.c @@ -37,9 +37,8 @@ #include <sys/param.h> #include <sys/disklabel.h> +#include "stand.h" -int dkcksum __P((struct disklabel *)); - char * getdisklabel(buf, lp) const char *buf; @@ -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); -} diff --git a/sys/lib/libsa/dkcksum.c b/sys/lib/libsa/dkcksum.c new file mode 100644 index 00000000000..75986afebd6 --- /dev/null +++ b/sys/lib/libsa/dkcksum.c @@ -0,0 +1,57 @@ +/* $NetBSD: disklabel.c,v 1.3 1994/10/26 05:44:42 cgd 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); +} diff --git a/sys/lib/libsa/fstat.c b/sys/lib/libsa/fstat.c new file mode 100644 index 00000000000..76b999d56a1 --- /dev/null +++ b/sys/lib/libsa/fstat.c @@ -0,0 +1,60 @@ +/* $NetBSD: stat.c,v 1.3 1994/10/26 05:45:07 cgd 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); +} diff --git a/sys/lib/libsa/nullfs.c b/sys/lib/libsa/nullfs.c new file mode 100644 index 00000000000..f69de86855b --- /dev/null +++ b/sys/lib/libsa/nullfs.c @@ -0,0 +1,105 @@ +/* $NetBSD: open.c,v 1.9 1995/09/19 09:16:52 thorpej 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; +} diff --git a/sys/lib/libsa/open.c b/sys/lib/libsa/open.c index 982f4eaf10e..8532db7f910 100644 --- a/sys/lib/libsa/open.c +++ b/sys/lib/libsa/open.c @@ -65,7 +65,10 @@ */ #include "stand.h" + +#ifndef atari struct open_file files[SOPEN_MAX]; +#endif /* * File primitives proper @@ -123,42 +126,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; -} - diff --git a/sys/lib/libsa/stand.h b/sys/lib/libsa/stand.h index f537d2d8223..f987bc84fb2 100644 --- a/sys/lib/libsa/stand.h +++ b/sys/lib/libsa/stand.h @@ -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,19 @@ 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 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)); diff --git a/sys/lib/libsa/stat.c b/sys/lib/libsa/stat.c index 9e2cbca00f6..6177f1cf948 100644 --- a/sys/lib/libsa/stat.c +++ b/sys/lib/libsa/stat.c @@ -38,28 +38,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; struct stat *sb; diff --git a/sys/lib/libsa/strerror.c b/sys/lib/libsa/strerror.c index e84c0ea357f..a9fdbaff7d9 100644 --- a/sys/lib/libsa/strerror.c +++ b/sys/lib/libsa/strerror.c @@ -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; diff --git a/sys/lib/libsa/ufs.c b/sys/lib/libsa/ufs.c index 1f9c608e80a..ccba9547f1e 100644 --- a/sys/lib/libsa/ufs.c +++ b/sys/lib/libsa/ufs.c @@ -147,7 +147,7 @@ read_inode(inumber, f) } out: free(buf, fs->fs_bsize); - return (0); + return (rc); } /* |