summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'sbin')
-rw-r--r--sbin/camcontrol/camcontrol.811
-rw-r--r--sbin/camcontrol/camcontrol.c72
-rw-r--r--sbin/camcontrol/camcontrol.h8
-rw-r--r--sbin/camcontrol/modeedit.c261
-rw-r--r--sbin/dhclient/dispatch.c8
-rw-r--r--sbin/fsck_ffs/suj.c54
-rw-r--r--sbin/ifconfig/ifieee80211.c2
-rw-r--r--sbin/pfctl/parse.y2
-rw-r--r--sbin/ping/ping.c7
9 files changed, 248 insertions, 177 deletions
diff --git a/sbin/camcontrol/camcontrol.8 b/sbin/camcontrol/camcontrol.8
index ee44d55..8697564 100644
--- a/sbin/camcontrol/camcontrol.8
+++ b/sbin/camcontrol/camcontrol.8
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 30, 2016
+.Dd January 6, 2017
.Dt CAMCONTROL 8
.Os
.Sh NAME
@@ -121,7 +121,7 @@
.Ic modepage
.Op device id
.Op generic args
-.Aq Fl m Ar page | Fl l
+.Aq Fl m Ar page[,subpage] | Fl l
.Op Fl P Ar pgctl
.Op Fl b | Fl e
.Op Fl d
@@ -702,9 +702,10 @@ The editor will be invoked if
detects that standard input is terminal.
.It Fl l
Lists all available mode pages.
-.It Fl m Ar mode_page
-This specifies the number of the mode page the user would like to view
-and/or edit.
+If specified more then once, also lists subpages.
+.It Fl m Ar page[,subpage]
+This specifies the number of the mode page and optionally subpage the user
+would like to view and/or edit.
This argument is mandatory unless
.Fl l
is specified.
diff --git a/sbin/camcontrol/camcontrol.c b/sbin/camcontrol/camcontrol.c
index 8fdb45c..dda58d2 100644
--- a/sbin/camcontrol/camcontrol.c
+++ b/sbin/camcontrol/camcontrol.c
@@ -125,12 +125,9 @@ typedef enum {
CAM_ARG_GET_STDINQ = 0x00002000,
CAM_ARG_GET_XFERRATE = 0x00004000,
CAM_ARG_INQ_MASK = 0x00007000,
- CAM_ARG_MODE_EDIT = 0x00008000,
- CAM_ARG_PAGE_CNTL = 0x00010000,
CAM_ARG_TIMEOUT = 0x00020000,
CAM_ARG_CMD_IN = 0x00040000,
CAM_ARG_CMD_OUT = 0x00080000,
- CAM_ARG_DBD = 0x00100000,
CAM_ARG_ERR_RECOVER = 0x00200000,
CAM_ARG_RETRIES = 0x00400000,
CAM_ARG_START_UNIT = 0x00800000,
@@ -3987,8 +3984,8 @@ reassignblocks(struct cam_device *device, u_int32_t *blocks, int num_blocks)
#ifndef MINIMALISTIC
void
-mode_sense(struct cam_device *device, int mode_page, int page_control,
- int dbd, int retry_count, int timeout, u_int8_t *data, int datalen)
+mode_sense(struct cam_device *device, int dbd, int pc, int page, int subpage,
+ int retry_count, int timeout, u_int8_t *data, int datalen)
{
union ccb *ccb;
int retval;
@@ -4000,15 +3997,17 @@ mode_sense(struct cam_device *device, int mode_page, int page_control,
CCB_CLEAR_ALL_EXCEPT_HDR(&ccb->csio);
- scsi_mode_sense(&ccb->csio,
+ scsi_mode_sense_subpage(&ccb->csio,
/* retries */ retry_count,
/* cbfcnp */ NULL,
/* tag_action */ MSG_SIMPLE_Q_TAG,
/* dbd */ dbd,
- /* page_code */ page_control << 6,
- /* page */ mode_page,
+ /* pc */ pc << 6,
+ /* page */ page,
+ /* subpage */ subpage,
/* param_buf */ data,
/* param_len */ datalen,
+ /* minimum_cmd_size */ 0,
/* sense_len */ SSD_FULL_SIZE,
/* timeout */ timeout ? timeout : 5000);
@@ -4089,8 +4088,9 @@ void
modepage(struct cam_device *device, int argc, char **argv, char *combinedopt,
int retry_count, int timeout)
{
- int c, mode_page = -1, page_control = 0;
- int binary = 0, list = 0;
+ char *str_subpage;
+ int c, page = -1, subpage = -1, pc = 0;
+ int binary = 0, dbd = 0, edit = 0, list = 0;
while ((c = getopt(argc, argv, combinedopt)) != -1) {
switch(c) {
@@ -4098,40 +4098,44 @@ modepage(struct cam_device *device, int argc, char **argv, char *combinedopt,
binary = 1;
break;
case 'd':
- arglist |= CAM_ARG_DBD;
+ dbd = 1;
break;
case 'e':
- arglist |= CAM_ARG_MODE_EDIT;
+ edit = 1;
break;
case 'l':
- list = 1;
+ list++;
break;
case 'm':
- mode_page = strtol(optarg, NULL, 0);
- if (mode_page < 0)
- errx(1, "invalid mode page %d", mode_page);
+ str_subpage = optarg;
+ strsep(&str_subpage, ",");
+ page = strtol(optarg, NULL, 0);
+ if (str_subpage)
+ subpage = strtol(str_subpage, NULL, 0);
+ else
+ subpage = 0;
+ if (page < 0)
+ errx(1, "invalid mode page %d", page);
+ if (subpage < 0)
+ errx(1, "invalid mode subpage %d", subpage);
break;
case 'P':
- page_control = strtol(optarg, NULL, 0);
- if ((page_control < 0) || (page_control > 3))
- errx(1, "invalid page control field %d",
- page_control);
- arglist |= CAM_ARG_PAGE_CNTL;
+ pc = strtol(optarg, NULL, 0);
+ if ((pc < 0) || (pc > 3))
+ errx(1, "invalid page control field %d", pc);
break;
default:
break;
}
}
- if (mode_page == -1 && list == 0)
+ if (page == -1 && list == 0)
errx(1, "you must specify a mode page!");
- if (list) {
- mode_list(device, page_control, arglist & CAM_ARG_DBD,
- retry_count, timeout);
+ if (list != 0) {
+ mode_list(device, dbd, pc, list > 1, retry_count, timeout);
} else {
- mode_edit(device, mode_page, page_control,
- arglist & CAM_ARG_DBD, arglist & CAM_ARG_MODE_EDIT, binary,
+ mode_edit(device, dbd, pc, page, subpage, edit, binary,
retry_count, timeout);
}
}
@@ -4146,7 +4150,7 @@ scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
u_int8_t cdb[20];
u_int8_t atacmd[12];
struct get_hook hook;
- int c, data_bytes = 0;
+ int c, data_bytes = 0, valid_bytes;
int cdb_len = 0;
int atacmd_len = 0;
int dmacmd = 0;
@@ -4450,16 +4454,20 @@ scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
}
}
+ if (cdb_len)
+ valid_bytes = ccb->csio.dxfer_len - ccb->csio.resid;
+ else
+ valid_bytes = ccb->ataio.dxfer_len - ccb->ataio.resid;
if (((ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP)
&& (arglist & CAM_ARG_CMD_IN)
- && (data_bytes > 0)) {
+ && (valid_bytes > 0)) {
if (fd_data == 0) {
- buff_decode_visit(data_ptr, data_bytes, datastr,
+ buff_decode_visit(data_ptr, valid_bytes, datastr,
arg_put, NULL);
fprintf(stdout, "\n");
} else {
ssize_t amt_written;
- int amt_to_write = data_bytes;
+ int amt_to_write = valid_bytes;
u_int8_t *buf_ptr = data_ptr;
for (amt_written = 0; (amt_to_write > 0) &&
@@ -4474,7 +4482,7 @@ scsicmd(struct cam_device *device, int argc, char **argv, char *combinedopt,
} else if ((amt_written == 0)
&& (amt_to_write > 0)) {
warnx("only wrote %u bytes out of %u",
- data_bytes - amt_to_write, data_bytes);
+ valid_bytes - amt_to_write, valid_bytes);
}
}
}
diff --git a/sbin/camcontrol/camcontrol.h b/sbin/camcontrol/camcontrol.h
index a9a661e..9ea1676 100644
--- a/sbin/camcontrol/camcontrol.h
+++ b/sbin/camcontrol/camcontrol.h
@@ -84,14 +84,14 @@ int epc(struct cam_device *device, int argc, char **argv, char *combinedopt,
int timestamp(struct cam_device *device, int argc, char **argv,
char *combinedopt, int retry_count, int timeout,
int verbosemode);
-void mode_sense(struct cam_device *device, int mode_page, int page_control,
- int dbd, int retry_count, int timeout, u_int8_t *data,
+void mode_sense(struct cam_device *device, int dbd, int pc, int page,
+ int subpage, int retry_count, int timeout, uint8_t *data,
int datalen);
void mode_select(struct cam_device *device, int save_pages, int retry_count,
int timeout, u_int8_t *data, int datalen);
-void mode_edit(struct cam_device *device, int page, int page_control, int dbd,
+void mode_edit(struct cam_device *device, int dbd, int pc, int page, int subpage,
int edit, int binary, int retry_count, int timeout);
-void mode_list(struct cam_device *device, int page_control, int dbd,
+void mode_list(struct cam_device *device, int dbd, int pc, int subpages,
int retry_count, int timeout);
int scsidoinquiry(struct cam_device *device, int argc, char **argv,
char *combinedopt, int retry_count, int timeout);
diff --git a/sbin/camcontrol/modeedit.c b/sbin/camcontrol/modeedit.c
index 8262c3c..90862db 100644
--- a/sbin/camcontrol/modeedit.c
+++ b/sbin/camcontrol/modeedit.c
@@ -66,9 +66,6 @@ __FBSDID("$FreeBSD$");
#define MODE_PAGE_HEADER(mh) \
(struct scsi_mode_page_header *)find_mode_page_6(mh)
-#define MODE_PAGE_DATA(mph) \
- (u_int8_t *)(mph) + sizeof(struct scsi_mode_page_header)
-
struct editentry {
STAILQ_ENTRY(editentry) link;
@@ -86,7 +83,8 @@ static int editlist_changed = 0; /* Whether any entries were changed. */
struct pagename {
SLIST_ENTRY(pagename) link;
- int pagenum;
+ int page;
+ int subpage;
char *name;
};
static SLIST_HEAD(, pagename) namelist; /* Page number to name mappings. */
@@ -106,21 +104,22 @@ static int editentry_save(void *hook, char *name);
static struct editentry *editentry_lookup(char *name);
static int editentry_set(char *name, char *newvalue,
int editonly);
-static void editlist_populate(struct cam_device *device,
- int modepage, int page_control,
- int dbd, int retries, int timeout);
-static void editlist_save(struct cam_device *device, int modepage,
- int page_control, int dbd, int retries,
- int timeout);
-static void nameentry_create(int pagenum, char *name);
-static struct pagename *nameentry_lookup(int pagenum);
-static int load_format(const char *pagedb_path, int page);
+static void editlist_populate(struct cam_device *device, int dbd,
+ int pc, int page, int subpage,
+ int retries, int timeout);
+static void editlist_save(struct cam_device *device, int dbd,
+ int pc, int page, int subpage,
+ int retries, int timeout);
+static void nameentry_create(int page, int subpage, char *name);
+static struct pagename *nameentry_lookup(int page, int subpage);
+static int load_format(const char *pagedb_path, int lpage,
+ int lsubpage);
static int modepage_write(FILE *file, int editonly);
static int modepage_read(FILE *file);
static void modepage_edit(void);
-static void modepage_dump(struct cam_device *device, int page,
- int page_control, int dbd, int retries,
- int timeout);
+static void modepage_dump(struct cam_device *device, int dbd,
+ int pc, int page, int subpage, int retries,
+ int timeout);
static void cleanup_editfile(void);
@@ -193,7 +192,14 @@ editentry_save(void *hook __unused, char *name)
struct editentry *src; /* Entry value to save. */
src = editentry_lookup(name);
- assert(src != NULL);
+ if (src == 0) {
+ /*
+ * This happens if field does not fit into read page size.
+ * It also means that this field won't be written, so the
+ * returned value does not really matter.
+ */
+ return (0);
+ }
switch (src->type) {
case 'i': /* Byte-sized integral type. */
@@ -318,10 +324,10 @@ editentry_set(char *name, char *newvalue, int editonly)
}
static void
-nameentry_create(int pagenum, char *name) {
+nameentry_create(int page, int subpage, char *name) {
struct pagename *newentry;
- if (pagenum < 0 || name == NULL || name[0] == '\0')
+ if (page < 0 || subpage < 0 || name == NULL || name[0] == '\0')
return;
/* Allocate memory for the new entry and a copy of the entry name. */
@@ -332,16 +338,17 @@ nameentry_create(int pagenum, char *name) {
/* Trim any trailing whitespace for the page name. */
RTRIM(newentry->name);
- newentry->pagenum = pagenum;
+ newentry->page = page;
+ newentry->subpage = subpage;
SLIST_INSERT_HEAD(&namelist, newentry, link);
}
static struct pagename *
-nameentry_lookup(int pagenum) {
+nameentry_lookup(int page, int subpage) {
struct pagename *scan;
SLIST_FOREACH(scan, &namelist, link) {
- if (pagenum == scan->pagenum)
+ if (page == scan->page && subpage == scan->subpage)
return (scan);
}
@@ -350,12 +357,14 @@ nameentry_lookup(int pagenum) {
}
static int
-load_format(const char *pagedb_path, int page)
+load_format(const char *pagedb_path, int lpage, int lsubpage)
{
FILE *pagedb;
- char str_pagenum[MAX_PAGENUM_LEN];
+ char str_page[MAX_PAGENUM_LEN];
+ char *str_subpage;
char str_pagename[MAX_PAGENAME_LEN];
- int pagenum;
+ int page;
+ int subpage;
int depth; /* Quoting depth. */
int found;
int lineno;
@@ -364,9 +373,10 @@ load_format(const char *pagedb_path, int page)
char c;
#define SETSTATE_LOCATE do { \
- str_pagenum[0] = '\0'; \
+ str_page[0] = '\0'; \
str_pagename[0] = '\0'; \
- pagenum = -1; \
+ page = -1; \
+ subpage = -1; \
state = LOCATE; \
} while (0)
@@ -443,32 +453,46 @@ load_format(const char *pagedb_path, int page)
* modes without providing a mode definition).
*/
/* Record the name of this page. */
- pagenum = strtol(str_pagenum, NULL, 0);
- nameentry_create(pagenum, str_pagename);
+ str_subpage = str_page;
+ strsep(&str_subpage, ",");
+ page = strtol(str_page, NULL, 0);
+ if (str_subpage)
+ subpage = strtol(str_subpage, NULL, 0);
+ else
+ subpage = 0;
+ nameentry_create(page, subpage, str_pagename);
SETSTATE_LOCATE;
} else if (depth == 0 && c == PAGENAME_START) {
SETSTATE_PAGENAME;
} else if (c == PAGEDEF_START) {
- pagenum = strtol(str_pagenum, NULL, 0);
+ str_subpage = str_page;
+ strsep(&str_subpage, ",");
+ page = strtol(str_page, NULL, 0);
+ if (str_subpage)
+ subpage = strtol(str_subpage, NULL, 0);
+ else
+ subpage = 0;
if (depth == 1) {
/* Record the name of this page. */
- nameentry_create(pagenum, str_pagename);
+ nameentry_create(page, subpage,
+ str_pagename);
/*
* Only record the format if this is
* the page we are interested in.
*/
- if (page == pagenum && !found)
+ if (lpage == page &&
+ lsubpage == subpage && !found)
SETSTATE_PAGEDEF;
}
} else if (c == PAGEDEF_END) {
/* Reset the processor state. */
SETSTATE_LOCATE;
- } else if (depth == 0 && ! BUFFERFULL(str_pagenum)) {
- strncat(str_pagenum, &c, 1);
+ } else if (depth == 0 && ! BUFFERFULL(str_page)) {
+ strncat(str_page, &c, 1);
} else if (depth == 0) {
errx(EX_OSFILE, "%s:%d: %s %zd %s", pagedb_path,
lineno, "page identifier exceeds",
- sizeof(str_pagenum) - 1, "characters");
+ sizeof(str_page) - 1, "characters");
}
break;
@@ -484,7 +508,7 @@ load_format(const char *pagedb_path, int page)
} else {
errx(EX_OSFILE, "%s:%d: %s %zd %s", pagedb_path,
lineno, "page name exceeds",
- sizeof(str_pagenum) - 1, "characters");
+ sizeof(str_page) - 1, "characters");
}
break;
@@ -525,88 +549,97 @@ load_format(const char *pagedb_path, int page)
}
static void
-editlist_populate(struct cam_device *device, int modepage, int page_control,
- int dbd, int retries, int timeout)
+editlist_populate(struct cam_device *device, int dbd, int pc, int page,
+ int subpage, int retries, int timeout)
{
u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
u_int8_t *mode_pars; /* Pointer to modepage params. */
struct scsi_mode_header_6 *mh; /* Location of mode header. */
struct scsi_mode_page_header *mph;
+ struct scsi_mode_page_header_sp *mphsp;
+ size_t len;
STAILQ_INIT(&editlist);
/* Fetch changeable values; use to build initial editlist. */
- mode_sense(device, modepage, 1, dbd, retries, timeout, data,
+ mode_sense(device, dbd, 1, page, subpage, retries, timeout, data,
sizeof(data));
mh = (struct scsi_mode_header_6 *)data;
mph = MODE_PAGE_HEADER(mh);
- mode_pars = MODE_PAGE_DATA(mph);
+ if ((mph->page_code & SMPH_SPF) == 0) {
+ mode_pars = (uint8_t *)(mph + 1);
+ len = mph->page_length;
+ } else {
+ mphsp = (struct scsi_mode_page_header_sp *)mph;
+ mode_pars = (uint8_t *)(mphsp + 1);
+ len = scsi_2btoul(mphsp->page_length);
+ }
+ len = MIN(len, sizeof(data) - (mode_pars - data));
/* Decode the value data, creating edit_entries for each value. */
- buff_decode_visit(mode_pars, mh->data_length, format,
- editentry_create, 0);
+ buff_decode_visit(mode_pars, len, format, editentry_create, 0);
/* Fetch the current/saved values; use to set editentry values. */
- mode_sense(device, modepage, page_control, dbd, retries, timeout, data,
- sizeof(data));
- buff_decode_visit(mode_pars, mh->data_length, format,
- editentry_update, 0);
+ mode_sense(device, dbd, pc, page, subpage, retries, timeout,
+ data, sizeof(data));
+ buff_decode_visit(mode_pars, len, format, editentry_update, 0);
}
static void
-editlist_save(struct cam_device *device, int modepage, int page_control,
- int dbd, int retries, int timeout)
+editlist_save(struct cam_device *device, int dbd, int pc, int page,
+ int subpage, int retries, int timeout)
{
u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
u_int8_t *mode_pars; /* Pointer to modepage params. */
struct scsi_mode_header_6 *mh; /* Location of mode header. */
struct scsi_mode_page_header *mph;
+ struct scsi_mode_page_header_sp *mphsp;
+ size_t len, hlen;
/* Make sure that something changed before continuing. */
if (! editlist_changed)
return;
- /*
- * Preload the CDB buffer with the current mode page data.
- * XXX If buff_encode_visit would return the number of bytes encoded
- * we *should* use that to build a header from scratch. As it is
- * now, we need mode_sense to find out the page length.
- */
- mode_sense(device, modepage, page_control, dbd, retries, timeout, data,
- sizeof(data));
+ /* Preload the CDB buffer with the current mode page data. */
+ mode_sense(device, dbd, pc, page, subpage, retries, timeout,
+ data, sizeof(data));
/* Initial headers & offsets. */
mh = (struct scsi_mode_header_6 *)data;
mph = MODE_PAGE_HEADER(mh);
- mode_pars = MODE_PAGE_DATA(mph);
+ if ((mph->page_code & SMPH_SPF) == 0) {
+ hlen = sizeof(*mph);
+ mode_pars = (uint8_t *)(mph + 1);
+ len = mph->page_length;
+ } else {
+ mphsp = (struct scsi_mode_page_header_sp *)mph;
+ hlen = sizeof(*mphsp);
+ mode_pars = (uint8_t *)(mphsp + 1);
+ len = scsi_2btoul(mphsp->page_length);
+ }
+ len = MIN(len, sizeof(data) - (mode_pars - data));
/* Encode the value data to be passed back to the device. */
- buff_encode_visit(mode_pars, mh->data_length, format,
- editentry_save, 0);
+ buff_encode_visit(mode_pars, len, format, editentry_save, 0);
/* Eliminate block descriptors. */
- bcopy(mph, ((u_int8_t *)mh) + sizeof(*mh),
- sizeof(*mph) + mph->page_length);
+ bcopy(mph, mh + 1, hlen + len);
/* Recalculate headers & offsets. */
- mh->blk_desc_len = 0; /* No block descriptors. */
+ mh->data_length = 0; /* Reserved for MODE SELECT command. */
mh->dev_spec = 0; /* Clear device-specific parameters. */
+ mh->blk_desc_len = 0; /* No block descriptors. */
mph = MODE_PAGE_HEADER(mh);
- mode_pars = MODE_PAGE_DATA(mph);
-
- mph->page_code &= SMS_PAGE_CODE;/* Isolate just the page code. */
- mh->data_length = 0; /* Reserved for MODE SELECT command. */
+ mph->page_code &= ~SMPH_PS; /* Reserved for MODE SELECT command. */
/*
* Write the changes back to the device. If the user editted control
* page 3 (saved values) then request the changes be permanently
* recorded.
*/
- mode_select(device,
- (page_control << PAGE_CTRL_SHIFT == SMS_PAGE_CTRL_SAVED),
- retries, timeout, (u_int8_t *)mh,
- sizeof(*mh) + mh->blk_desc_len + sizeof(*mph) + mph->page_length);
+ mode_select(device, (pc << PAGE_CTRL_SHIFT == SMS_PAGE_CTRL_SAVED),
+ retries, timeout, (u_int8_t *)mh, sizeof(*mh) + hlen + len);
}
static int
@@ -775,24 +808,33 @@ modepage_edit(void)
}
static void
-modepage_dump(struct cam_device *device, int page, int page_control, int dbd,
+modepage_dump(struct cam_device *device, int dbd, int pc, int page, int subpage,
int retries, int timeout)
{
u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
u_int8_t *mode_pars; /* Pointer to modepage params. */
struct scsi_mode_header_6 *mh; /* Location of mode header. */
struct scsi_mode_page_header *mph;
- int indx; /* Index for scanning mode params. */
+ struct scsi_mode_page_header_sp *mphsp;
+ size_t indx, len;
- mode_sense(device, page, page_control, dbd, retries, timeout, data,
- sizeof(data));
+ mode_sense(device, dbd, pc, page, subpage, retries, timeout,
+ data, sizeof(data));
mh = (struct scsi_mode_header_6 *)data;
mph = MODE_PAGE_HEADER(mh);
- mode_pars = MODE_PAGE_DATA(mph);
+ if ((mph->page_code & SMPH_SPF) == 0) {
+ mode_pars = (uint8_t *)(mph + 1);
+ len = mph->page_length;
+ } else {
+ mphsp = (struct scsi_mode_page_header_sp *)mph;
+ mode_pars = (uint8_t *)(mphsp + 1);
+ len = scsi_2btoul(mphsp->page_length);
+ }
+ len = MIN(len, sizeof(data) - (mode_pars - data));
/* Print the raw mode page data with newlines each 8 bytes. */
- for (indx = 0; indx < mph->page_length; indx++) {
+ for (indx = 0; indx < len; indx++) {
printf("%02x%c",mode_pars[indx],
(((indx + 1) % 8) == 0) ? '\n' : ' ');
}
@@ -810,7 +852,7 @@ cleanup_editfile(void)
}
void
-mode_edit(struct cam_device *device, int page, int page_control, int dbd,
+mode_edit(struct cam_device *device, int dbd, int pc, int page, int subpage,
int edit, int binary, int retry_count, int timeout)
{
const char *pagedb_path; /* Path to modepage database. */
@@ -822,15 +864,17 @@ mode_edit(struct cam_device *device, int page, int page_control, int dbd,
if ((pagedb_path = getenv("SCSI_MODES")) == NULL)
pagedb_path = DEFAULT_SCSI_MODE_DB;
- if (load_format(pagedb_path, page) != 0 && (edit || verbose)) {
+ if (load_format(pagedb_path, page, subpage) != 0 &&
+ (edit || verbose)) {
if (errno == ENOENT) {
/* Modepage database file not found. */
warn("cannot open modepage database \"%s\"",
pagedb_path);
} else if (errno == ESRCH) {
/* Modepage entry not found in database. */
- warnx("modepage %d not found in database"
- "\"%s\"", page, pagedb_path);
+ warnx("modepage 0x%02x,0x%02x not found in "
+ "database \"%s\"", page, subpage,
+ pagedb_path);
}
/* We can recover in display mode, otherwise we exit. */
if (!edit) {
@@ -840,22 +884,20 @@ mode_edit(struct cam_device *device, int page, int page_control, int dbd,
exit(EX_OSFILE);
}
- editlist_populate(device, page, page_control, dbd, retry_count,
+ editlist_populate(device, dbd, pc, page, subpage, retry_count,
timeout);
}
if (edit) {
- if (page_control << PAGE_CTRL_SHIFT != SMS_PAGE_CTRL_CURRENT &&
- page_control << PAGE_CTRL_SHIFT != SMS_PAGE_CTRL_SAVED)
+ if (pc << PAGE_CTRL_SHIFT != SMS_PAGE_CTRL_CURRENT &&
+ pc << PAGE_CTRL_SHIFT != SMS_PAGE_CTRL_SAVED)
errx(EX_USAGE, "it only makes sense to edit page 0 "
"(current) or page 3 (saved values)");
modepage_edit();
- editlist_save(device, page, page_control, dbd, retry_count,
- timeout);
+ editlist_save(device, dbd, pc, page, subpage, retry_count, timeout);
} else if (binary || STAILQ_EMPTY(&editlist)) {
/* Display without formatting information. */
- modepage_dump(device, page, page_control, dbd, retry_count,
- timeout);
+ modepage_dump(device, dbd, pc, page, subpage, retry_count, timeout);
} else {
/* Display with format. */
modepage_write(stdout, 0);
@@ -863,44 +905,55 @@ mode_edit(struct cam_device *device, int page, int page_control, int dbd,
}
void
-mode_list(struct cam_device *device, int page_control, int dbd,
+mode_list(struct cam_device *device, int dbd, int pc, int subpages,
int retry_count, int timeout)
{
u_int8_t data[MAX_COMMAND_SIZE];/* Buffer to hold sense data. */
struct scsi_mode_header_6 *mh; /* Location of mode header. */
struct scsi_mode_page_header *mph;
+ struct scsi_mode_page_header_sp *mphsp;
struct pagename *nameentry;
const char *pagedb_path;
- int len;
+ int len, page, subpage;
if ((pagedb_path = getenv("SCSI_MODES")) == NULL)
pagedb_path = DEFAULT_SCSI_MODE_DB;
- if (load_format(pagedb_path, 0) != 0 && verbose && errno == ENOENT) {
+ if (load_format(pagedb_path, 0, 0) != 0 && verbose && errno == ENOENT) {
/* Modepage database file not found. */
warn("cannot open modepage database \"%s\"", pagedb_path);
}
/* Build the list of all mode pages by querying the "all pages" page. */
- mode_sense(device, SMS_ALL_PAGES_PAGE, page_control, dbd, retry_count,
- timeout, data, sizeof(data));
+ mode_sense(device, dbd, pc, SMS_ALL_PAGES_PAGE,
+ subpages ? SMS_SUBPAGE_ALL : 0,
+ retry_count, timeout, data, sizeof(data));
mh = (struct scsi_mode_header_6 *)data;
len = sizeof(*mh) + mh->blk_desc_len; /* Skip block descriptors. */
/* Iterate through the pages in the reply. */
while (len < mh->data_length) {
/* Locate the next mode page header. */
- mph = (struct scsi_mode_page_header *)
- ((intptr_t)mh + len);
-
- mph->page_code &= SMS_PAGE_CODE;
- nameentry = nameentry_lookup(mph->page_code);
-
- if (nameentry == NULL || nameentry->name == NULL)
- printf("0x%02x\n", mph->page_code);
- else
- printf("0x%02x\t%s\n", mph->page_code,
- nameentry->name);
- len += mph->page_length + sizeof(*mph);
+ mph = (struct scsi_mode_page_header *)((intptr_t)mh + len);
+
+ if ((mph->page_code & SMPH_SPF) == 0) {
+ page = mph->page_code & SMS_PAGE_CODE;
+ subpage = 0;
+ len += sizeof(*mph) + mph->page_length;
+ } else {
+ mphsp = (struct scsi_mode_page_header_sp *)mph;
+ page = mphsp->page_code & SMS_PAGE_CODE;
+ subpage = mphsp->subpage;
+ len += sizeof(*mphsp) + scsi_2btoul(mphsp->page_length);
+ }
+
+ nameentry = nameentry_lookup(page, subpage);
+ if (subpage == 0) {
+ printf("0x%02x\t%s\n", page,
+ nameentry ? nameentry->name : "");
+ } else {
+ printf("0x%02x,0x%02x\t%s\n", page, subpage,
+ nameentry ? nameentry->name : "");
+ }
}
}
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 3317ceb..d493717 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -453,16 +453,12 @@ add_protocol(char *name, int fd, void (*handler)(struct protocol *),
void
remove_protocol(struct protocol *proto)
{
- struct protocol *p, *next, *prev;
+ struct protocol *p, *next;
- prev = NULL;
for (p = protocols; p; p = next) {
next = p->next;
if (p == proto) {
- if (prev)
- prev->next = p->next;
- else
- protocols = p->next;
+ protocols = p->next;
free(p);
}
}
diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c
index b265dfc..3ab14d1 100644
--- a/sbin/fsck_ffs/suj.c
+++ b/sbin/fsck_ffs/suj.c
@@ -1396,11 +1396,12 @@ ino_adjust(struct suj_ino *sino)
ip = ino_read(ino);
mode = DIP(ip, di_mode) & IFMT;
if (nlink > LINK_MAX)
- err_suj("ino %ju nlink manipulation error, new %d, old %d\n",
- (uintmax_t)ino, nlink, DIP(ip, di_nlink));
+ err_suj("ino %ju nlink manipulation error, new %ju, old %d\n",
+ (uintmax_t)ino, (uintmax_t)nlink, DIP(ip, di_nlink));
if (debug)
- printf("Adjusting ino %ju, nlink %d, old link %d lastmode %o\n",
- (uintmax_t)ino, nlink, DIP(ip, di_nlink), sino->si_mode);
+ printf("Adjusting ino %ju, nlink %ju, old link %d lastmode %o\n",
+ (uintmax_t)ino, (uintmax_t)nlink, DIP(ip, di_nlink),
+ sino->si_mode);
if (mode == 0) {
if (debug)
printf("ino %ju, zero inode freeing bitmap\n",
@@ -1419,8 +1420,9 @@ ino_adjust(struct suj_ino *sino)
/* If the inode doesn't have enough links to live, free it. */
if (nlink < reqlink) {
if (debug)
- printf("ino %ju not enough links to live %d < %d\n",
- (uintmax_t)ino, nlink, reqlink);
+ printf("ino %ju not enough links to live %ju < %ju\n",
+ (uintmax_t)ino, (uintmax_t)nlink,
+ (uintmax_t)reqlink);
ino_reclaim(ip, ino, mode);
return;
}
@@ -1657,10 +1659,12 @@ ino_check(struct suj_ino *sino)
err_suj("Inode mode/directory type mismatch %o != %o\n",
mode, rrec->jr_mode);
if (debug)
- printf("jrefrec: op %d ino %ju, nlink %d, parent %d, "
+ printf("jrefrec: op %d ino %ju, nlink %ju, parent %ju, "
"diroff %jd, mode %o, isat %d, isdot %d\n",
rrec->jr_op, (uintmax_t)rrec->jr_ino,
- rrec->jr_nlink, rrec->jr_parent, rrec->jr_diroff,
+ (uintmax_t)rrec->jr_nlink,
+ (uintmax_t)rrec->jr_parent,
+ (uintmax_t)rrec->jr_diroff,
rrec->jr_mode, isat, isdot);
mode = rrec->jr_mode & IFMT;
if (rrec->jr_op == JOP_REMREF)
@@ -1677,8 +1681,10 @@ ino_check(struct suj_ino *sino)
* by one.
*/
if (debug)
- printf("ino %ju nlink %d newlinks %d removes %d dotlinks %d\n",
- (uintmax_t)ino, nlink, newlinks, removes, dotlinks);
+ printf(
+ "ino %ju nlink %ju newlinks %ju removes %ju dotlinks %ju\n",
+ (uintmax_t)ino, (uintmax_t)nlink, (uintmax_t)newlinks,
+ (uintmax_t)removes, (uintmax_t)dotlinks);
nlink += newlinks;
nlink -= removes;
sino->si_linkadj = 1;
@@ -1962,15 +1968,17 @@ ino_append(union jrec *rec)
mvrec = &rec->rec_jmvrec;
refrec = &rec->rec_jrefrec;
if (debug && mvrec->jm_op == JOP_MVREF)
- printf("ino move: ino %d, parent %d, diroff %jd, oldoff %jd\n",
- mvrec->jm_ino, mvrec->jm_parent, mvrec->jm_newoff,
- mvrec->jm_oldoff);
+ printf("ino move: ino %ju, parent %ju, "
+ "diroff %jd, oldoff %jd\n",
+ (uintmax_t)mvrec->jm_ino, (uintmax_t)mvrec->jm_parent,
+ (uintmax_t)mvrec->jm_newoff, (uintmax_t)mvrec->jm_oldoff);
else if (debug &&
(refrec->jr_op == JOP_ADDREF || refrec->jr_op == JOP_REMREF))
- printf("ino ref: op %d, ino %d, nlink %d, "
- "parent %d, diroff %jd\n",
- refrec->jr_op, refrec->jr_ino, refrec->jr_nlink,
- refrec->jr_parent, refrec->jr_diroff);
+ printf("ino ref: op %d, ino %ju, nlink %ju, "
+ "parent %ju, diroff %jd\n",
+ refrec->jr_op, (uintmax_t)refrec->jr_ino,
+ (uintmax_t)refrec->jr_nlink,
+ (uintmax_t)refrec->jr_parent, (uintmax_t)refrec->jr_diroff);
sino = ino_lookup(((struct jrefrec *)rec)->jr_ino, 1);
sino->si_hasrecs = 1;
srec = errmalloc(sizeof(*srec));
@@ -2182,9 +2190,10 @@ blk_build(struct jblkrec *blkrec)
if (debug)
printf("blk_build: op %d blkno %jd frags %d oldfrags %d "
- "ino %d lbn %jd\n",
- blkrec->jb_op, blkrec->jb_blkno, blkrec->jb_frags,
- blkrec->jb_oldfrags, blkrec->jb_ino, blkrec->jb_lbn);
+ "ino %ju lbn %jd\n",
+ blkrec->jb_op, (uintmax_t)blkrec->jb_blkno,
+ blkrec->jb_frags, blkrec->jb_oldfrags,
+ (uintmax_t)blkrec->jb_ino, (uintmax_t)blkrec->jb_lbn);
blk = blknum(fs, blkrec->jb_blkno);
frag = fragnum(fs, blkrec->jb_blkno);
@@ -2232,8 +2241,9 @@ ino_build_trunc(struct jtrncrec *rec)
struct suj_ino *sino;
if (debug)
- printf("ino_build_trunc: op %d ino %d, size %jd\n",
- rec->jt_op, rec->jt_ino, rec->jt_size);
+ printf("ino_build_trunc: op %d ino %ju, size %jd\n",
+ rec->jt_op, (uintmax_t)rec->jt_ino,
+ (uintmax_t)rec->jt_size);
sino = ino_lookup(rec->jt_ino, 1);
if (rec->jt_op == JOP_SYNC) {
sino->si_trunc = NULL;
diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c
index 866f563..ddaf980 100644
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -5405,7 +5405,7 @@ static struct cmd ieee80211_cmds[] = {
DEF_CMD("stbctx", 1, set80211stbc),
DEF_CMD("-stbctx", -1, set80211stbc),
DEF_CMD("stbc", 3, set80211stbc), /* NB: tx+rx */
- DEF_CMD("-ampdu", -3, set80211stbc),
+ DEF_CMD("-stbc", -3, set80211stbc),
DEF_CMD("puren", 1, set80211puren),
DEF_CMD("-puren", 0, set80211puren),
DEF_CMD("doth", 1, set80211doth),
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index dcfddfc..c5b86cf 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -4319,7 +4319,7 @@ natrule : nataction interface af proto fromto tag tagged rtable
}
;
-binatrule : no BINAT natpasslog interface af proto FROM host toipspec tag
+binatrule : no BINAT natpasslog interface af proto FROM ipspec toipspec tag
tagged rtable redirection
{
struct pf_rule binat;
diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c
index db78ef6..ab4764a 100644
--- a/sbin/ping/ping.c
+++ b/sbin/ping/ping.c
@@ -1666,6 +1666,7 @@ pr_icmph(struct icmp *icp)
static void
pr_iph(struct ip *ip)
{
+ struct in_addr ina;
u_char *cp;
int hlen;
@@ -1681,8 +1682,10 @@ pr_iph(struct ip *ip)
(u_long) ntohl(ip->ip_off) & 0x1fff);
(void)printf(" %02x %02x %04x", ip->ip_ttl, ip->ip_p,
ntohs(ip->ip_sum));
- (void)printf(" %s ", inet_ntoa(*(struct in_addr *)&ip->ip_src.s_addr));
- (void)printf(" %s ", inet_ntoa(*(struct in_addr *)&ip->ip_dst.s_addr));
+ memcpy(&ina, &ip->ip_src.s_addr, sizeof ina);
+ (void)printf(" %s ", inet_ntoa(ina));
+ memcpy(&ina, &ip->ip_dst.s_addr, sizeof ina);
+ (void)printf(" %s ", inet_ntoa(ina));
/* dump any option bytes */
while (hlen-- > 20) {
(void)printf("%02x", *cp++);
OpenPOWER on IntegriCloud