From e89fd1026f451e8d3ac8f3eea2ab0eb3ee4997a2 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 23 Sep 2024 16:39:24 +0200 Subject: [PATCH] libmount: improve fs->stmnt_done mask use It is possible that one field in the libmnt_fs struct requires fetching multiple statmount fields using multiple STATMOUNT_* mask items. This requires changes to the way the fs->stmnt_done mask is used. Signed-off-by: Karel Zak --- libmount/src/fs_statmount.c | 10 ++++++++-- libmount/src/mountP.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libmount/src/fs_statmount.c b/libmount/src/fs_statmount.c index 8f05a45fd..c44e82299 100644 --- a/libmount/src/fs_statmount.c +++ b/libmount/src/fs_statmount.c @@ -305,10 +305,16 @@ int mnt_fs_fetch_statmount(struct libmnt_fs *fs, uint64_t mask) /* add default mask if on-demand enabled */ if (fs->stmnt && !fs->stmnt->disabled - && fs->stmnt->mask - && !(fs->stmnt_done & fs->stmnt->mask)) + && fs->stmnt->mask) mask |= fs->stmnt->mask; + /* call only for missing stuff */ + if (mask && fs->stmnt_done) { + mask &= ~fs->stmnt_done; /* remove what is already done */ + if (!mask) + return 0; + } + /* ignore repeated requests */ if (mask && fs->stmnt_done & mask) return 0; diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h index e2381e343..94328460a 100644 --- a/libmount/src/mountP.h +++ b/libmount/src/mountP.h @@ -291,7 +291,7 @@ struct libmnt_fs { if (!(FS)->MEMBER \ && (FS)->stmnt \ && !(FS)->stmnt->disabled \ - && !((FS)->stmnt_done & (FLAGS))) \ + && ((FLAGS) & ~((FS)->stmnt_done))) \ mnt_fs_fetch_statmount((FS), (FLAGS)); }) #endif -- 2.47.2