]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: improve fs->stmnt_done mask use
authorKarel Zak <kzak@redhat.com>
Mon, 23 Sep 2024 14:39:24 +0000 (16:39 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 8 Jan 2025 12:57:43 +0000 (13:57 +0100)
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 <kzak@redhat.com>
libmount/src/fs_statmount.c
libmount/src/mountP.h

index 8f05a45fd21667eab0164c86bc8cb7afd74118ea..c44e822995c3c8397d90983ee65c91445b31ff7b 100644 (file)
@@ -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;
index e2381e34314e5ad109a75c1a55f900d81be07586..94328460a11d50b788c388581cb0f13d006bfb60 100644 (file)
@@ -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