]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: make.stx_mnt_id use more robust
authorKarel Zak <kzak@redhat.com>
Thu, 31 Aug 2023 08:30:55 +0000 (10:30 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 31 Aug 2023 08:30:55 +0000 (10:30 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/hook_mount.c

index 0ebb8299853974acdbb4d28e5aced4339126481e..4b2a534f74e280e0dab27acf6cb80bab25634500 100644 (file)
@@ -299,12 +299,13 @@ static int hook_create_mount(struct libmnt_context *cxt,
                struct statx st;
 
                rc = statx(api->fd_tree, "", AT_EMPTY_PATH, STATX_MNT_ID, &st);
-               cxt->fs->id = (int) st.stx_mnt_id;
-
-               if (cxt->update) {
-                       struct libmnt_fs *fs = mnt_update_get_fs(cxt->update);
-                       if (fs)
-                               fs->id = cxt->fs->id;
+               if (rc == 0) {
+                       cxt->fs->id = (int) st.stx_mnt_id;
+                       if (cxt->update) {
+                               struct libmnt_fs *fs = mnt_update_get_fs(cxt->update);
+                               if (fs)
+                                       fs->id = cxt->fs->id;
+                       }
                }
        }
 #endif