summaryrefslogtreecommitdiffstats
path: root/sys/alpha
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2005-06-09 17:44:46 +0000
committerpjd <pjd@FreeBSD.org>2005-06-09 17:44:46 +0000
commit3af857a21ae29e6bd992143c332930401686617d (patch)
tree11a9edf30c5981a81932d35c358f4a0ab56990f8 /sys/alpha
parentcd5038ab36b62fd0d3378b0486ebd1c1a0b27b65 (diff)
downloadFreeBSD-src-3af857a21ae29e6bd992143c332930401686617d.zip
FreeBSD-src-3af857a21ae29e6bd992143c332930401686617d.tar.gz
Avoid code duplication in serval places by introducing universal
kern_getfsstat() function. Obtained from: jhb
Diffstat (limited to 'sys/alpha')
-rw-r--r--sys/alpha/osf1/osf1_mount.c70
1 files changed, 26 insertions, 44 deletions
diff --git a/sys/alpha/osf1/osf1_mount.c b/sys/alpha/osf1/osf1_mount.c
index 1d0ac2a..ca25854 100644
--- a/sys/alpha/osf1/osf1_mount.c
+++ b/sys/alpha/osf1/osf1_mount.c
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/proc.h>
-#include <sys/jail.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
@@ -156,56 +155,39 @@ osf1_getfsstat(td, uap)
struct thread *td;
register struct osf1_getfsstat_args *uap;
{
- long count, error, maxcount;
- caddr_t osf_sfsp;
- struct mount *mp, *nmp;
- struct statfs *sp, sb;
+ struct statfs *buf, *sp;
struct osf1_statfs osfs;
+ size_t count, size;
+ int error, flags;
if (uap->flags & ~OSF1_GETFSSTAT_FLAGS)
return (EINVAL);
-
- maxcount = uap->bufsize / sizeof(struct osf1_statfs);
- osf_sfsp = (caddr_t)uap->buf;
- for (count = 0, mp = TAILQ_FIRST(&mountlist); mp != NULL; mp = nmp) {
- nmp = TAILQ_NEXT(mp, mnt_list);
- if (osf_sfsp && count < maxcount) {
- if (!prison_check_mount(td->td_ucred, mp))
- continue;
-#ifdef MAC
- if (mac_check_mount_stat(td->td_ucred, mp) != 0)
- continue;
-#endif
- sp = &mp->mnt_stat;
- /*
- * If OSF1_MNT_NOWAIT is specified, do not refresh the
- * fsstat cache. OSF1_MNT_WAIT overrides
- * OSF1_MNT_NOWAIT.
- */
- if (((uap->flags & OSF1_MNT_NOWAIT) == 0 ||
- (uap->flags & OSF1_MNT_WAIT)) &&
- (error = VFS_STATFS(mp, sp, td)))
- continue;
- sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- if (suser(td)) {
- bcopy(sp, &sb, sizeof(sb));
- sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
- sp = &sb;
- }
+ flags = 0;
+ if (uap->flags & OSF1_MNT_WAIT)
+ flags |= MNT_WAIT;
+ if (uap->flags & OSF1_MNT_NOWAIT)
+ flags |= MNT_NOWAIT;
+
+ count = uap->bufsize / sizeof(struct ostatfs);
+ size = count * sizeof(struct statfs);
+ if (size > 0)
+ buf = malloc(size, M_TEMP, M_WAITOK);
+ else
+ buf = NULL;
+ error = kern_getfsstat(td, buf, size, UIO_SYSSPACE, flags);
+ if (buf != NULL) {
+ count = td->td_retval[0];
+ sp = buf;
+ while (count > 0 && error == 0) {
bsd2osf_statfs(sp, &osfs);
- if ((error = copyout(&osfs, osf_sfsp,
- sizeof (struct osf1_statfs))))
- return (error);
- osf_sfsp += sizeof (struct osf1_statfs);
+ error = copyout(&osfs, uap->buf, sizeof(osfs));
+ sp++;
+ uap->buf++;
+ count--;
}
- count++;
+ free(buf, M_TEMP);
}
- if (osf_sfsp && count > maxcount)
- td->td_retval[0] = maxcount;
- else
- td->td_retval[0] = count;
-
- return (0);
+ return (error);
}
int
OpenPOWER on IntegriCloud