#include <stdio.h>#include <sys/types.h>#include <stdlib.h>#include <string.h>#include <stddef.h>#include <unistd.h>#include <fcntl.h>#include <time.h>#include <sys/stat.h>#include <utime.h>#include <dirent.h>#include <errno.h>#include <assert.h>#include <sys/dir.h>Include dependency graph for cp.c:

Go to the source code of this file.
Data Structures | |
| struct | pathname |
| struct | entrylist |
Defines | |
| #define | nil 0 |
| #define | DEBUG 0 |
| #define | NDEBUG 1 |
| #define | CHUNK (1024 << (sizeof(int) + sizeof(char *))) |
| #define | CONFORMING 1 |
| #define | arraysize(a) (sizeof(a) / sizeof((a)[0])) |
| #define | arraylimit(a) ((a) + arraysize(a)) |
| #define | S_ISLNK(mode) (0) |
| #define | lstat stat |
| #define | symlink(path1, path2) (errno= ENOSYS, -1) |
| #define | readlink(path, buf, len) (errno= ENOSYS, -1) |
| #define | path_name(pp) ((const char *) (pp)->path) |
| #define | path_length(pp) ((pp)->idx) |
| #define | path_drop(pp) deallocate((void *) (pp)->path) |
| #define | PATH_MAX 1024 |
Typedefs | |
| typedef enum identity | identity_t |
| typedef enum action | action_t |
| typedef pathname | pathname_t |
| typedef entrylist | entrylist_t |
Enumerations | |
| enum | identity { CP, MV, RM, LN, CPDIR, CLONE } |
| enum | action { COPY, MOVE, REMOVE, LINK } |
Functions | |
| void | report (const char *label) |
| void | fatal (const char *label) |
| void | report2 (const char *src, const char *dst) |
| void * | allocate (void *mem, size_t size) |
| void | deallocate (void *mem) |
| void | path_init (pathname_t *pp) |
| void | path_add (pathname_t *pp, const char *name) |
| void | path_trunc (pathname_t *pp, size_t didx) |
| char * | basename (const char *path) |
| int | affirmative (void) |
| int | writable (const struct stat *stp) |
| static char * | link_islink (struct stat *stp, const char *file) |
| int | trylink (const char *src, const char *dst, struct stat *srcst, struct stat *dstst) |
| int | copy (const char *src, const char *dst, struct stat *srcst, struct stat *dstst) |
| void | copy1 (const char *src, const char *dst, struct stat *srcst, struct stat *dstst) |
| void | remove1 (const char *src, struct stat *srcst) |
| void | link1 (const char *src, const char *dst, struct stat *srcst, struct stat *dstst) |
| int | eat_dir (const char *dir, entrylist_t **dlist) |
| void | chop_dlist (entrylist_t **dlist) |
| void | drop_dlist (entrylist_t *dlist) |
| void | do1 (pathname_t *src, pathname_t *dst, int depth) |
| void | usage (void) |
| void | main (int argc, char **argv) |
Variables | |
| char * | prog_name |
| int | ex_code = 0 |
| identity_t | identity |
| action_t | action |
| int | pflag = 0 |
| int | iflag = 0 |
| int | fflag = 0 |
| int | sflag = 0 |
| int | Sflag = 0 |
| int | mflag = 0 |
| int | rflag = 0 |
| int | vflag = 0 |
| int | xflag = 0 |
| int | xdev = 0 |
| int | expand = 0 |
| int | conforming = CONFORMING |
| int | fc_mask |
| int | uid |
| int | gid |
| int | istty |
|
|
|
|
|
|
|
|
Definition at line 33 of file cp.c. Referenced by add(), bload(), bopen(), bskip(), build_index(), copy(), def(), extract(), gzcopy(), gzscan(), gztack(), inf(), main(), new_block(), reader(), and slave(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 188 of file cp.c. Referenced by apply_differences(), apply_remove(), do1(), link1(), main(), readstate(), recurse_dir(), and traverse(). |
|
|
Definition at line 238 of file cp.c. Referenced by addpath(), check_mtab(), chksymlinkzone(), decode_message(), descend(), diff_recursive(), do_exec(), fetch_name(), find(), find_bin(), finddev(), fpathconf(), fts_open(), get_data(), get_name(), iruserok(), link_islink(), list(), ltraverse(), main(), makelongnames(), makepath(), patch_stack(), tellstatus(), test21a(), test23a(), test23b(), test23c(), test25e(), test30c(), test31c(), test32b(), test33c(), update_mtab(), and work(). |
|
|
Definition at line 187 of file cp.c. Referenced by add(), add_file(), apply_add(), apply_differences(), apply_link(), apply_remove(), do1(), is_added(), link1(), readstate(), and traverse(). |
|
|
Definition at line 75 of file cp.c. Referenced by add_file(), copy1(), file(), link1(), print1(), and rdlink(). |
|
|
|
|
|
Definition at line 74 of file cp.c. Referenced by add(), apply_add(), copy1(), extract(), link1(), and node_creat(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 210 of file cp.c. References c, EOF, fflush(), getchar, ok(), stderr, and stdout. Referenced by copy(), copy1(), do1(), link1(), and remove1(). |
|
||||||||||||
|
|
|
|
Definition at line 192 of file cp.c. References p. |
|
|
Definition at line 851 of file cp.c. References deallocate, entrylist::name, and entrylist::next. Referenced by do1(), and drop_dlist(). |
|
||||||||||||||||||||
|
Definition at line 372 of file cp.c. References utimbuf::actime, affirmative(), assert, bp, chmod, chown, CHUNK, close, conforming, COPY, EACCES, ENOENT, EPERM, errno, fatal(), fc_mask, fflag, fprintf(), fstat, iflag, utimbuf::modtime, n, nil, O_CREAT, O_RDONLY, O_TRUNC, O_WRONLY, open, pflag, printf, prog_name, r, read, report(), S_IFREG, S_ISREG, S_IWUSR, stat::st_atime, stat::st_gid, stat::st_ino, stat::st_mode, stat::st_mtime, stat::st_uid, stderr, time, trylink(), unlink, utime, vflag, writable, and write. |
|
||||||||||||||||||||
|
Definition at line 546 of file cp.c. References utimbuf::actime, affirmative(), assert, chown, conforming, copy, EISDIR, EPERM, errno, ex_code, expand, fc_mask, fflag, fprintf(), iflag, linked(), lstat, mkfifo, mknod, utimbuf::modtime, nil, pflag, printf, prog_name, r, readlink, report(), rflag, S_ISBLK, S_ISCHR, S_ISDIR, S_ISFIFO, S_ISLNK, S_ISREG, stat::st_atime, stat::st_dev, stat::st_gid, stat::st_ino, stat::st_mode, stat::st_mtime, stat::st_rdev, stat::st_uid, stderr, symlink, time, trylink(), unlink, utime, vflag, and writable. Referenced by do1(). |
|
|
|
|
||||||||||||||||
|
Definition at line 867 of file cp.c. References utimbuf::actime, affirmative(), chmod, chop_dlist(), chown, conforming, COPY, copy1(), drop_dlist(), eat_dir(), EEXIST, EISDIR, ENOENT, ENOTDIR, ENOTEMPTY, EPERM, errno, ex_code, EXDEV, expand, fc_mask, fflag, flags, fprintf(), iflag, LINK, link1(), lstat, mflag, mkdir, utimbuf::modtime, nil, path_add(), path_length, path_name, path_trunc(), pflag, printf, prog_name, REMOVE, remove1(), rename, report(), report2(), rflag, rmdir, S_IRWXU, S_ISDIR, Sflag, sflag, stat::st_atime, stat::st_dev, stat::st_gid, stat::st_ino, stat::st_mode, stat::st_mtime, stat::st_uid, stderr, time, unlink, utime, vflag, writable, xdev, and xflag. Referenced by main(). |
|
|
Definition at line 861 of file cp.c. References chop_dlist(), and nil. Referenced by do1(). |
|
||||||||||||
|
Definition at line 829 of file cp.c. References allocate(), closedir, entry, nil, opendir, readdir, strcmp, strcpy(), and strlen(). |
|
|
|
|
||||||||||||||||||||
|
Definition at line 696 of file cp.c. References affirmative(), EISDIR, errno, ex_code, EXDEV, exit(), fflag, fprintf(), iflag, link, p, path_add(), path_drop, path_init(), path_length, path_name, path_trunc(), printf, prog_name, r, readlink, report(), report2(), rflag, S_ISDIR, S_ISLNK, Sflag, sflag, stat::st_ino, stat::st_mode, stderr, sym, symlink, unlink, vflag, and xdev. Referenced by do1(). |
|
||||||||||||
|
Definition at line 241 of file cp.c. References arraylimit, close, dev, free, link::ino, lp, link::next, nil, off, and PATH_MAX. |
|
||||||||||||
|
Definition at line 1199 of file cp.c. References assert, basename, CLONE, conforming, COPY, CP, CPDIR, do1(), ex_code, exit(), expand, fc_mask, fflag, flags, fprintf(), getegid, geteuid, gid, i, iflag, isatty, istty, LINK, LN, mflag, MV, nil, path_add(), path_drop, path_init(), path_length, path_trunc(), pflag, prog_name, REMOVE, rflag, RM, S_ISDIR, Sflag, sflag, slash(), st, stat::st_mode, stat, stderr, strchr, strcmp, uid, umask, usage, vflag, and xflag. |
|
||||||||||||
|
Definition at line 136 of file cp.c. References allocate(), pathname::idx, pathname::lim, p, pathname::path, and strlen(). Referenced by add(), apply_differences(), apply_remove(), do1(), link1(), main(), readstate(), and traverse(). |
|
|
Definition at line 129 of file cp.c. References allocate(), DIRSIZ, pathname::idx, pathname::lim, nil, and pathname::path. Referenced by add(), apply_differences(), link1(), main(), readstate(), and traverse(). |
|
||||||||||||
|
Definition at line 161 of file cp.c. References pathname::idx, and pathname::path. Referenced by apply_differences(), apply_remove(), do1(), link1(), main(), readstate(), and traverse(). |
|
||||||||||||
|
Definition at line 682 of file cp.c. References affirmative(), fflag, fprintf(), iflag, printf, report(), stat::st_mode, stderr, unlink, vflag, and writable. Referenced by do1(). |
|
|
Definition at line 78 of file cp.c. References errno, ex_code, fflag, fprintf(), prog_name, REMOVE, stderr, and strerror(). |
|
||||||||||||
|
Definition at line 91 of file cp.c. References errno, ex_code, fprintf(), prog_name, stderr, and strerror(). |
|
||||||||||||||||||||
|
Definition at line 349 of file cp.c. References COPY, expand, link, link_islink(), linked(), nil, printf, stat::st_ino, unlink, and vflag. |
|
|
Definition at line 1164 of file cp.c. References CLONE, CP, CPDIR, exit(), fprintf(), LN, MV, nil, prog_name, RM, and stderr. |
|
|
Definition at line 226 of file cp.c. References gid, istty, S_IWGRP, S_IWOTH, S_IWUSR, stat::st_gid, stat::st_mode, stat::st_uid, and uid. |
|
|
|
|
|
|
|
|
Definition at line 46 of file cp.c. Referenced by copy1(), do1(), link1(), main(), report(), and report2(). |
|
|
Definition at line 63 of file cp.c. Referenced by copy1(), do1(), docmds1(), eval(), evalstr(), find_device(), macro(), main(), mcat(), mformat(), and trylink(). |
|
|
|
|
|
|
|
|
Definition at line 67 of file cp.c. Referenced by display_attrib(), do_chown(), getids(), grp_add(), main(), permissions(), test34a(), test34c(), test35c(), and writable(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 67 of file cp.c. Referenced by display_attrib(), do_chown(), get_homedir(), getids(), main(), permissions(), recover(), test34a(), test34c(), test35c(), usr_add(), and writable(). |
|
|
|
|
|
Definition at line 62 of file cp.c. Referenced by do1(), link1(), and traverse(). |
|
|
|
1.4.6