Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
2b2d1886
Commit
2b2d1886
authored
Sep 09, 2010
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tdb: new command openjh for tdbtool (to use Jenkins hash)
parent
48038e70
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
ccan/tdb/tools/Makefile
ccan/tdb/tools/Makefile
+1
-1
ccan/tdb/tools/tdbtool.c
ccan/tdb/tools/tdbtool.c
+17
-3
No files found.
ccan/tdb/tools/Makefile
View file @
2b2d1886
LDLIBS
:=
../../tdb.o
LDLIBS
:=
../../tdb.o
../../hash.o
CFLAGS
:=
-I
../../..
-Wall
-O3
#-g -pg
LDFLAGS
:=
-L
../../..
...
...
ccan/tdb/tools/tdbtool.c
View file @
2b2d1886
...
...
@@ -21,6 +21,7 @@
*/
#include <ccan/tdb/tdb.h>
#include <ccan/hash/hash.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
...
...
@@ -45,6 +46,7 @@ static int disable_mmap;
enum
commands
{
CMD_CREATE_TDB
,
CMD_OPEN_TDB
,
CMD_OPENJH_TDB
,
CMD_TRANSACTION_START
,
CMD_TRANSACTION_COMMIT
,
CMD_TRANSACTION_CANCEL
,
...
...
@@ -78,6 +80,7 @@ typedef struct {
COMMAND_TABLE
cmd_table
[]
=
{
{
"create"
,
CMD_CREATE_TDB
},
{
"open"
,
CMD_OPEN_TDB
},
{
"openjh"
,
CMD_OPENJH_TDB
},
{
"transaction_start"
,
CMD_TRANSACTION_START
},
{
"transaction_commit"
,
CMD_TRANSACTION_COMMIT
},
{
"transaction_cancel"
,
CMD_TRANSACTION_CANCEL
},
...
...
@@ -189,6 +192,7 @@ static void help(void)
"tdbtool:
\n
"
" create dbname : create a database
\n
"
" open dbname : open an existing database
\n
"
" openjh dbname : open an existing database (jenkins hash)
\n
"
" transaction_start : start a transaction
\n
"
" transaction_commit : commit a transaction
\n
"
" transaction_cancel : cancel a transaction
\n
"
...
...
@@ -232,14 +236,19 @@ static void create_tdb(const char *tdbname)
}
}
static
void
open_tdb
(
const
char
*
tdbname
)
static
unsigned
int
jenkins_hash
(
TDB_DATA
*
key
)
{
return
hash_any
(
key
->
dptr
,
key
->
dsize
,
0
);
}
static
void
open_tdb
(
const
char
*
tdbname
,
tdb_hash_func
hashfn
)
{
struct
tdb_logging_context
log_ctx
;
log_ctx
.
log_fn
=
tdb_log
;
if
(
tdb
)
tdb_close
(
tdb
);
tdb
=
tdb_open_ex
(
tdbname
,
0
,
disable_mmap
?
TDB_NOMMAP
:
0
,
O_RDWR
,
0600
,
&
log_ctx
,
NULL
);
&
log_ctx
,
hashfn
);
if
(
!
tdb
)
{
printf
(
"Could not open %s: %s
\n
"
,
tdbname
,
strerror
(
errno
));
}
...
...
@@ -577,7 +586,11 @@ static int do_command(void)
return
0
;
case
CMD_OPEN_TDB
:
bIterate
=
0
;
open_tdb
(
arg1
);
open_tdb
(
arg1
,
NULL
);
return
0
;
case
CMD_OPENJH_TDB
:
bIterate
=
0
;
open_tdb
(
arg1
,
jenkins_hash
);
return
0
;
case
CMD_SYSTEM
:
/* Shell command */
...
...
@@ -673,6 +686,7 @@ static int do_command(void)
return
0
;
case
CMD_CREATE_TDB
:
case
CMD_OPEN_TDB
:
case
CMD_OPENJH_TDB
:
case
CMD_SYSTEM
:
case
CMD_QUIT
:
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment