From owner-svn-src-stable@freebsd.org Thu May 4 14:20:53 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CD6A4D5D1B4; Thu, 4 May 2017 14:20:53 +0000 (UTC) (envelope-from ken@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 mx1.freebsd.org (Postfix) with ESMTPS id 8F1C91987; Thu, 4 May 2017 14:20:53 +0000 (UTC) (envelope-from ken@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v44EKqAX097331; Thu, 4 May 2017 14:20:52 GMT (envelope-from ken@FreeBSD.org) Received: (from ken@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v44EKqP9097329; Thu, 4 May 2017 14:20:52 GMT (envelope-from ken@FreeBSD.org) Message-Id: <201705041420.v44EKqP9097329@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ken set sender to ken@FreeBSD.org using -f From: "Kenneth D. Merry" Date: Thu, 4 May 2017 14:20:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r317792 - stable/11/sbin/camcontrol X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 May 2017 14:20:53 -0000 Author: ken Date: Thu May 4 14:20:52 2017 New Revision: 317792 URL: https://svnweb.freebsd.org/changeset/base/317792 Log: MFC r317657: Fix camcontrol timestamp setting and update the man page. camcontrol timestamp -s would somtimes fail due to stack garbage. Zero out the timestamp parameters to fix it. Fix another nearby bug, and update the man page. sbin/camcontrol/timestamp.c: In set_timestamp(), bzero ts_p prior to creating the timestamp. Previously stack garbage could cause some tape drives to reject the timestamp. In set_timestamp(), check for failures from strptime(). sbin/camcontrol/camcontrol.8: Add the time argument to the -T option to camcontrol timestamp -s in the long description. Change the time/date format used in the camcontrol timestamp example to RFC 2822 format. This fixes a time zone issue with the original example by specifying the time zone as -0600. Otherwise, the time zone seems to default to standard time in the current locale, which makes the time, when reported back from the drive, 1 hour off from the intended setting. This also fixes a duplicate day of the week ("Wednesday Wed") in the previous example. Submitted by: Sam Klopsch Sponsored by: Spectra Logic Modified: stable/11/sbin/camcontrol/camcontrol.8 stable/11/sbin/camcontrol/timestamp.c Modified: stable/11/sbin/camcontrol/camcontrol.8 ============================================================================== --- stable/11/sbin/camcontrol/camcontrol.8 Thu May 4 12:18:58 2017 (r317791) +++ stable/11/sbin/camcontrol/camcontrol.8 Thu May 4 14:20:52 2017 (r317792) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 17, 2017 +.Dd May 1, 2017 .Dt CAMCONTROL 8 .Os .Sh NAME @@ -2488,7 +2488,7 @@ Specify the strptime format string, as d The time must also be specified with the .Fl T option. -.It Fl T +.It Fl T Ar time Provide the time in the format specified with the .Fl f option. @@ -2814,8 +2814,8 @@ drive .Pa ada0 . .Pp .Bd -literal -offset indent -camcontrol timestamp sa0 -s -f "%A %c" \e - -T "Wednesday Wed Oct 26 21:43:57 2016" +camcontrol timestamp sa0 -s -f "%a, %d %b %Y %T %z" \e + -T "Wed, 26 Oct 2016 21:43:57 -0600" .Ed .Pp Set the timestamp of drive Modified: stable/11/sbin/camcontrol/timestamp.c ============================================================================== --- stable/11/sbin/camcontrol/timestamp.c Thu May 4 12:18:58 2017 (r317791) +++ stable/11/sbin/camcontrol/timestamp.c Thu May 4 14:20:52 2017 (r317792) @@ -282,12 +282,18 @@ set_timestamp(struct cam_device *device, ts = (uint64_t) time_value; } else { bzero(&time_struct, sizeof(struct tm)); - strptime(timestamp_string, format_string, &time_struct); + if (strptime(timestamp_string, format_string, + &time_struct) == NULL) { + warnx("%s: strptime(3) failed", __func__); + error = 1; + goto bailout; + } time_value = mktime(&time_struct); ts = (uint64_t) time_value; } /* Convert time from seconds to milliseconds */ ts *= 1000; + bzero(&ts_p, sizeof(ts_p)); scsi_create_timestamp(ts_p.timestamp, ts); scsi_set_timestamp(&ccb->csio,