summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1994-10-02 17:35:40 +0000
committerphk <phk@FreeBSD.org>1994-10-02 17:35:40 +0000
commitc3e49455410fee43dec92514e04dfed13eb8c587 (patch)
tree63e8cb7113791c7e2efaced539ff5283adf25d25 /sys/kern
parent29627a3d7d000aefc2860e1042707614018a2b57 (diff)
downloadFreeBSD-src-c3e49455410fee43dec92514e04dfed13eb8c587.zip
FreeBSD-src-c3e49455410fee43dec92514e04dfed13eb8c587.tar.gz
All of this is cosmetic. prototypes, #includes, printfs and so on. Makes
GCC a lot more silent.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_acct.c8
-rw-r--r--sys/kern/kern_clock.c4
-rw-r--r--sys/kern/kern_descrip.c3
-rw-r--r--sys/kern/kern_exec.c6
-rw-r--r--sys/kern/kern_exit.c8
-rw-r--r--sys/kern/kern_ktrace.c7
-rw-r--r--sys/kern/kern_lkm.c14
-rw-r--r--sys/kern/kern_malloc.c8
-rw-r--r--sys/kern/kern_synch.c12
-rw-r--r--sys/kern/kern_sysctl.c21
-rw-r--r--sys/kern/kern_tc.c4
-rw-r--r--sys/kern/kern_time.c7
-rw-r--r--sys/kern/kern_timeout.c4
-rw-r--r--sys/kern/kern_xxx.c3
-rw-r--r--sys/kern/subr_log.c3
-rw-r--r--sys/kern/subr_prf.c31
-rw-r--r--sys/kern/subr_rlist.c3
-rw-r--r--sys/kern/sys_generic.c5
-rw-r--r--sys/kern/sys_socket.c3
-rw-r--r--sys/kern/sysv_msg.c5
-rw-r--r--sys/kern/sysv_sem.c5
-rw-r--r--sys/kern/sysv_shm.c41
-rw-r--r--sys/kern/tty.c71
-rw-r--r--sys/kern/tty_pty.c31
-rw-r--r--sys/kern/uipc_mbuf.c11
-rw-r--r--sys/kern/uipc_sockbuf.c38
-rw-r--r--sys/kern/uipc_socket.c29
-rw-r--r--sys/kern/uipc_socket2.c38
-rw-r--r--sys/kern/uipc_syscalls.c725
-rw-r--r--sys/kern/uipc_usrreq.c24
-rw-r--r--sys/kern/vfs_cache.c37
-rw-r--r--sys/kern/vfs_export.c5
-rw-r--r--sys/kern/vfs_extattr.c170
-rw-r--r--sys/kern/vfs_subr.c5
-rw-r--r--sys/kern/vfs_syscalls.c170
-rw-r--r--sys/kern/vfs_vnops.c34
36 files changed, 918 insertions, 675 deletions
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c
index 2360c55..46ed697 100644
--- a/sys/kern/kern_acct.c
+++ b/sys/kern/kern_acct.c
@@ -37,7 +37,7 @@
* SUCH DAMAGE.
*
* @(#)kern_acct.c 8.1 (Berkeley) 6/14/93
- * $Id$
+ * $Id: kern_acct.c,v 1.5 1994/09/26 21:09:00 davidg Exp $
*/
#include <sys/param.h>
@@ -105,7 +105,8 @@ acct(p, uap, retval)
int error;
/* Make sure that the caller is root. */
- if (error = suser(p->p_ucred, &p->p_acflag))
+ error = suser(p->p_ucred, &p->p_acflag);
+ if (error)
return (error);
/*
@@ -114,7 +115,8 @@ acct(p, uap, retval)
*/
if (uap->path != NULL) {
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = vn_open(&nd, FWRITE, 0))
+ error = vn_open(&nd, FWRITE, 0);
+ if (error)
return (error);
VOP_UNLOCK(nd.ni_vp);
if (nd.ni_vp->v_type != VREG) {
diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c
index cb67a90..db447bf 100644
--- a/sys/kern/kern_clock.c
+++ b/sys/kern/kern_clock.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
- * $Id: kern_clock.c,v 1.7 1994/09/25 19:33:34 phk Exp $
+ * $Id: kern_clock.c,v 1.8 1994/09/29 00:52:06 wollman Exp $
*/
/* Portions of this software are covered by the following: */
@@ -63,8 +63,10 @@
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
+#include <sys/signalvar.h>
#include <sys/timex.h>
#include <vm/vm.h>
+#include <sys/sysctl.h>
#include <machine/cpu.h>
#include <machine/clock.h>
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index e94a518..b18eab8 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94
- * $Id: kern_descrip.c,v 1.4 1994/09/02 10:17:30 davidg Exp $
+ * $Id: kern_descrip.c,v 1.5 1994/09/25 19:33:35 phk Exp $
*/
#include <sys/param.h>
@@ -55,6 +55,7 @@
#include <sys/syslog.h>
#include <sys/unistd.h>
#include <sys/resourcevar.h>
+#include <vm/vm.h>
int finishdup(struct filedesc *fdp, int old, int new, int *retval);
/*
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 6d1aa2e..ffd78da 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: kern_exec.c,v 1.8 1994/09/24 16:58:43 davidg Exp $
+ * $Id: kern_exec.c,v 1.9 1994/09/25 19:33:36 phk Exp $
*/
#include <sys/param.h>
@@ -37,6 +37,7 @@
#include <sys/resourcevar.h>
#include <sys/kernel.h>
#include <sys/mount.h>
+#include <sys/filedesc.h>
#include <sys/file.h>
#include <sys/acct.h>
#include <sys/exec.h>
@@ -46,6 +47,7 @@
#include <sys/mman.h>
#include <sys/malloc.h>
#include <sys/syslog.h>
+#include <sys/shm.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
@@ -289,7 +291,7 @@ interpret:
p->p_acflag &= ~AFORK;
/* Set entry address */
- setregs(p, iparams->entry_addr, stack_base);
+ setregs(p, iparams->entry_addr, (u_long)stack_base);
/*
* free various allocated resources
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index 82d303b..7369be2 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
- * $Id: kern_exit.c,v 1.6 1994/09/12 11:27:03 davidg Exp $
+ * $Id: kern_exit.c,v 1.7 1994/09/25 19:33:37 phk Exp $
*/
#include <sys/param.h>
@@ -56,7 +56,10 @@
#include <sys/syslog.h>
#include <sys/malloc.h>
#include <sys/resourcevar.h>
+#include <sys/signalvar.h>
#include <sys/ptrace.h>
+#include <sys/shm.h>
+#include <sys/filedesc.h>
#include <machine/cpu.h>
#ifdef COMPAT_43
@@ -67,9 +70,6 @@
#include <vm/vm.h>
#include <vm/vm_kern.h>
-__dead void cpu_exit __P((struct proc *));
-__dead void exit1 __P((struct proc *, int));
-
/*
* exit --
* Death of process.
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index c79620a..2bba4bb 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)kern_ktrace.c 8.2 (Berkeley) 9/23/93
- * $Id: kern_ktrace.c,v 1.3 1994/08/02 07:42:02 davidg Exp $
+ * $Id: kern_ktrace.c,v 1.4 1994/08/18 22:35:01 wollman Exp $
*/
#ifdef KTRACE
@@ -46,8 +46,6 @@
#include <sys/malloc.h>
#include <sys/syslog.h>
-void ktrwrite __P((struct vnode *, struct ktr_header *));
-
struct ktr_header *
ktrgetheader(type)
int type;
@@ -254,7 +252,8 @@ ktrace(curp, uap, retval)
* an operation which requires a file argument.
*/
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->fname, curp);
- if (error = vn_open(&nd, FREAD|FWRITE, 0)) {
+ error = vn_open(&nd, FREAD|FWRITE, 0);
+ if (error) {
curp->p_traceflag &= ~KTRFAC_ACTIVE;
return (error);
}
diff --git a/sys/kern/kern_lkm.c b/sys/kern/kern_lkm.c
index a85709c..6f25cb9 100644
--- a/sys/kern/kern_lkm.c
+++ b/sys/kern/kern_lkm.c
@@ -105,7 +105,8 @@ lkmcopen(dev, flag, devtype, p)
* Sleep pending unlock; we use tsleep() to allow
* an alarm out of the open.
*/
- if (error = tsleep((caddr_t)&lkm_v, TTIPRI|PCATCH, "lkmopn", 0))
+ error = tsleep((caddr_t)&lkm_v, TTIPRI|PCATCH, "lkmopn", 0);
+ if (error)
return(error); /* leave LKM_WANT set -- no problem */
}
lkm_v |= LKM_ALLOC;
@@ -181,7 +182,6 @@ lkmcioctl(dev, cmd, data, flag)
struct lmc_loadbuf *loadbufp;
struct lmc_unload *unloadp;
struct lmc_stat *statp;
- int (*funcp)();
char istr[MAXLKMNAME];
switch(cmd) {
@@ -240,7 +240,9 @@ lkmcioctl(dev, cmd, data, flag)
}
/* copy in buffer full of data */
- if (err = copyin((caddr_t)loadbufp->data, (caddr_t)curp->area + curp->offset, i))
+ err = copyin((caddr_t)loadbufp->data,
+ (caddr_t)curp->area + curp->offset, i);
+ if (err)
break;
if ((curp->offset + i) < curp->size) {
@@ -291,7 +293,8 @@ lkmcioctl(dev, cmd, data, flag)
curp->entry = (int (*)()) (*((int *) (data)));
/* call entry(load)... (assigns "private" portion) */
- if (err = (*(curp->entry))(curp, LKM_E_LOAD, LKM_VERSION)) {
+ err = (*(curp->entry))(curp, LKM_E_LOAD, LKM_VERSION);
+ if (err) {
/*
* Module may refuse loading or may have a
* version mismatch...
@@ -320,7 +323,8 @@ lkmcioctl(dev, cmd, data, flag)
* Copy name and lookup id from all loaded
* modules. May fail.
*/
- if (err = copyinstr(unloadp->name, istr, MAXLKMNAME-1, NULL))
+ err =copyinstr(unloadp->name, istr, MAXLKMNAME-1, NULL);
+ if (err)
break;
/*
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c
index fecf154..4c122dc 100644
--- a/sys/kern/kern_malloc.c
+++ b/sys/kern/kern_malloc.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94
- * $Id$
+ * $Id: kern_malloc.c,v 1.3 1994/08/02 07:42:04 davidg Exp $
*/
#include <sys/param.h>
@@ -196,7 +196,7 @@ malloc(size, type, flags)
memname[freep->type] : "???";
if (kbp->kb_next &&
!kernacc(kbp->kb_next, sizeof(struct freelist), 0)) {
- printf("%s of object 0x%x size %d %s %s (invalid addr 0x%x)\n",
+ printf("%s of object %p size %ld %s %s (invalid addr %p)\n",
"Data modified on freelist: word 2.5", va, size,
"previous type", savedtype, kbp->kb_next);
kbp->kb_next = NULL;
@@ -215,7 +215,7 @@ malloc(size, type, flags)
for (lp = (long *)va; lp < end; lp++) {
if (*lp == WEIRD_ADDR)
continue;
- printf("%s %d of object 0x%x size %d %s %s (0x%x != 0x%x)\n",
+ printf("%s %d of object %p size %ld %s %s (0x%lx != 0x%x)\n",
"Data modified on freelist: word", lp - (long *)va,
va, size, "previous type", savedtype, *lp, WEIRD_ADDR);
break;
@@ -308,7 +308,7 @@ free(addr, type)
for (cp = kbp->kb_next; cp; cp = *(caddr_t *)cp) {
if (addr != cp)
continue;
- printf("multiply freed item 0x%x\n", addr);
+ printf("multiply freed item %p\n", addr);
panic("free: duplicated free");
}
}
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c
index a7d3774..1ea5815 100644
--- a/sys/kern/kern_synch.c
+++ b/sys/kern/kern_synch.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_synch.c 8.6 (Berkeley) 1/21/94
- * $Id: kern_synch.c,v 1.5 1994/09/25 19:33:44 phk Exp $
+ * $Id: kern_synch.c,v 1.6 1994/10/02 04:45:50 davidg Exp $
*/
#include <sys/param.h>
@@ -46,7 +46,8 @@
#include <sys/buf.h>
#include <sys/signalvar.h>
#include <sys/resourcevar.h>
-#include <sys/vmmeter.h>
+#include <sys/signalvar.h>
+#include <vm/vm.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
@@ -420,7 +421,7 @@ sleep(ident, priority)
#ifdef DIAGNOSTIC
if (priority > PZERO) {
- printf("sleep called with priority %d > PZERO, wchan: %x\n",
+ printf("sleep called with priority %d > PZERO, wchan: %p\n",
priority, ident);
panic("old sleep");
}
@@ -504,9 +505,10 @@ wakeup(ident)
s = splhigh();
qp = &slpque[LOOKUP(ident)];
restart:
- for (q = &qp->sq_head; p = *q; ) {
+ for (q = &qp->sq_head; *q; ) {
+ p = *q;
#ifdef DIAGNOSTIC
- if (p->p_back || p->p_stat != SSLEEP && p->p_stat != SSTOP)
+ if (p->p_back || (p->p_stat != SSLEEP && p->p_stat != SSTOP))
panic("wakeup");
#endif
if (p->p_wchan == ident) {
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 0b37159..2762929 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
- * $Id: kern_sysctl.c,v 1.14 1994/09/21 03:46:46 wollman Exp $
+ * $Id: kern_sysctl.c,v 1.15 1994/09/23 19:07:17 wollman Exp $
*/
/*
@@ -102,7 +102,8 @@ __sysctl(p, uap, retval)
*/
if (uap->namelen > CTL_MAXNAME || uap->namelen < 2)
return (EINVAL);
- if (error = copyin(uap->name, &name, uap->namelen * sizeof(int)))
+ error = copyin(uap->name, &name, uap->namelen * sizeof(int));
+ if (error)
return (error);
switch (name[0]) {
@@ -571,7 +572,8 @@ sysctl_file(where, sizep)
*sizep = 0;
return (0);
}
- if (error = copyout((caddr_t)&filehead, where, sizeof(filehead)))
+ error = copyout((caddr_t)&filehead, where, sizeof(filehead));
+ if (error)
return (error);
buflen -= sizeof(filehead);
where += sizeof(filehead);
@@ -584,7 +586,8 @@ sysctl_file(where, sizep)
*sizep = where - start;
return (ENOMEM);
}
- if (error = copyout((caddr_t)fp, where, sizeof (struct file)))
+ error = copyout((caddr_t)fp, where, sizeof (struct file));
+ if (error)
return (error);
buflen -= sizeof(struct file);
where += sizeof(struct file);
@@ -661,11 +664,13 @@ again:
}
if (buflen >= sizeof(struct kinfo_proc)) {
fill_eproc(p, &eproc);
- if (error = copyout((caddr_t)p, &dp->kp_proc,
- sizeof(struct proc)))
+ error = copyout((caddr_t)p, &dp->kp_proc,
+ sizeof(struct proc));
+ if (error)
return (error);
- if (error = copyout((caddr_t)&eproc, &dp->kp_eproc,
- sizeof(eproc)))
+ error = copyout((caddr_t)&eproc, &dp->kp_eproc,
+ sizeof(eproc));
+ if (error)
return (error);
dp++;
buflen -= sizeof(struct kinfo_proc);
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c
index cb67a90..db447bf 100644
--- a/sys/kern/kern_tc.c
+++ b/sys/kern/kern_tc.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
- * $Id: kern_clock.c,v 1.7 1994/09/25 19:33:34 phk Exp $
+ * $Id: kern_clock.c,v 1.8 1994/09/29 00:52:06 wollman Exp $
*/
/* Portions of this software are covered by the following: */
@@ -63,8 +63,10 @@
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
+#include <sys/signalvar.h>
#include <sys/timex.h>
#include <vm/vm.h>
+#include <sys/sysctl.h>
#include <machine/cpu.h>
#include <machine/clock.h>
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 9c22644..f3581b1 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -31,11 +31,12 @@
* SUCH DAMAGE.
*
* @(#)kern_time.c 8.1 (Berkeley) 6/10/93
- * $Id: kern_time.c,v 1.3 1994/08/02 07:42:21 davidg Exp $
+ * $Id: kern_time.c,v 1.4 1994/09/25 19:33:45 phk Exp $
*/
#include <sys/param.h>
#include <sys/resourcevar.h>
+#include <sys/signalvar.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/proc.h>
@@ -43,10 +44,6 @@
#include <machine/cpu.h>
-void timevaladd __P((struct timeval *, struct timeval *));
-void timevalsub __P((struct timeval *, struct timeval *));
-void timevalfix __P((struct timeval *));
-
/*
* Time of day and interval timer support.
*
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index cb67a90..db447bf 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
- * $Id: kern_clock.c,v 1.7 1994/09/25 19:33:34 phk Exp $
+ * $Id: kern_clock.c,v 1.8 1994/09/29 00:52:06 wollman Exp $
*/
/* Portions of this software are covered by the following: */
@@ -63,8 +63,10 @@
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/resourcevar.h>
+#include <sys/signalvar.h>
#include <sys/timex.h>
#include <vm/vm.h>
+#include <sys/sysctl.h>
#include <machine/cpu.h>
#include <machine/clock.h>
diff --git a/sys/kern/kern_xxx.c b/sys/kern/kern_xxx.c
index 0ada2b3..337ff4f 100644
--- a/sys/kern/kern_xxx.c
+++ b/sys/kern/kern_xxx.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93
- * $Id: kern_xxx.c,v 1.6 1994/09/19 21:15:14 ache Exp $
+ * $Id: kern_xxx.c,v 1.7 1994/09/25 19:33:46 phk Exp $
*/
#include <sys/param.h>
@@ -42,6 +42,7 @@
#include <vm/vm.h>
#include <sys/sysctl.h>
#include <sys/utsname.h>
+#include <sys/signalvar.h>
struct reboot_args {
int opt;
diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c
index 35274fc..e0beafa 100644
--- a/sys/kern/subr_log.c
+++ b/sys/kern/subr_log.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)subr_log.c 8.1 (Berkeley) 6/10/93
- * $Id: subr_log.c,v 1.3 1994/08/02 07:42:29 davidg Exp $
+ * $Id: subr_log.c,v 1.4 1994/09/25 19:33:47 phk Exp $
*/
/*
@@ -45,6 +45,7 @@
#include <sys/ioctl.h>
#include <sys/msgbuf.h>
#include <sys/file.h>
+#include <sys/signalvar.h>
#define LOG_RDPRI (PZERO + 1)
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index c171867..cc492d1 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
- * $Id: subr_prf.c,v 1.5 1994/08/27 16:14:27 davidg Exp $
+ * $Id: subr_prf.c,v 1.6 1994/09/28 19:22:32 phk Exp $
*/
#include <sys/param.h>
@@ -270,12 +270,11 @@ void
logpri(level)
int level;
{
- register int ch;
register char *p;
putchar('<', TOLOG, NULL);
- for (p = ksprintn((u_long)level, 10, NULL); ch = *p--;)
- putchar(ch, TOLOG, NULL);
+ for (p = ksprintn((u_long)level, 10, NULL); *p;)
+ putchar(*p--, TOLOG, NULL);
putchar('>', TOLOG, NULL);
}
@@ -401,13 +400,14 @@ reswitch: switch (ch = *(u_char *)fmt++) {
case 'b':
ul = va_arg(ap, int);
p = va_arg(ap, char *);
- for (q = ksprintn(ul, *p++, NULL); ch = *q--;)
- putchar(ch, flags, tp);
+ for (q = ksprintn(ul, *p++, NULL); *q;)
+ putchar(*q--, flags, tp);
if (!ul)
break;
- for (tmp = 0; n = *p++;) {
+ for (tmp = 0; *p;) {
+ n = *p++;
if (ul & (1 << (n - 1))) {
putchar(tmp ? ',' : '<', flags, tp);
for (; (n = *p) > ' '; ++p)
@@ -429,8 +429,8 @@ reswitch: switch (ch = *(u_char *)fmt++) {
break;
case 's':
p = va_arg(ap, char *);
- while (ch = *p++)
- putchar(ch, flags, tp);
+ while (*p)
+ putchar(*p++, flags, tp);
break;
case 'd':
ul = lflag ? va_arg(ap, long) : va_arg(ap, int);
@@ -462,8 +462,8 @@ number: p = ksprintn(ul, base, &tmp);
if (width && (width -= tmp) > 0)
while (width--)
putchar(padc, flags, tp);
- while (ch = *p--)
- putchar(ch, flags, tp);
+ while (*p)
+ putchar(*p--, flags, tp);
break;
default:
putchar('%', flags, tp);
@@ -549,9 +549,8 @@ reswitch: switch (ch = *(u_char *)fmt++) {
break;
case 's':
p = va_arg(ap, char *);
- while (*bp++ = *p++)
- continue;
- --bp;
+ while (*p)
+ *bp++ = *p++;
break;
case 'd':
ul = lflag ? va_arg(ap, long) : va_arg(ap, int);
@@ -575,8 +574,8 @@ reswitch: switch (ch = *(u_char *)fmt++) {
case 'x':
ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int);
base = 16;
-number: for (p = ksprintn(ul, base, NULL); ch = *p--;)
- *bp++ = ch;
+number: for (p = ksprintn(ul, base, NULL); *p;)
+ *bp++ = *p--;
break;
default:
*bp++ = '%';
diff --git a/sys/kern/subr_rlist.c b/sys/kern/subr_rlist.c
index 0bc1778..ae4b012 100644
--- a/sys/kern/subr_rlist.c
+++ b/sys/kern/subr_rlist.c
@@ -45,7 +45,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: subr_rlist.c,v 1.5 1993/12/22 12:51:39 davidg Exp $
+ * $Id: subr_rlist.c,v 1.6 1994/08/13 03:50:24 wollman Exp $
*/
#include <sys/param.h>
@@ -53,6 +53,7 @@
#include <sys/cdefs.h>
#include <sys/malloc.h>
#include <sys/rlist.h>
+#include <sys/proc.h>
#include <vm/vm.h>
#include <vm/vm_map.h>
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index 167e129..5541b07 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)sys_generic.c 8.5 (Berkeley) 1/21/94
- * $Id: sys_generic.c,v 1.5 1994/09/02 15:06:39 davidg Exp $
+ * $Id: sys_generic.c,v 1.6 1994/09/25 19:33:48 phk Exp $
*/
#include <sys/param.h>
@@ -45,6 +45,9 @@
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/proc.h>
+#include <sys/stat.h>
+#include <sys/signalvar.h>
+#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/uio.h>
#include <sys/kernel.h>
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c
index d909cf3..f7ced53 100644
--- a/sys/kern/sys_socket.c
+++ b/sys/kern/sys_socket.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)sys_socket.c 8.1 (Berkeley) 6/10/93
- * $Id$
+ * $Id: sys_socket.c,v 1.3 1994/08/02 07:42:42 davidg Exp $
*/
#include <sys/param.h>
@@ -41,6 +41,7 @@
#include <sys/mbuf.h>
#include <sys/protosw.h>
#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/socketvar.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c
index cdd9226..4ef4bf7 100644
--- a/sys/kern/sysv_msg.c
+++ b/sys/kern/sysv_msg.c
@@ -1,4 +1,4 @@
-/* $Id: sysv_msg.c,v 1.1 1994/09/13 14:46:57 dfr Exp $ */
+/* $Id: sysv_msg.c,v 1.2 1994/09/17 13:24:16 davidg Exp $ */
/*
* Implementation of SVID messages
@@ -41,7 +41,6 @@ void
msginit()
{
register int i;
- vm_offset_t whocares1, whocares2;
/*
* msginfo.msgssz should be a power of two for efficiency reasons.
@@ -154,7 +153,7 @@ msgctl(p, uap, retval)
int cmd = uap->cmd;
struct msqid_ds *user_msqptr = uap->user_msqptr;
struct ucred *cred = p->p_ucred;
- int i, rval, eval;
+ int rval, eval;
struct msqid_ds msqbuf;
register struct msqid_ds *msqptr;
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index 53a2e9f..751896a 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -1,4 +1,4 @@
-/* $Id: sysv_sem.c,v 1.1 1994/09/13 14:47:00 dfr Exp $ */
+/* $Id: sysv_sem.c,v 1.2 1994/09/17 13:24:17 davidg Exp $ */
/*
* Implementation of SVID semaphores
@@ -25,7 +25,6 @@ void
seminit()
{
register int i;
- vm_offset_t whocares1, whocares2;
if (sema == NULL)
panic("sema is NULL");
@@ -582,7 +581,7 @@ semop(p, uap, retval)
struct sem_undo *suptr = NULL;
struct ucred *cred = p->p_ucred;
int i, j, eval;
- int all_ok, do_wakeup, do_undos;
+ int do_wakeup, do_undos;
#ifdef SEM_DEBUG
printf("call to semop(%d, 0x%x, %d)\n", semid, sops, nsops);
diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c
index 33e0d7c..cb1a664 100644
--- a/sys/kern/sysv_shm.c
+++ b/sys/kern/sysv_shm.c
@@ -1,4 +1,4 @@
-/* $Id: sysv_shm.c,v 1.1 1994/09/13 14:47:03 dfr Exp $ */
+/* $Id: sysv_shm.c,v 1.2 1994/09/16 17:43:22 dfr Exp $ */
/* $NetBSD: sysv_shm.c,v 1.23 1994/07/04 23:25:12 glass Exp $ */
/*
@@ -212,8 +212,9 @@ shmat(p, uap, retval)
shmseg = shm_find_segment_by_shmid(uap->shmid);
if (shmseg == NULL)
return EINVAL;
- if (error = ipcperm(cred, &shmseg->shm_perm,
- (uap->shmflg & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W))
+ error = ipcperm(cred, &shmseg->shm_perm,
+ (uap->shmflg & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W);
+ if (error)
return error;
for (i = 0; i < shminfo.shmseg; i++) {
if (shmmap_s->shmid == -1)
@@ -277,7 +278,7 @@ oshmctl(p, uap, retval)
int *retval;
{
#ifdef COMPAT_43
- int error, segnum;
+ int error;
struct ucred *cred = p->p_ucred;
struct shmid_ds *shmseg;
struct oshmid_ds outbuf;
@@ -287,7 +288,8 @@ oshmctl(p, uap, retval)
return EINVAL;
switch (uap->cmd) {
case IPC_STAT:
- if (error = ipcperm(cred, &shmseg->shm_perm, IPC_R))
+ error = ipcperm(cred, &shmseg->shm_perm, IPC_R);
+ if (error)
return error;
outbuf.shm_perm = shmseg->shm_perm;
outbuf.shm_segsz = shmseg->shm_segsz;
@@ -298,7 +300,8 @@ oshmctl(p, uap, retval)
outbuf.shm_dtime = shmseg->shm_dtime;
outbuf.shm_ctime = shmseg->shm_ctime;
outbuf.shm_handle = shmseg->shm_internal;
- if (error = copyout((caddr_t)&outbuf, uap->ubuf, sizeof(outbuf)))
+ error = copyout((caddr_t)&outbuf, uap->ubuf, sizeof(outbuf));
+ if (error)
return error;
break;
default:
@@ -321,7 +324,7 @@ shmctl(p, uap, retval)
struct shmctl_args *uap;
int *retval;
{
- int error, segnum;
+ int error;
struct ucred *cred = p->p_ucred;
struct shmid_ds inbuf;
struct shmid_ds *shmseg;
@@ -331,15 +334,19 @@ shmctl(p, uap, retval)
return EINVAL;
switch (uap->cmd) {
case IPC_STAT:
- if (error = ipcperm(cred, &shmseg->shm_perm, IPC_R))
+ error = ipcperm(cred, &shmseg->shm_perm, IPC_R);
+ if (error)
return error;
- if (error = copyout((caddr_t)shmseg, uap->ubuf, sizeof(inbuf)))
+ error = copyout((caddr_t)shmseg, uap->ubuf, sizeof(inbuf));
+ if (error)
return error;
break;
case IPC_SET:
- if (error = ipcperm(cred, &shmseg->shm_perm, IPC_M))
+ error = ipcperm(cred, &shmseg->shm_perm, IPC_M);
+ if (error)
return error;
- if (error = copyin(uap->ubuf, (caddr_t)&inbuf, sizeof(inbuf)))
+ error = copyin(uap->ubuf, (caddr_t)&inbuf, sizeof(inbuf));
+ if (error)
return error;
shmseg->shm_perm.uid = inbuf.shm_perm.uid;
shmseg->shm_perm.gid = inbuf.shm_perm.gid;
@@ -349,7 +356,8 @@ shmctl(p, uap, retval)
shmseg->shm_ctime = time.tv_sec;
break;
case IPC_RMID:
- if (error = ipcperm(cred, &shmseg->shm_perm, IPC_M))
+ error = ipcperm(cred, &shmseg->shm_perm, IPC_M);
+ if (error)
return error;
shmseg->shm_perm.key = IPC_PRIVATE;
shmseg->shm_perm.mode |= SHMSEG_REMOVED;
@@ -393,12 +401,13 @@ shmget_existing(p, uap, mode, segnum, retval)
* allocation failed or it was freed).
*/
shmseg->shm_perm.mode |= SHMSEG_WANTED;
- if (error =
- tsleep((caddr_t)shmseg, PLOCK | PCATCH, "shmget", 0))
+ error = tsleep((caddr_t)shmseg, PLOCK | PCATCH, "shmget", 0);
+ if (error)
return error;
return EAGAIN;
}
- if (error = ipcperm(cred, &shmseg->shm_perm, mode))
+ error = ipcperm(cred, &shmseg->shm_perm, mode);
+ if (error)
return error;
if (uap->size && uap->size > shmseg->shm_segsz)
return EINVAL;
@@ -490,7 +499,6 @@ shmget(p, uap, retval)
int *retval;
{
int segnum, mode, error;
- struct shmid_ds *shmseg;
mode = uap->shmflg & ACCESSPERMS;
if (uap->key != IPC_PRIVATE) {
@@ -546,7 +554,6 @@ shmexit(p)
struct proc *p;
{
struct shmmap_state *shmmap_s;
- struct shmid_ds *shmseg;
int i;
shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 79441ba..48e4fc5 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.c 8.8 (Berkeley) 1/21/94
- * $Id: tty.c,v 1.5 1994/08/02 07:42:46 davidg Exp $
+ * $Id: tty.c,v 1.6 1994/08/18 09:16:21 davidg Exp $
*/
#include <sys/param.h>
@@ -53,6 +53,8 @@
#include <sys/kernel.h>
#include <sys/vnode.h>
#include <sys/syslog.h>
+#include <sys/signalvar.h>
+#include <sys/resourcevar.h>
#include <vm/vm.h>
@@ -214,8 +216,8 @@ ttyclose(tp)
/* Is 'c' a line delimiter ("break" character)? */
#define TTBREAKC(c) \
- ((c) == '\n' || ((c) == cc[VEOF] || \
- (c) == cc[VEOL] || (c) == cc[VEOL2]) && (c) != _POSIX_VDISABLE)
+ ((c) == '\n' || (((c) == cc[VEOF] || \
+ (c) == cc[VEOL] || (c) == cc[VEOL2]) && (c) != _POSIX_VDISABLE))
/*
@@ -251,7 +253,8 @@ ttyinput(c, tp)
/* Handle exceptional conditions (break, parity, framing). */
cc = tp->t_cc;
iflag = tp->t_iflag;
- if (err = (ISSET(c, TTY_ERRORMASK))) {
+ err = (ISSET(c, TTY_ERRORMASK));
+ if (err) {
CLR(c, TTY_ERRORMASK);
if (ISSET(err, TTY_FE) && !c) { /* Break. */
if (ISSET(iflag, IGNBRK))
@@ -262,8 +265,8 @@ ttyinput(c, tp)
c = cc[VINTR];
else if (ISSET(iflag, PARMRK))
goto parmrk;
- } else if (ISSET(err, TTY_PE) &&
- ISSET(iflag, INPCK) || ISSET(err, TTY_FE)) {
+ } else if ((ISSET(err, TTY_PE) && ISSET(iflag, INPCK))
+ || ISSET(err, TTY_FE)) {
if (ISSET(iflag, IGNPAR))
goto endcase;
else if (ISSET(iflag, PARMRK)) {
@@ -667,8 +670,8 @@ ttioctl(tp, cmd, data, flag)
(p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
(p->p_sigmask & sigmask(SIGTTOU)) == 0) {
pgsignal(p->p_pgrp, SIGTTOU, 1);
- if (error = ttysleep(tp,
- &lbolt, TTOPRI | PCATCH, ttybg, 0))
+ error = ttysleep(tp, &lbolt, TTOPRI | PCATCH, ttybg, 0);
+ if (error)
return (error);
}
break;
@@ -718,7 +721,8 @@ ttioctl(tp, cmd, data, flag)
constty = NULL;
break;
case TIOCDRAIN: /* wait till output drained */
- if (error = ttywait(tp))
+ error = ttywait(tp);
+ if (error)
return (error);
break;
case TIOCGETA: { /* get termios struct */
@@ -760,7 +764,8 @@ ttioctl(tp, cmd, data, flag)
s = spltty();
if (cmd == TIOCSETAW || cmd == TIOCSETAF) {
- if (error = ttywait(tp)) {
+ error = ttywait(tp);
+ if (error) {
splx(s);
return (error);
}
@@ -870,8 +875,8 @@ ttioctl(tp, cmd, data, flag)
case TIOCSCTTY: /* become controlling tty */
/* Session ctty vnode pointer set in vnode layer. */
if (!SESS_LEADER(p) ||
- (p->p_session->s_ttyvp || tp->t_session) &&
- (tp->t_session != p->p_session))
+ ((p->p_session->s_ttyvp || tp->t_session) &&
+ (tp->t_session != p->p_session)))
return (EPERM);
tp->t_session = p->p_session;
tp->t_pgrp = p->p_pgrp;
@@ -923,8 +928,8 @@ ttselect(device, rw, p)
switch (rw) {
case FREAD:
nread = ttnread(tp);
- if (nread > 0 || !ISSET(tp->t_cflag, CLOCAL) &&
- !ISSET(tp->t_state, TS_CARR_ON))
+ if (nread > 0 || (!ISSET(tp->t_cflag, CLOCAL) &&
+ !ISSET(tp->t_state, TS_CARR_ON)))
goto win;
selrecord(p, &tp->t_rsel);
break;
@@ -970,8 +975,8 @@ ttywait(tp)
&& tp->t_oproc) {
(*tp->t_oproc)(tp);
SET(tp->t_state, TS_ASLEEP);
- if (error = ttysleep(tp,
- &tp->t_outq, TTOPRI | PCATCH, ttyout, 0))
+ error = ttysleep(tp, &tp->t_outq, TTOPRI | PCATCH, ttyout, 0);
+ if (error)
break;
}
splx(s);
@@ -1054,10 +1059,10 @@ ttyblock(tp)
* Block further input iff: current input > threshold
* AND input is available to user program.
*/
- if (total >= TTYHOG / 2 &&
+ if ((total >= TTYHOG / 2 &&
!ISSET(tp->t_state, TS_TBLOCK) &&
- !ISSET(tp->t_lflag, ICANON) || tp->t_canq.c_cc > 0 &&
- tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
+ !ISSET(tp->t_lflag, ICANON)) || (tp->t_canq.c_cc > 0 &&
+ tp->t_cc[VSTOP] != _POSIX_VDISABLE)) {
if (putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
SET(tp->t_state, TS_TBLOCK);
ttstart(tp);
@@ -1237,7 +1242,8 @@ loop: lflag = tp->t_lflag;
p->p_flag & P_PPWAIT || p->p_pgrp->pg_jobc == 0)
return (EIO);
pgsignal(p->p_pgrp, SIGTTIN, 1);
- if (error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0))
+ error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0);
+ if (error)
return (error);
goto loop;
}
@@ -1289,8 +1295,9 @@ loop: lflag = tp->t_lflag;
if (CCEQ(cc[VDSUSP], c) && ISSET(lflag, ISIG)) {
pgsignal(tp->t_pgrp, SIGTSTP, 1);
if (first) {
- if (error = ttysleep(tp,
- &lbolt, TTIPRI | PCATCH, ttybg, 0))
+ error = ttysleep(tp,
+ &lbolt, TTIPRI | PCATCH, ttybg, 0);
+ if (error)
break;
goto loop;
}
@@ -1417,7 +1424,8 @@ loop:
(p->p_sigmask & sigmask(SIGTTOU)) == 0 &&
p->p_pgrp->pg_jobc) {
pgsignal(p->p_pgrp, SIGTTOU, 1);
- if (error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0))
+ error = ttysleep(tp, &lbolt, TTIPRI | PCATCH, ttybg, 0);
+ if (error)
goto out;
goto loop;
}
@@ -1470,8 +1478,9 @@ loop:
if (ttyoutput(*cp, tp) >= 0) {
/* No Clists, wait a bit. */
ttstart(tp);
- if (error = ttysleep(tp, &lbolt,
- TTOPRI | PCATCH, ttybuf, 0))
+ error = ttysleep(tp, &lbolt,
+ TTOPRI | PCATCH, ttybuf, 0);
+ if (error)
break;
goto loop;
}
@@ -1500,8 +1509,9 @@ loop:
if (i > 0) {
/* No Clists, wait a bit. */
ttstart(tp);
- if (error = ttysleep(tp,
- &lbolt, TTOPRI | PCATCH, ttybuf, 0))
+ error = ttysleep(tp,
+ &lbolt, TTOPRI | PCATCH, ttybuf, 0);
+ if (error)
break;
goto loop;
}
@@ -1701,7 +1711,7 @@ ttyecho(c, tp)
ISSET(tp->t_lflag, EXTPROC))
return;
if (ISSET(tp->t_lflag, ECHOCTL) &&
- (ISSET(c, TTY_CHARMASK) <= 037 && c != '\t' && c != '\n' ||
+ ((ISSET(c, TTY_CHARMASK) <= 037 && c != '\t' && c != '\n') ||
ISSET(c, TTY_CHARMASK) == 0177)) {
(void)ttyoutput('^', tp);
CLR(c, ~TTY_CHARMASK);
@@ -1812,7 +1822,7 @@ ttyinfo(tp)
#define pgtok(a) (((a) * NBPG) / 1024)
/* Print percentage cpu, resident set size. */
- tmp = pick->p_pctcpu * 10000 + FSCALE / 2 >> FSHIFT;
+ tmp = (pick->p_pctcpu * 10000 + FSCALE / 2) >> FSHIFT;
ttyprintf(tp, "%d%% %dk\n",
tmp / 100,
pick->p_stat == SIDL || pick->p_stat == SZOMB ? 0 :
@@ -1939,7 +1949,8 @@ ttysleep(tp, chan, pri, wmesg, timo)
short gen;
gen = tp->t_gen;
- if (error = tsleep(chan, pri, wmesg, timo))
+ error = tsleep(chan, pri, wmesg, timo);
+ if (error)
return (error);
return (tp->t_gen == gen ? 0 : ERESTART);
}
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index 210aac6..a2d16ee 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.2 (Berkeley) 9/23/93
- * $Id: tty_pty.c,v 1.3 1994/08/02 07:42:51 davidg Exp $
+ * $Id: tty_pty.c,v 1.4 1994/09/15 19:47:16 bde Exp $
*/
/*
@@ -50,6 +50,7 @@
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
+#include <sys/signalvar.h>
#if NPTY == 1
#undef NPTY
@@ -137,8 +138,9 @@ ptsopen(dev, flag, devtype, p)
tp->t_state |= TS_WOPEN;
if (flag&FNONBLOCK)
break;
- if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
- ttopen, 0))
+ error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
+ ttopen, 0);
+ if (error)
return (error);
}
error = (*linesw[tp->t_line].l_open)(dev, tp);
@@ -182,15 +184,17 @@ again:
p->p_flag & P_PPWAIT)
return (EIO);
pgsignal(p->p_pgrp, SIGTTIN, 1);
- if (error = ttysleep(tp, (caddr_t)&lbolt,
- TTIPRI | PCATCH, ttybg, 0))
+ error = ttysleep(tp, (caddr_t)&lbolt,
+ TTIPRI | PCATCH, ttybg, 0);
+ if (error)
return (error);
}
if (tp->t_canq.c_cc == 0) {
if (flag & IO_NDELAY)
return (EWOULDBLOCK);
- if (error = ttysleep(tp, (caddr_t)&tp->t_canq,
- TTIPRI | PCATCH, ttyin, 0))
+ error = ttysleep(tp, (caddr_t)&tp->t_canq,
+ TTIPRI | PCATCH, ttyin, 0);
+ if (error)
return (error);
goto again;
}
@@ -358,8 +362,9 @@ ptcread(dev, uio, flag)
return (0); /* EOF */
if (flag & IO_NDELAY)
return (EWOULDBLOCK);
- if (error = tsleep((caddr_t)&tp->t_outq.c_cf, TTIPRI | PCATCH,
- ttyin, 0))
+ error = tsleep((caddr_t)&tp->t_outq.c_cf, TTIPRI | PCATCH,
+ ttyin, 0);
+ if (error)
return (error);
}
if (pti->pt_flags & (PF_PKT|PF_UCNTL))
@@ -433,8 +438,8 @@ ptcselect(dev, rw, p)
case 0: /* exceptional */
if ((tp->t_state&TS_ISOPEN) &&
- (pti->pt_flags&PF_PKT && pti->pt_send ||
- pti->pt_flags&PF_UCNTL && pti->pt_ucntl))
+ ((pti->pt_flags&PF_PKT && pti->pt_send) ||
+ (pti->pt_flags&PF_UCNTL && pti->pt_ucntl)))
return (1);
selrecord(p, &pti->pt_selr);
break;
@@ -538,8 +543,8 @@ block:
return (EWOULDBLOCK);
return (0);
}
- if (error = tsleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI | PCATCH,
- ttyout, 0)) {
+ error = tsleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI | PCATCH, ttyout, 0);
+ if (error) {
/* adjust for data copied in but not written */
uio->uio_resid += cc;
return (error);
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index a75ba75..0b35abb 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
- * $Id$
+ * $Id: uipc_mbuf.c,v 1.3 1994/08/02 07:43:02 davidg Exp $
*/
#include <sys/param.h>
@@ -48,8 +48,6 @@
#include <vm/vm.h>
-void m_reclaim __P(());
-
extern vm_map_t mb_map;
struct mbuf *mbutl;
char *mclrefcnt;
@@ -215,7 +213,8 @@ m_freem(m)
return;
do {
MFREE(m, n);
- } while (m = n);
+ m = n;
+ } while (m);
}
/*
@@ -455,8 +454,8 @@ m_adj(mp, req_len)
}
count -= m->m_len;
}
- while (m = m->m_next)
- m->m_len = 0;
+ while (m->m_next)
+ (m = m->m_next) ->m_len = 0;
}
}
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
index 6f16e23..2da7643 100644
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
- * $Id$
+ * $Id: uipc_socket2.c,v 1.3 1994/08/02 07:43:08 davidg Exp $
*/
#include <sys/param.h>
@@ -42,16 +42,10 @@
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
+#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
-
-void soqinsque __P((struct socket *, struct socket *, int));
-void sowakeup __P((struct socket *, struct sockbuf *));
-void sbrelease __P((struct sockbuf *));
-void sbappendrecord __P((struct sockbuf *, struct mbuf *));
-void sbcompress __P((struct sockbuf *, struct mbuf *, struct mbuf *));
-void sbflush __P((struct sockbuf *));
-void sbdrop __P((struct sockbuf *, int));
+#include <sys/signalvar.h>
/*
* Primitive routines for operating on sockets and socket buffers
@@ -299,9 +293,10 @@ sb_lock(sb)
while (sb->sb_flags & SB_LOCK) {
sb->sb_flags |= SB_WANT;
- if (error = tsleep((caddr_t)&sb->sb_flags,
+ error = tsleep((caddr_t)&sb->sb_flags,
(sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK|PCATCH,
- netio, 0))
+ netio, 0);
+ if (error)
return (error);
}
sb->sb_flags |= SB_LOCK;
@@ -461,7 +456,8 @@ sbappend(sb, m)
if (m == 0)
return;
- if (n = sb->sb_mb) {
+ n = sb->sb_mb;
+ if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
do {
@@ -511,7 +507,8 @@ sbappendrecord(sb, m0)
if (m0 == 0)
return;
- if (m = sb->sb_mb)
+ m = sb->sb_mb;
+ if (m)
while (m->m_nextpkt)
m = m->m_nextpkt;
/*
@@ -547,7 +544,8 @@ sbinsertoob(sb, m0)
if (m0 == 0)
return;
- for (mp = &sb->sb_mb; m = *mp; mp = &((*mp)->m_nextpkt)) {
+ for (mp = &sb->sb_mb; *mp ; mp = &((*mp)->m_nextpkt)) {
+ m = *mp;
again:
switch (m->m_type) {
@@ -555,7 +553,8 @@ sbinsertoob(sb, m0)
continue; /* WANT next train */
case MT_CONTROL:
- if (m = m->m_next)
+ m = m->m_next;
+ if (m)
goto again; /* inspect THIS train further */
}
break;
@@ -616,7 +615,8 @@ panic("sbappendaddr");
m->m_next = control;
for (n = m; n; n = n->m_next)
sballoc(sb, n);
- if (n = sb->sb_mb) {
+ n = sb->sb_mb;
+ if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
n->m_nextpkt = m;
@@ -648,7 +648,8 @@ sbappendcontrol(sb, m0, control)
n->m_next = m0; /* concatenate data to control */
for (m = control; m; m = m->m_next)
sballoc(sb, m);
- if (n = sb->sb_mb) {
+ n = sb->sb_mb;
+ if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
n->m_nextpkt = control;
@@ -783,6 +784,7 @@ sbdroprecord(sb)
do {
sbfree(sb, m);
MFREE(m, mn);
- } while (m = mn);
+ m = mn;
+ } while (m);
}
}
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index b50b263..91c3356 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94
- * $Id$
+ * $Id: uipc_socket.c,v 1.4 1994/08/02 07:43:06 davidg Exp $
*/
#include <sys/param.h>
@@ -46,9 +46,7 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/resourcevar.h>
-
-void sofree __P((struct socket *));
-void sorflush __P((struct socket *));
+#include <sys/signalvar.h>
/*
* Socket operation routines.
@@ -181,10 +179,12 @@ soclose(so)
if ((so->so_state & SS_ISDISCONNECTING) &&
(so->so_state & SS_NBIO))
goto drop;
- while (so->so_state & SS_ISCONNECTED)
- if (error = tsleep((caddr_t)&so->so_timeo,
- PSOCK | PCATCH, netcls, so->so_linger))
+ while (so->so_state & SS_ISCONNECTED) {
+ error = tsleep((caddr_t)&so->so_timeo,
+ PSOCK | PCATCH, netcls, so->so_linger);
+ if (error)
break;
+ }
}
}
drop:
@@ -354,7 +354,8 @@ sosend(so, addr, uio, top, control, flags)
#define snderr(errno) { error = errno; splx(s); goto release; }
restart:
- if (error = sblock(&so->so_snd, SBLOCKWAIT(flags)))
+ error = sblock(&so->so_snd, SBLOCKWAIT(flags));
+ if (error)
goto out;
do {
s = splnet();
@@ -373,7 +374,7 @@ restart:
space = sbspace(&so->so_snd);
if (flags & MSG_OOB)
space += 1024;
- if (atomic && resid > so->so_snd.sb_hiwat ||
+ if ((atomic && resid > so->so_snd.sb_hiwat) ||
clen > so->so_snd.sb_hiwat)
snderr(EMSGSIZE);
if (space < resid + clen && uio &&
@@ -531,7 +532,8 @@ bad:
(struct mbuf *)0, (struct mbuf *)0);
restart:
- if (error = sblock(&so->so_rcv, SBLOCKWAIT(flags)))
+ error = sblock(&so->so_rcv, SBLOCKWAIT(flags));
+ if (error)
return (error);
s = splnet();
@@ -547,11 +549,11 @@ restart:
* we have to do the receive in sections, and thus risk returning
* a short count if a timeout or signal occurs after we start.
*/
- if (m == 0 || ((flags & MSG_DONTWAIT) == 0 &&
+ if (m == 0 || (((flags & MSG_DONTWAIT) == 0 &&
so->so_rcv.sb_cc < uio->uio_resid) &&
(so->so_rcv.sb_cc < so->so_rcv.sb_lowat ||
((flags & MSG_WAITALL) && uio->uio_resid <= so->so_rcv.sb_hiwat)) &&
- m->m_nextpkt == 0 && (pr->pr_flags & PR_ATOMIC) == 0) {
+ m->m_nextpkt == 0 && (pr->pr_flags & PR_ATOMIC) == 0)) {
#ifdef DIAGNOSTIC
if (m == 0 && so->so_rcv.sb_cc)
panic("receive 1");
@@ -749,7 +751,8 @@ dontblock:
splx(s);
return (0);
}
- if (m = so->so_rcv.sb_mb)
+ m = so->so_rcv.sb_mb;
+ if (m)
nextrecord = m->m_nextpkt;
}
}
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index 6f16e23..2da7643 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
- * $Id$
+ * $Id: uipc_socket2.c,v 1.3 1994/08/02 07:43:08 davidg Exp $
*/
#include <sys/param.h>
@@ -42,16 +42,10 @@
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
+#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
-
-void soqinsque __P((struct socket *, struct socket *, int));
-void sowakeup __P((struct socket *, struct sockbuf *));
-void sbrelease __P((struct sockbuf *));
-void sbappendrecord __P((struct sockbuf *, struct mbuf *));
-void sbcompress __P((struct sockbuf *, struct mbuf *, struct mbuf *));
-void sbflush __P((struct sockbuf *));
-void sbdrop __P((struct sockbuf *, int));
+#include <sys/signalvar.h>
/*
* Primitive routines for operating on sockets and socket buffers
@@ -299,9 +293,10 @@ sb_lock(sb)
while (sb->sb_flags & SB_LOCK) {
sb->sb_flags |= SB_WANT;
- if (error = tsleep((caddr_t)&sb->sb_flags,
+ error = tsleep((caddr_t)&sb->sb_flags,
(sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK|PCATCH,
- netio, 0))
+ netio, 0);
+ if (error)
return (error);
}
sb->sb_flags |= SB_LOCK;
@@ -461,7 +456,8 @@ sbappend(sb, m)
if (m == 0)
return;
- if (n = sb->sb_mb) {
+ n = sb->sb_mb;
+ if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
do {
@@ -511,7 +507,8 @@ sbappendrecord(sb, m0)
if (m0 == 0)
return;
- if (m = sb->sb_mb)
+ m = sb->sb_mb;
+ if (m)
while (m->m_nextpkt)
m = m->m_nextpkt;
/*
@@ -547,7 +544,8 @@ sbinsertoob(sb, m0)
if (m0 == 0)
return;
- for (mp = &sb->sb_mb; m = *mp; mp = &((*mp)->m_nextpkt)) {
+ for (mp = &sb->sb_mb; *mp ; mp = &((*mp)->m_nextpkt)) {
+ m = *mp;
again:
switch (m->m_type) {
@@ -555,7 +553,8 @@ sbinsertoob(sb, m0)
continue; /* WANT next train */
case MT_CONTROL:
- if (m = m->m_next)
+ m = m->m_next;
+ if (m)
goto again; /* inspect THIS train further */
}
break;
@@ -616,7 +615,8 @@ panic("sbappendaddr");
m->m_next = control;
for (n = m; n; n = n->m_next)
sballoc(sb, n);
- if (n = sb->sb_mb) {
+ n = sb->sb_mb;
+ if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
n->m_nextpkt = m;
@@ -648,7 +648,8 @@ sbappendcontrol(sb, m0, control)
n->m_next = m0; /* concatenate data to control */
for (m = control; m; m = m->m_next)
sballoc(sb, m);
- if (n = sb->sb_mb) {
+ n = sb->sb_mb;
+ if (n) {
while (n->m_nextpkt)
n = n->m_nextpkt;
n->m_nextpkt = control;
@@ -783,6 +784,7 @@ sbdroprecord(sb)
do {
sbfree(sb, m);
MFREE(m, mn);
- } while (m = mn);
+ m = mn;
+ } while (m);
}
}
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 1674039..e2ad45a 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
- * $Id$
+ * $Id: uipc_syscalls.c,v 1.3 1994/08/02 07:43:10 davidg Exp $
*/
#include <sys/param.h>
@@ -43,8 +43,10 @@
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/protosw.h>
+#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
+#include <sys/signalvar.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
@@ -74,12 +76,14 @@ socket(p, uap, retval)
struct file *fp;
int fd, error;
- if (error = falloc(p, &fp, &fd))
+ error = falloc(p, &fp, &fd);
+ if (error)
return (error);
fp->f_flag = FREAD|FWRITE;
fp->f_type = DTYPE_SOCKET;
fp->f_ops = &socketops;
- if (error = socreate(uap->domain, &so, uap->type, uap->protocol)) {
+ error = socreate(uap->domain, &so, uap->type, uap->protocol);
+ if (error) {
fdp->fd_ofiles[fd] = 0;
ffree(fp);
} else {
@@ -105,9 +109,11 @@ bind(p, uap, retval)
struct mbuf *nam;
int error;
- if (error = getsock(p->p_fd, uap->s, &fp))
+ error = getsock(p->p_fd, uap->s, &fp);
+ if (error)
return (error);
- if (error = sockargs(&nam, uap->name, uap->namelen, MT_SONAME))
+ error = sockargs(&nam, uap->name, uap->namelen, MT_SONAME);
+ if (error)
return (error);
error = sobind((struct socket *)fp->f_data, nam);
m_freem(nam);
@@ -128,7 +134,8 @@ listen(p, uap, retval)
struct file *fp;
int error;
- if (error = getsock(p->p_fd, uap->s, &fp))
+ error = getsock(p->p_fd, uap->s, &fp);
+ if (error)
return (error);
return (solisten((struct socket *)fp->f_data, uap->backlog));
}
@@ -142,32 +149,9 @@ struct accept_args {
#endif
};
-#ifdef COMPAT_OLDSOCK
-int
-accept(p, uap, retval)
- struct proc *p;
- struct accept_args *uap;
- int *retval;
-{
-
- uap->compat_43 = 0;
- return (accept1(p, uap, retval));
-}
-
-int
-oaccept(p, uap, retval)
- struct proc *p;
- struct accept_args *uap;
- int *retval;
-{
-
- uap->compat_43 = 1;
- return (accept1(p, uap, retval));
-}
-#else /* COMPAT_OLDSOCK */
-
-#define accept1 accept
-#endif
+#ifndef COMPAT_OLDSOCK
+# define accept1 accept
+#endif /* COMPAT_OLDSOCK*/
int
accept1(p, uap, retval)
@@ -180,10 +164,14 @@ accept1(p, uap, retval)
int namelen, error, s;
register struct socket *so;
- if (uap->name && (error = copyin((caddr_t)uap->anamelen,
- (caddr_t)&namelen, sizeof (namelen))))
- return (error);
- if (error = getsock(p->p_fd, uap->s, &fp))
+ if (uap->name) {
+ error = copyin((caddr_t)uap->anamelen, (caddr_t)&namelen,
+ sizeof (namelen));
+ if(error)
+ return (error);
+ }
+ error = getsock(p->p_fd, uap->s, &fp);
+ if (error)
return (error);
s = splnet();
so = (struct socket *)fp->f_data;
@@ -200,8 +188,9 @@ accept1(p, uap, retval)
so->so_error = ECONNABORTED;
break;
}
- if (error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
- netcon, 0)) {
+ error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
+ netcon, 0);
+ if (error) {
splx(s);
return (error);
}
@@ -212,7 +201,8 @@ accept1(p, uap, retval)
splx(s);
return (error);
}
- if (error = falloc(p, &fp, retval)) {
+ error = falloc(p, &fp, retval);
+ if (error) {
splx(s);
return (error);
}
@@ -236,8 +226,9 @@ accept1(p, uap, retval)
if (namelen > nam->m_len)
namelen = nam->m_len;
/* SHOULD COPY OUT A CHAIN HERE */
- if ((error = copyout(mtod(nam, caddr_t), (caddr_t)uap->name,
- (u_int)namelen)) == 0)
+ error = copyout(mtod(nam, caddr_t), (caddr_t)uap->name,
+ (u_int)namelen);
+ if (!error)
error = copyout((caddr_t)&namelen,
(caddr_t)uap->anamelen, sizeof (*uap->anamelen));
}
@@ -246,6 +237,30 @@ accept1(p, uap, retval)
return (error);
}
+#ifdef COMPAT_OLDSOCK
+int
+accept(p, uap, retval)
+ struct proc *p;
+ struct accept_args *uap;
+ int *retval;
+{
+
+ uap->compat_43 = 0;
+ return (accept1(p, uap, retval));
+}
+
+int
+oaccept(p, uap, retval)
+ struct proc *p;
+ struct accept_args *uap;
+ int *retval;
+{
+
+ uap->compat_43 = 1;
+ return (accept1(p, uap, retval));
+}
+#endif /* COMPAT_OLDSOCK */
+
struct connect_args {
int s;
caddr_t name;
@@ -263,12 +278,14 @@ connect(p, uap, retval)
struct mbuf *nam;
int error, s;
- if (error = getsock(p->p_fd, uap->s, &fp))
+ error = getsock(p->p_fd, uap->s, &fp);
+ if (error)
return (error);
so = (struct socket *)fp->f_data;
if ((so->so_state & SS_NBIO) && (so->so_state & SS_ISCONNECTING))
return (EALREADY);
- if (error = sockargs(&nam, uap->name, uap->namelen, MT_SONAME))
+ error = sockargs(&nam, uap->name, uap->namelen, MT_SONAME);
+ if (error)
return (error);
error = soconnect(so, nam);
if (error)
@@ -278,10 +295,12 @@ connect(p, uap, retval)
return (EINPROGRESS);
}
s = splnet();
- while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0)
- if (error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
- netcon, 0))
+ while ((so->so_state & SS_ISCONNECTING) && so->so_error == 0) {
+ error = tsleep((caddr_t)&so->so_timeo, PSOCK | PCATCH,
+ netcon, 0);
+ if (error)
break;
+ }
if (error == 0) {
error = so->so_error;
so->so_error = 0;
@@ -312,31 +331,37 @@ socketpair(p, uap, retval)
struct socket *so1, *so2;
int fd, error, sv[2];
- if (error = socreate(uap->domain, &so1, uap->type, uap->protocol))
+ error = socreate(uap->domain, &so1, uap->type, uap->protocol);
+ if (error)
return (error);
- if (error = socreate(uap->domain, &so2, uap->type, uap->protocol))
+ error = socreate(uap->domain, &so2, uap->type, uap->protocol);
+ if (error)
goto free1;
- if (error = falloc(p, &fp1, &fd))
+ error = falloc(p, &fp1, &fd);
+ if (error)
goto free2;
sv[0] = fd;
fp1->f_flag = FREAD|FWRITE;
fp1->f_type = DTYPE_SOCKET;
fp1->f_ops = &socketops;
fp1->f_data = (caddr_t)so1;
- if (error = falloc(p, &fp2, &fd))
+ error = falloc(p, &fp2, &fd);
+ if (error)
goto free3;
fp2->f_flag = FREAD|FWRITE;
fp2->f_type = DTYPE_SOCKET;
fp2->f_ops = &socketops;
fp2->f_data = (caddr_t)so2;
sv[1] = fd;
- if (error = soconnect2(so1, so2))
+ error = soconnect2(so1, so2);
+ if (error)
goto free4;
if (uap->type == SOCK_DGRAM) {
/*
* Datagram socket connection is asymmetric.
*/
- if (error = soconnect2(so2, so1))
+ error = soconnect2(so2, so1);
+ if (error)
goto free4;
}
error = copyout((caddr_t)sv, (caddr_t)uap->rsv, 2 * sizeof (int));
@@ -356,6 +381,109 @@ free1:
return (error);
}
+int
+sendit(p, s, mp, flags, retsize)
+ register struct proc *p;
+ int s;
+ register struct msghdr *mp;
+ int flags, *retsize;
+{
+ struct file *fp;
+ struct uio auio;
+ register struct iovec *iov;
+ register int i;
+ struct mbuf *to, *control;
+ int len, error;
+#ifdef KTRACE
+ struct iovec *ktriov = NULL;
+#endif
+
+ error = getsock(p->p_fd, s, &fp);
+ if (error)
+ return (error);
+ auio.uio_iov = mp->msg_iov;
+ auio.uio_iovcnt = mp->msg_iovlen;
+ auio.uio_segflg = UIO_USERSPACE;
+ auio.uio_rw = UIO_WRITE;
+ auio.uio_procp = p;
+ auio.uio_offset = 0; /* XXX */
+ auio.uio_resid = 0;
+ iov = mp->msg_iov;
+ for (i = 0; i < mp->msg_iovlen; i++, iov++) {
+ if ((auio.uio_resid += iov->iov_len) < 0)
+ return (EINVAL);
+ }
+ if (mp->msg_name) {
+ error = sockargs(&to, mp->msg_name, mp->msg_namelen, MT_SONAME);
+ if (error)
+ return (error);
+ } else
+ to = 0;
+ if (mp->msg_control) {
+ if (mp->msg_controllen < sizeof(struct cmsghdr)
+#ifdef COMPAT_OLDSOCK
+ && mp->msg_flags != MSG_COMPAT
+#endif
+ ) {
+ error = EINVAL;
+ goto bad;
+ }
+ error = sockargs(&control, mp->msg_control,
+ mp->msg_controllen, MT_CONTROL);
+ if (error)
+ goto bad;
+#ifdef COMPAT_OLDSOCK
+ if (mp->msg_flags == MSG_COMPAT) {
+ register struct cmsghdr *cm;
+
+ M_PREPEND(control, sizeof(*cm), M_WAIT);
+ if (control == 0) {
+ error = ENOBUFS;
+ goto bad;
+ } else {
+ cm = mtod(control, struct cmsghdr *);
+ cm->cmsg_len = control->m_len;
+ cm->cmsg_level = SOL_SOCKET;
+ cm->cmsg_type = SCM_RIGHTS;
+ }
+ }
+#endif
+ } else
+ control = 0;
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_GENIO)) {
+ int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
+
+ MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
+ bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
+ }
+#endif
+ len = auio.uio_resid;
+ error = sosend((struct socket *)fp->f_data, to, &auio,
+ (struct mbuf *)0, control, flags);
+ if (error) {
+ if (auio.uio_resid != len && (error == ERESTART ||
+ error == EINTR || error == EWOULDBLOCK))
+ error = 0;
+ if (error == EPIPE)
+ psignal(p, SIGPIPE);
+ }
+ if (error == 0)
+ *retsize = len - auio.uio_resid;
+#ifdef KTRACE
+ if (ktriov != NULL) {
+ if (error == 0)
+ ktrgenio(p->p_tracep, s, UIO_WRITE,
+ ktriov, *retsize, error);
+ FREE(ktriov, M_TEMP);
+ }
+#endif
+bad:
+ if (to)
+ m_freem(to);
+ return (error);
+}
+
struct sendto_args {
int s;
caddr_t buf;
@@ -413,7 +541,6 @@ osend(p, uap, retval)
return (sendit(p, uap->s, &msg, uap->flags, retval));
}
-#define MSG_COMPAT 0x8000
struct osendmsg_args {
int s;
caddr_t msg;
@@ -429,7 +556,8 @@ osendmsg(p, uap, retval)
struct iovec aiov[UIO_SMALLIOV], *iov;
int error;
- if (error = copyin(uap->msg, (caddr_t)&msg, sizeof (struct omsghdr)))
+ error = copyin(uap->msg, (caddr_t)&msg, sizeof (struct omsghdr));
+ if (error)
return (error);
if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
if ((u_int)msg.msg_iovlen >= UIO_MAXIOV)
@@ -439,8 +567,9 @@ osendmsg(p, uap, retval)
M_WAITOK);
} else
iov = aiov;
- if (error = copyin((caddr_t)msg.msg_iov, (caddr_t)iov,
- (unsigned)(msg.msg_iovlen * sizeof (struct iovec))))
+ error = copyin((caddr_t)msg.msg_iov, (caddr_t)iov,
+ (unsigned)(msg.msg_iovlen * sizeof (struct iovec)));
+ if (error)
goto done;
msg.msg_flags = MSG_COMPAT;
msg.msg_iov = iov;
@@ -467,7 +596,8 @@ sendmsg(p, uap, retval)
struct iovec aiov[UIO_SMALLIOV], *iov;
int error;
- if (error = copyin(uap->msg, (caddr_t)&msg, sizeof (msg)))
+ error = copyin(uap->msg, (caddr_t)&msg, sizeof (msg));
+ if (error)
return (error);
if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
if ((u_int)msg.msg_iovlen >= UIO_MAXIOV)
@@ -492,29 +622,40 @@ done:
return (error);
}
+struct recvfrom_args {
+ int s;
+ caddr_t buf;
+ size_t len;
+ int flags;
+ caddr_t from;
+ int *fromlenaddr;
+};
+
int
-sendit(p, s, mp, flags, retsize)
+recvit(p, s, mp, namelenp, retsize)
register struct proc *p;
int s;
register struct msghdr *mp;
- int flags, *retsize;
+ caddr_t namelenp;
+ int *retsize;
{
struct file *fp;
struct uio auio;
register struct iovec *iov;
register int i;
- struct mbuf *to, *control;
int len, error;
+ struct mbuf *from = 0, *control = 0;
#ifdef KTRACE
struct iovec *ktriov = NULL;
#endif
- if (error = getsock(p->p_fd, s, &fp))
+ error = getsock(p->p_fd, s, &fp);
+ if (error)
return (error);
auio.uio_iov = mp->msg_iov;
auio.uio_iovcnt = mp->msg_iovlen;
auio.uio_segflg = UIO_USERSPACE;
- auio.uio_rw = UIO_WRITE;
+ auio.uio_rw = UIO_READ;
auio.uio_procp = p;
auio.uio_offset = 0; /* XXX */
auio.uio_resid = 0;
@@ -523,42 +664,6 @@ sendit(p, s, mp, flags, retsize)
if ((auio.uio_resid += iov->iov_len) < 0)
return (EINVAL);
}
- if (mp->msg_name) {
- if (error = sockargs(&to, mp->msg_name, mp->msg_namelen,
- MT_SONAME))
- return (error);
- } else
- to = 0;
- if (mp->msg_control) {
- if (mp->msg_controllen < sizeof(struct cmsghdr)
-#ifdef COMPAT_OLDSOCK
- && mp->msg_flags != MSG_COMPAT
-#endif
- ) {
- error = EINVAL;
- goto bad;
- }
- if (error = sockargs(&control, mp->msg_control,
- mp->msg_controllen, MT_CONTROL))
- goto bad;
-#ifdef COMPAT_OLDSOCK
- if (mp->msg_flags == MSG_COMPAT) {
- register struct cmsghdr *cm;
-
- M_PREPEND(control, sizeof(*cm), M_WAIT);
- if (control == 0) {
- error = ENOBUFS;
- goto bad;
- } else {
- cm = mtod(control, struct cmsghdr *);
- cm->cmsg_len = control->m_len;
- cm->cmsg_level = SOL_SOCKET;
- cm->cmsg_type = SCM_RIGHTS;
- }
- }
-#endif
- } else
- control = 0;
#ifdef KTRACE
if (KTRPOINT(p, KTR_GENIO)) {
int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
@@ -568,52 +673,101 @@ sendit(p, s, mp, flags, retsize)
}
#endif
len = auio.uio_resid;
- if (error = sosend((struct socket *)fp->f_data, to, &auio,
- (struct mbuf *)0, control, flags)) {
+ error = soreceive((struct socket *)fp->f_data, &from, &auio,
+ (struct mbuf **)0, mp->msg_control ? &control : (struct mbuf **)0,
+ &mp->msg_flags);
+ if (error) {
if (auio.uio_resid != len && (error == ERESTART ||
error == EINTR || error == EWOULDBLOCK))
error = 0;
- if (error == EPIPE)
- psignal(p, SIGPIPE);
}
- if (error == 0)
- *retsize = len - auio.uio_resid;
#ifdef KTRACE
if (ktriov != NULL) {
if (error == 0)
- ktrgenio(p->p_tracep, s, UIO_WRITE,
- ktriov, *retsize, error);
+ ktrgenio(p->p_tracep, s, UIO_READ,
+ ktriov, len - auio.uio_resid, error);
FREE(ktriov, M_TEMP);
}
#endif
-bad:
- if (to)
- m_freem(to);
+ if (error)
+ goto out;
+ *retsize = len - auio.uio_resid;
+ if (mp->msg_name) {
+ len = mp->msg_namelen;
+ if (len <= 0 || from == 0)
+ len = 0;
+ else {
+#ifdef COMPAT_OLDSOCK
+ if (mp->msg_flags & MSG_COMPAT)
+ mtod(from, struct osockaddr *)->sa_family =
+ mtod(from, struct sockaddr *)->sa_family;
+#endif
+ if (len > from->m_len)
+ len = from->m_len;
+ /* else if len < from->m_len ??? */
+ error = copyout(mtod(from, caddr_t),
+ (caddr_t)mp->msg_name, (unsigned)len);
+ if (error)
+ goto out;
+ }
+ mp->msg_namelen = len;
+ if (namelenp &&
+ (error = copyout((caddr_t)&len, namelenp, sizeof (int)))) {
+#ifdef COMPAT_OLDSOCK
+ if (mp->msg_flags & MSG_COMPAT)
+ error = 0; /* old recvfrom didn't check */
+ else
+#endif
+ goto out;
+ }
+ }
+ if (mp->msg_control) {
+#ifdef COMPAT_OLDSOCK
+ /*
+ * We assume that old recvmsg calls won't receive access
+ * rights and other control info, esp. as control info
+ * is always optional and those options didn't exist in 4.3.
+ * If we receive rights, trim the cmsghdr; anything else
+ * is tossed.
+ */
+ if (control && mp->msg_flags & MSG_COMPAT) {
+ if (mtod(control, struct cmsghdr *)->cmsg_level !=
+ SOL_SOCKET ||
+ mtod(control, struct cmsghdr *)->cmsg_type !=
+ SCM_RIGHTS) {
+ mp->msg_controllen = 0;
+ goto out;
+ }
+ control->m_len -= sizeof (struct cmsghdr);
+ control->m_data += sizeof (struct cmsghdr);
+ }
+#endif
+ len = mp->msg_controllen;
+ if (len <= 0 || control == 0)
+ len = 0;
+ else {
+ if (len >= control->m_len)
+ len = control->m_len;
+ else
+ mp->msg_flags |= MSG_CTRUNC;
+ error = copyout((caddr_t)mtod(control, caddr_t),
+ (caddr_t)mp->msg_control, (unsigned)len);
+ }
+ mp->msg_controllen = len;
+ }
+out:
+ if (from)
+ m_freem(from);
+ if (control)
+ m_freem(control);
return (error);
}
-struct recvfrom_args {
+struct shutdown_args {
int s;
- caddr_t buf;
- size_t len;
- int flags;
- caddr_t from;
- int *fromlenaddr;
+ int how;
};
-#ifdef COMPAT_OLDSOCK
-int
-orecvfrom(p, uap, retval)
- struct proc *p;
- struct recvfrom_args *uap;
- int *retval;
-{
-
- uap->flags |= MSG_COMPAT;
- return (recvfrom(p, uap, retval));
-}
-#endif
-
int
recvfrom(p, uap, retval)
struct proc *p;
@@ -625,8 +779,9 @@ recvfrom(p, uap, retval)
int error;
if (uap->fromlenaddr) {
- if (error = copyin((caddr_t)uap->fromlenaddr,
- (caddr_t)&msg.msg_namelen, sizeof (msg.msg_namelen)))
+ error = copyin((caddr_t)uap->fromlenaddr,
+ (caddr_t)&msg.msg_namelen, sizeof (msg.msg_namelen));
+ if (error)
return (error);
} else
msg.msg_namelen = 0;
@@ -641,6 +796,20 @@ recvfrom(p, uap, retval)
}
#ifdef COMPAT_OLDSOCK
+int
+orecvfrom(p, uap, retval)
+ struct proc *p;
+ struct recvfrom_args *uap;
+ int *retval;
+{
+
+ uap->flags |= MSG_COMPAT;
+ return (recvfrom(p, uap, retval));
+}
+#endif
+
+
+#ifdef COMPAT_OLDSOCK
struct orecv_args {
int s;
caddr_t buf;
@@ -687,8 +856,9 @@ orecvmsg(p, uap, retval)
struct iovec aiov[UIO_SMALLIOV], *iov;
int error;
- if (error = copyin((caddr_t)uap->msg, (caddr_t)&msg,
- sizeof (struct omsghdr)))
+ error = copyin((caddr_t)uap->msg, (caddr_t)&msg,
+ sizeof (struct omsghdr));
+ if (error)
return (error);
if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
if ((u_int)msg.msg_iovlen >= UIO_MAXIOV)
@@ -699,8 +869,9 @@ orecvmsg(p, uap, retval)
} else
iov = aiov;
msg.msg_flags = uap->flags | MSG_COMPAT;
- if (error = copyin((caddr_t)msg.msg_iov, (caddr_t)iov,
- (unsigned)(msg.msg_iovlen * sizeof (struct iovec))))
+ error = copyin((caddr_t)msg.msg_iov, (caddr_t)iov,
+ (unsigned)(msg.msg_iovlen * sizeof (struct iovec)));
+ if (error)
goto done;
msg.msg_iov = iov;
error = recvit(p, uap->s, &msg, (caddr_t)&uap->msg->msg_namelen, retval);
@@ -730,7 +901,8 @@ recvmsg(p, uap, retval)
struct iovec aiov[UIO_SMALLIOV], *uiov, *iov;
register int error;
- if (error = copyin((caddr_t)uap->msg, (caddr_t)&msg, sizeof (msg)))
+ error = copyin((caddr_t)uap->msg, (caddr_t)&msg, sizeof (msg));
+ if (error)
return (error);
if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
if ((u_int)msg.msg_iovlen >= UIO_MAXIOV)
@@ -747,10 +919,12 @@ recvmsg(p, uap, retval)
#endif
uiov = msg.msg_iov;
msg.msg_iov = iov;
- if (error = copyin((caddr_t)uiov, (caddr_t)iov,
- (unsigned)(msg.msg_iovlen * sizeof (struct iovec))))
+ error = copyin((caddr_t)uiov, (caddr_t)iov,
+ (unsigned)(msg.msg_iovlen * sizeof (struct iovec)));
+ if (error)
goto done;
- if ((error = recvit(p, uap->s, &msg, (caddr_t)0, retval)) == 0) {
+ error = recvit(p, uap->s, &msg, (caddr_t)0, retval);
+ if (!error) {
msg.msg_iov = uiov;
error = copyout((caddr_t)&msg, (caddr_t)uap->msg, sizeof(msg));
}
@@ -759,140 +933,6 @@ done:
FREE(iov, M_IOV);
return (error);
}
-
-int
-recvit(p, s, mp, namelenp, retsize)
- register struct proc *p;
- int s;
- register struct msghdr *mp;
- caddr_t namelenp;
- int *retsize;
-{
- struct file *fp;
- struct uio auio;
- register struct iovec *iov;
- register int i;
- int len, error;
- struct mbuf *from = 0, *control = 0;
-#ifdef KTRACE
- struct iovec *ktriov = NULL;
-#endif
-
- if (error = getsock(p->p_fd, s, &fp))
- return (error);
- auio.uio_iov = mp->msg_iov;
- auio.uio_iovcnt = mp->msg_iovlen;
- auio.uio_segflg = UIO_USERSPACE;
- auio.uio_rw = UIO_READ;
- auio.uio_procp = p;
- auio.uio_offset = 0; /* XXX */
- auio.uio_resid = 0;
- iov = mp->msg_iov;
- for (i = 0; i < mp->msg_iovlen; i++, iov++) {
- if ((auio.uio_resid += iov->iov_len) < 0)
- return (EINVAL);
- }
-#ifdef KTRACE
- if (KTRPOINT(p, KTR_GENIO)) {
- int iovlen = auio.uio_iovcnt * sizeof (struct iovec);
-
- MALLOC(ktriov, struct iovec *, iovlen, M_TEMP, M_WAITOK);
- bcopy((caddr_t)auio.uio_iov, (caddr_t)ktriov, iovlen);
- }
-#endif
- len = auio.uio_resid;
- if (error = soreceive((struct socket *)fp->f_data, &from, &auio,
- (struct mbuf **)0, mp->msg_control ? &control : (struct mbuf **)0,
- &mp->msg_flags)) {
- if (auio.uio_resid != len && (error == ERESTART ||
- error == EINTR || error == EWOULDBLOCK))
- error = 0;
- }
-#ifdef KTRACE
- if (ktriov != NULL) {
- if (error == 0)
- ktrgenio(p->p_tracep, s, UIO_READ,
- ktriov, len - auio.uio_resid, error);
- FREE(ktriov, M_TEMP);
- }
-#endif
- if (error)
- goto out;
- *retsize = len - auio.uio_resid;
- if (mp->msg_name) {
- len = mp->msg_namelen;
- if (len <= 0 || from == 0)
- len = 0;
- else {
-#ifdef COMPAT_OLDSOCK
- if (mp->msg_flags & MSG_COMPAT)
- mtod(from, struct osockaddr *)->sa_family =
- mtod(from, struct sockaddr *)->sa_family;
-#endif
- if (len > from->m_len)
- len = from->m_len;
- /* else if len < from->m_len ??? */
- if (error = copyout(mtod(from, caddr_t),
- (caddr_t)mp->msg_name, (unsigned)len))
- goto out;
- }
- mp->msg_namelen = len;
- if (namelenp &&
- (error = copyout((caddr_t)&len, namelenp, sizeof (int)))) {
-#ifdef COMPAT_OLDSOCK
- if (mp->msg_flags & MSG_COMPAT)
- error = 0; /* old recvfrom didn't check */
- else
-#endif
- goto out;
- }
- }
- if (mp->msg_control) {
-#ifdef COMPAT_OLDSOCK
- /*
- * We assume that old recvmsg calls won't receive access
- * rights and other control info, esp. as control info
- * is always optional and those options didn't exist in 4.3.
- * If we receive rights, trim the cmsghdr; anything else
- * is tossed.
- */
- if (control && mp->msg_flags & MSG_COMPAT) {
- if (mtod(control, struct cmsghdr *)->cmsg_level !=
- SOL_SOCKET ||
- mtod(control, struct cmsghdr *)->cmsg_type !=
- SCM_RIGHTS) {
- mp->msg_controllen = 0;
- goto out;
- }
- control->m_len -= sizeof (struct cmsghdr);
- control->m_data += sizeof (struct cmsghdr);
- }
-#endif
- len = mp->msg_controllen;
- if (len <= 0 || control == 0)
- len = 0;
- else {
- if (len >= control->m_len)
- len = control->m_len;
- else
- mp->msg_flags |= MSG_CTRUNC;
- error = copyout((caddr_t)mtod(control, caddr_t),
- (caddr_t)mp->msg_control, (unsigned)len);
- }
- mp->msg_controllen = len;
- }
-out:
- if (from)
- m_freem(from);
- if (control)
- m_freem(control);
- return (error);
-}
-
-struct shutdown_args {
- int s;
- int how;
-};
/* ARGSUSED */
int
shutdown(p, uap, retval)
@@ -903,7 +943,8 @@ shutdown(p, uap, retval)
struct file *fp;
int error;
- if (error = getsock(p->p_fd, uap->s, &fp))
+ error = getsock(p->p_fd, uap->s, &fp);
+ if (error)
return (error);
return (soshutdown((struct socket *)fp->f_data, uap->how));
}
@@ -926,7 +967,8 @@ setsockopt(p, uap, retval)
struct mbuf *m = NULL;
int error;
- if (error = getsock(p->p_fd, uap->s, &fp))
+ error = getsock(p->p_fd, uap->s, &fp);
+ if (error)
return (error);
if (uap->valsize > MLEN)
return (EINVAL);
@@ -934,8 +976,8 @@ setsockopt(p, uap, retval)
m = m_get(M_WAIT, MT_SOOPTS);
if (m == NULL)
return (ENOBUFS);
- if (error = copyin(uap->val, mtod(m, caddr_t),
- (u_int)uap->valsize)) {
+ error = copyin(uap->val, mtod(m, caddr_t), (u_int)uap->valsize);
+ if (error) {
(void) m_free(m);
return (error);
}
@@ -963,11 +1005,13 @@ getsockopt(p, uap, retval)
struct mbuf *m = NULL;
int valsize, error;
- if (error = getsock(p->p_fd, uap->s, &fp))
+ error = getsock(p->p_fd, uap->s, &fp);
+ if (error)
return (error);
if (uap->val) {
- if (error = copyin((caddr_t)uap->avalsize, (caddr_t)&valsize,
- sizeof (valsize)))
+ error = copyin((caddr_t)uap->avalsize, (caddr_t)&valsize,
+ sizeof (valsize));
+ if (error)
return (error);
} else
valsize = 0;
@@ -1000,25 +1044,30 @@ pipe(p, uap, retval)
struct socket *rso, *wso;
int fd, error;
- if (error = socreate(AF_UNIX, &rso, SOCK_STREAM, 0))
+ error = socreate(AF_UNIX, &rso, SOCK_STREAM, 0);
+ if (error)
return (error);
- if (error = socreate(AF_UNIX, &wso, SOCK_STREAM, 0))
+ error = socreate(AF_UNIX, &wso, SOCK_STREAM, 0);
+ if (error)
goto free1;
- if (error = falloc(p, &rf, &fd))
+ error = falloc(p, &rf, &fd);
+ if (error)
goto free2;
retval[0] = fd;
rf->f_flag = FREAD;
rf->f_type = DTYPE_SOCKET;
rf->f_ops = &socketops;
rf->f_data = (caddr_t)rso;
- if (error = falloc(p, &wf, &fd))
+ error = falloc(p, &wf, &fd);
+ if (error)
goto free3;
wf->f_flag = FWRITE;
wf->f_type = DTYPE_SOCKET;
wf->f_ops = &socketops;
wf->f_data = (caddr_t)wso;
retval[1] = fd;
- if (error = unp_connect2(wso, rso))
+ error = unp_connect2(wso, rso);
+ if (error)
goto free4;
return (0);
free4:
@@ -1045,30 +1094,8 @@ struct getsockname_args {
int compat_43; /* pseudo */
#endif
};
-#ifdef COMPAT_OLDSOCK
-int
-getsockname(p, uap, retval)
- struct proc *p;
- struct getsockname_args *uap;
- int *retval;
-{
-
- uap->compat_43 = 0;
- return (getsockname1(p, uap, retval));
-}
-
-int
-ogetsockname(p, uap, retval)
- struct proc *p;
- struct getsockname_args *uap;
- int *retval;
-{
-
- uap->compat_43 = 1;
- return (getsockname1(p, uap, retval));
-}
-#else /* COMPAT_OLDSOCK */
+#ifndef COMPAT_OLDSOCK
#define getsockname1 getsockname
#endif
@@ -1084,15 +1111,18 @@ getsockname1(p, uap, retval)
struct mbuf *m;
int len, error;
- if (error = getsock(p->p_fd, uap->fdes, &fp))
+ error = getsock(p->p_fd, uap->fdes, &fp);
+ if (error)
return (error);
- if (error = copyin((caddr_t)uap->alen, (caddr_t)&len, sizeof (len)))
+ error = copyin((caddr_t)uap->alen, (caddr_t)&len, sizeof (len));
+ if (error)
return (error);
so = (struct socket *)fp->f_data;
m = m_getclr(M_WAIT, MT_SONAME);
if (m == NULL)
return (ENOBUFS);
- if (error = (*so->so_proto->pr_usrreq)(so, PRU_SOCKADDR, 0, m, 0))
+ error = (*so->so_proto->pr_usrreq)(so, PRU_SOCKADDR, 0, m, 0);
+ if (error)
goto bad;
if (len > m->m_len)
len = m->m_len;
@@ -1110,42 +1140,44 @@ bad:
return (error);
}
-/*
- * Get name of peer for connected socket.
- */
-struct getpeername_args {
- int fdes;
- caddr_t asa;
- int *alen;
-#ifdef COMPAT_OLDSOCK
- int compat_43; /* pseudo */
-#endif
-};
-
#ifdef COMPAT_OLDSOCK
int
-getpeername(p, uap, retval)
+getsockname(p, uap, retval)
struct proc *p;
- struct getpeername_args *uap;
+ struct getsockname_args *uap;
int *retval;
{
uap->compat_43 = 0;
- return (getpeername1(p, uap, retval));
+ return (getsockname1(p, uap, retval));
}
int
-ogetpeername(p, uap, retval)
+ogetsockname(p, uap, retval)
struct proc *p;
- struct getpeername_args *uap;
+ struct getsockname_args *uap;
int *retval;
{
uap->compat_43 = 1;
- return (getpeername1(p, uap, retval));
+ return (getsockname1(p, uap, retval));
}
-#else /* COMPAT_OLDSOCK */
+#endif /* COMPAT_OLDSOCK */
+/*
+ * Get name of peer for connected socket.
+ */
+struct getpeername_args {
+ int fdes;
+ caddr_t asa;
+ int *alen;
+#ifdef COMPAT_OLDSOCK
+ int compat_43; /* pseudo */
+#endif
+};
+
+
+#ifndef COMPAT_OLDSOCK
#define getpeername1 getpeername
#endif
@@ -1161,17 +1193,20 @@ getpeername1(p, uap, retval)
struct mbuf *m;
int len, error;
- if (error = getsock(p->p_fd, uap->fdes, &fp))
+ error = getsock(p->p_fd, uap->fdes, &fp);
+ if (error)
return (error);
so = (struct socket *)fp->f_data;
if ((so->so_state & (SS_ISCONNECTED|SS_ISCONFIRMING)) == 0)
return (ENOTCONN);
- if (error = copyin((caddr_t)uap->alen, (caddr_t)&len, sizeof (len)))
+ error = copyin((caddr_t)uap->alen, (caddr_t)&len, sizeof (len));
+ if (error)
return (error);
m = m_getclr(M_WAIT, MT_SONAME);
if (m == NULL)
return (ENOBUFS);
- if (error = (*so->so_proto->pr_usrreq)(so, PRU_PEERADDR, 0, m, 0))
+ error = (*so->so_proto->pr_usrreq)(so, PRU_PEERADDR, 0, m, 0);
+ if (error)
goto bad;
if (len > m->m_len)
len = m->m_len;
@@ -1180,7 +1215,8 @@ getpeername1(p, uap, retval)
mtod(m, struct osockaddr *)->sa_family =
mtod(m, struct sockaddr *)->sa_family;
#endif
- if (error = copyout(mtod(m, caddr_t), (caddr_t)uap->asa, (u_int)len))
+ error = copyout(mtod(m, caddr_t), (caddr_t)uap->asa, (u_int)len);
+ if (error)
goto bad;
error = copyout((caddr_t)&len, (caddr_t)uap->alen, sizeof (len));
bad:
@@ -1188,6 +1224,29 @@ bad:
return (error);
}
+#ifdef COMPAT_OLDSOCK
+int
+getpeername(p, uap, retval)
+ struct proc *p;
+ struct getpeername_args *uap;
+ int *retval;
+{
+
+ uap->compat_43 = 0;
+ return (getpeername1(p, uap, retval));
+}
+
+int
+ogetpeername(p, uap, retval)
+ struct proc *p;
+ struct getpeername_args *uap;
+ int *retval;
+{
+
+ uap->compat_43 = 1;
+ return (getpeername1(p, uap, retval));
+}
+#endif /* COMPAT_OLDSOCK */
int
sockargs(mp, buf, buflen, type)
struct mbuf **mp;
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 7a56b7e..18b1dfe 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94
- * $Id: uipc_usrreq.c,v 1.3 1994/08/02 07:43:12 davidg Exp $
+ * $Id: uipc_usrreq.c,v 1.4 1994/09/28 19:55:10 phk Exp $
*/
#include <sys/param.h>
@@ -40,6 +40,7 @@
#include <sys/filedesc.h>
#include <sys/domain.h>
#include <sys/protosw.h>
+#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/unpcb.h>
@@ -50,15 +51,6 @@
#include <sys/stat.h>
#include <sys/mbuf.h>
-void unp_detach __P((struct unpcb *));
-void unp_disconnect __P((struct unpcb *));
-void unp_shutdown __P((struct unpcb *));
-void unp_drop __P((struct unpcb *, int));
-void unp_gc __P((void));
-void unp_scan __P((struct mbuf *, void (*)(struct file *)));
-void unp_mark __P((struct file *));
-void unp_discard __P((struct file *));
-
/*
* Unix communications domain.
*
@@ -411,7 +403,8 @@ unp_bind(unp, nam, p)
} else
*(mtod(nam, caddr_t) + nam->m_len) = 0;
/* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp != NULL) {
@@ -427,7 +420,8 @@ unp_bind(unp, nam, p)
vattr.va_type = VSOCK;
vattr.va_mode = ACCESSPERMS;
LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- if (error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr))
+ error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &vattr);
+ if (error)
return (error);
vp = nd.ni_vp;
vp->v_socket = unp->unp_socket;
@@ -456,14 +450,16 @@ unp_connect(so, nam, p)
return (EMSGSIZE);
} else
*(mtod(nam, caddr_t) + nam->m_len) = 0;
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VSOCK) {
error = ENOTSOCK;
goto bad;
}
- if (error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p))
+ error = VOP_ACCESS(vp, VWRITE, p->p_ucred, p);
+ if (error)
goto bad;
so2 = vp->v_socket;
if (so2 == 0) {
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 1bc4872..369e73f 100644
--- a/sys/kern/vfs_cache.c
+++ b/sys/kern/vfs_cache.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_cache.c 8.1 (Berkeley) 6/10/93
- * $Id$
+ * $Id: vfs_cache.c,v 1.3 1994/08/02 07:43:15 davidg Exp $
*/
#include <sys/param.h>
@@ -161,20 +161,23 @@ cache_lookup(dvp, vpp, cnp)
* want cache entry to exist.
*/
/* remove from LRU chain */
- if (ncq = ncp->nc_nxt)
+ ncq = ncp->nc_nxt;
+ if (ncq)
ncq->nc_prev = ncp->nc_prev;
else
nchtail = ncp->nc_prev;
*ncp->nc_prev = ncq;
/* remove from hash chain */
- if (ncq = ncp->nc_forw)
+ ncq = ncp->nc_forw;
+ if (ncq)
ncq->nc_back = ncp->nc_back;
*ncp->nc_back = ncq;
/* and make a dummy hash chain */
ncp->nc_forw = NULL;
ncp->nc_back = NULL;
/* insert at head of LRU list (first to grab) */
- if (ncq = nchhead)
+ ncq = nchhead;
+ if (ncq)
ncq->nc_prev = &ncp->nc_nxt;
else
nchtail = &ncp->nc_nxt;
@@ -209,23 +212,27 @@ cache_enter(dvp, vp, cnp)
malloc((u_long)sizeof *ncp, M_CACHE, M_WAITOK);
bzero((char *)ncp, sizeof *ncp);
numcache++;
- } else if (ncp = nchhead) {
+ } else if (!nchhead) {
+ return;
+ } else {
+ ncp = nchhead;
/* remove from lru chain */
- if (ncq = ncp->nc_nxt)
+ ncq = ncp->nc_nxt;
+ if (ncq)
ncq->nc_prev = ncp->nc_prev;
else
nchtail = ncp->nc_prev;
*ncp->nc_prev = ncq;
/* remove from old hash chain, if on one */
if (ncp->nc_back) {
- if (ncq = ncp->nc_forw)
+ ncq = ncp->nc_forw;
+ if (ncq)
ncq->nc_back = ncp->nc_back;
*ncp->nc_back = ncq;
ncp->nc_forw = NULL;
ncp->nc_back = NULL;
}
- } else
- return;
+ }
/* grab the vnode we just found */
ncp->nc_vp = vp;
if (vp)
@@ -244,7 +251,8 @@ cache_enter(dvp, vp, cnp)
nchtail = &ncp->nc_nxt;
/* and insert on hash chain */
ncpp = &nchashtbl[cnp->cn_hash & nchash];
- if (ncq = *ncpp)
+ ncq = *ncpp;
+ if (ncq)
ncq->nc_back = &ncp->nc_forw;
ncp->nc_forw = ncq;
ncp->nc_back = ncpp;
@@ -308,21 +316,24 @@ cache_purgevfs(mp)
ncp->nc_dvp = NULL;
/* remove from old hash chain, if on one */
if (ncp->nc_back) {
- if (nxtcp = ncp->nc_forw)
+ nxtcp = ncp->nc_forw;
+ if (nxtcp)
nxtcp->nc_back = ncp->nc_back;
*ncp->nc_back = nxtcp;
ncp->nc_forw = NULL;
ncp->nc_back = NULL;
}
/* delete this entry from LRU chain */
- if (nxtcp = ncp->nc_nxt)
+ nxtcp = ncp->nc_nxt;
+ if (nxtcp)
nxtcp->nc_prev = ncp->nc_prev;
else
nchtail = ncp->nc_prev;
*ncp->nc_prev = nxtcp;
/* cause rescan of list, it may have altered */
/* also put the now-free entry at head of LRU */
- if (nxtcp = nchhead)
+ nxtcp = nchhead;
+ if (nxtcp)
nxtcp->nc_prev = &ncp->nc_nxt;
else
nchtail = &ncp->nc_nxt;
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c
index 9d277d8..eda779b 100644
--- a/sys/kern/vfs_export.c
+++ b/sys/kern/vfs_export.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94
- * $Id: vfs_subr.c,v 1.8 1994/08/29 06:08:51 davidg Exp $
+ * $Id: vfs_subr.c,v 1.9 1994/09/25 19:33:52 phk Exp $
*/
/*
@@ -347,12 +347,15 @@ getnewvnode(tag, mp, vops, vpp)
if (vp->v_type != VBAD)
vgone(vp);
#ifdef DIAGNOSTIC
+ {
+ int s;
if (vp->v_data)
panic("cleaned vnode isn't");
s = splbio();
if (vp->v_numoutput)
panic("Clean vnode has pending I/O's");
splx(s);
+ }
#endif
vp->v_flag = 0;
vp->v_lastr = 0;
diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c
index 21fc5ee..ea4b9ef 100644
--- a/sys/kern/vfs_extattr.c
+++ b/sys/kern/vfs_extattr.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
- * $Id: vfs_syscalls.c,v 1.8 1994/09/22 19:37:56 wollman Exp $
+ * $Id: vfs_syscalls.c,v 1.9 1994/09/28 16:45:11 dfr Exp $
*/
#include <sys/param.h>
@@ -56,7 +56,6 @@
#include <vm/vm.h>
#include <sys/sysctl.h>
-void cvtstat __P((struct stat *, struct ostat *));
static int change_dir __P((struct nameidata *ndp, struct proc *p));
/*
@@ -87,13 +86,15 @@ mount(p, uap, retval)
/*
* Must be super user
*/
- if (error = suser(p->p_ucred, &p->p_acflag))
+ error = suser(p->p_ucred, &p->p_acflag);
+ if (error)
return (error);
/*
* Get vnode to be covered
*/
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (uap->flags & MNT_UPDATE) {
@@ -117,7 +118,8 @@ mount(p, uap, retval)
VOP_UNLOCK(vp);
goto update;
}
- if (error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0))
+ error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0);
+ if (error)
return (error);
if (vp->v_type != VDIR) {
vput(vp);
@@ -136,7 +138,8 @@ mount(p, uap, retval)
bzero((char *)mp, (u_long)sizeof(struct mount));
mp->mnt_op = vfssw[uap->type];
mp->mnt_vfc = vfsconf[uap->type];
- if (error = vfs_lock(mp)) {
+ error = vfs_lock(mp);
+ if (error) {
free((caddr_t)mp, M_MOUNT);
vput(vp);
return (error);
@@ -219,7 +222,8 @@ unmount(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
@@ -268,7 +272,8 @@ dounmount(mp, flags, p)
if (vfs_busy(mp))
return (EBUSY);
mp->mnt_flag |= MNT_UNMOUNT;
- if (error = vfs_lock(mp))
+ error = vfs_lock(mp);
+ if (error)
return (error);
mp->mnt_flag &=~ MNT_ASYNC;
@@ -359,7 +364,8 @@ quotactl(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
mp = nd.ni_vp->v_mount;
vrele(nd.ni_vp);
@@ -386,12 +392,14 @@ statfs(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
mp = nd.ni_vp->v_mount;
sp = &mp->mnt_stat;
vrele(nd.ni_vp);
- if (error = VFS_STATFS(mp, sp, p))
+ error = VFS_STATFS(mp, sp, p);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
@@ -416,11 +424,13 @@ fstatfs(p, uap, retval)
register struct statfs *sp;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if (error = VFS_STATFS(mp, sp, p))
+ error = VFS_STATFS(mp, sp, p);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
@@ -492,7 +502,8 @@ fchdir(p, uap, retval)
struct file *fp;
int error;
- if (error = getvnode(fdp, uap->fd, &fp))
+ error = getvnode(fdp, uap->fd, &fp);
+ if (error)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LOCK(vp);
@@ -527,7 +538,8 @@ chdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = change_dir(&nd, p))
+ error = change_dir(&nd, p);
+ if (error)
return (error);
vrele(fdp->fd_cdir);
fdp->fd_cdir = nd.ni_vp;
@@ -551,10 +563,12 @@ chroot(p, uap, retval)
int error;
struct nameidata nd;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ error = suser(p->p_ucred, &p->p_acflag);
+ if (error)
return (error);
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = change_dir(&nd, p))
+ error = change_dir(&nd, p);
+ if (error)
return (error);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
@@ -573,7 +587,8 @@ change_dir(ndp, p)
struct vnode *vp;
int error;
- if (error = namei(ndp))
+ error = namei(ndp);
+ if (error)
return (error);
vp = ndp->ni_vp;
if (vp->v_type != VDIR)
@@ -611,14 +626,16 @@ open(p, uap, retval)
struct nameidata nd;
extern struct fileops vnops;
- if (error = falloc(p, &nfp, &indx))
+ error = falloc(p, &nfp, &indx);
+ if (error)
return (error);
fp = nfp;
flags = FFLAGS(uap->flags);
cmode = ((uap->mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
- if (error = vn_open(&nd, flags, cmode)) {
+ error = vn_open(&nd, flags, cmode);
+ if (error) {
ffree(fp);
if ((error == ENODEV || error == ENXIO) &&
p->p_dupfd >= 0 && /* XXX from fdopen */
@@ -650,7 +667,8 @@ open(p, uap, retval)
if ((flags & FNONBLOCK) == 0)
type |= F_WAIT;
VOP_UNLOCK(vp);
- if (error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) {
+ error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type);
+ if (error) {
(void) vn_close(vp, fp->f_flag, fp->f_cred, p);
ffree(fp);
fdp->fd_ofiles[indx] = NULL;
@@ -707,10 +725,12 @@ mknod(p, uap, retval)
int error;
struct nameidata nd;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ error = suser(p->p_ucred, &p->p_acflag);
+ if (error)
return (error);
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp != NULL)
@@ -769,7 +789,8 @@ mkfifo(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
if (nd.ni_vp != NULL) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@@ -806,7 +827,8 @@ link(p, uap, retval)
int error;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VDIR ||
@@ -814,7 +836,8 @@ link(p, uap, retval)
nd.ni_cnd.cn_nameiop = CREATE;
nd.ni_cnd.cn_flags = LOCKPARENT;
nd.ni_dirp = uap->link;
- if ((error = namei(&nd)) == 0) {
+ error = namei(&nd);
+ if (!error) {
if (nd.ni_vp != NULL)
error = EEXIST;
if (!error) {
@@ -858,10 +881,12 @@ symlink(p, uap, retval)
struct nameidata nd;
MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
- if (error = copyinstr(uap->path, path, MAXPATHLEN, NULL))
+ error = copyinstr(uap->path, path, MAXPATHLEN, NULL);
+ if (error)
goto out;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->link, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
goto out;
if (nd.ni_vp) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@@ -900,7 +925,8 @@ unlink(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -962,8 +988,8 @@ lseek(p, uap, retval)
fp->f_offset += uap->offset;
break;
case L_XTND:
- if (error =
- VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p))
+ error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p);
+ if (error)
return (error);
fp->f_offset = uap->offset + vattr.va_size;
break;
@@ -1028,7 +1054,8 @@ access(p, uap, retval)
cred->cr_uid = p->p_cred->p_ruid;
cred->cr_groups[0] = p->p_cred->p_rgid;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
goto out1;
vp = nd.ni_vp;
@@ -1072,7 +1099,8 @@ ostat(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
vput(nd.ni_vp);
@@ -1105,7 +1133,8 @@ olstat(p, uap, retval)
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
/*
* For symbolic links, always return the attributes of its
@@ -1193,7 +1222,8 @@ stat(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
vput(nd.ni_vp);
@@ -1224,7 +1254,8 @@ lstat(p, uap, retval)
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
/*
* For symbolic links, always return the attributes of its
@@ -1280,7 +1311,8 @@ pathconf(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
vput(nd.ni_vp);
@@ -1309,7 +1341,8 @@ readlink(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VLNK)
@@ -1351,7 +1384,8 @@ chflags(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1386,7 +1420,8 @@ fchflags(p, uap, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1422,7 +1457,8 @@ chmod(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1457,7 +1493,8 @@ fchmod(p, uap, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1494,7 +1531,8 @@ chown(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1531,7 +1569,8 @@ fchown(p, uap, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1573,10 +1612,14 @@ utimes(p, uap, retval)
microtime(&tv[0]);
tv[1] = tv[0];
vattr.va_vaflags |= VA_UTIMES_NULL;
- } else if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
- return (error);
+ } else {
+ error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
+ if (error)
+ return (error);
+ }
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1617,7 +1660,8 @@ truncate(p, uap, retval)
if (uap->length < 0)
return(EINVAL);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1656,7 +1700,8 @@ ftruncate(p, uap, retval)
if (uap->length < 0)
return(EINVAL);
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
if ((fp->f_flag & FWRITE) == 0)
return (EINVAL);
@@ -1735,7 +1780,8 @@ fsync(p, uap, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LOCK(vp);
@@ -1765,12 +1811,14 @@ rename(p, uap, retval)
NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
uap->from, p);
- if (error = namei(&fromnd))
+ error = namei(&fromnd);
+ if (error)
return (error);
fvp = fromnd.ni_vp;
NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
UIO_USERSPACE, uap->to, p);
- if (error = namei(&tond)) {
+ error = namei(&tond);
+ if (error) {
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
vrele(fromnd.ni_dvp);
vrele(fvp);
@@ -1851,7 +1899,8 @@ mkdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp != NULL) {
@@ -1891,7 +1940,8 @@ rmdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VDIR) {
@@ -1951,7 +2001,8 @@ ogetdirentries(p, uap, retval)
int error, readcnt;
long loff;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
@@ -2048,7 +2099,8 @@ getdirentries(p, uap, retval)
long loff;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
@@ -2158,14 +2210,16 @@ revoke(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VCHR && vp->v_type != VBLK) {
error = EINVAL;
goto out;
}
- if (error = VOP_GETATTR(vp, &vattr, p->p_ucred, p))
+ error = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
+ if (error)
goto out;
if (p->p_ucred->cr_uid != vattr.va_uid &&
(error = suser(p->p_ucred, &p->p_acflag)))
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 9d277d8..eda779b 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94
- * $Id: vfs_subr.c,v 1.8 1994/08/29 06:08:51 davidg Exp $
+ * $Id: vfs_subr.c,v 1.9 1994/09/25 19:33:52 phk Exp $
*/
/*
@@ -347,12 +347,15 @@ getnewvnode(tag, mp, vops, vpp)
if (vp->v_type != VBAD)
vgone(vp);
#ifdef DIAGNOSTIC
+ {
+ int s;
if (vp->v_data)
panic("cleaned vnode isn't");
s = splbio();
if (vp->v_numoutput)
panic("Clean vnode has pending I/O's");
splx(s);
+ }
#endif
vp->v_flag = 0;
vp->v_lastr = 0;
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 21fc5ee..ea4b9ef 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
- * $Id: vfs_syscalls.c,v 1.8 1994/09/22 19:37:56 wollman Exp $
+ * $Id: vfs_syscalls.c,v 1.9 1994/09/28 16:45:11 dfr Exp $
*/
#include <sys/param.h>
@@ -56,7 +56,6 @@
#include <vm/vm.h>
#include <sys/sysctl.h>
-void cvtstat __P((struct stat *, struct ostat *));
static int change_dir __P((struct nameidata *ndp, struct proc *p));
/*
@@ -87,13 +86,15 @@ mount(p, uap, retval)
/*
* Must be super user
*/
- if (error = suser(p->p_ucred, &p->p_acflag))
+ error = suser(p->p_ucred, &p->p_acflag);
+ if (error)
return (error);
/*
* Get vnode to be covered
*/
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (uap->flags & MNT_UPDATE) {
@@ -117,7 +118,8 @@ mount(p, uap, retval)
VOP_UNLOCK(vp);
goto update;
}
- if (error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0))
+ error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0);
+ if (error)
return (error);
if (vp->v_type != VDIR) {
vput(vp);
@@ -136,7 +138,8 @@ mount(p, uap, retval)
bzero((char *)mp, (u_long)sizeof(struct mount));
mp->mnt_op = vfssw[uap->type];
mp->mnt_vfc = vfsconf[uap->type];
- if (error = vfs_lock(mp)) {
+ error = vfs_lock(mp);
+ if (error) {
free((caddr_t)mp, M_MOUNT);
vput(vp);
return (error);
@@ -219,7 +222,8 @@ unmount(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
@@ -268,7 +272,8 @@ dounmount(mp, flags, p)
if (vfs_busy(mp))
return (EBUSY);
mp->mnt_flag |= MNT_UNMOUNT;
- if (error = vfs_lock(mp))
+ error = vfs_lock(mp);
+ if (error)
return (error);
mp->mnt_flag &=~ MNT_ASYNC;
@@ -359,7 +364,8 @@ quotactl(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
mp = nd.ni_vp->v_mount;
vrele(nd.ni_vp);
@@ -386,12 +392,14 @@ statfs(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
mp = nd.ni_vp->v_mount;
sp = &mp->mnt_stat;
vrele(nd.ni_vp);
- if (error = VFS_STATFS(mp, sp, p))
+ error = VFS_STATFS(mp, sp, p);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
@@ -416,11 +424,13 @@ fstatfs(p, uap, retval)
register struct statfs *sp;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if (error = VFS_STATFS(mp, sp, p))
+ error = VFS_STATFS(mp, sp, p);
+ if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
@@ -492,7 +502,8 @@ fchdir(p, uap, retval)
struct file *fp;
int error;
- if (error = getvnode(fdp, uap->fd, &fp))
+ error = getvnode(fdp, uap->fd, &fp);
+ if (error)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LOCK(vp);
@@ -527,7 +538,8 @@ chdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = change_dir(&nd, p))
+ error = change_dir(&nd, p);
+ if (error)
return (error);
vrele(fdp->fd_cdir);
fdp->fd_cdir = nd.ni_vp;
@@ -551,10 +563,12 @@ chroot(p, uap, retval)
int error;
struct nameidata nd;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ error = suser(p->p_ucred, &p->p_acflag);
+ if (error)
return (error);
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = change_dir(&nd, p))
+ error = change_dir(&nd, p);
+ if (error)
return (error);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
@@ -573,7 +587,8 @@ change_dir(ndp, p)
struct vnode *vp;
int error;
- if (error = namei(ndp))
+ error = namei(ndp);
+ if (error)
return (error);
vp = ndp->ni_vp;
if (vp->v_type != VDIR)
@@ -611,14 +626,16 @@ open(p, uap, retval)
struct nameidata nd;
extern struct fileops vnops;
- if (error = falloc(p, &nfp, &indx))
+ error = falloc(p, &nfp, &indx);
+ if (error)
return (error);
fp = nfp;
flags = FFLAGS(uap->flags);
cmode = ((uap->mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
- if (error = vn_open(&nd, flags, cmode)) {
+ error = vn_open(&nd, flags, cmode);
+ if (error) {
ffree(fp);
if ((error == ENODEV || error == ENXIO) &&
p->p_dupfd >= 0 && /* XXX from fdopen */
@@ -650,7 +667,8 @@ open(p, uap, retval)
if ((flags & FNONBLOCK) == 0)
type |= F_WAIT;
VOP_UNLOCK(vp);
- if (error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type)) {
+ error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, type);
+ if (error) {
(void) vn_close(vp, fp->f_flag, fp->f_cred, p);
ffree(fp);
fdp->fd_ofiles[indx] = NULL;
@@ -707,10 +725,12 @@ mknod(p, uap, retval)
int error;
struct nameidata nd;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ error = suser(p->p_ucred, &p->p_acflag);
+ if (error)
return (error);
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp != NULL)
@@ -769,7 +789,8 @@ mkfifo(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
if (nd.ni_vp != NULL) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@@ -806,7 +827,8 @@ link(p, uap, retval)
int error;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VDIR ||
@@ -814,7 +836,8 @@ link(p, uap, retval)
nd.ni_cnd.cn_nameiop = CREATE;
nd.ni_cnd.cn_flags = LOCKPARENT;
nd.ni_dirp = uap->link;
- if ((error = namei(&nd)) == 0) {
+ error = namei(&nd);
+ if (!error) {
if (nd.ni_vp != NULL)
error = EEXIST;
if (!error) {
@@ -858,10 +881,12 @@ symlink(p, uap, retval)
struct nameidata nd;
MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
- if (error = copyinstr(uap->path, path, MAXPATHLEN, NULL))
+ error = copyinstr(uap->path, path, MAXPATHLEN, NULL);
+ if (error)
goto out;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->link, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
goto out;
if (nd.ni_vp) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@@ -900,7 +925,8 @@ unlink(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -962,8 +988,8 @@ lseek(p, uap, retval)
fp->f_offset += uap->offset;
break;
case L_XTND:
- if (error =
- VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p))
+ error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p);
+ if (error)
return (error);
fp->f_offset = uap->offset + vattr.va_size;
break;
@@ -1028,7 +1054,8 @@ access(p, uap, retval)
cred->cr_uid = p->p_cred->p_ruid;
cred->cr_groups[0] = p->p_cred->p_rgid;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
goto out1;
vp = nd.ni_vp;
@@ -1072,7 +1099,8 @@ ostat(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
vput(nd.ni_vp);
@@ -1105,7 +1133,8 @@ olstat(p, uap, retval)
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
/*
* For symbolic links, always return the attributes of its
@@ -1193,7 +1222,8 @@ stat(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
vput(nd.ni_vp);
@@ -1224,7 +1254,8 @@ lstat(p, uap, retval)
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
/*
* For symbolic links, always return the attributes of its
@@ -1280,7 +1311,8 @@ pathconf(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
vput(nd.ni_vp);
@@ -1309,7 +1341,8 @@ readlink(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VLNK)
@@ -1351,7 +1384,8 @@ chflags(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1386,7 +1420,8 @@ fchflags(p, uap, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1422,7 +1457,8 @@ chmod(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1457,7 +1493,8 @@ fchmod(p, uap, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1494,7 +1531,8 @@ chown(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1531,7 +1569,8 @@ fchown(p, uap, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
vp = (struct vnode *)fp->f_data;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1573,10 +1612,14 @@ utimes(p, uap, retval)
microtime(&tv[0]);
tv[1] = tv[0];
vattr.va_vaflags |= VA_UTIMES_NULL;
- } else if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
- return (error);
+ } else {
+ error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
+ if (error)
+ return (error);
+ }
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1617,7 +1660,8 @@ truncate(p, uap, retval)
if (uap->length < 0)
return(EINVAL);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1656,7 +1700,8 @@ ftruncate(p, uap, retval)
if (uap->length < 0)
return(EINVAL);
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
if ((fp->f_flag & FWRITE) == 0)
return (EINVAL);
@@ -1735,7 +1780,8 @@ fsync(p, uap, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LOCK(vp);
@@ -1765,12 +1811,14 @@ rename(p, uap, retval)
NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
uap->from, p);
- if (error = namei(&fromnd))
+ error = namei(&fromnd);
+ if (error)
return (error);
fvp = fromnd.ni_vp;
NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
UIO_USERSPACE, uap->to, p);
- if (error = namei(&tond)) {
+ error = namei(&tond);
+ if (error) {
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
vrele(fromnd.ni_dvp);
vrele(fvp);
@@ -1851,7 +1899,8 @@ mkdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp != NULL) {
@@ -1891,7 +1940,8 @@ rmdir(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VDIR) {
@@ -1951,7 +2001,8 @@ ogetdirentries(p, uap, retval)
int error, readcnt;
long loff;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
@@ -2048,7 +2099,8 @@ getdirentries(p, uap, retval)
long loff;
int error;
- if (error = getvnode(p->p_fd, uap->fd, &fp))
+ error = getvnode(p->p_fd, uap->fd, &fp);
+ if (error)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
@@ -2158,14 +2210,16 @@ revoke(p, uap, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
- if (error = namei(&nd))
+ error = namei(&nd);
+ if (error)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VCHR && vp->v_type != VBLK) {
error = EINVAL;
goto out;
}
- if (error = VOP_GETATTR(vp, &vattr, p->p_ucred, p))
+ error = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
+ if (error)
goto out;
if (p->p_ucred->cr_uid != vattr.va_uid &&
(error = suser(p->p_ucred, &p->p_acflag)))
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 7229c33..de89705 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94
- * $Id: vfs_vnops.c,v 1.3 1994/08/02 07:43:33 davidg Exp $
+ * $Id: vfs_vnops.c,v 1.4 1994/08/18 03:53:38 davidg Exp $
*/
#include <sys/param.h>
@@ -78,15 +78,17 @@ vn_open(ndp, fmode, cmode)
ndp->ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
if ((fmode & O_EXCL) == 0)
ndp->ni_cnd.cn_flags |= FOLLOW;
- if (error = namei(ndp))
+ error = namei(ndp);
+ if (error)
return (error);
if (ndp->ni_vp == NULL) {
VATTR_NULL(vap);
vap->va_type = VREG;
vap->va_mode = cmode;
LEASE_CHECK(ndp->ni_dvp, p, cred, LEASE_WRITE);
- if (error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
- &ndp->ni_cnd, vap))
+ error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
+ &ndp->ni_cnd, vap);
+ if (error)
return (error);
fmode &= ~O_TRUNC;
vp = ndp->ni_vp;
@@ -107,7 +109,8 @@ vn_open(ndp, fmode, cmode)
} else {
ndp->ni_cnd.cn_nameiop = LOOKUP;
ndp->ni_cnd.cn_flags = FOLLOW | LOCKLEAF;
- if (error = namei(ndp))
+ error = namei(ndp);
+ if (error)
return (error);
vp = ndp->ni_vp;
}
@@ -117,7 +120,8 @@ vn_open(ndp, fmode, cmode)
}
if ((fmode & O_CREAT) == 0) {
if (fmode & FREAD) {
- if (error = VOP_ACCESS(vp, VREAD, cred, p))
+ error = VOP_ACCESS(vp, VREAD, cred, p);
+ if (error)
goto bad;
}
if (fmode & (FWRITE | O_TRUNC)) {
@@ -125,8 +129,11 @@ vn_open(ndp, fmode, cmode)
error = EISDIR;
goto bad;
}
- if ((error = vn_writechk(vp)) ||
- (error = VOP_ACCESS(vp, VWRITE, cred, p)))
+ error = vn_writechk(vp);
+ if(error)
+ goto bad;
+ error = VOP_ACCESS(vp, VWRITE, cred, p);
+ if(error)
goto bad;
}
}
@@ -136,10 +143,12 @@ vn_open(ndp, fmode, cmode)
VOP_LOCK(vp); /* XXX */
VATTR_NULL(vap);
vap->va_size = 0;
- if (error = VOP_SETATTR(vp, vap, cred, p))
+ error = VOP_SETATTR(vp, vap, cred, p);
+ if (error)
goto bad;
}
- if (error = VOP_OPEN(vp, fmode, cred, p))
+ error = VOP_OPEN(vp, fmode, cred, p);
+ if (error)
goto bad;
if (fmode & FWRITE)
vp->v_writecount++;
@@ -168,6 +177,8 @@ vn_writechk(vp)
switch (vp->v_type) {
case VREG: case VDIR: case VLNK:
return (EROFS);
+ default:
+ break;
}
}
/*
@@ -381,7 +392,8 @@ vn_ioctl(fp, com, data, p)
case VREG:
case VDIR:
if (com == FIONREAD) {
- if (error = VOP_GETATTR(vp, &vattr, p->p_ucred, p))
+ error = VOP_GETATTR(vp, &vattr, p->p_ucred, p);
+ if (error)
return (error);
*(int *)data = vattr.va_size - fp->f_offset;
return (0);
OpenPOWER on IntegriCloud