diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-04-30 11:04:28 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-04-30 11:04:28 +0000 |
commit | 700f72453ed8dfd356a5591b9447127b5066ac4b (patch) | |
tree | 46a30958a2f160cf389a9309355c3ebc39c584fd /source3/tdb/tdb.c | |
parent | 71e7974f3f847759ba6f844ea7f482786cc5db02 (diff) | |
download | samba-700f72453ed8dfd356a5591b9447127b5066ac4b.tar.gz samba-700f72453ed8dfd356a5591b9447127b5066ac4b.tar.bz2 samba-700f72453ed8dfd356a5591b9447127b5066ac4b.zip |
- removed all our old wildcard matching code and replaced it with a
call to ms_fnmatch(). This also removes all the Win9X semantics stuff
and a bunch of other associated cruft.
- moved the stat cache code into statcache.c
- fixed the uint16 alignment requirements of ascii_to_unistr() and
unistr_to_ascii()
- trans2 SMB_FIND_FILE_BOTH_DIRECTORY_INFO returns the short name as
unicode always (at least thats what NT4 does)
- fixed some errors in the in-memory tdb code. Still ugly, but doesn't
crash as much
(This used to be commit 03e9cea004bbba72161a5323cf3b4556c94aed8e)
Diffstat (limited to 'source3/tdb/tdb.c')
-rw-r--r-- | source3/tdb/tdb.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index c8860e2191..a1483d42d2 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -499,7 +499,7 @@ static int tdb_new_database(TDB_CONTEXT *tdb, int hash_size) header.version = TDB_VERSION; header.hash_size = hash_size; lseek(tdb->fd, 0, SEEK_SET); - ftruncate(tdb->fd, 0); + if (tdb->fd != -1) ftruncate(tdb->fd, 0); if (tdb->fd != -1 && write(tdb->fd, &header, sizeof(header)) != sizeof(header)) { @@ -1150,12 +1150,12 @@ TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags, tdb.read_only = ((open_flags & O_ACCMODE) == O_RDONLY); - if (name != NULL) { - tdb.fd = open(name, open_flags, mode); - if (tdb.fd == -1) { + if (name == NULL) goto in_memory; + + tdb.fd = open(name, open_flags, mode); + if (tdb.fd == -1) { goto fail; - } - } + } /* ensure there is only one process initialising at once */ tdb_brlock(&tdb, GLOBAL_LOCK, LOCK_SET, F_WRLCK, F_SETLKW); @@ -1182,19 +1182,15 @@ TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags, if (tdb_new_database(&tdb, hash_size) == -1) goto fail; lseek(tdb.fd, 0, SEEK_SET); - if (tdb.fd != -1 && read(tdb.fd, &tdb.header, - sizeof(tdb.header)) != - sizeof(tdb.header)) + if (read(tdb.fd, &tdb.header, sizeof(tdb.header)) != sizeof(tdb.header)) goto fail; } - if (tdb.fd != -1) { - fstat(tdb.fd, &st); + fstat(tdb.fd, &st); - /* map the database and fill in the return structure */ - tdb.name = (char *)strdup(name); - tdb.map_size = st.st_size; - } + /* map the database and fill in the return structure */ + tdb.name = (char *)strdup(name); + tdb.map_size = st.st_size; tdb.locked = (int *)calloc(tdb.header.hash_size+1, sizeof(tdb.locked[0])); @@ -1203,13 +1199,12 @@ TDB_CONTEXT *tdb_open(char *name, int hash_size, int tdb_flags, } #if HAVE_MMAP - if (tdb.fd != -1) { - tdb.map_ptr = (void *)mmap(NULL, st.st_size, - tdb.read_only? PROT_READ : PROT_READ|PROT_WRITE, - MAP_SHARED | MAP_FILE, tdb.fd, 0); - } + tdb.map_ptr = (void *)mmap(NULL, st.st_size, + tdb.read_only? PROT_READ : PROT_READ|PROT_WRITE, + MAP_SHARED | MAP_FILE, tdb.fd, 0); #endif + in_memory: ret = (TDB_CONTEXT *)malloc(sizeof(tdb)); if (!ret) goto fail; |