Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/msdosfs tidy up debugging printfs; no functional change.



details:   https://anonhg.NetBSD.org/src/rev/3182439043a5
branches:  trunk
changeset: 784400:3182439043a5
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jan 27 20:15:58 2013 +0000

description:
tidy up debugging printfs; no functional change.

diffstat:

 sys/fs/msdosfs/msdosfs_fat.c |  60 ++++++++++++++++++++++++++-----------------
 1 files changed, 36 insertions(+), 24 deletions(-)

diffs (196 lines):

diff -r bb3f0ebf8b03 -r 3182439043a5 sys/fs/msdosfs/msdosfs_fat.c
--- a/sys/fs/msdosfs/msdosfs_fat.c      Sun Jan 27 20:05:46 2013 +0000
+++ b/sys/fs/msdosfs/msdosfs_fat.c      Sun Jan 27 20:15:58 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_fat.c,v 1.25 2013/01/26 16:51:51 christos Exp $        */
+/*     $NetBSD: msdosfs_fat.c,v 1.26 2013/01/27 20:15:58 christos Exp $        */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -52,7 +52,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.25 2013/01/26 16:51:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_fat.c,v 1.26 2013/01/27 20:15:58 christos Exp $");
 
 /*
  * kernel include files.
@@ -97,6 +97,11 @@
 int pm_fatblocksize;
 
 #ifdef MSDOSFS_DEBUG
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
+#ifdef MSDOSFS_DEBUG
 void print_fat_stats(void);
 
 void
@@ -199,6 +204,7 @@
                return (0);
 
        cn = dep->de_StartCluster;
+       DPRINTF(("%s(start cluster=%lu)\n", __func__, cn));
        /*
         * The "file" that makes up the root directory is contiguous,
         * permanently allocated, of fixed size, and is not made up of
@@ -210,6 +216,8 @@
                        if (de_cn2off(pmp, findcn) >= dep->de_FileSize) {
                                if (cnp)
                                        *cnp = de_bn2cn(pmp, pmp->pm_rootdirsize);
+                               DPRINTF(("%s(root, %lu ETOOBIG)\n", __func__,
+                                   de_cn2off(pmp, findcn)));
                                return (E2BIG);
                        }
                        if (bnp)
@@ -219,10 +227,14 @@
                        if (sp)
                                *sp = min(pmp->pm_bpcluster,
                                    dep->de_FileSize - de_cn2off(pmp, findcn));
+                       DPRINTF(("%s(root, bn=%lu, cn=%u)\n", __func__,
+                           pmp->pm_rootdirblk + de_cn2bn(pmp, findcn),
+                           MSDOSFSROOT));
                        return (0);
                } else {                /* just an empty file */
                        if (cnp)
                                *cnp = 0;
+                       DPRINTF(("%s(root, empty ETOOBIG)\n", __func__));
                        return (E2BIG);
                }
        }
@@ -240,6 +252,8 @@
         */
        i = 0;
        fc_lookup(dep, findcn, &i, &cn);
+       DPRINTF(("%s(bpcluster=%lu i=%lu cn=%lu\n", __func__, pmp->pm_bpcluster,
+           i, cn));
        if ((bn = findcn - i) >= LMMAX) {
                fc_largedistance++;
                fc_wherefrom = i;
@@ -265,6 +279,7 @@
                        error = bread(pmp->pm_devvp, de_bn2kb(pmp, bn), bsize,
                            NOCRED, 0, &bp);
                        if (error) {
+                               DPRINTF(("%s(bread, %d)\n", __func__, error));
                                return (error);
                        }
                        bp_bn = bn;
@@ -273,6 +288,8 @@
                if (bo >= bsize) {
                        if (bp)
                                brelse(bp, 0);
+                       DPRINTF(("%s(block, %lu >= %lu)\n", __func__, bo,
+                           bsize));
                        return (EIO);
                }
                KASSERT(bp != NULL);
@@ -292,6 +309,8 @@
                        *bnp = cntobn(pmp, cn);
                if (cnp)
                        *cnp = cn;
+               DPRINTF(("%s(bn=%lu, cn=%lu)\n", __func__, cntobn(pmp, cn),
+                   cn));
                fc_setcache(dep, FC_LASTMAP, i, cn);
                return (0);
        }
@@ -303,6 +322,7 @@
                brelse(bp, 0);
        /* update last file cluster entry in the FAT cache */
        fc_setcache(dep, FC_LASTFC, i - 1, prevcn);
+       DPRINTF(("%s(eof, %lu)\n", __func__, i));
        return (E2BIG);
 }
 
@@ -362,10 +382,7 @@
        int i;
        struct buf *bpn;
 
-#ifdef MSDOSFS_DEBUG
-       printf("updatefats(pmp %p, bp %p, fatbn %lu)\n",
-           pmp, bp, fatbn);
-#endif
+       DPRINTF(("%s(pmp %p, bp %p, fatbn %lu)\n", __func__, pmp, bp, fatbn));
 
        /*
         * If we have an FSInfo block, update it.
@@ -530,17 +547,16 @@
        u_long bn, bo, bsize, byteoffset;
        struct buf *bp;
 
-#ifdef MSDOSFS_DEBUG
-       printf("fatentry(func %d, pmp %p, clust %lu, oldcon %p, newcon %lx)\n",
-            function, pmp, cn, oldcontents, newcontents);
-#endif
+       DPRINTF(("%s(func %d, pmp %p, clust %lu, oldcon %p, newcon " "%lx)\n",
+           __func__, function, pmp, cn, oldcontents, newcontents));
 
 #ifdef DIAGNOSTIC
        /*
         * Be sure they asked us to do something.
         */
        if ((function & (FAT_SET | FAT_GET)) == 0) {
-               printf("fatentry(): function code doesn't specify get or set\n");
+               DPRINTF(("%s(): function code doesn't specify get or set\n",
+                   __func__));
                return (EINVAL);
        }
 
@@ -549,7 +565,8 @@
         * where to put it, give them an error.
         */
        if ((function & FAT_GET) && oldcontents == NULL) {
-               printf("fatentry(): get function with no place to put result\n");
+               DPRINTF(("%s(): get function with no place to put result\n",
+                       __func__));
                return (EINVAL);
        }
 #endif
@@ -628,10 +645,8 @@
        u_long bn, bo, bsize, byteoffset, readcn, newc;
        struct buf *bp;
 
-#ifdef MSDOSFS_DEBUG
-       printf("fatchain(pmp %p, start %lu, count %lu, fillwith %lx)\n",
-           pmp, start, count, fillwith);
-#endif
+       DPRINTF(("%s(pmp %p, start %lu, count %lu, fillwith %lx)\n", __func__,
+           pmp, start, count, fillwith));
        /*
         * Be sure the clusters are in the filesystem.
         */
@@ -744,10 +759,9 @@
                usemap_alloc(pmp, cl++);
        if ((error = fatchain(pmp, start, count, fillwith)) != 0)
                return (error);
-#ifdef MSDOSFS_DEBUG
-       printf("clusteralloc(): allocated cluster chain at %lu (%lu clusters)\n",
-           start, count);
-#endif
+
+       DPRINTF(("%s(): allocated cluster chain at %lu (%lu clusters)\n",
+           __func__, start, count));
        if (retcluster)
                *retcluster = start;
        if (got)
@@ -775,9 +789,7 @@
        u_long fillwith = CLUST_EOFE;
        u_int map;
 
-#ifdef MSDOSFS_DEBUG
-       printf("clusteralloc(): find %lu clusters\n",count);
-#endif
+       DPRINTF(("%s(): find %lu clusters\n", __func__, count));
        if (start) {
                if ((len = chainlength(pmp, start, count)) >= count)
                        return (chainalloc(pmp, start, count, fillwith, retcluster, got));
@@ -990,7 +1002,7 @@
         */
        if (dep->de_StartCluster == MSDOSFSROOT
            && (dep->de_Attributes & ATTR_DIRECTORY)) {
-               printf("extendfile(): attempt to extend root directory\n");
+               DPRINTF(("%s(): attempt to extend root directory\n", __func__));
                return (ENOSPC);
        }
 



Home | Main Index | Thread Index | Old Index