(struct cp_options.umask_kill): Use mode_t, not unsigned int.
[platform/upstream/coreutils.git] / src / copy.h
1 #ifndef COPY_H
2 # define COPY_H
3
4 /* Control creation of sparse files (files with holes).  */
5 enum Sparse_type
6 {
7   SPARSE_UNUSED,
8
9   /* Never create holes in DEST.  */
10   SPARSE_NEVER,
11
12   /* This is the default.  Use a crude (and sometimes inaccurate)
13      heuristic to determine if SOURCE has holes.  If so, try to create
14      holes in DEST.  */
15   SPARSE_AUTO,
16
17   /* For every sufficiently long sequence of bytes in SOURCE, try to
18      create a corresponding hole in DEST.  There is a performance penalty
19      here because CP has to search for holes in SRC.  But if the holes are
20      big enough, that penalty can be offset by the decrease in the amount
21      of data written to disk.   */
22   SPARSE_ALWAYS
23 };
24
25 # define VALID_SPARSE_MODE(Mode)        \
26   ((Mode) == SPARSE_NEVER               \
27    || (Mode) == SPARSE_AUTO             \
28    || (Mode) == SPARSE_ALWAYS)
29
30 struct cp_options
31 {
32   enum backup_type backup_type;
33
34   /* If nonzero, copy all files except (directories and, if not dereferencing
35      them, symbolic links,) as if they were regular files. */
36   int copy_as_regular;
37
38   /* If nonzero, dereference symbolic links (copy the files they point to). */
39   int dereference;
40
41   /* If nonzero, remove existing destination nondirectories. */
42   int force;
43
44   /* Setting this member is meaningful only if FORCE is also set.
45      If nonzero, copy returns nonzero upon failed unlink.
46      Otherwise, the failure still elicits a diagnostic, but it doesn't
47      change copy's return value.  This is nonzero for cp and mv, and zero
48      for install.  */
49   int failed_unlink_is_fatal;
50
51   /* If nonzero, create hard links instead of copying files.
52      Create destination directories as usual. */
53   int hard_link;
54
55   /* If nonzero, query before overwriting existing destinations
56      with regular files. */
57   int interactive;
58
59   /* If nonzero, rather than copying, first attempt to use rename.
60      If that fails, then resort to copying.  */
61   int move_mode;
62
63   /* This process's effective user ID.  */
64   uid_t myeuid;
65
66   /* If nonzero, when copying recursively, skip any subdirectories that are
67      on different filesystems from the one we started on. */
68   int one_file_system;
69
70   /* If nonzero, attempt to give the copies the original files' permissions,
71      owner, group, and timestamps. */
72   int preserve_owner_and_group;
73   int preserve_chmod_bits;
74   int preserve_timestamps;
75
76   /* If nonzero and any of the above (for preserve) file attributes cannot
77      be applied to a destination file, treat it as a failure and return
78      nonzero immediately.  E.g. cp -p requires this be nonzero, mv requires
79      it be zero.  */
80   int require_preserve;
81
82   /* If nonzero, copy directories recursively and copy special files
83      as themselves rather than copying their contents. */
84   int recursive;
85
86   /* If nonzero, set file mode to value of MODE.  Otherwise,
87      set it based on current umask modified by UMASK_KILL.  */
88   int set_mode;
89
90   /* Set the mode of the destination file to exactly this value
91      if USE_MODE is nonzero.  */
92   mode_t mode;
93
94   /* Control creation of sparse files.  */
95   enum Sparse_type sparse_mode;
96
97   /* If nonzero, create symbolic links instead of copying files.
98      Create destination directories as usual. */
99   int symbolic_link;
100
101   /* The bits to preserve in created files' modes. */
102   mode_t umask_kill;
103
104   /* If nonzero, do not copy a nondirectory that has an existing destination
105      with the same or newer modification time. */
106   int update;
107
108   /* If nonzero, display the names of the files before copying them. */
109   int verbose;
110
111   /* A pointer to either lstat or stat, depending on
112      whether the copy should dereference symlinks.  */
113   int (*xstat) ();
114 };
115
116 int
117 copy PARAMS ((const char *src_path, const char *dst_path,
118               int nonexistent_dst, const struct cp_options *options,
119               int *copy_into_self, int *rename_succeeded));
120
121 #endif