projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
first bootable version
[unix-history]
/
usr
/
src
/
sys
/
kern
/
vfs_vnops.c
diff --git
a/usr/src/sys/kern/vfs_vnops.c
b/usr/src/sys/kern/vfs_vnops.c
index
be70be5
..
19077a0
100644
(file)
--- a/
usr/src/sys/kern/vfs_vnops.c
+++ b/
usr/src/sys/kern/vfs_vnops.c
@@
-1,4
+1,4
@@
-/* vfs_vnops.c
3.1 %H%
*/
+/* vfs_vnops.c
4.13 81/10/11
*/
#include "../h/param.h"
#include "../h/systm.h"
#include "../h/param.h"
#include "../h/systm.h"
@@
-10,6
+10,7
@@
#include "../h/inode.h"
#include "../h/reg.h"
#include "../h/acct.h"
#include "../h/inode.h"
#include "../h/reg.h"
#include "../h/acct.h"
+#include "../h/mount.h"
/*
* Convert a user supplied
/*
* Convert a user supplied
@@
-24,13
+25,11
@@
register int f;
{
register struct file *fp;
{
register struct file *fp;
- if(0 <= f && f < NOFILE) {
- fp = u.u_ofile[f];
- if(fp != NULL)
- return(fp);
+ if ((unsigned)f >= NOFILE || (fp = u.u_ofile[f]) == NULL) {
+ u.u_error = EBADF;
+ return (NULL);
}
}
- u.u_error = EBADF;
- return(NULL);
+ return (fp);
}
/*
}
/*
@@
-48,10
+47,10
@@
closef(fp)
register struct file *fp;
{
register struct inode *ip;
register struct file *fp;
{
register struct inode *ip;
+ register struct mount *mp;
int flag, mode;
dev_t dev;
register int (*cfunc)();
int flag, mode;
dev_t dev;
register int (*cfunc)();
- struct chan *cp;
if(fp == NULL)
return;
if(fp == NULL)
return;
@@
-59,45
+58,63
@@
register struct file *fp;
fp->f_count--;
return;
}
fp->f_count--;
return;
}
- ip = fp->f_inode;
flag = fp->f_flag;
flag = fp->f_flag;
- cp = fp->f_un.f_chan;
+#ifdef BBNNET
+ if (flag&FNET) {
+ netclose(fp);
+ return;
+ }
+#endif
+ if (flag & FPORT) {
+ ptclose(fp);
+ fp->f_count = 0;
+ return;
+ }
+ ip = fp->f_inode;
dev = (dev_t)ip->i_un.i_rdev;
dev = (dev_t)ip->i_un.i_rdev;
- mode = ip->i_mode;
-
+ mode = ip->i_mode & IFMT;
plock(ip);
plock(ip);
- fp->f_count = 0;
- if(flag & FPIPE) {
- ip->i_mode &= ~(IREAD|IWRITE);
- wakeup((caddr_t)ip+1);
- wakeup((caddr_t)ip+2);
- }
iput(ip);
iput(ip);
+ fp->f_count = 0;
- switch
(mode&IFMT
) {
+ switch
(mode
) {
case IFCHR:
case IFCHR:
- case IFMPC:
cfunc = cdevsw[major(dev)].d_close;
break;
case IFBLK:
cfunc = cdevsw[major(dev)].d_close;
break;
case IFBLK:
- case IFMPB:
+ /*
+ * We don't want to really close the device if it is mounted
+ */
+ for (mp = mount; mp < &mount[NMOUNT]; mp++)
+ if (mp->m_bufp != NULL && mp->m_dev == dev)
+ return;
cfunc = bdevsw[major(dev)].d_close;
break;
default:
return;
}
cfunc = bdevsw[major(dev)].d_close;
break;
default:
return;
}
- if (flag & FMP)
- goto call;
-
- for(fp=file; fp < &file[NFILE]; fp++)
- if (fp->f_count && fp->f_inode==ip)
+ for(fp=file; fp < fileNFILE; fp++) {
+#ifdef BBNNET
+ if (fp->f_flag & FNET)
+ continue;
+#endif
+ if (fp->f_count && (ip = fp->f_inode) &&
+ ip->i_un.i_rdev == dev &&
+ (ip->i_mode&IFMT) == mode)
return;
return;
-
-call:
- (*cfunc)(dev, flag, cp);
+ }
+ if (mode == IFBLK) {
+ /*
+ * on last close of a block device (that isn't mounted)
+ * we must invalidate any in core blocks
+ */
+ bflush(dev);
+ binval(dev);
+ }
+ (*cfunc)(dev, flag, fp);
}
/*
}
/*
@@
-116,14
+133,12
@@
register struct inode *ip;
switch(ip->i_mode&IFMT) {
case IFCHR:
switch(ip->i_mode&IFMT) {
case IFCHR:
- case IFMPC:
if(maj >= nchrdev)
goto bad;
(*cdevsw[maj].d_open)(dev, rw);
break;
case IFBLK:
if(maj >= nchrdev)
goto bad;
(*cdevsw[maj].d_open)(dev, rw);
break;
case IFBLK:
- case IFMPB:
if(maj >= nblkdev)
goto bad;
(*bdevsw[maj].d_open)(dev, rw);
if(maj >= nblkdev)
goto bad;
(*bdevsw[maj].d_open)(dev, rw);
@@
-235,14
+250,12
@@
ufalloc()
return(-1);
}
return(-1);
}
+struct file *lastf;
/*
* Allocate a user file descriptor
* and a file structure.
* Initialize the descriptor
* to point at the file structure.
/*
* Allocate a user file descriptor
* and a file structure.
* Initialize the descriptor
* to point at the file structure.
- *
- * no file -- if there are no available
- * file structures.
*/
struct file *
falloc()
*/
struct file *
falloc()
@@
-251,16
+264,24
@@
falloc()
register i;
i = ufalloc();
register i;
i = ufalloc();
- if(i < 0)
+ if
(i < 0)
return(NULL);
return(NULL);
- for(fp = &file[0]; fp < &file[NFILE]; fp++)
- if(fp->f_count == 0) {
- u.u_ofile[i] = fp;
- fp->f_count++;
- fp->f_un.f_offset = 0;
- return(fp);
- }
- printf("no file\n");
+ if (lastf == 0)
+ lastf = file;
+ for (fp = lastf; fp < fileNFILE; fp++)
+ if (fp->f_count == 0)
+ goto slot;
+ for (fp = file; fp < lastf; fp++)
+ if (fp->f_count == 0)
+ goto slot;
+ tablefull("file");
u.u_error = ENFILE;
u.u_error = ENFILE;
- return(NULL);
+ return (NULL);
+slot:
+ u.u_ofile[i] = fp;
+ fp->f_count++;
+ fp->f_un.f_offset = 0;
+ fp->f_inode = 0;
+ lastf = fp + 1;
+ return (fp);
}
}