From 245bfd34da590e12884bd1a5677f3227a36d4bcf Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Thu, 21 May 2020 01:55:35 +0000 Subject: Deduplicate fsid comparisons Comparing fsid_t objects requires internal knowledge of the fsid structure and yet this is duplicated across a number of places in the code. Simplify by creating a fsidcmp function (macro). Reviewed by: mjg, rmacklem Approved by: mav (mentor) MFC after: 1 week Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D24749 --- usr.sbin/mountd/mountd.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'usr.sbin/mountd/mountd.c') diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 79d6ac7f5693..36b3659ea487 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -1568,10 +1568,8 @@ get_exportlist_one(int passno) ep = get_exp(); } else { if (ep) { - if (ep->ex_fs.val[0] != - fsb.f_fsid.val[0] || - ep->ex_fs.val[1] != - fsb.f_fsid.val[1]) { + if (fsidcmp(&ep->ex_fs, &fsb.f_fsid) + != 0) { getexp_err(ep, tgrp, "fsid mismatch"); goto nextline; @@ -2088,8 +2086,7 @@ compare_nmount_exportlist(struct iovec *iov, int iovlen, char *errmsg) if ((oep->ex_flag & EX_DONE) == 0) { LOGDEBUG("not done delete=%s", oep->ex_fsdir); if (statfs(oep->ex_fsdir, &ofs) >= 0 && - oep->ex_fs.val[0] == ofs.f_fsid.val[0] && - oep->ex_fs.val[1] == ofs.f_fsid.val[1]) { + fsidcmp(&oep->ex_fs, &ofs.f_fsid) == 0) { LOGDEBUG("do delete"); /* * Clear has_publicfh if if was set @@ -2353,8 +2350,7 @@ ex_search(fsid_t *fsid, struct exportlisthead *exhp) i = EXPHASH(fsid); SLIST_FOREACH(ep, &exhp[i], entries) { - if (ep->ex_fs.val[0] == fsid->val[0] && - ep->ex_fs.val[1] == fsid->val[1]) + if (fsidcmp(&ep->ex_fs, fsid) == 0) return (ep); } @@ -3122,8 +3118,7 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags, * filesystem. */ if (statfs(dirp, &fsb1) != 0 || - bcmp(&fsb1.f_fsid, &fsb->f_fsid, - sizeof (fsb1.f_fsid)) != 0) { + fsidcmp(&fsb1.f_fsid, &fsb->f_fsid) != 0) { *cp = savedc; syslog(LOG_ERR, "can't export %s %s", dirp, -- cgit v1.2.3