All of this is cosmetic. prototypes, #includes, printfs and so on. Makes
GCC a lot more silent.
This commit is contained in:
parent
abd358cd49
commit
797f2d22f0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3308
@ -37,7 +37,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_acct.c 8.1 (Berkeley) 6/14/93
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -105,7 +105,8 @@ acct(p, uap, retval)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
/* Make sure that the caller is root. */
|
/* 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);
|
return (error);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -114,7 +115,8 @@ acct(p, uap, retval)
|
|||||||
*/
|
*/
|
||||||
if (uap->path != NULL) {
|
if (uap->path != NULL) {
|
||||||
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, p);
|
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);
|
return (error);
|
||||||
VOP_UNLOCK(nd.ni_vp);
|
VOP_UNLOCK(nd.ni_vp);
|
||||||
if (nd.ni_vp->v_type != VREG) {
|
if (nd.ni_vp->v_type != VREG) {
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
|
* @(#)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: */
|
/* Portions of this software are covered by the following: */
|
||||||
@ -63,8 +63,10 @@
|
|||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
#include <sys/timex.h>
|
#include <sys/timex.h>
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
#include <machine/cpu.h>
|
#include <machine/cpu.h>
|
||||||
#include <machine/clock.h>
|
#include <machine/clock.h>
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -55,6 +55,7 @@
|
|||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
#include <sys/unistd.h>
|
#include <sys/unistd.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
|
#include <vm/vm.h>
|
||||||
|
|
||||||
int finishdup(struct filedesc *fdp, int old, int new, int *retval);
|
int finishdup(struct filedesc *fdp, int old, int new, int *retval);
|
||||||
/*
|
/*
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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>
|
#include <sys/param.h>
|
||||||
@ -37,6 +37,7 @@
|
|||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/acct.h>
|
#include <sys/acct.h>
|
||||||
#include <sys/exec.h>
|
#include <sys/exec.h>
|
||||||
@ -46,6 +47,7 @@
|
|||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
#include <vm/vm_kern.h>
|
#include <vm/vm_kern.h>
|
||||||
@ -289,7 +291,7 @@ execve(p, uap, retval)
|
|||||||
p->p_acflag &= ~AFORK;
|
p->p_acflag &= ~AFORK;
|
||||||
|
|
||||||
/* Set entry address */
|
/* Set entry address */
|
||||||
setregs(p, iparams->entry_addr, stack_base);
|
setregs(p, iparams->entry_addr, (u_long)stack_base);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* free various allocated resources
|
* free various allocated resources
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -56,7 +56,10 @@
|
|||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
|
#include <sys/shm.h>
|
||||||
|
#include <sys/filedesc.h>
|
||||||
|
|
||||||
#include <machine/cpu.h>
|
#include <machine/cpu.h>
|
||||||
#ifdef COMPAT_43
|
#ifdef COMPAT_43
|
||||||
@ -67,9 +70,6 @@
|
|||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
#include <vm/vm_kern.h>
|
#include <vm/vm_kern.h>
|
||||||
|
|
||||||
__dead void cpu_exit __P((struct proc *));
|
|
||||||
__dead void exit1 __P((struct proc *, int));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* exit --
|
* exit --
|
||||||
* Death of process.
|
* Death of process.
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_ktrace.c 8.2 (Berkeley) 9/23/93
|
* @(#)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
|
#ifdef KTRACE
|
||||||
@ -46,8 +46,6 @@
|
|||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
|
|
||||||
void ktrwrite __P((struct vnode *, struct ktr_header *));
|
|
||||||
|
|
||||||
struct ktr_header *
|
struct ktr_header *
|
||||||
ktrgetheader(type)
|
ktrgetheader(type)
|
||||||
int type;
|
int type;
|
||||||
@ -254,7 +252,8 @@ ktrace(curp, uap, retval)
|
|||||||
* an operation which requires a file argument.
|
* an operation which requires a file argument.
|
||||||
*/
|
*/
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->fname, curp);
|
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;
|
curp->p_traceflag &= ~KTRFAC_ACTIVE;
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,8 @@ lkmcopen(dev, flag, devtype, p)
|
|||||||
* Sleep pending unlock; we use tsleep() to allow
|
* Sleep pending unlock; we use tsleep() to allow
|
||||||
* an alarm out of the open.
|
* 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 */
|
return(error); /* leave LKM_WANT set -- no problem */
|
||||||
}
|
}
|
||||||
lkm_v |= LKM_ALLOC;
|
lkm_v |= LKM_ALLOC;
|
||||||
@ -181,7 +182,6 @@ lkmcioctl(dev, cmd, data, flag)
|
|||||||
struct lmc_loadbuf *loadbufp;
|
struct lmc_loadbuf *loadbufp;
|
||||||
struct lmc_unload *unloadp;
|
struct lmc_unload *unloadp;
|
||||||
struct lmc_stat *statp;
|
struct lmc_stat *statp;
|
||||||
int (*funcp)();
|
|
||||||
char istr[MAXLKMNAME];
|
char istr[MAXLKMNAME];
|
||||||
|
|
||||||
switch(cmd) {
|
switch(cmd) {
|
||||||
@ -240,7 +240,9 @@ lkmcioctl(dev, cmd, data, flag)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* copy in buffer full of data */
|
/* 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;
|
break;
|
||||||
|
|
||||||
if ((curp->offset + i) < curp->size) {
|
if ((curp->offset + i) < curp->size) {
|
||||||
@ -291,7 +293,8 @@ lkmcioctl(dev, cmd, data, flag)
|
|||||||
curp->entry = (int (*)()) (*((int *) (data)));
|
curp->entry = (int (*)()) (*((int *) (data)));
|
||||||
|
|
||||||
/* call entry(load)... (assigns "private" portion) */
|
/* 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
|
* Module may refuse loading or may have a
|
||||||
* version mismatch...
|
* version mismatch...
|
||||||
@ -320,7 +323,8 @@ lkmcioctl(dev, cmd, data, flag)
|
|||||||
* Copy name and lookup id from all loaded
|
* Copy name and lookup id from all loaded
|
||||||
* modules. May fail.
|
* modules. May fail.
|
||||||
*/
|
*/
|
||||||
if (err = copyinstr(unloadp->name, istr, MAXLKMNAME-1, NULL))
|
err =copyinstr(unloadp->name, istr, MAXLKMNAME-1, NULL);
|
||||||
|
if (err)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_malloc.c 8.3 (Berkeley) 1/4/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -196,7 +196,7 @@ malloc(size, type, flags)
|
|||||||
memname[freep->type] : "???";
|
memname[freep->type] : "???";
|
||||||
if (kbp->kb_next &&
|
if (kbp->kb_next &&
|
||||||
!kernacc(kbp->kb_next, sizeof(struct freelist), 0)) {
|
!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,
|
"Data modified on freelist: word 2.5", va, size,
|
||||||
"previous type", savedtype, kbp->kb_next);
|
"previous type", savedtype, kbp->kb_next);
|
||||||
kbp->kb_next = NULL;
|
kbp->kb_next = NULL;
|
||||||
@ -215,7 +215,7 @@ malloc(size, type, flags)
|
|||||||
for (lp = (long *)va; lp < end; lp++) {
|
for (lp = (long *)va; lp < end; lp++) {
|
||||||
if (*lp == WEIRD_ADDR)
|
if (*lp == WEIRD_ADDR)
|
||||||
continue;
|
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,
|
"Data modified on freelist: word", lp - (long *)va,
|
||||||
va, size, "previous type", savedtype, *lp, WEIRD_ADDR);
|
va, size, "previous type", savedtype, *lp, WEIRD_ADDR);
|
||||||
break;
|
break;
|
||||||
@ -308,7 +308,7 @@ free(addr, type)
|
|||||||
for (cp = kbp->kb_next; cp; cp = *(caddr_t *)cp) {
|
for (cp = kbp->kb_next; cp; cp = *(caddr_t *)cp) {
|
||||||
if (addr != cp)
|
if (addr != cp)
|
||||||
continue;
|
continue;
|
||||||
printf("multiply freed item 0x%x\n", addr);
|
printf("multiply freed item %p\n", addr);
|
||||||
panic("free: duplicated free");
|
panic("free: duplicated free");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_synch.c 8.6 (Berkeley) 1/21/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -46,7 +46,8 @@
|
|||||||
#include <sys/buf.h>
|
#include <sys/buf.h>
|
||||||
#include <sys/signalvar.h>
|
#include <sys/signalvar.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
#include <sys/vmmeter.h>
|
#include <sys/signalvar.h>
|
||||||
|
#include <vm/vm.h>
|
||||||
#ifdef KTRACE
|
#ifdef KTRACE
|
||||||
#include <sys/ktrace.h>
|
#include <sys/ktrace.h>
|
||||||
#endif
|
#endif
|
||||||
@ -420,7 +421,7 @@ sleep(ident, priority)
|
|||||||
|
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
if (priority > PZERO) {
|
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);
|
priority, ident);
|
||||||
panic("old sleep");
|
panic("old sleep");
|
||||||
}
|
}
|
||||||
@ -504,9 +505,10 @@ wakeup(ident)
|
|||||||
s = splhigh();
|
s = splhigh();
|
||||||
qp = &slpque[LOOKUP(ident)];
|
qp = &slpque[LOOKUP(ident)];
|
||||||
restart:
|
restart:
|
||||||
for (q = &qp->sq_head; p = *q; ) {
|
for (q = &qp->sq_head; *q; ) {
|
||||||
|
p = *q;
|
||||||
#ifdef DIAGNOSTIC
|
#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");
|
panic("wakeup");
|
||||||
#endif
|
#endif
|
||||||
if (p->p_wchan == ident) {
|
if (p->p_wchan == ident) {
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94
|
* @(#)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)
|
if (uap->namelen > CTL_MAXNAME || uap->namelen < 2)
|
||||||
return (EINVAL);
|
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);
|
return (error);
|
||||||
|
|
||||||
switch (name[0]) {
|
switch (name[0]) {
|
||||||
@ -571,7 +572,8 @@ sysctl_file(where, sizep)
|
|||||||
*sizep = 0;
|
*sizep = 0;
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (error = copyout((caddr_t)&filehead, where, sizeof(filehead)))
|
error = copyout((caddr_t)&filehead, where, sizeof(filehead));
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
buflen -= sizeof(filehead);
|
buflen -= sizeof(filehead);
|
||||||
where += sizeof(filehead);
|
where += sizeof(filehead);
|
||||||
@ -584,7 +586,8 @@ sysctl_file(where, sizep)
|
|||||||
*sizep = where - start;
|
*sizep = where - start;
|
||||||
return (ENOMEM);
|
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);
|
return (error);
|
||||||
buflen -= sizeof(struct file);
|
buflen -= sizeof(struct file);
|
||||||
where += sizeof(struct file);
|
where += sizeof(struct file);
|
||||||
@ -661,11 +664,13 @@ sysctl_doproc(name, namelen, where, sizep)
|
|||||||
}
|
}
|
||||||
if (buflen >= sizeof(struct kinfo_proc)) {
|
if (buflen >= sizeof(struct kinfo_proc)) {
|
||||||
fill_eproc(p, &eproc);
|
fill_eproc(p, &eproc);
|
||||||
if (error = copyout((caddr_t)p, &dp->kp_proc,
|
error = copyout((caddr_t)p, &dp->kp_proc,
|
||||||
sizeof(struct proc)))
|
sizeof(struct proc));
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
if (error = copyout((caddr_t)&eproc, &dp->kp_eproc,
|
error = copyout((caddr_t)&eproc, &dp->kp_eproc,
|
||||||
sizeof(eproc)))
|
sizeof(eproc));
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
dp++;
|
dp++;
|
||||||
buflen -= sizeof(struct kinfo_proc);
|
buflen -= sizeof(struct kinfo_proc);
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
|
* @(#)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: */
|
/* Portions of this software are covered by the following: */
|
||||||
@ -63,8 +63,10 @@
|
|||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
#include <sys/timex.h>
|
#include <sys/timex.h>
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
#include <machine/cpu.h>
|
#include <machine/cpu.h>
|
||||||
#include <machine/clock.h>
|
#include <machine/clock.h>
|
||||||
|
@ -31,11 +31,12 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_time.c 8.1 (Berkeley) 6/10/93
|
* @(#)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/param.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
@ -43,10 +44,6 @@
|
|||||||
|
|
||||||
#include <machine/cpu.h>
|
#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.
|
* Time of day and interval timer support.
|
||||||
*
|
*
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_clock.c 8.5 (Berkeley) 1/21/94
|
* @(#)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: */
|
/* Portions of this software are covered by the following: */
|
||||||
@ -63,8 +63,10 @@
|
|||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
#include <sys/timex.h>
|
#include <sys/timex.h>
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
#include <machine/cpu.h>
|
#include <machine/cpu.h>
|
||||||
#include <machine/clock.h>
|
#include <machine/clock.h>
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)kern_xxx.c 8.2 (Berkeley) 11/14/93
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -42,6 +42,7 @@
|
|||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
|
|
||||||
struct reboot_args {
|
struct reboot_args {
|
||||||
int opt;
|
int opt;
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)subr_log.c 8.1 (Berkeley) 6/10/93
|
* @(#)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/ioctl.h>
|
||||||
#include <sys/msgbuf.h>
|
#include <sys/msgbuf.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
|
|
||||||
#define LOG_RDPRI (PZERO + 1)
|
#define LOG_RDPRI (PZERO + 1)
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -270,12 +270,11 @@ void
|
|||||||
logpri(level)
|
logpri(level)
|
||||||
int level;
|
int level;
|
||||||
{
|
{
|
||||||
register int ch;
|
|
||||||
register char *p;
|
register char *p;
|
||||||
|
|
||||||
putchar('<', TOLOG, NULL);
|
putchar('<', TOLOG, NULL);
|
||||||
for (p = ksprintn((u_long)level, 10, NULL); ch = *p--;)
|
for (p = ksprintn((u_long)level, 10, NULL); *p;)
|
||||||
putchar(ch, TOLOG, NULL);
|
putchar(*p--, TOLOG, NULL);
|
||||||
putchar('>', TOLOG, NULL);
|
putchar('>', TOLOG, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,13 +400,14 @@ reswitch: switch (ch = *(u_char *)fmt++) {
|
|||||||
case 'b':
|
case 'b':
|
||||||
ul = va_arg(ap, int);
|
ul = va_arg(ap, int);
|
||||||
p = va_arg(ap, char *);
|
p = va_arg(ap, char *);
|
||||||
for (q = ksprintn(ul, *p++, NULL); ch = *q--;)
|
for (q = ksprintn(ul, *p++, NULL); *q;)
|
||||||
putchar(ch, flags, tp);
|
putchar(*q--, flags, tp);
|
||||||
|
|
||||||
if (!ul)
|
if (!ul)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
for (tmp = 0; n = *p++;) {
|
for (tmp = 0; *p;) {
|
||||||
|
n = *p++;
|
||||||
if (ul & (1 << (n - 1))) {
|
if (ul & (1 << (n - 1))) {
|
||||||
putchar(tmp ? ',' : '<', flags, tp);
|
putchar(tmp ? ',' : '<', flags, tp);
|
||||||
for (; (n = *p) > ' '; ++p)
|
for (; (n = *p) > ' '; ++p)
|
||||||
@ -429,8 +429,8 @@ reswitch: switch (ch = *(u_char *)fmt++) {
|
|||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
p = va_arg(ap, char *);
|
p = va_arg(ap, char *);
|
||||||
while (ch = *p++)
|
while (*p)
|
||||||
putchar(ch, flags, tp);
|
putchar(*p++, flags, tp);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
ul = lflag ? va_arg(ap, long) : va_arg(ap, int);
|
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)
|
if (width && (width -= tmp) > 0)
|
||||||
while (width--)
|
while (width--)
|
||||||
putchar(padc, flags, tp);
|
putchar(padc, flags, tp);
|
||||||
while (ch = *p--)
|
while (*p)
|
||||||
putchar(ch, flags, tp);
|
putchar(*p--, flags, tp);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
putchar('%', flags, tp);
|
putchar('%', flags, tp);
|
||||||
@ -549,9 +549,8 @@ reswitch: switch (ch = *(u_char *)fmt++) {
|
|||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
p = va_arg(ap, char *);
|
p = va_arg(ap, char *);
|
||||||
while (*bp++ = *p++)
|
while (*p)
|
||||||
continue;
|
*bp++ = *p++;
|
||||||
--bp;
|
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
ul = lflag ? va_arg(ap, long) : va_arg(ap, int);
|
ul = lflag ? va_arg(ap, long) : va_arg(ap, int);
|
||||||
@ -575,8 +574,8 @@ reswitch: switch (ch = *(u_char *)fmt++) {
|
|||||||
case 'x':
|
case 'x':
|
||||||
ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int);
|
ul = lflag ? va_arg(ap, u_long) : va_arg(ap, u_int);
|
||||||
base = 16;
|
base = 16;
|
||||||
number: for (p = ksprintn(ul, base, NULL); ch = *p--;)
|
number: for (p = ksprintn(ul, base, NULL); *p;)
|
||||||
*bp++ = ch;
|
*bp++ = *p--;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
*bp++ = '%';
|
*bp++ = '%';
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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>
|
#include <sys/param.h>
|
||||||
@ -53,6 +53,7 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/rlist.h>
|
#include <sys/rlist.h>
|
||||||
|
#include <sys/proc.h>
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
#include <vm/vm_map.h>
|
#include <vm/vm_map.h>
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)sys_generic.c 8.5 (Berkeley) 1/21/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -45,6 +45,9 @@
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
#include <sys/socketvar.h>
|
#include <sys/socketvar.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)sys_socket.c 8.1 (Berkeley) 6/10/93
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -41,6 +41,7 @@
|
|||||||
#include <sys/mbuf.h>
|
#include <sys/mbuf.h>
|
||||||
#include <sys/protosw.h>
|
#include <sys/protosw.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/socketvar.h>
|
#include <sys/socketvar.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
@ -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
|
* Implementation of SVID messages
|
||||||
@ -41,7 +41,6 @@ void
|
|||||||
msginit()
|
msginit()
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
vm_offset_t whocares1, whocares2;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* msginfo.msgssz should be a power of two for efficiency reasons.
|
* msginfo.msgssz should be a power of two for efficiency reasons.
|
||||||
@ -154,7 +153,7 @@ msgctl(p, uap, retval)
|
|||||||
int cmd = uap->cmd;
|
int cmd = uap->cmd;
|
||||||
struct msqid_ds *user_msqptr = uap->user_msqptr;
|
struct msqid_ds *user_msqptr = uap->user_msqptr;
|
||||||
struct ucred *cred = p->p_ucred;
|
struct ucred *cred = p->p_ucred;
|
||||||
int i, rval, eval;
|
int rval, eval;
|
||||||
struct msqid_ds msqbuf;
|
struct msqid_ds msqbuf;
|
||||||
register struct msqid_ds *msqptr;
|
register struct msqid_ds *msqptr;
|
||||||
|
|
||||||
|
@ -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
|
* Implementation of SVID semaphores
|
||||||
@ -25,7 +25,6 @@ void
|
|||||||
seminit()
|
seminit()
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
vm_offset_t whocares1, whocares2;
|
|
||||||
|
|
||||||
if (sema == NULL)
|
if (sema == NULL)
|
||||||
panic("sema is NULL");
|
panic("sema is NULL");
|
||||||
@ -582,7 +581,7 @@ semop(p, uap, retval)
|
|||||||
struct sem_undo *suptr = NULL;
|
struct sem_undo *suptr = NULL;
|
||||||
struct ucred *cred = p->p_ucred;
|
struct ucred *cred = p->p_ucred;
|
||||||
int i, j, eval;
|
int i, j, eval;
|
||||||
int all_ok, do_wakeup, do_undos;
|
int do_wakeup, do_undos;
|
||||||
|
|
||||||
#ifdef SEM_DEBUG
|
#ifdef SEM_DEBUG
|
||||||
printf("call to semop(%d, 0x%x, %d)\n", semid, sops, nsops);
|
printf("call to semop(%d, 0x%x, %d)\n", semid, sops, nsops);
|
||||||
|
@ -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 $ */
|
/* $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);
|
shmseg = shm_find_segment_by_shmid(uap->shmid);
|
||||||
if (shmseg == NULL)
|
if (shmseg == NULL)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
if (error = ipcperm(cred, &shmseg->shm_perm,
|
error = ipcperm(cred, &shmseg->shm_perm,
|
||||||
(uap->shmflg & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W))
|
(uap->shmflg & SHM_RDONLY) ? IPC_R : IPC_R|IPC_W);
|
||||||
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
for (i = 0; i < shminfo.shmseg; i++) {
|
for (i = 0; i < shminfo.shmseg; i++) {
|
||||||
if (shmmap_s->shmid == -1)
|
if (shmmap_s->shmid == -1)
|
||||||
@ -277,7 +278,7 @@ oshmctl(p, uap, retval)
|
|||||||
int *retval;
|
int *retval;
|
||||||
{
|
{
|
||||||
#ifdef COMPAT_43
|
#ifdef COMPAT_43
|
||||||
int error, segnum;
|
int error;
|
||||||
struct ucred *cred = p->p_ucred;
|
struct ucred *cred = p->p_ucred;
|
||||||
struct shmid_ds *shmseg;
|
struct shmid_ds *shmseg;
|
||||||
struct oshmid_ds outbuf;
|
struct oshmid_ds outbuf;
|
||||||
@ -287,7 +288,8 @@ oshmctl(p, uap, retval)
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
switch (uap->cmd) {
|
switch (uap->cmd) {
|
||||||
case IPC_STAT:
|
case IPC_STAT:
|
||||||
if (error = ipcperm(cred, &shmseg->shm_perm, IPC_R))
|
error = ipcperm(cred, &shmseg->shm_perm, IPC_R);
|
||||||
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
outbuf.shm_perm = shmseg->shm_perm;
|
outbuf.shm_perm = shmseg->shm_perm;
|
||||||
outbuf.shm_segsz = shmseg->shm_segsz;
|
outbuf.shm_segsz = shmseg->shm_segsz;
|
||||||
@ -298,7 +300,8 @@ oshmctl(p, uap, retval)
|
|||||||
outbuf.shm_dtime = shmseg->shm_dtime;
|
outbuf.shm_dtime = shmseg->shm_dtime;
|
||||||
outbuf.shm_ctime = shmseg->shm_ctime;
|
outbuf.shm_ctime = shmseg->shm_ctime;
|
||||||
outbuf.shm_handle = shmseg->shm_internal;
|
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;
|
return error;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -321,7 +324,7 @@ shmctl(p, uap, retval)
|
|||||||
struct shmctl_args *uap;
|
struct shmctl_args *uap;
|
||||||
int *retval;
|
int *retval;
|
||||||
{
|
{
|
||||||
int error, segnum;
|
int error;
|
||||||
struct ucred *cred = p->p_ucred;
|
struct ucred *cred = p->p_ucred;
|
||||||
struct shmid_ds inbuf;
|
struct shmid_ds inbuf;
|
||||||
struct shmid_ds *shmseg;
|
struct shmid_ds *shmseg;
|
||||||
@ -331,15 +334,19 @@ shmctl(p, uap, retval)
|
|||||||
return EINVAL;
|
return EINVAL;
|
||||||
switch (uap->cmd) {
|
switch (uap->cmd) {
|
||||||
case IPC_STAT:
|
case IPC_STAT:
|
||||||
if (error = ipcperm(cred, &shmseg->shm_perm, IPC_R))
|
error = ipcperm(cred, &shmseg->shm_perm, IPC_R);
|
||||||
|
if (error)
|
||||||
return 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;
|
return error;
|
||||||
break;
|
break;
|
||||||
case IPC_SET:
|
case IPC_SET:
|
||||||
if (error = ipcperm(cred, &shmseg->shm_perm, IPC_M))
|
error = ipcperm(cred, &shmseg->shm_perm, IPC_M);
|
||||||
|
if (error)
|
||||||
return 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;
|
return error;
|
||||||
shmseg->shm_perm.uid = inbuf.shm_perm.uid;
|
shmseg->shm_perm.uid = inbuf.shm_perm.uid;
|
||||||
shmseg->shm_perm.gid = inbuf.shm_perm.gid;
|
shmseg->shm_perm.gid = inbuf.shm_perm.gid;
|
||||||
@ -349,7 +356,8 @@ shmctl(p, uap, retval)
|
|||||||
shmseg->shm_ctime = time.tv_sec;
|
shmseg->shm_ctime = time.tv_sec;
|
||||||
break;
|
break;
|
||||||
case IPC_RMID:
|
case IPC_RMID:
|
||||||
if (error = ipcperm(cred, &shmseg->shm_perm, IPC_M))
|
error = ipcperm(cred, &shmseg->shm_perm, IPC_M);
|
||||||
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
shmseg->shm_perm.key = IPC_PRIVATE;
|
shmseg->shm_perm.key = IPC_PRIVATE;
|
||||||
shmseg->shm_perm.mode |= SHMSEG_REMOVED;
|
shmseg->shm_perm.mode |= SHMSEG_REMOVED;
|
||||||
@ -393,12 +401,13 @@ shmget_existing(p, uap, mode, segnum, retval)
|
|||||||
* allocation failed or it was freed).
|
* allocation failed or it was freed).
|
||||||
*/
|
*/
|
||||||
shmseg->shm_perm.mode |= SHMSEG_WANTED;
|
shmseg->shm_perm.mode |= SHMSEG_WANTED;
|
||||||
if (error =
|
error = tsleep((caddr_t)shmseg, PLOCK | PCATCH, "shmget", 0);
|
||||||
tsleep((caddr_t)shmseg, PLOCK | PCATCH, "shmget", 0))
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
return EAGAIN;
|
return EAGAIN;
|
||||||
}
|
}
|
||||||
if (error = ipcperm(cred, &shmseg->shm_perm, mode))
|
error = ipcperm(cred, &shmseg->shm_perm, mode);
|
||||||
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
if (uap->size && uap->size > shmseg->shm_segsz)
|
if (uap->size && uap->size > shmseg->shm_segsz)
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
@ -490,7 +499,6 @@ shmget(p, uap, retval)
|
|||||||
int *retval;
|
int *retval;
|
||||||
{
|
{
|
||||||
int segnum, mode, error;
|
int segnum, mode, error;
|
||||||
struct shmid_ds *shmseg;
|
|
||||||
|
|
||||||
mode = uap->shmflg & ACCESSPERMS;
|
mode = uap->shmflg & ACCESSPERMS;
|
||||||
if (uap->key != IPC_PRIVATE) {
|
if (uap->key != IPC_PRIVATE) {
|
||||||
@ -546,7 +554,6 @@ shmexit(p)
|
|||||||
struct proc *p;
|
struct proc *p;
|
||||||
{
|
{
|
||||||
struct shmmap_state *shmmap_s;
|
struct shmmap_state *shmmap_s;
|
||||||
struct shmid_ds *shmseg;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;
|
shmmap_s = (struct shmmap_state *)p->p_vmspace->vm_shm;
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)tty.c 8.8 (Berkeley) 1/21/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -53,6 +53,8 @@
|
|||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/vnode.h>
|
#include <sys/vnode.h>
|
||||||
#include <sys/syslog.h>
|
#include <sys/syslog.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
|
#include <sys/resourcevar.h>
|
||||||
|
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
|
|
||||||
@ -214,8 +216,8 @@ ttyclose(tp)
|
|||||||
|
|
||||||
/* Is 'c' a line delimiter ("break" character)? */
|
/* Is 'c' a line delimiter ("break" character)? */
|
||||||
#define TTBREAKC(c) \
|
#define TTBREAKC(c) \
|
||||||
((c) == '\n' || ((c) == cc[VEOF] || \
|
((c) == '\n' || (((c) == cc[VEOF] || \
|
||||||
(c) == cc[VEOL] || (c) == cc[VEOL2]) && (c) != _POSIX_VDISABLE)
|
(c) == cc[VEOL] || (c) == cc[VEOL2]) && (c) != _POSIX_VDISABLE))
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -251,7 +253,8 @@ ttyinput(c, tp)
|
|||||||
/* Handle exceptional conditions (break, parity, framing). */
|
/* Handle exceptional conditions (break, parity, framing). */
|
||||||
cc = tp->t_cc;
|
cc = tp->t_cc;
|
||||||
iflag = tp->t_iflag;
|
iflag = tp->t_iflag;
|
||||||
if (err = (ISSET(c, TTY_ERRORMASK))) {
|
err = (ISSET(c, TTY_ERRORMASK));
|
||||||
|
if (err) {
|
||||||
CLR(c, TTY_ERRORMASK);
|
CLR(c, TTY_ERRORMASK);
|
||||||
if (ISSET(err, TTY_FE) && !c) { /* Break. */
|
if (ISSET(err, TTY_FE) && !c) { /* Break. */
|
||||||
if (ISSET(iflag, IGNBRK))
|
if (ISSET(iflag, IGNBRK))
|
||||||
@ -262,8 +265,8 @@ ttyinput(c, tp)
|
|||||||
c = cc[VINTR];
|
c = cc[VINTR];
|
||||||
else if (ISSET(iflag, PARMRK))
|
else if (ISSET(iflag, PARMRK))
|
||||||
goto parmrk;
|
goto parmrk;
|
||||||
} else if (ISSET(err, TTY_PE) &&
|
} else if ((ISSET(err, TTY_PE) && ISSET(iflag, INPCK))
|
||||||
ISSET(iflag, INPCK) || ISSET(err, TTY_FE)) {
|
|| ISSET(err, TTY_FE)) {
|
||||||
if (ISSET(iflag, IGNPAR))
|
if (ISSET(iflag, IGNPAR))
|
||||||
goto endcase;
|
goto endcase;
|
||||||
else if (ISSET(iflag, PARMRK)) {
|
else if (ISSET(iflag, PARMRK)) {
|
||||||
@ -667,8 +670,8 @@ ttioctl(tp, cmd, data, flag)
|
|||||||
(p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
|
(p->p_sigignore & sigmask(SIGTTOU)) == 0 &&
|
||||||
(p->p_sigmask & sigmask(SIGTTOU)) == 0) {
|
(p->p_sigmask & sigmask(SIGTTOU)) == 0) {
|
||||||
pgsignal(p->p_pgrp, SIGTTOU, 1);
|
pgsignal(p->p_pgrp, SIGTTOU, 1);
|
||||||
if (error = ttysleep(tp,
|
error = ttysleep(tp, &lbolt, TTOPRI | PCATCH, ttybg, 0);
|
||||||
&lbolt, TTOPRI | PCATCH, ttybg, 0))
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -718,7 +721,8 @@ ttioctl(tp, cmd, data, flag)
|
|||||||
constty = NULL;
|
constty = NULL;
|
||||||
break;
|
break;
|
||||||
case TIOCDRAIN: /* wait till output drained */
|
case TIOCDRAIN: /* wait till output drained */
|
||||||
if (error = ttywait(tp))
|
error = ttywait(tp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
break;
|
break;
|
||||||
case TIOCGETA: { /* get termios struct */
|
case TIOCGETA: { /* get termios struct */
|
||||||
@ -760,7 +764,8 @@ ttioctl(tp, cmd, data, flag)
|
|||||||
|
|
||||||
s = spltty();
|
s = spltty();
|
||||||
if (cmd == TIOCSETAW || cmd == TIOCSETAF) {
|
if (cmd == TIOCSETAW || cmd == TIOCSETAF) {
|
||||||
if (error = ttywait(tp)) {
|
error = ttywait(tp);
|
||||||
|
if (error) {
|
||||||
splx(s);
|
splx(s);
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
@ -870,8 +875,8 @@ ttioctl(tp, cmd, data, flag)
|
|||||||
case TIOCSCTTY: /* become controlling tty */
|
case TIOCSCTTY: /* become controlling tty */
|
||||||
/* Session ctty vnode pointer set in vnode layer. */
|
/* Session ctty vnode pointer set in vnode layer. */
|
||||||
if (!SESS_LEADER(p) ||
|
if (!SESS_LEADER(p) ||
|
||||||
(p->p_session->s_ttyvp || tp->t_session) &&
|
((p->p_session->s_ttyvp || tp->t_session) &&
|
||||||
(tp->t_session != p->p_session))
|
(tp->t_session != p->p_session)))
|
||||||
return (EPERM);
|
return (EPERM);
|
||||||
tp->t_session = p->p_session;
|
tp->t_session = p->p_session;
|
||||||
tp->t_pgrp = p->p_pgrp;
|
tp->t_pgrp = p->p_pgrp;
|
||||||
@ -923,8 +928,8 @@ ttselect(device, rw, p)
|
|||||||
switch (rw) {
|
switch (rw) {
|
||||||
case FREAD:
|
case FREAD:
|
||||||
nread = ttnread(tp);
|
nread = ttnread(tp);
|
||||||
if (nread > 0 || !ISSET(tp->t_cflag, CLOCAL) &&
|
if (nread > 0 || (!ISSET(tp->t_cflag, CLOCAL) &&
|
||||||
!ISSET(tp->t_state, TS_CARR_ON))
|
!ISSET(tp->t_state, TS_CARR_ON)))
|
||||||
goto win;
|
goto win;
|
||||||
selrecord(p, &tp->t_rsel);
|
selrecord(p, &tp->t_rsel);
|
||||||
break;
|
break;
|
||||||
@ -970,8 +975,8 @@ ttywait(tp)
|
|||||||
&& tp->t_oproc) {
|
&& tp->t_oproc) {
|
||||||
(*tp->t_oproc)(tp);
|
(*tp->t_oproc)(tp);
|
||||||
SET(tp->t_state, TS_ASLEEP);
|
SET(tp->t_state, TS_ASLEEP);
|
||||||
if (error = ttysleep(tp,
|
error = ttysleep(tp, &tp->t_outq, TTOPRI | PCATCH, ttyout, 0);
|
||||||
&tp->t_outq, TTOPRI | PCATCH, ttyout, 0))
|
if (error)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
splx(s);
|
splx(s);
|
||||||
@ -1054,10 +1059,10 @@ ttyblock(tp)
|
|||||||
* Block further input iff: current input > threshold
|
* Block further input iff: current input > threshold
|
||||||
* AND input is available to user program.
|
* AND input is available to user program.
|
||||||
*/
|
*/
|
||||||
if (total >= TTYHOG / 2 &&
|
if ((total >= TTYHOG / 2 &&
|
||||||
!ISSET(tp->t_state, TS_TBLOCK) &&
|
!ISSET(tp->t_state, TS_TBLOCK) &&
|
||||||
!ISSET(tp->t_lflag, ICANON) || tp->t_canq.c_cc > 0 &&
|
!ISSET(tp->t_lflag, ICANON)) || (tp->t_canq.c_cc > 0 &&
|
||||||
tp->t_cc[VSTOP] != _POSIX_VDISABLE) {
|
tp->t_cc[VSTOP] != _POSIX_VDISABLE)) {
|
||||||
if (putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
|
if (putc(tp->t_cc[VSTOP], &tp->t_outq) == 0) {
|
||||||
SET(tp->t_state, TS_TBLOCK);
|
SET(tp->t_state, TS_TBLOCK);
|
||||||
ttstart(tp);
|
ttstart(tp);
|
||||||
@ -1237,7 +1242,8 @@ loop: lflag = tp->t_lflag;
|
|||||||
p->p_flag & P_PPWAIT || p->p_pgrp->pg_jobc == 0)
|
p->p_flag & P_PPWAIT || p->p_pgrp->pg_jobc == 0)
|
||||||
return (EIO);
|
return (EIO);
|
||||||
pgsignal(p->p_pgrp, SIGTTIN, 1);
|
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);
|
return (error);
|
||||||
goto loop;
|
goto loop;
|
||||||
}
|
}
|
||||||
@ -1289,8 +1295,9 @@ loop: lflag = tp->t_lflag;
|
|||||||
if (CCEQ(cc[VDSUSP], c) && ISSET(lflag, ISIG)) {
|
if (CCEQ(cc[VDSUSP], c) && ISSET(lflag, ISIG)) {
|
||||||
pgsignal(tp->t_pgrp, SIGTSTP, 1);
|
pgsignal(tp->t_pgrp, SIGTSTP, 1);
|
||||||
if (first) {
|
if (first) {
|
||||||
if (error = ttysleep(tp,
|
error = ttysleep(tp,
|
||||||
&lbolt, TTIPRI | PCATCH, ttybg, 0))
|
&lbolt, TTIPRI | PCATCH, ttybg, 0);
|
||||||
|
if (error)
|
||||||
break;
|
break;
|
||||||
goto loop;
|
goto loop;
|
||||||
}
|
}
|
||||||
@ -1417,7 +1424,8 @@ ttwrite(tp, uio, flag)
|
|||||||
(p->p_sigmask & sigmask(SIGTTOU)) == 0 &&
|
(p->p_sigmask & sigmask(SIGTTOU)) == 0 &&
|
||||||
p->p_pgrp->pg_jobc) {
|
p->p_pgrp->pg_jobc) {
|
||||||
pgsignal(p->p_pgrp, SIGTTOU, 1);
|
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 out;
|
||||||
goto loop;
|
goto loop;
|
||||||
}
|
}
|
||||||
@ -1470,8 +1478,9 @@ ttwrite(tp, uio, flag)
|
|||||||
if (ttyoutput(*cp, tp) >= 0) {
|
if (ttyoutput(*cp, tp) >= 0) {
|
||||||
/* No Clists, wait a bit. */
|
/* No Clists, wait a bit. */
|
||||||
ttstart(tp);
|
ttstart(tp);
|
||||||
if (error = ttysleep(tp, &lbolt,
|
error = ttysleep(tp, &lbolt,
|
||||||
TTOPRI | PCATCH, ttybuf, 0))
|
TTOPRI | PCATCH, ttybuf, 0);
|
||||||
|
if (error)
|
||||||
break;
|
break;
|
||||||
goto loop;
|
goto loop;
|
||||||
}
|
}
|
||||||
@ -1500,8 +1509,9 @@ ttwrite(tp, uio, flag)
|
|||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
/* No Clists, wait a bit. */
|
/* No Clists, wait a bit. */
|
||||||
ttstart(tp);
|
ttstart(tp);
|
||||||
if (error = ttysleep(tp,
|
error = ttysleep(tp,
|
||||||
&lbolt, TTOPRI | PCATCH, ttybuf, 0))
|
&lbolt, TTOPRI | PCATCH, ttybuf, 0);
|
||||||
|
if (error)
|
||||||
break;
|
break;
|
||||||
goto loop;
|
goto loop;
|
||||||
}
|
}
|
||||||
@ -1701,7 +1711,7 @@ ttyecho(c, tp)
|
|||||||
ISSET(tp->t_lflag, EXTPROC))
|
ISSET(tp->t_lflag, EXTPROC))
|
||||||
return;
|
return;
|
||||||
if (ISSET(tp->t_lflag, ECHOCTL) &&
|
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)) {
|
ISSET(c, TTY_CHARMASK) == 0177)) {
|
||||||
(void)ttyoutput('^', tp);
|
(void)ttyoutput('^', tp);
|
||||||
CLR(c, ~TTY_CHARMASK);
|
CLR(c, ~TTY_CHARMASK);
|
||||||
@ -1812,7 +1822,7 @@ ttyinfo(tp)
|
|||||||
|
|
||||||
#define pgtok(a) (((a) * NBPG) / 1024)
|
#define pgtok(a) (((a) * NBPG) / 1024)
|
||||||
/* Print percentage cpu, resident set size. */
|
/* 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",
|
ttyprintf(tp, "%d%% %dk\n",
|
||||||
tmp / 100,
|
tmp / 100,
|
||||||
pick->p_stat == SIDL || pick->p_stat == SZOMB ? 0 :
|
pick->p_stat == SIDL || pick->p_stat == SZOMB ? 0 :
|
||||||
@ -1939,7 +1949,8 @@ ttysleep(tp, chan, pri, wmesg, timo)
|
|||||||
short gen;
|
short gen;
|
||||||
|
|
||||||
gen = tp->t_gen;
|
gen = tp->t_gen;
|
||||||
if (error = tsleep(chan, pri, wmesg, timo))
|
error = tsleep(chan, pri, wmesg, timo);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
return (tp->t_gen == gen ? 0 : ERESTART);
|
return (tp->t_gen == gen ? 0 : ERESTART);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)tty_pty.c 8.2 (Berkeley) 9/23/93
|
* @(#)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/uio.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/vnode.h>
|
#include <sys/vnode.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
|
|
||||||
#if NPTY == 1
|
#if NPTY == 1
|
||||||
#undef NPTY
|
#undef NPTY
|
||||||
@ -137,8 +138,9 @@ ptsopen(dev, flag, devtype, p)
|
|||||||
tp->t_state |= TS_WOPEN;
|
tp->t_state |= TS_WOPEN;
|
||||||
if (flag&FNONBLOCK)
|
if (flag&FNONBLOCK)
|
||||||
break;
|
break;
|
||||||
if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
|
error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
|
||||||
ttopen, 0))
|
ttopen, 0);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
error = (*linesw[tp->t_line].l_open)(dev, tp);
|
error = (*linesw[tp->t_line].l_open)(dev, tp);
|
||||||
@ -182,15 +184,17 @@ ptsread(dev, uio, flag)
|
|||||||
p->p_flag & P_PPWAIT)
|
p->p_flag & P_PPWAIT)
|
||||||
return (EIO);
|
return (EIO);
|
||||||
pgsignal(p->p_pgrp, SIGTTIN, 1);
|
pgsignal(p->p_pgrp, SIGTTIN, 1);
|
||||||
if (error = ttysleep(tp, (caddr_t)&lbolt,
|
error = ttysleep(tp, (caddr_t)&lbolt,
|
||||||
TTIPRI | PCATCH, ttybg, 0))
|
TTIPRI | PCATCH, ttybg, 0);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
if (tp->t_canq.c_cc == 0) {
|
if (tp->t_canq.c_cc == 0) {
|
||||||
if (flag & IO_NDELAY)
|
if (flag & IO_NDELAY)
|
||||||
return (EWOULDBLOCK);
|
return (EWOULDBLOCK);
|
||||||
if (error = ttysleep(tp, (caddr_t)&tp->t_canq,
|
error = ttysleep(tp, (caddr_t)&tp->t_canq,
|
||||||
TTIPRI | PCATCH, ttyin, 0))
|
TTIPRI | PCATCH, ttyin, 0);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
@ -358,8 +362,9 @@ ptcread(dev, uio, flag)
|
|||||||
return (0); /* EOF */
|
return (0); /* EOF */
|
||||||
if (flag & IO_NDELAY)
|
if (flag & IO_NDELAY)
|
||||||
return (EWOULDBLOCK);
|
return (EWOULDBLOCK);
|
||||||
if (error = tsleep((caddr_t)&tp->t_outq.c_cf, TTIPRI | PCATCH,
|
error = tsleep((caddr_t)&tp->t_outq.c_cf, TTIPRI | PCATCH,
|
||||||
ttyin, 0))
|
ttyin, 0);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
if (pti->pt_flags & (PF_PKT|PF_UCNTL))
|
if (pti->pt_flags & (PF_PKT|PF_UCNTL))
|
||||||
@ -433,8 +438,8 @@ ptcselect(dev, rw, p)
|
|||||||
|
|
||||||
case 0: /* exceptional */
|
case 0: /* exceptional */
|
||||||
if ((tp->t_state&TS_ISOPEN) &&
|
if ((tp->t_state&TS_ISOPEN) &&
|
||||||
(pti->pt_flags&PF_PKT && pti->pt_send ||
|
((pti->pt_flags&PF_PKT && pti->pt_send) ||
|
||||||
pti->pt_flags&PF_UCNTL && pti->pt_ucntl))
|
(pti->pt_flags&PF_UCNTL && pti->pt_ucntl)))
|
||||||
return (1);
|
return (1);
|
||||||
selrecord(p, &pti->pt_selr);
|
selrecord(p, &pti->pt_selr);
|
||||||
break;
|
break;
|
||||||
@ -538,8 +543,8 @@ ptcwrite(dev, uio, flag)
|
|||||||
return (EWOULDBLOCK);
|
return (EWOULDBLOCK);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (error = tsleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI | PCATCH,
|
error = tsleep((caddr_t)&tp->t_rawq.c_cf, TTOPRI | PCATCH, ttyout, 0);
|
||||||
ttyout, 0)) {
|
if (error) {
|
||||||
/* adjust for data copied in but not written */
|
/* adjust for data copied in but not written */
|
||||||
uio->uio_resid += cc;
|
uio->uio_resid += cc;
|
||||||
return (error);
|
return (error);
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -48,8 +48,6 @@
|
|||||||
|
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
|
|
||||||
void m_reclaim __P(());
|
|
||||||
|
|
||||||
extern vm_map_t mb_map;
|
extern vm_map_t mb_map;
|
||||||
struct mbuf *mbutl;
|
struct mbuf *mbutl;
|
||||||
char *mclrefcnt;
|
char *mclrefcnt;
|
||||||
@ -215,7 +213,8 @@ m_freem(m)
|
|||||||
return;
|
return;
|
||||||
do {
|
do {
|
||||||
MFREE(m, n);
|
MFREE(m, n);
|
||||||
} while (m = n);
|
m = n;
|
||||||
|
} while (m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -455,8 +454,8 @@ m_adj(mp, req_len)
|
|||||||
}
|
}
|
||||||
count -= m->m_len;
|
count -= m->m_len;
|
||||||
}
|
}
|
||||||
while (m = m->m_next)
|
while (m->m_next)
|
||||||
m->m_len = 0;
|
(m = m->m_next) ->m_len = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -42,16 +42,10 @@
|
|||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/mbuf.h>
|
#include <sys/mbuf.h>
|
||||||
#include <sys/protosw.h>
|
#include <sys/protosw.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/socketvar.h>
|
#include <sys/socketvar.h>
|
||||||
|
#include <sys/signalvar.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));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Primitive routines for operating on sockets and socket buffers
|
* Primitive routines for operating on sockets and socket buffers
|
||||||
@ -299,9 +293,10 @@ sb_lock(sb)
|
|||||||
|
|
||||||
while (sb->sb_flags & SB_LOCK) {
|
while (sb->sb_flags & SB_LOCK) {
|
||||||
sb->sb_flags |= SB_WANT;
|
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,
|
(sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK|PCATCH,
|
||||||
netio, 0))
|
netio, 0);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
sb->sb_flags |= SB_LOCK;
|
sb->sb_flags |= SB_LOCK;
|
||||||
@ -461,7 +456,8 @@ sbappend(sb, m)
|
|||||||
|
|
||||||
if (m == 0)
|
if (m == 0)
|
||||||
return;
|
return;
|
||||||
if (n = sb->sb_mb) {
|
n = sb->sb_mb;
|
||||||
|
if (n) {
|
||||||
while (n->m_nextpkt)
|
while (n->m_nextpkt)
|
||||||
n = n->m_nextpkt;
|
n = n->m_nextpkt;
|
||||||
do {
|
do {
|
||||||
@ -511,7 +507,8 @@ sbappendrecord(sb, m0)
|
|||||||
|
|
||||||
if (m0 == 0)
|
if (m0 == 0)
|
||||||
return;
|
return;
|
||||||
if (m = sb->sb_mb)
|
m = sb->sb_mb;
|
||||||
|
if (m)
|
||||||
while (m->m_nextpkt)
|
while (m->m_nextpkt)
|
||||||
m = m->m_nextpkt;
|
m = m->m_nextpkt;
|
||||||
/*
|
/*
|
||||||
@ -547,7 +544,8 @@ sbinsertoob(sb, m0)
|
|||||||
|
|
||||||
if (m0 == 0)
|
if (m0 == 0)
|
||||||
return;
|
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:
|
again:
|
||||||
switch (m->m_type) {
|
switch (m->m_type) {
|
||||||
|
|
||||||
@ -555,7 +553,8 @@ sbinsertoob(sb, m0)
|
|||||||
continue; /* WANT next train */
|
continue; /* WANT next train */
|
||||||
|
|
||||||
case MT_CONTROL:
|
case MT_CONTROL:
|
||||||
if (m = m->m_next)
|
m = m->m_next;
|
||||||
|
if (m)
|
||||||
goto again; /* inspect THIS train further */
|
goto again; /* inspect THIS train further */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -616,7 +615,8 @@ panic("sbappendaddr");
|
|||||||
m->m_next = control;
|
m->m_next = control;
|
||||||
for (n = m; n; n = n->m_next)
|
for (n = m; n; n = n->m_next)
|
||||||
sballoc(sb, n);
|
sballoc(sb, n);
|
||||||
if (n = sb->sb_mb) {
|
n = sb->sb_mb;
|
||||||
|
if (n) {
|
||||||
while (n->m_nextpkt)
|
while (n->m_nextpkt)
|
||||||
n = n->m_nextpkt;
|
n = n->m_nextpkt;
|
||||||
n->m_nextpkt = m;
|
n->m_nextpkt = m;
|
||||||
@ -648,7 +648,8 @@ sbappendcontrol(sb, m0, control)
|
|||||||
n->m_next = m0; /* concatenate data to control */
|
n->m_next = m0; /* concatenate data to control */
|
||||||
for (m = control; m; m = m->m_next)
|
for (m = control; m; m = m->m_next)
|
||||||
sballoc(sb, m);
|
sballoc(sb, m);
|
||||||
if (n = sb->sb_mb) {
|
n = sb->sb_mb;
|
||||||
|
if (n) {
|
||||||
while (n->m_nextpkt)
|
while (n->m_nextpkt)
|
||||||
n = n->m_nextpkt;
|
n = n->m_nextpkt;
|
||||||
n->m_nextpkt = control;
|
n->m_nextpkt = control;
|
||||||
@ -783,6 +784,7 @@ sbdroprecord(sb)
|
|||||||
do {
|
do {
|
||||||
sbfree(sb, m);
|
sbfree(sb, m);
|
||||||
MFREE(m, mn);
|
MFREE(m, mn);
|
||||||
} while (m = mn);
|
m = mn;
|
||||||
|
} while (m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -46,9 +46,7 @@
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/socketvar.h>
|
#include <sys/socketvar.h>
|
||||||
#include <sys/resourcevar.h>
|
#include <sys/resourcevar.h>
|
||||||
|
#include <sys/signalvar.h>
|
||||||
void sofree __P((struct socket *));
|
|
||||||
void sorflush __P((struct socket *));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Socket operation routines.
|
* Socket operation routines.
|
||||||
@ -181,10 +179,12 @@ soclose(so)
|
|||||||
if ((so->so_state & SS_ISDISCONNECTING) &&
|
if ((so->so_state & SS_ISDISCONNECTING) &&
|
||||||
(so->so_state & SS_NBIO))
|
(so->so_state & SS_NBIO))
|
||||||
goto drop;
|
goto drop;
|
||||||
while (so->so_state & SS_ISCONNECTED)
|
while (so->so_state & SS_ISCONNECTED) {
|
||||||
if (error = tsleep((caddr_t)&so->so_timeo,
|
error = tsleep((caddr_t)&so->so_timeo,
|
||||||
PSOCK | PCATCH, netcls, so->so_linger))
|
PSOCK | PCATCH, netcls, so->so_linger);
|
||||||
|
if (error)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drop:
|
drop:
|
||||||
@ -354,7 +354,8 @@ sosend(so, addr, uio, top, control, flags)
|
|||||||
#define snderr(errno) { error = errno; splx(s); goto release; }
|
#define snderr(errno) { error = errno; splx(s); goto release; }
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
if (error = sblock(&so->so_snd, SBLOCKWAIT(flags)))
|
error = sblock(&so->so_snd, SBLOCKWAIT(flags));
|
||||||
|
if (error)
|
||||||
goto out;
|
goto out;
|
||||||
do {
|
do {
|
||||||
s = splnet();
|
s = splnet();
|
||||||
@ -373,7 +374,7 @@ sosend(so, addr, uio, top, control, flags)
|
|||||||
space = sbspace(&so->so_snd);
|
space = sbspace(&so->so_snd);
|
||||||
if (flags & MSG_OOB)
|
if (flags & MSG_OOB)
|
||||||
space += 1024;
|
space += 1024;
|
||||||
if (atomic && resid > so->so_snd.sb_hiwat ||
|
if ((atomic && resid > so->so_snd.sb_hiwat) ||
|
||||||
clen > so->so_snd.sb_hiwat)
|
clen > so->so_snd.sb_hiwat)
|
||||||
snderr(EMSGSIZE);
|
snderr(EMSGSIZE);
|
||||||
if (space < resid + clen && uio &&
|
if (space < resid + clen && uio &&
|
||||||
@ -531,7 +532,8 @@ soreceive(so, paddr, uio, mp0, controlp, flagsp)
|
|||||||
(struct mbuf *)0, (struct mbuf *)0);
|
(struct mbuf *)0, (struct mbuf *)0);
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
if (error = sblock(&so->so_rcv, SBLOCKWAIT(flags)))
|
error = sblock(&so->so_rcv, SBLOCKWAIT(flags));
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
s = splnet();
|
s = splnet();
|
||||||
|
|
||||||
@ -547,11 +549,11 @@ soreceive(so, paddr, uio, mp0, controlp, flagsp)
|
|||||||
* we have to do the receive in sections, and thus risk returning
|
* we have to do the receive in sections, and thus risk returning
|
||||||
* a short count if a timeout or signal occurs after we start.
|
* 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 < uio->uio_resid) &&
|
||||||
(so->so_rcv.sb_cc < so->so_rcv.sb_lowat ||
|
(so->so_rcv.sb_cc < so->so_rcv.sb_lowat ||
|
||||||
((flags & MSG_WAITALL) && uio->uio_resid <= so->so_rcv.sb_hiwat)) &&
|
((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
|
#ifdef DIAGNOSTIC
|
||||||
if (m == 0 && so->so_rcv.sb_cc)
|
if (m == 0 && so->so_rcv.sb_cc)
|
||||||
panic("receive 1");
|
panic("receive 1");
|
||||||
@ -749,7 +751,8 @@ soreceive(so, paddr, uio, mp0, controlp, flagsp)
|
|||||||
splx(s);
|
splx(s);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
if (m = so->so_rcv.sb_mb)
|
m = so->so_rcv.sb_mb;
|
||||||
|
if (m)
|
||||||
nextrecord = m->m_nextpkt;
|
nextrecord = m->m_nextpkt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)uipc_socket2.c 8.1 (Berkeley) 6/10/93
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -42,16 +42,10 @@
|
|||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/mbuf.h>
|
#include <sys/mbuf.h>
|
||||||
#include <sys/protosw.h>
|
#include <sys/protosw.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/socketvar.h>
|
#include <sys/socketvar.h>
|
||||||
|
#include <sys/signalvar.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));
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Primitive routines for operating on sockets and socket buffers
|
* Primitive routines for operating on sockets and socket buffers
|
||||||
@ -299,9 +293,10 @@ sb_lock(sb)
|
|||||||
|
|
||||||
while (sb->sb_flags & SB_LOCK) {
|
while (sb->sb_flags & SB_LOCK) {
|
||||||
sb->sb_flags |= SB_WANT;
|
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,
|
(sb->sb_flags & SB_NOINTR) ? PSOCK : PSOCK|PCATCH,
|
||||||
netio, 0))
|
netio, 0);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
sb->sb_flags |= SB_LOCK;
|
sb->sb_flags |= SB_LOCK;
|
||||||
@ -461,7 +456,8 @@ sbappend(sb, m)
|
|||||||
|
|
||||||
if (m == 0)
|
if (m == 0)
|
||||||
return;
|
return;
|
||||||
if (n = sb->sb_mb) {
|
n = sb->sb_mb;
|
||||||
|
if (n) {
|
||||||
while (n->m_nextpkt)
|
while (n->m_nextpkt)
|
||||||
n = n->m_nextpkt;
|
n = n->m_nextpkt;
|
||||||
do {
|
do {
|
||||||
@ -511,7 +507,8 @@ sbappendrecord(sb, m0)
|
|||||||
|
|
||||||
if (m0 == 0)
|
if (m0 == 0)
|
||||||
return;
|
return;
|
||||||
if (m = sb->sb_mb)
|
m = sb->sb_mb;
|
||||||
|
if (m)
|
||||||
while (m->m_nextpkt)
|
while (m->m_nextpkt)
|
||||||
m = m->m_nextpkt;
|
m = m->m_nextpkt;
|
||||||
/*
|
/*
|
||||||
@ -547,7 +544,8 @@ sbinsertoob(sb, m0)
|
|||||||
|
|
||||||
if (m0 == 0)
|
if (m0 == 0)
|
||||||
return;
|
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:
|
again:
|
||||||
switch (m->m_type) {
|
switch (m->m_type) {
|
||||||
|
|
||||||
@ -555,7 +553,8 @@ sbinsertoob(sb, m0)
|
|||||||
continue; /* WANT next train */
|
continue; /* WANT next train */
|
||||||
|
|
||||||
case MT_CONTROL:
|
case MT_CONTROL:
|
||||||
if (m = m->m_next)
|
m = m->m_next;
|
||||||
|
if (m)
|
||||||
goto again; /* inspect THIS train further */
|
goto again; /* inspect THIS train further */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -616,7 +615,8 @@ panic("sbappendaddr");
|
|||||||
m->m_next = control;
|
m->m_next = control;
|
||||||
for (n = m; n; n = n->m_next)
|
for (n = m; n; n = n->m_next)
|
||||||
sballoc(sb, n);
|
sballoc(sb, n);
|
||||||
if (n = sb->sb_mb) {
|
n = sb->sb_mb;
|
||||||
|
if (n) {
|
||||||
while (n->m_nextpkt)
|
while (n->m_nextpkt)
|
||||||
n = n->m_nextpkt;
|
n = n->m_nextpkt;
|
||||||
n->m_nextpkt = m;
|
n->m_nextpkt = m;
|
||||||
@ -648,7 +648,8 @@ sbappendcontrol(sb, m0, control)
|
|||||||
n->m_next = m0; /* concatenate data to control */
|
n->m_next = m0; /* concatenate data to control */
|
||||||
for (m = control; m; m = m->m_next)
|
for (m = control; m; m = m->m_next)
|
||||||
sballoc(sb, m);
|
sballoc(sb, m);
|
||||||
if (n = sb->sb_mb) {
|
n = sb->sb_mb;
|
||||||
|
if (n) {
|
||||||
while (n->m_nextpkt)
|
while (n->m_nextpkt)
|
||||||
n = n->m_nextpkt;
|
n = n->m_nextpkt;
|
||||||
n->m_nextpkt = control;
|
n->m_nextpkt = control;
|
||||||
@ -783,6 +784,7 @@ sbdroprecord(sb)
|
|||||||
do {
|
do {
|
||||||
sbfree(sb, m);
|
sbfree(sb, m);
|
||||||
MFREE(m, mn);
|
MFREE(m, mn);
|
||||||
} while (m = mn);
|
m = mn;
|
||||||
|
} while (m);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -40,6 +40,7 @@
|
|||||||
#include <sys/filedesc.h>
|
#include <sys/filedesc.h>
|
||||||
#include <sys/domain.h>
|
#include <sys/domain.h>
|
||||||
#include <sys/protosw.h>
|
#include <sys/protosw.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/socketvar.h>
|
#include <sys/socketvar.h>
|
||||||
#include <sys/unpcb.h>
|
#include <sys/unpcb.h>
|
||||||
@ -50,15 +51,6 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/mbuf.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.
|
* Unix communications domain.
|
||||||
*
|
*
|
||||||
@ -411,7 +403,8 @@ unp_bind(unp, nam, p)
|
|||||||
} else
|
} else
|
||||||
*(mtod(nam, caddr_t) + nam->m_len) = 0;
|
*(mtod(nam, caddr_t) + nam->m_len) = 0;
|
||||||
/* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */
|
/* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp != NULL) {
|
if (vp != NULL) {
|
||||||
@ -427,7 +420,8 @@ unp_bind(unp, nam, p)
|
|||||||
vattr.va_type = VSOCK;
|
vattr.va_type = VSOCK;
|
||||||
vattr.va_mode = ACCESSPERMS;
|
vattr.va_mode = ACCESSPERMS;
|
||||||
LEASE_CHECK(nd.ni_dvp, p, p->p_ucred, LEASE_WRITE);
|
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);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
vp->v_socket = unp->unp_socket;
|
vp->v_socket = unp->unp_socket;
|
||||||
@ -456,14 +450,16 @@ unp_connect(so, nam, p)
|
|||||||
return (EMSGSIZE);
|
return (EMSGSIZE);
|
||||||
} else
|
} else
|
||||||
*(mtod(nam, caddr_t) + nam->m_len) = 0;
|
*(mtod(nam, caddr_t) + nam->m_len) = 0;
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp->v_type != VSOCK) {
|
if (vp->v_type != VSOCK) {
|
||||||
error = ENOTSOCK;
|
error = ENOTSOCK;
|
||||||
goto bad;
|
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;
|
goto bad;
|
||||||
so2 = vp->v_socket;
|
so2 = vp->v_socket;
|
||||||
if (so2 == 0) {
|
if (so2 == 0) {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)vfs_cache.c 8.1 (Berkeley) 6/10/93
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -161,20 +161,23 @@ cache_lookup(dvp, vpp, cnp)
|
|||||||
* want cache entry to exist.
|
* want cache entry to exist.
|
||||||
*/
|
*/
|
||||||
/* remove from LRU chain */
|
/* remove from LRU chain */
|
||||||
if (ncq = ncp->nc_nxt)
|
ncq = ncp->nc_nxt;
|
||||||
|
if (ncq)
|
||||||
ncq->nc_prev = ncp->nc_prev;
|
ncq->nc_prev = ncp->nc_prev;
|
||||||
else
|
else
|
||||||
nchtail = ncp->nc_prev;
|
nchtail = ncp->nc_prev;
|
||||||
*ncp->nc_prev = ncq;
|
*ncp->nc_prev = ncq;
|
||||||
/* remove from hash chain */
|
/* remove from hash chain */
|
||||||
if (ncq = ncp->nc_forw)
|
ncq = ncp->nc_forw;
|
||||||
|
if (ncq)
|
||||||
ncq->nc_back = ncp->nc_back;
|
ncq->nc_back = ncp->nc_back;
|
||||||
*ncp->nc_back = ncq;
|
*ncp->nc_back = ncq;
|
||||||
/* and make a dummy hash chain */
|
/* and make a dummy hash chain */
|
||||||
ncp->nc_forw = NULL;
|
ncp->nc_forw = NULL;
|
||||||
ncp->nc_back = NULL;
|
ncp->nc_back = NULL;
|
||||||
/* insert at head of LRU list (first to grab) */
|
/* insert at head of LRU list (first to grab) */
|
||||||
if (ncq = nchhead)
|
ncq = nchhead;
|
||||||
|
if (ncq)
|
||||||
ncq->nc_prev = &ncp->nc_nxt;
|
ncq->nc_prev = &ncp->nc_nxt;
|
||||||
else
|
else
|
||||||
nchtail = &ncp->nc_nxt;
|
nchtail = &ncp->nc_nxt;
|
||||||
@ -209,23 +212,27 @@ cache_enter(dvp, vp, cnp)
|
|||||||
malloc((u_long)sizeof *ncp, M_CACHE, M_WAITOK);
|
malloc((u_long)sizeof *ncp, M_CACHE, M_WAITOK);
|
||||||
bzero((char *)ncp, sizeof *ncp);
|
bzero((char *)ncp, sizeof *ncp);
|
||||||
numcache++;
|
numcache++;
|
||||||
} else if (ncp = nchhead) {
|
} else if (!nchhead) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
ncp = nchhead;
|
||||||
/* remove from lru chain */
|
/* remove from lru chain */
|
||||||
if (ncq = ncp->nc_nxt)
|
ncq = ncp->nc_nxt;
|
||||||
|
if (ncq)
|
||||||
ncq->nc_prev = ncp->nc_prev;
|
ncq->nc_prev = ncp->nc_prev;
|
||||||
else
|
else
|
||||||
nchtail = ncp->nc_prev;
|
nchtail = ncp->nc_prev;
|
||||||
*ncp->nc_prev = ncq;
|
*ncp->nc_prev = ncq;
|
||||||
/* remove from old hash chain, if on one */
|
/* remove from old hash chain, if on one */
|
||||||
if (ncp->nc_back) {
|
if (ncp->nc_back) {
|
||||||
if (ncq = ncp->nc_forw)
|
ncq = ncp->nc_forw;
|
||||||
|
if (ncq)
|
||||||
ncq->nc_back = ncp->nc_back;
|
ncq->nc_back = ncp->nc_back;
|
||||||
*ncp->nc_back = ncq;
|
*ncp->nc_back = ncq;
|
||||||
ncp->nc_forw = NULL;
|
ncp->nc_forw = NULL;
|
||||||
ncp->nc_back = NULL;
|
ncp->nc_back = NULL;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
return;
|
|
||||||
/* grab the vnode we just found */
|
/* grab the vnode we just found */
|
||||||
ncp->nc_vp = vp;
|
ncp->nc_vp = vp;
|
||||||
if (vp)
|
if (vp)
|
||||||
@ -244,7 +251,8 @@ cache_enter(dvp, vp, cnp)
|
|||||||
nchtail = &ncp->nc_nxt;
|
nchtail = &ncp->nc_nxt;
|
||||||
/* and insert on hash chain */
|
/* and insert on hash chain */
|
||||||
ncpp = &nchashtbl[cnp->cn_hash & nchash];
|
ncpp = &nchashtbl[cnp->cn_hash & nchash];
|
||||||
if (ncq = *ncpp)
|
ncq = *ncpp;
|
||||||
|
if (ncq)
|
||||||
ncq->nc_back = &ncp->nc_forw;
|
ncq->nc_back = &ncp->nc_forw;
|
||||||
ncp->nc_forw = ncq;
|
ncp->nc_forw = ncq;
|
||||||
ncp->nc_back = ncpp;
|
ncp->nc_back = ncpp;
|
||||||
@ -308,21 +316,24 @@ cache_purgevfs(mp)
|
|||||||
ncp->nc_dvp = NULL;
|
ncp->nc_dvp = NULL;
|
||||||
/* remove from old hash chain, if on one */
|
/* remove from old hash chain, if on one */
|
||||||
if (ncp->nc_back) {
|
if (ncp->nc_back) {
|
||||||
if (nxtcp = ncp->nc_forw)
|
nxtcp = ncp->nc_forw;
|
||||||
|
if (nxtcp)
|
||||||
nxtcp->nc_back = ncp->nc_back;
|
nxtcp->nc_back = ncp->nc_back;
|
||||||
*ncp->nc_back = nxtcp;
|
*ncp->nc_back = nxtcp;
|
||||||
ncp->nc_forw = NULL;
|
ncp->nc_forw = NULL;
|
||||||
ncp->nc_back = NULL;
|
ncp->nc_back = NULL;
|
||||||
}
|
}
|
||||||
/* delete this entry from LRU chain */
|
/* delete this entry from LRU chain */
|
||||||
if (nxtcp = ncp->nc_nxt)
|
nxtcp = ncp->nc_nxt;
|
||||||
|
if (nxtcp)
|
||||||
nxtcp->nc_prev = ncp->nc_prev;
|
nxtcp->nc_prev = ncp->nc_prev;
|
||||||
else
|
else
|
||||||
nchtail = ncp->nc_prev;
|
nchtail = ncp->nc_prev;
|
||||||
*ncp->nc_prev = nxtcp;
|
*ncp->nc_prev = nxtcp;
|
||||||
/* cause rescan of list, it may have altered */
|
/* cause rescan of list, it may have altered */
|
||||||
/* also put the now-free entry at head of LRU */
|
/* also put the now-free entry at head of LRU */
|
||||||
if (nxtcp = nchhead)
|
nxtcp = nchhead;
|
||||||
|
if (nxtcp)
|
||||||
nxtcp->nc_prev = &ncp->nc_nxt;
|
nxtcp->nc_prev = &ncp->nc_nxt;
|
||||||
else
|
else
|
||||||
nchtail = &ncp->nc_nxt;
|
nchtail = &ncp->nc_nxt;
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94
|
* @(#)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)
|
if (vp->v_type != VBAD)
|
||||||
vgone(vp);
|
vgone(vp);
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
|
{
|
||||||
|
int s;
|
||||||
if (vp->v_data)
|
if (vp->v_data)
|
||||||
panic("cleaned vnode isn't");
|
panic("cleaned vnode isn't");
|
||||||
s = splbio();
|
s = splbio();
|
||||||
if (vp->v_numoutput)
|
if (vp->v_numoutput)
|
||||||
panic("Clean vnode has pending I/O's");
|
panic("Clean vnode has pending I/O's");
|
||||||
splx(s);
|
splx(s);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
vp->v_flag = 0;
|
vp->v_flag = 0;
|
||||||
vp->v_lastr = 0;
|
vp->v_lastr = 0;
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -56,7 +56,6 @@
|
|||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
void cvtstat __P((struct stat *, struct ostat *));
|
|
||||||
static int change_dir __P((struct nameidata *ndp, struct proc *p));
|
static int change_dir __P((struct nameidata *ndp, struct proc *p));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -87,13 +86,15 @@ mount(p, uap, retval)
|
|||||||
/*
|
/*
|
||||||
* Must be super user
|
* 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);
|
return (error);
|
||||||
/*
|
/*
|
||||||
* Get vnode to be covered
|
* Get vnode to be covered
|
||||||
*/
|
*/
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (uap->flags & MNT_UPDATE) {
|
if (uap->flags & MNT_UPDATE) {
|
||||||
@ -117,7 +118,8 @@ mount(p, uap, retval)
|
|||||||
VOP_UNLOCK(vp);
|
VOP_UNLOCK(vp);
|
||||||
goto update;
|
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);
|
return (error);
|
||||||
if (vp->v_type != VDIR) {
|
if (vp->v_type != VDIR) {
|
||||||
vput(vp);
|
vput(vp);
|
||||||
@ -136,7 +138,8 @@ mount(p, uap, retval)
|
|||||||
bzero((char *)mp, (u_long)sizeof(struct mount));
|
bzero((char *)mp, (u_long)sizeof(struct mount));
|
||||||
mp->mnt_op = vfssw[uap->type];
|
mp->mnt_op = vfssw[uap->type];
|
||||||
mp->mnt_vfc = vfsconf[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);
|
free((caddr_t)mp, M_MOUNT);
|
||||||
vput(vp);
|
vput(vp);
|
||||||
return (error);
|
return (error);
|
||||||
@ -219,7 +222,8 @@ unmount(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
|
|
||||||
@ -268,7 +272,8 @@ dounmount(mp, flags, p)
|
|||||||
if (vfs_busy(mp))
|
if (vfs_busy(mp))
|
||||||
return (EBUSY);
|
return (EBUSY);
|
||||||
mp->mnt_flag |= MNT_UNMOUNT;
|
mp->mnt_flag |= MNT_UNMOUNT;
|
||||||
if (error = vfs_lock(mp))
|
error = vfs_lock(mp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
mp->mnt_flag &=~ MNT_ASYNC;
|
mp->mnt_flag &=~ MNT_ASYNC;
|
||||||
@ -359,7 +364,8 @@ quotactl(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
mp = nd.ni_vp->v_mount;
|
mp = nd.ni_vp->v_mount;
|
||||||
vrele(nd.ni_vp);
|
vrele(nd.ni_vp);
|
||||||
@ -386,12 +392,14 @@ statfs(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
mp = nd.ni_vp->v_mount;
|
mp = nd.ni_vp->v_mount;
|
||||||
sp = &mp->mnt_stat;
|
sp = &mp->mnt_stat;
|
||||||
vrele(nd.ni_vp);
|
vrele(nd.ni_vp);
|
||||||
if (error = VFS_STATFS(mp, sp, p))
|
error = VFS_STATFS(mp, sp, p);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||||
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
|
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
|
||||||
@ -416,11 +424,13 @@ fstatfs(p, uap, retval)
|
|||||||
register struct statfs *sp;
|
register struct statfs *sp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
mp = ((struct vnode *)fp->f_data)->v_mount;
|
mp = ((struct vnode *)fp->f_data)->v_mount;
|
||||||
sp = &mp->mnt_stat;
|
sp = &mp->mnt_stat;
|
||||||
if (error = VFS_STATFS(mp, sp, p))
|
error = VFS_STATFS(mp, sp, p);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||||
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
|
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
|
||||||
@ -492,7 +502,8 @@ fchdir(p, uap, retval)
|
|||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(fdp, uap->fd, &fp))
|
error = getvnode(fdp, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = (struct vnode *)fp->f_data;
|
vp = (struct vnode *)fp->f_data;
|
||||||
VOP_LOCK(vp);
|
VOP_LOCK(vp);
|
||||||
@ -527,7 +538,8 @@ chdir(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
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);
|
return (error);
|
||||||
vrele(fdp->fd_cdir);
|
vrele(fdp->fd_cdir);
|
||||||
fdp->fd_cdir = nd.ni_vp;
|
fdp->fd_cdir = nd.ni_vp;
|
||||||
@ -551,10 +563,12 @@ chroot(p, uap, retval)
|
|||||||
int error;
|
int error;
|
||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
if (error = suser(p->p_ucred, &p->p_acflag))
|
error = suser(p->p_ucred, &p->p_acflag);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
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);
|
return (error);
|
||||||
if (fdp->fd_rdir != NULL)
|
if (fdp->fd_rdir != NULL)
|
||||||
vrele(fdp->fd_rdir);
|
vrele(fdp->fd_rdir);
|
||||||
@ -573,7 +587,8 @@ change_dir(ndp, p)
|
|||||||
struct vnode *vp;
|
struct vnode *vp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = namei(ndp))
|
error = namei(ndp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = ndp->ni_vp;
|
vp = ndp->ni_vp;
|
||||||
if (vp->v_type != VDIR)
|
if (vp->v_type != VDIR)
|
||||||
@ -611,14 +626,16 @@ open(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
extern struct fileops vnops;
|
extern struct fileops vnops;
|
||||||
|
|
||||||
if (error = falloc(p, &nfp, &indx))
|
error = falloc(p, &nfp, &indx);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
fp = nfp;
|
fp = nfp;
|
||||||
flags = FFLAGS(uap->flags);
|
flags = FFLAGS(uap->flags);
|
||||||
cmode = ((uap->mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
|
cmode = ((uap->mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
|
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);
|
ffree(fp);
|
||||||
if ((error == ENODEV || error == ENXIO) &&
|
if ((error == ENODEV || error == ENXIO) &&
|
||||||
p->p_dupfd >= 0 && /* XXX from fdopen */
|
p->p_dupfd >= 0 && /* XXX from fdopen */
|
||||||
@ -650,7 +667,8 @@ open(p, uap, retval)
|
|||||||
if ((flags & FNONBLOCK) == 0)
|
if ((flags & FNONBLOCK) == 0)
|
||||||
type |= F_WAIT;
|
type |= F_WAIT;
|
||||||
VOP_UNLOCK(vp);
|
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);
|
(void) vn_close(vp, fp->f_flag, fp->f_cred, p);
|
||||||
ffree(fp);
|
ffree(fp);
|
||||||
fdp->fd_ofiles[indx] = NULL;
|
fdp->fd_ofiles[indx] = NULL;
|
||||||
@ -707,10 +725,12 @@ mknod(p, uap, retval)
|
|||||||
int error;
|
int error;
|
||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
if (error = suser(p->p_ucred, &p->p_acflag))
|
error = suser(p->p_ucred, &p->p_acflag);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp != NULL)
|
if (vp != NULL)
|
||||||
@ -769,7 +789,8 @@ mkfifo(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
if (nd.ni_vp != NULL) {
|
if (nd.ni_vp != NULL) {
|
||||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||||
@ -806,7 +827,8 @@ link(p, uap, retval)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp->v_type != VDIR ||
|
if (vp->v_type != VDIR ||
|
||||||
@ -814,7 +836,8 @@ link(p, uap, retval)
|
|||||||
nd.ni_cnd.cn_nameiop = CREATE;
|
nd.ni_cnd.cn_nameiop = CREATE;
|
||||||
nd.ni_cnd.cn_flags = LOCKPARENT;
|
nd.ni_cnd.cn_flags = LOCKPARENT;
|
||||||
nd.ni_dirp = uap->link;
|
nd.ni_dirp = uap->link;
|
||||||
if ((error = namei(&nd)) == 0) {
|
error = namei(&nd);
|
||||||
|
if (!error) {
|
||||||
if (nd.ni_vp != NULL)
|
if (nd.ni_vp != NULL)
|
||||||
error = EEXIST;
|
error = EEXIST;
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@ -858,10 +881,12 @@ symlink(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
|
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;
|
goto out;
|
||||||
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->link, p);
|
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->link, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
goto out;
|
goto out;
|
||||||
if (nd.ni_vp) {
|
if (nd.ni_vp) {
|
||||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||||
@ -900,7 +925,8 @@ unlink(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -962,8 +988,8 @@ lseek(p, uap, retval)
|
|||||||
fp->f_offset += uap->offset;
|
fp->f_offset += uap->offset;
|
||||||
break;
|
break;
|
||||||
case L_XTND:
|
case L_XTND:
|
||||||
if (error =
|
error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p);
|
||||||
VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p))
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
fp->f_offset = uap->offset + vattr.va_size;
|
fp->f_offset = uap->offset + vattr.va_size;
|
||||||
break;
|
break;
|
||||||
@ -1028,7 +1054,8 @@ access(p, uap, retval)
|
|||||||
cred->cr_uid = p->p_cred->p_ruid;
|
cred->cr_uid = p->p_cred->p_ruid;
|
||||||
cred->cr_groups[0] = p->p_cred->p_rgid;
|
cred->cr_groups[0] = p->p_cred->p_rgid;
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
goto out1;
|
goto out1;
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
|
|
||||||
@ -1072,7 +1099,8 @@ ostat(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
error = vn_stat(nd.ni_vp, &sb, p);
|
error = vn_stat(nd.ni_vp, &sb, p);
|
||||||
vput(nd.ni_vp);
|
vput(nd.ni_vp);
|
||||||
@ -1105,7 +1133,8 @@ olstat(p, uap, retval)
|
|||||||
|
|
||||||
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
|
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
|
||||||
uap->path, p);
|
uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
/*
|
/*
|
||||||
* For symbolic links, always return the attributes of its
|
* For symbolic links, always return the attributes of its
|
||||||
@ -1193,7 +1222,8 @@ stat(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
error = vn_stat(nd.ni_vp, &sb, p);
|
error = vn_stat(nd.ni_vp, &sb, p);
|
||||||
vput(nd.ni_vp);
|
vput(nd.ni_vp);
|
||||||
@ -1224,7 +1254,8 @@ lstat(p, uap, retval)
|
|||||||
|
|
||||||
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
|
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
|
||||||
uap->path, p);
|
uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
/*
|
/*
|
||||||
* For symbolic links, always return the attributes of its
|
* For symbolic links, always return the attributes of its
|
||||||
@ -1280,7 +1311,8 @@ pathconf(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
|
error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
|
||||||
vput(nd.ni_vp);
|
vput(nd.ni_vp);
|
||||||
@ -1309,7 +1341,8 @@ readlink(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp->v_type != VLNK)
|
if (vp->v_type != VLNK)
|
||||||
@ -1351,7 +1384,8 @@ chflags(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1386,7 +1420,8 @@ fchflags(p, uap, retval)
|
|||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = (struct vnode *)fp->f_data;
|
vp = (struct vnode *)fp->f_data;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1422,7 +1457,8 @@ chmod(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1457,7 +1493,8 @@ fchmod(p, uap, retval)
|
|||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = (struct vnode *)fp->f_data;
|
vp = (struct vnode *)fp->f_data;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1494,7 +1531,8 @@ chown(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1531,7 +1569,8 @@ fchown(p, uap, retval)
|
|||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = (struct vnode *)fp->f_data;
|
vp = (struct vnode *)fp->f_data;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1573,10 +1612,14 @@ utimes(p, uap, retval)
|
|||||||
microtime(&tv[0]);
|
microtime(&tv[0]);
|
||||||
tv[1] = tv[0];
|
tv[1] = tv[0];
|
||||||
vattr.va_vaflags |= VA_UTIMES_NULL;
|
vattr.va_vaflags |= VA_UTIMES_NULL;
|
||||||
} else if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
|
} else {
|
||||||
return (error);
|
error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1617,7 +1660,8 @@ truncate(p, uap, retval)
|
|||||||
if (uap->length < 0)
|
if (uap->length < 0)
|
||||||
return(EINVAL);
|
return(EINVAL);
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1656,7 +1700,8 @@ ftruncate(p, uap, retval)
|
|||||||
|
|
||||||
if (uap->length < 0)
|
if (uap->length < 0)
|
||||||
return(EINVAL);
|
return(EINVAL);
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
if ((fp->f_flag & FWRITE) == 0)
|
if ((fp->f_flag & FWRITE) == 0)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
@ -1735,7 +1780,8 @@ fsync(p, uap, retval)
|
|||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = (struct vnode *)fp->f_data;
|
vp = (struct vnode *)fp->f_data;
|
||||||
VOP_LOCK(vp);
|
VOP_LOCK(vp);
|
||||||
@ -1765,12 +1811,14 @@ rename(p, uap, retval)
|
|||||||
|
|
||||||
NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
|
NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
|
||||||
uap->from, p);
|
uap->from, p);
|
||||||
if (error = namei(&fromnd))
|
error = namei(&fromnd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
fvp = fromnd.ni_vp;
|
fvp = fromnd.ni_vp;
|
||||||
NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
|
NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
|
||||||
UIO_USERSPACE, uap->to, p);
|
UIO_USERSPACE, uap->to, p);
|
||||||
if (error = namei(&tond)) {
|
error = namei(&tond);
|
||||||
|
if (error) {
|
||||||
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
|
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
|
||||||
vrele(fromnd.ni_dvp);
|
vrele(fromnd.ni_dvp);
|
||||||
vrele(fvp);
|
vrele(fvp);
|
||||||
@ -1851,7 +1899,8 @@ mkdir(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp != NULL) {
|
if (vp != NULL) {
|
||||||
@ -1891,7 +1940,8 @@ rmdir(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp->v_type != VDIR) {
|
if (vp->v_type != VDIR) {
|
||||||
@ -1951,7 +2001,8 @@ ogetdirentries(p, uap, retval)
|
|||||||
int error, readcnt;
|
int error, readcnt;
|
||||||
long loff;
|
long loff;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
if ((fp->f_flag & FREAD) == 0)
|
if ((fp->f_flag & FREAD) == 0)
|
||||||
return (EBADF);
|
return (EBADF);
|
||||||
@ -2048,7 +2099,8 @@ getdirentries(p, uap, retval)
|
|||||||
long loff;
|
long loff;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
if ((fp->f_flag & FREAD) == 0)
|
if ((fp->f_flag & FREAD) == 0)
|
||||||
return (EBADF);
|
return (EBADF);
|
||||||
@ -2158,14 +2210,16 @@ revoke(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp->v_type != VCHR && vp->v_type != VBLK) {
|
if (vp->v_type != VCHR && vp->v_type != VBLK) {
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
goto out;
|
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;
|
goto out;
|
||||||
if (p->p_ucred->cr_uid != vattr.va_uid &&
|
if (p->p_ucred->cr_uid != vattr.va_uid &&
|
||||||
(error = suser(p->p_ucred, &p->p_acflag)))
|
(error = suser(p->p_ucred, &p->p_acflag)))
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)vfs_subr.c 8.13 (Berkeley) 4/18/94
|
* @(#)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)
|
if (vp->v_type != VBAD)
|
||||||
vgone(vp);
|
vgone(vp);
|
||||||
#ifdef DIAGNOSTIC
|
#ifdef DIAGNOSTIC
|
||||||
|
{
|
||||||
|
int s;
|
||||||
if (vp->v_data)
|
if (vp->v_data)
|
||||||
panic("cleaned vnode isn't");
|
panic("cleaned vnode isn't");
|
||||||
s = splbio();
|
s = splbio();
|
||||||
if (vp->v_numoutput)
|
if (vp->v_numoutput)
|
||||||
panic("Clean vnode has pending I/O's");
|
panic("Clean vnode has pending I/O's");
|
||||||
splx(s);
|
splx(s);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
vp->v_flag = 0;
|
vp->v_flag = 0;
|
||||||
vp->v_lastr = 0;
|
vp->v_lastr = 0;
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -56,7 +56,6 @@
|
|||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
|
|
||||||
void cvtstat __P((struct stat *, struct ostat *));
|
|
||||||
static int change_dir __P((struct nameidata *ndp, struct proc *p));
|
static int change_dir __P((struct nameidata *ndp, struct proc *p));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -87,13 +86,15 @@ mount(p, uap, retval)
|
|||||||
/*
|
/*
|
||||||
* Must be super user
|
* 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);
|
return (error);
|
||||||
/*
|
/*
|
||||||
* Get vnode to be covered
|
* Get vnode to be covered
|
||||||
*/
|
*/
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (uap->flags & MNT_UPDATE) {
|
if (uap->flags & MNT_UPDATE) {
|
||||||
@ -117,7 +118,8 @@ mount(p, uap, retval)
|
|||||||
VOP_UNLOCK(vp);
|
VOP_UNLOCK(vp);
|
||||||
goto update;
|
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);
|
return (error);
|
||||||
if (vp->v_type != VDIR) {
|
if (vp->v_type != VDIR) {
|
||||||
vput(vp);
|
vput(vp);
|
||||||
@ -136,7 +138,8 @@ mount(p, uap, retval)
|
|||||||
bzero((char *)mp, (u_long)sizeof(struct mount));
|
bzero((char *)mp, (u_long)sizeof(struct mount));
|
||||||
mp->mnt_op = vfssw[uap->type];
|
mp->mnt_op = vfssw[uap->type];
|
||||||
mp->mnt_vfc = vfsconf[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);
|
free((caddr_t)mp, M_MOUNT);
|
||||||
vput(vp);
|
vput(vp);
|
||||||
return (error);
|
return (error);
|
||||||
@ -219,7 +222,8 @@ unmount(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
|
|
||||||
@ -268,7 +272,8 @@ dounmount(mp, flags, p)
|
|||||||
if (vfs_busy(mp))
|
if (vfs_busy(mp))
|
||||||
return (EBUSY);
|
return (EBUSY);
|
||||||
mp->mnt_flag |= MNT_UNMOUNT;
|
mp->mnt_flag |= MNT_UNMOUNT;
|
||||||
if (error = vfs_lock(mp))
|
error = vfs_lock(mp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
mp->mnt_flag &=~ MNT_ASYNC;
|
mp->mnt_flag &=~ MNT_ASYNC;
|
||||||
@ -359,7 +364,8 @@ quotactl(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
mp = nd.ni_vp->v_mount;
|
mp = nd.ni_vp->v_mount;
|
||||||
vrele(nd.ni_vp);
|
vrele(nd.ni_vp);
|
||||||
@ -386,12 +392,14 @@ statfs(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
mp = nd.ni_vp->v_mount;
|
mp = nd.ni_vp->v_mount;
|
||||||
sp = &mp->mnt_stat;
|
sp = &mp->mnt_stat;
|
||||||
vrele(nd.ni_vp);
|
vrele(nd.ni_vp);
|
||||||
if (error = VFS_STATFS(mp, sp, p))
|
error = VFS_STATFS(mp, sp, p);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||||
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
|
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
|
||||||
@ -416,11 +424,13 @@ fstatfs(p, uap, retval)
|
|||||||
register struct statfs *sp;
|
register struct statfs *sp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
mp = ((struct vnode *)fp->f_data)->v_mount;
|
mp = ((struct vnode *)fp->f_data)->v_mount;
|
||||||
sp = &mp->mnt_stat;
|
sp = &mp->mnt_stat;
|
||||||
if (error = VFS_STATFS(mp, sp, p))
|
error = VFS_STATFS(mp, sp, p);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
|
||||||
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
|
return (copyout((caddr_t)sp, (caddr_t)uap->buf, sizeof(*sp)));
|
||||||
@ -492,7 +502,8 @@ fchdir(p, uap, retval)
|
|||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(fdp, uap->fd, &fp))
|
error = getvnode(fdp, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = (struct vnode *)fp->f_data;
|
vp = (struct vnode *)fp->f_data;
|
||||||
VOP_LOCK(vp);
|
VOP_LOCK(vp);
|
||||||
@ -527,7 +538,8 @@ chdir(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
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);
|
return (error);
|
||||||
vrele(fdp->fd_cdir);
|
vrele(fdp->fd_cdir);
|
||||||
fdp->fd_cdir = nd.ni_vp;
|
fdp->fd_cdir = nd.ni_vp;
|
||||||
@ -551,10 +563,12 @@ chroot(p, uap, retval)
|
|||||||
int error;
|
int error;
|
||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
if (error = suser(p->p_ucred, &p->p_acflag))
|
error = suser(p->p_ucred, &p->p_acflag);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
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);
|
return (error);
|
||||||
if (fdp->fd_rdir != NULL)
|
if (fdp->fd_rdir != NULL)
|
||||||
vrele(fdp->fd_rdir);
|
vrele(fdp->fd_rdir);
|
||||||
@ -573,7 +587,8 @@ change_dir(ndp, p)
|
|||||||
struct vnode *vp;
|
struct vnode *vp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = namei(ndp))
|
error = namei(ndp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = ndp->ni_vp;
|
vp = ndp->ni_vp;
|
||||||
if (vp->v_type != VDIR)
|
if (vp->v_type != VDIR)
|
||||||
@ -611,14 +626,16 @@ open(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
extern struct fileops vnops;
|
extern struct fileops vnops;
|
||||||
|
|
||||||
if (error = falloc(p, &nfp, &indx))
|
error = falloc(p, &nfp, &indx);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
fp = nfp;
|
fp = nfp;
|
||||||
flags = FFLAGS(uap->flags);
|
flags = FFLAGS(uap->flags);
|
||||||
cmode = ((uap->mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
|
cmode = ((uap->mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
p->p_dupfd = -indx - 1; /* XXX check for fdopen */
|
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);
|
ffree(fp);
|
||||||
if ((error == ENODEV || error == ENXIO) &&
|
if ((error == ENODEV || error == ENXIO) &&
|
||||||
p->p_dupfd >= 0 && /* XXX from fdopen */
|
p->p_dupfd >= 0 && /* XXX from fdopen */
|
||||||
@ -650,7 +667,8 @@ open(p, uap, retval)
|
|||||||
if ((flags & FNONBLOCK) == 0)
|
if ((flags & FNONBLOCK) == 0)
|
||||||
type |= F_WAIT;
|
type |= F_WAIT;
|
||||||
VOP_UNLOCK(vp);
|
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);
|
(void) vn_close(vp, fp->f_flag, fp->f_cred, p);
|
||||||
ffree(fp);
|
ffree(fp);
|
||||||
fdp->fd_ofiles[indx] = NULL;
|
fdp->fd_ofiles[indx] = NULL;
|
||||||
@ -707,10 +725,12 @@ mknod(p, uap, retval)
|
|||||||
int error;
|
int error;
|
||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
if (error = suser(p->p_ucred, &p->p_acflag))
|
error = suser(p->p_ucred, &p->p_acflag);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp != NULL)
|
if (vp != NULL)
|
||||||
@ -769,7 +789,8 @@ mkfifo(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
if (nd.ni_vp != NULL) {
|
if (nd.ni_vp != NULL) {
|
||||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||||
@ -806,7 +827,8 @@ link(p, uap, retval)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp->v_type != VDIR ||
|
if (vp->v_type != VDIR ||
|
||||||
@ -814,7 +836,8 @@ link(p, uap, retval)
|
|||||||
nd.ni_cnd.cn_nameiop = CREATE;
|
nd.ni_cnd.cn_nameiop = CREATE;
|
||||||
nd.ni_cnd.cn_flags = LOCKPARENT;
|
nd.ni_cnd.cn_flags = LOCKPARENT;
|
||||||
nd.ni_dirp = uap->link;
|
nd.ni_dirp = uap->link;
|
||||||
if ((error = namei(&nd)) == 0) {
|
error = namei(&nd);
|
||||||
|
if (!error) {
|
||||||
if (nd.ni_vp != NULL)
|
if (nd.ni_vp != NULL)
|
||||||
error = EEXIST;
|
error = EEXIST;
|
||||||
if (!error) {
|
if (!error) {
|
||||||
@ -858,10 +881,12 @@ symlink(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
|
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;
|
goto out;
|
||||||
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->link, p);
|
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->link, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
goto out;
|
goto out;
|
||||||
if (nd.ni_vp) {
|
if (nd.ni_vp) {
|
||||||
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd);
|
||||||
@ -900,7 +925,8 @@ unlink(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, DELETE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -962,8 +988,8 @@ lseek(p, uap, retval)
|
|||||||
fp->f_offset += uap->offset;
|
fp->f_offset += uap->offset;
|
||||||
break;
|
break;
|
||||||
case L_XTND:
|
case L_XTND:
|
||||||
if (error =
|
error=VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p);
|
||||||
VOP_GETATTR((struct vnode *)fp->f_data, &vattr, cred, p))
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
fp->f_offset = uap->offset + vattr.va_size;
|
fp->f_offset = uap->offset + vattr.va_size;
|
||||||
break;
|
break;
|
||||||
@ -1028,7 +1054,8 @@ access(p, uap, retval)
|
|||||||
cred->cr_uid = p->p_cred->p_ruid;
|
cred->cr_uid = p->p_cred->p_ruid;
|
||||||
cred->cr_groups[0] = p->p_cred->p_rgid;
|
cred->cr_groups[0] = p->p_cred->p_rgid;
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
goto out1;
|
goto out1;
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
|
|
||||||
@ -1072,7 +1099,8 @@ ostat(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
error = vn_stat(nd.ni_vp, &sb, p);
|
error = vn_stat(nd.ni_vp, &sb, p);
|
||||||
vput(nd.ni_vp);
|
vput(nd.ni_vp);
|
||||||
@ -1105,7 +1133,8 @@ olstat(p, uap, retval)
|
|||||||
|
|
||||||
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
|
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
|
||||||
uap->path, p);
|
uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
/*
|
/*
|
||||||
* For symbolic links, always return the attributes of its
|
* For symbolic links, always return the attributes of its
|
||||||
@ -1193,7 +1222,8 @@ stat(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
error = vn_stat(nd.ni_vp, &sb, p);
|
error = vn_stat(nd.ni_vp, &sb, p);
|
||||||
vput(nd.ni_vp);
|
vput(nd.ni_vp);
|
||||||
@ -1224,7 +1254,8 @@ lstat(p, uap, retval)
|
|||||||
|
|
||||||
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
|
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
|
||||||
uap->path, p);
|
uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
/*
|
/*
|
||||||
* For symbolic links, always return the attributes of its
|
* For symbolic links, always return the attributes of its
|
||||||
@ -1280,7 +1311,8 @@ pathconf(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
|
error = VOP_PATHCONF(nd.ni_vp, uap->name, retval);
|
||||||
vput(nd.ni_vp);
|
vput(nd.ni_vp);
|
||||||
@ -1309,7 +1341,8 @@ readlink(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp->v_type != VLNK)
|
if (vp->v_type != VLNK)
|
||||||
@ -1351,7 +1384,8 @@ chflags(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1386,7 +1420,8 @@ fchflags(p, uap, retval)
|
|||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = (struct vnode *)fp->f_data;
|
vp = (struct vnode *)fp->f_data;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1422,7 +1457,8 @@ chmod(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1457,7 +1493,8 @@ fchmod(p, uap, retval)
|
|||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = (struct vnode *)fp->f_data;
|
vp = (struct vnode *)fp->f_data;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1494,7 +1531,8 @@ chown(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1531,7 +1569,8 @@ fchown(p, uap, retval)
|
|||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = (struct vnode *)fp->f_data;
|
vp = (struct vnode *)fp->f_data;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1573,10 +1612,14 @@ utimes(p, uap, retval)
|
|||||||
microtime(&tv[0]);
|
microtime(&tv[0]);
|
||||||
tv[1] = tv[0];
|
tv[1] = tv[0];
|
||||||
vattr.va_vaflags |= VA_UTIMES_NULL;
|
vattr.va_vaflags |= VA_UTIMES_NULL;
|
||||||
} else if (error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv)))
|
} else {
|
||||||
return (error);
|
error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
|
||||||
|
if (error)
|
||||||
|
return (error);
|
||||||
|
}
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1617,7 +1660,8 @@ truncate(p, uap, retval)
|
|||||||
if (uap->length < 0)
|
if (uap->length < 0)
|
||||||
return(EINVAL);
|
return(EINVAL);
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
LEASE_CHECK(vp, p, p->p_ucred, LEASE_WRITE);
|
||||||
@ -1656,7 +1700,8 @@ ftruncate(p, uap, retval)
|
|||||||
|
|
||||||
if (uap->length < 0)
|
if (uap->length < 0)
|
||||||
return(EINVAL);
|
return(EINVAL);
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
if ((fp->f_flag & FWRITE) == 0)
|
if ((fp->f_flag & FWRITE) == 0)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
@ -1735,7 +1780,8 @@ fsync(p, uap, retval)
|
|||||||
struct file *fp;
|
struct file *fp;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = (struct vnode *)fp->f_data;
|
vp = (struct vnode *)fp->f_data;
|
||||||
VOP_LOCK(vp);
|
VOP_LOCK(vp);
|
||||||
@ -1765,12 +1811,14 @@ rename(p, uap, retval)
|
|||||||
|
|
||||||
NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
|
NDINIT(&fromnd, DELETE, WANTPARENT | SAVESTART, UIO_USERSPACE,
|
||||||
uap->from, p);
|
uap->from, p);
|
||||||
if (error = namei(&fromnd))
|
error = namei(&fromnd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
fvp = fromnd.ni_vp;
|
fvp = fromnd.ni_vp;
|
||||||
NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
|
NDINIT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART,
|
||||||
UIO_USERSPACE, uap->to, p);
|
UIO_USERSPACE, uap->to, p);
|
||||||
if (error = namei(&tond)) {
|
error = namei(&tond);
|
||||||
|
if (error) {
|
||||||
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
|
VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd);
|
||||||
vrele(fromnd.ni_dvp);
|
vrele(fromnd.ni_dvp);
|
||||||
vrele(fvp);
|
vrele(fvp);
|
||||||
@ -1851,7 +1899,8 @@ mkdir(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, CREATE, LOCKPARENT, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp != NULL) {
|
if (vp != NULL) {
|
||||||
@ -1891,7 +1940,8 @@ rmdir(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp->v_type != VDIR) {
|
if (vp->v_type != VDIR) {
|
||||||
@ -1951,7 +2001,8 @@ ogetdirentries(p, uap, retval)
|
|||||||
int error, readcnt;
|
int error, readcnt;
|
||||||
long loff;
|
long loff;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
if ((fp->f_flag & FREAD) == 0)
|
if ((fp->f_flag & FREAD) == 0)
|
||||||
return (EBADF);
|
return (EBADF);
|
||||||
@ -2048,7 +2099,8 @@ getdirentries(p, uap, retval)
|
|||||||
long loff;
|
long loff;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (error = getvnode(p->p_fd, uap->fd, &fp))
|
error = getvnode(p->p_fd, uap->fd, &fp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
if ((fp->f_flag & FREAD) == 0)
|
if ((fp->f_flag & FREAD) == 0)
|
||||||
return (EBADF);
|
return (EBADF);
|
||||||
@ -2158,14 +2210,16 @@ revoke(p, uap, retval)
|
|||||||
struct nameidata nd;
|
struct nameidata nd;
|
||||||
|
|
||||||
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, uap->path, p);
|
||||||
if (error = namei(&nd))
|
error = namei(&nd);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = nd.ni_vp;
|
vp = nd.ni_vp;
|
||||||
if (vp->v_type != VCHR && vp->v_type != VBLK) {
|
if (vp->v_type != VCHR && vp->v_type != VBLK) {
|
||||||
error = EINVAL;
|
error = EINVAL;
|
||||||
goto out;
|
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;
|
goto out;
|
||||||
if (p->p_ucred->cr_uid != vattr.va_uid &&
|
if (p->p_ucred->cr_uid != vattr.va_uid &&
|
||||||
(error = suser(p->p_ucred, &p->p_acflag)))
|
(error = suser(p->p_ucred, &p->p_acflag)))
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)vfs_vnops.c 8.2 (Berkeley) 1/21/94
|
* @(#)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>
|
#include <sys/param.h>
|
||||||
@ -78,15 +78,17 @@ vn_open(ndp, fmode, cmode)
|
|||||||
ndp->ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
|
ndp->ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
|
||||||
if ((fmode & O_EXCL) == 0)
|
if ((fmode & O_EXCL) == 0)
|
||||||
ndp->ni_cnd.cn_flags |= FOLLOW;
|
ndp->ni_cnd.cn_flags |= FOLLOW;
|
||||||
if (error = namei(ndp))
|
error = namei(ndp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
if (ndp->ni_vp == NULL) {
|
if (ndp->ni_vp == NULL) {
|
||||||
VATTR_NULL(vap);
|
VATTR_NULL(vap);
|
||||||
vap->va_type = VREG;
|
vap->va_type = VREG;
|
||||||
vap->va_mode = cmode;
|
vap->va_mode = cmode;
|
||||||
LEASE_CHECK(ndp->ni_dvp, p, cred, LEASE_WRITE);
|
LEASE_CHECK(ndp->ni_dvp, p, cred, LEASE_WRITE);
|
||||||
if (error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
|
error = VOP_CREATE(ndp->ni_dvp, &ndp->ni_vp,
|
||||||
&ndp->ni_cnd, vap))
|
&ndp->ni_cnd, vap);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
fmode &= ~O_TRUNC;
|
fmode &= ~O_TRUNC;
|
||||||
vp = ndp->ni_vp;
|
vp = ndp->ni_vp;
|
||||||
@ -107,7 +109,8 @@ vn_open(ndp, fmode, cmode)
|
|||||||
} else {
|
} else {
|
||||||
ndp->ni_cnd.cn_nameiop = LOOKUP;
|
ndp->ni_cnd.cn_nameiop = LOOKUP;
|
||||||
ndp->ni_cnd.cn_flags = FOLLOW | LOCKLEAF;
|
ndp->ni_cnd.cn_flags = FOLLOW | LOCKLEAF;
|
||||||
if (error = namei(ndp))
|
error = namei(ndp);
|
||||||
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
vp = ndp->ni_vp;
|
vp = ndp->ni_vp;
|
||||||
}
|
}
|
||||||
@ -117,7 +120,8 @@ vn_open(ndp, fmode, cmode)
|
|||||||
}
|
}
|
||||||
if ((fmode & O_CREAT) == 0) {
|
if ((fmode & O_CREAT) == 0) {
|
||||||
if (fmode & FREAD) {
|
if (fmode & FREAD) {
|
||||||
if (error = VOP_ACCESS(vp, VREAD, cred, p))
|
error = VOP_ACCESS(vp, VREAD, cred, p);
|
||||||
|
if (error)
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
if (fmode & (FWRITE | O_TRUNC)) {
|
if (fmode & (FWRITE | O_TRUNC)) {
|
||||||
@ -125,8 +129,11 @@ vn_open(ndp, fmode, cmode)
|
|||||||
error = EISDIR;
|
error = EISDIR;
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
if ((error = vn_writechk(vp)) ||
|
error = vn_writechk(vp);
|
||||||
(error = VOP_ACCESS(vp, VWRITE, cred, p)))
|
if(error)
|
||||||
|
goto bad;
|
||||||
|
error = VOP_ACCESS(vp, VWRITE, cred, p);
|
||||||
|
if(error)
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,10 +143,12 @@ vn_open(ndp, fmode, cmode)
|
|||||||
VOP_LOCK(vp); /* XXX */
|
VOP_LOCK(vp); /* XXX */
|
||||||
VATTR_NULL(vap);
|
VATTR_NULL(vap);
|
||||||
vap->va_size = 0;
|
vap->va_size = 0;
|
||||||
if (error = VOP_SETATTR(vp, vap, cred, p))
|
error = VOP_SETATTR(vp, vap, cred, p);
|
||||||
|
if (error)
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
if (error = VOP_OPEN(vp, fmode, cred, p))
|
error = VOP_OPEN(vp, fmode, cred, p);
|
||||||
|
if (error)
|
||||||
goto bad;
|
goto bad;
|
||||||
if (fmode & FWRITE)
|
if (fmode & FWRITE)
|
||||||
vp->v_writecount++;
|
vp->v_writecount++;
|
||||||
@ -168,6 +177,8 @@ vn_writechk(vp)
|
|||||||
switch (vp->v_type) {
|
switch (vp->v_type) {
|
||||||
case VREG: case VDIR: case VLNK:
|
case VREG: case VDIR: case VLNK:
|
||||||
return (EROFS);
|
return (EROFS);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -381,7 +392,8 @@ vn_ioctl(fp, com, data, p)
|
|||||||
case VREG:
|
case VREG:
|
||||||
case VDIR:
|
case VDIR:
|
||||||
if (com == FIONREAD) {
|
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);
|
return (error);
|
||||||
*(int *)data = vattr.va_size - fp->f_offset;
|
*(int *)data = vattr.va_size - fp->f_offset;
|
||||||
return (0);
|
return (0);
|
||||||
|
Loading…
Reference in New Issue
Block a user