Index: sys/compat/linprocfs/linprocfs.c =================================================================== --- sys/compat/linprocfs/linprocfs.c +++ sys/compat/linprocfs/linprocfs.c @@ -53,10 +53,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include @@ -326,11 +327,12 @@ linprocfs_domtab(PFS_FILL_ARGS) { struct nameidata nd; - struct mount *mp; const char *lep; char *dlep, *flep, *mntto, *mntfrom, *fstype; size_t lep_len; int error; + struct statfs *buf, *sp; + size_t count, size = SIZE_T_MAX; /* resolve symlinks etc. in the emulation tree prefix */ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path, td); @@ -344,20 +346,24 @@ } lep_len = strlen(lep); - mtx_lock(&mountlist_mtx); - error = 0; - TAILQ_FOREACH(mp, &mountlist, mnt_list) { + error = kern_getfsstat(td, &buf, size, UIO_SYSSPACE, MNT_WAIT); + if (error != 0) { + free(buf, M_TEMP); + free(flep, M_TEMP); + return (error); + } + + for (sp = buf, count = td->td_retval[0]; count > 0; sp++, count--) { /* determine device name */ - mntfrom = mp->mnt_stat.f_mntfromname; + mntfrom = sp->f_mntfromname; /* determine mount point */ - mntto = mp->mnt_stat.f_mntonname; - if (strncmp(mntto, lep, lep_len) == 0 && - mntto[lep_len] == '/') + mntto = sp->f_mntonname; + if (strncmp(mntto, lep, lep_len) == 0 && mntto[lep_len] == '/') mntto += lep_len; /* determine fs type */ - fstype = mp->mnt_stat.f_fstypename; + fstype = sp->f_fstypename; if (strcmp(fstype, pn->pn_info->pi_name) == 0) mntfrom = fstype = "proc"; else if (strcmp(fstype, "procfs") == 0) @@ -365,16 +371,16 @@ if (strcmp(fstype, "linsysfs") == 0) { sbuf_printf(sb, "/sys %s sysfs %s", mntto, - mp->mnt_stat.f_flags & MNT_RDONLY ? "ro" : "rw"); + sp->f_flags & MNT_RDONLY ? "ro" : "rw"); } else { /* For Linux msdosfs is called vfat */ if (strcmp(fstype, "msdosfs") == 0) fstype = "vfat"; sbuf_printf(sb, "%s %s %s %s", mntfrom, mntto, fstype, - mp->mnt_stat.f_flags & MNT_RDONLY ? "ro" : "rw"); + sp->f_flags & MNT_RDONLY ? "ro" : "rw"); } #define ADD_OPTION(opt, name) \ - if (mp->mnt_stat.f_flags & (opt)) sbuf_printf(sb, "," name); + if (sp->f_flags & (opt)) sbuf_printf(sb, "," name); ADD_OPTION(MNT_SYNCHRONOUS, "sync"); ADD_OPTION(MNT_NOEXEC, "noexec"); ADD_OPTION(MNT_NOSUID, "nosuid"); @@ -387,7 +393,8 @@ /* a real Linux mtab will also show NFS options */ sbuf_printf(sb, " 0 0\n"); } - mtx_unlock(&mountlist_mtx); + + free(buf, M_TEMP); free(flep, M_TEMP); return (error); }