cp,mv,install: minor copy_internal refactoring
[coreutils.git] / src / chown-core.h
blob8afdc0b1e52889ef5546ff52de685c5c4bf4451e
1 /* chown-core.h -- types and prototypes shared by chown and chgrp.
3 Copyright (C) 2000-2023 Free Software Foundation, Inc.
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18 #ifndef CHOWN_CORE_H
19 # define CHOWN_CORE_H
21 # include "dev-ino.h"
22 # include <stdlib.h>
24 enum Change_status
26 CH_NOT_APPLIED = 1,
27 CH_SUCCEEDED,
28 CH_FAILED,
29 CH_NO_CHANGE_REQUESTED
32 enum Verbosity
34 /* Print a message for each file that is processed. */
35 V_high,
37 /* Print a message for each file whose attributes we change. */
38 V_changes_only,
40 /* Do not be verbose. This is the default. */
41 V_off
44 struct Chown_option
46 /* Level of verbosity. */
47 enum Verbosity verbosity;
49 /* If nonzero, change the ownership of directories recursively. */
50 bool recurse;
52 /* Pointer to the device and inode numbers of '/', when --recursive.
53 Need not be freed. Otherwise nullptr. */
54 struct dev_ino *root_dev_ino;
56 /* This corresponds to the --dereference (opposite of -h) option. */
57 bool affect_symlink_referent;
59 /* If nonzero, force silence (no error messages). */
60 bool force_silent;
62 /* The name of the user to which ownership of the files is being given. */
63 char *user_name;
65 /* The name of the group to which ownership of the files is being given. */
66 char *group_name;
69 void
70 chopt_init (struct Chown_option *);
72 void
73 chopt_free (struct Chown_option *);
75 char *
76 gid_to_name (gid_t)
77 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
78 _GL_ATTRIBUTE_RETURNS_NONNULL;
80 char *
81 uid_to_name (uid_t)
82 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
83 _GL_ATTRIBUTE_RETURNS_NONNULL;
85 bool
86 chown_files (char **files, int bit_flags,
87 uid_t uid, gid_t gid,
88 uid_t required_uid, gid_t required_gid,
89 struct Chown_option const *chopt)
90 _GL_ATTRIBUTE_NONNULL ();
92 #endif /* CHOWN_CORE_H */