selinux_restorecon: add a global mutex to synchronize progress output
Another small incremental change to pave the way for a parallel selinux_restorecon() function. Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
This commit is contained in:
parent
78bdce9c2a
commit
a578d1cecd
1 changed files with 3 additions and 0 deletions
|
@ -60,6 +60,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. */
|
||||
static struct dir_xattr *dir_xattr_list;
|
||||
|
@ -647,6 +648,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) {
|
||||
|
@ -658,6 +660,7 @@ static int restorecon_sb(const char *pathname, const struct stat *sb,
|
|||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
__pthread_mutex_unlock(&progress_mutex);
|
||||
}
|
||||
|
||||
if (flags->add_assoc) {
|
||||
|
|
Loading…
Reference in a new issue