Commit graph

37 commits

Author SHA1 Message Date
Wilbert Allen Koeswoyo Suwito 8b6876e136
chio(8): Fix typo in the copyright section
Event:		Advanced UNIX Programming Course (Fall’23) at NTHU.
Pull Request:	https://github.com/freebsd/freebsd-src/pull/978
2024-02-13 12:38:27 +08:00
Warner Losh 0b8224d1cc Remove copyright strings ifdef'd out
We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Alfonso Gregory e97468063d Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:17 -06:00
Warner Losh 3b899d5a8f chio: Mark some arguments as unused.
Sponsored by:		Netflix
2022-10-25 10:57:29 -06:00
Ed Maste 8550ddb2ea chio: avoid out of bounds read
ch_ces is alloacated with space for total_elem entries.

CID:		1418536
Reported by:	Coverity Scan
Sponsored by:	The FreeBSD Foundation
2020-07-26 15:10:33 +00:00
Kenneth D. Merry 21b6ee96fc Update chio(1) and ch(4) to support reporting element designators.
This allows mapping a tape drive in a changer (as reported by
'chio status') to a sa(4) driver instance by comparing the
serial numbers.

The designators can be ASCII (which is printed out directly), binary
(which is printed in hex format) or UTF-8, which is printed in either
native UTF-8 format if the terminal can support it, or in %XX notation
for non-ASCII characters.  Thanks to Hiroki Sato <hrs@> for the
explaining UTF-8 printing and example UTF-8 printing code.

chio.h:		Modify the changer_element_status structure to add new
		fields and definitions from the SMC3r16 spec.

		Rename the original CHIOGSTATUS ioctl to OCHIOGTATUS and
		define a new CHIOGSTATUS ioctl.

		Clean up some tab/space issues.

chio.c: 	For the 'status' subcommand, print the designator field
		if it is supplied by a device.

scsi_ch.h:	Add new flags for DVCID and CURDATA to the READ
		ELEMENT STATUS command structure.

		Add a read_element_status_device_id structure
		for the data fields in the new standard. Add new
		unions, dt_or_obsolete and voltage_devid, to hold
		and address data from either SCSI-2 or newer devices.

scsi_ch.c:	Implement support for fetching device IDs with READ
		ELEMENT STATUS data.

		Add new arguments to scsi_read_element_status() to
		allow the user to request the DVCID and CURDATA bits.
		This isn't compiled into libcam (it's only an internal
		kernel interface), so we don't need any special
		handling for the API change.

		If the user issues the new CHIOGSTATUS ioctl, copy all of
		the available element status data out.  If he issues the
		OCHIOGSTATUS ioctl, we don't copy the new fields in the
		structure.

		Fix a bug in chopen() that would result in the peripheral
		never getting unheld if chgetparams() failed.

Sponsored by:	Spectra Logic
Submitted by:	Po-Li Soong
MFC After:	1 week
2013-04-19 20:03:51 +00:00
Ed Schouten 469743871e Add static keywords to chio(1).
All other global variables are already marked static, so for consistency
sake, add them to these three arrays as well.
2011-12-11 20:53:12 +00:00
Ulrich Spörlein c5d27505b6 Zero struct before reading from it
PR:	   140384
Found by:  clang static analyzer
MFC after: 3 weeks
2010-06-02 09:34:41 +00:00
Joerg Wunsch 7f33c7dd6f When running a "chio return" operation using a physical source unit
rather than a voltag name, do not set the CESR_VOLTAGS flags in the
CHIOGSTATUS command requesting the current status.  As voltags are an
optional feature that must be handled as "reserved" by media changers
not implementing the feature, always setting CESR_VOLTAGS resulted in
the command being aborted with an `Invalid field in CDB', and
consequently the "chio return" failed, for media changers that do not
support voltags.

MFC after:	1 week
2008-10-30 19:51:02 +00:00
Warner Losh 9ddb49cbe4 /*- or .\"- or #- to begin license clauses. 2005-01-10 08:39:26 +00:00
David E. O'Brien 09a80d4867 Quiet warnings about copyright[]. 2003-05-01 16:58:57 +00:00
David Malone 0567678261 Remove double #include <sys/cdef.h> and __FBSDID.
PR:		40053
Submitted by:	Dan Lukes <dan@obluda.cz>
2002-07-01 10:46:39 +00:00
David E. O'Brien 5eb43ac2f7 Consistently use __FBSDID 2002-06-30 05:13:54 +00:00
Mark Murray 55fad6bb0f Replace use of __progname with the functionally identical and more
acceptable getprogname(3).
2002-03-24 14:56:55 +00:00
Warner Losh 250a0cef8f Use ANSI-99 int names (uintXX_t) over traditional BSD int names
(u_intXX_t).
2002-03-05 05:28:49 +00:00
Mark Murray ece5764570 Fix a boatload of warnings inspired by lint, a commercial lint
and WARNS=4.
2002-02-22 21:21:37 +00:00
Warner Losh 5dce647c1b Modernization effort for bin/c*:
o __P has been reoved
  o Old-style K&R declarations have been converted to new C89 style
  o register has been removed
  o prototype for main() has been removed (gcc3 makes it an error)
  o int main(int argc, char *argv[]) is the preferred main definition.
  o Attempt to not break style(9) conformance for declarations more than
    they already are.

  Approved by: arch@, new style(9)
2002-02-02 06:15:22 +00:00
Mike Heffner 616203938d Fix warnings on alpha and re-enable WARNS=2.
Submitted by:	Mike Barcroft <mike@q9media.com>
2001-07-04 21:35:15 +00:00
Mike Heffner 6c120f4628 Constify and lockdown with WARNS=2.
Submitted by:	Mike Barcroft <mike@q9media.com>
MFC after:	2 weeks
2001-07-03 03:22:49 +00:00
Kenneth D. Merry f944dc77e7 Add two new features to chio(1):
- The ability to specify elements by volume tag instead of their actual
   physical location.  e.g., instead of:
	chio move slot 3 slot 4
   you would now use:
	chio move voltag FOO slot 4

 - The ability to return an element to its previous location, as specified
   by the source element.  e.g., instead of:
	chio move drive 0 slot 4
   you would now use:
	chio return drive 0
   or
	chio return voltag FOO

These features will obviously only work with changers that support volume
tags and/or source element IDs.  chio(1) should fail gracefully if the user
attempts to use these new features and the source element ID or volume tag
are not found.

PR:		bin/21178
Submitted by:	"C. Stephen Gunn" <csg@waterspout.com>
Reviewed by:	ken
2000-09-18 06:09:11 +00:00
Warner Losh 2c15efcfb5 Don't explicitly declare optarg and optind. These are declared in
unistd.h, which is already included.
2000-08-16 05:14:49 +00:00
Peter Wemm 2a4562393f $Id$ -> $FreeBSD$ 1999-08-27 23:15:48 +00:00
Kris Kennaway 98ae496f7f Correct some style issues in my previous commit.
Submitted by:	bde
1999-07-22 14:26:21 +00:00
Kris Kennaway 794bf053c4 Undo some of the reversions from previous revisions, and attempt to
minimize diffs with {Net,Open}BSD

Hinted-More-Or-Less-By:	bde
1999-06-21 13:23:23 +00:00
Kris Kennaway 305a253acf Changes from OpenBSD:
* Better usage() - correct syntax, display available commands
	  instead of examples
	* Accept command abbreviations
	* sprintf -> snprintf (for paranoia)
	* manpage capitalisation tweak

Obtained from:	OpenBSD
1999-06-07 13:53:57 +00:00
Warner Losh b790f1b6de getopt(3) returns -1 not EOF. 1999-05-23 23:24:26 +00:00
Warner Losh 426e9c1dcc First set of fixes to keep egcs happy. These include {} around single
statement if blocks[*] when the else could be ambiguous, not defaulting
to int type and removal of some unused variables.

[*] This is explicitly allowed by style(9) when the single statement
spans more than one line.

Reviewed by: obrien, chuckr
1999-04-25 21:13:34 +00:00
Bruce Evans 9776f3dbad Fixed printf format errors (new bugs in rev.1.7). Fixed a spelling error
(rev.1.7 blew away most of rev.1.2-1.6; I'm only fixing blowing away of
rev.1.4).
1998-12-07 10:16:58 +00:00
Kenneth D. Merry c8c7ba2b9a Fix 'chio params' so that it actually prints out the current picker.
(This was broken when the volume tag changes went in.)

Submitted by:	Josef Karthauser <joe@pavilion.net>
1998-10-01 23:30:14 +00:00
Justin T. Gibbs 20bf9a142c Updated the ch(4) driver and chio(1) command to include volume
tag support.  These changes have been tested with a Breeze Hill
Q47 DLT and a DEC DLT2500 media changer.  The latter has no
volume tag support.

The chio(1) command was updated to include various flags to the
status subcommand.  These flags can be used to select additional
information to be displayed (like volume tags).

A new chio(1) subcommand named 'voltag' has been added which allows
for changes to volume tags inside the media changer controller.
This could not be tested as the Q47 does not provide the functio-
nality.

Submitted by:	Hans Huebner
1998-09-15 07:48:51 +00:00
Philippe Charnier 930ab418d3 Do not remove include of <sys/param.h> and <sys/types.h>. They should
be here before including almost any POSIX header.
Requested by:	Bruce
1998-05-13 07:19:45 +00:00
Philippe Charnier cbf6f7d358 Correct use of .Nm and other cosmetics. Add rcsid. Remove unused #inc. 1998-05-06 06:51:42 +00:00
Eivind Eklund 112e2ea9f2 spelling
Obtained from:  OpenBSD (src/bin/chio/chio.c rev 1.7) by todd@openbsd.org
1998-02-11 06:34:38 +00:00
Philippe Charnier 714ec423a0 Do not use __progname. 1997-06-06 06:32:09 +00:00
Philippe Charnier 73087c02bb Remove unused variables. Suppress -Wall warnings. Check for potential buffer
overflow. Display available command in usage string.
Obtained from: {Net|Open}BSD
1997-06-02 06:25:19 +00:00
Joerg Wunsch 224c8a5b9b Import Jason Thorpe's contribution for an updated SCSI media changer
device (now, finally!).
1997-03-06 15:30:06 +00:00