netatalk: nad_util.c File Reference

netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
nad_util.c File Reference
`#include <errno.h>`
`#include <fcntl.h>`
`#include <libgen.h>`
`#include <limits.h>`
`#include <stdarg.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <bstrlib.h>`
`#include <sys/mman.h>`
`#include <sys/param.h>`
`#include <sys/stat.h>`
`#include <sys/types.h>`
`#include <sysexits.h>`
`#include <unistd.h>`
`#include <sys/acl.h>`
`#include <atalk/cnid.h>`
`#include <atalk/errchk.h>`
`#include <atalk/globals.h>`
`#include <atalk/logger.h>`
`#include <atalk/netatalk_conf.h>`
`#include <atalk/unicode.h>`
`#include <atalk/util.h>`
`#include "nad.h"`

## Functions
static void | sig_handler (int signo)
void | set_signal (void)
void | _log (enum logtype lt, char *fmt,...)
int | openvol_optional (AFPObj *obj, const char *path, afpvol_t *vol)
| Open an AFP volume, or return a stub for non-AFP paths.
int | openvol (AFPObj *obj, const char *path, afpvol_t *vol)
| Load volinfo and initialize struct vol.
void | closevol (afpvol_t *vol)
int | convert_dots_encoding (const afpvol_t *svol, const afpvol_t *dvol, char *path)
| Convert dot encoding of basename in place.
cnid_t | cnid_for_paths_parent (const afpvol_t *vol, const char *path, cnid_t *did)
| Resolves CNID of a given paths parent directory.

## Variables
int | log_verbose
volatile sig_atomic_t | alarmed
static struct vol | null_vol

## Function Documentation

## ◆ _log()

void _log | ( | enum logtype | lt,
|  | char * | fmt,
|  |  | ... )

## ◆ closevol()

void closevol | ( | afpvol_t * | vol | ) |

## ◆ cnid_for_paths_parent()

cnid_t cnid_for_paths_parent | ( | const afpvol_t * | vol,
|  | const char * | path,
|  | cnid_t * | did )

Resolves CNID of a given paths parent directory.

path might be: (a) relative: "dir/subdir" with cwd: "/afp_volume/topdir" (b) absolute: "/afp_volume/dir/subdir"

path MUST be pointing inside vol, this is usually the case as vol has been build from path using loadvolinfo and friends.

Parameters

  [in] | vol | pointer to afpvol_t
  [in] | path | path, see above
  [in,out] | did | parent CNID of returned CNID

Returns
  CNID of path

## ◆ convert_dots_encoding()

int convert_dots_encoding | ( | const afpvol_t * | svol,
|  | const afpvol_t * | dvol,
|  | char * | path )

Convert dot encoding of basename in place.

path arg can be "[/][dir/ | ...]filename". It will be converted in place possible encoding ".file" as ":2efile" which means the result will be longer then the original which means provide a big enough buffer.

Parameters

  [in] | svol | source volume
  [in] | dvol | destination volume
  [in,out] | path | path to convert in place

Returns
  0 on success, -1 on error

## ◆ openvol()

int openvol | ( | AFPObj * | obj,
|  | const char * | path,
|  | afpvol_t * | vol )

Load volinfo and initialize struct vol.

The path must be inside an AFP volume. Returns -1 if it is not.

Parameters

  [in] | obj | AFPObj of the current connection
  [in] | path | path to evaluate
  [in,out] | vol | structure to initialize

Returns
  0 on success, -1 on error

## ◆ openvol_optional()

int openvol_optional | ( | AFPObj * | obj,
|  | const char * | path,
|  | afpvol_t * | vol )

Open an AFP volume, or return a stub for non-AFP paths.

If the path is inside an AFP volume, the volume's CNID database is opened. If the path is outside any AFP volume, a stub volume with v_path=NULL and v_cdb=NULL is returned so that callers can use v_path as a guard for AFP-specific operations.

This is intended for commands like mv and cp that may operate across AFP and non-AFP paths.

Parameters

  [in] | obj | AFPObj of the current connection
  [in] | path | path to evaluate
  [in,out] | vol | structure to initialize

Returns
  0 on success, -1 on error

## ◆ set_signal()

void set_signal | ( | void |  | ) |

## ◆ sig_handler()

void sig_handler | ( | int | signo | ) |
| static

## Variable Documentation

## ◆ alarmed

volatile sig_atomic_t alarmed

Signal flag for clean exit

flags for signals

## ◆ log_verbose

int log_verbose

Logging flag

## ◆ null_vol

struct vol null_vol
| static

Static stub volume for paths outside any AFP volume