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 | sig_handler (int signo) |
| static void | set_signal (void) |
| static void | usage_cp (void) |
| int | ad_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 volatile sig_atomic_t | alarmed |
| static int | badcp |
| static int | rval |
| static int | ftw_options = FTW_MOUNT | FTW_PHYS | FTW_ACTIONRETVAL |
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.
| #define BUFSIZE_MAX (2*1024*1024) |
Maximum buffer size in bytes - do not allow it to grow larger than this
| #define BUFSIZE_SMALL (MAXPHYS) |
| #define MAXPHYS (64 * 1024) |
Small (default) buffer size in bytes. It's inefficient for this to be smaller than MAXPHYS
| #define PHYSPAGES_THRESHOLD (32*1024) |
Memory strategy threshold, in pages: if physmem is larger then this, use a large buffer
| #define STRIP_TRAILING_SLASH | ( | p | ) |
| #define YESNO "(y/n [n]) " |
| enum op |
| int ad_cp | ( | int | argc, |
| char * | argv[], | ||
| AFPObj * | obj ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
| cnid_t did |
|
static |
|
static |
| int fflag |
|
static |
| int iflag |
| mode_t mask |
| int nflag |
| cnid_t pdid |
| int pflag |
| cnid_t ppdid |
|
static |
|
static |
|
static |
| PATH_T to = { to.p_path, emptystring, "" } |
|
static |
| int vflag |