Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/lfs Fix obvious bugs:



details:   https://anonhg.NetBSD.org/src/rev/d8db28a4abda
branches:  trunk
changeset: 471537:d8db28a4abda
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Sun Apr 04 09:56:44 1999 +0000

description:
Fix obvious bugs:
* The MNT_UPDATE case had a null pointer dereference.  (This is a good example
  of why blindly adding bogus initializiers is a FUNDAMENTALLY BAD IDEA!)
* Make sure the whole ufsmount is zeroed, as the export code relies on this.
* If we decided to use the second/alternate superblock, make sure to copy the
  in-core version from the right buffer.
Also, reenable NFS exporting.

diffstat:

 sys/ufs/lfs/lfs_vfsops.c |  22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diffs (77 lines):

diff -r 3e8acd9dca4c -r d8db28a4abda sys/ufs/lfs/lfs_vfsops.c
--- a/sys/ufs/lfs/lfs_vfsops.c  Sun Apr 04 09:10:27 1999 +0000
+++ b/sys/ufs/lfs/lfs_vfsops.c  Sun Apr 04 09:56:44 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs_vfsops.c,v 1.28 1999/03/25 21:39:19 perseant Exp $ */
+/*     $NetBSD: lfs_vfsops.c,v 1.29 1999/04/04 09:56:44 mycroft Exp $  */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -212,9 +212,11 @@
        if (error)
                return (error);
 
+#if 0
        /* Until LFS can do NFS right.          XXX */
        if (args.export.ex_flags & MNT_EXPORTED)
                return (EINVAL);
+#endif
 
        /*
         * If updating, check whether changing from read-only to
@@ -222,6 +224,7 @@
         */
        if (mp->mnt_flag & MNT_UPDATE) {
                ump = VFSTOUFS(mp);
+               fs = ump->um_lfs;
                if (fs->lfs_ronly && (mp->mnt_flag & MNT_WANTRDWR)) {
                        /*
                         * If upgrade to read-write by non-root, then verify
@@ -338,12 +341,10 @@
        error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p);
        if (error)
                return (error);
-
        if (VOP_IOCTL(devvp, DIOCGPART, (caddr_t)&dpart, FREAD, cred, p) != 0)
                size = DEV_BSIZE;
-       else {
+       else
                size = dpart.disklab->d_secsize;
-       }
 
        /* Don't free random space on error. */
        bp = NULL;
@@ -364,7 +365,8 @@
        if (error)
                goto out;
        adfs = (struct dlfs *)abp->b_data;
-       if(adfs->dlfs_tstamp < dfs->dlfs_tstamp) /* XXX KS - 1s resolution? */
+
+       if (adfs->dlfs_tstamp < dfs->dlfs_tstamp) /* XXX KS - 1s resolution? */
                dfs = adfs;
 
        /* Check the basics. */
@@ -375,9 +377,11 @@
        }
 
        /* Allocate the mount structure, copy the superblock into it. */
-       ump = (struct ufsmount *)malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
-       fs = ump->um_lfs = malloc(sizeof(struct lfs), M_UFSMNT, M_WAITOK);
-       bcopy(bp->b_data, &(fs->lfs_dlfs), sizeof(struct dlfs));
+       fs = malloc(sizeof(struct lfs), M_UFSMNT, M_WAITOK);
+       memcpy(&fs->lfs_dlfs, dfs, sizeof(struct dlfs));
+       ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
+       memset((caddr_t)ump, 0, sizeof *ump);
+       ump->um_lfs = fs;
        if (sizeof(struct lfs) < LFS_SBPAD)                     /* XXX why? */
                bp->b_flags |= B_INVAL;
        brelse(bp);
@@ -393,7 +397,7 @@
        fs->lfs_sbactive = NULL;
 #endif
 #ifdef LFS_TRACK_IOS
-       for(i=0;i<LFS_THROTTLE;i++)
+       for (i=0;i<LFS_THROTTLE;i++)
                fs->lfs_pending[i] = LFS_UNUSED_DADDR;
 #endif
 



Home | Main Index | Thread Index | Old Index