#include <errno.h>#include <stdbool.h>#include <stdint.h>#include <atalk/adouble.h>#include <atalk/list.h>#include <atalk/uuid.h>Go to the source code of this file.
Data Structures | |
| struct | _cnid_db |
| struct | cnid_open_args |
| struct | _cnid_module |
Macros | |
| #define | CNID_FLAG_PERSISTENT 0x01 |
| #define | CNID_FLAG_MANGLING 0x02 |
| #define | CNID_FLAG_SETUID 0x04 |
| #define | CNID_FLAG_BLOCK 0x08 |
| #define | CNID_FLAG_NODEV 0x10 |
| #define | CNID_FLAG_LAZY_INIT 0x20 |
| #define | CNID_FLAG_INODE 0x80 |
| #define | CNID_INVALID 0 |
| #define | CNID_START 17 |
| #define | CNID_ERR_PARAM 0x80000001 |
| #define | CNID_ERR_PATH 0x80000002 |
| #define | CNID_ERR_DB 0x80000003 |
| #define | CNID_ERR_CLOSE 0x80000004 |
| #define | CNID_ERR_MAX 0x80000005 |
| #define | CNID_ERR_RESET 0x80000006 |
| #define | CNID_ERR_BUSY 0x80000007 |
| #define | CNID_ERR_CORRUPT 0x80000008 |
| #define | CNID_ERR_NOTFOUND 0x80000009 |
| #define | CNID_ERRNO() |
| #define | CNID_ERRNO_IS_BACKEND_FAILURE() |
| Whether errno says the backend could not answer at all. | |
| #define | CNID_FIND_MIN_RESULTS 100 |
| #define | CNID_FIND_MIN_BUFLEN (CNID_FIND_MIN_RESULTS * sizeof(uint32_t)) |
Typedefs | |
| typedef struct _cnid_db | cnid_db |
| typedef struct _cnid_module | cnid_module |
Functions | |
| void | cnid_init (void) |
| void | cnid_register (struct _cnid_module *module) |
| struct _cnid_db * | cnid_open (struct vol *vol, char *type, int flags) |
| 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) |
| int | cnid_delete (struct _cnid_db *cdb, cnid_t id) |
| cnid_t | cnid_get (struct _cnid_db *cdb, const cnid_t did, char *name, const size_t len) |
| int | cnid_getstamp (struct _cnid_db *cdb, void *buffer, const size_t len) |
| cnid_t | cnid_lookup (struct _cnid_db *cdb, const struct stat *st, const cnid_t did, char *name, const size_t len) |
| char * | cnid_resolve (struct _cnid_db *cdb, cnid_t *id, void *buffer, size_t len) |
| 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) |
| 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) |
| 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. | |
| int | cnid_find_scoped (struct _cnid_db *cdb, const char *name, size_t namelen, cnid_t scope_did, void *buffer, size_t buflen, bool *more_available) |
| cnid_find() restricted to the subtree of a directory | |
| int | cnid_wipe (struct _cnid_db *cdb) |
| void | cnid_close (struct _cnid_db *db) |
This file contains all generic CNID related stuff declarations. Included:
| #define CNID_ERR_BUSY 0x80000007 |
contended or transient, retryable
| #define CNID_ERR_CLOSE 0x80000004 |
the db was not open
| #define CNID_ERR_CORRUPT 0x80000008 |
unusable data returned for a CNID
| #define CNID_ERR_DB 0x80000003 |
the backend itself is gone
| #define CNID_ERR_MAX 0x80000005 |
| #define CNID_ERR_NOTFOUND 0x80000009 |
no row for the query
| #define CNID_ERR_PARAM 0x80000001 |
| #define CNID_ERR_PATH 0x80000002 |
| #define CNID_ERR_RESET 0x80000006 |
CNID table was reset, all CNIDs stale
| #define CNID_ERRNO | ( | ) |
| #define CNID_ERRNO_IS_BACKEND_FAILURE | ( | ) |
Whether errno says the backend could not answer at all.
The object's existence is unknown, so the reply is the retryable AFPERR_MISC: AFPERR_NOOBJ and AFPERR_NOID are permanent and a client does not retry them.
| #define CNID_FIND_MIN_BUFLEN (CNID_FIND_MIN_RESULTS * sizeof(uint32_t)) |
| #define CNID_FIND_MIN_RESULTS 100 |
| #define CNID_FLAG_BLOCK 0x08 |
block signals in update.
| #define CNID_FLAG_INODE 0x80 |
in cnid_add the inode is authoritative
| #define CNID_FLAG_LAZY_INIT 0x20 |
| #define CNID_FLAG_MANGLING 0x02 |
This backend has name mangling feature.
| #define CNID_FLAG_NODEV 0x10 |
don't use device number only inode
| #define CNID_FLAG_PERSISTENT 0x01 |
This backend implements DID persistence
| #define CNID_FLAG_SETUID 0x04 |
Set db owner to parent folder owner.
| #define CNID_INVALID 0 |
| #define CNID_START 17 |
first valid ID
| typedef struct _cnid_module cnid_module |
| 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 ) |
| void cnid_close | ( | struct _cnid_db * | db | ) |
Closes CNID database. Currently it's just a wrapper around db->cnid_close().
| 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.
Centralises parameter validation so all three CNID backends (dbd, sqlite, mysql) behave identically against bad input. The 4-byte upper-bound shrink on namelen leaves room for the DBD backend's pagination offset prefix in the wire payload; the constraint is applied uniformly here so callers see consistent behaviour regardless of the configured backend.
The optional more_available out-parameter, when non-NULL, is written unconditionally on entry to false and again by the backend: false on error, true iff the result set was truncated on success (more matches exist than fit in buffer, or were collected within the daemon's wall-clock budget).
| [in] | cdb | CNID database handle |
| [in] | name | UTF-8 substring to search for, not necessarily NUL-terminated |
| [in] | namelen | bytes in name, range 1..MAXPATHLEN-sizeof(uint32_t) |
| [out] | buffer | caller-provided buffer for matching CNIDs in network byte order |
| [in] | buflen | capacity of buffer in bytes, must be >= CNID_FIND_MIN_BUFLEN |
| [out] | more_available | set to true iff result set was truncated, NULL to opt out |
buffer on success, -1 on failure (errno = CNID_ERR_PARAM or CNID_ERR_DB) | int cnid_find_scoped | ( | struct _cnid_db * | cdb, |
| const char * | name, | ||
| size_t | namelen, | ||
| cnid_t | scope_did, | ||
| void * | buffer, | ||
| size_t | buflen, | ||
| bool * | more_available ) |
cnid_find() restricted to the subtree of a directory
Identical contract to cnid_find(); additionally, when scope_did is not CNID_INVALID only entries lying underneath that directory match. The scope directory itself is not a result.
| [in] | cdb | CNID database handle |
| [in] | name | UTF-8 substring to search for, not necessarily NUL-terminated |
| [in] | namelen | bytes in name, range 1..MAXPATHLEN-sizeof(uint32_t) |
| [in] | scope_did | CNID of the scope directory in network byte order, or CNID_INVALID for the whole volume |
| [out] | buffer | caller-provided buffer for matching CNIDs in network byte order |
| [in] | buflen | capacity of buffer in bytes, must be >= CNID_FIND_MIN_BUFLEN |
| [out] | more_available | set to true iff result set was truncated, NULL to opt out |
buffer on success, -1 on failure (errno = CNID_ERR_PARAM or CNID_ERR_DB) | int cnid_getstamp | ( | struct _cnid_db * | cdb, |
| void * | buffer, | ||
| const size_t | len ) |
| void cnid_init | ( | void | ) |
| cnid_t cnid_lookup | ( | struct _cnid_db * | cdb, |
| const struct stat * | st, | ||
| const cnid_t | did, | ||
| char * | name, | ||
| const size_t | len ) |
Opens CNID database using particular back-end
| 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 ) |
| void cnid_register | ( | struct _cnid_module * | module | ) |
Once module has been registered, it cannot be unregistered.
| 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 ) |
| int cnid_wipe | ( | struct _cnid_db * | cdb | ) |