Changeset 979


Ignore:
Timestamp:
Jan 11, 2004, 8:58:48 PM (22 years ago)
Author:
bird
Message:

Merged in changes from the old port (src/emx/bsd/db).

Location:
trunk/src/emx/src/lib/bsd/db
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/bsd/db/btree/bt_close.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r978 r979  
    7171        BTREE *t;
    7272        int fd;
     73#ifdef __EMX__
     74        char *tempname;
     75        int r;
     76#endif /* __EMX__ */
    7377
    7478        t = dbp->internal;
     
    106110
    107111        fd = t->bt_fd;
     112#ifdef __EMX__
     113        tempname = t->tempname;
     114        free(t);
     115        free(dbp);
     116        r = _close(fd) ? RET_ERROR : RET_SUCCESS;
     117        if (tempname != NULL) {
     118                int e = errno;
     119                (void)unlink (tempname);
     120                free (tempname);
     121                errno = e;
     122        }
     123        return r;
     124#else /* not __EMX__ */
    108125        free(t);
    109126        free(dbp);
    110127        return (_close(fd) ? RET_ERROR : RET_SUCCESS);
     128#endif
    111129}
    112130
  • trunk/src/emx/src/lib/bsd/db/btree/bt_open.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r978 r979  
    213213                if ((flags & O_ACCMODE) != O_RDWR)
    214214                        goto einval;
     215#ifdef __EMX__
     216                {
     217                char namestr[] = "btXXXXXX";
     218                char absname[MAXPATHLEN];
     219                if ((t->bt_fd = mkstemp (namestr)) == -1)
     220                        goto err;
     221                setmode (t->bt_fd, O_BINARY);
     222                if (_abspath (absname, namestr, sizeof (absname)) == 0)
     223                        t->tempname = strdup (absname);
     224                }
     225#else /* not __EMX__ */
    215226                if ((t->bt_fd = tmp()) == -1)
    216227                        goto err;
     228#endif /* not __EMX__ */
    217229                F_SET(t, B_INMEM);
    218230        }
     
    341353                if (t->bt_fd != -1)
    342354                        (void)_close(t->bt_fd);
     355#ifdef __EMX__
     356                if (t->tempname != NULL) {
     357                        (void)unlink(t->tempname);
     358                        free(t->tempname);
     359                }
     360#endif /* __EMX__ */
    343361                free(t);
    344362        }
     
    389407}
    390408
     409#ifndef __EMX__ /* bird */
    391410static int
    392411tmp()
     
    397416        char path[MAXPATHLEN];
    398417
    399 #ifndef __EMX__ /* bird */
    400418        if (issetugid() == 0)
    401 #endif
    402419                envtmp = getenv("TMPDIR");
    403420        (void)snprintf(path,
     
    411428        return(fd);
    412429}
     430#endif /*!EMX*/
    413431
    414432static int
  • trunk/src/emx/src/lib/bsd/db/btree/btree.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r978 r979  
    380380#define B_DB_TXN        0x10000         /* DB_TXN specified. */
    381381        u_int32_t flags;
     382#ifdef __EMX__
     383        char *tempname;                 /* Name of temporary file */
     384#endif /* __EMX__ */
    382385} BTREE;
    383386
  • trunk/src/emx/src/lib/bsd/db/db/db.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r978 r979  
    6060#define USE_OPEN_FLAGS                                                  \
    6161        (O_CREAT | O_EXCL /*| O_EXLOCK*/ | O_NONBLOCK | O_RDONLY |              \
    62          O_RDWR | /*O_SHLOCK |*/ O_TRUNC)
     62         O_RDWR | /*O_SHLOCK |*/ O_TRUNC | O_BINARY)
    6363#else
    6464#define USE_OPEN_FLAGS                                                  \
  • trunk/src/emx/src/lib/bsd/db/hash/hash.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r978 r979  
    444444        if (hashp->fp != -1)
    445445                (void)_close(hashp->fp);
     446#ifdef __EMX__
     447        if (hashp->tempname != NULL) {
     448                (void)unlink (hashp->tempname);
     449                free (hashp->tempname);
     450                }
     451#endif /* __EMX__ */
    446452
    447453        free(hashp);
     
    517523                if (wsize != sizeof(HASHHDR)) {
    518524                        errno = EFTYPE;
    519                         hashp->error = errno;
     525                        hashp->dbmerrno = errno; /* bird: errno */
    520526                        return (-1);
    521527                }
     
    548554        hashp = (HTAB *)dbp->internal;
    549555        if (flag) {
    550                 hashp->error = errno = EINVAL;
     556                hashp->dbmerrno = errno = EINVAL;   /* bird: errno */
    551557                return (ERROR);
    552558        }
     
    565571        hashp = (HTAB *)dbp->internal;
    566572        if (flag && flag != R_NOOVERWRITE) {
    567                 hashp->error = EINVAL;
     573                hashp->dbmerrno = EINVAL;           /* bird: errno */
    568574                errno = EINVAL;
    569575                return (ERROR);
    570576        }
    571577        if ((hashp->flags & O_ACCMODE) == O_RDONLY) {
    572                 hashp->error = errno = EPERM;
     578                hashp->dbmerrno = errno = EPERM;    /* bird: errno */
    573579                return (ERROR);
    574580        }
     
    587593        hashp = (HTAB *)dbp->internal;
    588594        if (flag && flag != R_CURSOR) {
    589                 hashp->error = errno = EINVAL;
     595                hashp->dbmerrno = errno = EINVAL;   /* bird: errno */
    590596                return (ERROR);
    591597        }
    592598        if ((hashp->flags & O_ACCMODE) == O_RDONLY) {
    593                 hashp->error = errno = EPERM;
     599                hashp->dbmerrno = errno = EPERM;    /* bird: errno */
    594600                return (ERROR);
    595601        }
     
    742748        hashp = (HTAB *)dbp->internal;
    743749        if (flag && flag != R_FIRST && flag != R_NEXT) {
    744                 hashp->error = errno = EINVAL;
     750                hashp->dbmerrno = errno = EINVAL;   /* bird: errno */
    745751                return (ERROR);
    746752        }
  • trunk/src/emx/src/lib/bsd/db/hash/hash.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r978 r979  
    7373        int             ssize;          /* Segment Size */
    7474        int             sshift;         /* Segment shift */
    75         int             ovfl_point;     /* Where overflow pages are being 
     75        int             ovfl_point;     /* Where overflow pages are being
    7676                                         * allocated */
    7777        int             last_freed;     /* Last overflow page freed */
    7878        int             max_bucket;     /* ID of Maximum bucket in use */
    7979        int             high_mask;      /* Mask to modulo into entire table */
    80         int             low_mask;       /* Mask to modulo into lower half of 
     80        int             low_mask;       /* Mask to modulo into lower half of
    8181                                         * table */
    8282        int             ffactor;        /* Fill factor */
     
    8484        int             hdrpages;       /* Size of table header */
    8585        int             h_charkey;      /* value of hash(CHARKEY) */
    86 #define NCACHED 32                      /* number of bit maps and spare 
     86#define NCACHED 32                      /* number of bit maps and spare
    8787                                         * points */
    8888        int             spares[NCACHED];/* spare pages for overflow */
    89         u_int16_t       bitmaps[NCACHED];       /* address of overflow page 
     89        u_int16_t       bitmaps[NCACHED];       /* address of overflow page
    9090                                                 * bitmaps */
    9191} HASHHDR;
     
    9494        HASHHDR         hdr;            /* Header */
    9595        int             nsegs;          /* Number of allocated segments */
    96         int             exsegs;         /* Number of extra allocated 
     96        int             exsegs;         /* Number of extra allocated
    9797                                         * segments */
    9898        u_int32_t                       /* Hash function */
     
    105105        int             cbucket;        /* Current bucket */
    106106        int             cndx;           /* Index of next item on cpage */
    107         int             error;          /* Error Number -- for DBM
    108                                          * compatibility */
    109         int             new_file;       /* Indicates if fd is backing store
     107        /* bird: this used to be errno but that crashes with the errno define in errno.h and stdlib.h. */
     108        int             dbmerrno;       /* Error Number -- for DBM
     109                                         * compatability */
     110        int             new_file;       /* Indicates if fd is backing store
    110111                                         * or no */
    111         int             save_file;      /* Indicates whether we need to flush 
     112        int             save_file;      /* Indicates whether we need to flush
    112113                                         * file at
    113114                                         * exit */
    114115        u_int32_t       *mapp[NCACHED]; /* Pointers to page maps */
    115116        int             nmaps;          /* Initial number of bitmaps */
    116         int             nbufs;          /* Number of buffers left to 
     117        int             nbufs;          /* Number of buffers left to
    117118                                         * allocate */
    118119        BUFHEAD         bufhead;        /* Header of buffer lru list */
    119120        SEGMENT         *dir;           /* Hash Bucket directory */
     121#ifdef __EMX__
     122        char            *tempname;      /* Name of temporary file */
     123#endif /* __EMX__ */
    120124} HTAB;
    121125
  • trunk/src/emx/src/lib/bsd/db/hash/hash_page.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r978 r979  
    6969#ifdef DEBUG
    7070#include <assert.h>
     71#endif
     72#ifdef __EMX__
     73#include <io.h>
    7174#endif
    7275#include "un-namespace.h"
     
    868871{
    869872        sigset_t set, oset;
     873#ifdef __EMX__
     874        char namestr[] = "hsXXXXXX";
     875#else /* not __EMX__ */
    870876        static char namestr[] = "_hashXXXXXX";
     877#endif /* not __EMX__ */
    871878
    872879        /* Block signals; make sure file goes away at process exit. */
     
    874881        (void)_sigprocmask(SIG_BLOCK, &set, &oset);
    875882        if ((hashp->fp = mkstemp(namestr)) != -1) {
     883#ifdef __EMX__
     884                char absname[_MAX_PATH];
     885                setmode (hashp->fp, O_BINARY);
     886                if (_abspath (absname, namestr, sizeof (absname)) == 0)
     887                        hashp->tempname = strdup (absname);
     888#else /* not __EMX__ */
    876889                (void)unlink(namestr);
     890#endif /* not __EMX__ */
    877891                (void)_fcntl(hashp->fp, F_SETFD, 1);
    878892        }
  • trunk/src/emx/src/lib/bsd/db/hash/ndbm.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r978 r979  
    211211
    212212        hp = (HTAB *)db->internal;
    213         return (hp->error);
     213        return (hp->dbmerrno);          /* bird: errno */
    214214}
    215215
     
    221221
    222222        hp = (HTAB *)db->internal;
    223         hp->error = 0;
     223        hp->dbmerrno = 0;               /* bird: errno */
    224224        return (0);
    225225}
Note: See TracChangeset for help on using the changeset viewer.