Need some helps on using dbm functions

Charles Wilson cwilson@ece.gatech.edu
Tue Dec 12 14:41:00 GMT 2000


Jeff Lu wrote:
> 
> I've a small program that writes data using dbm calls
> 
> here's a snapshot of code and how I compile it:
> gcc -s -o /e/inetpub/wwwroot/cgi-bin/send.exe send.c
> intrautil.c -DBM_STATIC -lgdbm

The readme /usr/doc/Cygwin/gdbm-1.8.0.README clearly states that you
must use "-DGDBM_STATIC" not "-DBM_STATIC" or some variant thereof.

I sent a more explanatory answer but it appears that the mail server
swallowed it.  I will repeat that explanation here, but don't be
surprised if the mailserver eventually disgorges the previous one and
you see another message like this one.

> When the program is run, info.pag gets created but dbm_open returns a NULL
> file handle dbm_local.  In Unix there is info.dir file that goes with
> info.pag but I don't see one here in cygwin.  Is this the way it's supposed
> to be?  Can some one tell me why this is happening?  thanks.

Normal ndbm databases consist of two files: foo.dir and foo.pag.  gdbm
databases consist of a single file "foo".  When you use gdbm in its
"ndbm emulation" to create a new "ndbm"-style database (e.g. by calling
'dbm_open("my non-existant database")'  -- remember that 'dbm_open' is
an ndbm-style entry point; true gdbm programs use 'gdbm_open') it first
creates a gdbm-style database with the name "foo.pag". Then, it
HARDLINKS the file "foo.dir" to that new foo.pag database.

>From that point on it only accesses foo.pag.  However, the initial
creation step fails on FAT drives and under Win9x -- because Win9X only
supports FAT -- and hardlinks don't work on FAT drives.  (No, we can't
rewrite gdbm to use symlinks -- the hardlink is used to insure that the
timestamps on both files are the same; symlinks do not inherit the
timestamp of their target.)

So, the short answer is: ndbm-emulation doesn't work on Win9x or FAT. 
Are you using either of those?

--Chuck

P.S. Note that the comments in the source file gdbm-1.8.0/dbm_open.c are
wrong.  It states "NOTE: the file foo.dir is ignored and will always
have a size 0." That is incorrect, as inspection of the source code
itself will show.  I based my explanation above on the source code, not
the (wrong) comments.

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list