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
*/
2019-10-16 16:29:28 +03:00
# include "replace.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"
2019-10-16 16:29:28 +03:00
# include "lib/util/debug.h"
# include "lib/util/samba_util.h"
2012-02-15 17:57:01 +04:00
# include "system/filesys.h"
2014-03-26 18:26:24 +04:00
# include "lib/param/param.h"
2017-06-27 09:25:03 +03:00
# include "libcli/util/error.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
} ;
2016-09-12 18:30:55 +03:00
static NTSTATUS db_tdb_storev ( struct db_record * rec ,
const TDB_DATA * dbufs , int num_dbufs , int flag ) ;
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_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 )
{
if ( DEBUGLEVEL < 10 ) {
return ;
}
if ( DEBUGLEVEL = = 10 ) {
/*
* Only fully spam at debuglevel > 10
*/
2019-10-16 16:27:49 +03:00
key . dsize = MIN ( 10 , key . dsize ) ;
2011-12-07 17:50:54 +04:00
}
2019-10-16 16:27:49 +03:00
if ( key . dsize < 1024 ) {
char keystr [ key . dsize * 2 + 1 ] ;
hex_encode_buf ( keystr , key . dptr , key . dsize ) ;
DBG_DEBUG ( " %s key %s \n " , prefix , keystr ) ;
return ;
}
dump_data ( DEBUGLEVEL , key . dptr , key . dsize ) ;
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
}
2019-10-24 17:41:47 +03:00
result - > value_valid = true ;
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 (
2018-08-16 14:18:14 +03:00
struct db_context * db ,
struct db_tdb_ctx * ctx ,
TALLOC_CTX * mem_ctx ,
TDB_DATA key )
2008-01-07 02:14:24 +03:00
{
struct tdb_fetch_locked_state state ;
2018-08-18 10:12:21 +03:00
int ret ;
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
2018-08-18 09:35:27 +03:00
state = ( struct tdb_fetch_locked_state ) {
. mem_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
2018-08-18 10:12:21 +03:00
ret = tdb_parse_record ( ctx - > wtdb - > tdb ,
key ,
db_tdb_fetchlock_parse ,
& state ) ;
if ( ( ret < 0 ) & & ( tdb_error ( ctx - > wtdb - > tdb ) ! = TDB_ERR_NOEXIST ) ) {
2012-04-19 12:47:07 +04:00
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 ) ;
2015-09-21 13:32:47 +03:00
state . result - > private_data = ctx ;
2016-09-12 18:30:55 +03:00
state . result - > storev = db_tdb_storev ;
2008-01-07 02:14:24 +03:00
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
2018-05-13 07:18:21 +03:00
DBG_DEBUG ( " Allocated locked data %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 ;
}
2018-08-16 14:18:14 +03:00
return db_tdb_fetch_locked_internal ( db , ctx , mem_ctx , key ) ;
2012-03-27 16:31:04 +04:00
}
2017-06-27 09:25:03 +03:00
static NTSTATUS db_tdb_do_locked ( struct db_context * db , TDB_DATA key ,
void ( * fn ) ( struct db_record * rec ,
2019-10-23 12:34:47 +03:00
TDB_DATA value ,
2017-06-27 09:25:03 +03:00
void * private_data ) ,
void * private_data )
{
struct db_tdb_ctx * ctx = talloc_get_type_abort (
db - > private_data , struct db_tdb_ctx ) ;
uint8_t * buf = NULL ;
struct db_record rec ;
int ret ;
ret = tdb_chainlock ( ctx - > wtdb - > tdb , key ) ;
if ( ret = = - 1 ) {
enum TDB_ERROR err = tdb_error ( ctx - > wtdb - > tdb ) ;
DBG_DEBUG ( " tdb_chainlock failed: %s \n " ,
tdb_errorstr ( ctx - > wtdb - > tdb ) ) ;
return map_nt_error_from_tdb ( err ) ;
}
ret = tdb_fetch_talloc ( ctx - > wtdb - > tdb , key , ctx , & buf ) ;
if ( ( ret ! = 0 ) & & ( ret ! = ENOENT ) ) {
DBG_DEBUG ( " tdb_fetch_talloc failed: %s \n " ,
strerror ( errno ) ) ;
tdb_chainunlock ( ctx - > wtdb - > tdb , key ) ;
return map_nt_error_from_unix_common ( ret ) ;
}
rec = ( struct db_record ) {
. db = db , . key = key ,
2019-10-23 13:19:38 +03:00
. value_valid = false ,
2017-06-27 09:25:03 +03:00
. storev = db_tdb_storev , . delete_rec = db_tdb_delete ,
. private_data = ctx
} ;
2019-10-23 13:19:38 +03:00
fn ( & rec ,
( TDB_DATA ) { . dptr = buf , . dsize = talloc_get_size ( buf ) } ,
private_data ) ;
2017-06-27 09:25:03 +03:00
tdb_chainunlock ( ctx - > wtdb - > tdb , key ) ;
2019-08-13 15:43:08 +03:00
talloc_free ( buf ) ;
2017-06-27 09:25:03 +03:00
return NT_STATUS_OK ;
}
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
}
2016-09-12 18:30:55 +03:00
static NTSTATUS db_tdb_storev ( struct db_record * rec ,
const TDB_DATA * dbufs , int num_dbufs , int flag )
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 * ctx = talloc_get_type_abort ( rec - > private_data ,
struct db_tdb_ctx ) ;
2019-10-09 18:17:07 +03:00
struct tdb_context * tdb = ctx - > wtdb - > tdb ;
NTSTATUS status = NT_STATUS_OK ;
2016-09-12 18:30:55 +03:00
int ret ;
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 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 .
*/
2019-10-09 18:17:07 +03:00
ret = tdb_storev ( tdb , rec - > key , dbufs , num_dbufs , flag ) ;
if ( ret = = - 1 ) {
enum TDB_ERROR err = tdb_error ( tdb ) ;
status = map_nt_error_from_tdb ( err ) ;
}
return status ;
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_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 ;
2019-10-24 17:41:47 +03:00
rec . value_valid = true ;
2016-09-12 18:30:55 +03:00
rec . storev = db_tdb_storev ;
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
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
}
2016-09-12 18:30:55 +03:00
static NTSTATUS db_tdb_storev_deny ( struct db_record * rec ,
const TDB_DATA * dbufs , int num_dbufs ,
int flag )
2007-05-29 22:04:38 +04:00
{
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 ;
2019-10-24 17:41:47 +03:00
rec . value_valid = true ;
2016-09-12 18:30:55 +03:00
rec . storev = db_tdb_storev_deny ;
2007-05-29 22:04:38 +04:00
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
}
2015-09-20 17:26:06 +03:00
static size_t db_tdb_id ( struct db_context * db , uint8_t * id , size_t idlen )
2012-02-15 17:57:01 +04:00
{
struct db_tdb_ctx * db_ctx =
talloc_get_type_abort ( db - > private_data , struct db_tdb_ctx ) ;
2015-09-20 17:26:06 +03:00
if ( idlen > = sizeof ( db_ctx - > id ) ) {
memcpy ( id , & db_ctx - > id , sizeof ( db_ctx - > id ) ) ;
}
return sizeof ( db_ctx - > id ) ;
2012-02-15 17:57:01 +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
struct db_context * db_open_tdb ( TALLOC_CTX * mem_ctx ,
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 ,
2015-10-20 15:00:54 +03:00
uint64_t dbwrap_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
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
2015-09-21 13:28:20 +03:00
db_tdb - > wtdb = tdb_wrap_open ( db_tdb , name , hash_size , tdb_flags ,
2014-03-26 18:41:03 +04:00
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 ;
2017-06-27 09:25:03 +03:00
result - > do_locked = db_tdb_do_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 ) ;
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 ;
}