[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/8] os-posix.c: move code around
From: |
Michael Tokarev |
Subject: |
[PATCH 5/8] os-posix.c: move code around |
Date: |
Fri, 1 Sep 2023 13:12:59 +0300 |
this moves code blocks so that functions and variables which
belongs to the same concept are now close to each other.
There's no actual code changes in there.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
os-posix.c | 49 +++++++++++++++++++++++++++----------------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/os-posix.c b/os-posix.c
index 4102fcdb5e..340373d972 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -40,17 +40,6 @@
#include <sys/prctl.h>
#endif
-/*
- * Must set all three of these at once.
- * Legal combinations are unset by name by uid
- */
-static struct passwd *user_pwd; /* NULL non-NULL NULL */
-static uid_t user_uid = (uid_t)-1; /* -1 -1 >=0 */
-static gid_t user_gid = (gid_t)-1; /* -1 -1 >=0 */
-
-static const char *chroot_dir;
-static int daemonize;
-static int daemon_pipe;
void os_setup_early_signal_handling(void)
{
@@ -97,6 +86,15 @@ void os_set_proc_name(const char *s)
#endif
}
+
+/*
+ * Must set all three of these at once.
+ * Legal combinations are unset by name by uid
+ */
+static struct passwd *user_pwd; /* NULL non-NULL NULL */
+static uid_t user_uid = (uid_t)-1; /* -1 -1 >=0 */
+static gid_t user_gid = (gid_t)-1; /* -1 -1 >=0 */
+
/*
* Prepare to change user ID. optarg can be one of 3 forms:
* - a username, in which case user ID will be changed to its uid,
@@ -174,6 +172,9 @@ static void change_process_uid(void)
}
}
+
+static const char *chroot_dir;
+
void os_set_chroot(const char *optarg)
{
chroot_dir = optarg;
@@ -194,6 +195,21 @@ static void change_root(void)
}
+
+static int daemonize;
+static int daemon_pipe;
+
+bool is_daemonized(void)
+{
+ return daemonize;
+}
+
+int os_set_daemonize(bool d)
+{
+ daemonize = d;
+ return 0;
+}
+
void os_daemonize(void)
{
if (daemonize) {
@@ -287,17 +303,6 @@ void os_set_line_buffering(void)
setvbuf(stdout, NULL, _IOLBF, 0);
}
-bool is_daemonized(void)
-{
- return daemonize;
-}
-
-int os_set_daemonize(bool d)
-{
- daemonize = d;
- return 0;
-}
-
int os_mlock(void)
{
#ifdef HAVE_MLOCKALL
--
2.39.2
- [PATCH 0/8] move softmmu options processing from os-posix.c to vl.c, Michael Tokarev, 2023/09/01
- [PATCH 1/8] include/sysemu/os-posix.h: move *daemonize* declarations together, Michael Tokarev, 2023/09/01
- [PATCH 2/8] os-posix: create and export os_set_runas(), Michael Tokarev, 2023/09/01
- [PATCH 3/8] os-posix.c: create and export os_set_chroot(), Michael Tokarev, 2023/09/01
- [PATCH 6/8] os-posix.c: remove unneeded #includes, Michael Tokarev, 2023/09/01
- [PATCH 8/8] util/async-teardown.c: move to softmmu/, only build it when system build is requested, Michael Tokarev, 2023/09/01
- [PATCH 4/8] os-posix.c, softmmu/vl.c: move os_parse_cmd_args() into qemu_init(), Michael Tokarev, 2023/09/01
- [PATCH 5/8] os-posix.c: move code around,
Michael Tokarev <=
- [PATCH 7/8] softmmu/vl.c: inline include/qemu/qemu-options.h into vl.c, Michael Tokarev, 2023/09/01
- Re: [PATCH 0/8] move softmmu options processing from os-posix.c to vl.c, Paolo Bonzini, 2023/09/01