Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit a8ffbc4

Browse files
committedFeb 16, 2025
Introduce CNID backend built on SQLite, GitHub #1177
Based on the MySQL CNID backend by Ralph Boehme. In part written by Christopher Kobayashi. Signed-off-by: Daniel Markstedt <[email protected]>
1 parent 62fc85b commit a8ffbc4

File tree

12 files changed

+1123
-5
lines changed

12 files changed

+1123
-5
lines changed
 

‎.github/workflows/build.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ jobs:
7474
perl \
7575
pkgconfig \
7676
rpcsvc-proto-dev \
77+
sqlite-dev \
7778
talloc-dev \
7879
tinysparql-dev
7980
- name: Configure
@@ -125,6 +126,7 @@ jobs:
125126
po4a \
126127
pkgconfig \
127128
rpcsvc-proto \
129+
sqlite \
128130
talloc \
129131
tinysparql
130132
- name: Configure
@@ -180,6 +182,7 @@ jobs:
180182
libldap2-dev \
181183
libmariadb-dev \
182184
libpam0g-dev \
185+
libsqlite3-dev \
183186
libtalloc-dev \
184187
libtirpc-dev \
185188
libtracker-sparql-3.0-dev \
@@ -250,6 +253,7 @@ jobs:
250253
perl \
251254
perl-Net-DBus \
252255
quota-devel \
256+
sqlite-devel \
253257
systemd \
254258
systemtap-sdt-devel \
255259
tracker \
@@ -361,7 +365,8 @@ jobs:
361365
iniparser \
362366
mariadb \
363367
meson \
364-
openldap
368+
openldap \
369+
sqlite
365370
- name: Configure
366371
run: |
367372
meson setup build \
@@ -419,6 +424,7 @@ jobs:
419424
py39-gdbm \
420425
py39-sqlite3 \
421426
py39-tkinter \
427+
sqlite \
422428
talloc \
423429
tracker3
424430
run: |
@@ -462,6 +468,7 @@ jobs:
462468
p5-Net-DBus \
463469
perl5 \
464470
pkgconf \
471+
sqlite3 \
465472
talloc \
466473
tracker3
467474
run: |
@@ -516,6 +523,7 @@ jobs:
516523
p5-Net-DBus \
517524
perl \
518525
pkg-config \
526+
sqlite3 \
519527
talloc
520528
run: |
521529
set -e
@@ -569,6 +577,7 @@ jobs:
569577
openpam \
570578
p5-Net-DBus \
571579
pkgconf \
580+
sqlite \
572581
tracker3
573582
run: |
574583
set -e
@@ -618,6 +627,7 @@ jobs:
618627
libgcrypt \
619628
meson \
620629
mysql-client \
630+
sqlite3 \
621631
talloc
622632
run: |
623633
set -e
@@ -666,7 +676,8 @@ jobs:
666676
libgcrypt \
667677
ninja \
668678
pkg-config \
669-
python/pip
679+
python/pip \
680+
sqlite-3
670681
pip install meson
671682
curl -O https://gitlab.com/iniparser/iniparser/-/archive/v4.2.5/iniparser-v4.2.5.tar.gz
672683
tar xzf iniparser-v4.2.5.tar.gz

‎etc/afpd/afp_options.c

+3
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ static void show_version( void )
7878
#endif
7979
#ifdef CNID_BACKEND_MYSQL
8080
printf( "mysql " );
81+
#endif
82+
#ifdef CNID_BACKEND_SQLITE
83+
printf( "sqlite " );
8184
#endif
8285
puts( "" );
8386
}

‎etc/cnid_dbd/cmd_dbd.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ int main(int argc, char **argv)
247247
}
248248

249249
/* open volume */
250-
if (STRCMP(vol->v_cnidscheme, != , "dbd") && STRCMP(vol->v_cnidscheme, != , "mysql")) {
250+
if (STRCMP(vol->v_cnidscheme, != , "dbd")
251+
&& STRCMP(vol->v_cnidscheme, != , "mysql")
252+
&& STRCMP(vol->v_cnidscheme, != , "sqlite")
253+
) {
251254
dbd_log(LOGSTD, "\"%s\" isn't a \"dbd\" CNID volume", vol->v_path);
252255
exit(EXIT_FAILURE);
253256
}

‎etc/cnid_dbd/meson.build

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ if use_dbd_backend
1919

2020
cnid_dbd_deps = [iniparser]
2121

22+
if have_iconv
23+
cnid_dbd_deps += iconv
24+
endif
25+
2226
if use_mysql_backend
2327
cnid_dbd_deps += mysqlclient
2428
endif
2529

26-
if have_iconv
27-
cnid_dbd_deps += iconv
30+
if use_sqlite_backend
31+
cnid_dbd_deps += sqlite_deps
2832
endif
2933

3034
cnid_metad_sources = ['cnid_metad.c', 'usockfd.c', 'db_param.c']

‎include/atalk/cnid_sqlite_private.h

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef _ATALK_CNID_SQLITE_PRIVATE_H
2+
#define _ATALK_CNID_SQLITE_PRIVATE_H 1
3+
4+
#include <atalk/cnid_private.h>
5+
#include <atalk/uuid.h>
6+
7+
#define CNID_SQLITE_FLAG_DEPLETED (1 << 0) /* CNID set overflowed */
8+
9+
typedef struct CNID_sqlite_private {
10+
struct vol *vol;
11+
uint32_t cnid_sqlite_flags;
12+
sqlite3 *cnid_sqlite_con;
13+
char *cnid_sqlite_voluuid_str;
14+
cnid_t cnid_sqlite_hint;
15+
sqlite3_stmt *cnid_lookup_stmt;
16+
sqlite3_stmt *cnid_add_stmt;
17+
sqlite3_stmt *cnid_put_stmt;
18+
} CNID_sqlite_private;
19+
20+
#endif

‎libatalk/cnid/cnid_init.c

+8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ extern struct _cnid_module cnid_dbd_module;
4444
extern struct _cnid_module cnid_mysql_module;
4545
#endif
4646

47+
#ifdef CNID_BACKEND_SQLITE
48+
extern struct _cnid_module cnid_sqlite_module;
49+
#endif
50+
4751
void cnid_init(void)
4852
{
4953
#ifdef CNID_BACKEND_LAST
@@ -57,4 +61,8 @@ void cnid_init(void)
5761
#ifdef CNID_BACKEND_MYSQL
5862
cnid_register(&cnid_mysql_module);
5963
#endif
64+
65+
#ifdef CNID_BACKEND_SQLITE
66+
cnid_register(&cnid_sqlite_module);
67+
#endif
6068
}

‎libatalk/cnid/meson.build

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ if use_mysql_backend
1414
libcnid_deps += mysql_deps
1515
endif
1616

17+
if use_sqlite_backend
18+
subdir('sqlite')
19+
libcnid_libs += libcnid_sqlite
20+
libcnid_deps += sqlite_deps
21+
endif
22+
1723
cnid_sources = ['cnid_init.c', 'cnid.c']
1824

1925
libcnid = static_library(

‎libatalk/cnid/sqlite/cnid_sqlite.c

+1,030
Large diffs are not rendered by default.

‎libatalk/cnid/sqlite/meson.build

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
libcnid_sqlite_sources = ['cnid_sqlite.c']
2+
3+
libcnid_sqlite = static_library(
4+
'cnid_sqlite',
5+
libcnid_sqlite_sources,
6+
include_directories: root_includes,
7+
dependencies: sqlite_deps,
8+
c_args: statedir,
9+
install: false,
10+
)
11+
12+
install_emptydir(localstatedir / 'netatalk/CNID/sqlite', install_mode: 'rwxrwxrwx')

‎meson.build

+12
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,18 @@ if get_option('with-cnid-mysql-backend')
15331533
endif
15341534
endif
15351535

1536+
# Check for sqlite CNID backend
1537+
1538+
sqlite_deps = dependency('sqlite3', required: false)
1539+
1540+
use_sqlite_backend = false
1541+
1542+
if get_option('with-cnid-sqlite-backend') and sqlite_deps.found()
1543+
use_sqlite_backend = true
1544+
cnid_backends += ' sqlite'
1545+
cdata.set('CNID_BACKEND_SQLITE', 1)
1546+
endif
1547+
15361548
compiled_backends = '"' + cnid_backends + '"'
15371549
cdata.set('compiled_backends', compiled_backends)
15381550

‎meson_config.h

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
/* whether the MySQL CNID module is available */
2020
#mesondefine CNID_BACKEND_MYSQL
2121

22+
/* whether the SQLite CNID module is available */
23+
#mesondefine CNID_BACKEND_SQLITE
24+
2225
/* Path to dbus-daemon */
2326
#mesondefine DBUS_DAEMON_PATH
2427

‎meson_options.txt

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ option(
3333
value: true,
3434
description: 'Compile MySQL CNID scheme',
3535
)
36+
option(
37+
'with-cnid-sqlite-backend',
38+
type: 'boolean',
39+
value: true,
40+
description: 'Compile SQLite CNID scheme',
41+
)
3642
option(
3743
'with-cracklib',
3844
type: 'boolean',

0 commit comments

Comments
 (0)
Please sign in to comment.