netatalk: cnid.h File Reference

netatalk 4.5.1
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
cnid.h File Reference
`#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_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_wipe (struct _cnid_db *cdb)
void | cnid_close (struct _cnid_db *db)

## Detailed Description

This file contains all generic CNID related stuff declarations. Included:

- CNID factory, which retrieves (eventually instantiates) CNID objects on demand
- selection of CNID backends (default, detected by volume)
- full set of CNID operations needed by server core.

## Macro Definition Documentation

## ◆ CNID_ERR_CLOSE

#define CNID_ERR_CLOSE 0x80000004

the db was not open

## ◆ CNID_ERR_DB

#define CNID_ERR_DB 0x80000003

## ◆ CNID_ERR_MAX

#define CNID_ERR_MAX 0x80000005

## ◆ CNID_ERR_PARAM

#define CNID_ERR_PARAM 0x80000001

## ◆ CNID_ERR_PATH

#define CNID_ERR_PATH 0x80000002

## ◆ CNID_FIND_MIN_BUFLEN

#define CNID_FIND_MIN_BUFLEN (CNID_FIND_MIN_RESULTS * sizeof(uint32_t))

## ◆ CNID_FIND_MIN_RESULTS

#define CNID_FIND_MIN_RESULTS 100

## ◆ CNID_FLAG_BLOCK

#define CNID_FLAG_BLOCK 0x08

block signals in update.

## ◆ CNID_FLAG_INODE

#define CNID_FLAG_INODE 0x80

in cnid_add the inode is authoritative

## ◆ CNID_FLAG_LAZY_INIT

#define CNID_FLAG_LAZY_INIT 0x20

## ◆ CNID_FLAG_MANGLING

#define CNID_FLAG_MANGLING 0x02

This backend has name mangling feature.

## ◆ CNID_FLAG_NODEV

#define CNID_FLAG_NODEV 0x10

don't use device number only inode

## ◆ CNID_FLAG_PERSISTENT

#define CNID_FLAG_PERSISTENT 0x01

This backend implements DID persistence

## ◆ CNID_FLAG_SETUID

#define CNID_FLAG_SETUID 0x04

Set db owner to parent folder owner.

## ◆ CNID_INVALID

#define CNID_INVALID 0

## ◆ CNID_START

#define CNID_START 17

first valid ID

## Typedef Documentation

## ◆ cnid_db

typedef struct _cnid_db cnid_db

This is instance of CNID database object.

## ◆ cnid_module

typedef struct _cnid_module cnid_module

## Function Documentation

## ◆ 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 )

## ◆ cnid_close()

void cnid_close | ( | struct _cnid_db * | db | ) |

Closes CNID database. Currently it's just a wrapper around db->cnid_close().

## ◆ cnid_delete()

int cnid_delete | ( | struct _cnid_db * | cdb,
|  | cnid_t | id )

## ◆ 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.

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).

Parameters

  [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

Returns
  number of CNIDs written to `buffer` on success, -1 on failure (errno = CNID_ERR_PARAM or CNID_ERR_DB)

## ◆ cnid_get()

cnid_t cnid_get | ( | struct _cnid_db * | cdb,
|  | const cnid_t | did,
|  | char * | name,
|  | const size_t | len )

## ◆ cnid_getstamp()

int cnid_getstamp | ( | struct _cnid_db * | cdb,
|  | void * | buffer,
|  | const size_t | len )

## ◆ cnid_init()

void cnid_init | ( | void |  | ) |

## ◆ cnid_lookup()

cnid_t cnid_lookup | ( | struct _cnid_db * | cdb,
|  | const struct stat * | st,
|  | const cnid_t | did,
|  | char * | name,
|  | const size_t | len )

## ◆ cnid_open()

struct _cnid_db * cnid_open | ( | struct vol * | vol,
|  | char * | type,
|  | int | flags )

Opens CNID database using particular back-end

## ◆ 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 )

## ◆ cnid_register()

void cnid_register | ( | struct _cnid_module * | module | ) |

Once module has been registered, it cannot be unregistered.

## ◆ cnid_resolve()

char * cnid_resolve | ( | struct _cnid_db * | cdb,
|  | cnid_t * | id,
|  | void * | buffer,
|  | size_t | len )

## ◆ 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 )

## ◆ cnid_wipe()

int cnid_wipe | ( | struct _cnid_db * | cdb | ) |