sys/vfs/msdosfs: Cleanups
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 1 Sep 2019 12:30:12 +0000 (21:30 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Sun, 1 Sep 2019 15:43:24 +0000 (00:43 +0900)
sys/vfs/msdosfs/msdosfs_denode.c
sys/vfs/msdosfs/msdosfs_fat.c
sys/vfs/msdosfs/msdosfs_vfsops.c
sys/vfs/msdosfs/msdosfs_vnops.c

index 2d00af8..9c4dcda 100644 (file)
@@ -415,7 +415,7 @@ again:
                 */
                if ((diroffset == 0) && (ldep->de_StartCluster != dirclust)) {
                        kprintf("deget(): . entry at clust %ld != %ld\n",
-                                       dirclust, ldep->de_StartCluster);
+                               dirclust, ldep->de_StartCluster);
                        ldep->de_StartCluster = dirclust;
                }
 
@@ -592,7 +592,7 @@ detrunc(struct denode *dep, u_long length, int flags)
                allerror = error;
 #ifdef MSDOSFS_DEBUG
        kprintf("detrunc(): allerror %d, eofentry %lu\n",
-              allerror, eofentry);
+               allerror, eofentry);
 #endif
 
        /*
@@ -728,7 +728,7 @@ msdosfs_inactive(struct vop_inactive_args *ap)
         */
 #ifdef MSDOSFS_DEBUG
        kprintf("msdosfs_inactive(): dep %p, refcnt %ld, mntflag %x, MNT_RDONLY %x\n",
-              dep, dep->de_refcnt, vp->v_mount->mnt_flag, MNT_RDONLY);
+               dep, dep->de_refcnt, vp->v_mount->mnt_flag, MNT_RDONLY);
 #endif
        if (dep->de_refcnt <= 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) {
                error = detrunc(dep, (u_long) 0, 0);
index 96e817d..119b51f 100644 (file)
@@ -417,7 +417,6 @@ updatefats(struct msdosfsmount *pmp, struct buf *bp, u_long fatbn)
 static __inline void
 usemap_alloc(struct msdosfsmount *pmp, u_long cn)
 {
-
        pmp->pm_inusemap[cn / N_INUSEBITS] |= 1 << (cn % N_INUSEBITS);
        pmp->pm_freeclustercount--;
 }
@@ -425,7 +424,6 @@ usemap_alloc(struct msdosfsmount *pmp, u_long cn)
 static __inline void
 usemap_free(struct msdosfsmount *pmp, u_long cn)
 {
-
        pmp->pm_freeclustercount++;
        pmp->pm_inusemap[cn / N_INUSEBITS] &= ~(1 << (cn % N_INUSEBITS));
 }
@@ -480,9 +478,9 @@ fatentry(int function, struct msdosfsmount *pmp, u_long cn, u_long *oldcontents,
        u_long bn, bo, bsize, byteoffset;
        struct buf *bp;
 
-#ifdef MSDOSFS_DEBUG
+#ifdef MSDOSFS_DEBUG
        kprintf("fatentry(func %d, pmp %p, clust %lu, oldcon %p, newcon %lx)\n",
-            function, pmp, cn, oldcontents, newcontents);
+               function, pmp, cn, oldcontents, newcontents);
 #endif
 
 #ifdef DIAGNOSTIC
@@ -850,7 +848,8 @@ freeclusterchain(struct msdosfsmount *pmp, u_long cluster)
                case FAT32_MASK:
                        cluster = getulong(&bp->b_data[bo]);
                        putulong(&bp->b_data[bo],
-                                (MSDOSFSFREE & FAT32_MASK) | (cluster & ~FAT32_MASK));
+                                (MSDOSFSFREE & FAT32_MASK) |
+                                (cluster & ~FAT32_MASK));
                        break;
                }
                cluster &= pmp->pm_fatmask;
index 9da748a..76a037f 100644 (file)
@@ -129,18 +129,17 @@ update_mp(struct mount *mp, struct msdosfs_args *argp)
                        return error;
        }
 
-       if (pmp->pm_flags & MSDOSFSMNT_NOWIN95)
+       if (pmp->pm_flags & MSDOSFSMNT_NOWIN95) {
                pmp->pm_flags |= MSDOSFSMNT_SHORTNAME;
-       else if (!(pmp->pm_flags &
+       else if (!(pmp->pm_flags &
            (MSDOSFSMNT_SHORTNAME | MSDOSFSMNT_LONGNAME))) {
-               struct vnode *rootvp;
-
                /*
                 * Try to divine whether to support Win'95 long filenames
                 */
-               if (FAT32(pmp))
+               if (FAT32(pmp)) {
                        pmp->pm_flags |= MSDOSFSMNT_LONGNAME;
-               else {
+               } else {
+                       struct vnode *rootvp;
                        if ((error = msdosfs_root(mp, &rootvp)) != 0)
                                return error;
                        pmp->pm_flags |= findwin95(VTODE(rootvp))
@@ -180,7 +179,8 @@ msdosfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
        if (mp->mnt_flag & MNT_UPDATE) {
                pmp = VFSTOMSDOSFS(mp);
                error = 0;
-               if (!(pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_flag & MNT_RDONLY)) {
+               if (!(pmp->pm_flags & MSDOSFSMNT_RONLY) &&
+                   (mp->mnt_flag & MNT_RDONLY)) {
                        flags = WRITECLOSE;
                        if (mp->mnt_flag & MNT_FORCE)
                                flags |= FORCECLOSE;
@@ -199,7 +199,8 @@ msdosfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
                        error = EOPNOTSUPP;
                if (error)
                        return (error);
-               if ((pmp->pm_flags & MSDOSFSMNT_RONLY) && (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
+               if ((pmp->pm_flags & MSDOSFSMNT_RONLY) &&
+                   (mp->mnt_kern_flag & MNTK_WANTRDWR)) {
                        /*
                         * If upgrade to read-write by non-root, then verify
                         * that user has necessary permissions on the device.
@@ -207,7 +208,8 @@ msdosfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
                        devvp = pmp->pm_devvp;
                        vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY);
                        if (cred->cr_uid != 0) {
-                               error = VOP_EACCESS(devvp, VREAD | VWRITE, cred);
+                               error = VOP_EACCESS(devvp, VREAD | VWRITE,
+                                                   cred);
                                if (error) {
                                        vn_unlock(devvp);
                                        return (error);
@@ -219,7 +221,7 @@ msdosfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
                        pmp->pm_flags &= ~MSDOSFSMNT_RONLY;
                }
                if (args.fspec == NULL) {
-#ifdef __notyet__              /* doesn't work correctly with current mountd   XXX */
+#ifdef __notyet__      /* doesn't work correctly with current mountd XXX */
                        if (args.flags & MSDOSFSMNT_MNTOPT) {
                                pmp->pm_flags &= ~MSDOSFSMNT_MNTOPT;
                                pmp->pm_flags |= args.flags & MSDOSFSMNT_MNTOPT;
@@ -293,7 +295,8 @@ msdosfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
        bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
        msdosfs_statfs(mp, &mp->mnt_stat, cred);
 #ifdef MSDOSFS_DEBUG
-       kprintf("msdosfs_mount(): mp %p, pmp %p, inusemap %p\n", mp, pmp, pmp->pm_inusemap);
+       kprintf("msdosfs_mount(): mp %p, pmp %p, inusemap %p\n",
+               mp, pmp, pmp->pm_inusemap);
 #endif
        return (0);
 }
@@ -636,7 +639,9 @@ msdosfs_unmount(struct mount *mp, int mntflags)
 {
        struct msdosfsmount *pmp;
        int error, flags;
-
+#ifdef MSDOSFS_DEBUG
+       struct vnode *vp;
+#endif
        flags = 0;
        if (mntflags & MNT_FORCE)
                flags |= FORCECLOSE;
@@ -655,28 +660,22 @@ msdosfs_unmount(struct mount *mp, int mntflags)
                if(pmp->pm_u2d)
                        msdos_iconv->close(pmp->pm_u2d);
        }
+
 #ifdef MSDOSFS_DEBUG
-       {
-               struct vnode *vp = pmp->pm_devvp;
-
-               kprintf("msdosfs_umount(): just before calling VOP_CLOSE()\n");
-               kprintf("flag %08x, refcnt 0x%08x, writecount %d, "
-                       "auxrefs 0x%08x\n",
-                       vp->v_flag, vp->v_refcnt,
-                       vp->v_writecount, vp->v_auxrefs);
-               kprintf("mount %p, op %p\n", vp->v_mount, vp->v_ops);
-               kprintf("mount %p\n", vp->v_mount);
-               kprintf("cleanblkhd %p, dirtyblkhd %p, numoutput %d, type %d\n",
-                   RB_ROOT(&vp->v_rbclean_tree),
-                   RB_ROOT(&vp->v_rbdirty_tree),
-                   bio_track_active(&vp->v_track_write),
-                   vp->v_type);
-               kprintf("union %p, tag %d, data[0] %08x, data[1] %08x\n",
-                   vp->v_socket, vp->v_tag,
-                   ((u_int *)vp->v_data)[0],
-                   ((u_int *)vp->v_data)[1]);
-       }
+       vp = pmp->pm_devvp;
+       kprintf("msdosfs_umount(): just before calling VOP_CLOSE()\n");
+       kprintf("flag %08x, refcnt 0x%08x, writecount %d, auxrefs 0x%08x\n",
+               vp->v_flag, vp->v_refcnt, vp->v_writecount, vp->v_auxrefs);
+       kprintf("mount %p, op %p\n", vp->v_mount, vp->v_ops);
+       kprintf("mount %p\n", vp->v_mount);
+       kprintf("cleanblkhd %p, dirtyblkhd %p, numoutput %d, type %d\n",
+               RB_ROOT(&vp->v_rbclean_tree), RB_ROOT(&vp->v_rbdirty_tree),
+               bio_track_active(&vp->v_track_write), vp->v_type);
+       kprintf("union %p, tag %d, data[0] %08x, data[1] %08x\n",
+               vp->v_socket, vp->v_tag, ((u_int *)vp->v_data)[0],
+               ((u_int *)vp->v_data)[1]);
 #endif
+
        vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY);
        error = VOP_CLOSE(pmp->pm_devvp,
                    (pmp->pm_flags&MSDOSFSMNT_RONLY) ? FREAD : FREAD | FWRITE,
index a1652aa..96ad3b8 100644 (file)
@@ -175,10 +175,8 @@ msdosfs_mknod(struct vop_old_mknod_args *ap)
        switch (ap->a_vap->va_type) {
        case VDIR:
                return (msdosfs_mkdir((struct vop_old_mkdir_args *)ap));
-               break;
        case VREG:
                return (msdosfs_create((struct vop_old_create_args *)ap));
-               break;
        default:
                return (EINVAL);
        }
@@ -1551,10 +1549,6 @@ msdosfs_readdir(struct vop_readdir_args *ap)
         */
        if (dep->de_StartCluster == MSDOSFSROOT
            || (FAT32(pmp) && dep->de_StartCluster == pmp->pm_rootdirblk)) {
-#if 0
-               kprintf("msdosfs_readdir(): going after . or .. in root dir, offset %d\n",
-                   offset);
-#endif
                bias = 2 * sizeof(struct direntry);
                if (offset < bias) {
                        for (n = (int)offset / sizeof(struct direntry); n < 2;
@@ -1618,10 +1612,6 @@ msdosfs_readdir(struct vop_readdir_args *ap)
                for (dentp = (struct direntry *)(bp->b_data + on);
                     (char *)dentp < bp->b_data + on + n;
                     dentp++, offset += sizeof(struct direntry)) {
-#if 0
-                       kprintf("rd: dentp %08x prev %08x crnt %08x deName %02x attr %02x\n",
-                           dentp, prev, crnt, dentp->deName[0], dentp->deAttributes);
-#endif
                        d_name = d_name_storage;
                        d_namlen = 0;
                        /*