tdb/common/dump.c

ソースコードを見る。

関数

static tdb_off_t tdb_dump_record (struct tdb_context *tdb, int hash, tdb_off_t offset)
static int tdb_dump_chain (struct tdb_context *tdb, int i)
void tdb_dump_all (struct tdb_context *tdb)
int tdb_printfreelist (struct tdb_context *tdb)


関数

static tdb_off_t tdb_dump_record ( struct tdb_context tdb,
int  hash,
tdb_off_t  offset 
) [static]

dump.c31 行で定義されています。

参照先 tdb_context::methodsprintf()tdbtdb_ofs_read()tdb_methods::tdb_read.

参照元 tdb_dump_chain().

00033 {
00034         struct list_struct rec;
00035         tdb_off_t tailer_ofs, tailer;
00036 
00037         if (tdb->methods->tdb_read(tdb, offset, (char *)&rec, 
00038                                    sizeof(rec), DOCONV()) == -1) {
00039                 printf("ERROR: failed to read record at %u\n", offset);
00040                 return 0;
00041         }
00042 
00043         printf(" rec: hash=%d offset=0x%08x next=0x%08x rec_len=%d "
00044                "key_len=%d data_len=%d full_hash=0x%x magic=0x%x\n",
00045                hash, offset, rec.next, rec.rec_len, rec.key_len, rec.data_len,
00046                rec.full_hash, rec.magic);
00047 
00048         tailer_ofs = offset + sizeof(rec) + rec.rec_len - sizeof(tdb_off_t);
00049 
00050         if (tdb_ofs_read(tdb, tailer_ofs, &tailer) == -1) {
00051                 printf("ERROR: failed to read tailer at %u\n", tailer_ofs);
00052                 return rec.next;
00053         }
00054 
00055         if (tailer != rec.rec_len + sizeof(rec)) {
00056                 printf("ERROR: tailer does not match record! tailer=%u totalsize=%u\n",
00057                                 (unsigned int)tailer, (unsigned int)(rec.rec_len + sizeof(rec)));
00058         }
00059         return rec.next;
00060 }

static int tdb_dump_chain ( struct tdb_context tdb,
int  i 
) [static]

dump.c62 行で定義されています。

参照先 printf()tdbtdb_dump_record()tdb_lock()tdb_ofs_read()tdb_unlock()top.

参照元 tdb_dump_all().

00063 {
00064         tdb_off_t rec_ptr, top;
00065 
00066         top = TDB_HASH_TOP(i);
00067 
00068         if (tdb_lock(tdb, i, F_WRLCK) != 0)
00069                 return -1;
00070 
00071         if (tdb_ofs_read(tdb, top, &rec_ptr) == -1)
00072                 return tdb_unlock(tdb, i, F_WRLCK);
00073 
00074         if (rec_ptr)
00075                 printf("hash=%d\n", i);
00076 
00077         while (rec_ptr) {
00078                 rec_ptr = tdb_dump_record(tdb, i, rec_ptr);
00079         }
00080 
00081         return tdb_unlock(tdb, i, F_WRLCK);
00082 }

void tdb_dump_all ( struct tdb_context tdb  ) 

dump.c84 行で定義されています。

参照先 tdb_header::hash_sizetdb_context::headerprintf()tdbtdb_dump_chain().

参照元 do_command().

00085 {
00086         int i;
00087         for (i=0;i<tdb->header.hash_size;i++) {
00088                 tdb_dump_chain(tdb, i);
00089         }
00090         printf("freelist:\n");
00091         tdb_dump_chain(tdb, -1);
00092 }

int tdb_printfreelist ( struct tdb_context tdb  ) 

dump.c94 行で定義されています。

参照先 tdb_context::methodsprintf()tdbtdb_lock()tdb_ofs_read()tdb_methods::tdb_readtdb_unlock().

参照元 do_command().

00095 {
00096         int ret;
00097         long total_free = 0;
00098         tdb_off_t offset, rec_ptr;
00099         struct list_struct rec;
00100 
00101         if ((ret = tdb_lock(tdb, -1, F_WRLCK)) != 0)
00102                 return ret;
00103 
00104         offset = FREELIST_TOP;
00105 
00106         /* read in the freelist top */
00107         if (tdb_ofs_read(tdb, offset, &rec_ptr) == -1) {
00108                 tdb_unlock(tdb, -1, F_WRLCK);
00109                 return 0;
00110         }
00111 
00112         printf("freelist top=[0x%08x]\n", rec_ptr );
00113         while (rec_ptr) {
00114                 if (tdb->methods->tdb_read(tdb, rec_ptr, (char *)&rec, 
00115                                            sizeof(rec), DOCONV()) == -1) {
00116                         tdb_unlock(tdb, -1, F_WRLCK);
00117                         return -1;
00118                 }
00119 
00120                 if (rec.magic != TDB_FREE_MAGIC) {
00121                         printf("bad magic 0x%08x in free list\n", rec.magic);
00122                         tdb_unlock(tdb, -1, F_WRLCK);
00123                         return -1;
00124                 }
00125 
00126                 printf("entry offset=[0x%08x], rec.rec_len = [0x%08x (%d)] (end = 0x%08x)\n", 
00127                        rec_ptr, rec.rec_len, rec.rec_len, rec_ptr + rec.rec_len);
00128                 total_free += rec.rec_len;
00129 
00130                 /* move to the next record */
00131                 rec_ptr = rec.next;
00132         }
00133         printf("total rec_len = [0x%08x (%d)]\n", (int)total_free, 
00134                (int)total_free);
00135 
00136         return tdb_unlock(tdb, -1, F_WRLCK);
00137 }


Sambaに対してSat Aug 29 21:24:30 2009に生成されました。  doxygen 1.4.7