netatalk: cmd_dbd_scanvol.c File Reference

netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
cmd_dbd_scanvol.c File Reference
`#include <dirent.h>`
`#include <errno.h>`
`#include <fcntl.h>`
`#include <setjmp.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <sys/stat.h>`
`#include <sys/types.h>`
`#include <time.h>`
`#include <unistd.h>`
`#include <atalk/acl.h>`
`#include <atalk/adouble.h>`
`#include <atalk/cnid.h>`
`#include <atalk/cnid_private.h>`
`#include <atalk/compat.h>`
`#include <atalk/ea.h>`
`#include <atalk/errchk.h>`
`#include <atalk/netatalk_conf.h>`
`#include <atalk/unicode.h>`
`#include <atalk/util.h>`
`#include <atalk/volume.h>`
`#include "cmd_dbd.h"`

## Macros
#define | ADDIR_OK (addir_ok == 0)
#define | ADFILE_OK (adfile_ok == 0)

## Functions
static const char * | check_netatalk_dirs (const char *name)
| Check for netatalk special folders e.g. ".AppleDB" or ".AppleDesktop".
static const char * | check_special_dirs (const char *name)
| Check for special names.
static int | update_cnid (cnid_t did, const struct stat *sp, const char *oldname, const char *newname)
static int | check_adfile (const char *fname, const struct stat *st, const char **newname)
static void | remove_eafiles (const char *name, struct ea *ea)
static int | check_eafiles (const char *fname)
static int | check_addir (int volroot)
static int | check_eafile_in_adouble (const char *name)
| Check if file cotains "::EA" and if it does check if its correspondig data fork exists.
static int | read_addir (void)
| Check files and dirs inside .AppleDouble folder.
static cnid_t | check_cnid (const char *name, cnid_t did, struct stat *st, int adfile_ok)
| Check CNID for a file/dir, both from db and from ad-file.
static int | check_orphaned (const char *name)
static int | dbd_readdir (int volroot, cnid_t did)
int | cmd_dbd_scanvol (struct vol *vol_in, dbd_flags_t flags)

## Variables
static char | cwdbuf [MAXPATHLEN+1]
static struct vol * | vol
static dbd_flags_t | dbd_flags
static char | stamp [CNID_DEV_LEN]
static char * | netatalk_dirs []
static char * | special_dirs []
static jmp_buf | jmp
static char | pname [MAXPATHLEN] = "../"

## Macro Definition Documentation

## ◆ ADDIR_OK

#define ADDIR_OK (addir_ok == 0)

## ◆ ADFILE_OK

#define ADFILE_OK (adfile_ok == 0)

## Function Documentation

## ◆ check_addir()

int check_addir | ( | int | volroot | ) |
| static

Check for .AppleDouble folder and .Parent, create if missing

## ◆ check_adfile()

int check_adfile | ( | const char * | fname,
|  | const struct stat * | st,
|  | const char ** | newname )
| static

Check for .AppleDouble file, create if missing

## ◆ check_cnid()

cnid_t check_cnid | ( | const char * | name,
|  | cnid_t | did,
|  | struct stat * | st,
|  | int | adfile_ok )
| static

Check CNID for a file/dir, both from db and from ad-file.

Returns
  Correct CNID of object or CNID_INVALID (ie 0) on error

## ◆ check_eafile_in_adouble()

int check_eafile_in_adouble | ( | const char * | name | ) |
| static

Check if file cotains "::EA" and if it does check if its correspondig data fork exists.

Returns
  0 = name is not an EA file
  1 = name is an EA file and no problem was found
  -1 = name is an EA file and data fork is gone

## ◆ check_eafiles()

int check_eafiles | ( | const char * | fname | ) |
| static

Check Extended Attributes files

## ◆ check_netatalk_dirs()

const char * check_netatalk_dirs | ( | const char * | name | ) |
| static

Check for netatalk special folders e.g. ".AppleDB" or ".AppleDesktop".

Returns
  pointer to name or NULL.

## ◆ check_orphaned()

int check_orphaned | ( | const char * | name | ) |
| static

## ◆ check_special_dirs()

const char * check_special_dirs | ( | const char * | name | ) |
| static

Check for special names.

Returns
  pointer to name or NULL.

## ◆ cmd_dbd_scanvol()

int cmd_dbd_scanvol | ( | struct vol * | vol_in,
|  | dbd_flags_t | flags )

Main func called from cmd_dbd.c

## ◆ dbd_readdir()

int dbd_readdir | ( | int | volroot,
|  | cnid_t | did )
| static

This is called recursively for all dirs. volroot=1 means we're in the volume root dir, 0 means we aren't. We use this when checking for netatalk private folders like .AppleDB. did is our parent's CNID.

## ◆ read_addir()

int read_addir | ( | void |  | ) |
| static

Check files and dirs inside .AppleDouble folder.

Note
  remove orphaned files
  bail on dirs

## ◆ remove_eafiles()

void remove_eafiles | ( | const char * | name,
|  | struct ea * | ea )
| static

Remove all files with file::EA* from adouble dir

## ◆ update_cnid()

int update_cnid | ( | cnid_t | did,
|  | const struct stat * | sp,
|  | const char * | oldname,
|  | const char * | newname )
| static

We unCAPed a name, update CNID db

## Variable Documentation

## ◆ cwdbuf

char cwdbuf[MAXPATHLEN+1]
| static

## ◆ dbd_flags

dbd_flags_t dbd_flags
| static

## ◆ jmp

jmp_buf jmp
| static

## ◆ netatalk_dirs

char* netatalk_dirs[]
| static

Initial value:
= {
".AppleDB",
".AppleDesktop",
NULL
}
NULL
#define NULL
Definition utf8util.c:47

## ◆ pname

char pname[MAXPATHLEN] = "../"
| static

## ◆ special_dirs

char* special_dirs[]
| static

Initial value:
= {
".zfs",
NULL
}

## ◆ stamp

char stamp[CNID_DEV_LEN]
| static

## ◆ vol

struct vol* vol
| static