aboutsummaryrefslogtreecommitdiff
path: root/sbin/camcontrol/modeedit.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* camcontrol: Migrate to modern uintXX_t from u_intXX_tWarner Losh2023-07-251-7/+7
| | | | | | | | As per https://lists.freebsd.org/archives/freebsd-scsi/2023-July/000257.html move to the modern uintXX_t. MFC After: 3 days Sponsored by: Netflix
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* sbin/camcontrol: use calloc/strlcpy where appropriate.Xin LI2021-01-041-3/+2
| | | | MFC after: 2 weeks
* Make GCC happy about math in r350676.Alexander Motin2019-08-071-4/+1
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=350677
* Make `camcontrol modepage` support block descriptors.Alexander Motin2019-08-071-28/+234
| | | | | | | | | | | | | | | | | | | | It allows to read and write block descriptors alike to mode page parameters. It allows to change block size or short-stroke HDDs or overprovision SSDs. Depenting on -P parameter the change can be either persistent or till reset. In case of block size change device may need reformat after the setting. In case of SSD overprovisioning format or sanitize may be needed to really free the flash. During implementation appeared that csio_encode_visit() can not handle integers of more then 4 bytes, that makes 8-byte LBA handling awkward. I had to split it into two 4-byte halves now. MFC after: 1 week Relnotes: yes Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=350676
* Make `camcontrol modepage` to use 10 byte commands.Alexander Motin2019-07-301-89/+122
| | | | | | | | | | | | | | While old devices may not support 10 byte MODE SENSE/MODE SELECT commands, new ones may not be able to report all mode pages with 6 byte commands. This patch makes camcontrol by default start with 10 byte commands and fall back to 6 byte on ILLEGAL REQUEST error, or 6 byte can be forced. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Notes: svn path=/head/; revision=350457
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326276
* When editing a mode page on a tape drive, do not clear the deviceKenneth D. Merry2017-05-051-1/+14
| | | | | | | | | | | | | | | | | | | | | | | | | specific parameter. Tape drives include write protect (WP), Buffered Mode and Speed settings in the device-specific parameter. Clearing this parameter on a mode select can have the effect of turning off write protect or buffered mode, or changing the speed setting of the tape drive. Disks report DPO/FUA support via the device specific parameter for MODE SENSE, but the bit is reserved for MODE SELECT. So we clear this for disks (and other non-tape devices) to avoid potential errors from the target device. sbin/camcontrol/modeedit.c: Clear the device-specific parameter in the mode page header if we're not operating on a tape drive. MFC after: 3 days Sponsored by: Spectra Logic Notes: svn path=/head/; revision=317854
* Add task attribute support to camcontrol(8).Kenneth D. Merry2017-02-171-20/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=313893
* Add checks for received mode page length.Alexander Motin2017-01-101-3/+6
| | | | | | | | | | | | If our buffer is too small, we may receive part of the page, and should not try read/write past the end of the buffer. Reported by: Coverity CID: 1368374, 1368375 MFC after: 1 week Notes: svn path=/head/; revision=311897
* Make 'camcontrol modepage' support subpages.Alexander Motin2017-01-071-103/+146
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=311636
* Make do_buff_decode() not read past the end of the buffer.Alexander Motin2017-01-071-1/+8
| | | | | | | | | Abort format processing as soon as we have no enough data. MFC after: 2 weeks Notes: svn path=/head/; revision=311623
* Limit RESOLUTION_MAX to INT_MAX, not UINT_MAX (all spelled out) so theEnji Cooper2015-10-251-1/+1
| | | | | | | | | | | | | | | | | mode value isn't always clipped to -1 when (resolution * size) == 32, which would have been the case with values => {4i,32b,32t}. This seems to have been broken in r64382. MFC after: 1 week X-MFC with: r289915 PR: 200619 Reported by: Michael Baptist Submitted by: Lars Skodje Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=289916
* Fix mode page length calculation to remove last garbage line from theAlexander Motin2013-10-111-2/+2
| | | | | | | | | | | `camcontrol mode daX -l` output. PR Approved by: re (gjb) MFC after: 2 weeks Notes: svn path=/head/; revision=256317
* More -Wmissing-variable-declarations fixes.Ed Schouten2012-10-191-2/+0
| | | | | | | | | | | | | | | | | | | In addition to adding `static' where possible: - bin/date: Move `retval' into extern.h to make it visible to date.c. - bin/ed: Move globally used variables into ed.h. - sbin/camcontrol: Move `verbose' into camcontrol.h and fix shadow warnings. - usr.bin/calendar: Remove unneeded variables. - usr.bin/chat: Make `line' local instead of global. - usr.bin/elfdump: Comment out unneeded function. - usr.bin/rlogin: Use _Noreturn instead of __dead2. - usr.bin/tset: Pull `Ospeed' into extern.h. - usr.sbin/mfiutil: Put global variables in mfiutil.h. - usr.sbin/pkg: Remove unused `os_corres'. - usr.sbin/quotaon, usr.sbin/repquota: Remove unused `qfname'. Notes: svn path=/head/; revision=241737
* Fix warning when compiling with gcc46:Eitan Adler2012-01-101-2/+0
| | | | | | | | | | | | error: variable 'freq' set but not used error: variable 'mode_pars' set but not used Reviewed by: mav Approved by: dim MFC after: 3 days Notes: svn path=/head/; revision=229919
* Add missing static keywords to global variables in camcontrol.Ed Schouten2011-12-111-3/+3
| | | | | | | | While there, make the vendor list const and add appropriate keywords to functions that use this list. Notes: svn path=/head/; revision=228407
* Initialize variables before usage.Ulrich Spörlein2010-06-111-0/+1
| | | | | | | | Found by: clang static analyzer Found by: Coverity Prevent[tm] (CID 7736, 7760) Notes: svn path=/head/; revision=209051
* Userland signed char fixes for PPC build. Problems were using a charPeter Grehan2004-01-221-4/+6
| | | | | | | | | | | | return for getopt() and comparing to -1, ditto with fgetc() and EOF, and using the kg_nice value from <sys/user.h> Submitted by: Stefan Farfeleder <stefan@fafoe.narf.at> Reviewed by: obrien, bde (a while back) Tested lightly on: ppc, i386, make universe Notes: svn path=/head/; revision=124830
* Fix alignment of the trailing \Warner Losh2003-08-221-1/+1
| | | | Notes: svn path=/head/; revision=119252
* Make this WARNS=6 clean by:Johan Karlsson2003-08-051-24/+21
| | | | | | | | | | | | | | | | | | | | | | | 1: add 'const' to char * where needed; 2: mark unused variables with __unused; 3: remove double prototypes for mode_edit and mode_list. 4: moves the global variables 'bus', 'target', and 'lun' into the main function and protect them with #ifndef MINIMALISTIC, 5: renames 3 variable in order not to shadow other things index -> indx -- in modepage_dump since index is a function from <strings.h.> arglist -> arglst -- in the function parse_btl since arglist is also a global variable convertend -> convertend2 -- in the function editentry_set since that name is used two times within the function. 6: cast 0xffffffff in the macro RESOLUTION_MAX(size) to (int) since it is unsigned otherwise. Tested by: make universe Approved by: ken Notes: svn path=/head/; revision=118478
* Use __FBSDID.David E. O'Brien2003-05-021-4/+2
| | | | Notes: svn path=/head/; revision=114513
* Fixed (soon might be fatal) -Wformat warnings.Ruslan Ermilov2003-03-151-3/+3
| | | | Notes: svn path=/head/; revision=112254
* Make camcontrol WARNS=2 clean.Johan Karlsson2003-02-201-1/+1
| | | | | | | Approved by: ken Notes: svn path=/head/; revision=111195
* Fix syntax errors (labels with no statement).Garrett Wollman2002-05-301-4/+4
| | | | Notes: svn path=/head/; revision=97636
* Remove 'register' keyword.David E. O'Brien2002-03-201-1/+1
| | | | | | | | | It does not help modern compilers, and some may take some hit from it. (I also found several functions that listed *every* of its 10 local vars with "register" -- just how many free registers do people think machines have?) Notes: svn path=/head/; revision=92806
* Fix an order-of-operations bug and properly shift page_control values forKelly Yancey2000-08-101-6/+8
| | | | | | | comparison with SMS_PAGE_CTRL_* macros. Notes: svn path=/head/; revision=64474
* Fix a typo in the last commit so that this compiles.John Baldwin2000-08-091-1/+1
| | | | Notes: svn path=/head/; revision=64435
* Fix some whitespace errors.Kelly Yancey2000-08-081-12/+12
| | | | | | | Pointed out by: ps Notes: svn path=/head/; revision=64393
* This is an overhaul of the mode page handling in camcontrol as well asKelly Yancey2000-08-081-373/+780
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | related patches. These include: * Mode page editting can be scripted. This involves two things: first, if stdin is not a tty, changes are read from stdin rather than invoking $EDITOR. Second, and more importantly, not all modepage entries must be included in the change set. This means that camcontrol can now gracefully handle more intrusive editting from the $EDITOR, including removal or rearrangement of lines. It also means that you can do stuff like: # echo "WCE: 1" | camcontrol modepage da3 -m 8 -e # newfs /dev/da3 # echo "WCE: 0" | camcontrol modepage da3 -m 8 -e * Range-checking on user-supplied input values. modeedit.c now uses the field width specifiers to determine the maximum allowable value for a field. If the user enters a value larger than the maximum, it clips the value to the max and warns the user. This also involved patching cam_cmdparse.c to be more consistent with regards to the "count" parameter to arg_put (previously is was the length of strings and 1 for all integral types). The cam_cdbparse(3) man page was also updated to reflect the revised semantics. * In the process, I removed the 64 entry limit on mode pages (not that we were even close to hitting that limit). This was a nice side-effect of the other changes. * Technically, the new mode editting functionality allows editting of character array entries in mode pages (type 'c' or 'z'), however since buff_encode doesn't grok them it is currently useless. * Camcontrol gained two new options related to mode pages: -l and -b. The former lists all available mode pages for a given device. The latter forces mode page display in binary format (the default when no mode page definition was found in scsi_modes). * Added support for mode page names to scsi_modes. Allows names to be displayed alongside mode numbers in the mode page listing. Updated scsi_modes to use the new functionality. This also adds the semicolon into the scsi_modes syntax as an optional mode page definition terminator. This is needed to name pages without providing a page format definition. * Updated scsi_all.h to include a structure describing mode page headers. * Added $FreeBSD$ line to scsi_modes. Inspired by: dwhite Reviewed by: ken Notes: svn path=/head/; revision=64382
* Do some intptr_t casting for alpha.Matt Jacob2000-01-211-4/+4
| | | | | | | Reviewed by: ken@freebsd.org Notes: svn path=/head/; revision=56384
* Use mkstemp(3) instead of tmpnam(3) when creating temporary files for modeKenneth D. Merry1999-09-281-3/+6
| | | | | | | | | | page editing. Submitted by: roberto Reviewed by: imp, ken Notes: svn path=/head/; revision=51737
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50476
* Add a new device specification syntax to camcontrol. It is now possible toKenneth D. Merry1999-05-101-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | do things like: camcontrol tur da5 or camcontrol tur 1:2:0 or camcontrol tur 1:2 These changes are fully backwards compatible with the original device specification syntax (-n dev -u unit), so it is possible to use either method to specify a device now. The device specification changes do not affect the rescan, reset or debug commands, since by design, those commands work on a bus or bus:target:lun basis only. Also, shorten the default usage statement so that it fits in a 24 column terminal. The full usage statement is still available by using the "help" "-h" or "-?" arguments to camcontrol. Submitted by: Joerg Wunsch <joerg_wunsch@interface-business.de> Notes: svn path=/head/; revision=46938
* Camcontrol - A utility for configuring/manipulating the CAM subsystemJustin T. Gibbs1998-09-151-0/+500
Submitted by: "Kenneth D. Merry" <ken@plutotech.com> Notes: svn path=/head/; revision=39214