From owner-svn-src-all@freebsd.org Thu Aug 8 03:16:33 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2EC51C1FB6; Thu, 8 Aug 2019 03:16:33 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 463tnY0PMLz3H2s; Thu, 8 Aug 2019 03:16:33 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E39FB1ECB0; Thu, 8 Aug 2019 03:16:32 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x783GWmT070042; Thu, 8 Aug 2019 03:16:32 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x783GW3r070041; Thu, 8 Aug 2019 03:16:32 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201908080316.x783GW3r070041@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Thu, 8 Aug 2019 03:16:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r350737 - head/usr.sbin/autofs X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/usr.sbin/autofs X-SVN-Commit-Revision: 350737 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Aug 2019 03:16:33 -0000 Author: jhibbits Date: Thu Aug 8 03:16:32 2019 New Revision: 350737 URL: https://svnweb.freebsd.org/changeset/base/350737 Log: Change autounmountd(8) to use time_t for duration instead of double Summary: autounmountd(8) uses doubles to handle mount time durations. However, it must convert to integer types, time_t in particular, to do anything meaningful. Additionally, even though it's a floating-point value in seconds, the sub-seconds component is never used, so it's unnecessary. Switching type to time_t fixes an assertion on powerpc64, which checks that a sleep value that's not -1.0 is greater than 0. On powerpc64, it happens that the value of -1.0 gets loaded as a float (perhaps a bug in gcc), but gets compared to a double. This compares as false, so follows through the 'sleep != -1.0' path, and fails the assert. Since the sub-second component isn't used in the double, just drop it and deal with whole-integer seconds. Reviewed by: trasz Differential Revision: https://reviews.freebsd.org/D21109 Modified: head/usr.sbin/autofs/autounmountd.c Modified: head/usr.sbin/autofs/autounmountd.c ============================================================================== --- head/usr.sbin/autofs/autounmountd.c Thu Aug 8 03:01:35 2019 (r350736) +++ head/usr.sbin/autofs/autounmountd.c Thu Aug 8 03:16:32 2019 (r350737) @@ -179,12 +179,12 @@ unmount_by_fsid(const fsid_t fsid, const char *mountpo return (error); } -static double -expire_automounted(double expiration_time) +static time_t +expire_automounted(time_t expiration_time) { struct automounted_fs *af, *tmpaf; time_t now; - double mounted_for, mounted_max = -1.0; + time_t mounted_for, mounted_max = -1; int error; now = time(NULL); @@ -196,9 +196,9 @@ expire_automounted(double expiration_time) if (mounted_for < expiration_time) { log_debugx("skipping %s (FSID:%d:%d), mounted " - "for %.0f seconds", af->af_mountpoint, + "for %ld seconds", af->af_mountpoint, af->af_fsid.val[0], af->af_fsid.val[1], - mounted_for); + (long)mounted_for); if (mounted_for > mounted_max) mounted_max = mounted_for; @@ -207,9 +207,9 @@ expire_automounted(double expiration_time) } log_debugx("filesystem mounted on %s (FSID:%d:%d), " - "was mounted for %.0f seconds; unmounting", + "was mounted for %ld seconds; unmounting", af->af_mountpoint, af->af_fsid.val[0], af->af_fsid.val[1], - mounted_for); + (long)mounted_for); error = unmount_by_fsid(af->af_fsid, af->af_mountpoint); if (error != 0) { if (mounted_for > mounted_max) @@ -229,18 +229,19 @@ usage_autounmountd(void) } static void -do_wait(int kq, double sleep_time) +do_wait(int kq, time_t sleep_time) { struct timespec timeout; struct kevent unused; int nevents; - if (sleep_time != -1.0) { - assert(sleep_time > 0.0); + if (sleep_time != -1) { + assert(sleep_time > 0); timeout.tv_sec = sleep_time; timeout.tv_nsec = 0; - log_debugx("waiting for filesystem event for %.0f seconds", sleep_time); + log_debugx("waiting for filesystem event for %ld seconds", + (long)sleep_time); nevents = kevent(kq, NULL, 0, &unused, 1, &timeout); } else { log_debugx("waiting for filesystem event"); @@ -254,7 +255,7 @@ do_wait(int kq, double sleep_time) if (nevents == 0) { log_debugx("timeout reached"); - assert(sleep_time > 0.0); + assert(sleep_time > 0); } else { log_debugx("got filesystem event"); } @@ -268,7 +269,7 @@ main_autounmountd(int argc, char **argv) pid_t otherpid; const char *pidfile_path = AUTOUNMOUNTD_PIDFILE; int ch, debug = 0, error, kq; - double expiration_time = 600, retry_time = 600, mounted_max, sleep_time; + time_t expiration_time = 600, retry_time = 600, mounted_max, sleep_time; bool dont_daemonize = false; while ((ch = getopt(argc, argv, "dr:t:v")) != -1) { @@ -336,17 +337,17 @@ main_autounmountd(int argc, char **argv) for (;;) { refresh_automounted(); mounted_max = expire_automounted(expiration_time); - if (mounted_max == -1.0) { + if (mounted_max == -1) { sleep_time = mounted_max; log_debugx("no filesystems to expire"); } else if (mounted_max < expiration_time) { sleep_time = difftime(expiration_time, mounted_max); - log_debugx("some filesystems expire in %.0f seconds", - sleep_time); + log_debugx("some filesystems expire in %ld seconds", + (long)sleep_time); } else { sleep_time = retry_time; log_debugx("some expired filesystems remain mounted, " - "will retry in %.0f seconds", sleep_time); + "will retry in %ld seconds", (long)sleep_time); } do_wait(kq, sleep_time);