www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2000/12/15/23:05:21

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Message-ID: <3A368684.10492BEB@ece.gatech.edu>
Date: Tue, 12 Dec 2000 15:11:48 -0500
From: Charles Wilson <cwilson AT ece DOT gatech DOT edu>
X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
To: Jeff Lu <jklcom AT mindspring DOT com>
CC: cygwin AT sources DOT redhat DOT com
Subject: Re: Why is dbm_store saving garbage to file?
References: <NDBBIHPECLIGKCCLMACAGEGMCIAA DOT jklcom AT mindspring DOT com>

Okay, here's my guess:

  You're using gdbm, but you're using it in its 'ndbm-emulation' mode. 
True NDBM database usually have two files, foo.pag and foo.dir.  GDBM
databases have only a single file.  GDBM emulates NDBM operation by
creating its database file as foo.pag, and hardlinks foo.dir to it. 

Hard links don't work on FAT drives, or on Win9x.  Symlinks can't be
used, because you need the timestamps on both "files" to be the same;
symlinks do not inherit their target's timestamp.

Therefore, gdbm's ndbm-emulation mode doesn't work in those
circumstances.  Are you on Win9x or using FAT drives?

--Chuck

P.S. Be warned that the documentation in the source code,
gdbm-1.8.0/dbm_open.c is a little misleading. "NOTE: file.dir will be
ignored and will always have a size of zero." This statement is untrue
-- on database creation, file.dir is created as a hardlink to file.pag. 
If the database has already been created, then yes, "file.dir" is
ignored.  But it never has a size of zero.

Jeff Lu wrote:
> 
> It's calling from gdbm.  Here's the flag I used to compile -lgdbm.
> 
> After doing some more debugging, I realized the returned file handle is
> always NULL.  So for some reason it's not able to open the file but it did
> create it.
> 
> Thanks
> 
> -----Original Message-----
> From: cwilson AT ece DOT gatech DOT edu [mailto:cwilson AT ece DOT gatech DOT edu]
> Sent: Tuesday, December 12, 2000 1:31 AM
> To: Jeff Lu
> Cc: cygwin AT cygwin DOT com
> Subject: Re: Why is dbm_store saving garbage to file?
> 
> Jeff Lu wrote:
> >
> > Hi,
> >
> > I'm trying to save some data using dbm but what's being written to the
> file
> > is just gibberish.  The same code works in Unix/Linux.  Here's the code:
> >
> >         dbm_local = dbm_open (database, O_RDWR|O_CREAT, 00664);
> >         if(dbm_local)
> >         {
> >           strcpy(buffer, "CurrentOrderNumber");
> >           key.dptr = buffer;
> >           key.dsize = strlen(buffer)+1;
> >           return_data = dbm_fetch(dbm_local, key);
> >           if(return_data.dptr)
> >             sprintf(count, "%d", atoi(return_data.dptr)+1);
> >           else
> >             strcpy(count, "1");
> >           data_data.dptr = count;
> >           data_data.dsize = strlen(count)+1;
> >           dbm_store(dbm_local, key, data_data, DBM_REPLACE);
> >           dbm_close (dbm_local);
> >         }
> >
> > Thanks
> 
> In which library are dbm_open, dbm_fetch, dbm_store, and dbm_close
> implemented?  Are you using ndbm?  dbm?  Berkeley db?  or gdbm?  (Note
> that only gdbm is a supported, 'official' cygwin package.)
> 
> --Chuck

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019