From f35b277b8d3579e6558208fc45b5b7151fd9b872 Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Wed, 21 Jan 1998 16:33:31 +0000 Subject: [PATCH] * btree/bt_open.c: Added O_BINARY for __CYGWIN32__. * clib/mkstemp.c: Added O_BINARY for __CYGWIN32__. * db/db.c: Added O_BINARY for __CYGWIN32__. * hash/dbm.c: Added O_BINARY for __CYGWIN32__. * hash/hash.c: Added O_BINARY for __CYGWIN32__. * hash/hsearch.c: Added O_BINARY for __CYGWIN32__. * include/db-int.h: Added O_BINARY for __CYGWIN32__. * recno/rec_open.c: Added O_BINARY for __CYGWIN32__. * test/dbtest.c: Added O_BINARY for __CYGWIN32__. * test/SEQ_TEST/t.c: Added O_BINARY for __CYGWIN32__. * test/btree.tests/main.c: Added O_BINARY for __CYGWIN32__. * test/hash1.tests/driver2.c: Added O_BINARY for __CYGWIN32__. * test/hash1.tests/tcreat3.c: Added O_BINARY for __CYGWIN32__. * test/hash1.tests/tdel.c: Added O_BINARY for __CYGWIN32__. * test/hash1.tests/thash4.c: Added O_BINARY for __CYGWIN32__. * test/hash1.tests/tread2.c: Added O_BINARY for __CYGWIN32__. * test/hash1.tests/tseq.c: Added O_BINARY for __CYGWIN32__. * test/hash1.tests/tverify.c: Added O_BINARY for __CYGWIN32__. * test/hash2.tests/bigtest.c: Added O_BINARY for __CYGWIN32__. * test/hash2.tests/passtest.c: Added O_BINARY for __CYGWIN32__. Changes originally by Jeremy Allison (jra@cygnus.com) git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10364 dc483132-0cff-0310-8789-dd5450dbe970 --- src/util/db2/ChangeLog | 30 +++++++++++++++++++++--- src/util/db2/btree/bt_open.c | 7 +++++- src/util/db2/clib/mkstemp.c | 6 ++++- src/util/db2/db/db.c | 2 +- src/util/db2/hash/dbm.c | 4 ++-- src/util/db2/hash/hash.c | 2 +- src/util/db2/hash/hsearch.c | 2 +- src/util/db2/include/db-int.h | 3 +++ src/util/db2/recno/rec_open.c | 8 +++---- src/util/db2/test/SEQ_TEST/t.c | 4 ++-- src/util/db2/test/btree.tests/main.c | 4 ++-- src/util/db2/test/dbtest.c | 2 +- src/util/db2/test/hash1.tests/driver2.c | 2 +- src/util/db2/test/hash1.tests/tcreat3.c | 2 +- src/util/db2/test/hash1.tests/tdel.c | 2 +- src/util/db2/test/hash1.tests/thash4.c | 2 +- src/util/db2/test/hash1.tests/tread2.c | 2 +- src/util/db2/test/hash1.tests/tseq.c | 2 +- src/util/db2/test/hash1.tests/tverify.c | 2 +- src/util/db2/test/hash2.tests/bigtest.c | 2 +- src/util/db2/test/hash2.tests/passtest.c | 8 +++---- 21 files changed, 67 insertions(+), 31 deletions(-) diff --git a/src/util/db2/ChangeLog b/src/util/db2/ChangeLog index 7bd6da565..d3581d7c2 100644 --- a/src/util/db2/ChangeLog +++ b/src/util/db2/ChangeLog @@ -1,4 +1,28 @@ -Thu Jan 15 11:34:13 1998 Ezra Peisach +Wed Jan 21 10:17:34 1998 Ezra Peisach + + * btree/bt_open.c: Added O_BINARY for __CYGWIN32__. + * clib/mkstemp.c: Added O_BINARY for __CYGWIN32__. + * db/db.c: Added O_BINARY for __CYGWIN32__. + * hash/dbm.c: Added O_BINARY for __CYGWIN32__. + * hash/hash.c: Added O_BINARY for __CYGWIN32__. + * hash/hsearch.c: Added O_BINARY for __CYGWIN32__. + * include/db-int.h: Added O_BINARY for __CYGWIN32__. + * recno/rec_open.c: Added O_BINARY for __CYGWIN32__. + * test/dbtest.c: Added O_BINARY for __CYGWIN32__. + * test/SEQ_TEST/t.c: Added O_BINARY for __CYGWIN32__. + * test/btree.tests/main.c: Added O_BINARY for __CYGWIN32__. + * test/hash1.tests/driver2.c: Added O_BINARY for __CYGWIN32__. + * test/hash1.tests/tcreat3.c: Added O_BINARY for __CYGWIN32__. + * test/hash1.tests/tdel.c: Added O_BINARY for __CYGWIN32__. + * test/hash1.tests/thash4.c: Added O_BINARY for __CYGWIN32__. + * test/hash1.tests/tread2.c: Added O_BINARY for __CYGWIN32__. + * test/hash1.tests/tseq.c: Added O_BINARY for __CYGWIN32__. + * test/hash1.tests/tverify.c: Added O_BINARY for __CYGWIN32__. + * test/hash2.tests/bigtest.c: Added O_BINARY for __CYGWIN32__. + * test/hash2.tests/passtest.c: Added O_BINARY for __CYGWIN32__. + Changes originally by Jeremy Allison (jra@cygnus.com) + +Thu Jan 15 11:34:13 1998 Ezra Peisach * hash/hash_bigkey.c (collect_key, collect_data): Cast malloc return value to correct types. (raeburn@cygnus.com) @@ -55,7 +79,7 @@ Wed Aug 28 17:25:10 1996 Tom Yu * include/db.h: Check SIZEOF_INT rather than UINT_MAX; it's broken under Ultrix. -Thu Aug 22 23:13:32 1996 Ezra Peisach +Thu Aug 22 23:13:32 1996 Ezra Peisach * Makefile.in: Add dummy rule for Makefiles. @@ -76,7 +100,7 @@ Fri Jul 26 00:41:45 1996 Theodore Y. Ts'o * Makefile.in (install): Add a blank install target to keep the top-level "make install" happy. -Tue Jul 23 16:08:43 1996 Ezra Peisach +Tue Jul 23 16:08:43 1996 Ezra Peisach * hash/dbm.c: Copy elements from the datum to an internal DBT. Handles case of differences in size of size fields. diff --git a/src/util/db2/btree/bt_open.c b/src/util/db2/btree/bt_open.c index 3a7aa9462..50fbe3f00 100644 --- a/src/util/db2/btree/bt_open.c +++ b/src/util/db2/btree/bt_open.c @@ -201,7 +201,7 @@ __bt_open(fname, flags, mode, openinfo, dflags) goto einval; } - if ((t->bt_fd = open(fname, flags, mode)) < 0) + if ((t->bt_fd = open(fname, flags | O_BINARY, mode)) < 0) goto err; } else { @@ -427,6 +427,11 @@ tmp() #else sigsetmask(oset); #endif +#ifdef __CYGWIN32__ + /* Ensure the fd is in binary mode. */ + setmode(fd, O_BINARY); +#endif /* __CYGWIN32__ */ + return(fd); } diff --git a/src/util/db2/clib/mkstemp.c b/src/util/db2/clib/mkstemp.c index 07d4186a9..89251104a 100644 --- a/src/util/db2/clib/mkstemp.c +++ b/src/util/db2/clib/mkstemp.c @@ -42,6 +42,10 @@ static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93"; #include #include +#ifndef O_BINARY +#define O_BINARY 0 +#endif + static int _gettemp(); mkstemp(path) @@ -92,7 +96,7 @@ _gettemp(path, doopen) for (;;) { if (doopen) { if ((*doopen = - open(path, O_CREAT|O_EXCL|O_RDWR, 0600)) >= 0) + open(path, O_CREAT|O_EXCL|O_RDWR|O_BINARY, 0600)) >= 0) return(1); if (errno != EEXIST) return(0); diff --git a/src/util/db2/db/db.c b/src/util/db2/db/db.c index dc38abdc4..e236afbd0 100644 --- a/src/util/db2/db/db.c +++ b/src/util/db2/db/db.c @@ -55,7 +55,7 @@ dbopen(fname, flags, mode, type, openinfo) #define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN) #define USE_OPEN_FLAGS \ (O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \ - O_RDWR | O_SHLOCK | O_TRUNC) + O_RDWR | O_SHLOCK | O_TRUNC | O_BINARY) if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0) switch (type) { diff --git a/src/util/db2/hash/dbm.c b/src/util/db2/hash/dbm.c index 474512775..7b83da09d 100644 --- a/src/util/db2/hash/dbm.c +++ b/src/util/db2/hash/dbm.c @@ -73,9 +73,9 @@ dbminit(file) { if (__cur_db != NULL) (void)dbm_close(__cur_db); - if ((__cur_db = dbm_open(file, O_RDWR, 0)) != NULL) + if ((__cur_db = dbm_open(file, O_RDWR|O_BINARY, 0)) != NULL) return (0); - if ((__cur_db = dbm_open(file, O_RDONLY, 0)) != NULL) + if ((__cur_db = dbm_open(file, O_RDONLY|O_BINARY, 0)) != NULL) return (0); return (-1); } diff --git a/src/util/db2/hash/hash.c b/src/util/db2/hash/hash.c index e52275438..8e9f7f073 100644 --- a/src/util/db2/hash/hash.c +++ b/src/util/db2/hash/hash.c @@ -140,7 +140,7 @@ __hash_open(file, flags, mode, info, dflags) new_table = 1; } if (file) { - if ((hashp->fp = open(file, flags, mode)) == -1) + if ((hashp->fp = open(file, flags|O_BINARY, mode)) == -1) RETURN_ERROR(errno, error0); (void)fcntl(hashp->fp, F_SETFD, 1); } diff --git a/src/util/db2/hash/hsearch.c b/src/util/db2/hash/hsearch.c index f257cd6ea..02ff7ef84 100644 --- a/src/util/db2/hash/hsearch.c +++ b/src/util/db2/hash/hsearch.c @@ -61,7 +61,7 @@ hcreate(nel) info.cachesize = 0; info.hash = NULL; info.lorder = 0; - dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0); + dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR | O_BINARY, 0600, &info, 0); return (dbp != NULL); } diff --git a/src/util/db2/include/db-int.h b/src/util/db2/include/db-int.h index 78be4c8a3..f9da8a284 100644 --- a/src/util/db2/include/db-int.h +++ b/src/util/db2/include/db-int.h @@ -205,4 +205,7 @@ void __dbpanic __P((DB *dbp)); #define S_ISSOCK(m) ((m & 0170000) == 0140000) /* socket */ #endif +#ifndef O_BINARY +#define O_BINARY 0 /* Needed for Win32 compiles */ +#endif #endif /* _DB_INT_H_ */ diff --git a/src/util/db2/recno/rec_open.c b/src/util/db2/recno/rec_open.c index fccaacc90..f18a1cb02 100644 --- a/src/util/db2/recno/rec_open.c +++ b/src/util/db2/recno/rec_open.c @@ -68,7 +68,7 @@ __rec_open(fname, flags, mode, openinfo, dflags) int rfd, sverrno; /* Open the user's file -- if this fails, we're done. */ - if (fname != NULL && (rfd = open(fname, flags, mode)) < 0) + if (fname != NULL && (rfd = open(fname, flags | O_BINARY, mode)) < 0) return (NULL); /* Create a btree in memory (backed by disk). */ @@ -85,9 +85,9 @@ __rec_open(fname, flags, mode, openinfo, dflags) btopeninfo.prefix = NULL; btopeninfo.lorder = openinfo->lorder; dbp = __bt_open(openinfo->bfname, - O_RDWR, S_IRUSR | S_IWUSR, &btopeninfo, dflags); + O_RDWR | O_BINARY, S_IRUSR | S_IWUSR, &btopeninfo, dflags); } else - dbp = __bt_open(NULL, O_RDWR, S_IRUSR | S_IWUSR, NULL, dflags); + dbp = __bt_open(NULL, O_RDWR | O_BINARY, S_IRUSR | S_IWUSR, NULL, dflags); if (dbp == NULL) goto err; @@ -130,7 +130,7 @@ __rec_open(fname, flags, mode, openinfo, dflags) default: goto einval; } -slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL) +slow: if ((t->bt_rfp = fdopen(rfd, "rb")) == NULL) goto err; F_SET(t, R_CLOSEFP); t->bt_irec = diff --git a/src/util/db2/test/SEQ_TEST/t.c b/src/util/db2/test/SEQ_TEST/t.c index ac0fef71e..31262b2d9 100644 --- a/src/util/db2/test/SEQ_TEST/t.c +++ b/src/util/db2/test/SEQ_TEST/t.c @@ -23,7 +23,7 @@ void main(int argc, char *argv[]) { printf("Unable to open %s\n","data"); exit(25); } - if ((dbp = dbopen("test.db",O_RDWR | O_CREAT, 0664 + if ((dbp = dbopen("test.db",O_RDWR | O_CREAT | O_BINARY, 0664 , DB_BTREE, NULL )) == NULL) { printf("\n Open error on test.db %d %s\n",errno,strerror(errno)); exit(25); @@ -43,7 +43,7 @@ void main(int argc, char *argv[]) { printf("%d Records in\n",out); dbp->close(dbp); - if ((dbp = dbopen("test.db", O_RDWR, 0664 + if ((dbp = dbopen("test.db", O_RDWR | O_BINARY, 0664 , DB_BTREE, NULL )) == NULL) { printf("\n Error on dbopen %d %s\n",errno,strerror(errno)); exit(61); diff --git a/src/util/db2/test/btree.tests/main.c b/src/util/db2/test/btree.tests/main.c index 02f1b9628..61c9731cc 100644 --- a/src/util/db2/test/btree.tests/main.c +++ b/src/util/db2/test/btree.tests/main.c @@ -169,10 +169,10 @@ main(argc, argv) argv += optind; if (recno) - db = dbopen(*argv == NULL ? NULL : *argv, O_RDWR, + db = dbopen(*argv == NULL ? NULL : *argv, O_RDWR|O_BINARY, 0, DB_RECNO, NULL); else - db = dbopen(*argv == NULL ? NULL : *argv, O_CREAT|O_RDWR, + db = dbopen(*argv == NULL ? NULL : *argv, O_CREAT|O_RDWR|O_BINARY, 0600, DB_BTREE, &b); if (db == NULL) { diff --git a/src/util/db2/test/dbtest.c b/src/util/db2/test/dbtest.c index f49228165..170a0ea0f 100644 --- a/src/util/db2/test/dbtest.c +++ b/src/util/db2/test/dbtest.c @@ -99,7 +99,7 @@ main(argc, argv) infoarg = NULL; fname = NULL; - oflags = O_CREAT | O_RDWR; + oflags = O_CREAT | O_RDWR | O_BINARY; sflag = 0; while ((ch = getopt(argc, argv, "f:i:lo:s")) != EOF) switch (ch) { diff --git a/src/util/db2/test/hash1.tests/driver2.c b/src/util/db2/test/hash1.tests/driver2.c index 074f9eae0..6a3b432cb 100644 --- a/src/util/db2/test/hash1.tests/driver2.c +++ b/src/util/db2/test/hash1.tests/driver2.c @@ -81,7 +81,7 @@ main(argc, argv) info.hash = my_hash; #endif info.lorder = 0; - if (!(db = dbopen("bigtest", O_RDWR | O_CREAT, 0644, DB_HASH, &info))) { + if (!(db = dbopen("bigtest", O_RDWR | O_CREAT | O_BINARY, 0644, DB_HASH, &info))) { sprintf(buf, "dbopen: failed on file bigtest"); perror(buf); exit(1); diff --git a/src/util/db2/test/hash1.tests/tcreat3.c b/src/util/db2/test/hash1.tests/tcreat3.c index 3aaab99cb..f11487b32 100644 --- a/src/util/db2/test/hash1.tests/tcreat3.c +++ b/src/util/db2/test/hash1.tests/tcreat3.c @@ -72,7 +72,7 @@ char **argv; ctl.nelem = atoi(*argv++); ctl.lorder = 0; if (!(dbp = dbopen( "hashtest", - O_CREAT|O_TRUNC|O_RDWR, 0600, DB_HASH, &ctl))){ + O_CREAT|O_TRUNC|O_RDWR|O_BINARY, 0600, DB_HASH, &ctl))){ /* create table */ fprintf(stderr, "cannot create: hash table (size %d)\n", INITIAL); diff --git a/src/util/db2/test/hash1.tests/tdel.c b/src/util/db2/test/hash1.tests/tdel.c index b542d8ef3..826611486 100644 --- a/src/util/db2/test/hash1.tests/tdel.c +++ b/src/util/db2/test/hash1.tests/tdel.c @@ -74,7 +74,7 @@ char **argv; ctl.cachesize = 1024 * 1024; /* 1 MEG */ ctl.lorder = 0; argc -= 2; - if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) { + if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR|O_BINARY, 0400, DB_HASH, &ctl))) { /* create table */ fprintf(stderr, "cannot create: hash table size %d)\n", INITIAL); diff --git a/src/util/db2/test/hash1.tests/thash4.c b/src/util/db2/test/hash1.tests/thash4.c index b0d4b42e3..b15b617bc 100644 --- a/src/util/db2/test/hash1.tests/thash4.c +++ b/src/util/db2/test/hash1.tests/thash4.c @@ -75,7 +75,7 @@ char **argv; ctl.nelem = atoi(*argv++); ctl.cachesize = atoi(*argv++); ctl.lorder = 0; - if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR, 0400, DB_HASH, &ctl))) { + if (!(dbp = dbopen( NULL, O_CREAT|O_RDWR|O_BINARY, 0400, DB_HASH, &ctl))) { /* create table */ fprintf(stderr, "cannot create: hash table size %d)\n", INITIAL); diff --git a/src/util/db2/test/hash1.tests/tread2.c b/src/util/db2/test/hash1.tests/tread2.c index 44acaa93d..1e2cc4c50 100644 --- a/src/util/db2/test/hash1.tests/tread2.c +++ b/src/util/db2/test/hash1.tests/tread2.c @@ -74,7 +74,7 @@ char **argv; ctl.ffactor = 1; ctl.cachesize = atoi(*argv++); ctl.lorder = 0; - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) { + if (!(dbp = dbopen( "hashtest", O_RDONLY|O_BINARY, 0400, DB_HASH, &ctl))) { /* create table */ fprintf(stderr, "cannot open: hash table\n" ); exit(1); diff --git a/src/util/db2/test/hash1.tests/tseq.c b/src/util/db2/test/hash1.tests/tseq.c index 5eee5de61..d2d36862d 100644 --- a/src/util/db2/test/hash1.tests/tseq.c +++ b/src/util/db2/test/hash1.tests/tseq.c @@ -63,7 +63,7 @@ char **argv; FILE *fp; int stat; - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, NULL))) { + if (!(dbp = dbopen( "hashtest", O_RDONLY|O_BINARY, 0400, DB_HASH, NULL))) { /* create table */ fprintf(stderr, "cannot open: hash table\n" ); exit(1); diff --git a/src/util/db2/test/hash1.tests/tverify.c b/src/util/db2/test/hash1.tests/tverify.c index a5a5dfd18..4747804f7 100644 --- a/src/util/db2/test/hash1.tests/tverify.c +++ b/src/util/db2/test/hash1.tests/tverify.c @@ -75,7 +75,7 @@ char **argv; ctl.ffactor = 1; ctl.cachesize = 1024 * 1024; /* 1 MEG */ ctl.lorder = 0; - if (!(dbp = dbopen( "hashtest", O_RDONLY, 0400, DB_HASH, &ctl))) { + if (!(dbp = dbopen( "hashtest", O_RDONLY|O_BINARY, 0400, DB_HASH, &ctl))) { /* create table */ fprintf(stderr, "cannot open: hash table\n" ); exit(1); diff --git a/src/util/db2/test/hash2.tests/bigtest.c b/src/util/db2/test/hash2.tests/bigtest.c index e6d4108b7..81c559ad2 100644 --- a/src/util/db2/test/hash2.tests/bigtest.c +++ b/src/util/db2/test/hash2.tests/bigtest.c @@ -20,7 +20,7 @@ main(void) info.nelem = 0; info.hash = NULL; - db = dbopen("big2.db", O_RDWR|O_CREAT|O_TRUNC, 0664, DB_HASH, &info); + db = dbopen("big2.db", O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0664, DB_HASH, &info); data = malloc(800 * sizeof(int)); for (n = 0; n < 800; n++) data[n] = 0xDEADBEEF; diff --git a/src/util/db2/test/hash2.tests/passtest.c b/src/util/db2/test/hash2.tests/passtest.c index d6277ca52..adb72c004 100644 --- a/src/util/db2/test/hash2.tests/passtest.c +++ b/src/util/db2/test/hash2.tests/passtest.c @@ -30,7 +30,7 @@ main(void) passwd.lorder = 4321; - db = dbopen("/usr/tmp/passwd.db", O_RDWR|O_CREAT|O_TRUNC, 0664, DB_HASH, + db = dbopen("/usr/tmp/passwd.db", O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0664, DB_HASH, &passwd); if (!db) { fprintf(stderr, "create_db: couldn't create database file\n"); @@ -66,7 +66,7 @@ main(void) get_key = (char *)malloc(100); get_val = (char *)malloc(300); - db = dbopen("/usr/tmp/passwd.db", O_RDWR, 0664, DB_HASH, &passwd); + db = dbopen("/usr/tmp/passwd.db", O_RDWR|O_BINARY, 0664, DB_HASH, &passwd); if (!db) fprintf(stderr, "Could not open db!\n"); n = 0; @@ -123,7 +123,7 @@ main(void) keys = fopen("yp.keys", "rt"); vals = fopen("yp.total", "rt"); - db = dbopen("/usr/tmp/passwd.db", O_RDWR, 0664, DB_HASH, &passwd); + db = dbopen("/usr/tmp/passwd.db", O_RDWR|O_BINARY, 0664, DB_HASH, &passwd); n = 0; while ((get_key = fgets(get_key, 100, keys)) != NULL) { if (n % 1000 == 0) @@ -151,7 +151,7 @@ main(void) keys = fopen("yp.keys", "rt"); vals = fopen("yp.total", "rt"); - db = dbopen("/usr/tmp/passwd.db", O_RDWR, 0664, DB_HASH, &passwd); + db = dbopen("/usr/tmp/passwd.db", O_RDWR|O_BINARY, 0664, DB_HASH, &passwd); n = 0; while ((get_key = fgets(get_key, 100, keys)) != NULL) { n += 2; -- 2.26.2