2011-12-05 13:49:48 +04:00
/*
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
Unix SMB / CIFS implementation .
Database interface wrapper around tdb
Copyright ( C ) Volker Lendecke 2005 - 2007
2011-12-05 13:49:48 +04:00
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
( at your option ) any later version .
2011-12-05 13:49:48 +04:00
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2011-12-05 13:49:48 +04:00
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
*/
# include "includes.h"
2011-07-07 19:42:08 +04:00
# include "dbwrap/dbwrap.h"
2011-08-24 16:53:42 +04:00
# include "dbwrap/dbwrap_private.h"
2011-08-16 17:58:27 +04:00
# include "dbwrap/dbwrap_tdb.h"
2012-03-11 00:33:11 +04:00
# include "lib/tdb_wrap/tdb_wrap.h"
2012-05-12 00:11:42 +04:00
# include "lib/util/util_tdb.h"
2012-02-15 17:57:01 +04:00
# include "system/filesys.h"
2012-06-22 09:37:43 +04:00
# include "ccan/str/str.h"
2014-03-26 18:26:24 +04:00
# include "lib/param/param.h"
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
struct db_tdb_ctx {
2007-06-03 10:54:51 +04:00
struct tdb_wrap * wtdb ;
2012-02-15 17:57:01 +04:00
struct {
dev_t dev ;
ino_t ino ;
} id ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
} ;
static NTSTATUS db_tdb_store ( struct db_record * rec , TDB_DATA data , int flag ) ;
static NTSTATUS db_tdb_delete ( struct db_record * rec ) ;
2011-12-07 17:50:54 +04:00
static void db_tdb_log_key ( const char * prefix , TDB_DATA key )
{
size_t len ;
char * keystr ;
2012-10-24 11:23:04 +04:00
TALLOC_CTX * frame ;
2011-12-07 17:50:54 +04:00
if ( DEBUGLEVEL < 10 ) {
return ;
}
2012-10-24 11:23:04 +04:00
frame = talloc_stackframe ( ) ;
2011-12-07 17:50:54 +04:00
len = key . dsize ;
if ( DEBUGLEVEL = = 10 ) {
/*
* Only fully spam at debuglevel > 10
*/
len = MIN ( 10 , key . dsize ) ;
}
2012-10-24 11:23:04 +04:00
keystr = hex_encode_talloc ( frame , ( unsigned char * ) ( key . dptr ) ,
2011-12-07 17:50:54 +04:00
len ) ;
DEBUG ( 10 , ( " %s key %s \n " , prefix , keystr ) ) ;
2012-10-24 11:23:04 +04:00
TALLOC_FREE ( frame ) ;
2011-12-07 17:50:54 +04:00
}
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
static int db_tdb_record_destr ( struct db_record * data )
{
struct db_tdb_ctx * ctx =
talloc_get_type_abort ( data - > private_data , struct db_tdb_ctx ) ;
2011-12-07 17:50:54 +04:00
db_tdb_log_key ( " Unlocking " , data - > key ) ;
2011-06-20 13:10:31 +04:00
tdb_chainunlock ( ctx - > wtdb - > tdb , data - > key ) ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
return 0 ;
}
2008-01-07 02:14:24 +03:00
struct tdb_fetch_locked_state {
TALLOC_CTX * mem_ctx ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
struct db_record * result ;
2008-01-07 02:14:24 +03:00
} ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
2008-01-07 02:14:24 +03:00
static int db_tdb_fetchlock_parse ( TDB_DATA key , TDB_DATA data ,
void * private_data )
{
struct tdb_fetch_locked_state * state =
( struct tdb_fetch_locked_state * ) private_data ;
2011-12-09 19:39:09 +04:00
struct db_record * result ;
2008-01-07 02:14:24 +03:00
2011-12-09 19:39:09 +04:00
result = ( struct db_record * ) talloc_size (
2008-01-07 02:14:24 +03:00
state - > mem_ctx ,
sizeof ( struct db_record ) + key . dsize + data . dsize ) ;
2011-12-09 19:39:09 +04:00
if ( result = = NULL ) {
2008-01-07 02:14:24 +03:00
return 0 ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
}
2011-12-09 19:39:09 +04:00
state - > result = result ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
2011-12-09 19:39:09 +04:00
result - > key . dsize = key . dsize ;
2012-05-11 23:56:03 +04:00
result - > key . dptr = ( ( uint8_t * ) result ) + sizeof ( struct db_record ) ;
2011-12-09 19:39:09 +04:00
memcpy ( result - > key . dptr , key . dptr , key . dsize ) ;
2008-01-07 02:14:24 +03:00
2011-12-09 19:39:09 +04:00
result - > value . dsize = data . dsize ;
2008-01-07 02:14:24 +03:00
if ( data . dsize > 0 ) {
2011-12-09 19:39:09 +04:00
result - > value . dptr = result - > key . dptr + key . dsize ;
memcpy ( result - > value . dptr , data . dptr , data . dsize ) ;
2008-01-07 02:14:24 +03:00
}
else {
2011-12-09 19:39:09 +04:00
result - > value . dptr = NULL ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
}
2008-01-07 02:14:24 +03:00
return 0 ;
}
2012-03-27 16:31:04 +04:00
static struct db_record * db_tdb_fetch_locked_internal (
struct db_context * db , TALLOC_CTX * mem_ctx , TDB_DATA key )
2008-01-07 02:14:24 +03:00
{
struct db_tdb_ctx * ctx = talloc_get_type_abort ( db - > private_data ,
struct db_tdb_ctx ) ;
struct tdb_fetch_locked_state state ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
2008-01-07 02:14:24 +03:00
state . mem_ctx = mem_ctx ;
state . result = NULL ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
2012-04-19 12:47:07 +04:00
if ( ( tdb_parse_record ( ctx - > wtdb - > tdb , key , db_tdb_fetchlock_parse ,
& state ) < 0 ) & &
( tdb_error ( ctx - > wtdb - > tdb ) ! = TDB_ERR_NOEXIST ) ) {
tdb_chainunlock ( ctx - > wtdb - > tdb , key ) ;
return NULL ;
}
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
2008-01-07 02:14:24 +03:00
if ( state . result = = NULL ) {
db_tdb_fetchlock_parse ( key , tdb_null , & state ) ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
}
2008-01-07 02:14:24 +03:00
if ( state . result = = NULL ) {
tdb_chainunlock ( ctx - > wtdb - > tdb , key ) ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
return NULL ;
}
2008-01-07 02:14:24 +03:00
talloc_set_destructor ( state . result , db_tdb_record_destr ) ;
state . result - > private_data = talloc_reference ( state . result , ctx ) ;
state . result - > store = db_tdb_store ;
state . result - > delete_rec = db_tdb_delete ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
2008-01-07 02:14:24 +03:00
DEBUG ( 10 , ( " Allocated locked data 0x%p \n " , state . result ) ) ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
2008-01-07 02:14:24 +03:00
return state . result ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
}
2012-03-27 16:31:04 +04:00
static struct db_record * db_tdb_fetch_locked (
struct db_context * db , TALLOC_CTX * mem_ctx , TDB_DATA key )
{
struct db_tdb_ctx * ctx = talloc_get_type_abort ( db - > private_data ,
struct db_tdb_ctx ) ;
db_tdb_log_key ( " Locking " , key ) ;
if ( tdb_chainlock ( ctx - > wtdb - > tdb , key ) ! = 0 ) {
DEBUG ( 3 , ( " tdb_chainlock failed \n " ) ) ;
return NULL ;
}
return db_tdb_fetch_locked_internal ( db , mem_ctx , key ) ;
}
static struct db_record * db_tdb_try_fetch_locked (
struct db_context * db , TALLOC_CTX * mem_ctx , TDB_DATA key )
{
struct db_tdb_ctx * ctx = talloc_get_type_abort ( db - > private_data ,
struct db_tdb_ctx ) ;
db_tdb_log_key ( " Trying to lock " , key ) ;
if ( tdb_chainlock_nonblock ( ctx - > wtdb - > tdb , key ) ! = 0 ) {
DEBUG ( 3 , ( " tdb_chainlock_nonblock failed \n " ) ) ;
return NULL ;
}
return db_tdb_fetch_locked_internal ( db , mem_ctx , key ) ;
}
2011-07-04 12:27:17 +04:00
static int db_tdb_exists ( struct db_context * db , TDB_DATA key )
{
struct db_tdb_ctx * ctx = talloc_get_type_abort (
db - > private_data , struct db_tdb_ctx ) ;
return tdb_exists ( ctx - > wtdb - > tdb , key ) ;
}
2011-08-16 16:43:29 +04:00
static int db_tdb_wipe ( struct db_context * db )
{
struct db_tdb_ctx * ctx = talloc_get_type_abort (
db - > private_data , struct db_tdb_ctx ) ;
return tdb_wipe_all ( ctx - > wtdb - > tdb ) ;
}
2012-06-22 09:37:43 +04:00
static int db_tdb_check ( struct db_context * db )
{
struct db_tdb_ctx * ctx = talloc_get_type_abort (
db - > private_data , struct db_tdb_ctx ) ;
return tdb_check ( ctx - > wtdb - > tdb , NULL , NULL ) ;
}
2011-12-08 18:50:33 +04:00
struct db_tdb_parse_state {
void ( * parser ) ( TDB_DATA key , TDB_DATA data ,
void * private_data ) ;
void * private_data ;
} ;
/*
* tdb_parse_record expects a parser returning int , mixing up tdb and
* parser errors . Wrap around that by always returning 0 and have
* dbwrap_parse_record expect a parser returning void .
*/
static int db_tdb_parser ( TDB_DATA key , TDB_DATA data , void * private_data )
{
struct db_tdb_parse_state * state =
( struct db_tdb_parse_state * ) private_data ;
state - > parser ( key , data , state - > private_data ) ;
return 0 ;
}
static NTSTATUS db_tdb_parse ( struct db_context * db , TDB_DATA key ,
void ( * parser ) ( TDB_DATA key , TDB_DATA data ,
void * private_data ) ,
void * private_data )
2009-02-22 02:47:54 +03:00
{
struct db_tdb_ctx * ctx = talloc_get_type_abort (
db - > private_data , struct db_tdb_ctx ) ;
2011-12-08 18:50:33 +04:00
struct db_tdb_parse_state state ;
int ret ;
state . parser = parser ;
state . private_data = private_data ;
2009-02-22 02:47:54 +03:00
2011-12-08 18:50:33 +04:00
ret = tdb_parse_record ( ctx - > wtdb - > tdb , key , db_tdb_parser , & state ) ;
2011-12-16 17:51:46 +04:00
if ( ret ! = 0 ) {
return map_nt_error_from_tdb ( tdb_error ( ctx - > wtdb - > tdb ) ) ;
}
return NT_STATUS_OK ;
2009-02-22 02:47:54 +03:00
}
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
static NTSTATUS db_tdb_store ( struct db_record * rec , TDB_DATA data , int flag )
{
struct db_tdb_ctx * ctx = talloc_get_type_abort ( rec - > private_data ,
struct db_tdb_ctx ) ;
/*
* This has a bug : We need to replace rec - > value for correct
* operation , but right now brlock and locking don ' t use the value
* anymore after it was stored .
*/
2007-06-03 10:54:51 +04:00
return ( tdb_store ( ctx - > wtdb - > tdb , rec - > key , data , flag ) = = 0 ) ?
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
NT_STATUS_OK : NT_STATUS_UNSUCCESSFUL ;
}
static NTSTATUS db_tdb_delete ( struct db_record * rec )
{
struct db_tdb_ctx * ctx = talloc_get_type_abort ( rec - > private_data ,
struct db_tdb_ctx ) ;
2008-01-24 21:06:25 +03:00
if ( tdb_delete ( ctx - > wtdb - > tdb , rec - > key ) = = 0 ) {
return NT_STATUS_OK ;
}
if ( tdb_error ( ctx - > wtdb - > tdb ) = = TDB_ERR_NOEXIST ) {
return NT_STATUS_NOT_FOUND ;
}
return NT_STATUS_UNSUCCESSFUL ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
}
struct db_tdb_traverse_ctx {
struct db_context * db ;
int ( * f ) ( struct db_record * rec , void * private_data ) ;
void * private_data ;
} ;
static int db_tdb_traverse_func ( TDB_CONTEXT * tdb , TDB_DATA kbuf , TDB_DATA dbuf ,
void * private_data )
{
struct db_tdb_traverse_ctx * ctx =
( struct db_tdb_traverse_ctx * ) private_data ;
struct db_record rec ;
rec . key = kbuf ;
rec . value = dbuf ;
rec . store = db_tdb_store ;
rec . delete_rec = db_tdb_delete ;
rec . private_data = ctx - > db - > private_data ;
2012-01-02 16:30:51 +04:00
rec . db = ctx - > db ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
return ctx - > f ( & rec , ctx - > private_data ) ;
}
static int db_tdb_traverse ( struct db_context * db ,
int ( * f ) ( struct db_record * rec , void * private_data ) ,
void * private_data )
{
struct db_tdb_ctx * db_ctx =
talloc_get_type_abort ( db - > private_data , struct db_tdb_ctx ) ;
struct db_tdb_traverse_ctx ctx ;
ctx . db = db ;
ctx . f = f ;
ctx . private_data = private_data ;
2007-06-03 10:54:51 +04:00
return tdb_traverse ( db_ctx - > wtdb - > tdb , db_tdb_traverse_func , & ctx ) ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
}
2007-05-29 22:04:38 +04:00
static NTSTATUS db_tdb_store_deny ( struct db_record * rec , TDB_DATA data , int flag )
{
return NT_STATUS_MEDIA_WRITE_PROTECTED ;
}
static NTSTATUS db_tdb_delete_deny ( struct db_record * rec )
{
return NT_STATUS_MEDIA_WRITE_PROTECTED ;
}
static int db_tdb_traverse_read_func ( TDB_CONTEXT * tdb , TDB_DATA kbuf , TDB_DATA dbuf ,
void * private_data )
{
struct db_tdb_traverse_ctx * ctx =
( struct db_tdb_traverse_ctx * ) private_data ;
struct db_record rec ;
rec . key = kbuf ;
rec . value = dbuf ;
rec . store = db_tdb_store_deny ;
rec . delete_rec = db_tdb_delete_deny ;
rec . private_data = ctx - > db - > private_data ;
2012-01-02 16:30:51 +04:00
rec . db = ctx - > db ;
2007-05-29 22:04:38 +04:00
return ctx - > f ( & rec , ctx - > private_data ) ;
}
static int db_tdb_traverse_read ( struct db_context * db ,
int ( * f ) ( struct db_record * rec , void * private_data ) ,
void * private_data )
{
struct db_tdb_ctx * db_ctx =
talloc_get_type_abort ( db - > private_data , struct db_tdb_ctx ) ;
struct db_tdb_traverse_ctx ctx ;
ctx . db = db ;
ctx . f = f ;
ctx . private_data = private_data ;
2007-06-03 10:54:51 +04:00
return tdb_traverse_read ( db_ctx - > wtdb - > tdb , db_tdb_traverse_read_func , & ctx ) ;
2007-05-29 22:04:38 +04:00
}
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
static int db_tdb_get_seqnum ( struct db_context * db )
{
struct db_tdb_ctx * db_ctx =
talloc_get_type_abort ( db - > private_data , struct db_tdb_ctx ) ;
2007-06-03 10:54:51 +04:00
return tdb_get_seqnum ( db_ctx - > wtdb - > tdb ) ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
}
2008-03-10 12:17:05 +03:00
static int db_tdb_transaction_start ( struct db_context * db )
{
struct db_tdb_ctx * db_ctx =
talloc_get_type_abort ( db - > private_data , struct db_tdb_ctx ) ;
2011-09-14 02:43:28 +04:00
return tdb_transaction_start ( db_ctx - > wtdb - > tdb ) ? - 1 : 0 ;
2008-03-10 12:17:05 +03:00
}
2012-06-22 09:37:44 +04:00
static NTSTATUS db_tdb_transaction_start_nonblock ( struct db_context * db )
{
struct db_tdb_ctx * db_ctx =
talloc_get_type_abort ( db - > private_data , struct db_tdb_ctx ) ;
int ret ;
ret = tdb_transaction_start_nonblock ( db_ctx - > wtdb - > tdb ) ;
if ( ret ! = 0 ) {
return map_nt_error_from_tdb ( tdb_error ( db_ctx - > wtdb - > tdb ) ) ;
}
return NT_STATUS_OK ;
}
2008-03-10 12:17:05 +03:00
static int db_tdb_transaction_commit ( struct db_context * db )
{
struct db_tdb_ctx * db_ctx =
talloc_get_type_abort ( db - > private_data , struct db_tdb_ctx ) ;
2011-09-14 02:43:28 +04:00
return tdb_transaction_commit ( db_ctx - > wtdb - > tdb ) ? - 1 : 0 ;
2008-03-10 12:17:05 +03:00
}
static int db_tdb_transaction_cancel ( struct db_context * db )
{
struct db_tdb_ctx * db_ctx =
talloc_get_type_abort ( db - > private_data , struct db_tdb_ctx ) ;
2011-06-20 13:10:31 +04:00
tdb_transaction_cancel ( db_ctx - > wtdb - > tdb ) ;
return 0 ;
2008-03-10 12:17:05 +03:00
}
2012-02-15 17:57:01 +04:00
static void db_tdb_id ( struct db_context * db , const uint8_t * * id , size_t * idlen )
{
struct db_tdb_ctx * db_ctx =
talloc_get_type_abort ( db - > private_data , struct db_tdb_ctx ) ;
* id = ( uint8_t * ) & db_ctx - > id ;
* idlen = sizeof ( db_ctx - > id ) ;
}
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
struct db_context * db_open_tdb ( TALLOC_CTX * mem_ctx ,
2012-04-16 07:37:39 +04:00
struct loadparm_context * lp_ctx ,
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
const char * name ,
int hash_size , int tdb_flags ,
2012-03-15 14:10:35 +04:00
int open_flags , mode_t mode ,
2014-01-28 15:33:42 +04:00
enum dbwrap_lock_order lock_order ,
uint64_t dbrwap_flags )
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
{
struct db_context * result = NULL ;
struct db_tdb_ctx * db_tdb ;
2012-02-15 17:57:01 +04:00
struct stat st ;
2011-12-05 13:49:48 +04:00
2012-06-22 09:37:43 +04:00
/* Extra paranoia. */
if ( name & & strends ( name , " .ntdb " ) ) {
DEBUG ( 0 , ( " can't try to open %s with tdb! \n " , name ) ) ;
return NULL ;
}
2011-06-07 05:44:43 +04:00
result = talloc_zero ( mem_ctx , struct db_context ) ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
if ( result = = NULL ) {
DEBUG ( 0 , ( " talloc failed \n " ) ) ;
goto fail ;
}
2011-06-07 05:38:41 +04:00
result - > private_data = db_tdb = talloc ( result , struct db_tdb_ctx ) ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
if ( db_tdb = = NULL ) {
DEBUG ( 0 , ( " talloc failed \n " ) ) ;
goto fail ;
}
2012-03-15 14:10:35 +04:00
result - > lock_order = lock_order ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
2014-03-26 18:26:24 +04:00
if ( hash_size = = 0 ) {
hash_size = lpcfg_tdb_hash_size ( lp_ctx , name ) ;
}
2014-03-26 18:41:03 +04:00
db_tdb - > wtdb = tdb_wrap_open ( db_tdb , name , hash_size ,
lpcfg_tdb_flags ( lp_ctx , tdb_flags ) ,
open_flags , mode ) ;
2007-06-03 10:54:51 +04:00
if ( db_tdb - > wtdb = = NULL ) {
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
DEBUG ( 3 , ( " Could not open tdb: %s \n " , strerror ( errno ) ) ) ;
goto fail ;
}
2012-02-15 17:57:01 +04:00
ZERO_STRUCT ( db_tdb - > id ) ;
if ( fstat ( tdb_fd ( db_tdb - > wtdb - > tdb ) , & st ) = = - 1 ) {
DEBUG ( 3 , ( " fstat failed: %s \n " , strerror ( errno ) ) ) ;
goto fail ;
}
db_tdb - > id . dev = st . st_dev ;
db_tdb - > id . ino = st . st_ino ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
result - > fetch_locked = db_tdb_fetch_locked ;
2012-03-27 16:31:04 +04:00
result - > try_fetch_locked = db_tdb_try_fetch_locked ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
result - > traverse = db_tdb_traverse ;
2007-05-29 22:04:38 +04:00
result - > traverse_read = db_tdb_traverse_read ;
2009-02-22 02:47:54 +03:00
result - > parse_record = db_tdb_parse ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
result - > get_seqnum = db_tdb_get_seqnum ;
2008-01-16 12:09:48 +03:00
result - > persistent = ( ( tdb_flags & TDB_CLEAR_IF_FIRST ) = = 0 ) ;
2008-03-10 12:17:05 +03:00
result - > transaction_start = db_tdb_transaction_start ;
2012-06-22 09:37:44 +04:00
result - > transaction_start_nonblock = db_tdb_transaction_start_nonblock ;
2008-03-10 12:17:05 +03:00
result - > transaction_commit = db_tdb_transaction_commit ;
result - > transaction_cancel = db_tdb_transaction_cancel ;
2011-07-04 12:27:17 +04:00
result - > exists = db_tdb_exists ;
2011-08-16 16:43:29 +04:00
result - > wipe = db_tdb_wipe ;
2012-02-15 17:57:01 +04:00
result - > id = db_tdb_id ;
2012-06-22 09:37:43 +04:00
result - > check = db_tdb_check ;
2012-06-22 09:37:44 +04:00
result - > name = tdb_name ( db_tdb - > wtdb - > tdb ) ;
2012-06-22 09:37:44 +04:00
result - > hash_size = hash_size ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
return result ;
fail :
2012-11-29 18:04:33 +04:00
TALLOC_FREE ( result ) ;
r22775: For the cluster code I've developed a wrapper around tdb to put different
database backends in place dynamically.
The main abstractions are db_context and db_record, it should be mainly
self-describing, see include/dbwrap.h. You open the db just as you would open
a tdb, this time with db_open(). If you want to fetch a record, just do the
db->fetch() call, if you want to do operations on it, you need to get it with
fetch_locked().
I added dbwrap_file.c (not heavily tested lately) as an example for what can
be done with that abstraction, uses a file per key. So if anybody is willing
to shape that up, we might have a chance on reiserfs again.... :-)
This abstraction works fine for brlock.tdb, locking.tdb, connections.tdb and
sessionid.tdb. It should work fine for the others as well, I just did not yet
get around to convert them.
If nobody loudly screams NO, then I will import the code that uses this soon.
Volker
(This used to be commit e9d7484ca246cfca4a1fd23be35edc2783136ebe)
2007-05-10 14:42:13 +04:00
return NULL ;
}