From ba75a66f20739920656736c08e5ef161f4a932e3 Mon Sep 17 00:00:00 2001 From: groo Date: Fri, 1 Jun 2001 15:17:23 +0000 Subject: Apply patch to tdb.c so that it works on pre-UBC systems. .tdb databases were previously enlarged by the sequence: lseek, write, munmap, mmap and are now enlarged by: munmap, lseek, write, mmap. The Samba team is already aware of the problem. I expect this patch will be incorporated in a future release. --- net/samba/patches/patch-ad | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 net/samba/patches/patch-ad (limited to 'net/samba/patches/patch-ad') diff --git a/net/samba/patches/patch-ad b/net/samba/patches/patch-ad new file mode 100644 index 00000000000..95e3b7ba7cf --- /dev/null +++ b/net/samba/patches/patch-ad @@ -0,0 +1,43 @@ +$NetBSD: patch-ad,v 1.7 2001/06/01 15:17:23 groo Exp $ + +--- tdb/tdb.c.orig Thu May 31 23:27:21 2001 ++++ tdb/tdb.c Thu May 31 23:29:55 2001 +@@ -439,20 +439,24 @@ + the database up to a multiple of TDB_PAGE_SIZE */ + size = TDB_ALIGN(tdb->map_size + size*10, TDB_PAGE_SIZE) - tdb->map_size; + ++ if (!(tdb->flags & TDB_INTERNAL) && tdb->map_ptr) ++ tdb->map_ptr = tdb_munmap(tdb->map_ptr, tdb->map_size); ++ + /* expand the file itself */ + if (!(tdb->flags & TDB_INTERNAL)) { +- lseek(tdb->fd, tdb->map_size + size - 1, SEEK_SET); ++ if (lseek(tdb->fd, tdb->map_size + size - 1, SEEK_SET)!=tdb->map_size + size - 1) ++ goto fail; + if (write(tdb->fd, &b, 1) != 1) goto fail; + } + +- if (!(tdb->flags & TDB_INTERNAL) && tdb->map_ptr) +- tdb->map_ptr = tdb_munmap(tdb->map_ptr, tdb->map_size); +- + tdb->map_size += size; + + if (tdb->flags & TDB_INTERNAL) + tdb->map_ptr = realloc(tdb->map_ptr, tdb->map_size); + ++ if (!(tdb->flags & TDB_NOMMAP)) ++ tdb->map_ptr = tdb_mmap(tdb->map_size, 0, tdb->fd); ++ + /* form a new freelist record */ + memset(&rec,'\0',sizeof(rec)); + rec.rec_len = size - sizeof(rec); +@@ -460,9 +464,6 @@ + /* link it into the free list */ + offset = tdb->map_size - size; + if (tdb_free(tdb, offset, &rec) == -1) goto fail; +- +- if (!(tdb->flags & TDB_NOMMAP)) +- tdb->map_ptr = tdb_mmap(tdb->map_size, 0, tdb->fd); + + tdb_unlock(tdb, -1, F_WRLCK); + return 0; -- cgit v1.2.3