mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-30 04:15:06 +01:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95b66175a3 |
No files matched your search
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1998 John Birrell <[email protected]>.
|
||||
* 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 John Birrell.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
|
||||
*
|
||||
* $Id: _spinlock_stub.c,v 1.2 1998/04/29 09:02:16 jb Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Don't build these stubs into libc_r: */
|
||||
#ifndef _THREAD_SAFE
|
||||
#include "spinlock.h"
|
||||
|
||||
/*
|
||||
* Declare weak references in case the application is not linked
|
||||
* with libpthread.
|
||||
*/
|
||||
#pragma weak _spinlock=_spinlock_stub
|
||||
#pragma weak _spinlock_debug=_spinlock_debug_stub
|
||||
|
||||
/*
|
||||
* This function is a stub for the spinlock function in libpthread.
|
||||
*/
|
||||
void
|
||||
_spinlock_stub(spinlock_t *lck)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is a stub for the debug spinlock function in libpthread.
|
||||
*/
|
||||
void
|
||||
_spinlock_debug_stub(spinlock_t *lck, char *fname, int lineno)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1998 John Birrell <[email protected]>.
|
||||
* 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 John Birrell.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
|
||||
*
|
||||
* $Id: libc_private.h,v 1.1 1998/04/11 06:57:33 jb Exp $
|
||||
*
|
||||
* Private definitions for libc, libc_r and libpthread.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LIBC_PRIVATE_H_
|
||||
#define _LIBC_PRIVATE_H_
|
||||
|
||||
/*
|
||||
* This global flag is non-zero when a process has created one
|
||||
* or more threads. It is used to avoid calling locking functions
|
||||
* when they are not required.
|
||||
*/
|
||||
extern int __isthreaded;
|
||||
|
||||
/*
|
||||
* File lock contention is difficult to diagnose without knowing
|
||||
* where locks were set. Allow a debug library to be built which
|
||||
* records the source file and line number of each lock call.
|
||||
*/
|
||||
#ifdef _FLOCK_DEBUG
|
||||
#define _FLOCKFILE(x) _flockfile_debug(x, __FILE__, __LINE__)
|
||||
#else
|
||||
#define _FLOCKFILE(x) flockfile(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros for locking and unlocking FILEs. These test if the
|
||||
* process is threaded to avoid locking when not required.
|
||||
*/
|
||||
#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp)
|
||||
#define FUNLOCKFILE(fp) if (__isthreaded) funlockfile(fp)
|
||||
|
||||
#endif /* _LIBC_PRIVATE_H_ */
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1998 John Birrell <[email protected]>.
|
||||
* 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 John Birrell.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
|
||||
*
|
||||
* $Id: spinlock.h,v 1.2 1998/05/05 21:46:30 jb Exp $
|
||||
*
|
||||
* Lock definitions used in both libc and libpthread.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SPINLOCK_H_
|
||||
#define _SPINLOCK_H_
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* Lock structure with room for debugging information.
|
||||
*/
|
||||
typedef struct {
|
||||
volatile long access_lock;
|
||||
volatile long lock_owner;
|
||||
volatile char *fname;
|
||||
volatile int lineno;
|
||||
} spinlock_t;
|
||||
|
||||
#define _SPINLOCK_INITIALIZER { 0, 0, 0, 0 }
|
||||
|
||||
#define _SPINUNLOCK(_lck) (_lck)->access_lock = 0
|
||||
#ifdef _LOCK_DEBUG
|
||||
#define _SPINLOCK(_lck) _spinlock_debug(_lck, __FILE__, __LINE__)
|
||||
#else
|
||||
#define _SPINLOCK(_lck) _spinlock(_lck)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Thread function prototype definitions:
|
||||
*/
|
||||
__BEGIN_DECLS
|
||||
long _atomic_lock __P((volatile long *));
|
||||
void _spinlock __P((spinlock_t *));
|
||||
void _spinlock_debug __P((spinlock_t *, char *, int));
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _SPINLOCK_H_ */
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1998 John Birrell <[email protected]>.
|
||||
* 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 John Birrell.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
|
||||
*
|
||||
* $Id: _flock_stub.c,v 1.1 1998/04/11 07:40:41 jb Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Don't build this in libc_r, just libc: */
|
||||
#ifndef _THREAD_SAFE
|
||||
/*
|
||||
* Declare weak references in case the application is not linked
|
||||
* with libpthread.
|
||||
*/
|
||||
#pragma weak flockfile=_flockfile_stub
|
||||
#pragma weak _flockfile_debug=_flockfile_debug_stub
|
||||
#pragma weak ftrylockfile=_ftrylockfile_stub
|
||||
#pragma weak funlockfile=_funlockfile_stub
|
||||
|
||||
/*
|
||||
* This function is a stub for the _flockfile function in libpthread.
|
||||
*/
|
||||
void
|
||||
_flockfile_stub(FILE *fp)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is a stub for the _flockfile_debug function in libpthread.
|
||||
*/
|
||||
void
|
||||
_flockfile_debug_stub(FILE *fp, char *fname, int lineno)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is a stub for the _ftrylockfile function in libpthread.
|
||||
*/
|
||||
int
|
||||
_ftrylockfile_stub(FILE *fp)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is a stub for the _funlockfile function in libpthread.
|
||||
*/
|
||||
void
|
||||
_funlockfile_stub(FILE *fp)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1998 John Birrell <[email protected]>
|
||||
* 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 John Birrell.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
|
||||
*
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef _THREAD_SAFE
|
||||
#include <pthread.h>
|
||||
#include "pthread_private.h"
|
||||
|
||||
ssize_t
|
||||
recvmsg(int fd, struct msghdr *msg, int flags)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if ((ret = _FD_LOCK(fd, FD_READ, NULL)) == 0) {
|
||||
while ((ret = _thread_sys_recvmsg(fd, msg, flags)) < 0) {
|
||||
if (!(_thread_fd_table[fd]->flags & O_NONBLOCK) && ((errno == EWOULDBLOCK) || (errno == EAGAIN))) {
|
||||
_thread_run->data.fd.fd = fd;
|
||||
|
||||
/* Set the timeout: */
|
||||
_thread_kern_set_timeout(NULL);
|
||||
_thread_run->interrupted = 0;
|
||||
_thread_kern_sched_state(PS_FDR_WAIT, __FILE__, __LINE__);
|
||||
|
||||
/* Check if the wait was interrupted: */
|
||||
if (_thread_run->interrupted) {
|
||||
/* Return an error status: */
|
||||
errno = EINTR;
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_FD_UNLOCK(fd, FD_READ);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
#endif
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1998 John Birrell <[email protected]>
|
||||
* 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 John Birrell.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
|
||||
*
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef _THREAD_SAFE
|
||||
#include <pthread.h>
|
||||
#include "pthread_private.h"
|
||||
|
||||
ssize_t
|
||||
sendmsg(int fd, const struct msghdr *msg, int flags)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if ((ret = _FD_LOCK(fd, FD_WRITE, NULL)) == 0) {
|
||||
while ((ret = _thread_sys_sendmsg(fd, msg, flags)) < 0) {
|
||||
if (!(_thread_fd_table[fd]->flags & O_NONBLOCK) && ((errno == EWOULDBLOCK) || (errno == EAGAIN))) {
|
||||
_thread_run->data.fd.fd = fd;
|
||||
|
||||
/* Set the timeout: */
|
||||
_thread_kern_set_timeout(NULL);
|
||||
_thread_run->interrupted = 0;
|
||||
_thread_kern_sched_state(PS_FDW_WAIT, __FILE__, __LINE__);
|
||||
|
||||
/* Check if the operation was interrupted: */
|
||||
if (_thread_run->interrupted) {
|
||||
errno = EINTR;
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_FD_UNLOCK(fd, FD_WRITE);
|
||||
}
|
||||
return (ret);
|
||||
}
|
||||
#endif
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1997 John Birrell <[email protected]>.
|
||||
* 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 John Birrell.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JOHN BIRRELL 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.
|
||||
*
|
||||
* $Id: uthread_spinlock.c,v 1.3 1998/06/06 07:27:06 jb Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <string.h>
|
||||
#include "pthread_private.h"
|
||||
|
||||
extern char *__progname;
|
||||
|
||||
/*
|
||||
* Lock a location for the running thread. Yield to allow other
|
||||
* threads to run if this thread is blocked because the lock is
|
||||
* not available. Note that this function does not sleep. It
|
||||
* assumes that the lock will be available very soon.
|
||||
*/
|
||||
void
|
||||
_spinlock(spinlock_t *lck)
|
||||
{
|
||||
/*
|
||||
* Try to grab the lock and loop if another thread grabs
|
||||
* it before we do.
|
||||
*/
|
||||
while(_atomic_lock(&lck->access_lock)) {
|
||||
/* Give up the time slice: */
|
||||
sched_yield();
|
||||
|
||||
/* Check if already locked by the running thread: */
|
||||
if (lck->lock_owner == (long) _thread_run)
|
||||
return;
|
||||
}
|
||||
|
||||
/* The running thread now owns the lock: */
|
||||
lck->lock_owner = (long) _thread_run;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lock a location for the running thread. Yield to allow other
|
||||
* threads to run if this thread is blocked because the lock is
|
||||
* not available. Note that this function does not sleep. It
|
||||
* assumes that the lock will be available very soon.
|
||||
*
|
||||
* This function checks if the running thread has already locked the
|
||||
* location, warns if this occurs and creates a thread dump before
|
||||
* returning.
|
||||
*/
|
||||
void
|
||||
_spinlock_debug(spinlock_t *lck, char *fname, int lineno)
|
||||
{
|
||||
/*
|
||||
* Try to grab the lock and loop if another thread grabs
|
||||
* it before we do.
|
||||
*/
|
||||
while(_atomic_lock(&lck->access_lock)) {
|
||||
/* Give up the time slice: */
|
||||
sched_yield();
|
||||
|
||||
/* Check if already locked by the running thread: */
|
||||
if (lck->lock_owner == (long) _thread_run) {
|
||||
char str[256];
|
||||
snprintf(str, sizeof(str), "%s - Warning: Thread %p attempted to lock %p from %s (%d) which it had already locked in %s (%d)\n", __progname, _thread_run, lck, fname, lineno, lck->fname, lck->lineno);
|
||||
_thread_sys_write(2,str,strlen(str));
|
||||
|
||||
/* Create a thread dump to help debug this problem: */
|
||||
_thread_dump_info();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* The running thread now owns the lock: */
|
||||
lck->lock_owner = (long) _thread_run;
|
||||
lck->fname = fname;
|
||||
lck->lineno = lineno;
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
* This is probably the last program in the `sysinstall' line - the next
|
||||
* generation being essentially a complete rewrite.
|
||||
*
|
||||
* $Id: index.c,v 1.38.2.14 1998/03/23 05:49:45 jkh Exp $
|
||||
* $Id: index.c,v 1.38.2.16 1998/07/23 19:33:05 jkh Exp $
|
||||
*
|
||||
* Copyright (c) 1995
|
||||
* Jordan Hubbard. All rights reserved.
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "sysinstall.h"
|
||||
|
||||
/* Macros and magic values */
|
||||
#define MAX_MENU 12
|
||||
#define MAX_MENU 8
|
||||
#define _MAX_DESC 55
|
||||
|
||||
static int index_extract_one(Device *dev, PkgNodePtr top, PkgNodePtr who, Boolean depended);
|
||||
@@ -60,7 +60,10 @@ static char *descrs[] = {
|
||||
"already marked, it will be unmarked or deleted (if installed).\n"
|
||||
"To search for a package by name, press ESC. To select a category,\n"
|
||||
"press RETURN. NOTE: The All category selection creates a very large\n"
|
||||
"submenu. If you select it, please be patient while it comes up.",
|
||||
"submenu. If you select it, please be patient while it comes up.\n\n"
|
||||
"If a package you're looking for is not listed here and you are\n"
|
||||
"installing from CD, please check the other CD(s) after installation\n"
|
||||
"since the sheer number of packages means they no longer all fit on one.\n",
|
||||
"Package Targets", "These are the packages you've selected for extraction.\n\n"
|
||||
"If you're sure of these choices, select OK.\n"
|
||||
"If not, select Cancel to go back to the package selection menu.\n",
|
||||
@@ -100,6 +103,7 @@ static char *descrs[] = {
|
||||
"networking", "Networking utilities.",
|
||||
"news", "USENET News support software.",
|
||||
"numeric", "Mathematical computation software.",
|
||||
"offix", "An office automation suite of sorts.",
|
||||
"orphans", "Packages without a home elsewhere.",
|
||||
"perl5", "Utilities/modules for the PERL5 language..",
|
||||
"pilot", "Software support for the USR Palm Pilot(tm).",
|
||||
@@ -107,6 +111,7 @@ static char *descrs[] = {
|
||||
"print", "Utilities for dealing with printing.",
|
||||
"printing", "Utilities for dealing with printing.",
|
||||
"programming", "Software development utilities and libraries.",
|
||||
"python", "Software related to the python language.",
|
||||
"russian", "Ported software for the Russian market.",
|
||||
"security", "System security software.",
|
||||
"shells", "Various shells (tcsh, bash, etc).",
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# $Id$
|
||||
|
||||
PROG= newfs_msdos
|
||||
MAN8= newfs_msdos.8
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
@@ -1,922 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1998 Robert Nordier
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id: newfs_msdos.c,v 1.3 1998/07/16 12:24:51 rnordier Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/diskslice.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <sys/mount.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define MAXU16 0xffff /* maximum unsigned 16-bit quantity */
|
||||
#define BPN 4 /* bits per nibble */
|
||||
#define NPB 2 /* nibbles per byte */
|
||||
|
||||
#define DOSMAGIC 0xaa55 /* DOS magic number */
|
||||
#define MINBPS 128 /* minimum bytes per sector */
|
||||
#define MAXSPC 128 /* maximum sectors per cluster */
|
||||
#define MAXNFT 16 /* maximum number of FATs */
|
||||
#define DEFBLK 4096 /* default block size */
|
||||
#define DEFBLK16 2048 /* default block size FAT16 */
|
||||
#define DEFRDE 512 /* default root directory entries */
|
||||
#define RESFTE 2 /* reserved FAT entries */
|
||||
#define MINCLS12 1 /* minimum FAT12 clusters */
|
||||
#define MINCLS16 0x1000 /* minimum FAT16 clusters */
|
||||
#define MINCLS32 2 /* minimum FAT32 clusters */
|
||||
#define MAXCLS12 0xfed /* maximum FAT12 clusters */
|
||||
#define MAXCLS16 0xfff5 /* maximum FAT16 clusters */
|
||||
#define MAXCLS32 0xffffff5 /* maximum FAT32 clusters */
|
||||
|
||||
#define mincls(fat) ((fat) == 12 ? MINCLS12 : \
|
||||
(fat) == 16 ? MINCLS16 : \
|
||||
MINCLS32)
|
||||
|
||||
#define maxcls(fat) ((fat) == 12 ? MAXCLS12 : \
|
||||
(fat) == 16 ? MAXCLS16 : \
|
||||
MAXCLS32)
|
||||
|
||||
#define mk1(p, x) \
|
||||
(p) = (u_int8_t)(x)
|
||||
|
||||
#define mk2(p, x) \
|
||||
(p)[0] = (u_int8_t)(x), \
|
||||
(p)[1] = (u_int8_t)((x) >> 010)
|
||||
|
||||
#define mk4(p, x) \
|
||||
(p)[0] = (u_int8_t)(x), \
|
||||
(p)[1] = (u_int8_t)((x) >> 010), \
|
||||
(p)[2] = (u_int8_t)((x) >> 020), \
|
||||
(p)[3] = (u_int8_t)((x) >> 030)
|
||||
|
||||
#define argto1(arg, lo, msg) argtou(arg, lo, 0xff, msg)
|
||||
#define argto2(arg, lo, msg) argtou(arg, lo, 0xffff, msg)
|
||||
#define argto4(arg, lo, msg) argtou(arg, lo, 0xffffffff, msg)
|
||||
#define argtox(arg, lo, msg) argtou(arg, lo, UINT_MAX, msg)
|
||||
|
||||
struct bs {
|
||||
u_int8_t jmp[3]; /* bootstrap entry point */
|
||||
u_int8_t oem[8]; /* OEM name and version */
|
||||
};
|
||||
|
||||
struct bsbpb {
|
||||
u_int8_t bps[2]; /* bytes per sector */
|
||||
u_int8_t spc; /* sectors per cluster */
|
||||
u_int8_t res[2]; /* reserved sectors */
|
||||
u_int8_t nft; /* number of FATs */
|
||||
u_int8_t rde[2]; /* root directory entries */
|
||||
u_int8_t sec[2]; /* total sectors */
|
||||
u_int8_t mid; /* media descriptor */
|
||||
u_int8_t spf[2]; /* sectors per FAT */
|
||||
u_int8_t spt[2]; /* sectors per track */
|
||||
u_int8_t hds[2]; /* drive heads */
|
||||
u_int8_t hid[4]; /* hidden sectors */
|
||||
u_int8_t bsec[4]; /* big total sectors */
|
||||
};
|
||||
|
||||
struct bsxbpb {
|
||||
u_int8_t bspf[4]; /* big sectors per FAT */
|
||||
u_int8_t xflg[2]; /* FAT control flags */
|
||||
u_int8_t vers[2]; /* file system version */
|
||||
u_int8_t rdcl[4]; /* root directory start cluster */
|
||||
u_int8_t infs[2]; /* file system info sector */
|
||||
u_int8_t bkbs[2]; /* backup boot sector */
|
||||
u_int8_t rsvd[12]; /* reserved */
|
||||
};
|
||||
|
||||
struct bsx {
|
||||
u_int8_t drv; /* drive number */
|
||||
u_int8_t rsvd; /* reserved */
|
||||
u_int8_t sig; /* extended boot signature */
|
||||
u_int8_t volid[4]; /* volume ID number */
|
||||
u_int8_t label[11]; /* volume label */
|
||||
u_int8_t type[8]; /* file system type */
|
||||
};
|
||||
|
||||
struct de {
|
||||
u_int8_t namext[11]; /* name and extension */
|
||||
u_int8_t attr; /* attributes */
|
||||
u_int8_t rsvd[10]; /* reserved */
|
||||
u_int8_t time[2]; /* creation time */
|
||||
u_int8_t date[2]; /* creation date */
|
||||
u_int8_t clus[2]; /* starting cluster */
|
||||
u_int8_t size[4]; /* size */
|
||||
};
|
||||
|
||||
struct bpb {
|
||||
u_int bps; /* bytes per sector */
|
||||
u_int spc; /* sectors per cluster */
|
||||
u_int res; /* reserved sectors */
|
||||
u_int nft; /* number of FATs */
|
||||
u_int rde; /* root directory entries */
|
||||
u_int sec; /* total sectors */
|
||||
u_int mid; /* media descriptor */
|
||||
u_int spf; /* sectors per FAT */
|
||||
u_int spt; /* sectors per track */
|
||||
u_int hds; /* drive heads */
|
||||
u_int hid; /* hidden sectors */
|
||||
u_int bsec; /* big total sectors */
|
||||
u_int bspf; /* big sectors per FAT */
|
||||
u_int rdcl; /* root directory start cluster */
|
||||
u_int infs; /* file system info sector */
|
||||
u_int bkbs; /* backup boot sector */
|
||||
};
|
||||
|
||||
static struct {
|
||||
const char *name;
|
||||
struct bpb bpb;
|
||||
} stdfmt[] = {
|
||||
{"160", {512, 1, 1, 2, 64, 320, 0xfe, 1, 8, 1}},
|
||||
{"180", {512, 1, 1, 2, 64, 360, 0xfc, 2, 9, 1}},
|
||||
{"320", {512, 2, 1, 2, 112, 640, 0xff, 1, 8, 2}},
|
||||
{"360", {512, 2, 1, 2, 112, 720, 0xfd, 2, 9, 2}},
|
||||
{"720", {512, 2, 1, 2, 112, 1440, 0xf9, 3, 9, 2}},
|
||||
{"1200", {512, 1, 1, 2, 224, 2400, 0xf9, 7, 15, 2}},
|
||||
{"1440", {512, 1, 1, 2, 224, 2880, 0xf0, 9, 18, 2}},
|
||||
{"2880", {512, 2, 1, 2, 240, 5760, 0xf0, 9, 36, 2}}
|
||||
};
|
||||
|
||||
static u_int8_t bootcode[] = {
|
||||
0xfa, /* cli */
|
||||
0x31, 0xc0, /* xor ax,ax */
|
||||
0x8e, 0xd0, /* mov ss,ax */
|
||||
0xbc, 0x00, 0x7c, /* mov sp,7c00h */
|
||||
0xfb, /* sti */
|
||||
0x8e, 0xd8, /* mov ds,ax */
|
||||
0xe8, 0x00, 0x00, /* call $ + 3 */
|
||||
0x5e, /* pop si */
|
||||
0x83, 0xc6, 0x19, /* add si,+19h */
|
||||
0xbb, 0x07, 0x00, /* mov bx,0007h */
|
||||
0xfc, /* cld */
|
||||
0xac, /* lodsb */
|
||||
0x84, 0xc0, /* test al,al */
|
||||
0x74, 0x06, /* jz $ + 8 */
|
||||
0xb4, 0x0e, /* mov ah,0eh */
|
||||
0xcd, 0x10, /* int 10h */
|
||||
0xeb, 0xf5, /* jmp $ - 9 */
|
||||
0x30, 0xe4, /* xor ah,ah */
|
||||
0xcd, 0x16, /* int 16h */
|
||||
0xcd, 0x19, /* int 19h */
|
||||
0x0d, 0x0a,
|
||||
'N', 'o', 'n', '-', 's', 'y', 's', 't',
|
||||
'e', 'm', ' ', 'd', 'i', 's', 'k',
|
||||
0x0d, 0x0a,
|
||||
'P', 'r', 'e', 's', 's', ' ', 'a', 'n',
|
||||
'y', ' ', 'k', 'e', 'y', ' ', 't', 'o',
|
||||
' ', 'r', 'e', 'b', 'o', 'o', 't',
|
||||
0x0d, 0x0a,
|
||||
0
|
||||
};
|
||||
|
||||
static void check_mounted(const char *, mode_t);
|
||||
static void getstdfmt(const char *, struct bpb *);
|
||||
static void getdiskinfo(int, const char *, const char *, int,
|
||||
struct bpb *);
|
||||
static void print_bpb(struct bpb *);
|
||||
static u_int ckgeom(const char *, u_int, const char *);
|
||||
static u_int argtou(const char *, u_int, u_int, const char *);
|
||||
static int oklabel(const char *);
|
||||
static void mklabel(u_int8_t *, const char *);
|
||||
static void setstr(u_int8_t *, const char *, size_t);
|
||||
static void usage(void);
|
||||
|
||||
/*
|
||||
* Construct a FAT12, FAT16, or FAT32 file system.
|
||||
*/
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
static char opts[] = "NB:F:I:L:O:S:a:b:c:e:f:h:i:k:m:n:o:r:s:u:";
|
||||
static const char *opt_B, *opt_L, *opt_O, *opt_f;
|
||||
static u_int opt_F, opt_I, opt_S, opt_a, opt_b, opt_c, opt_e;
|
||||
static u_int opt_h, opt_i, opt_k, opt_m, opt_n, opt_o, opt_r;
|
||||
static u_int opt_s, opt_u;
|
||||
static int opt_N;
|
||||
static int Iflag, mflag, oflag;
|
||||
char buf[MAXPATHLEN];
|
||||
struct stat sb;
|
||||
struct timeval tv;
|
||||
struct bpb bpb;
|
||||
struct tm *tm;
|
||||
struct bs *bs;
|
||||
struct bsbpb *bsbpb;
|
||||
struct bsxbpb *bsxbpb;
|
||||
struct bsx *bsx;
|
||||
struct de *de;
|
||||
u_int8_t *img;
|
||||
const char *fname, *dtype, *bname;
|
||||
ssize_t n;
|
||||
u_int fat, bss, rds, cls, dir, lsn, x, x1, x2;
|
||||
int ch, fd, fd1;
|
||||
|
||||
while ((ch = getopt(argc, argv, opts)) != -1)
|
||||
switch (ch) {
|
||||
case 'N':
|
||||
opt_N = 1;
|
||||
break;
|
||||
case 'B':
|
||||
opt_B = optarg;
|
||||
break;
|
||||
case 'F':
|
||||
if (strcmp(optarg, "12") &&
|
||||
strcmp(optarg, "16") &&
|
||||
strcmp(optarg, "32"))
|
||||
errx(1, "%s: bad FAT type", optarg);
|
||||
opt_F = atoi(optarg);
|
||||
break;
|
||||
case 'I':
|
||||
opt_I = argto4(optarg, 0, "volume ID");
|
||||
Iflag = 1;
|
||||
break;
|
||||
case 'L':
|
||||
if (!oklabel(optarg))
|
||||
errx(1, "%s: bad volume label", optarg);
|
||||
opt_L = optarg;
|
||||
break;
|
||||
case 'O':
|
||||
if (strlen(optarg) > 8)
|
||||
errx(1, "%s: bad OEM string", optarg);
|
||||
opt_O = optarg;
|
||||
break;
|
||||
case 'S':
|
||||
opt_S = argto2(optarg, 1, "bytes/sector");
|
||||
break;
|
||||
case 'a':
|
||||
opt_a = argto4(optarg, 1, "sectors/FAT");
|
||||
break;
|
||||
case 'b':
|
||||
opt_b = argtox(optarg, 1, "block size");
|
||||
opt_c = 0;
|
||||
break;
|
||||
case 'c':
|
||||
opt_c = argto1(optarg, 1, "sectors/cluster");
|
||||
opt_b = 0;
|
||||
break;
|
||||
case 'e':
|
||||
opt_e = argto2(optarg, 1, "directory entries");
|
||||
break;
|
||||
case 'f':
|
||||
opt_f = optarg;
|
||||
break;
|
||||
case 'h':
|
||||
opt_h = argto2(optarg, 1, "drive heads");
|
||||
break;
|
||||
case 'i':
|
||||
opt_i = argto2(optarg, 1, "info sector");
|
||||
break;
|
||||
case 'k':
|
||||
opt_k = argto2(optarg, 1, "backup sector");
|
||||
break;
|
||||
case 'm':
|
||||
opt_m = argto1(optarg, 0, "media descriptor");
|
||||
mflag = 1;
|
||||
break;
|
||||
case 'n':
|
||||
opt_n = argto1(optarg, 1, "number of FATs");
|
||||
break;
|
||||
case 'o':
|
||||
opt_o = argto4(optarg, 0, "hidden sectors");
|
||||
oflag = 1;
|
||||
break;
|
||||
case 'r':
|
||||
opt_r = argto2(optarg, 1, "reserved sectors");
|
||||
break;
|
||||
case 's':
|
||||
opt_s = argto4(optarg, 1, "file system size");
|
||||
break;
|
||||
case 'u':
|
||||
opt_u = argto2(optarg, 1, "sectors/track");
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (argc < 1 || argc > 2)
|
||||
usage();
|
||||
fname = *argv++;
|
||||
if (!strchr(fname, '/')) {
|
||||
snprintf(buf, sizeof(buf), "%sr%s", _PATH_DEV, fname);
|
||||
if (stat(buf, &sb))
|
||||
snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname);
|
||||
if (!(fname = strdup(buf)))
|
||||
err(1, NULL);
|
||||
}
|
||||
dtype = *argv;
|
||||
if ((fd = open(fname, opt_N ? O_RDONLY : O_RDWR)) == -1 ||
|
||||
fstat(fd, &sb))
|
||||
err(1, "%s", fname);
|
||||
if (!opt_N)
|
||||
check_mounted(fname, sb.st_mode);
|
||||
if (!S_ISCHR(sb.st_mode))
|
||||
warnx("warning: %s is not a character device", fname);
|
||||
memset(&bpb, 0, sizeof(bpb));
|
||||
if (opt_f) {
|
||||
getstdfmt(opt_f, &bpb);
|
||||
bpb.bsec = bpb.sec;
|
||||
bpb.sec = 0;
|
||||
bpb.bspf = bpb.spf;
|
||||
bpb.spf = 0;
|
||||
}
|
||||
if (opt_h)
|
||||
bpb.hds = opt_h;
|
||||
if (opt_u)
|
||||
bpb.spt = opt_u;
|
||||
if (opt_S)
|
||||
bpb.bps = opt_S;
|
||||
if (opt_s)
|
||||
bpb.bsec = opt_s;
|
||||
if (oflag)
|
||||
bpb.hid = opt_o;
|
||||
if (!(opt_f || (opt_h && opt_u && opt_S && opt_s && oflag)))
|
||||
getdiskinfo(fd, fname, dtype, oflag, &bpb);
|
||||
if (!powerof2(bpb.bps))
|
||||
errx(1, "bytes/sector (%u) is not a power of 2", bpb.bps);
|
||||
if (bpb.bps < MINBPS)
|
||||
errx(1, "bytes/sector (%u) is too small; minimum is %u",
|
||||
bpb.bps, MINBPS);
|
||||
if (!(fat = opt_F))
|
||||
if (opt_f)
|
||||
fat = 12;
|
||||
else if (!opt_e && (opt_i || opt_k))
|
||||
fat = 32;
|
||||
if ((fat == 32 && opt_e) || (fat != 32 && (opt_i || opt_k)))
|
||||
errx(1, "-%c is not a legal FAT%s option",
|
||||
fat == 32 ? 'e' : opt_i ? 'i' : 'k',
|
||||
fat == 32 ? "32" : "12/16");
|
||||
if (opt_f && fat == 32)
|
||||
bpb.rde = 0;
|
||||
if (opt_b) {
|
||||
if (!powerof2(opt_b))
|
||||
errx(1, "block size (%u) is not a power of 2", opt_b);
|
||||
if (opt_b < bpb.bps)
|
||||
errx(1, "block size (%u) is too small; minimum is %u",
|
||||
opt_b, bpb.bps);
|
||||
if (opt_b > bpb.bps * MAXSPC)
|
||||
errx(1, "block size (%u) is too large; maximum is %u",
|
||||
opt_b, bpb.bps * MAXSPC);
|
||||
bpb.spc = opt_b / bpb.bps;
|
||||
}
|
||||
if (opt_c) {
|
||||
if (!powerof2(opt_c))
|
||||
errx(1, "sectors/cluster (%u) is not a power of 2", opt_c);
|
||||
bpb.spc = opt_c;
|
||||
}
|
||||
if (opt_r)
|
||||
bpb.res = opt_r;
|
||||
if (opt_n) {
|
||||
if (opt_n > MAXNFT)
|
||||
errx(1, "number of FATs (%u) is too large; maximum is %u",
|
||||
opt_n, MAXNFT);
|
||||
bpb.nft = opt_n;
|
||||
}
|
||||
if (opt_e)
|
||||
bpb.rde = opt_e;
|
||||
if (mflag) {
|
||||
if (opt_m < 0xf0)
|
||||
errx(1, "illegal media descriptor (0x%x)", opt_m);
|
||||
bpb.mid = opt_m;
|
||||
}
|
||||
if (opt_a)
|
||||
bpb.bspf = opt_a;
|
||||
if (opt_i)
|
||||
bpb.infs = opt_i;
|
||||
if (opt_k)
|
||||
bpb.bkbs = opt_k;
|
||||
bss = 1;
|
||||
bname = NULL;
|
||||
fd1 = -1;
|
||||
if (opt_B) {
|
||||
bname = opt_B;
|
||||
if (!strchr(bname, '/')) {
|
||||
snprintf(buf, sizeof(buf), "/usr/mdec/%s", bname);
|
||||
if (!(bname = strdup(buf)))
|
||||
err(1, NULL);
|
||||
}
|
||||
if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb))
|
||||
err(1, "%s", bname);
|
||||
if (!S_ISREG(sb.st_mode) || sb.st_size % bpb.bps ||
|
||||
sb.st_size < bpb.bps || sb.st_size > bpb.bps * MAXU16)
|
||||
errx(1, "%s: inappropriate file type or format", bname);
|
||||
bss = sb.st_size / bpb.bps;
|
||||
}
|
||||
if (!bpb.nft)
|
||||
bpb.nft = 2;
|
||||
if (!fat)
|
||||
if (bpb.bsec < (bpb.res ? bpb.res : bss) +
|
||||
howmany((RESFTE + (bpb.spc ? MINCLS16 : MAXCLS12 + 1)) *
|
||||
((bpb.spc ? 16 : 12) / BPN), bpb.bps * NPB) *
|
||||
bpb.nft +
|
||||
howmany(bpb.rde ? bpb.rde : DEFRDE,
|
||||
bpb.bps / sizeof(struct de)) +
|
||||
(bpb.spc ? MINCLS16 : MAXCLS12 + 1) *
|
||||
(bpb.spc ? bpb.spc : howmany(DEFBLK, bpb.bps)))
|
||||
fat = 12;
|
||||
else if (bpb.rde || bpb.bsec <
|
||||
(bpb.res ? bpb.res : bss) +
|
||||
howmany((RESFTE + MAXCLS16) * 2, bpb.bps) * bpb.nft +
|
||||
howmany(DEFRDE, bpb.bps / sizeof(struct de)) +
|
||||
(MAXCLS16 + 1) *
|
||||
(bpb.spc ? bpb.spc : howmany(8192, bpb.bps)))
|
||||
fat = 16;
|
||||
else
|
||||
fat = 32;
|
||||
x = bss;
|
||||
if (fat == 32) {
|
||||
if (!bpb.infs) {
|
||||
if (x == MAXU16 || x == bpb.bkbs)
|
||||
errx(1, "no room for info sector");
|
||||
bpb.infs = x;
|
||||
}
|
||||
if (bpb.infs != MAXU16 && x <= bpb.infs)
|
||||
x = bpb.infs + 1;
|
||||
if (!bpb.bkbs) {
|
||||
if (x == MAXU16)
|
||||
errx(1, "no room for backup sector");
|
||||
bpb.bkbs = x;
|
||||
} else if (bpb.bkbs != MAXU16 && bpb.bkbs == bpb.infs)
|
||||
errx(1, "backup sector would overwrite info sector");
|
||||
if (bpb.bkbs != MAXU16 && x <= bpb.bkbs)
|
||||
x = bpb.bkbs + 1;
|
||||
}
|
||||
if (!bpb.res)
|
||||
bpb.res = fat == 32 ? MAX(x, MAX(16384 / bpb.bps, 4)) : x;
|
||||
else if (bpb.res < x)
|
||||
errx(1, "too few reserved sectors");
|
||||
if (fat != 32 && !bpb.rde)
|
||||
bpb.rde = DEFRDE;
|
||||
rds = howmany(bpb.rde, bpb.bps / sizeof(struct de));
|
||||
if (!bpb.spc)
|
||||
for (bpb.spc = howmany(fat == 16 ? DEFBLK16 : DEFBLK, bpb.bps);
|
||||
bpb.spc < MAXSPC &&
|
||||
bpb.res +
|
||||
howmany((RESFTE + maxcls(fat)) * (fat / BPN),
|
||||
bpb.bps * NPB) * bpb.nft +
|
||||
rds +
|
||||
(u_int64_t)(maxcls(fat) + 1) * bpb.spc <= bpb.bsec;
|
||||
bpb.spc <<= 1);
|
||||
if (fat != 32 && bpb.bspf > MAXU16)
|
||||
errx(1, "too many sectors/FAT for FAT12/16");
|
||||
x1 = bpb.res + rds;
|
||||
x = bpb.bspf ? bpb.bspf : 1;
|
||||
if (x1 + (u_int64_t)x * bpb.nft > bpb.bsec)
|
||||
errx(1, "meta data exceeds file system size");
|
||||
x1 += x * bpb.nft;
|
||||
x = (u_int64_t)(bpb.bsec - x1) * bpb.bps * NPB /
|
||||
(bpb.spc * bpb.bps * NPB + fat / BPN * bpb.nft);
|
||||
x2 = howmany((RESFTE + MIN(x, maxcls(fat))) * (fat / BPN),
|
||||
bpb.bps * NPB);
|
||||
if (!bpb.bspf) {
|
||||
bpb.bspf = x2;
|
||||
x1 += (bpb.bspf - 1) * bpb.nft;
|
||||
}
|
||||
cls = (bpb.bsec - x1) / bpb.spc;
|
||||
x = (u_int64_t)bpb.bspf * bpb.bps * NPB / (fat / BPN) - RESFTE;
|
||||
if (cls > x)
|
||||
cls = x;
|
||||
if (bpb.bspf < x2)
|
||||
warnx("warning: sectors/FAT limits file system to %u clusters",
|
||||
cls);
|
||||
if (cls < mincls(fat))
|
||||
errx(1, "too few clusters for FAT%u", fat);
|
||||
if (cls > maxcls(fat)) {
|
||||
cls = maxcls(fat);
|
||||
bpb.bsec = x1 + (cls + 1) * bpb.spc - 1;
|
||||
warnx("warning: FAT type limits file system to %u sectors",
|
||||
bpb.bsec);
|
||||
}
|
||||
printf("%s: %u sector%s in %u FAT%u cluster%s "
|
||||
"(%u bytes/cluster)\n", fname, cls * bpb.spc,
|
||||
cls * bpb.spc == 1 ? "" : "s", cls, fat,
|
||||
cls == 1 ? "" : "s", bpb.bps * bpb.spc);
|
||||
if (!bpb.mid)
|
||||
bpb.mid = !bpb.hid ? 0xf0 : 0xf8;
|
||||
if (fat == 32)
|
||||
bpb.rdcl = RESFTE;
|
||||
if (bpb.hid + bpb.bsec <= MAXU16) {
|
||||
bpb.sec = bpb.bsec;
|
||||
bpb.bsec = 0;
|
||||
}
|
||||
if (fat != 32) {
|
||||
bpb.spf = bpb.bspf;
|
||||
bpb.bspf = 0;
|
||||
}
|
||||
print_bpb(&bpb);
|
||||
if (!opt_N) {
|
||||
gettimeofday(&tv, NULL);
|
||||
tm = localtime(&tv.tv_sec);
|
||||
if (!(img = malloc(bpb.bps)))
|
||||
err(1, NULL);
|
||||
dir = bpb.res + (bpb.spf ? bpb.spf : bpb.bspf) * bpb.nft;
|
||||
for (lsn = 0; lsn < dir + (fat == 32 ? bpb.spc : rds); lsn++) {
|
||||
x = lsn;
|
||||
if (opt_B &&
|
||||
fat == 32 && bpb.bkbs != MAXU16 &&
|
||||
bss <= bpb.bkbs && x >= bpb.bkbs) {
|
||||
x -= bpb.bkbs;
|
||||
if (!x && lseek(fd1, 0, SEEK_SET))
|
||||
err(1, "%s", bname);
|
||||
}
|
||||
if (opt_B && x < bss) {
|
||||
if ((n = read(fd1, img, bpb.bps)) == -1)
|
||||
err(1, "%s", bname);
|
||||
if (n != bpb.bps)
|
||||
errx(1, "%s: can't read sector %u", bname, x);
|
||||
} else
|
||||
memset(img, 0, bpb.bps);
|
||||
if (!lsn ||
|
||||
(fat == 32 && bpb.bkbs != MAXU16 && lsn == bpb.bkbs)) {
|
||||
x1 = sizeof(struct bs);
|
||||
bsbpb = (struct bsbpb *)(img + x1);
|
||||
mk2(bsbpb->bps, bpb.bps);
|
||||
mk1(bsbpb->spc, bpb.spc);
|
||||
mk2(bsbpb->res, bpb.res);
|
||||
mk1(bsbpb->nft, bpb.nft);
|
||||
mk2(bsbpb->rde, bpb.rde);
|
||||
mk2(bsbpb->sec, bpb.sec);
|
||||
mk1(bsbpb->mid, bpb.mid);
|
||||
mk2(bsbpb->spf, bpb.spf);
|
||||
mk2(bsbpb->spt, bpb.spt);
|
||||
mk2(bsbpb->hds, bpb.hds);
|
||||
mk4(bsbpb->hid, bpb.hid);
|
||||
mk4(bsbpb->bsec, bpb.bsec);
|
||||
x1 += sizeof(struct bsbpb);
|
||||
if (fat == 32) {
|
||||
bsxbpb = (struct bsxbpb *)(img + x1);
|
||||
mk4(bsxbpb->bspf, bpb.bspf);
|
||||
mk2(bsxbpb->xflg, 0);
|
||||
mk2(bsxbpb->vers, 0);
|
||||
mk4(bsxbpb->rdcl, bpb.rdcl);
|
||||
mk2(bsxbpb->infs, bpb.infs);
|
||||
mk2(bsxbpb->bkbs, bpb.bkbs);
|
||||
x1 += sizeof(struct bsxbpb);
|
||||
}
|
||||
bsx = (struct bsx *)(img + x1);
|
||||
mk1(bsx->sig, 0x29);
|
||||
if (Iflag)
|
||||
x = opt_I;
|
||||
else
|
||||
x = (((u_int)(1 + tm->tm_mon) << 8 |
|
||||
(u_int)tm->tm_mday) +
|
||||
((u_int)tm->tm_sec << 8 |
|
||||
(u_int)(tv.tv_usec / 10))) << 16 |
|
||||
((u_int)(1900 + tm->tm_year) +
|
||||
((u_int)tm->tm_hour << 8 |
|
||||
(u_int)tm->tm_min));
|
||||
mk4(bsx->volid, x);
|
||||
mklabel(bsx->label, opt_L ? opt_L : "NO NAME");
|
||||
sprintf(buf, "FAT%u", fat);
|
||||
setstr(bsx->type, buf, sizeof(bsx->type));
|
||||
if (!opt_B) {
|
||||
x1 += sizeof(struct bsx);
|
||||
bs = (struct bs *)img;
|
||||
mk1(bs->jmp[0], 0xeb);
|
||||
mk1(bs->jmp[1], x1 - 2);
|
||||
mk1(bs->jmp[2], 0x90);
|
||||
setstr(bs->oem, opt_O ? opt_O : "BSD 4.4",
|
||||
sizeof(bs->oem));
|
||||
memcpy(img + x1, bootcode, sizeof(bootcode));
|
||||
mk2(img + bpb.bps - 2, DOSMAGIC);
|
||||
}
|
||||
} else if (fat == 32 && bpb.infs != MAXU16 &&
|
||||
(lsn == bpb.infs ||
|
||||
(bpb.bkbs != MAXU16 &&
|
||||
lsn == bpb.bkbs + bpb.infs))) {
|
||||
mk4(img, 0x41615252);
|
||||
mk4(img + bpb.bps - 28, 0x61417272);
|
||||
mk4(img + bpb.bps - 24, 0xffffffff);
|
||||
mk4(img + bpb.bps - 20, bpb.rdcl);
|
||||
mk2(img + bpb.bps - 2, DOSMAGIC);
|
||||
} else if (lsn >= bpb.res && lsn < dir &&
|
||||
!((lsn - bpb.res) %
|
||||
(bpb.spf ? bpb.spf : bpb.bspf))) {
|
||||
mk1(img[0], bpb.mid);
|
||||
for (x = 1; x < fat * (fat == 32 ? 3 : 2) / 8; x++)
|
||||
mk1(img[x], fat == 32 && x % 4 == 3 ? 0x0f : 0xff);
|
||||
} else if (lsn == dir && opt_L) {
|
||||
de = (struct de *)img;
|
||||
mklabel(de->namext, opt_L);
|
||||
mk1(de->attr, 050);
|
||||
x = (u_int)tm->tm_hour << 11 |
|
||||
(u_int)tm->tm_min << 5 |
|
||||
(u_int)tm->tm_sec >> 1;
|
||||
mk2(de->time, x);
|
||||
x = (u_int)(tm->tm_year - 80) << 9 |
|
||||
(u_int)(tm->tm_mon + 1) << 5 |
|
||||
(u_int)tm->tm_mday;
|
||||
mk2(de->date, x);
|
||||
}
|
||||
if ((n = write(fd, img, bpb.bps)) == -1)
|
||||
err(1, "%s", fname);
|
||||
if (n != bpb.bps)
|
||||
errx(1, "%s: can't write sector %u", fname, lsn);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Exit with error if file system is mounted.
|
||||
*/
|
||||
static void
|
||||
check_mounted(const char *fname, mode_t mode)
|
||||
{
|
||||
struct statfs *mp;
|
||||
const char *s1, *s2;
|
||||
size_t len;
|
||||
int n, r;
|
||||
|
||||
if (!(n = getmntinfo(&mp, MNT_NOWAIT)))
|
||||
err(1, "getmntinfo");
|
||||
len = strlen(_PATH_DEV);
|
||||
s1 = fname;
|
||||
if (!strncmp(s1, _PATH_DEV, len))
|
||||
s1 += len;
|
||||
r = S_ISCHR(mode) && s1 != fname && *s1 == 'r';
|
||||
for (; n--; mp++) {
|
||||
s2 = mp->f_mntfromname;
|
||||
if (!strncmp(s2, _PATH_DEV, len))
|
||||
s2 += len;
|
||||
if ((r && s2 != mp->f_mntfromname && !strcmp(s1 + 1, s2)) ||
|
||||
!strcmp(s1, s2))
|
||||
errx(1, "%s is mounted on %s", fname, mp->f_mntonname);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a standard format.
|
||||
*/
|
||||
static void
|
||||
getstdfmt(const char *fmt, struct bpb *bpb)
|
||||
{
|
||||
u_int x, i;
|
||||
|
||||
x = sizeof(stdfmt) / sizeof(stdfmt[0]);
|
||||
for (i = 0; i < x && strcmp(fmt, stdfmt[i].name); i++);
|
||||
if (i == x)
|
||||
errx(1, "%s: unknown standard format", fmt);
|
||||
*bpb = stdfmt[i].bpb;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get disk slice, partition, and geometry information.
|
||||
*/
|
||||
static void
|
||||
getdiskinfo(int fd, const char *fname, const char *dtype, int oflag,
|
||||
struct bpb *bpb)
|
||||
{
|
||||
struct diskslices ds;
|
||||
struct disklabel dl, *lp;
|
||||
const char *s1, *s2;
|
||||
char *s;
|
||||
int slice, part, fd1, i, e;
|
||||
|
||||
slice = part = -1;
|
||||
s1 = fname;
|
||||
if ((s2 = strrchr(s1, '/')))
|
||||
s1 = s2 + 1;
|
||||
for (s2 = s1; *s2 && !isdigit(*s2); s2++);
|
||||
if (!*s2 || s2 == s1)
|
||||
s2 = NULL;
|
||||
else
|
||||
while (isdigit(*++s2));
|
||||
s1 = s2;
|
||||
if (s2 && *s2 == 's') {
|
||||
slice = strtol(s2 + 1, &s, 10);
|
||||
if (slice < 1 || slice > MAX_SLICES - BASE_SLICE)
|
||||
s2 = NULL;
|
||||
else {
|
||||
slice = BASE_SLICE + slice - 1;
|
||||
s2 = s;
|
||||
}
|
||||
}
|
||||
if (s2 && *s2 >= 'a' && *s2 <= 'a' + MAXPARTITIONS - 1) {
|
||||
if (slice == -1)
|
||||
slice = COMPATIBILITY_SLICE;
|
||||
part = *s2++ - 'a';
|
||||
}
|
||||
if (!s2 || (*s2 && *s2 != '.'))
|
||||
errx(1, "%s: can't figure out partition info", fname);
|
||||
if (slice != -1 && (!oflag || (!bpb->bsec && part == -1))) {
|
||||
if (ioctl(fd, DIOCGSLICEINFO, &ds) == -1) {
|
||||
warn("ioctl (GSLICEINFO)");
|
||||
errx(1, "%s: can't get slice info", fname);
|
||||
}
|
||||
if (slice >= ds.dss_nslices || !ds.dss_slices[slice].ds_size)
|
||||
errx(1, "%s: slice is unavailable", fname);
|
||||
if (!oflag)
|
||||
bpb->hid = ds.dss_slices[slice].ds_offset;
|
||||
if (!bpb->bsec && part == -1)
|
||||
bpb->bsec = ds.dss_slices[slice].ds_size;
|
||||
}
|
||||
if (((slice == -1 || part != -1) &&
|
||||
((!oflag && part != -1) || !bpb->bsec)) ||
|
||||
!bpb->bps || !bpb->spt || !bpb->hds) {
|
||||
lp = &dl;
|
||||
i = ioctl(fd, DIOCGDINFO, lp);
|
||||
if (i == -1 && slice != -1 && part == -1) {
|
||||
e = errno;
|
||||
if (!(s = strdup(fname)))
|
||||
err(1, NULL);
|
||||
s[s1 - fname] = 0;
|
||||
if ((fd1 = open(s, O_RDONLY)) != -1) {
|
||||
i = ioctl(fd1, DIOCGDINFO, lp);
|
||||
close(fd1);
|
||||
}
|
||||
free(s);
|
||||
errno = e;
|
||||
}
|
||||
if (i == -1)
|
||||
if (!dtype) {
|
||||
warn("ioctl (GDINFO)");
|
||||
errx(1, "%s: can't read disk label; "
|
||||
"disk type must be specified", fname);
|
||||
} else if (!(lp = getdiskbyname(dtype)))
|
||||
errx(1, "%s: unknown disk type", dtype);
|
||||
if (slice == -1 || part != -1) {
|
||||
if (part == -1)
|
||||
part = RAW_PART;
|
||||
if (part >= lp->d_npartitions ||
|
||||
!lp->d_partitions[part].p_size)
|
||||
errx(1, "%s: partition is unavailable", fname);
|
||||
if (!oflag && part != -1)
|
||||
bpb->hid += lp->d_partitions[part].p_offset;
|
||||
if (!bpb->bsec)
|
||||
bpb->bsec = lp->d_partitions[part].p_size;
|
||||
}
|
||||
if (!bpb->bps)
|
||||
bpb->bps = ckgeom(fname, lp->d_secsize, "bytes/sector");
|
||||
if (!bpb->spt)
|
||||
bpb->spt = ckgeom(fname, lp->d_nsectors, "sectors/track");
|
||||
if (!bpb->hds)
|
||||
bpb->hds = ckgeom(fname, lp->d_ntracks, "drive heads");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print out BPB values.
|
||||
*/
|
||||
static void
|
||||
print_bpb(struct bpb *bpb)
|
||||
{
|
||||
printf("bps=%u spc=%u res=%u nft=%u", bpb->bps, bpb->spc, bpb->res,
|
||||
bpb->nft);
|
||||
if (bpb->rde)
|
||||
printf(" rde=%u", bpb->rde);
|
||||
if (bpb->sec)
|
||||
printf(" sec=%u", bpb->sec);
|
||||
printf(" mid=0x%x", bpb->mid);
|
||||
if (bpb->spf)
|
||||
printf(" spf=%u", bpb->spf);
|
||||
printf(" spt=%u hds=%u hid=%u", bpb->spt, bpb->hds, bpb->hid);
|
||||
if (bpb->bsec)
|
||||
printf(" bsec=%u", bpb->bsec);
|
||||
if (!bpb->spf) {
|
||||
printf(" bspf=%u rdcl=%u", bpb->bspf, bpb->rdcl);
|
||||
printf(" infs=");
|
||||
printf(bpb->infs == MAXU16 ? "0x%x" : "%u", bpb->infs);
|
||||
printf(" bkbs=");
|
||||
printf(bpb->bkbs == MAXU16 ? "0x%x" : "%u", bpb->bkbs);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Check a disk geometry value.
|
||||
*/
|
||||
static u_int
|
||||
ckgeom(const char *fname, u_int val, const char *msg)
|
||||
{
|
||||
if (!val)
|
||||
errx(1, "%s: no default %s", fname, msg);
|
||||
if (val > MAXU16)
|
||||
errx(1, "%s: illegal %s", fname, msg);
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert and check a numeric option argument.
|
||||
*/
|
||||
static u_int
|
||||
argtou(const char *arg, u_int lo, u_int hi, const char *msg)
|
||||
{
|
||||
char *s;
|
||||
u_long x;
|
||||
|
||||
errno = 0;
|
||||
x = strtoul(arg, &s, 0);
|
||||
if (errno || !*arg || *s || x < lo || x > hi)
|
||||
errx(1, "%s: bad %s", arg, msg);
|
||||
return x;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check a volume label.
|
||||
*/
|
||||
static int
|
||||
oklabel(const char *src)
|
||||
{
|
||||
int c, i;
|
||||
|
||||
for (i = 0; i <= 11; i++) {
|
||||
c = (u_char)*src++;
|
||||
if (c < ' ' + !i || strchr("\"*+,./:;<=>?[\\]|", c))
|
||||
break;
|
||||
}
|
||||
return i && !c;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make a volume label.
|
||||
*/
|
||||
static void
|
||||
mklabel(u_int8_t *dest, const char *src)
|
||||
{
|
||||
int c, i;
|
||||
|
||||
for (i = 0; i < 11; i++) {
|
||||
c = *src ? toupper(*src++) : ' ';
|
||||
*dest++ = !i && c == '\xe5' ? 5 : c;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy string, padding with spaces.
|
||||
*/
|
||||
static void
|
||||
setstr(u_int8_t *dest, const char *src, size_t len)
|
||||
{
|
||||
while (len--)
|
||||
*dest++ = *src ? *src++ : ' ';
|
||||
}
|
||||
|
||||
/*
|
||||
* Print usage message.
|
||||
*/
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: newfs_msdos [ -options ] special [disktype]\n");
|
||||
fprintf(stderr, "where the options are:\n");
|
||||
fprintf(stderr, "\t-N don't create file system: "
|
||||
"just print out parameters\n");
|
||||
fprintf(stderr, "\t-B get bootstrap from file\n");
|
||||
fprintf(stderr, "\t-F FAT type (12, 16, or 32)\n");
|
||||
fprintf(stderr, "\t-I volume ID\n");
|
||||
fprintf(stderr, "\t-L volume label\n");
|
||||
fprintf(stderr, "\t-O OEM string\n");
|
||||
fprintf(stderr, "\t-S bytes/sector\n");
|
||||
fprintf(stderr, "\t-a sectors/FAT\n");
|
||||
fprintf(stderr, "\t-b block size\n");
|
||||
fprintf(stderr, "\t-c sectors/cluster\n");
|
||||
fprintf(stderr, "\t-e root directory entries\n");
|
||||
fprintf(stderr, "\t-f standard format\n");
|
||||
fprintf(stderr, "\t-h drive heads\n");
|
||||
fprintf(stderr, "\t-i file system info sector\n");
|
||||
fprintf(stderr, "\t-k backup boot sector\n");
|
||||
fprintf(stderr, "\t-m media descriptor\n");
|
||||
fprintf(stderr, "\t-n number of FATs\n");
|
||||
fprintf(stderr, "\t-o hidden sectors\n");
|
||||
fprintf(stderr, "\t-r reserved sectors\n");
|
||||
fprintf(stderr, "\t-s file system size (sectors)\n");
|
||||
fprintf(stderr, "\t-u sectors/track\n");
|
||||
exit(1);
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
.\" Copyright (c) 1997, 1998
|
||||
.\" Bill Paul <[email protected]>. 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 Bill Paul.
|
||||
.\" 4. Neither the name of the author nor the names of any co-contributors
|
||||
.\" may be used to endorse or promote products derived from this software
|
||||
.\" without specific prior written permission.
|
||||
.\"
|
||||
.\" THIS SOFTWARE IS PROVIDED BY Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
|
||||
.\" 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.
|
||||
.\"
|
||||
.\" $Id: tl.4,v 1.3 1998/05/06 05:40:56 wpaul Exp $
|
||||
.\"
|
||||
.Dd May 1, 1998
|
||||
.Dt TL 4 i386
|
||||
.Os FreeBSD
|
||||
.Sh NAME
|
||||
.Nm tl
|
||||
.Nd
|
||||
Texas Instruments ThunderLAN ethernet device driver
|
||||
.Sh SYNOPSIS
|
||||
.Cd "device tl0"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
driver provides support for PCI ethernet adapters based on the Texas
|
||||
Instruments ThunderLAN ethernet controller chip. This includes a large
|
||||
number of Compaq PCI-bus ethernet adapters as well as the integrated
|
||||
ethernet controllers built in to several models of Compaq Prosignia
|
||||
servers and Compaq Deskpro desktop machines.
|
||||
.Pp
|
||||
The ThunderLAN controller has a standard MII interface that supports
|
||||
up to 32 physical interface devices (PHYs). It also has a built-in
|
||||
10baseT PHY hardwired at MII address 31, which may be used in some
|
||||
10Mbps-only hardware configurations. In 100Mbps configurations, a
|
||||
National Semiconductor DP83840A or other MII-compliant PHY may be
|
||||
attached to the ThunderLAN's MII bus. If a DP83840A or equivalent
|
||||
is available, the ThunderLAN chip can operate at either 100Mbps or
|
||||
10Mbps in either half-duplex or full-duplex modes. The ThunderLAN's
|
||||
built-in PHY and the DP83840A also support autonegotiation.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
driver supports the following media types:
|
||||
.Pp
|
||||
.Bl -tag -width xxxxxxxxxxxxxxxxxxxx
|
||||
.It autoselect
|
||||
Enable autoselection of the media type and options. Note that this
|
||||
option is only available on those PHYs that support autonegotiation.
|
||||
Also, the PHY will not advertise those modes that have been explcitly
|
||||
disabled using the following media options.
|
||||
.It 10baseT/UTP
|
||||
Set 10Mbps operation
|
||||
.It 100baseTX
|
||||
Set 100Mbps (fast ethernet) operation
|
||||
.It 10base5/AUI
|
||||
Enable AUI/BNC interface (useful only with the built-in PHY).
|
||||
.El
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
driver supports the following media options:
|
||||
.Pp
|
||||
.Bl -tag -width xxxxxxxxxxxxxxxxxxxx
|
||||
.It full-duplex
|
||||
Force full duplex operation
|
||||
.It half-duplex
|
||||
Force half duplex operation.
|
||||
.It hw-loopback
|
||||
Enable hardware loopback mode.
|
||||
.El
|
||||
.Pp
|
||||
Note that the 100baseTX media type is only available if supported
|
||||
by the PHY.
|
||||
For more information on configuring this device, see
|
||||
.Xr ifconfig 8 .
|
||||
.Sh DIAGNOSTICS
|
||||
.Bl -diag
|
||||
.It "tl%d: couldn't map memory"
|
||||
A fatal initialization error has occurred.
|
||||
.It "tl%d: couldn't map interrupt"
|
||||
A fatal initialization error has occurred.
|
||||
.It "tl%d: device timeout"
|
||||
The device has stopped responding to the network, or there is a problem with
|
||||
the network connection (cable).
|
||||
.It "tl%d: no memory for rx list"
|
||||
The driver failed to allocate an mbuf for the receiver ring.
|
||||
.It "tl%d: no memory for tx list"
|
||||
The driver fauled to allocate an mbuf for the transmitter ring when
|
||||
allocating a pad buffer or collapsing an mbuf chain into a cluster.
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr arp 4 ,
|
||||
.Xr netintro 4 ,
|
||||
.Xr ifconfig 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
device driver first appeared in
|
||||
.Fx 2.2 .
|
||||
.Sh AUTHOR
|
||||
The
|
||||
.Nm
|
||||
driver was written by
|
||||
.An Bill Paul Aq [email protected] .
|
||||
+3
-3
@@ -32,11 +32,11 @@
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# @(#)newvers.sh 8.1 (Berkeley) 4/20/94
|
||||
# $Id: newvers.sh,v 1.26.2.27 1998/07/21 13:49:50 jkh Exp $
|
||||
# $Id: newvers.sh,v 1.26.2.25 1998/03/24 18:07:21 jkh Exp $
|
||||
|
||||
TYPE="FreeBSD"
|
||||
REVISION="2.2.7"
|
||||
BRANCH="STABLE"
|
||||
BRANCH="RELEASE"
|
||||
RELEASE="${REVISION}-${BRANCH}"
|
||||
SNAPDATE=""
|
||||
if [ "X${SNAPDATE}" != "X" ]; then
|
||||
@@ -44,7 +44,7 @@ if [ "X${SNAPDATE}" != "X" ]; then
|
||||
fi
|
||||
VERSION="${TYPE} ${RELEASE}"
|
||||
|
||||
RELDATE="227001"
|
||||
RELDATE="227000"
|
||||
|
||||
b=share/examples/etc/bsd-style-copyright
|
||||
year=`date '+%Y'`
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**
|
||||
** $Id: userconfig.c,v 1.10.2.22 1998/07/21 12:12:50 kato Exp $
|
||||
** $Id: userconfig.c,v 1.10.2.21 1998/05/31 17:31:07 kato Exp $
|
||||
**/
|
||||
|
||||
/**
|
||||
@@ -251,7 +251,7 @@ static DEV_INFO device_info[] = {
|
||||
{"wt", "Wangtek/Archive QIC-02 Tape drive", 0, CLS_STORAGE},
|
||||
{"amd", "Tekram DC-390(T) / AMD 53c974 based PCI SCSI", FLG_FIXED, CLS_STORAGE},
|
||||
|
||||
{"cs", "IBM EtherJet, CS89x0-based Ethernet adapters",0, CLS_NETWORK},
|
||||
{"cs", "IBM EtherJet, CS89x0-based Ethernet adapeters",0, CLS_NETWORK},
|
||||
#ifdef PC98
|
||||
{"ed", "NS8390 Ethernet adapters", 0, CLS_NETWORK},
|
||||
#else
|
||||
@@ -267,7 +267,7 @@ static DEV_INFO device_info[] = {
|
||||
{"ix", "Intel EtherExpress Ethernet adapter", 0, CLS_NETWORK},
|
||||
{"le", "DEC Etherworks 2 and 3 Ethernet adapters", 0, CLS_NETWORK},
|
||||
{"lnc", "Isolan, Novell NE2100/NE32-VL Ethernet adapters", 0,CLS_NETWORK},
|
||||
{"tx", "SMC 9432TX Ethernet adapter", 0, CLS_NETWORK},
|
||||
{"tx", "SMC 9432TX Ethernet adapters", 0, CLS_NETWORK},
|
||||
{"vx", "3COM 3C590/3C595 Ethernet adapters", 0, CLS_NETWORK},
|
||||
{"ze", "IBM/National Semiconductor PCMCIA Ethernet adapter",0, CLS_NETWORK},
|
||||
{"zp", "3COM PCMCIA Etherlink III Ethernet adapter", 0, CLS_NETWORK},
|
||||
@@ -2384,7 +2384,7 @@ visuserconfig(void)
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: userconfig.c,v 1.10.2.22 1998/07/21 12:12:50 kato Exp $
|
||||
* $Id: userconfig.c,v 1.10.2.21 1998/05/31 17:31:07 kato Exp $
|
||||
*/
|
||||
|
||||
#include "scbus.h"
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
This file summarises changes made to ppp that effect
|
||||
its configuration.
|
||||
|
||||
It does not describe new features, rather it attempts
|
||||
to answer any `this used to work, why doesn't it now?'
|
||||
questions.
|
||||
|
||||
o The `set debug' command was replaced with `set log'.
|
||||
o The `set log LCP' command was split into LCP, IPCP and CCP logs.
|
||||
o Syslogd is used for logging. /etc/syslog.conf must be updated.
|
||||
o LQR is disabled by default.
|
||||
o Openmode is active by default.
|
||||
o Users must be a member of group `network' for ppp access. Furthermore,
|
||||
they must be `allow'ed to run ppp via the `allow' command in the
|
||||
configuration file.
|
||||
For a brief period, ppp could only be run as root.
|
||||
o No diagnostic socket is created by default. The `set server' command
|
||||
must be used.
|
||||
o The diagnostic socket password must be specified *only* on the `set
|
||||
server' command line.
|
||||
o When `set server' is used to re-select a diagnostic port, all existing
|
||||
diagnostic connections are dropped.
|
||||
o pppd-deflate is now called deflate24.
|
||||
o Filter IPs of 0.0.0.0 have a default width of 0, not 32.
|
||||
o Errors in `add' and `delete' are logged as warnings rather than being
|
||||
written to the TCP/IP log.
|
||||
o Any number of diagnostic prompts are allowed, and they are allowed in
|
||||
interactive mode.
|
||||
o The default `device' is cuaa1, then cuaa0
|
||||
o A password of "*" in ppp.secret causes a passwd database lookup in
|
||||
pap mode.
|
||||
o The value of the CONNECT environment variable is logged in the
|
||||
utmp host field in -direct mode.
|
||||
o Out-of-sequence FSM packets (IPCP/LCP/CCP) are dropped by default.
|
||||
o Reconnect values are used after an LQR timeout.
|
||||
o ^C works on the parent in -background mode.
|
||||
o The dial/call/open command works asynchronously. As a result, prompts
|
||||
do not lose control while dialing.
|
||||
o The `display' command has been removed. All information is available
|
||||
with the appropriate `show' command.
|
||||
o Msext does not need to be enabled/disabled. Setting the NBNS (set nbns)
|
||||
will auto enable it. The DNS side may be enabled/disabled, and if
|
||||
enabled without a `set dns' (was `set ns') will use values from
|
||||
/etc/resolv.conf.
|
||||
o Filters are now called `allow', `dial', `in' and `out'. `set
|
||||
ifilter ...' becomes `set filter in ...' etc.
|
||||
o Authname and Authkey may only be `set' in phase DEAD.
|
||||
o Set encrypt is no longer necessary. Ppp will respond to M$CHAP
|
||||
servers correctly if it's built with DES.
|
||||
o Throughput statistics are enabled by default.
|
||||
o `Set stopped' only has two parameters. It's no longer possible to
|
||||
have an IPCP stopped timer.
|
||||
o `Set timeout' only has one parameter. Use `set lqrperiod' and `set
|
||||
{lcp,ccp,ipcp,chap,pap}retry' for the other timers. `show timeout'
|
||||
is also now available using the relevant show commands.
|
||||
o `set loopback' is now `enable/disable loopback'.
|
||||
o `show auto', `show loopback' and `show mtu' are all part of `show bundle'.
|
||||
o `show mru' is part of `show lcp'
|
||||
o `show msext' and `show vj' are part of `show ipcp'
|
||||
o `show reconnect' and `show redial' are part of `show link'
|
||||
o A signal 15 (TERM) will now shut down the link gracefully.
|
||||
o A signal 2 (HUP) will drop all links immediately.
|
||||
o Signal 30 (USR1) is now ignored.
|
||||
o Add & delete commands are not necessary in ppp.linkup if they are
|
||||
`sticky routes' (ie, contain MYADDR or HISADDR).
|
||||
o LINK and CARRIER logging are no longer available.
|
||||
o Timer based DEBUG messages are now logged in the new TIMER log.
|
||||
o Ppp can use tun devices > tun255.
|
||||
o Protocol-compressed packets are accepted even if they were denied
|
||||
at LCP negotiation time.
|
||||
o Passwords aren't logged when logging the ``set server'' line.
|
||||
o Command line options only need enough characters to uniquely identify
|
||||
them. -a == -auto, -dd == -ddial etc. -interactive is also allowed.
|
||||
@@ -1,51 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $Id: descriptor.h,v 1.3 1998/05/23 22:24:34 brian Exp $
|
||||
*/
|
||||
|
||||
#define PHYSICAL_DESCRIPTOR (1)
|
||||
#define SERVER_DESCRIPTOR (2)
|
||||
#define PROMPT_DESCRIPTOR (3)
|
||||
#define CHAT_DESCRIPTOR (4)
|
||||
#define DATALINK_DESCRIPTOR (5)
|
||||
#define BUNDLE_DESCRIPTOR (6)
|
||||
#define MPSERVER_DESCRIPTOR (7)
|
||||
|
||||
struct bundle;
|
||||
|
||||
struct descriptor {
|
||||
int type;
|
||||
|
||||
int (*UpdateSet)(struct descriptor *, fd_set *, fd_set *, fd_set *, int *);
|
||||
int (*IsSet)(struct descriptor *, const fd_set *);
|
||||
void (*Read)(struct descriptor *, struct bundle *, const fd_set *);
|
||||
int (*Write)(struct descriptor *, struct bundle *, const fd_set *);
|
||||
};
|
||||
|
||||
#define descriptor_UpdateSet(d, r, w, e, n) ((*(d)->UpdateSet)(d, r, w, e, n))
|
||||
#define descriptor_IsSet(d, s) ((*(d)->IsSet)(d, s))
|
||||
#define descriptor_Read(d, b, f) ((*(d)->Read)(d, b, f))
|
||||
#define descriptor_Write(d, b, f) ((*(d)->Write)(d, b, f))
|
||||
@@ -1,53 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $Id: probe.c,v 1.1 1998/06/24 19:36:36 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "probe.h"
|
||||
#include "log.h"
|
||||
|
||||
/* Does select() alter the passed time value ? */
|
||||
static int
|
||||
select_changes_time(void)
|
||||
{
|
||||
struct timeval t;
|
||||
|
||||
t.tv_sec = 0;
|
||||
t.tv_usec = 100000;
|
||||
select(0, NULL, NULL, NULL, &t);
|
||||
return t.tv_usec != 100000;
|
||||
}
|
||||
|
||||
void
|
||||
probe_Init(struct probe *p)
|
||||
{
|
||||
p->select_changes_time = select_changes_time() ? 1 : 0;
|
||||
log_Printf(LogDEBUG, "Select changes time: %s\n",
|
||||
p->select_changes_time ? "yes" : "no");
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
struct probe {
|
||||
unsigned select_changes_time : 1;
|
||||
};
|
||||
|
||||
extern void probe_Init(struct probe *);
|
||||
@@ -1,91 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1998 Brian Somers <brian@Awfulhak.org>
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*
|
||||
* $Id: prompt.h,v 1.3 1998/05/23 22:24:49 brian Exp $
|
||||
*/
|
||||
|
||||
#define LOCAL_AUTH 0x01
|
||||
#define LOCAL_NO_AUTH 0x02
|
||||
#define LOCAL_DENY 0x03
|
||||
#define LOCAL_CX 0x04 /* OR'd value - require a context */
|
||||
#define LOCAL_CX_OPT 0x08 /* OR'd value - optional context */
|
||||
|
||||
struct server;
|
||||
struct datalink;
|
||||
struct bundle;
|
||||
struct cmdargs;
|
||||
|
||||
struct prompt {
|
||||
struct descriptor desc;
|
||||
int fd_in, fd_out;
|
||||
struct datalink *TermMode; /* The modem we're talking directly to */
|
||||
FILE *Term; /* sits on top of fd_out */
|
||||
u_char auth; /* Local Authorized status */
|
||||
struct server *owner; /* who created me */
|
||||
struct bundle *bundle; /* who I'm controlling */
|
||||
unsigned nonewline : 1; /* need a newline before our prompt ? */
|
||||
unsigned needprompt : 1; /* Show a prompt at the next UpdateSet() */
|
||||
unsigned active : 1; /* Is the prompt active (^Z) */
|
||||
unsigned readtilde : 1; /* We've read a ``~'' from fd_in */
|
||||
|
||||
struct {
|
||||
const char *type; /* Type of connection */
|
||||
char from[40]; /* Source of connection */
|
||||
} src;
|
||||
|
||||
struct prompt *next; /* Maintained in log.c */
|
||||
u_long logmask; /* Maintained in log.c */
|
||||
|
||||
struct termios oldtio; /* Original tty mode */
|
||||
struct termios comtio; /* Command level tty mode */
|
||||
};
|
||||
|
||||
#define descriptor2prompt(d) \
|
||||
((d)->type == PROMPT_DESCRIPTOR ? (struct prompt *)(d) : NULL)
|
||||
|
||||
#define PROMPT_STD (-1)
|
||||
extern struct prompt *prompt_Create(struct server *, struct bundle *, int);
|
||||
extern void prompt_Destroy(struct prompt *, int);
|
||||
extern void prompt_Required(struct prompt *);
|
||||
#ifdef __GNUC__
|
||||
extern void prompt_Printf(struct prompt *, const char *, ...)
|
||||
__attribute__ ((format (printf, 2, 3)));
|
||||
#else
|
||||
extern void prompt_Printf(struct prompt *, const char *, ...);
|
||||
#endif
|
||||
extern void prompt_vPrintf(struct prompt *, const char *, _BSD_VA_LIST_);
|
||||
#define PROMPT_DONT_WANT_INT 1
|
||||
#define PROMPT_WANT_INT 0
|
||||
extern void prompt_TtyInit(struct prompt *);
|
||||
extern void prompt_TtyCommandMode(struct prompt *);
|
||||
extern void prompt_TtyTermMode(struct prompt *, struct datalink *);
|
||||
extern void prompt_TtyOldMode(struct prompt *);
|
||||
extern pid_t prompt_pgrp(struct prompt *);
|
||||
extern int PasswdCommand(struct cmdargs const *);
|
||||
extern void prompt_Suspend(struct prompt *);
|
||||
extern void prompt_Continue(struct prompt *);
|
||||
#define prompt_IsTermMode(p, dl) ((p)->TermMode == (dl) ? 1 : 0)
|
||||
#define prompt_IsController(p) (!(p) || (p)->owner ? 0 : 1)
|
||||
#define prompt_Required(p) ((p)->needprompt = 1)
|
||||
Reference in new issue
Block a user