netatalk: sl_cnid.c File Reference

netatalk 4.5.1
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
sl_cnid.c File Reference
`#include <ctype.h>`
`#include <inttypes.h>`
`#include <stdbool.h>`
`#include <stdint.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <sys/stat.h>`
`#include <unistd.h>`
`#include <talloc.h>`
`#include <atalk/cnid.h>`
`#include <atalk/directory.h>`
`#include <atalk/errchk.h>`
`#include <atalk/globals.h>`
`#include <atalk/logger.h>`
`#include <atalk/spotlight.h>`
`#include <atalk/util.h>`
`#include <atalk/volume.h>`
`#include "etc/spotlight/spotlight_private.h"`

## Data Structures
struct | sl_cnid_query

## Macros
#define | SL_CNID_MAX_RESULTS 10000
#define | SL_CNID_MIN_TERMLEN 3
#define | SL_CNID_PAGE_SIZE 20
#define | SL_CNID_MAX_DEPTH 64

## Functions
static int | cnid_comp_fn (const void *p1, const void *p2)
static char * | sl_cnid_extract_term (TALLOC_CTX *mem_ctx, const char *qstring)
| Extract a filename search term from a Spotlight query string.
static char * | sl_cnid_to_path (TALLOC_CTX *mem_ctx, const struct vol *vol, cnid_t cnid)
| Reconstruct the full filesystem path for a CNID.
static int | sl_cnid_init (AFPObj *obj)
static void | sl_cnid_close (AFPObj *obj)
static int | sl_cnid_fill_results (slq_t *slq)
| Emit up to SL_CNID_PAGE_SIZE results from the private CNID buffer.
static int | sl_cnid_open_query (slq_t *slq)
static int | sl_cnid_fetch_results (slq_t *slq)
static void | sl_cnid_close_query (slq_t *slq)

## Variables
const sl_backend_ops | sl_cnid_ops

## Macro Definition Documentation

## ◆ SL_CNID_MAX_DEPTH

#define SL_CNID_MAX_DEPTH 64

## ◆ SL_CNID_MAX_RESULTS

#define SL_CNID_MAX_RESULTS 10000

## ◆ SL_CNID_MIN_TERMLEN

#define SL_CNID_MIN_TERMLEN 3

## ◆ SL_CNID_PAGE_SIZE

#define SL_CNID_PAGE_SIZE 20

## Function Documentation

## ◆ cnid_comp_fn()

int cnid_comp_fn | ( | const void * | p1,
|  | const void * | p2 )
| static

## ◆ sl_cnid_close()

void sl_cnid_close | ( | AFPObj * | obj | ) |
| static

## ◆ sl_cnid_close_query()

void sl_cnid_close_query | ( | slq_t * | slq | ) |
| static

## ◆ sl_cnid_extract_term()

char * sl_cnid_extract_term | ( | TALLOC_CTX * | mem_ctx,
|  | const char * | qstring )
| static

Extract a filename search term from a Spotlight query string.

Handles the common macOS patterns: kMDItemFSName = "foo*"cd → "foo" kMDItemDisplayName = "*foo*"cd → "foo" _kMDItemFileName = "foo*"cd → "foo"

Returns a talloc-allocated copy of the extracted term, or NULL if the query does not contain a supported filename predicate.

## ◆ sl_cnid_fetch_results()

int sl_cnid_fetch_results | ( | slq_t * | slq | ) |
| static

## ◆ sl_cnid_fill_results()

int sl_cnid_fill_results | ( | slq_t * | slq | ) |
| static

Emit up to SL_CNID_PAGE_SIZE results from the private CNID buffer.

Iterates over the remaining entries in csq->cnids[csq->pos..csq->count-1], resolving each CNID to a filesystem path and adding it to query_results. Stops after SL_CNID_PAGE_SIZE accepted results or when the buffer is exhausted, whichever comes first.

Sets slq_state to: SLQ_STATE_FULL — page is full, more results remain; client must poll SLQ_STATE_DONE — all results have been delivered SLQ_STATE_ERROR — add_filemeta() failed

Returns
  0 on success, -1 on error

## ◆ sl_cnid_init()

int sl_cnid_init | ( | AFPObj * | obj | ) |
| static

## ◆ sl_cnid_open_query()

int sl_cnid_open_query | ( | slq_t * | slq | ) |
| static

## ◆ sl_cnid_to_path()

char * sl_cnid_to_path | ( | TALLOC_CTX * | mem_ctx,
|  | const struct vol * | vol,
|  | cnid_t | cnid )
| static

Reconstruct the full filesystem path for a CNID.

Walks the DID chain upward via repeated cnid_resolve() calls, prepending path components, until reaching DIRDID_ROOT (the volume root).

Parameters

  mem_ctx | talloc context for the returned string
  vol | volume whose CNID database to query
  cnid | network-byte-order CNID (as returned by cnid_find)

Returns
  talloc-allocated full path, or NULL on error

## Variable Documentation

## ◆ sl_cnid_ops

const sl_backend_ops sl_cnid_ops

Initial value:
= {
.sbo_name = "cnid",
.sbo_init = sl_cnid_init,
.sbo_close = sl_cnid_close,
.sbo_open_query = sl_cnid_open_query,
.sbo_fetch_results = sl_cnid_fetch_results,
.sbo_close_query = sl_cnid_close_query,
}
sl_cnid_close
static void sl_cnid_close(AFPObj *obj)
Definition sl_cnid.c:329
sl_cnid_fetch_results
static int sl_cnid_fetch_results(slq_t *slq)
Definition sl_cnid.c:506
sl_cnid_open_query
static int sl_cnid_open_query(slq_t *slq)
Definition sl_cnid.c:449
sl_cnid_init
static int sl_cnid_init(AFPObj *obj)
Definition sl_cnid.c:323
sl_cnid_close_query
static void sl_cnid_close_query(slq_t *slq)
Definition sl_cnid.c:525