mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-01 12:19:28 +00:00
Eliminate the default device name (da) and unit number (0) in camcontrol.
This may break some scripts, but with the number of ways users can damage a system with this tool, it's important to make sure they specify which device they want to talk to. Suggested by: joerg
This commit is contained in:
parent
0e61e4dd08
commit
b3550398d3
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=61233
@ -202,13 +202,12 @@ the code will generally attempt to spin up drives that are not spinning.
|
||||
It may take some other actions, depending upon the sense code returned from
|
||||
the command.
|
||||
.It Fl n Ar dev_name
|
||||
Specify the device type to operate on. The default is
|
||||
.Em da .
|
||||
Specify the device type to operate on, e.g. "da", "cd".
|
||||
.It Fl t Ar timeout
|
||||
SCSI command timeout in seconds. This overrides the default timeout for
|
||||
any given command.
|
||||
.It Fl u Ar unit_number
|
||||
Specify the device unit number. The default is 0.
|
||||
Specify the device unit number, e.g. "1", "5".
|
||||
.It Fl v
|
||||
Be verbose, print out sense information for failed SCSI commands.
|
||||
.El
|
||||
@ -616,7 +615,7 @@ are the CAM application passthrough devices.
|
||||
Eject the CD from cd1, and print SCSI sense information if the command
|
||||
fails.
|
||||
.Pp
|
||||
.Dl camcontrol tur
|
||||
.Dl camcontrol tur da0
|
||||
.Pp
|
||||
Send the SCSI test unit ready command to da0.
|
||||
.Nm camcontrol
|
||||
|
@ -48,9 +48,6 @@
|
||||
#include <camlib.h>
|
||||
#include "camcontrol.h"
|
||||
|
||||
#define DEFAULT_DEVICE "da"
|
||||
#define DEFAULT_UNIT 0
|
||||
|
||||
typedef enum {
|
||||
CAM_ARG_NONE = 0x00000000,
|
||||
CAM_ARG_DEVLIST = 0x00000001,
|
||||
@ -1068,6 +1065,8 @@ scanlun_or_reset_dev(int bus, int target, int lun, int scan)
|
||||
struct cam_device *device;
|
||||
int fd;
|
||||
|
||||
device = NULL;
|
||||
|
||||
if (bus < 0) {
|
||||
warnx("invalid bus number %d", bus);
|
||||
return(1);
|
||||
@ -3015,8 +3014,8 @@ usage(int verbose)
|
||||
"Generic arguments:\n"
|
||||
"-v be verbose, print out sense information\n"
|
||||
"-t timeout command timeout in seconds, overrides default timeout\n"
|
||||
"-n dev_name specify device name (default is %s)\n"
|
||||
"-u unit specify unit number (default is %d)\n"
|
||||
"-n dev_name specify device name, e.g. \"da\", \"cd\"\n"
|
||||
"-u unit specify unit number, e.g. \"0\", \"5\"\n"
|
||||
"-E have the kernel attempt to perform SCSI error recovery\n"
|
||||
"-C count specify the SCSI command retry count (needs -E to work)\n"
|
||||
"modepage arguments:\n"
|
||||
@ -3059,8 +3058,7 @@ usage(int verbose)
|
||||
"format arguments:\n"
|
||||
"-q be quiet, don't print status messages\n"
|
||||
"-w don't send immediate format command\n"
|
||||
"-y don't ask any questions\n",
|
||||
DEFAULT_DEVICE, DEFAULT_UNIT);
|
||||
"-y don't ask any questions\n");
|
||||
}
|
||||
|
||||
int
|
||||
@ -3245,12 +3243,6 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if ((arglist & CAM_ARG_DEVICE) == 0)
|
||||
device = (char *)strdup(DEFAULT_DEVICE);
|
||||
|
||||
if ((arglist & CAM_ARG_UNIT) == 0)
|
||||
unit = DEFAULT_UNIT;
|
||||
|
||||
/*
|
||||
* For most commands we'll want to open the passthrough device
|
||||
* associated with the specified device. In the case of the rescan
|
||||
@ -3258,6 +3250,13 @@ main(int argc, char **argv)
|
||||
* transport layer device.
|
||||
*/
|
||||
if (devopen == 1) {
|
||||
if (((arglist & (CAM_ARG_BUS|CAM_ARG_TARGET)) == 0)
|
||||
&& (((arglist & CAM_ARG_DEVICE) == 0)
|
||||
|| ((arglist & CAM_ARG_UNIT) == 0))) {
|
||||
errx(1, "subcommand \"%s\" requires a valid device "
|
||||
"identifier", argv[1]);
|
||||
}
|
||||
|
||||
if ((cam_dev = ((arglist & (CAM_ARG_BUS | CAM_ARG_TARGET))?
|
||||
cam_open_btl(bus, target, lun, O_RDWR, NULL) :
|
||||
cam_open_spec_device(device,unit,O_RDWR,NULL)))
|
||||
|
Loading…
Reference in New Issue
Block a user