netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
cnid.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003 the Netatalk Team
3 * Copyright (c) 2003 Rafal Lewczuk <rlewczuk@pronet.pl>
4 * Copyright (c) 2010 Frank Lahm
5 *
6 * This program is free software; you can redistribute and/or modify
7 * it under the terms of the GNU General Public License as published
8 * by the Free Software Foundation version 2 of the License or later
9 * version if explicitly stated by any of above copyright holders.
10 *
11 * 2024/07/05: Rafal Lewczuk gave permission to change the license
12 * to a later verion of the GNU GPL in
13 * https://github.com/Netatalk/netatalk/issues/1193
14 *
15 */
16
26
27#ifndef _ATALK_CNID__H
28#define _ATALK_CNID__H 1
29
30#include <stdbool.h>
31#include <stdint.h>
32
33#include <atalk/adouble.h>
34#include <atalk/list.h>
35#include <atalk/uuid.h>
36
37/* CNID object flags */
38#define CNID_FLAG_PERSISTENT 0x01
39#define CNID_FLAG_MANGLING 0x02
40#define CNID_FLAG_SETUID 0x04
41#define CNID_FLAG_BLOCK 0x08
42#define CNID_FLAG_NODEV 0x10
43#define CNID_FLAG_LAZY_INIT 0x20
44#define CNID_FLAG_INODE 0x80
45
46#define CNID_INVALID 0
47#define CNID_START 17
48
49#define CNID_ERR_PARAM 0x80000001
50#define CNID_ERR_PATH 0x80000002
51#define CNID_ERR_DB 0x80000003
52#define CNID_ERR_CLOSE 0x80000004
53#define CNID_ERR_MAX 0x80000005
54
55/* cnid_find() requires a result buffer large enough to hold at least one
56 * full DBD-backend batch (CNID_FIND_MIN_RESULTS = 100 CNIDs in network
57 * byte order). The cnid_find() wrapper enforces this minimum centrally
58 * so every CNID backend behaves identically. */
59#define CNID_FIND_MIN_RESULTS 100
60#define CNID_FIND_MIN_BUFLEN (CNID_FIND_MIN_RESULTS * sizeof(uint32_t))
61
65 typedef struct _cnid_db {
66 /* Flags describing some CNID backend aspects. */
67 uint32_t cnid_db_flags;
68 struct vol *cnid_db_vol;
69 /* back-end speficic data */
70 void *cnid_db_private;
71
72 cnid_t (*cnid_add)(struct _cnid_db *cdb, const struct stat *st, cnid_t did,
73 const char *name, size_t, cnid_t hint);
74 int (*cnid_delete)(struct _cnid_db *cdb, cnid_t id);
75 cnid_t (*cnid_get)(struct _cnid_db *cdb, cnid_t did, const char *name,
76 size_t);
77 cnid_t (*cnid_lookup)(struct _cnid_db *cdb, const struct stat *st,
78 cnid_t did, const char *name, size_t);
79 cnid_t (*cnid_nextid)(struct _cnid_db *cdb);
80 char *(*cnid_resolve)(struct _cnid_db *cdb, cnid_t *id, void *buffer,
81 size_t len);
82 int (*cnid_update)(struct _cnid_db *cdb, cnid_t id, const struct stat *st,
83 cnid_t did, const char *name, size_t len);
84 void (*cnid_close)(struct _cnid_db *cdb);
85 int (*cnid_getstamp)(struct _cnid_db *cdb, void *buffer, const size_t len);
86 cnid_t (*cnid_rebuild_add)(struct _cnid_db *, const struct stat *, cnid_t,
87 const char *, size_t, cnid_t);
88 int (*cnid_find)(struct _cnid_db *cdb, const char *name, size_t namelen,
89 void *buffer, size_t buflen, bool *more_available);
90 int (*cnid_wipe)(struct _cnid_db *cdb);
91} cnid_db;
92
93/*
94 * Consolidation of args passed from main cnid_open to modules cnid_XXX_open, so
95 * that it's easier to add aditional args as required.
96 */
97 struct cnid_open_args {
98 uint32_t cnid_args_flags;
99 struct vol *cnid_args_vol;
100};
101
102/*
103 * CNID module - represents particular CNID implementation
104 */
105 struct _cnid_module {
106 char *name;
107 /* CNID modules are also stored on a bidirectional list. */
108 struct list_head db_list;
109 struct _cnid_db *(*cnid_open)(struct cnid_open_args *args);
110 /* Flags describing some CNID backend aspects. */
111 uint32_t flags;
112};
113
114 typedef struct _cnid_module cnid_module;
115
116/* Inititalize the CNID backends */
117 void cnid_init(void);
118
119/* Registers new CNID backend module */
120 void cnid_register(struct _cnid_module *module);
121
122/* This function opens a CNID database for selected volume. */
123 struct _cnid_db *cnid_open(struct vol *vol, char *type, int flags);
124 cnid_t cnid_add(struct _cnid_db *cdb, const struct stat *st, const cnid_t did,
125 const char *name, const size_t len, cnid_t hint);
126 int cnid_delete(struct _cnid_db *cdb, cnid_t id);
127 cnid_t cnid_get(struct _cnid_db *cdb, const cnid_t did, char *name,
128 const size_t len);
129 int cnid_getstamp(struct _cnid_db *cdb, void *buffer, const size_t len);
130 cnid_t cnid_lookup(struct _cnid_db *cdb, const struct stat *st,
131 const cnid_t did, char *name, const size_t len);
132 char *cnid_resolve(struct _cnid_db *cdb, cnid_t *id, void *buffer,
133 size_t len);
134 int cnid_update(struct _cnid_db *cdb, const cnid_t id,
135 const struct stat *st, const cnid_t did, char *name,
136 const size_t len);
137 cnid_t cnid_rebuild_add(struct _cnid_db *cdb, const struct stat *st,
138 const cnid_t did, char *name, const size_t len,
139 cnid_t hint);
140 int cnid_find(struct _cnid_db *cdb, const char *name, size_t namelen,
141 void *buffer, size_t buflen, bool *more_available);
142 int cnid_wipe(struct _cnid_db *cdb);
143 void cnid_close(struct _cnid_db *db);
144
145#endif
adouble.h
Part of Netatalk's AppleDouble implementatation.
cnid_t
uint32_t cnid_t
Definition adouble.h:156
flags
static dbd_flags_t flags
Definition cmd_dbd.c:43
cnid_find
int cnid_find(struct _cnid_db *cdb, const char *name, size_t namelen, void *buffer, size_t buflen, bool *more_available)
Search the CNID database for entries whose name contains a substring.
Definition cnid/cnid.c:351
cnid_db
struct _cnid_db cnid_db
cnid_update
int cnid_update(struct _cnid_db *cdb, const cnid_t id, const struct stat *st, const cnid_t did, char *name, const size_t len)
Definition cnid/cnid.c:407
cnid_add
cnid_t cnid_add(struct _cnid_db *cdb, const struct stat *st, const cnid_t did, const char *name, const size_t len, cnid_t hint)
Definition cnid/cnid.c:251
cnid_lookup
cnid_t cnid_lookup(struct _cnid_db *cdb, const struct stat *st, const cnid_t did, char *name, const size_t len)
Definition cnid/cnid.c:314
cnid_get
cnid_t cnid_get(struct _cnid_db *cdb, const cnid_t did, char *name, const size_t len)
Definition cnid/cnid.c:278
cnid_init
void cnid_init(void)
Definition cnid_init.c:49
cnid_register
void cnid_register(struct _cnid_module *module)
Definition cnid/cnid.c:47
cnid_wipe
int cnid_wipe(struct _cnid_db *cdb)
Definition cnid/cnid.c:430
cnid_module
struct _cnid_module cnid_module
Definition cnid.h:114
cnid_delete
int cnid_delete(struct _cnid_db *cdb, cnid_t id)
Definition cnid/cnid.c:267
cnid_rebuild_add
cnid_t cnid_rebuild_add(struct _cnid_db *cdb, const struct stat *st, const cnid_t did, char *name, const size_t len, cnid_t hint)
Definition cnid/cnid.c:418
cnid_close
void cnid_close(struct _cnid_db *db)
Definition cnid/cnid.c:234
cnid_getstamp
int cnid_getstamp(struct _cnid_db *cdb, void *buffer, const size_t len)
Definition cnid/cnid.c:289
cnid_open
struct _cnid_db * cnid_open(struct vol *vol, char *type, int flags)
Definition cnid/cnid.c:104
cnid_resolve
char * cnid_resolve(struct _cnid_db *cdb, cnid_t *id, void *buffer, size_t len)
Definition cnid/cnid.c:391
list.h
Simple doubly linked list implementation.
did
cnid_t did
Definition nad_cp.c:93
type
static enum op type
Definition nad_cp.c:96
buffer
char buffer[MAXPATHLEN+2]
Definition netacnv.c:35
_cnid_db
Definition cnid.h:65
_cnid_db::cnid_getstamp
int(* cnid_getstamp)(struct _cnid_db *cdb, void *buffer, const size_t len)
Definition cnid.h:85
_cnid_db::cnid_db_flags
uint32_t cnid_db_flags
Definition cnid.h:67
_cnid_db::cnid_add
cnid_t(* cnid_add)(struct _cnid_db *cdb, const struct stat *st, cnid_t did, const char *name, size_t, cnid_t hint)
Definition cnid.h:72
_cnid_db::cnid_close
void(* cnid_close)(struct _cnid_db *cdb)
Definition cnid.h:84
_cnid_db::cnid_rebuild_add
cnid_t(* cnid_rebuild_add)(struct _cnid_db *, const struct stat *, cnid_t, const char *, size_t, cnid_t)
Definition cnid.h:86
_cnid_db::cnid_db_vol
struct vol * cnid_db_vol
Definition cnid.h:68
_cnid_db::cnid_delete
int(* cnid_delete)(struct _cnid_db *cdb, cnid_t id)
Definition cnid.h:74
_cnid_db::cnid_find
int(* cnid_find)(struct _cnid_db *cdb, const char *name, size_t namelen, void *buffer, size_t buflen, bool *more_available)
Definition cnid.h:88
_cnid_db::cnid_get
cnid_t(* cnid_get)(struct _cnid_db *cdb, cnid_t did, const char *name, size_t)
Definition cnid.h:75
_cnid_db::cnid_update
int(* cnid_update)(struct _cnid_db *cdb, cnid_t id, const struct stat *st, cnid_t did, const char *name, size_t len)
Definition cnid.h:82
_cnid_db::cnid_wipe
int(* cnid_wipe)(struct _cnid_db *cdb)
Definition cnid.h:90
_cnid_db::cnid_lookup
cnid_t(* cnid_lookup)(struct _cnid_db *cdb, const struct stat *st, cnid_t did, const char *name, size_t)
Definition cnid.h:77
_cnid_db::cnid_nextid
cnid_t(* cnid_nextid)(struct _cnid_db *cdb)
Definition cnid.h:79
_cnid_db::cnid_db_private
void * cnid_db_private
Definition cnid.h:70
_cnid_module
Definition cnid.h:105
_cnid_module::db_list
struct list_head db_list
Definition cnid.h:108
_cnid_module::flags
uint32_t flags
Definition cnid.h:111
_cnid_module::name
char * name
Definition cnid.h:106
cnid_open_args
Definition cnid.h:97
cnid_open_args::cnid_args_flags
uint32_t cnid_args_flags
Definition cnid.h:98
cnid_open_args::cnid_args_vol
struct vol * cnid_args_vol
Definition cnid.h:99
list_head
Definition include/atalk/list.h:18
vol
Definition include/atalk/volume.h:33
args
static char * args[]
Definition test.c:48
uuid.h