netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
nad_cp.c File Reference

Cp copies source files to target files. More...

`#include <errno.h>`
`#include <libgen.h>`
`#include <limits.h>`
`#include <signal.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <sys/stat.h>`
`#include <sys/types.h>`
`#include <unistd.h>`
`#include <bstrlib.h>`
`#include <atalk/adouble.h>`
`#include <atalk/queue.h>`
`#include <atalk/unix.h>`
`#include <atalk/util.h>`
`#include <atalk/vfs.h>`
`#include <atalk/volume.h>`
`#include "nad.h"`
`#include "ftw.h"`

## Macros
#define | STRIP_TRAILING_SLASH(p)
#define | PHYSPAGES_THRESHOLD (32*1024)
#define | BUFSIZE_MAX (2*1024*1024)
#define | MAXPHYS (64 * 1024)
#define | BUFSIZE_SMALL (MAXPHYS)
#define | YESNO "(y/n [n]) "

## Enumerations
enum | op { FILE_TO_FILE , FILE_TO_DIR , DIR_TO_DNE }

## Functions
static int | copy (const char *fpath, const struct stat *sb, int tflag, struct FTW *ftwbuf)
static int | ftw_copy_file (const struct FTW *, const char *, const struct stat *, int)
static int | ftw_copy_link (const struct FTW *, const char *, const struct stat *, int)
static int | setfile (const struct stat *, int)
static void | upfunc (void)
static void | usage_cp (void)
int | nad_cp (int argc, char *argv[], AFPObj *obj)

## Variables
static char | emptystring [] = ""
PATH_T | to = { to.p_path, emptystring, "" }
int | fflag
int | iflag
int | nflag
int | pflag
int | vflag
mode_t | mask
cnid_t | ppdid
cnid_t | pdid
cnid_t | did
static afpvol_t | svolume
static afpvol_t | dvolume
static enum op | type
static int | Rflag
static int | badcp
static int | rval
static int | ftw_options = FTW_MOUNT | FTW_PHYS | FTW_ACTIONRETVAL

## Detailed Description

Cp copies source files to target files.

The global PATH_T structure "to" always contains the path to the current target file. Since fts(3) does not change directories, this path can be either absolute or dot-relative.

The basic algorithm is to initialize "to" and use fts(3) to traverse the file hierarchy rooted in the argument list. A trivial case is the case of 'cp file1 file2'. The more interesting case is the case of 'cp file1 file2 ... fileN dir' where the hierarchy is traversed and the path (relative to the root of the traversal) is appended to dir (stored in "to") to form the final target path.

## Macro Definition Documentation

## ◆ BUFSIZE_MAX

#define BUFSIZE_MAX (2*1024*1024)

Maximum buffer size in bytes - do not allow it to grow larger than this

## ◆ BUFSIZE_SMALL

#define BUFSIZE_SMALL (MAXPHYS)

## ◆ MAXPHYS

#define MAXPHYS (64 * 1024)

Small (default) buffer size in bytes. It's inefficient for this to be smaller than MAXPHYS

## ◆ PHYSPAGES_THRESHOLD

#define PHYSPAGES_THRESHOLD (32*1024)

Memory strategy threshold, in pages: if physmem is larger then this, use a large buffer

## ◆ STRIP_TRAILING_SLASH

#define STRIP_TRAILING_SLASH | ( |  | p | ) |

Value:
{ \
while ((p).p_end > (p).p_path + 1 && (p).p_end[-1] == '/') \
*--(p).p_end = 0; \
}
p
size_t p
Definition dircache.c:256

## ◆ YESNO

#define YESNO "(y/n [n]) "

## Enumeration Type Documentation

## ◆ op

enum op

Enumerator
FILE_TO_FILE |
FILE_TO_DIR |
DIR_TO_DNE |

## Function Documentation

## ◆ copy()

int copy | ( | const char * | fpath,
|  | const struct stat * | sb,
|  | int | tflag,
|  | struct FTW * | ftwbuf )
| static

## ◆ ftw_copy_file()

int ftw_copy_file | ( | const struct FTW * | entp,
|  | const char * | spath,
|  | const struct stat * | sp,
|  | int | dne )
| static

## ◆ ftw_copy_link()

int ftw_copy_link | ( | const struct FTW * | p,
|  | const char * | spath,
|  | const struct stat * | sstp,
|  | int | exists )
| static

## ◆ nad_cp()

int nad_cp | ( | int | argc,
|  | char * | argv[],
|  | AFPObj * | obj )

## ◆ setfile()

int setfile | ( | const struct stat * | fs,
|  | int | fd )
| static

## ◆ upfunc()

void upfunc | ( | void |  | ) |
| static

## ◆ usage_cp()

void usage_cp | ( | void |  | ) |
| static

## Variable Documentation

## ◆ badcp

int badcp
| static

## ◆ did

cnid_t did

## ◆ dvolume

afpvol_t dvolume
| static

## ◆ emptystring

char emptystring[] = ""
| static

## ◆ fflag

int fflag

## ◆ ftw_options

int ftw_options = FTW_MOUNT | FTW_PHYS | FTW_ACTIONRETVAL
| static

## ◆ iflag

int iflag

## ◆ mask

mode_t mask

## ◆ nflag

int nflag

## ◆ pdid

cnid_t pdid

## ◆ pflag

int pflag

## ◆ ppdid

cnid_t ppdid

## ◆ Rflag

int Rflag
| static

## ◆ rval

int rval
| static

## ◆ svolume

afpvol_t svolume
| static

## ◆ to

PATH_T to = { to.p_path, emptystring, "" }

## ◆ type

enum op type
| static

## ◆ vflag

int vflag