only delete space used by inode, on inode deletion; required
[unix-history] / usr / src / sys / kern / kern_descrip.c
index 7432e54..ca1a201 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)kern_descrip.c      7.26 (Berkeley) %G%
+ *     @(#)kern_descrip.c      7.30 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
@@ -457,11 +457,11 @@ falloc(p, resultfp, resultfd)
         */
        nfiles++;
        MALLOC(fp, struct file *, sizeof(struct file), M_FILE, M_WAITOK);
         */
        nfiles++;
        MALLOC(fp, struct file *, sizeof(struct file), M_FILE, M_WAITOK);
-       p->p_fd->fd_ofiles[i] = fp;
        if (fq = p->p_fd->fd_ofiles[0])
                fpp = &fq->f_filef;
        else
                fpp = &filehead;
        if (fq = p->p_fd->fd_ofiles[0])
                fpp = &fq->f_filef;
        else
                fpp = &filehead;
+       p->p_fd->fd_ofiles[i] = fp;
        if (fq = *fpp)
                fq->f_fileb = &fp->f_filef;
        fp->f_filef = fq;
        if (fq = *fpp)
                fq->f_fileb = &fp->f_filef;
        fp->f_filef = fq;
@@ -581,6 +581,8 @@ fdfree(p)
 /*
  * Internal form of close.
  * Decrement reference count on file structure.
 /*
  * Internal form of close.
  * Decrement reference count on file structure.
+ * Note: p may be NULL when closing a file
+ * that was being passed in a message.
  */
 closef(fp, p)
        register struct file *fp;
  */
 closef(fp, p)
        register struct file *fp;
@@ -597,8 +599,10 @@ closef(fp, p)
         * locks owned by this process.  This is handled by setting
         * a flag in the unlock to free ONLY locks obeying POSIX
         * semantics, and not to free BSD-style file locks.
         * locks owned by this process.  This is handled by setting
         * a flag in the unlock to free ONLY locks obeying POSIX
         * semantics, and not to free BSD-style file locks.
+        * If the descriptor was in a message, POSIX-style locks
+        * aren't passed with the descriptor.
         */
         */
-       if ((p->p_flag & SADVLCK) && fp->f_type == DTYPE_VNODE) {
+       if (p && (p->p_flag & SADVLCK) && fp->f_type == DTYPE_VNODE) {
                lf.l_whence = SEEK_SET;
                lf.l_start = 0;
                lf.l_len = 0;
                lf.l_whence = SEEK_SET;
                lf.l_start = 0;
                lf.l_len = 0;
@@ -680,9 +684,10 @@ flock(p, uap, retval)
  * references to this file will be direct to the other driver.
  */
 /* ARGSUSED */
  * references to this file will be direct to the other driver.
  */
 /* ARGSUSED */
-fdopen(dev, mode, type)
+fdopen(dev, mode, type, p)
        dev_t dev;
        int mode, type;
        dev_t dev;
        int mode, type;
+       struct proc *p;
 {
 
        /*
 {
 
        /*
@@ -693,7 +698,7 @@ fdopen(dev, mode, type)
         * actions in dupfdopen below. Other callers of vn_open or VOP_OPEN
         * will simply report the error.
         */
         * actions in dupfdopen below. Other callers of vn_open or VOP_OPEN
         * will simply report the error.
         */
-       curproc->p_dupfd = minor(dev);          /* XXX */
+       p->p_dupfd = minor(dev);
        return (ENODEV);
 }
 
        return (ENODEV);
 }