Modem Manager GUI creates a database named sms.gdbm to store all the SMS details. Currently Modem Manager GUI is not providing a feature to simply delete all received/sent messages. So I'm trying to create a program to remove those records from its database (sms.gdbm). But first I want to know the structure of the sms.gdbm database. What are the databases it contains, also table and their column names. So are there any CLI or GUI programs to display the structure of a *.gdbm file?


GDBM databases are readable through the GDBM API. I wrote a small article about it last year. They are basically a way to store simple key-value pairs of any kind. There is no "structure" as in traditional DBMSes : no tables, no columns... Only keys and values.

The API defines the following functions:

GDBM_FILE gdbm_open (const char *name, int block_size, int flags, int mode, void (*fatal_func)(const char *));
void gdbm_close (GDBM_FILE dbf);

typedef struct {
    char *dptr;
    int dsize;
} datum;

int gdbm_store (GDBM_FILE dbf, datum key, datum content, int flag);
datum gdbm_fetch (GDBM_FILE dbf, datum key);
int gdbm_delete (GDBM_FILE dbf, datum key);
datum gdbm_firstkey (GDBM_FILE dbf);
datum datum gdbm_nextkey (GDBM_FILE dbf, datum prev);

const char * gdbm_strerror (gdbm_error errno);

Basically, all you have to do is open the file through the API...

GDBM_FILE database = gdbm_open("sms.gdbm", 512, GDBM_READER, 0, NULL);

And start reading:

#include <stdio.h>
#include <stdlib.h>
#include <gdbm.h>

int main(int argc, char** argv)
    GDBM_FILE database = gdbm_open("sms.gdbm", 512, GDBM_READER, 0, NULL);

    datum key, data;
    for(key = gdbm_firstkey(database); /* get the first key */
        key.dptr != NULL; /* keep going until the end */
        key = gdbm_nextkey(database, key)) /* next key */
        /* fetch data associated to key */
        data = gdbm_fetch(database, key);
        if(data.dptr != NULL)
            printf("Entry found (%d bytes) : %s.\n", data.dsize, data.dptr);

    return EXIT_SUCCESS;

Be careful that there is no certainty as to the type of data stored in the database. Here, I assumed there would be strings, but it could be anything. The data is stored in binary form, and the only thing you can be certain of is the size (data.dsize). The API will provide you with a pointer to the start of the data (data.dptr), but how you process it is up to you (or at least, up to your Modem Manager GUI).

Once you've found the entry you want to delete, just call gdbm_delete:

gdbm_delete(database, key);

And don't forget to close everything when you're done ;)


I am not aware of any GDBM reader program already available, but writing one doesn't really require too much effort. Don't forget to include the GDBM header (gdbm.h) and to link the library when compiling:

gcc reader.c -o reader -lgdbm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.