From: Karel Zak Date: Tue, 13 Jan 2026 17:36:39 +0000 (+0100) Subject: libmount: move fstype_to_mounttype() to include/ X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b7170f96c043628b8a73d2fd1e1da32b1f9eb07;p=thirdparty%2Futil-linux.git libmount: move fstype_to_mounttype() to include/ Make the workaround function globally available. Signed-off-by: Karel Zak --- diff --git a/include/mountutils.h b/include/mountutils.h index e77f20c2a..b2c4f7509 100644 --- a/include/mountutils.h +++ b/include/mountutils.h @@ -483,7 +483,31 @@ static inline int has_listmount(void) #endif #endif /* HAVE_STATMOUNT_API */ - #endif /* HAVE_LINUX_MOUNT_H */ +/* + * Default NTFS mount type (used by libmount and libblkid) + */ +#ifndef CONFIG_UL_NTFS_MOUNTTYPE +# define CONFIG_UL_NTFS_MOUNTTYPE "ntfs3" +#endif + +/* + * Convert FS-type (as provided by libblkid or udev) to the preferred + * kernel FS driver (type used to mount the FS). + * + * This is a temporary solution; the final solution should be based on config + * files like /etc/mount/fs.d/ (from lib/configs.c) and managed by + * libmount. + */ +static inline const char *ul_fstype_to_mounttype(const char *fstype) +{ + if (!fstype) + return NULL; + + if (strcmp(fstype, "ntfs") == 0) + return CONFIG_UL_NTFS_MOUNTTYPE; + + return NULL; +} #endif /* UTIL_LINUX_MOUNTUTILS_H */ diff --git a/libmount/src/context.c b/libmount/src/context.c index 9d6e0e59b..53464f19a 100644 --- a/libmount/src/context.c +++ b/libmount/src/context.c @@ -2090,7 +2090,7 @@ int mnt_context_guess_srcpath_fstype(struct libmnt_context *cxt, char **type) } if (rc == 0 && *type) { - const char *x = mnt_fstype_to_mounttype(*type); + const char *x = ul_fstype_to_mounttype(*type); if (x) { free(*type); diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c index 7a452ea0a..68b93ef06 100644 --- a/libmount/src/context_umount.c +++ b/libmount/src/context_umount.c @@ -298,7 +298,7 @@ static int lookup_umount_fs_by_statfs(struct libmnt_context *cxt, const char *tg close(fd); } if (type) { - const char *x = mnt_fstype_to_mounttype(type); + const char *x = ul_fstype_to_mounttype(type); int rc = mnt_fs_set_fstype(cxt->fs, x ? x : type); if (rc) diff --git a/libmount/src/mountP.h b/libmount/src/mountP.h index abe7c6fc6..7a6a4fbe2 100644 --- a/libmount/src/mountP.h +++ b/libmount/src/mountP.h @@ -109,7 +109,6 @@ struct libmnt_listmnt; extern int mnt_valid_tagname(const char *tagname); extern const char *mnt_statfs_get_fstype(struct statfs *vfs); -extern const char *mnt_fstype_to_mounttype(const char *fstype); extern int is_file_empty(const char *name); extern int mnt_is_readonly(const char *path) diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 863879718..3d220e9c5 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -542,31 +542,6 @@ const char *mnt_statfs_get_fstype(struct statfs *vfs) return NULL; } -/* - * Default NTFS mount type (used by libmount and libblkid) - */ -#ifndef CONFIG_UL_NTFS_MOUNTTYPE -# define CONFIG_UL_NTFS_MOUNTTYPE "ntfs3" -#endif - -/* - * Convert FS-type (as provided by libblkid or udev) to the preferred - * kernel FS driver (type used to mount the FS). - * - * This is a temporary solution; the final solution should be - * based on config files like /etc/mount/fs.d/ (from lib/configs.c). - */ -const char *mnt_fstype_to_mounttype(const char *fstype) -{ - if (!fstype) - return NULL; - - if (strcmp(fstype, "ntfs") == 0) - return CONFIG_UL_NTFS_MOUNTTYPE; - - return NULL; -} - /** * mnt_match_fstype: * @type: filesystem type