History log of /freebsd-current/sbin/camcontrol/timestamp.c
Revision Date Author Comments
# 32e86a82 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sbin: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# df8aa95b 29-Jul-2019 Alexander Motin <mav@FreeBSD.org>

Use present now scsi_mode_sense_subpage().

MFC after: 2 weeks


# d618624c 01-May-2017 Kenneth D. Merry <ken@FreeBSD.org>

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
MFC after: 3 days
Sponsored by: Spectra Logic


# 492a2ef5 17-Feb-2017 Kenneth D. Merry <ken@FreeBSD.org>

Add task attribute support to camcontrol(8).

Users can use the new generic argument, -Q task_attr, to specify a task
attribute (simple, ordered, head of queue, aca) for the commands issued.
The the default is simple, which works with all SCSI devices that support
tagged queueing.

This will mostly be useful for debugging target behavior in certain
situations.

You can try it out by compiling CTL with CTL_IO_DELAY turned on (in
sys/cam/ctl/ctl_io.h) and then do something like this with one of the CTL
LUNs:

ctladm delay 0:0 -l done -t 10
camcontrol tur da34 -v

And at then before the 10 second timer is up, in another terminal:

camcontrol inquiry da34 -Q ordered -v

The Inquiry should complete just after the TUR completes. Ordinarily
it would complete first because of the delay injection, but because the
task attribute is set to ordered in this case, CTL holds it up until the
previous command has completed.

sbin/camcontrol/camcontrol.c:
Add the new generic argument, -Q, which allows the user to specify
a SCSI task attribute. The user can specify task attributes by
name or numerically.

Add a new task_attr arguments to SCSI sub-functions.

sbin/camcontrol/attrib.c,
sbin/camcontrol/camcontrol.h,
sbin/camcontrol/fwdownload.c,
sbin/camcontrol/modeedit.c,
sbin/camcontrol/persist.c,
sbin/camcontrol/timestamp.c,
sbin/camcontrol/zone.c:
Add the new task_attr argument to SCSI sub-functions.

sbin/camcontrol/camcontrol.8:
Document the new -Q option, and add an example.

Sponsored by: Spectra Logic
MFC after: 1 week


# 77d9b0ef 20-Jan-2017 Alan Somers <asomers@FreeBSD.org>

Misc Coverity fixes in camcontrol(8)

CID 1229913 Fix output of "camcontrol persist -i report_capabilities".
The reported Persistent Reservation Types were wrong in all
cases.
CID 1356029 Annotate the code so Coverity will know that this is a false
positive.
CID 1366830 Fix a memory leak in "camcontrol timestamp -s"
CID 1366832 Fix a segfault that could be caused by bad drive firmware

Also, fix the man page entry for the "camcontrol epc state" command to match
what the code does.

Reviewed by: ken, wblock
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D9239


# f2a12bce 10-Dec-2016 Enji Cooper <ngie@FreeBSD.org>

Cut to the chase and just call free instead of free(x) + x = NULL

NULLing out x wasn't required as the memory was immediately scribbled
over with strdup in the following call.

MFC after: 1 week
Submitted by: imp


# 110559ba 10-Dec-2016 Enji Cooper <ngie@FreeBSD.org>

free/NULL out variables prior to calling strdup to avoid leaking memory
if arguments are specified more than once with "camcontrol timestamp".

CID: 1366829, 1366831
MFC after: 1 week


# a1fa2391 03-Dec-2016 Adrian Chadd <adrian@FreeBSD.org>

[camcontrol] init ts=0 to quieten gcc.

It "looks" like ts is set to something on success, and not modified on
error.

Checked on IRC with: cem


# 28db0a5e 01-Dec-2016 Kenneth D. Merry <ken@FreeBSD.org>

Add SCSI REPORT TIMESTAMP and SET TIMESTAMP support.

This adds support to camcontrol(8) and libcam(3) for getting and setting
the time on SCSI protocol drives. This is more commonly found on tape
drives, but is a SPC (SCSI Primary Commands) command, and may be found
on any device that speaks SCSI.

The new camcontrol timestamp subcommand allows getting the current device
time or setting the time to the current system time or any arbitrary time.

sbin/camcontrol/Makefile:
Add timestamp.c.

sbin/camcontrol/camcontrol.8:
Document the new timestamp subcommand.

sbin/camcontrol/camcontrol.c:
Add the timestamp subcommand to camcontrol.

sbin/camcontrol/camcontrol.h:
Add the timestamp() function prototype.

sbin/camcontrol/timestamp.c:
Timestamp setting and reporting functionality.

sys/cam/scsi/scsi_all.c:
Add two new CCB building functions, scsi_set_timestamp() and
scsi_report_timestamp(). Also, add a new helper function,
scsi_create_timestamp().

sys/cam/scsi/scsi_all.h:
Add CDB and parameter data for the the set and report timestamp
commands.

Add function declarations for the new CCB building and helper
functions.

Submitted by: Sam Klopsch
Sponsored by: Spectra Logic
MFC After: 2 weeks