summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_conf.h54
-rw-r--r--sys/kern/subr_disk.c8
-rw-r--r--sys/kern/subr_prf.c39
-rw-r--r--sys/kern/subr_xxx.c8
-rw-r--r--sys/kern/tty_pty.c229
-rw-r--r--sys/kern/vfs_bio.c23
-rw-r--r--sys/kern/vfs_init.c21
-rw-r--r--sys/kern/vfs_subr.c113
-rw-r--r--sys/kern/vfs_syscalls.c301
-rw-r--r--sys/kern/vnode_if.src6
10 files changed, 492 insertions, 310 deletions
diff --git a/sys/kern/kern_conf.h b/sys/kern/kern_conf.h
new file mode 100644
index 00000000000..5aaa8e39d5b
--- /dev/null
+++ b/sys/kern/kern_conf.h
@@ -0,0 +1,54 @@
+/* $NetBSD: kern_conf.h,v 1.1 1996/02/04 02:19:27 christos Exp $ */
+
+/*
+ * Copyright (c) 1995 Christos Zoulas. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by Christos Zoulas.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/conf.h>
+
+cdev_decl(fdesc);
+
+cdev_decl(log);
+
+#ifndef LKM
+# define NLKM 0
+# define lkmenodev enodev
+#else
+# define NLKM 1
+#endif
+cdev_decl(lkm);
+
+#include "pty.h"
+#define ptstty ptytty
+#define ptsioctl ptyioctl
+cdev_decl(pts);
+#define ptctty ptytty
+#define ptcioctl ptyioctl
+cdev_decl(ptc);
+
+cdev_decl(ctty);
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 8ec8d7d9d10..a4cf0dad7d5 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_disk.c,v 1.15 1996/01/07 22:03:49 thorpej Exp $ */
+/* $NetBSD: subr_disk.c,v 1.16 1996/02/09 18:59:56 christos Exp $ */
/*
* Copyright (c) 1995 Jason R. Thorpe. All rights reserved.
@@ -315,10 +315,10 @@ disk_attach(diskp)
}
/*
- * Detatch a disk.
+ * Detach a disk.
*/
void
-disk_detatch(diskp)
+disk_detach(diskp)
struct disk *diskp;
{
@@ -333,7 +333,7 @@ disk_detatch(diskp)
*/
TAILQ_REMOVE(&disklist, diskp, dk_link);
if (--disk_count < 0)
- panic("disk_detatch: disk_count < 0");
+ panic("disk_detach: disk_count < 0");
}
/*
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index 68ed24d7d58..d7a9745fb6d 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_prf.c,v 1.19 1995/06/16 10:52:17 cgd Exp $ */
+/* $NetBSD: subr_prf.c,v 1.21 1996/02/09 19:00:01 christos Exp $ */
/*-
* Copyright (c) 1986, 1988, 1991, 1993
@@ -55,6 +55,8 @@
#include <sys/syslog.h>
#include <sys/malloc.h>
+#include <dev/cons.h>
+
/*
* Note that stdarg.h and the ANSI style va_start macro is used for both
* ANSI and traditional C compilers.
@@ -71,12 +73,11 @@
struct tty *constty; /* pointer to console "window" tty */
-extern cnputc(); /* standard console putc */
-int (*v_putc)() = cnputc; /* routine to putc on virtual console */
+void (*v_putc) __P((int)) = cnputc; /* routine to putc on virtual console */
-static void putchar __P((int ch, int flags, struct tty *tp));
-static char *ksprintn __P((u_long num, int base, int *len));
-void kprintf __P((const char *fmt, int flags, struct tty *tp, va_list ap));
+static void putchar __P((int, int, struct tty *));
+static char *ksprintn __P((u_long, int, int *));
+void kprintf __P((const char *, int, struct tty *, va_list));
int consintr = 1; /* Ok to handle console interrupts? */
@@ -101,10 +102,12 @@ panic(const char *fmt, ...)
#else
panic(fmt, va_alist)
char *fmt;
+ va_dcl
#endif
{
int bootopt;
va_list ap;
+ static const char fm[] = "panic: %r\n";
bootopt = RB_AUTOBOOT | RB_DUMP;
if (panicstr)
@@ -113,7 +116,7 @@ panic(fmt, va_alist)
panicstr = fmt;
va_start(ap, fmt);
- printf("panic: %r\n", fmt, ap);
+ printf(fm, fmt, ap);
va_end(ap);
#ifdef KGDB
@@ -151,6 +154,7 @@ uprintf(const char *fmt, ...)
#else
uprintf(fmt, va_alist)
char *fmt;
+ va_dcl
#endif
{
register struct proc *p = curproc;
@@ -195,6 +199,7 @@ tprintf(tpr_t tpr, const char *fmt, ...)
tprintf(tpr, fmt, va_alist)
tpr_t tpr;
char *fmt;
+ va_dcl
#endif
{
register struct session *sess = (struct session *)tpr;
@@ -225,6 +230,7 @@ ttyprintf(struct tty *tp, const char *fmt, ...)
ttyprintf(tp, fmt, va_alist)
struct tty *tp;
char *fmt;
+ va_dcl
#endif
{
va_list ap;
@@ -248,6 +254,7 @@ log(int level, const char *fmt, ...)
log(level, fmt, va_alist)
int level;
char *fmt;
+ va_dcl
#endif
{
register int s;
@@ -275,7 +282,7 @@ logpri(level)
register char *p;
putchar('<', TOLOG, NULL);
- for (p = ksprintn((u_long)level, 10, NULL); ch = *p--;)
+ for (p = ksprintn((u_long)level, 10, NULL); (ch = *p--) != 0;)
putchar(ch, TOLOG, NULL);
putchar('>', TOLOG, NULL);
}
@@ -286,6 +293,7 @@ addlog(const char *fmt, ...)
#else
addlog(fmt, va_alist)
char *fmt;
+ va_dcl
#endif
{
register int s;
@@ -310,6 +318,7 @@ printf(const char *fmt, ...)
#else
printf(fmt, va_alist)
char *fmt;
+ va_dcl
#endif
{
va_list ap;
@@ -402,13 +411,13 @@ 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--;)
+ for (q = ksprintn(ul, *p++, NULL); (ch = *q--) != 0;)
putchar(ch, flags, tp);
if (!ul)
break;
- for (tmp = 0; n = *p++;) {
+ for (tmp = 0; (n = *p++) != 0;) {
if (ul & (1 << (n - 1))) {
putchar(tmp ? ',' : '<', flags, tp);
for (; (n = *p) > ' '; ++p)
@@ -431,7 +440,7 @@ reswitch: switch (ch = *(u_char *)fmt++) {
case 's':
if ((p = va_arg(ap, char *)) == NULL)
p = "(null)";
- while (ch = *p++)
+ while ((ch = *p++) != 0)
putchar(ch, flags, tp);
break;
case 'd':
@@ -463,7 +472,7 @@ number: p = ksprintn(ul, base, &tmp);
if (width && (width -= tmp) > 0)
while (width--)
putchar(padc, flags, tp);
- while (ch = *p--)
+ while ((ch = *p--) != 0)
putchar(ch, flags, tp);
break;
default:
@@ -518,11 +527,13 @@ putchar(c, flags, tp)
/*
* Scaled down version of sprintf(3).
*/
+int
#ifdef __STDC__
sprintf(char *buf, const char *cfmt, ...)
#else
sprintf(buf, cfmt, va_alist)
char *buf, *cfmt;
+ va_dcl
#endif
{
register const char *fmt = cfmt;
@@ -565,7 +576,7 @@ reswitch: switch (ch = *(u_char *)fmt++) {
/* case 'r': ... break; XXX */
case 's':
p = va_arg(ap, char *);
- while (*bp++ = *p++)
+ while ((*bp++ = *p++) != 0)
continue;
--bp;
break;
@@ -601,7 +612,7 @@ number: p = ksprintn(ul, base, &tmp);
if (width && (width -= tmp) > 0)
while (width--)
*bp++ = padc;
- while (ch = *p--)
+ while ((ch = *p--) != 0)
*bp++ = ch;
break;
default:
diff --git a/sys/kern/subr_xxx.c b/sys/kern/subr_xxx.c
index 902ace34f36..d311c1e5b3c 100644
--- a/sys/kern/subr_xxx.c
+++ b/sys/kern/subr_xxx.c
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_xxx.c,v 1.9 1994/06/29 06:33:03 cgd Exp $ */
+/* $NetBSD: subr_xxx.c,v 1.10 1996/02/04 02:16:51 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1991, 1993
@@ -80,7 +80,7 @@ enoioctl()
* that is not supported by the current system binary.
*/
int
-enosys()
+enosys ()
{
return (ENOSYS);
@@ -100,8 +100,10 @@ eopnotsupp()
/*
* Generic null operation, always returns success.
*/
+/*ARGSUSED*/
int
-nullop()
+nullop(v)
+ void *v;
{
return (0);
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index 423e1fc1f27..d1912abfe22 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -1,4 +1,4 @@
-/* $NetBSD: tty_pty.c,v 1.30 1995/10/10 01:27:03 mycroft Exp $ */
+/* $NetBSD: tty_pty.c,v 1.32 1996/02/09 19:00:41 christos Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -46,11 +46,16 @@
#include <sys/ioctl.h>
#include <sys/proc.h>
#include <sys/tty.h>
-#include <sys/conf.h>
#include <sys/file.h>
#include <sys/uio.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
+#include <sys/signalvar.h>
+#include <sys/uio.h>
+
+#undef NPTY /* XXX */
+#include <kern/kern_conf.h>
+
#if NPTY == 1
#undef NPTY
@@ -78,7 +83,10 @@ int npty = NPTY; /* for pstat -t */
#define PF_NOSTOP 0x40
#define PF_UCNTL 0x80 /* user control mode */
-void ptsstop __P((struct tty *, int));
+void ptyattach __P((int));
+void ptcwakeup __P((struct tty *, int));
+struct tty *ptytty __P((dev_t));
+void ptsstart __P((struct tty *));
/*
* Establish n (or default if n is 1) ptys in the system.
@@ -99,6 +107,7 @@ ptyattach(n)
}
/*ARGSUSED*/
+int
ptsopen(dev, flag, devtype, p)
dev_t dev;
int flag, devtype;
@@ -132,8 +141,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);
@@ -141,6 +151,7 @@ ptsopen(dev, flag, devtype, p)
return (error);
}
+int
ptsclose(dev, flag, mode, p)
dev_t dev;
int flag, mode;
@@ -148,14 +159,15 @@ ptsclose(dev, flag, mode, p)
{
register struct pt_softc *pti = &pt_softc[minor(dev)];
register struct tty *tp = pti->pt_tty;
- int err;
+ int error;
- err = (*linesw[tp->t_line].l_close)(tp, flag);
- err |= ttyclose(tp);
+ error = (*linesw[tp->t_line].l_close)(tp, flag);
+ error |= ttyclose(tp);
ptcwakeup(tp, FREAD|FWRITE);
- return (err);
+ return (error);
}
+int
ptsread(dev, uio, flag)
dev_t dev;
struct uio *uio;
@@ -175,15 +187,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;
}
@@ -208,6 +222,7 @@ again:
* Wakeups of controlling tty will happen
* indirectly, when tty driver calls ptsstart.
*/
+int
ptswrite(dev, uio, flag)
dev_t dev;
struct uio *uio;
@@ -240,6 +255,32 @@ ptsstart(tp)
ptcwakeup(tp, FREAD);
}
+int
+ptsstop(tp, flush)
+ register struct tty *tp;
+ int flush;
+{
+ struct pt_softc *pti = &pt_softc[minor(tp->t_dev)];
+ int flag;
+
+ /* note: FLUSHREAD and FLUSHWRITE already ok */
+ if (flush == 0) {
+ flush = TIOCPKT_STOP;
+ pti->pt_flags |= PF_STOPPED;
+ } else
+ pti->pt_flags &= ~PF_STOPPED;
+ pti->pt_send |= flush;
+ /* change of perspective */
+ flag = 0;
+ if (flush & FREAD)
+ flag |= FWRITE;
+ if (flush & FWRITE)
+ flag |= FREAD;
+ ptcwakeup(tp, flag);
+ return 0;
+}
+
+void
ptcwakeup(tp, flag)
struct tty *tp;
int flag;
@@ -286,9 +327,12 @@ ptcopen(dev, flag, devtype, p)
return (0);
}
+/*ARGSUSED*/
int
-ptcclose(dev)
+ptcclose(dev, flag, devtype, p)
dev_t dev;
+ int flag, devtype;
+ struct proc *p;
{
register struct pt_softc *pti = &pt_softc[minor(dev)];
register struct tty *tp = pti->pt_tty;
@@ -299,6 +343,7 @@ ptcclose(dev)
return (0);
}
+int
ptcread(dev, uio, flag)
dev_t dev;
struct uio *uio;
@@ -324,7 +369,8 @@ ptcread(dev, uio, flag)
if (pti->pt_send & TIOCPKT_IOCTL) {
cc = min(uio->uio_resid,
sizeof(tp->t_termios));
- uiomove(&tp->t_termios, cc, uio);
+ uiomove((caddr_t) &tp->t_termios,
+ cc, uio);
}
pti->pt_send = 0;
return (0);
@@ -343,8 +389,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))
@@ -365,84 +412,8 @@ ptcread(dev, uio, flag)
return (error);
}
-void
-ptsstop(tp, flush)
- register struct tty *tp;
- int flush;
-{
- struct pt_softc *pti = &pt_softc[minor(tp->t_dev)];
- int flag;
-
- /* note: FLUSHREAD and FLUSHWRITE already ok */
- if (flush == 0) {
- flush = TIOCPKT_STOP;
- pti->pt_flags |= PF_STOPPED;
- } else
- pti->pt_flags &= ~PF_STOPPED;
- pti->pt_send |= flush;
- /* change of perspective */
- flag = 0;
- if (flush & FREAD)
- flag |= FWRITE;
- if (flush & FWRITE)
- flag |= FREAD;
- ptcwakeup(tp, flag);
-}
-
-ptcselect(dev, rw, p)
- dev_t dev;
- int rw;
- struct proc *p;
-{
- register struct pt_softc *pti = &pt_softc[minor(dev)];
- register struct tty *tp = pti->pt_tty;
- int s;
-
- if ((tp->t_state&TS_CARR_ON) == 0)
- return (1);
- switch (rw) {
-
- case FREAD:
- /*
- * Need to block timeouts (ttrstart).
- */
- s = spltty();
- if ((tp->t_state&TS_ISOPEN) &&
- tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0) {
- splx(s);
- return (1);
- }
- splx(s);
- /* FALLTHROUGH */
-
- 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))
- return (1);
- selrecord(p, &pti->pt_selr);
- break;
-
-
- case FWRITE:
- if (tp->t_state&TS_ISOPEN) {
- if (pti->pt_flags & PF_REMOTE) {
- if (tp->t_canq.c_cc == 0)
- return (1);
- } else {
- if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG-2)
- return (1);
- if (tp->t_canq.c_cc == 0 && (tp->t_iflag&ICANON))
- return (1);
- }
- }
- selrecord(p, &pti->pt_selw);
- break;
-
- }
- return (0);
-}
+int
ptcwrite(dev, uio, flag)
dev_t dev;
register struct uio *uio;
@@ -450,7 +421,7 @@ ptcwrite(dev, uio, flag)
{
register struct pt_softc *pti = &pt_softc[minor(dev)];
register struct tty *tp = pti->pt_tty;
- register u_char *cp;
+ register u_char *cp = NULL;
register int cc = 0;
u_char locbuf[BUFSIZ];
int cnt = 0;
@@ -521,8 +492,9 @@ 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);
@@ -530,6 +502,62 @@ block:
goto again;
}
+int
+ptcselect(dev, rw, p)
+ dev_t dev;
+ int rw;
+ struct proc *p;
+{
+ register struct pt_softc *pti = &pt_softc[minor(dev)];
+ register struct tty *tp = pti->pt_tty;
+ int s;
+
+ if ((tp->t_state&TS_CARR_ON) == 0)
+ return (1);
+ switch (rw) {
+
+ case FREAD:
+ /*
+ * Need to block timeouts (ttrstart).
+ */
+ s = spltty();
+ if ((tp->t_state&TS_ISOPEN) &&
+ tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0) {
+ splx(s);
+ return (1);
+ }
+ splx(s);
+ /* FALLTHROUGH */
+
+ 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)))
+ return (1);
+ selrecord(p, &pti->pt_selr);
+ break;
+
+
+ case FWRITE:
+ if (tp->t_state&TS_ISOPEN) {
+ if (pti->pt_flags & PF_REMOTE) {
+ if (tp->t_canq.c_cc == 0)
+ return (1);
+ } else {
+ if (tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG-2)
+ return (1);
+ if (tp->t_canq.c_cc == 0 && (tp->t_iflag&ICANON))
+ return (1);
+ }
+ }
+ selrecord(p, &pti->pt_selw);
+ break;
+
+ }
+ return (0);
+}
+
+
struct tty *
ptytty(dev)
dev_t dev;
@@ -541,6 +569,7 @@ ptytty(dev)
}
/*ARGSUSED*/
+int
ptyioctl(dev, cmd, data, flag, p)
dev_t dev;
u_long cmd;
@@ -616,7 +645,7 @@ ptyioctl(dev, cmd, data, flag, p)
ttyflush(tp, FREAD|FWRITE);
return (0);
-#if defined(COMPAT_43) || defined(COMPAT_FREEBSD)
+#ifdef COMPAT_OLDTTY
case TIOCSETP:
case TIOCSETN:
#endif
@@ -660,11 +689,9 @@ ptyioctl(dev, cmd, data, flag, p)
case TIOCSETA:
case TIOCSETAW:
case TIOCSETAF:
-#if defined(COMPAT_43) || defined(COMPAT_FREEBSD)
+#ifdef COMPAT_OLDTTY
case TIOCSETP:
case TIOCSETN:
-#endif
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS) || defined(COMPAT_FREEBSD)
case TIOCSETC:
case TIOCSLTC:
case TIOCLBIS:
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index 4592f764764..0667f8ed409 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_bio.c,v 1.39 1995/08/02 22:01:46 cgd Exp $ */
+/* $NetBSD: vfs_bio.c,v 1.41 1996/02/09 19:00:53 christos Exp $ */
/*-
* Copyright (c) 1994 Christopher G. Demetriou
@@ -58,6 +58,7 @@
#include <sys/malloc.h>
#include <sys/resourcevar.h>
#include <sys/conf.h>
+#include <sys/cpu.h>
/* Macros to clear/set/test flags. */
#define SET(t, f) (t) |= (f)
@@ -97,6 +98,10 @@ int needbuffer;
#define binsheadfree(bp, dp) TAILQ_INSERT_HEAD(dp, bp, b_freelist)
#define binstailfree(bp, dp) TAILQ_INSERT_TAIL(dp, bp, b_freelist)
+static __inline struct buf *bio_doread __P((struct vnode *, daddr_t, int,
+ struct ucred *, int));
+int count_lock_queue __P((void));
+
void
bremfree(bp)
struct buf *bp;
@@ -155,7 +160,7 @@ bufinit()
}
}
-__inline struct buf *
+static __inline struct buf *
bio_doread(vp, blkno, size, cred, async)
struct vnode *vp;
daddr_t blkno;
@@ -194,6 +199,7 @@ bio_doread(vp, blkno, size, cred, async)
* Read a disk block.
* This algorithm described in Bach (p.54).
*/
+int
bread(vp, blkno, size, cred, bpp)
struct vnode *vp;
daddr_t blkno;
@@ -214,6 +220,7 @@ bread(vp, blkno, size, cred, bpp)
* Read-ahead multiple disk blocks. The first is sync, the rest async.
* Trivial modification to the breada algorithm presented in Bach (p.55).
*/
+int
breadn(vp, blkno, size, rablks, rasizes, nrablks, cred, bpp)
struct vnode *vp;
daddr_t blkno; int size;
@@ -248,6 +255,7 @@ breadn(vp, blkno, size, rablks, rasizes, nrablks, cred, bpp)
* implemented as a call to breadn().
* XXX for compatibility with old file systems.
*/
+int
breada(vp, blkno, size, rablkno, rabsize, cred, bpp)
struct vnode *vp;
daddr_t blkno; int size;
@@ -262,10 +270,11 @@ breada(vp, blkno, size, rablkno, rabsize, cred, bpp)
/*
* Block write. Described in Bach (p.56)
*/
+int
bwrite(bp)
struct buf *bp;
{
- int rv, s, sync, wasdelayed;
+ int rv, sync, wasdelayed;
/*
* Remember buffer type, to switch on it later. If the write was
@@ -327,9 +336,10 @@ bwrite(bp)
}
int
-vn_bwrite(ap)
- struct vop_bwrite_args *ap;
+vn_bwrite(v)
+ void *v;
{
+ struct vop_bwrite_args *ap = v;
return (bwrite(ap->a_bp));
}
@@ -584,6 +594,7 @@ geteblk(size)
* start a write. If the buffer grows, it's the callers
* responsibility to fill out the buffer's additional contents.
*/
+void
allocbuf(bp, size)
struct buf *bp;
int size;
@@ -616,7 +627,7 @@ allocbuf(bp, size)
/* and steal its pages, up to the amount we need */
amt = min(nbp->b_bufsize, (desired_size - bp->b_bufsize));
pagemove((nbp->b_data + nbp->b_bufsize - amt),
- bp->b_data + bp->b_bufsize, amt);
+ bp->b_data + bp->b_bufsize, amt);
bp->b_bufsize += amt;
nbp->b_bufsize -= amt;
diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c
index 89ea3fcf9e9..3cad6d54bc2 100644
--- a/sys/kern/vfs_init.c
+++ b/sys/kern/vfs_init.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_init.c,v 1.4 1995/03/19 23:45:01 mycroft Exp $ */
+/* $NetBSD: vfs_init.c,v 1.6 1996/02/09 19:00:58 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -51,6 +51,7 @@
#include <sys/buf.h>
#include <sys/errno.h>
#include <sys/malloc.h>
+#include <sys/systm.h>
/*
* Sigh, such primitive tools are these...
@@ -73,14 +74,21 @@ extern struct vnodeop_desc *vfs_op_descs[];
*/
int vfs_opv_numops;
-typedef (*PFI)(); /* the standard Pointer to a Function returning an Int */
+typedef (*PFI) __P((void *));
+
+void vfs_opv_init __P((void));
+void vfs_opv_init_explicit __P((struct vnodeopv_desc *));
+void vfs_opv_init_default __P((struct vnodeopv_desc *));
+void vfs_op_init __P((void));
/*
* A miscellaneous routine.
* A generic "default" routine that just returns an error.
*/
+/*ARGSUSED*/
int
-vn_default_error()
+vn_default_error(v)
+ void *v;
{
return (EOPNOTSUPP);
@@ -111,7 +119,7 @@ void
vfs_opv_init_explicit(vfs_opv_desc)
struct vnodeopv_desc *vfs_opv_desc;
{
- int (**opv_desc_vector)();
+ int (**opv_desc_vector) __P((void *));
struct vnodeopv_entry_desc *opve_descp;
opv_desc_vector = *(vfs_opv_desc->opv_desc_vector_p);
@@ -166,8 +174,7 @@ vfs_opv_init_default(vfs_opv_desc)
struct vnodeopv_desc *vfs_opv_desc;
{
int j;
- int (**opv_desc_vector)();
- struct vnodeopv_entry_desc *opve_descp;
+ int (**opv_desc_vector) __P((void *));
opv_desc_vector = *(vfs_opv_desc->opv_desc_vector_p);
@@ -232,12 +239,12 @@ vfs_op_init()
*/
extern struct vnodeops dead_vnodeops;
extern struct vnodeops spec_vnodeops;
-extern void vclean();
struct vattr va_null;
/*
* Initialize the vnode structures and initialize each file system type.
*/
+void
vfsinit()
{
struct vfsops **vfsp;
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index e9dad30122d..d7c464703cd 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_subr.c,v 1.47 1995/10/07 06:28:48 mycroft Exp $ */
+/* $NetBSD: vfs_subr.c,v 1.51 1996/02/09 19:01:01 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -59,6 +59,8 @@
#include <sys/malloc.h>
#include <sys/domain.h>
#include <sys/mbuf.h>
+#include <sys/syscallargs.h>
+#include <sys/cpu.h>
#include <vm/vm.h>
#include <sys/sysctl.h>
@@ -88,9 +90,54 @@ int prtactive = 0; /* 1 => print out reclaim of active vnodes */
TAILQ_HEAD(freelst, vnode) vnode_free_list; /* vnode free list */
struct mntlist mountlist; /* mounted filesystem list */
+int vfs_lock __P((struct mount *));
+void vfs_unlock __P((struct mount *));
+struct mount *getvfs __P((fsid_t *));
+long makefstype __P((char *));
+void vattr_null __P((struct vattr *));
+int getnewvnode __P((enum vtagtype, struct mount *, int (**)(void *),
+ struct vnode **));
+void insmntque __P((struct vnode *, struct mount *));
+int vinvalbuf __P((struct vnode *, int, struct ucred *, struct proc *, int,
+ int));
+void vflushbuf __P((struct vnode *, int));
+void brelvp __P((struct buf *));
+int bdevvp __P((dev_t, struct vnode **));
+int cdevvp __P((dev_t, struct vnode **));
+int getdevvp __P((dev_t, struct vnode **, enum vtype));
+struct vnode *checkalias __P((struct vnode *, dev_t, struct mount *));
+int vget __P((struct vnode *, int));
+void vref __P((struct vnode *));
+void vput __P((struct vnode *));
+void vrele __P((struct vnode *));
+void vhold __P((struct vnode *));
+void holdrele __P((struct vnode *));
+int vflush __P((struct mount *, struct vnode *, int));
+void vgoneall __P((struct vnode *));
+void vgone __P((struct vnode *));
+int vcount __P((struct vnode *));
+void vprint __P((char *, struct vnode *));
+int vfs_mountedon __P((struct vnode *));
+int vfs_export __P((struct mount *, struct netexport *, struct export_args *));
+struct netcred *vfs_export_lookup __P((struct mount *, struct netexport *,
+ struct mbuf *));
+int vaccess __P((mode_t, uid_t, gid_t, mode_t, struct ucred *));
+void vfs_unmountall __P((void));
+void vfs_shutdown __P((void));
+
+static int vfs_hang_addrlist __P((struct mount *, struct netexport *,
+ struct export_args *));
+static int vfs_free_netcred __P((struct radix_node *, void *));
+static void vfs_free_addrlist __P((struct netexport *));
+
+#ifdef DEBUG
+void printlockedvnodes __P((void));
+#endif
+
/*
* Initialize the vnode management data structures.
*/
+void
vntblinit()
{
@@ -102,6 +149,7 @@ vntblinit()
* Lock a filesystem.
* Used to prevent access to it while mounting and unmounting.
*/
+int
vfs_lock(mp)
register struct mount *mp;
{
@@ -136,6 +184,7 @@ vfs_unlock(mp)
* Mark a mount point as busy.
* Used to synchronize access and to delay unmounting.
*/
+int
vfs_busy(mp)
register struct mount *mp;
{
@@ -154,6 +203,7 @@ vfs_busy(mp)
* Free a busy filesystem.
* Panic if filesystem is not busy.
*/
+void
vfs_unbusy(mp)
register struct mount *mp;
{
@@ -242,9 +292,9 @@ vattr_null(vap)
vap->va_mode = vap->va_nlink = vap->va_uid = vap->va_gid =
vap->va_fsid = vap->va_fileid =
vap->va_blocksize = vap->va_rdev =
- vap->va_atime.ts_sec = vap->va_atime.ts_nsec =
- vap->va_mtime.ts_sec = vap->va_mtime.ts_nsec =
- vap->va_ctime.ts_sec = vap->va_ctime.ts_nsec =
+ vap->va_atime.tv_sec = vap->va_atime.tv_nsec =
+ vap->va_mtime.tv_sec = vap->va_mtime.tv_nsec =
+ vap->va_ctime.tv_sec = vap->va_ctime.tv_nsec =
vap->va_flags = vap->va_gen = VNOVAL;
vap->va_vaflags = 0;
}
@@ -252,21 +302,23 @@ vattr_null(vap)
/*
* Routines having to do with the management of the vnode table.
*/
-extern int (**dead_vnodeop_p)();
-extern void vclean();
+extern int (**dead_vnodeop_p) __P((void *));
long numvnodes;
/*
* Return the next vnode from the free list.
*/
+int
getnewvnode(tag, mp, vops, vpp)
enum vtagtype tag;
struct mount *mp;
- int (**vops)();
+ int (**vops) __P((void *));
struct vnode **vpp;
{
register struct vnode *vp;
+#ifdef DIAGNOSTIC
int s;
+#endif
if ((vnode_free_list.tqh_first == NULL &&
numvnodes < 2 * desiredvnodes) ||
@@ -325,6 +377,7 @@ getnewvnode(tag, mp, vops, vpp)
/*
* Move a vnode from one mount queue to another.
*/
+void
insmntque(vp, mp)
register struct vnode *vp;
register struct mount *mp;
@@ -346,13 +399,14 @@ insmntque(vp, mp)
/*
* Update outstanding I/O count and do wakeup if requested.
*/
+void
vwakeup(bp)
register struct buf *bp;
{
register struct vnode *vp;
bp->b_flags &= ~B_WRITEINPROG;
- if (vp = bp->b_vp) {
+ if ((vp = bp->b_vp) != NULL) {
if (--vp->v_numoutput < 0)
panic("vwakeup: neg numoutput");
if ((vp->v_flag & VBWAIT) && vp->v_numoutput <= 0) {
@@ -379,7 +433,7 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo)
int s, error;
if (flags & V_SAVE) {
- if (error = VOP_FSYNC(vp, cred, MNT_WAIT, p))
+ if ((error = VOP_FSYNC(vp, cred, MNT_WAIT, p)) != 0)
return (error);
if (vp->v_dirtyblkhd.lh_first != NULL)
panic("vinvalbuf: dirty bufs");
@@ -479,6 +533,7 @@ loop:
/*
* Associate a buffer with a vnode.
*/
+void
bgetvp(vp, bp)
register struct vnode *vp;
register struct buf *bp;
@@ -501,6 +556,7 @@ bgetvp(vp, bp)
/*
* Disassociate a buffer from a vnode.
*/
+void
brelvp(bp)
register struct buf *bp;
{
@@ -523,6 +579,7 @@ brelvp(bp)
* Used to assign file specific control information
* (indirect blocks) to the vnode to which they belong.
*/
+void
reassignbuf(bp, newvp)
register struct buf *bp;
register struct vnode *newvp;
@@ -554,6 +611,7 @@ reassignbuf(bp, newvp)
* Used for root filesystem, argdev, and swap areas.
* Also used for memory file system special devices.
*/
+int
bdevvp(dev, vpp)
dev_t dev;
struct vnode **vpp;
@@ -566,6 +624,7 @@ bdevvp(dev, vpp)
* Create a vnode for a character device.
* Used for kernfs and some console handling.
*/
+int
cdevvp(dev, vpp)
dev_t dev;
struct vnode **vpp;
@@ -579,6 +638,7 @@ cdevvp(dev, vpp)
* Used by bdevvp (block device) for root file system etc.,
* and by cdevvp (character device) for console and kernfs.
*/
+int
getdevvp(dev, vpp, type)
dev_t dev;
struct vnode **vpp;
@@ -590,14 +650,14 @@ getdevvp(dev, vpp, type)
if (dev == NODEV)
return (0);
- error = getnewvnode(VT_NON, (struct mount *)0, spec_vnodeop_p, &nvp);
+ error = getnewvnode(VT_NON, NULL, spec_vnodeop_p, &nvp);
if (error) {
*vpp = NULLVP;
return (error);
}
vp = nvp;
vp->v_type = type;
- if (nvp = checkalias(vp, dev, (struct mount *)0)) {
+ if ((nvp = checkalias(vp, dev, NULL)) != 0) {
vput(vp);
vp = nvp;
}
@@ -795,6 +855,7 @@ int busyprt = 0; /* print out busy vnodes */
struct ctldebug debug1 = { "busyprt", &busyprt };
#endif
+int
vflush(mp, skipvp, flags)
struct mount *mp;
struct vnode *skipvp;
@@ -877,7 +938,7 @@ vclean(vp, flags)
* so that its count cannot fall to zero and generate a
* race against ourselves to recycle it.
*/
- if (active = vp->v_usecount)
+ if ((active = vp->v_usecount) != 0)
VREF(vp);
/*
* Even if the count is zero, the VOP_INACTIVE routine may still
@@ -1004,10 +1065,7 @@ vgone(vp)
/*
* Delete from old mount point vnode list, if on one.
*/
- if (vp->v_mount != NULL) {
- LIST_REMOVE(vp, v_mntvnodes);
- vp->v_mount = NULL;
- }
+ insmntque(vp, (struct mount *)0);
/*
* If special device, remove it from special device alias list.
*/
@@ -1068,6 +1126,7 @@ vgone(vp)
/*
* Lookup a vnode by device number.
*/
+int
vfinddev(dev, type, vpp)
dev_t dev;
enum vtype type;
@@ -1161,6 +1220,7 @@ vprint(label, vp)
* List all of the locked vnodes in the system.
* Called when debugging the kernel.
*/
+void
printlockedvnodes()
{
register struct mount *mp;
@@ -1186,6 +1246,7 @@ int kinfo_vgetfailed;
* Copyout address of vnode followed by vnode.
*/
/* ARGSUSED */
+int
sysctl_vnode(where, sizep)
char *where;
size_t *sizep;
@@ -1295,7 +1356,8 @@ vfs_hang_addrlist(mp, nep, argp)
np = (struct netcred *)malloc(i, M_NETADDR, M_WAITOK);
bzero((caddr_t)np, i);
saddr = (struct sockaddr *)(np + 1);
- if (error = copyin(argp->ex_addr, (caddr_t)saddr, argp->ex_addrlen))
+ error = copyin(argp->ex_addr, (caddr_t)saddr, argp->ex_addrlen);
+ if (error)
goto out;
if (saddr->sa_len > argp->ex_addrlen)
saddr->sa_len = argp->ex_addrlen;
@@ -1343,7 +1405,7 @@ out:
static int
vfs_free_netcred(rn, w)
struct radix_node *rn;
- caddr_t w;
+ void *w;
{
register struct radix_node_head *rnh = (struct radix_node_head *)w;
@@ -1363,9 +1425,8 @@ vfs_free_addrlist(nep)
register struct radix_node_head *rnh;
for (i = 0; i <= AF_MAX; i++)
- if (rnh = nep->ne_rtable[i]) {
- (*rnh->rnh_walktree)(rnh, vfs_free_netcred,
- (caddr_t)rnh);
+ if ((rnh = nep->ne_rtable[i]) != NULL) {
+ (*rnh->rnh_walktree)(rnh, vfs_free_netcred, rnh);
free((caddr_t)rnh, M_RTABLE);
nep->ne_rtable[i] = 0;
}
@@ -1384,7 +1445,7 @@ vfs_export(mp, nep, argp)
mp->mnt_flag &= ~(MNT_EXPORTED | MNT_DEFEXPORTED);
}
if (argp->ex_flags & MNT_EXPORTED) {
- if (error = vfs_hang_addrlist(mp, nep, argp))
+ if ((error = vfs_hang_addrlist(mp, nep, argp)) != 0)
return (error);
mp->mnt_flag |= MNT_EXPORTED;
}
@@ -1440,8 +1501,6 @@ vaccess(file_mode, uid, gid, acc_mode, cred)
struct ucred *cred;
{
mode_t mask;
- int i;
- register gid_t *gp;
/* User id 0 always gets access. */
if (cred->cr_uid == 0)
@@ -1495,7 +1554,7 @@ vfs_unmountall()
for (allerror = 0,
mp = mountlist.cqh_last; mp != (void *)&mountlist; mp = nmp) {
nmp = mp->mnt_list.cqe_prev;
- if (error = dounmount(mp, MNT_FORCE, &proc0)) {
+ if ((error = dounmount(mp, MNT_FORCE, &proc0)) != 0) {
printf("unmount of %s failed with error %d\n",
mp->mnt_stat.f_mntonname, error);
allerror = 1;
@@ -1527,14 +1586,14 @@ vfs_shutdown()
#endif
/* Sync before unmount, in case we hang on something. */
- sys_sync(&proc0, (void *)0, (int *)0);
+ sys_sync(&proc0, (void *)0, (register_t *)0);
/* Unmount file systems. */
vfs_unmountall();
}
/* Sync again after unmount, just in case. */
- sys_sync(&proc0, (void *)0, (int *)0);
+ sys_sync(&proc0, (void *)0, (register_t *)0);
/* Wait for sync to finish. */
for (iter = 0; iter < 20; iter++) {
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 38c91fa1c15..72370525422 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.c,v 1.58 1995/11/07 22:41:02 gwr Exp $ */
+/* $NetBSD: vfs_syscalls.c,v 1.68 1996/02/09 19:01:05 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -59,7 +59,10 @@
#include <vm/vm.h>
#include <sys/sysctl.h>
-static int change_dir __P((struct nameidata *ndp, struct proc *p));
+static int change_dir __P((struct nameidata *, struct proc *));
+
+void checkdirs __P((struct vnode *));
+int dounmount __P((struct mount *, int, struct proc *));
/*
* Virtual File System System Calls
@@ -69,6 +72,7 @@ static int change_dir __P((struct nameidata *ndp, struct proc *p));
* Mount a file system.
*/
/* ARGSUSED */
+int
sys_mount(p, v, retval)
struct proc *p;
void *v;
@@ -82,8 +86,8 @@ sys_mount(p, v, retval)
} */ *uap = v;
register struct vnode *vp;
register struct mount *mp;
- int error, flag;
- u_long fsindex;
+ int error, flag = 0;
+ u_long fsindex = 0;
char fstypename[MFSNAMELEN];
struct vattr va;
struct nameidata nd;
@@ -93,7 +97,7 @@ sys_mount(p, v, retval)
*/
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
if (SCARG(uap, flags) & MNT_UPDATE) {
@@ -158,14 +162,14 @@ sys_mount(p, v, retval)
}
SCARG(uap, flags) |= MNT_NOSUID | MNT_NODEV;
}
- if (error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0))
+ if ((error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0)) != 0)
return (error);
if (vp->v_type != VDIR) {
vput(vp);
return (ENOTDIR);
}
- if (error = copyinstr(SCARG(uap, type), fstypename, MFSNAMELEN,
- (size_t *)0)) {
+ error = copyinstr(SCARG(uap, type), fstypename, MFSNAMELEN, NULL);
+ if (error) {
#if defined(COMPAT_09) || defined(COMPAT_43)
/*
* Historically filesystem types were identified by number.
@@ -210,7 +214,7 @@ sys_mount(p, v, retval)
M_MOUNT, M_WAITOK);
bzero((char *)mp, (u_long)sizeof(struct mount));
mp->mnt_op = vfssw[fsindex];
- if (error = vfs_lock(mp)) {
+ if ((error = vfs_lock(mp)) != 0) {
free((caddr_t)mp, M_MOUNT);
vput(vp);
return (error);
@@ -272,6 +276,7 @@ update:
* or root directory onto which the new filesystem has just been
* mounted. If so, replace them with the new mount point.
*/
+void
checkdirs(olddp)
struct vnode *olddp;
{
@@ -311,6 +316,7 @@ checkdirs(olddp)
* not special file (as before).
*/
/* ARGSUSED */
+int
sys_unmount(p, v, retval)
struct proc *p;
void *v;
@@ -327,7 +333,7 @@ sys_unmount(p, v, retval)
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
mp = vp->v_mount;
@@ -364,6 +370,7 @@ sys_unmount(p, v, retval)
/*
* Do the actual file system unmount.
*/
+int
dounmount(mp, flags, p)
register struct mount *mp;
int flags;
@@ -376,7 +383,7 @@ dounmount(mp, flags, p)
if (vfs_busy(mp))
return (EBUSY);
mp->mnt_flag |= MNT_UNMOUNT;
- if (error = vfs_lock(mp))
+ if ((error = vfs_lock(mp)) != 0)
return (error);
mp->mnt_flag &=~ MNT_ASYNC;
@@ -413,6 +420,7 @@ struct ctldebug debug0 = { "syncprt", &syncprt };
#endif
/* ARGSUSED */
+int
sys_sync(p, v, retval)
struct proc *p;
void *v;
@@ -457,6 +465,7 @@ sys_sync(p, v, retval)
* Change filesystem quotas.
*/
/* ARGSUSED */
+int
sys_quotactl(p, v, retval)
struct proc *p;
void *v;
@@ -473,7 +482,7 @@ sys_quotactl(p, v, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
mp = nd.ni_vp->v_mount;
vrele(nd.ni_vp);
@@ -485,6 +494,7 @@ sys_quotactl(p, v, retval)
* Get filesystem statistics.
*/
/* ARGSUSED */
+int
sys_statfs(p, v, retval)
struct proc *p;
void *v;
@@ -500,12 +510,12 @@ sys_statfs(p, v, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
mp = nd.ni_vp->v_mount;
sp = &mp->mnt_stat;
vrele(nd.ni_vp);
- if (error = VFS_STATFS(mp, sp, p))
+ if ((error = VFS_STATFS(mp, sp, p)) != 0)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return (copyout((caddr_t)sp, (caddr_t)SCARG(uap, buf), sizeof(*sp)));
@@ -515,6 +525,7 @@ sys_statfs(p, v, retval)
* Get filesystem statistics.
*/
/* ARGSUSED */
+int
sys_fstatfs(p, v, retval)
struct proc *p;
void *v;
@@ -529,11 +540,11 @@ sys_fstatfs(p, v, retval)
register struct statfs *sp;
int error;
- if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
sp = &mp->mnt_stat;
- if (error = VFS_STATFS(mp, sp, p))
+ if ((error = VFS_STATFS(mp, sp, p)) != 0)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
return (copyout((caddr_t)sp, (caddr_t)SCARG(uap, buf), sizeof(*sp)));
@@ -542,6 +553,7 @@ sys_fstatfs(p, v, retval)
/*
* Get statistics on all filesystems.
*/
+int
sys_getfsstat(p, v, retval)
struct proc *p;
void *v;
@@ -574,7 +586,8 @@ sys_getfsstat(p, v, retval)
(error = VFS_STATFS(mp, sp, p)))
continue;
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- if (error = copyout((caddr_t)sp, sfsp, sizeof(*sp)))
+ error = copyout((caddr_t)sp, sfsp, sizeof(*sp));
+ if (error)
return (error);
sfsp += sizeof(*sp);
}
@@ -591,6 +604,7 @@ sys_getfsstat(p, v, retval)
* Change current working directory to a given file descriptor.
*/
/* ARGSUSED */
+int
sys_fchdir(p, v, retval)
struct proc *p;
void *v;
@@ -605,7 +619,7 @@ sys_fchdir(p, v, retval)
struct file *fp;
int error;
- if (error = getvnode(fdp, SCARG(uap, fd), &fp))
+ if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
return (error);
vp = (struct vnode *)fp->f_data;
VREF(vp);
@@ -620,7 +634,7 @@ sys_fchdir(p, v, retval)
sleep((caddr_t)mp, PVFS);
continue;
}
- if (error = VFS_ROOT(mp, &tdp))
+ if ((error = VFS_ROOT(mp, &tdp)) != 0)
break;
vput(vp);
vp = tdp;
@@ -639,6 +653,7 @@ sys_fchdir(p, v, retval)
* Change current working directory (``.'').
*/
/* ARGSUSED */
+int
sys_chdir(p, v, retval)
struct proc *p;
void *v;
@@ -653,7 +668,7 @@ sys_chdir(p, v, retval)
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
- if (error = change_dir(&nd, p))
+ if ((error = change_dir(&nd, p)) != 0)
return (error);
vrele(fdp->fd_cdir);
fdp->fd_cdir = nd.ni_vp;
@@ -664,6 +679,7 @@ sys_chdir(p, v, retval)
* Change notion of root (``/'') directory.
*/
/* ARGSUSED */
+int
sys_chroot(p, v, retval)
struct proc *p;
void *v;
@@ -676,11 +692,11 @@ sys_chroot(p, v, retval)
int error;
struct nameidata nd;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
- if (error = change_dir(&nd, p))
+ if ((error = change_dir(&nd, p)) != 0)
return (error);
if (fdp->fd_rdir != NULL)
vrele(fdp->fd_rdir);
@@ -699,7 +715,7 @@ change_dir(ndp, p)
struct vnode *vp;
int error;
- if (error = namei(ndp))
+ if ((error = namei(ndp)) != 0)
return (error);
vp = ndp->ni_vp;
if (vp->v_type != VDIR)
@@ -716,6 +732,7 @@ change_dir(ndp, p)
* Check permissions, allocate an open file structure,
* and call the device open routine if any.
*/
+int
sys_open(p, v, retval)
struct proc *p;
void *v;
@@ -736,14 +753,14 @@ sys_open(p, v, retval)
struct nameidata nd;
extern struct fileops vnops;
- if (error = falloc(p, &nfp, &indx))
+ if ((error = falloc(p, &nfp, &indx)) != 0)
return (error);
fp = nfp;
flags = FFLAGS(SCARG(uap, flags));
cmode = ((SCARG(uap, mode) &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
- if (error = vn_open(&nd, flags, cmode)) {
+ if ((error = vn_open(&nd, flags, cmode)) != 0) {
ffree(fp);
if ((error == ENODEV || error == ENXIO) &&
p->p_dupfd >= 0 && /* XXX from fdopen */
@@ -775,7 +792,8 @@ sys_open(p, v, 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;
@@ -793,6 +811,7 @@ sys_open(p, v, retval)
* Create a special file.
*/
/* ARGSUSED */
+int
sys_mknod(p, v, retval)
struct proc *p;
void *v;
@@ -806,13 +825,13 @@ sys_mknod(p, v, retval)
register struct vnode *vp;
struct vattr vattr;
int error;
- int whiteout;
+ int whiteout = 0;
struct nameidata nd;
- if (error = suser(p->p_ucred, &p->p_acflag))
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
if (vp != NULL)
@@ -868,6 +887,7 @@ sys_mknod(p, v, retval)
* Create a named pipe.
*/
/* ARGSUSED */
+int
sys_mkfifo(p, v, retval)
struct proc *p;
void *v;
@@ -885,7 +905,7 @@ sys_mkfifo(p, v, retval)
return (EOPNOTSUPP);
#else
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
if (nd.ni_vp != NULL) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@@ -908,6 +928,7 @@ sys_mkfifo(p, v, retval)
* Make a hard file link.
*/
/* ARGSUSED */
+int
sys_link(p, v, retval)
struct proc *p;
void *v;
@@ -922,33 +943,26 @@ sys_link(p, v, retval)
int error;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
- if (vp->v_type != VDIR ||
- (error = suser(p->p_ucred, &p->p_acflag)) == 0) {
- nd.ni_cnd.cn_nameiop = CREATE;
- nd.ni_cnd.cn_flags = LOCKPARENT;
- nd.ni_dirp = SCARG(uap, link);
- if ((error = namei(&nd)) == 0) {
- if (nd.ni_vp != NULL)
- error = EEXIST;
- if (!error) {
- VOP_LEASE(nd.ni_dvp, p, p->p_ucred,
- LEASE_WRITE);
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
- } else {
- VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
- if (nd.ni_dvp == nd.ni_vp)
- vrele(nd.ni_dvp);
- else
- vput(nd.ni_dvp);
- if (nd.ni_vp)
- vrele(nd.ni_vp);
- }
- }
+ NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, link), p);
+ if ((error = namei(&nd)) != 0)
+ goto out;
+ if (nd.ni_vp) {
+ VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
+ if (nd.ni_dvp == nd.ni_vp)
+ vrele(nd.ni_dvp);
+ else
+ vput(nd.ni_dvp);
+ vrele(nd.ni_vp);
+ error = EEXIST;
+ goto out;
}
+ VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
+ VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
+ error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd);
+out:
vrele(vp);
return (error);
}
@@ -957,6 +971,7 @@ sys_link(p, v, retval)
* Make a symbolic link.
*/
/* ARGSUSED */
+int
sys_symlink(p, v, retval)
struct proc *p;
void *v;
@@ -972,10 +987,11 @@ sys_symlink(p, v, retval)
struct nameidata nd;
MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
- if (error = copyinstr(SCARG(uap, path), path, MAXPATHLEN, (size_t *)0))
+ error = copyinstr(SCARG(uap, path), path, MAXPATHLEN, NULL);
+ if (error)
goto out;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, link), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
goto out;
if (nd.ni_vp) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
@@ -1000,6 +1016,7 @@ out:
* Delete a whiteout from the filesystem.
*/
/* ARGSUSED */
+int
sys_undelete(p, v, retval)
struct proc *p;
void *v;
@@ -1029,7 +1046,7 @@ sys_undelete(p, v, retval)
}
VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- if (error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, DELETE))
+ if ((error = VOP_WHITEOUT(nd.ni_dvp, &nd.ni_cnd, DELETE)) != 0)
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
vput(nd.ni_dvp);
return (error);
@@ -1039,6 +1056,7 @@ sys_undelete(p, v, retval)
* Delete a name from the filesystem.
*/
/* ARGSUSED */
+int
sys_unlink(p, v, retval)
struct proc *p;
void *v;
@@ -1051,42 +1069,39 @@ sys_unlink(p, v, retval)
int error;
struct nameidata nd;
- NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE,
+ SCARG(uap, path), p);
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
- VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
- VOP_LOCK(vp);
-
- if (vp->v_type != VDIR ||
- (error = suser(p->p_ucred, &p->p_acflag)) == 0) {
- /*
- * The root of a mounted filesystem cannot be deleted.
- */
- if (vp->v_flag & VROOT)
- error = EBUSY;
- else
- (void)vnode_pager_uncache(vp);
- }
- if (!error) {
- VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
- error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
- } else {
+ /*
+ * The root of a mounted filesystem cannot be deleted.
+ */
+ if (vp->v_flag & VROOT) {
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
if (nd.ni_dvp == vp)
vrele(nd.ni_dvp);
else
vput(nd.ni_dvp);
- if (vp != NULLVP)
- vput(vp);
+ vput(vp);
+ error = EBUSY;
+ goto out;
}
+
+ if (vp->v_flag & VTEXT)
+ (void)vnode_pager_uncache(vp);
+ VOP_LEASE(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
+ VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
+ error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
+out:
return (error);
}
/*
* Reposition read/write file offset.
*/
+int
sys_lseek(p, v, retval)
struct proc *p;
void *v;
@@ -1114,8 +1129,9 @@ sys_lseek(p, v, retval)
fp->f_offset += SCARG(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 = SCARG(uap, offset) + vattr.va_size;
break;
@@ -1132,6 +1148,7 @@ sys_lseek(p, v, retval)
/*
* Check access permissions.
*/
+int
sys_access(p, v, retval)
struct proc *p;
void *v;
@@ -1152,7 +1169,7 @@ sys_access(p, v, retval)
cred->cr_gid = p->p_cred->p_rgid;
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
goto out1;
vp = nd.ni_vp;
@@ -1179,6 +1196,7 @@ out1:
* Get file status; this version follows links.
*/
/* ARGSUSED */
+int
sys_stat(p, v, retval)
struct proc *p;
void *v;
@@ -1194,7 +1212,7 @@ sys_stat(p, v, retval)
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
error = vn_stat(nd.ni_vp, &sb, p);
vput(nd.ni_vp);
@@ -1208,6 +1226,7 @@ sys_stat(p, v, retval)
* Get file status; this version does not follow links.
*/
/* ARGSUSED */
+int
sys_lstat(p, v, retval)
struct proc *p;
void *v;
@@ -1217,47 +1236,18 @@ sys_lstat(p, v, retval)
syscallarg(char *) path;
syscallarg(struct stat *) ub;
} */ *uap = v;
+ struct stat sb;
int error;
- struct vnode *vp, *dvp;
- struct stat sb, sb1;
struct nameidata nd;
- NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
+ NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
+ return (error);
+ error = vn_stat(nd.ni_vp, &sb, p);
+ vput(nd.ni_vp);
+ if (error)
return (error);
- /*
- * For symbolic links, always return the attributes of its
- * containing directory, except for mode, size, and links.
- */
- vp = nd.ni_vp;
- dvp = nd.ni_dvp;
- if (vp->v_type != VLNK) {
- if (dvp == vp)
- vrele(dvp);
- else
- vput(dvp);
- error = vn_stat(vp, &sb, p);
- vput(vp);
- if (error)
- return (error);
- } else {
- error = vn_stat(dvp, &sb, p);
- vput(dvp);
- if (error) {
- vput(vp);
- return (error);
- }
- error = vn_stat(vp, &sb1, p);
- vput(vp);
- if (error)
- return (error);
- sb.st_mode &= ~S_IFDIR;
- sb.st_mode |= S_IFLNK;
- sb.st_nlink = sb1.st_nlink;
- sb.st_size = sb1.st_size;
- sb.st_blocks = sb1.st_blocks;
- }
error = copyout((caddr_t)&sb, (caddr_t)SCARG(uap, ub), sizeof (sb));
return (error);
}
@@ -1266,6 +1256,7 @@ sys_lstat(p, v, retval)
* Get configurable pathname variables.
*/
/* ARGSUSED */
+int
sys_pathconf(p, v, retval)
struct proc *p;
void *v;
@@ -1280,7 +1271,7 @@ sys_pathconf(p, v, retval)
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
error = VOP_PATHCONF(nd.ni_vp, SCARG(uap, name), retval);
vput(nd.ni_vp);
@@ -1291,6 +1282,7 @@ sys_pathconf(p, v, retval)
* Return target name of a symbolic link.
*/
/* ARGSUSED */
+int
sys_readlink(p, v, retval)
struct proc *p;
void *v;
@@ -1309,7 +1301,7 @@ sys_readlink(p, v, retval)
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VLNK)
@@ -1335,6 +1327,7 @@ sys_readlink(p, v, retval)
* Change flags of a file given a path name.
*/
/* ARGSUSED */
+int
sys_chflags(p, v, retval)
struct proc *p;
void *v;
@@ -1350,7 +1343,7 @@ sys_chflags(p, v, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1370,6 +1363,7 @@ sys_chflags(p, v, retval)
* Change flags of a file given a file descriptor.
*/
/* ARGSUSED */
+int
sys_fchflags(p, v, retval)
struct proc *p;
void *v;
@@ -1384,7 +1378,7 @@ sys_fchflags(p, v, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1404,6 +1398,7 @@ sys_fchflags(p, v, retval)
* Change mode of a file given path name.
*/
/* ARGSUSED */
+int
sys_chmod(p, v, retval)
struct proc *p;
void *v;
@@ -1419,7 +1414,7 @@ sys_chmod(p, v, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1439,6 +1434,7 @@ sys_chmod(p, v, retval)
* Change mode of a file given a file descriptor.
*/
/* ARGSUSED */
+int
sys_fchmod(p, v, retval)
struct proc *p;
void *v;
@@ -1453,7 +1449,7 @@ sys_fchmod(p, v, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1473,6 +1469,7 @@ sys_fchmod(p, v, retval)
* Set ownership given a path name.
*/
/* ARGSUSED */
+int
sys_chown(p, v, retval)
struct proc *p;
void *v;
@@ -1489,7 +1486,7 @@ sys_chown(p, v, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1510,6 +1507,7 @@ sys_chown(p, v, retval)
* Set ownership given a file descriptor.
*/
/* ARGSUSED */
+int
sys_fchown(p, v, retval)
struct proc *p;
void *v;
@@ -1525,7 +1523,7 @@ sys_fchown(p, v, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1546,6 +1544,7 @@ sys_fchown(p, v, retval)
* Set the access and modification times of a file.
*/
/* ARGSUSED */
+int
sys_utimes(p, v, retval)
struct proc *p;
void *v;
@@ -1566,11 +1565,15 @@ sys_utimes(p, v, retval)
microtime(&tv[0]);
tv[1] = tv[0];
vattr.va_vaflags |= VA_UTIMES_NULL;
- } else if (error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv,
- sizeof (tv)))
- return (error);
+ }
+ else {
+ error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv,
+ sizeof (tv));
+ if (error)
+ return (error);
+ }
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1578,10 +1581,10 @@ sys_utimes(p, v, retval)
if (vp->v_mount->mnt_flag & MNT_RDONLY)
error = EROFS;
else {
- vattr.va_atime.ts_sec = tv[0].tv_sec;
- vattr.va_atime.ts_nsec = tv[0].tv_usec * 1000;
- vattr.va_mtime.ts_sec = tv[1].tv_sec;
- vattr.va_mtime.ts_nsec = tv[1].tv_usec * 1000;
+ vattr.va_atime.tv_sec = tv[0].tv_sec;
+ vattr.va_atime.tv_nsec = tv[0].tv_usec * 1000;
+ vattr.va_mtime.tv_sec = tv[1].tv_sec;
+ vattr.va_mtime.tv_nsec = tv[1].tv_usec * 1000;
error = VOP_SETATTR(vp, &vattr, p->p_ucred, p);
}
vput(vp);
@@ -1592,6 +1595,7 @@ sys_utimes(p, v, retval)
* Truncate a file given its path name.
*/
/* ARGSUSED */
+int
sys_truncate(p, v, retval)
struct proc *p;
void *v;
@@ -1608,7 +1612,7 @@ sys_truncate(p, v, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
VOP_LEASE(vp, p, p->p_ucred, LEASE_WRITE);
@@ -1629,6 +1633,7 @@ sys_truncate(p, v, retval)
* Truncate a file given a file descriptor.
*/
/* ARGSUSED */
+int
sys_ftruncate(p, v, retval)
struct proc *p;
void *v;
@@ -1644,7 +1649,7 @@ sys_ftruncate(p, v, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FWRITE) == 0)
return (EINVAL);
@@ -1666,6 +1671,7 @@ sys_ftruncate(p, v, retval)
* Sync an open file.
*/
/* ARGSUSED */
+int
sys_fsync(p, v, retval)
struct proc *p;
void *v;
@@ -1678,7 +1684,7 @@ sys_fsync(p, v, retval)
struct file *fp;
int error;
- if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
vp = (struct vnode *)fp->f_data;
VOP_LOCK(vp);
@@ -1692,6 +1698,7 @@ sys_fsync(p, v, retval)
* or both not be directories. If target is a directory, it must be empty.
*/
/* ARGSUSED */
+int
sys_rename(p, v, retval)
struct proc *p;
void *v;
@@ -1707,12 +1714,12 @@ sys_rename(p, v, retval)
NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
SCARG(uap, from), p);
- if (error = namei(&fromnd))
+ if ((error = namei(&fromnd)) != 0)
return (error);
fvp = fromnd.ni_vp;
NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
UIO_USERSPACE, SCARG(uap, to), p);
- if (error = namei(&tond)) {
+ if ((error = namei(&tond)) != 0) {
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
vrele(fromnd.ni_dvp);
vrele(fvp);
@@ -1777,6 +1784,7 @@ out1:
* Make a directory file.
*/
/* ARGSUSED */
+int
sys_mkdir(p, v, retval)
struct proc *p;
void *v;
@@ -1792,7 +1800,7 @@ sys_mkdir(p, v, retval)
struct nameidata nd;
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
if (vp != NULL) {
@@ -1818,6 +1826,7 @@ sys_mkdir(p, v, retval)
* Remove a directory file.
*/
/* ARGSUSED */
+int
sys_rmdir(p, v, retval)
struct proc *p;
void *v;
@@ -1832,7 +1841,7 @@ sys_rmdir(p, v, retval)
NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE,
SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
return (error);
vp = nd.ni_vp;
if (vp->v_type != VDIR) {
@@ -1870,6 +1879,7 @@ out:
/*
* Read a block of directory entries in a file system independent format.
*/
+int
sys_getdirentries(p, v, retval)
struct proc *p;
void *v;
@@ -1888,7 +1898,7 @@ sys_getdirentries(p, v, retval)
long loff;
int error, eofflag;
- if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
return (error);
if ((fp->f_flag & FREAD) == 0)
return (EBADF);
@@ -1914,7 +1924,7 @@ unionread:
#ifdef UNION
{
- extern int (**union_vnodeop_p)();
+ extern int (**union_vnodeop_p) __P((void *));
extern struct vnode *union_dircache __P((struct vnode *));
if ((SCARG(uap, count) == auio.uio_resid) &&
@@ -1998,6 +2008,7 @@ sys_umask(p, v, retval)
* away from vnode.
*/
/* ARGSUSED */
+int
sys_revoke(p, v, retval)
struct proc *p;
void *v;
@@ -2012,14 +2023,14 @@ sys_revoke(p, v, retval)
struct nameidata nd;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
- if (error = namei(&nd))
+ if ((error = namei(&nd)) != 0)
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))
+ if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0)
goto out;
if (p->p_ucred->cr_uid != vattr.va_uid &&
(error = suser(p->p_ucred, &p->p_acflag)))
diff --git a/sys/kern/vnode_if.src b/sys/kern/vnode_if.src
index 5bbac4d2413..8e0e7300f81 100644
--- a/sys/kern/vnode_if.src
+++ b/sys/kern/vnode_if.src
@@ -1,4 +1,4 @@
-# $NetBSD: vnode_if.src,v 1.8 1994/12/14 18:58:43 mycroft Exp $
+# $NetBSD: vnode_if.src,v 1.9 1996/02/09 14:45:38 mycroft Exp $
#
# Copyright (c) 1992, 1993
# The Regents of the University of California. All rights reserved.
@@ -149,8 +149,8 @@ vop_remove {
};
vop_link {
- IN WILLRELE struct vnode *vp;
- IN struct vnode *tdvp;
+ IN WILLRELE struct vnode *dvp;
+ IN struct vnode *vp;
IN struct componentname *cnp;
};