summaryrefslogtreecommitdiffstats
path: root/src/chown-core.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:11:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:11:47 +0000
commit758f820bcc0f68aeebac1717e537ca13a320b909 (patch)
tree48111ece75cf4f98316848b37a7e26356e00669e /src/chown-core.h
parentInitial commit. (diff)
downloadcoreutils-upstream.tar.xz
coreutils-upstream.zip
Adding upstream version 9.1.upstream/9.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/chown-core.h')
-rw-r--r--src/chown-core.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/chown-core.h b/src/chown-core.h
new file mode 100644
index 0000000..8d4b181
--- /dev/null
+++ b/src/chown-core.h
@@ -0,0 +1,92 @@
+/* chown-core.h -- types and prototypes shared by chown and chgrp.
+
+ Copyright (C) 2000-2022 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef CHOWN_CORE_H
+# define CHOWN_CORE_H
+
+# include "dev-ino.h"
+# include <stdlib.h>
+
+enum Change_status
+{
+ CH_NOT_APPLIED = 1,
+ CH_SUCCEEDED,
+ CH_FAILED,
+ CH_NO_CHANGE_REQUESTED
+};
+
+enum Verbosity
+{
+ /* Print a message for each file that is processed. */
+ V_high,
+
+ /* Print a message for each file whose attributes we change. */
+ V_changes_only,
+
+ /* Do not be verbose. This is the default. */
+ V_off
+};
+
+struct Chown_option
+{
+ /* Level of verbosity. */
+ enum Verbosity verbosity;
+
+ /* If nonzero, change the ownership of directories recursively. */
+ bool recurse;
+
+ /* Pointer to the device and inode numbers of '/', when --recursive.
+ Need not be freed. Otherwise NULL. */
+ struct dev_ino *root_dev_ino;
+
+ /* This corresponds to the --dereference (opposite of -h) option. */
+ bool affect_symlink_referent;
+
+ /* If nonzero, force silence (no error messages). */
+ bool force_silent;
+
+ /* The name of the user to which ownership of the files is being given. */
+ char *user_name;
+
+ /* The name of the group to which ownership of the files is being given. */
+ char *group_name;
+};
+
+void
+chopt_init (struct Chown_option *);
+
+void
+chopt_free (struct Chown_option *);
+
+char *
+gid_to_name (gid_t)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
+
+char *
+uid_to_name (uid_t)
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
+
+bool
+chown_files (char **files, int bit_flags,
+ uid_t uid, gid_t gid,
+ uid_t required_uid, gid_t required_gid,
+ struct Chown_option const *chopt)
+ _GL_ATTRIBUTE_NONNULL ();
+
+#endif /* CHOWN_CORE_H */