6 /* Control creation of sparse files (files with holes). */
11 /* Never create holes in DEST. */
14 /* This is the default. Use a crude (and sometimes inaccurate)
15 heuristic to determine if SOURCE has holes. If so, try to create
19 /* For every sufficiently long sequence of bytes in SOURCE, try to
20 create a corresponding hole in DEST. There is a performance penalty
21 here because CP has to search for holes in SRC. But if the holes are
22 big enough, that penalty can be offset by the decrease in the amount
23 of data written to disk. */
27 /* This type is used to help mv (via copy.c) distinguish these cases. */
36 /* How to handle symbolic links. */
37 enum Dereference_symlink
41 /* Copy the symbolic link itself. -P */
44 /* If the symbolic is a command line argument, then copy
45 its referent. Otherwise, copy the symbolic link itself. -H */
46 DEREF_COMMAND_LINE_ARGUMENTS
,
48 /* Copy the referent of the symbolic link. -L */
52 # define VALID_SPARSE_MODE(Mode) \
53 ((Mode) == SPARSE_NEVER \
54 || (Mode) == SPARSE_AUTO \
55 || (Mode) == SPARSE_ALWAYS)
57 /* These options control how files are copied by at least the
58 following programs: mv (when rename doesn't work), cp, install.
59 So, if you add a new member, be sure to initialize it in
60 mv.c, cp.c, and install.c. */
63 enum backup_type backup_type
;
65 /* If nonzero, copy all files except (directories and, if not dereferencing
66 them, symbolic links,) as if they were regular files. */
69 /* How to handle symlinks. */
70 enum Dereference_symlink dereference
;
72 /* If nonzero, remove each existing destination nondirectory before
74 int unlink_dest_before_opening
;
76 /* If nonzero, first try to open each existing destination nondirectory,
77 then, if the open fails, unlink and try again.
78 This option must be set for `cp -f', in case the destination file
79 exists when the open is attempted. It is irrelevant to `mv' since
80 any destination is sure to be removed before the open. */
81 int unlink_dest_after_failed_open
;
83 /* If nonzero, create hard links instead of copying files.
84 Create destination directories as usual. */
87 /* This value is used to determine whether to prompt before removing
88 each existing destination file. It works differently depending on
89 whether move_mode is set. See code/comments in copy.c. */
90 enum Interactive interactive
;
92 /* If nonzero, rather than copying, first attempt to use rename.
93 If that fails, then resort to copying. */
96 /* This process's effective user ID. */
99 /* If nonzero, when copying recursively, skip any subdirectories that are
100 on different filesystems from the one we started on. */
103 /* If nonzero, attempt to give the copies the original files' permissions,
104 owner, group, and timestamps. */
105 int preserve_ownership
;
107 int preserve_timestamps
;
109 /* Enabled for mv, and for cp by the --preserve=links option.
110 If nonzero, attempt to preserve in the destination files any
111 logical hard links between the source files. If used with cp's
112 --no-dereference option, and copying two hard-linked files,
113 the two corresponding destination files will also be hard linked.
115 If used with cp's --dereference (-L) option, then, as that option implies,
116 hard links are *not* preserved. However, when copying a file F and
117 a symlink S to F, the resulting S and F in the destination directory
118 will be hard links to the same file (a copy of F). */
121 /* If nonzero and any of the above (for preserve) file attributes cannot
122 be applied to a destination file, treat it as a failure and return
123 nonzero immediately. E.g. cp -p requires this be nonzero, mv requires
125 int require_preserve
;
127 /* If nonzero, copy directories recursively and copy special files
128 as themselves rather than copying their contents. */
131 /* If nonzero, set file mode to value of MODE. Otherwise,
132 set it based on current umask modified by UMASK_KILL. */
135 /* Set the mode of the destination file to exactly this value
136 if USE_MODE is nonzero. */
139 /* Control creation of sparse files. */
140 enum Sparse_type sparse_mode
;
142 /* If nonzero, create symbolic links instead of copying files.
143 Create destination directories as usual. */
146 /* The bits to preserve in created files' modes. */
149 /* If nonzero, do not copy a nondirectory that has an existing destination
150 with the same or newer modification time. */
153 /* If nonzero, display the names of the files before copying them. */
156 /* If nonzero, stdin is a tty. */
159 /* This is a set of destination name/inode/dev triples. Each such triple
160 represents a file we have created corresponding to a source file name
161 that was specified on the command line. Use it to avoid clobbering
162 source files in commands like this:
163 rm -rf a b c; mkdir a b c; touch a/f b/f; mv a/f b/f c
164 For now, it protects only regular files when copying (i.e. not renaming).
165 When renaming, it protects all non-directories.
166 Use dest_info_init to initialize it, or set it to NULL to disable
168 Hash_table
*dest_info
;
171 Hash_table
*src_info
;
177 # define XSTAT(X, Src_path, Src_sb) \
178 ((X)->dereference == DEREF_NEVER \
179 ? lstat (Src_path, Src_sb) \
180 : stat (Src_path, Src_sb))
182 /* Arrange to make lstat calls go through the wrapper function
183 on systems with an lstat function that does not dereference symlinks
184 that are specified with a trailing slash. */
185 # if ! LSTAT_FOLLOWS_SLASHED_SYMLINK
186 int rpl_lstat (const char *, struct stat
*);
188 # define lstat rpl_lstat
193 /* Arrange to make rename calls go through the wrapper function
194 on systems with a rename function that fails for a source path
195 specified with a trailing slash. */
196 # if RENAME_TRAILING_SLASH_BUG
197 int rpl_rename (const char *, const char *);
199 # define rename rpl_rename
203 copy (const char *src_path
, const char *dst_path
,
204 int nonexistent_dst
, const struct cp_options
*options
,
205 int *copy_into_self
, int *rename_succeeded
);
208 dest_info_init (struct cp_options
*);
210 src_info_init (struct cp_options
*);