tdb/common/freelistcheck.c

ソースコードを見る。

関数

static int seen_insert (struct tdb_context *mem_tdb, tdb_off_t rec_ptr)
int tdb_validate_freelist (struct tdb_context *tdb, int *pnum_entries)


関数

static int seen_insert ( struct tdb_context mem_tdb,
tdb_off_t  rec_ptr 
) [static]

freelistcheck.c37 行で定義されています。

参照先 TDB_DATA::dptrTDB_DATA::dsizetdb_store().

参照元 tdb_validate_freelist().

00038 {
00039         TDB_DATA key, data;
00040 
00041         memset(&data, '\0', sizeof(data));
00042         key.dptr = (char *)&rec_ptr;
00043         key.dsize = sizeof(rec_ptr);
00044         return tdb_store(mem_tdb, key, data, TDB_INSERT);
00045 }

int tdb_validate_freelist ( struct tdb_context tdb,
int *  pnum_entries 
)

freelistcheck.c47 行で定義されています。

参照先 tdb_header::hash_sizetdb_context::headerlast_ptrlist_struct::nextrec_free_read()seen_insert()tdbtdb_close()TDB_ERR_CORRUPTtdb_lock()tdb_ofs_read()tdb_open()tdb_unlock().

参照元 main().

00048 {
00049         struct tdb_context *mem_tdb = NULL;
00050         struct list_struct rec;
00051         tdb_off_t rec_ptr, last_ptr;
00052         int ret = -1;
00053 
00054         *pnum_entries = 0;
00055 
00056         mem_tdb = tdb_open("flval", tdb->header.hash_size,
00057                                 TDB_INTERNAL, O_RDWR, 0600);
00058         if (!mem_tdb) {
00059                 return -1;
00060         }
00061 
00062         if (tdb_lock(tdb, -1, F_WRLCK) == -1) {
00063                 tdb_close(mem_tdb);
00064                 return 0;
00065         }
00066 
00067         last_ptr = FREELIST_TOP;
00068 
00069         /* Store the FREELIST_TOP record. */
00070         if (seen_insert(mem_tdb, last_ptr) == -1) {
00071                 ret = TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
00072                 goto fail;
00073         }
00074 
00075         /* read in the freelist top */
00076         if (tdb_ofs_read(tdb, FREELIST_TOP, &rec_ptr) == -1) {
00077                 goto fail;
00078         }
00079 
00080         while (rec_ptr) {
00081 
00082                 /* If we can't store this record (we've seen it
00083                    before) then the free list has a loop and must
00084                    be corrupt. */
00085 
00086                 if (seen_insert(mem_tdb, rec_ptr)) {
00087                         ret = TDB_ERRCODE(TDB_ERR_CORRUPT, -1);
00088                         goto fail;
00089                 }
00090 
00091                 if (rec_free_read(tdb, rec_ptr, &rec) == -1) {
00092                         goto fail;
00093                 }
00094 
00095                 /* move to the next record */
00096                 last_ptr = rec_ptr;
00097                 rec_ptr = rec.next;
00098                 *pnum_entries += 1;
00099         }
00100 
00101         ret = 0;
00102 
00103   fail:
00104 
00105         tdb_close(mem_tdb);
00106         tdb_unlock(tdb, -1, F_WRLCK);
00107         return ret;
00108 }


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