"Fossies" - the Fresh Open Source Software Archive

Member "coda-6.9.5/coda-src/vol/dumpcamstorage.cc" (6 Oct 2008, 10074 Bytes) of package /linux/misc/old/coda-6.9.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "dumpcamstorage.cc" see the Fossies "Dox" file reference documentation.

    1 /* BLURB gpl
    2 
    3                            Coda File System
    4                               Release 6
    5 
    6           Copyright (c) 1987-2003 Carnegie Mellon University
    7                   Additional copyrights listed below
    8 
    9 This  code  is  distributed "AS IS" without warranty of any kind under
   10 the terms of the GNU General Public Licence Version 2, as shown in the
   11 file  LICENSE.  The  technical and financial  contributors to Coda are
   12 listed in the file CREDITS.
   13 
   14                         Additional copyrights
   15                            none currently
   16 
   17 #*/
   18 
   19 /********************************
   20  * dumpcamstorage.c     *
   21  ********************************/
   22 
   23 #ifdef __cplusplus
   24 extern "C" {
   25 #endif
   26 
   27 #include <sys/types.h>
   28 #include <sys/time.h>
   29 
   30 #include <stdio.h>
   31 #include <ctype.h>
   32 #include <sys/param.h>
   33 #include <errno.h>
   34 #include <sys/stat.h>
   35 #include <sys/time.h>
   36 #include <sys/file.h>
   37 #include <netinet/in.h>
   38 #include <sys/wait.h>
   39 #include <setjmp.h>
   40 #include <unistd.h>
   41 #include <stdlib.h>
   42 #include <struct.h>
   43 
   44 #include <lwp/lwp.h>
   45 #include <lwp/lock.h>
   46 #include <util.h>
   47 #include <rvmlib.h>
   48 
   49 #ifdef __cplusplus
   50 }
   51 #endif
   52 
   53 #include <vice.h>
   54 #include "cvnode.h"
   55 #include "volume.h"
   56 #include "vldb.h"
   57 #include "partition.h"
   58 #include "vutil.h"
   59 #include "fssync.h"
   60 #include "index.h"
   61 #include "recov.h"
   62 #include "camprivate.h"
   63 #include "coda_globals.h"
   64 
   65 void print_VolumeDiskData(VolumeDiskData *ddata);
   66 static void PrintVersionVector(vv_t vv, const char *indent);
   67 void print_VnodeDiskObject(VnodeDiskObject *vnode);
   68 void print_VolData(struct VolumeData *data);
   69 void print_VolHead(struct VolHead *VolHead, int volindex);
   70 
   71 /* These routines should be called from within a transaction */
   72 
   73 void dump_storage(int level, const char *s)
   74 {
   75     int i;
   76 
   77     if (level > VolDebugLevel)
   78     return;
   79 
   80     printf("dump_storage at %s\n", s);
   81     printf("{\n    already_initialized = %d;\n\n    VolumeList = {\n",
   82        SRV_RVM(already_initialized));
   83     for (i = 0; i < 14; i++) {
   84     print_VolHead(&SRV_RVM(VolumeList[i]), i);
   85     print_VolData(&(SRV_RVM(VolumeList[i]).data));
   86     }
   87 
   88     printf("    }\n\tSmallVnodeFreeList = {\n");
   89     for (i = 0; i < 3; i++) {
   90     if (SRV_RVM(SmallVnodeFreeList[i]) != NULL) {
   91         printf("SmallVnodeFreeList[%d]\n", i);
   92         print_VnodeDiskObject(SRV_RVM(SmallVnodeFreeList[i]));
   93     }
   94     }
   95     printf("    }\n\tLargeVnodeFreeList = {\n");
   96     for (i = 0; i < 2; i++) {
   97     if (SRV_RVM(LargeVnodeFreeList[i]) != NULL) {
   98         printf("LargeVnodeFreeList[%d]\n", i);
   99         print_VnodeDiskObject(SRV_RVM(LargeVnodeFreeList[i]));
  100     }
  101     }
  102     printf("    }\n    SmallVnodeIndex = %d;\n", SRV_RVM(SmallVnodeIndex));
  103     printf("    LargeVnodeIndex = %d;\n", SRV_RVM(LargeVnodeIndex));
  104     printf("    MaxVolId = %x;\n}\n", SRV_RVM(MaxVolId));
  105 
  106 }
  107 
  108 void print_VolHead(struct VolHead *VolHead, int volindex)
  109 {
  110     printf("    VolHead VolumeList[%d]:\n", volindex);
  111     if (VolHead->header.stamp.magic != 0 ) {
  112     printf("\t\tversion stamp = %x, %u\n", VolHead->header.stamp.magic,
  113                         VolHead->header.stamp.version);
  114     }
  115     printf("\t\tid = %x\n\t\tparentid = %x\n\t\ttype = %u\n", VolHead->header.id,
  116                 VolHead->header.parent, VolHead->header.type);
  117 }
  118 
  119 void print_VolData(struct VolumeData *data)
  120 {
  121     int i = 0;
  122 
  123     printf("    VolumeData:\n");
  124     if (data->volumeInfo != NULL) {
  125     printf("\t\tVolumeDiskData *volumeInfo = %p\n", data->volumeInfo);
  126     print_VolumeDiskData(data->volumeInfo);
  127     }
  128 
  129     printf("\t\tsmallvnodes = %u\n\t\tsmallListSize = %u\n", data->nsmallvnodes, data->nsmallLists);
  130     printf("\t\trec_smolist *smallVnodeList = %p\n", data->smallVnodeLists);
  131     if (data->smallVnodeLists != NULL) {
  132     rec_smolist *p;
  133     for (i = 0; i < (int)data->nsmallLists; i++) {
  134         p = &(data->smallVnodeLists[i]);
  135         p->print();
  136         if (!p->IsEmpty()) {
  137         rec_smolist_iterator next(*p);
  138         struct rec_smolink *l;
  139         while ((l = next())) {
  140             VnodeDiskObject *vdo;
  141             vdo = strbase(VnodeDiskObject, l, nextvn);
  142             printf("\n\tVNODE%d\n", i);
  143             print_VnodeDiskObject(vdo);
  144         }
  145         }
  146     }
  147     }
  148     printf("\n");
  149 
  150     printf("\t\tlargevnodes = %u\n\t\tlargeListSize = %u\n", data->nlargevnodes, data->nlargeLists);
  151     printf("\t\tVnodeDiskObject **largeVnodeList = %p\n", data->largeVnodeLists);
  152     if (data->largeVnodeLists != NULL) {
  153     rec_smolist *p;
  154     for(i = 0; i < (int)data->nlargeLists; i++) {
  155         p = &(data->largeVnodeLists[i]);
  156         p->print();
  157         if (!p->IsEmpty()){
  158         rec_smolist_iterator next(*p);
  159         struct rec_smolink *l;
  160         while((l = next())){
  161             VnodeDiskObject *vdo;
  162             vdo = strbase(VnodeDiskObject, l, nextvn);
  163             printf("\n\tVNODE%d\n", i);
  164             print_VnodeDiskObject(vdo);
  165         }
  166         }
  167     }
  168     }
  169     printf("\n\n");
  170 
  171 }
  172 
  173 void print_VnodeDiskObject(VnodeDiskObject *vnode)
  174 {
  175     if (vnode->type == vNull && vnode->linkCount == 0)
  176     return;
  177     printf("\ttype = %u\tcloned = %u\tmode = %o\tlinks = %u\n",
  178     vnode->type, vnode->cloned, vnode->modeBits, vnode->linkCount);
  179     printf("\tlength = %u\tunique = %x\tversion = %u\tinode = %p\n",
  180        vnode->length, vnode->uniquifier, vnode->dataVersion,
  181        vnode->node.dirNode);
  182     PrintVersionVector(vnode->versionvector, "\t");
  183     printf("\tvolindex = %d\tmodtime = %u\tauthor = %u\towner = %u\n",
  184     vnode->vol_index, vnode->unixModifyTime, vnode->author, vnode->owner);
  185     printf("\tparent = %x.%x\tmagic = %x\tsrv_mtime = %u\n",
  186        vnode->vparent, vnode->uparent,
  187        vnode->vnodeMagic, vnode->serverModifyTime);
  188 }
  189 
  190 static void PrintVersionVector(vv_t vv, const char *indent) {
  191 
  192     fprintf(stdout, "%s", indent);
  193     FPrintVV(stdout, &vv);
  194 }
  195 
  196 void print_VolumeDiskData(VolumeDiskData *ddata)
  197 {
  198     int i = 0;
  199     printf("\t\t\tversion stamp = %x, %u\n", ddata->stamp.magic, ddata->stamp.version);
  200     printf("\t\t\tid = %08x\n\t\t\tpartition = %s\n\t\t\tname = %s\n\t\t\tinUse = %u\n\t\t\tinService = %u\n",
  201         ddata->id, ddata->partition, ddata->name, ddata->inUse, ddata->inService);
  202 
  203     if (ddata->stamp.magic != 0) {
  204     printf("\t\t\tblessed = %u\n\t\t\tneedsSalvaged = %u\n\t\t\tuniquifier= %u\n\t\t\ttype = %d\n",
  205         ddata->blessed, ddata->needsSalvaged, ddata->uniquifier, ddata->type);
  206     printf("\t\t\tparentId = %08x\n\t\t\tgrpId = %08x\n\t\t\tcloneId = %08x\n\t\t\tbackupId = %08x\n\t\t\trestoreFromId = %08x\n",
  207         ddata->parentId, ddata->groupId, ddata->cloneId, ddata->backupId, ddata->restoredFromId);
  208     printf("\t\t\tneedsCallback = %u\n\t\t\tdestroyMe = %u\n\t\t\tdontSalvage = %u\n\t\t\treserveb3 = %u\n",
  209         ddata->needsCallback, ddata->destroyMe, ddata->dontSalvage, ddata->reserveb3);
  210     PrintVersionVector(ddata->versionvector, "\t\t\t");
  211     }
  212     printf("\t\t\t");
  213     for (i = 0; i < 3; i++) {
  214     printf("reserved1[%d] = %u, ", i, ddata->reserved1[i]);
  215     }
  216     printf("\n\t\t\t");
  217     for (i = 3; i < 5; i++) {
  218     printf("reserved1[%d] = %u, ", i, ddata->reserved1[i]);
  219     }
  220     printf("\n");
  221 
  222     printf("\t\t\tmaxquota = %d\n\t\t\tminquota = %d\n\t\t\tmaxfiles = %d\n\t\t\tacctNum = %u\n\t\t\towner = %u\n",
  223     ddata->maxquota, ddata->minquota, ddata->maxfiles, ddata->accountNumber, ddata->owner);
  224     printf("\t\t\t");
  225     for (i = 0; i < 3; i++) {
  226     printf("reserved2[%d] = %d, ", i, ddata->reserved2[i]);
  227     }
  228     printf("\n\t\t\t");
  229     for (i = 3; i < 6; i++) {
  230     printf("reserved2[%d] = %d, ", i, ddata->reserved2[i]);
  231     }
  232     printf("\n\t\t\t");
  233     for (i = 6; i < 8; i++) {
  234     printf("reserved2[%d] = %d, ", i, ddata->reserved2[i]);
  235     }
  236     printf("\n");
  237 
  238     printf("\t\t\tfilecount = %d\n\t\t\tlinkcount = %u\n\t\t\tdiskused = %d\n\t\t\tdayUse = %d\n\t\t\tdayUseDate = %u\n",
  239     ddata->filecount, ddata->linkcount, ddata->diskused, ddata->dayUse, ddata->dayUseDate);
  240     printf("\t\t\t");
  241     for (i = 0; i < 3; i++) {
  242     printf("weekUse[%d] = %d, ", i, ddata->weekUse[i]);
  243     }
  244     printf("\n\t\t\t");
  245     for (i = 3; i < 6; i++) {
  246     printf("weekUse[%d] = %d, ", i, ddata->weekUse[i]);
  247     }
  248     printf("\n\t\t\t");
  249     for (i = 6; i < 7; i++) {
  250     printf("weekUse[%d] = %d, ", i, ddata->weekUse[i]);
  251     }
  252     printf("\n");
  253 
  254     printf("\t\t\t");
  255     for(i = 0; i < 3; i++) {
  256     printf("reserved3[%d] = %d, ", i, ddata->reserved3[i]);
  257     }
  258     printf("\n\t\t\t");
  259     for(i = 3; i < 6; i++) {
  260     printf("reserved3[%d] = %d, ", i, ddata->reserved3[i]);
  261     }
  262     printf("\n");
  263     printf("\t\t\t");
  264     for(i = 6; i < 9; i++) {
  265     printf("reserved3[%d] = %d, ", i, ddata->reserved3[i]);
  266     }
  267     printf("\n\t\t\t");
  268     for(i = 9; i < 11; i++) {
  269     printf("reserved3[%d] = %d, ", i, ddata->reserved3[i]);
  270     }
  271     printf("\n");
  272 
  273     printf("\t\t\tcreationDate = %u\n\t\t\taccessDate = %u\n\t\t\tupdateDate = %u\n\t\t\texpirationDate = %u\n",
  274     ddata->creationDate, ddata->accessDate, ddata->updateDate, ddata->expirationDate);
  275     printf("\t\t\tbackupDate = %u\n\t\t\tcopyDate = %u\n", ddata->backupDate, ddata->copyDate);
  276     printf("\t\t\t");
  277     for (i = 0; i < 3; i++) {
  278     printf("reserved4[%d] = %u, ", i, ddata->reserved4[i]);
  279     }
  280     printf("\n\t\t\t");
  281     for (i = 3; i < 6; i++) {
  282     printf("reserved4[%d] = %u, ", i, ddata->reserved4[i]);
  283     }
  284     printf("\n\t\t\t");
  285     for (i = 6; i < 7; i++) {
  286     printf("reserved4[%d] = %u, ", i, ddata->reserved4[i]);
  287     }
  288     printf("\n");
  289     printf("\t\t\tofflineMessage = %s\n", ddata->offlineMessage);
  290     printf("\t\t\tmotd = %s\n\n", ddata->motd);
  291 }
  292 
  293 void PrintCamVnode(int level, int volindex, int vclass, VnodeId vnodeindex,
  294             Unique_t unq)
  295 {
  296     char buf[SIZEOF_LARGEDISKVNODE];
  297     VnodeDiskObject *vnode = (VnodeDiskObject *)buf;
  298     int rc = 0;
  299 
  300     if (level > VolDebugLevel) return;
  301 
  302     rc = ExtractVnode(volindex, vclass, vnodeindex, unq, vnode);
  303     if (rc) printf("Error from ExtractVnode\n");
  304 }
  305 
  306 void PrintCamDiskData(int level, int volindex, VolumeDiskData *vdisk) {
  307 
  308     if (level > VolDebugLevel) return;
  309 
  310     printf("Printing VolumeDiskObject for volume index %d\n", volindex);
  311     print_VolumeDiskData(vdisk);
  312 }
  313 
  314 void PrintCamVolume(int level, int volindex) {
  315 
  316     if (level > VolDebugLevel) return;
  317     printf("Printing volume at index %d:\n", volindex);
  318     print_VolHead(&(SRV_RVM(VolumeList[volindex])), volindex);
  319     print_VolData(&(SRV_RVM(VolumeList[volindex].data)));
  320 }