do not call close operator of the f_ops vector has not yet been set
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 20 Apr 1994 13:15:25 +0000 (05:15 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 20 Apr 1994 13:15:25 +0000 (05:15 -0800)
SCCS-vsn: sys/kern/kern_descrip.c 8.6

usr/src/sys/kern/kern_descrip.c

index 75e9027..d4cfa73 100644 (file)
@@ -9,7 +9,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)kern_descrip.c      8.5 (Berkeley) %G%
+ *     @(#)kern_descrip.c      8.6 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -562,6 +562,7 @@ 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);
+       bzero(fp, sizeof(struct file));
        if (fq = p->p_fd->fd_ofiles[0])
                fpp = &fq->f_filef;
        else
        if (fq = p->p_fd->fd_ofiles[0])
                fpp = &fq->f_filef;
        else
@@ -573,8 +574,6 @@ falloc(p, resultfp, resultfd)
        fp->f_fileb = fpp;
        *fpp = fp;
        fp->f_count = 1;
        fp->f_fileb = fpp;
        *fpp = fp;
        fp->f_count = 1;
-       fp->f_msgcount = 0;
-       fp->f_offset = 0;
        fp->f_cred = p->p_ucred;
        crhold(fp->f_cred);
        if (resultfp)
        fp->f_cred = p->p_ucred;
        crhold(fp->f_cred);
        if (resultfp)
@@ -727,7 +726,10 @@ closef(fp, p)
                vp = (struct vnode *)fp->f_data;
                (void) VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK);
        }
                vp = (struct vnode *)fp->f_data;
                (void) VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK);
        }
-       error = (*fp->f_ops->fo_close)(fp, p);
+       if (fp->f_ops)
+               error = (*fp->f_ops->fo_close)(fp, p);
+       else
+               error = 0;
        ffree(fp);
        return (error);
 }
        ffree(fp);
        return (error);
 }