7 /* Control creation of sparse files (files with holes). */
12 /* Never create holes in DEST. */
15 /* This is the default. Use a crude (and sometimes inaccurate)
16 heuristic to determine if SOURCE has holes. If so, try to create
20 /* For every sufficiently long sequence of bytes in SOURCE, try to
21 create a corresponding hole in DEST. There is a performance penalty
22 here because CP has to search for holes in SRC. But if the holes are
23 big enough, that penalty can be offset by the decrease in the amount
24 of data written to disk. */
28 /* This type is used to help mv (via copy.c) distinguish these cases. */
37 /* How to handle symbolic links. */
38 enum Dereference_symlink
42 /* Copy the symbolic link itself. -P */
45 /* If the symbolic is a command line argument, then copy
46 its referent. Otherwise, copy the symbolic link itself. -H */
47 DEREF_COMMAND_LINE_ARGUMENTS
,
49 /* Copy the referent of the symbolic link. -L */
53 # define VALID_SPARSE_MODE(Mode) \
54 ((Mode) == SPARSE_NEVER \
55 || (Mode) == SPARSE_AUTO \
56 || (Mode) == SPARSE_ALWAYS)
58 /* These options control how files are copied by at least the
59 following programs: mv (when rename doesn't work), cp, install.
60 So, if you add a new member, be sure to initialize it in
61 mv.c, cp.c, and install.c. */
64 enum backup_type backup_type
;
66 /* If true, copy all files except (directories and, if not dereferencing
67 them, symbolic links,) as if they were regular files. */
70 /* How to handle symlinks. */
71 enum Dereference_symlink dereference
;
73 /* If true, remove each existing destination nondirectory before
75 bool unlink_dest_before_opening
;
77 /* If true, first try to open each existing destination nondirectory,
78 then, if the open fails, unlink and try again.
79 This option must be set for `cp -f', in case the destination file
80 exists when the open is attempted. It is irrelevant to `mv' since
81 any destination is sure to be removed before the open. */
82 bool unlink_dest_after_failed_open
;
84 /* If true, create hard links instead of copying files.
85 Create destination directories as usual. */
88 /* This value is used to determine whether to prompt before removing
89 each existing destination file. It works differently depending on
90 whether move_mode is set. See code/comments in copy.c. */
91 enum Interactive interactive
;
93 /* If true, rather than copying, first attempt to use rename.
94 If that fails, then resort to copying. */
97 /* This process's effective user ID. */
100 /* If true, when copying recursively, skip any subdirectories that are
101 on different file systems from the one we started on. */
102 bool one_file_system
;
104 /* If true, attempt to give the copies the original files' permissions,
105 owner, group, and timestamps. */
106 bool preserve_ownership
;
108 bool preserve_timestamps
;
110 /* Enabled for mv, and for cp by the --preserve=links option.
111 If true, attempt to preserve in the destination files any
112 logical hard links between the source files. If used with cp's
113 --no-dereference option, and copying two hard-linked files,
114 the two corresponding destination files will also be hard linked.
116 If used with cp's --dereference (-L) option, then, as that option implies,
117 hard links are *not* preserved. However, when copying a file F and
118 a symlink S to F, the resulting S and F in the destination directory
119 will be hard links to the same file (a copy of F). */
122 /* If true and any of the above (for preserve) file attributes cannot
123 be applied to a destination file, treat it as a failure and return
124 nonzero immediately. E.g. cp -p requires this be nonzero, mv requires
126 bool require_preserve
;
128 /* If true, copy directories recursively and copy special files
129 as themselves rather than copying their contents. */
132 /* If true, set file mode to value of MODE. Otherwise,
133 set it based on current umask modified by UMASK_KILL. */
136 /* Set the mode of the destination file to exactly this value
137 if SET_MODE is nonzero. */
140 /* Control creation of sparse files. */
141 enum Sparse_type sparse_mode
;
143 /* If true, create symbolic links instead of copying files.
144 Create destination directories as usual. */
147 /* The bits to preserve in created files' modes. */
150 /* If true, do not copy a nondirectory that has an existing destination
151 with the same or newer modification time. */
154 /* If true, display the names of the files before copying them. */
157 /* If true, stdin is a tty. */
160 /* This is a set of destination name/inode/dev triples. Each such triple
161 represents a file we have created corresponding to a source file name
162 that was specified on the command line. Use it to avoid clobbering
163 source files in commands like this:
164 rm -rf a b c; mkdir a b c; touch a/f b/f; mv a/f b/f c
165 For now, it protects only regular files when copying (i.e. not renaming).
166 When renaming, it protects all non-directories.
167 Use dest_info_init to initialize it, or set it to NULL to disable
169 Hash_table
*dest_info
;
172 Hash_table
*src_info
;
175 # define XSTAT(X, Src_path, Src_sb) \
176 ((X)->dereference == DEREF_NEVER \
177 ? lstat (Src_path, Src_sb) \
178 : stat (Src_path, Src_sb))
180 /* Arrange to make lstat calls go through the wrapper function
181 on systems with an lstat function that does not dereference symlinks
182 that are specified with a trailing slash. */
183 # if ! LSTAT_FOLLOWS_SLASHED_SYMLINK
184 int rpl_lstat (const char *, struct stat
*);
186 # define lstat rpl_lstat
189 /* Arrange to make rename calls go through the wrapper function
190 on systems with a rename function that fails for a source path
191 specified with a trailing slash. */
192 # if RENAME_TRAILING_SLASH_BUG
193 int rpl_rename (const char *, const char *);
195 # define rename rpl_rename
199 copy (const char *src_path
, const char *dst_path
,
200 bool nonexistent_dst
, const struct cp_options
*options
,
201 bool *copy_into_self
, bool *rename_succeeded
);
204 dest_info_init (struct cp_options
*);
206 src_info_init (struct cp_options
*);