linprocfs: Rework according to the new ABI altroot facility

By 3d2fec7d the ABI prefix path added to the struct pwd.
Use it in the mounts, mountinfo filler functions.

Differential revision:	https://reviews.freebsd.org/D39438
MFC after:		2 month
This commit is contained in:
Dmitry Chagin 2023-05-29 11:18:37 +03:00
parent d706d02edb
commit a482fffc7e

View File

@ -526,29 +526,26 @@ _sbuf_mntoptions_helper(struct sbuf *sb, uint64_t f_flags)
static int static int
linprocfs_domtab(PFS_FILL_ARGS) linprocfs_domtab(PFS_FILL_ARGS)
{ {
struct nameidata nd; const char *mntto, *mntfrom, *fstype;
const char *lep, *mntto, *mntfrom, *fstype;
char *dlep, *flep; char *dlep, *flep;
struct vnode *vp;
struct pwd *pwd;
size_t lep_len; size_t lep_len;
int error; int error;
struct statfs *buf, *sp; struct statfs *buf, *sp;
size_t count; size_t count;
/* resolve symlinks etc. in the emulation tree prefix */
/* /*
* Ideally, this would use the current chroot rather than some * Resolve emulation tree prefix
* hardcoded path.
*/ */
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path);
flep = NULL; flep = NULL;
error = namei(&nd); pwd = pwd_hold(td);
lep = linux_emul_path; vp = pwd->pwd_adir;
if (error == 0) { error = vn_fullpath_global(vp, &dlep, &flep);
if (vn_fullpath(nd.ni_vp, &dlep, &flep) == 0) pwd_drop(pwd);
lep = dlep; if (error != 0)
vrele(nd.ni_vp); return (error);
} lep_len = strlen(dlep);
lep_len = strlen(lep);
buf = NULL; buf = NULL;
error = kern_getfsstat(td, &buf, SIZE_T_MAX, &count, error = kern_getfsstat(td, &buf, SIZE_T_MAX, &count,
@ -567,7 +564,7 @@ linprocfs_domtab(PFS_FILL_ARGS)
} }
/* determine mount point */ /* determine mount point */
if (strncmp(mntto, lep, lep_len) == 0 && mntto[lep_len] == '/') if (strncmp(mntto, dlep, lep_len) == 0 && mntto[lep_len] == '/')
mntto += lep_len; mntto += lep_len;
sbuf_printf(sb, "%s %s %s ", mntfrom, mntto, fstype); sbuf_printf(sb, "%s %s %s ", mntfrom, mntto, fstype);
@ -584,28 +581,25 @@ linprocfs_domtab(PFS_FILL_ARGS)
static int static int
linprocfs_doprocmountinfo(PFS_FILL_ARGS) linprocfs_doprocmountinfo(PFS_FILL_ARGS)
{ {
struct nameidata nd;
const char *mntfrom, *mntto, *fstype; const char *mntfrom, *mntto, *fstype;
const char *lep;
char *dlep, *flep; char *dlep, *flep;
struct statfs *buf, *sp; struct statfs *buf, *sp;
size_t count, lep_len; size_t count, lep_len;
struct vnode *vp;
struct pwd *pwd;
int error; int error;
/* /*
* Ideally, this would use the current chroot rather than some * Resolve emulation tree prefix
* hardcoded path.
*/ */
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path);
flep = NULL; flep = NULL;
error = namei(&nd); pwd = pwd_hold(td);
lep = linux_emul_path; vp = pwd->pwd_adir;
if (error == 0) { error = vn_fullpath_global(vp, &dlep, &flep);
if (vn_fullpath(nd.ni_vp, &dlep, &flep) == 0) pwd_drop(pwd);
lep = dlep; if (error != 0)
vrele(nd.ni_vp); return (error);
} lep_len = strlen(dlep);
lep_len = strlen(lep);
buf = NULL; buf = NULL;
error = kern_getfsstat(td, &buf, SIZE_T_MAX, &count, error = kern_getfsstat(td, &buf, SIZE_T_MAX, &count,
@ -620,7 +614,7 @@ linprocfs_doprocmountinfo(PFS_FILL_ARGS)
continue; continue;
} }
if (strncmp(mntto, lep, lep_len) == 0 && mntto[lep_len] == '/') if (strncmp(mntto, dlep, lep_len) == 0 && mntto[lep_len] == '/')
mntto += lep_len; mntto += lep_len;
#if 0 #if 0
/* /*