All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ondrej Mosnacek <omosnace@redhat.com>
To: selinux@vger.kernel.org
Subject: [RFC PATCH userspace 4/6] selinux_restorecon: add a global mutex to synchronize progress output
Date: Tue, 23 Mar 2021 18:08:28 +0100	[thread overview]
Message-ID: <20210323170830.182553-5-omosnace@redhat.com> (raw)
In-Reply-To: <20210323170830.182553-1-omosnace@redhat.com>

Another small incremental change to pave the way for a parallel
selinux_restorecon() function.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
---
 libselinux/src/selinux_restorecon.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libselinux/src/selinux_restorecon.c b/libselinux/src/selinux_restorecon.c
index 0ebe56b1..3f3ac2e6 100644
--- a/libselinux/src/selinux_restorecon.c
+++ b/libselinux/src/selinux_restorecon.c
@@ -69,6 +69,7 @@ static int exclude_count = 0;
 static struct edir *exclude_lst = NULL;
 static uint64_t fc_count = 0;	/* Number of files processed so far */
 static uint64_t efile_count;	/* Estimated total number of files */
+static pthread_mutex_t progress_mutex = PTHREAD_MUTEX_INITIALIZER;
 
 /* Store information on directories with xattr's. */
 struct dir_xattr *dir_xattr_list;
@@ -658,6 +659,7 @@ static int restorecon_sb(const char *pathname, const struct stat *sb,
 	}
 
 	if (flags->progress) {
+		__pthread_mutex_lock(&progress_mutex);
 		fc_count++;
 		if (fc_count % STAR_COUNT == 0) {
 			if (flags->mass_relabel && efile_count > 0) {
@@ -669,6 +671,7 @@ static int restorecon_sb(const char *pathname, const struct stat *sb,
 			}
 			fflush(stdout);
 		}
+		__pthread_mutex_unlock(&progress_mutex);
 	}
 
 	if (flags->add_assoc) {
-- 
2.30.2


  parent reply	other threads:[~2021-03-23 17:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 17:08 [RFC PATCH userspace 0/6] Parallel setfiles/restorecon Ondrej Mosnacek
2021-03-23 17:08 ` [RFC PATCH userspace 1/6] selinux_restorecon: simplify fl_head allocation by using calloc() Ondrej Mosnacek
2021-03-23 17:08 ` [RFC PATCH userspace 2/6] selinux_restorecon: protect file_spec list with a mutex Ondrej Mosnacek
2021-03-23 17:08 ` [RFC PATCH userspace 3/6] selinux_restorecon: introduce selinux_log_sync() Ondrej Mosnacek
2021-03-23 17:08 ` Ondrej Mosnacek [this message]
2021-03-23 17:08 ` [RFC PATCH userspace 5/6] selinux_restorecon: introduce selinux_restorecon_parallel(3) Ondrej Mosnacek
2021-03-23 17:08 ` [RFC PATCH userspace 6/6] setfiles/restorecon: support parallel relabeling Ondrej Mosnacek
2021-03-24  9:58 ` [RFC PATCH userspace 0/6] Parallel setfiles/restorecon peter enderborg
2021-03-24 11:04   ` Ondrej Mosnacek
2021-04-28 21:11     ` Nicolas Iooss
2021-04-30 12:49       ` Ondrej Mosnacek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210323170830.182553-5-omosnace@redhat.com \
    --to=omosnace@redhat.com \
    --cc=selinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.