mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-30 18:56:23 +03:00
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:
committed by
Brian Behlendorf
parent
f64f12079c
commit
a59e712d25
+1
-5
@@ -7694,15 +7694,11 @@ unshare_unmount_path(int op, char *path, int flags, boolean_t is_manual)
|
|||||||
zfs_handle_t *zhp;
|
zfs_handle_t *zhp;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct stat64 statbuf;
|
struct stat64 statbuf;
|
||||||
struct extmnttab entry;
|
struct mnttab entry;
|
||||||
const char *cmdname = (op == OP_SHARE) ? "unshare" : "unmount";
|
const char *cmdname = (op == OP_SHARE) ? "unshare" : "unmount";
|
||||||
ino_t path_inode;
|
ino_t path_inode;
|
||||||
char *zfs_mntpnt, *entry_mntpnt;
|
char *zfs_mntpnt, *entry_mntpnt;
|
||||||
|
|
||||||
/*
|
|
||||||
* Search for the given (major,minor) pair in the mount table.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (getextmntent(path, &entry, &statbuf) != 0) {
|
if (getextmntent(path, &entry, &statbuf) != 0) {
|
||||||
if (op == OP_SHARE) {
|
if (op == OP_SHARE) {
|
||||||
(void) fprintf(stderr, gettext("cannot %s '%s': not "
|
(void) fprintf(stderr, gettext("cannot %s '%s': not "
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ static int
|
|||||||
parse_pathname(const char *inpath, char *dataset, char *relpath,
|
parse_pathname(const char *inpath, char *dataset, char *relpath,
|
||||||
struct stat64 *statbuf)
|
struct stat64 *statbuf)
|
||||||
{
|
{
|
||||||
struct extmnttab mp;
|
struct mnttab mp;
|
||||||
const char *rel;
|
const char *rel;
|
||||||
char fullpath[MAXPATHLEN];
|
char fullpath[MAXPATHLEN];
|
||||||
|
|
||||||
|
|||||||
@@ -57,26 +57,11 @@ struct mnttab {
|
|||||||
char *mnt_mntopts;
|
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 stat64;
|
||||||
struct statfs;
|
struct statfs;
|
||||||
|
|
||||||
extern int _sol_getmntent(FILE *fp, struct mnttab *mp);
|
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);
|
struct stat64 *statbuf);
|
||||||
extern void statfs2mnttab(struct statfs *sfs, struct mnttab *mp);
|
extern void statfs2mnttab(struct statfs *sfs, struct mnttab *mp);
|
||||||
extern char *hasmntopt(struct mnttab *mnt, const char *opt);
|
extern char *hasmntopt(struct mnttab *mnt, const char *opt);
|
||||||
|
|||||||
@@ -54,25 +54,10 @@ struct mnttab {
|
|||||||
char *mnt_mntopts;
|
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;
|
struct statfs;
|
||||||
|
|
||||||
extern int _sol_getmntent(FILE *fp, struct mnttab *mp);
|
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);
|
struct stat64 *statbuf);
|
||||||
static inline char *_sol_hasmntopt(struct mnttab *mnt, const char *opt)
|
static inline char *_sol_hasmntopt(struct mnttab *mnt, const char *opt)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#include <libzutil.h>
|
#include <libzutil.h>
|
||||||
|
|
||||||
int
|
int
|
||||||
getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
|
getextmntent(const char *path, struct mnttab *entry, struct stat64 *statbuf)
|
||||||
{
|
{
|
||||||
struct statfs sfs;
|
struct statfs sfs;
|
||||||
|
|
||||||
@@ -60,6 +60,6 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
|
|||||||
zfs_strerror(errno));
|
zfs_strerror(errno));
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
statfs2mnttab(&sfs, (struct mnttab *)entry);
|
statfs2mnttab(&sfs, entry);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ _sol_getmntent(FILE *fp, struct mnttab *mgetp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
int ret;
|
||||||
struct stat64 st;
|
struct stat64 st;
|
||||||
@@ -84,19 +84,17 @@ getextmntent_impl(FILE *fp, struct extmnttab *mp, uint64_t *mnt_id)
|
|||||||
*mnt_id = stx.stx_mnt_id;
|
*mnt_id = stx.stx_mnt_id;
|
||||||
#endif
|
#endif
|
||||||
if (stat64(mp->mnt_mountp, &st) != 0) {
|
if (stat64(mp->mnt_mountp, &st) != 0) {
|
||||||
mp->mnt_major = 0;
|
*dev = 0;
|
||||||
mp->mnt_minor = 0;
|
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
mp->mnt_major = major(st.st_dev);
|
*dev = st.st_dev;
|
||||||
mp->mnt_minor = minor(st.st_dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
|
getextmntent(const char *path, struct mnttab *entry, struct stat64 *statbuf)
|
||||||
{
|
{
|
||||||
struct stat64 st;
|
struct stat64 st;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@@ -104,6 +102,7 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
|
|||||||
boolean_t have_mnt_id = B_FALSE;
|
boolean_t have_mnt_id = B_FALSE;
|
||||||
uint64_t target_mnt_id = 0;
|
uint64_t target_mnt_id = 0;
|
||||||
uint64_t entry_mnt_id;
|
uint64_t entry_mnt_id;
|
||||||
|
dev_t dev;
|
||||||
#ifdef HAVE_STATX_MNT_ID
|
#ifdef HAVE_STATX_MNT_ID
|
||||||
struct statx stx;
|
struct statx stx;
|
||||||
#endif
|
#endif
|
||||||
@@ -143,12 +142,11 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
match = 0;
|
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) {
|
if (have_mnt_id) {
|
||||||
match = (entry_mnt_id == target_mnt_id);
|
match = (entry_mnt_id == target_mnt_id);
|
||||||
} else {
|
} else {
|
||||||
match = makedev(entry->mnt_major, entry->mnt_minor) ==
|
match = (dev == statbuf->st_dev);
|
||||||
statbuf->st_dev;
|
|
||||||
}
|
}
|
||||||
if (match)
|
if (match)
|
||||||
break;
|
break;
|
||||||
@@ -161,11 +159,8 @@ getextmntent(const char *path, struct extmnttab *entry, struct stat64 *statbuf)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat64(entry->mnt_mountp, &st) != 0) {
|
if (stat64(entry->mnt_mountp, &st) != 0)
|
||||||
entry->mnt_major = 0;
|
|
||||||
entry->mnt_minor = 0;
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1171,7 +1171,7 @@ zfs_handle_t *
|
|||||||
zfs_path_to_zhandle(libzfs_handle_t *hdl, const char *path, zfs_type_t argtype)
|
zfs_path_to_zhandle(libzfs_handle_t *hdl, const char *path, zfs_type_t argtype)
|
||||||
{
|
{
|
||||||
struct stat64 statbuf;
|
struct stat64 statbuf;
|
||||||
struct extmnttab entry;
|
struct mnttab entry;
|
||||||
|
|
||||||
if (path[0] != '/' && strncmp(path, "./", strlen("./")) != 0) {
|
if (path[0] != '/' && strncmp(path, "./", strlen("./")) != 0) {
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user