libmount: add mnt_fs_is_regularfs() to public API

Fix: https://github.com/karelzak/util-linux/issues/1328
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2021-06-02 12:14:10 +02:00
parent 14ae6d5ae0
commit ac8697d606
6 changed files with 23 additions and 5 deletions

View File

@ -249,6 +249,7 @@ mnt_fs_get_vfs_options_all
mnt_fs_is_kernel
mnt_fs_is_netfs
mnt_fs_is_pseudofs
mnt_fs_is_regularfs
mnt_fs_is_swaparea
mnt_fs_match_fstype
mnt_fs_match_options

View File

@ -62,7 +62,7 @@ int mnt_context_is_loopdev(struct libmnt_context *cxt)
*/
type = mnt_fs_get_fstype(cxt->fs);
if (mnt_fs_is_regular(cxt->fs) &&
if (mnt_fs_is_regularfs(cxt->fs) &&
(!type || strcmp(type, "auto") == 0 || blkid_known_fstype(type))) {
struct stat st;

View File

@ -636,6 +636,21 @@ int mnt_fs_is_netfs(struct libmnt_fs *fs)
return mnt_fs_get_flags(fs) & MNT_FS_NET;
}
/**
* mnt_fs_is_regularfs:
* @fs: filesystem
*
* Returns: 1 if the filesystem is a regular filesystem (not network or pseudo filesystem).
*
* Since: 2.38
*/
int mnt_fs_is_regularfs(struct libmnt_fs *fs)
{
return !(mnt_fs_is_pseudofs(fs)
|| mnt_fs_is_netfs(fs)
|| mnt_fs_is_swaparea(fs));
}
/**
* mnt_fs_get_fstype:
* @fs: fstab/mtab/mountinfo entry pointer

View File

@ -515,6 +515,7 @@ extern int mnt_fs_is_kernel(struct libmnt_fs *fs);
extern int mnt_fs_is_swaparea(struct libmnt_fs *fs);
extern int mnt_fs_is_netfs(struct libmnt_fs *fs);
extern int mnt_fs_is_pseudofs(struct libmnt_fs *fs);
extern int mnt_fs_is_regularfs(struct libmnt_fs *fs);
extern void mnt_free_mntent(struct mntent *mnt);
extern int mnt_fs_to_mntent(struct libmnt_fs *fs, struct mntent **mnt);

View File

@ -361,3 +361,8 @@ MOUNT_2_37 {
mnt_fs_get_vfs_options_all;
mnt_table_over_fs;
} MOUNT_2_35;
MOUNT_2_38 {
mnt_fs_is_regularfs;
} MOUNT_2_37;

View File

@ -227,10 +227,6 @@ struct libmnt_fs {
#define MNT_FS_KERNEL (1 << 4) /* data from /proc/{mounts,self/mountinfo} */
#define MNT_FS_MERGED (1 << 5) /* already merged data from /run/mount/utab */
#define mnt_fs_is_regular(_f) (!(mnt_fs_is_pseudofs(_f) \
|| mnt_fs_is_netfs(_f) \
|| mnt_fs_is_swaparea(_f)))
/*
* mtab/fstab/mountinfo file
*/