libspl/mnttab: remove struct extmnttab

The two additional fields are never used by calling code, and we can
replace their sole internal use with an extra stack param.

Sponsored-by: TrueNAS
Reviewed-by: Ameer Hamza <ahamza@ixsystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@truenas.com>
Closes #18296
This commit is contained in:
Rob Norris
2026-03-09 12:08:14 +11:00
committed by Brian Behlendorf
parent f64f12079c
commit a59e712d25
7 changed files with 15 additions and 54 deletions
+1 -16
View File
@@ -57,26 +57,11 @@ struct mnttab {
char *mnt_mntopts;
};
/*
* NOTE: fields in extmnttab should match struct mnttab till new fields
* are encountered, this allows hasmntopt to work properly when its arg is
* a pointer to an extmnttab struct cast to a mnttab struct pointer.
*/
struct extmnttab {
char *mnt_special;
char *mnt_mountp;
char *mnt_fstype;
char *mnt_mntopts;
uint_t mnt_major;
uint_t mnt_minor;
};
struct stat64;
struct statfs;
extern int _sol_getmntent(FILE *fp, struct mnttab *mp);
extern int getextmntent(const char *path, struct extmnttab *entry,
extern int getextmntent(const char *path, struct mnttab *entry,
struct stat64 *statbuf);
extern void statfs2mnttab(struct statfs *sfs, struct mnttab *mp);
extern char *hasmntopt(struct mnttab *mnt, const char *opt);
+1 -16
View File
@@ -54,25 +54,10 @@ struct mnttab {
char *mnt_mntopts;
};
/*
* NOTE: fields in extmnttab should match struct mnttab till new fields
* are encountered, this allows hasmntopt to work properly when its arg is
* a pointer to an extmnttab struct cast to a mnttab struct pointer.
*/
struct extmnttab {
char *mnt_special;
char *mnt_mountp;
char *mnt_fstype;
char *mnt_mntopts;
uint_t mnt_major;
uint_t mnt_minor;
};
struct statfs;
extern int _sol_getmntent(FILE *fp, struct mnttab *mp);
extern int getextmntent(const char *path, struct extmnttab *mp,
extern int getextmntent(const char *path, struct mnttab *mp,
struct stat64 *statbuf);
static inline char *_sol_hasmntopt(struct mnttab *mnt, const char *opt)
{
+2 -2
View File
@@ -40,7 +40,7 @@
#include <libzutil.h>
int
getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
getextmntent(const char *path, struct mnttab *entry, struct stat64 *statbuf)
{
struct statfs sfs;
@@ -60,6 +60,6 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
zfs_strerror(errno));
return (-1);
}
statfs2mnttab(&sfs, (struct mnttab *)entry);
statfs2mnttab(&sfs, entry);
return (0);
}
+8 -13
View File
@@ -68,7 +68,7 @@ _sol_getmntent(FILE *fp, struct mnttab *mgetp)
}
static int
getextmntent_impl(FILE *fp, struct extmnttab *mp, uint64_t *mnt_id)
getextmntent_impl(FILE *fp, struct mnttab *mp, uint64_t *mnt_id, dev_t *dev)
{
int ret;
struct stat64 st;
@@ -84,19 +84,17 @@ getextmntent_impl(FILE *fp, struct extmnttab *mp, uint64_t *mnt_id)
*mnt_id = stx.stx_mnt_id;
#endif
if (stat64(mp->mnt_mountp, &st) != 0) {
mp->mnt_major = 0;
mp->mnt_minor = 0;
*dev = 0;
return (ret);
}
mp->mnt_major = major(st.st_dev);
mp->mnt_minor = minor(st.st_dev);
*dev = st.st_dev;
}
return (ret);
}
int
getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
getextmntent(const char *path, struct mnttab *entry, struct stat64 *statbuf)
{
struct stat64 st;
FILE *fp;
@@ -104,6 +102,7 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
boolean_t have_mnt_id = B_FALSE;
uint64_t target_mnt_id = 0;
uint64_t entry_mnt_id;
dev_t dev;
#ifdef HAVE_STATX_MNT_ID
struct statx stx;
#endif
@@ -143,12 +142,11 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
*/
match = 0;
while (getextmntent_impl(fp, entry, &entry_mnt_id) == 0) {
while (getextmntent_impl(fp, entry, &entry_mnt_id, &dev) == 0) {
if (have_mnt_id) {
match = (entry_mnt_id == target_mnt_id);
} else {
match = makedev(entry->mnt_major, entry->mnt_minor) ==
statbuf->st_dev;
match = (dev == statbuf->st_dev);
}
if (match)
break;
@@ -161,11 +159,8 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
return (-1);
}
if (stat64(entry->mnt_mountp, &st) != 0) {
entry->mnt_major = 0;
entry->mnt_minor = 0;
if (stat64(entry->mnt_mountp, &st) != 0)
return (-1);
}
return (0);
}
+1 -1
View File
@@ -1171,7 +1171,7 @@ zfs_handle_t *
zfs_path_to_zhandle(libzfs_handle_t *hdl, const char *path, zfs_type_t argtype)
{
struct stat64 statbuf;
struct extmnttab entry;
struct mnttab entry;
if (path[0] != '/' && strncmp(path, "./", strlen("./")) != 0) {
/*