MFC @247774

This commit is contained in:
Martin Matuska 2013-03-04 09:35:50 +00:00
commit 23c07ad60d
39 changed files with 511 additions and 229 deletions

View File

@ -124,3 +124,6 @@ isci(4) jimharris Pre-commit review requested.
cmx daniel@roe.ch Pre-commit review preferred.
filemon obrien Pre-commit review preferred.
sysdoc trhodes Pre-commit review preferred.
sh(1) jilles Pre-commit review requested. This also applies
to kill(1), printf(1) and test(1) which are
compiled in as builtins.

View File

@ -39,6 +39,8 @@
# done
# 20130302: NTFS support removed
OLD_FILES+=rescue/mount_ntfs
OLD_FILES+=sbin/mount_ntfs
OLD_FILES+=usr/include/fs/ntfs/ntfs.h
OLD_FILES+=usr/include/fs/ntfs/ntfs_compr.h
OLD_FILES+=usr/include/fs/ntfs/ntfs_ihash.h
@ -51,6 +53,7 @@ OLD_FILES+=usr/share/man/man8/mount_ntfs.8.gz
# 20130302: PORTALFS support removed
OLD_FILES+=usr/include/fs/portalfs/portal.h
OLD_DIRS+=usr/include/fs/portalfs
OLD_FILES+=usr/sbin/mount_portalfs
OLD_FILES+=usr/share/examples/portal/README
OLD_FILES+=usr/share/examples/portal/portal.conf
OLD_DIRS+=usr/share/examples/portal
@ -79,9 +82,10 @@ OLD_DIRS+=var/remote
# 20121114: zpool-features manual page moved from section 5 to 7
OLD_FILES+=usr/share/man/man5/zpool-features.5.gz
# 20121022: remove harp, hfa and idt man page
OLD_FILES+=share/man/man4/harp.4
OLD_FILES+=share/man/man4/hfa.4
OLD_FILES+=share/man/man4/idt.4
OLD_FILES+=usr/share/man/man4/harp.4.gz
OLD_FILES+=usr/share/man/man4/hfa.4.gz
OLD_FILES+=usr/share/man/man4/idt.4.gz
OLD_FILES+=usr/share/man/man4/if_idt.4.gz
# 20121022: VFS_LOCK_GIANT elimination
OLD_FILES+=usr/share/man/man9/VFS_LOCK_GIANT.9.gz
OLD_FILES+=usr/share/man/man9/VFS_UNLOCK_GIANT.9.gz

View File

@ -455,7 +455,6 @@ dotrap(void)
last_trapsig = i;
savestatus = exitstatus;
evalstring(trap[i], 0);
exitstatus = savestatus;
/*
* If such a command was not
@ -464,9 +463,11 @@ dotrap(void)
* trap action to have an effect
* outside of it.
*/
if (prev_evalskip != 0) {
if (evalskip == 0 ||
prev_evalskip != 0) {
evalskip = prev_evalskip;
skipcount = prev_skipcount;
exitstatus = savestatus;
}
if (i == SIGCHLD)

View File

@ -11,6 +11,7 @@ OSRCS= chared.c common.c el.c emacs.c fcns.c filecomplete.c help.c \
parse.c prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c
DPADD= ${LIBNCURSES}
LDADD= -lncurses
MAN= editline.3 editrc.5

View File

@ -116,7 +116,7 @@ static struct pidfh *pfh;
int Dflag;
int dflag;
int nflag;
int romeo_must_die = 0;
static volatile sig_atomic_t romeo_must_die = 0;
static const char *configfile = CF;
@ -319,7 +319,7 @@ media::do_match(config &c)
// the name of interest, first try device-name and fall back
// to subsystem if none exists.
value = c.get_variable("device-name");
if (value.length() == 0)
if (value.empty())
value = c.get_variable("subsystem");
if (Dflag)
fprintf(stderr, "Testing media type of %s against 0x%x\n",
@ -460,7 +460,7 @@ config::open_pidfile()
{
pid_t otherpid;
if (_pidfile == "")
if (_pidfile.empty())
return;
pfh = pidfile_open(_pidfile.c_str(), 0600, &otherpid);
if (pfh == NULL) {
@ -528,7 +528,7 @@ config::add_notify(int prio, event_proc *p)
void
config::set_pidfile(const char *fn)
{
_pidfile = string(fn);
_pidfile = fn;
}
void
@ -585,7 +585,7 @@ config::expand_one(const char *&src, string &dst)
src++;
// $$ -> $
if (*src == '$') {
dst.append(src++, 1);
dst += *src++;
return;
}
@ -593,7 +593,7 @@ config::expand_one(const char *&src, string &dst)
// Not sure if I want to support this or not, so for now we just pass
// it through.
if (*src == '(') {
dst.append("$");
dst += '$';
count = 1;
/* If the string ends before ) is matched , return. */
while (count > 0 && *src) {
@ -601,23 +601,23 @@ config::expand_one(const char *&src, string &dst)
count--;
else if (*src == '(')
count++;
dst.append(src++, 1);
dst += *src++;
}
return;
}
// ${^A-Za-z] -> $\1
// $[^A-Za-z] -> $\1
if (!isalpha(*src)) {
dst.append("$");
dst.append(src++, 1);
dst += '$';
dst += *src++;
return;
}
// $var -> replace with value
do {
buffer.append(src++, 1);
buffer += *src++;
} while (is_id_char(*src));
dst.append(get_variable(buffer.c_str()));
dst.append(get_variable(buffer));
}
const string
@ -653,7 +653,7 @@ config::expand_string(const char *src, const char *prepend, const char *append)
}
bool
config::chop_var(char *&buffer, char *&lhs, char *&rhs)
config::chop_var(char *&buffer, char *&lhs, char *&rhs) const
{
char *walker;
@ -912,9 +912,7 @@ event_loop(void)
server_fd = create_socket(PIPE);
accepting = 1;
max_fd = max(fd, server_fd) + 1;
while (1) {
if (romeo_must_die)
break;
while (!romeo_must_die) {
if (!once && !dflag && !nflag) {
// Check to see if we have any events pending.
tv.tv_sec = 0;
@ -1076,8 +1074,7 @@ set_variable(const char *var, const char *val)
static void
gensighand(int)
{
romeo_must_die++;
_exit(0);
romeo_must_die = 1;
}
static void

View File

@ -41,8 +41,6 @@ class config;
class var_list
{
public:
var_list() {}
virtual ~var_list() {}
/** Set a variable in this var list.
*/
void set_variable(const std::string &var, const std::string &val);
@ -68,7 +66,6 @@ private:
struct eps
{
public:
eps() {}
virtual ~eps() {}
/** Does this eps match the current config?
*/
@ -144,7 +141,7 @@ private:
class config
{
public:
config() : _pidfile("") { push_var_table(); }
config() { push_var_table(); }
virtual ~config() { reset(); }
void add_attach(int, event_proc *);
void add_detach(int, event_proc *);
@ -172,7 +169,7 @@ protected:
void parse_files_in_dir(const char *dirname);
void expand_one(const char *&src, std::string &dst);
bool is_id_char(char) const;
bool chop_var(char *&buffer, char *&lhs, char *&rhs);
bool chop_var(char *&buffer, char *&lhs, char *&rhs) const;
private:
std::vector<std::string> _dir_list;
std::string _pidfile;

View File

@ -64,6 +64,22 @@ int ipfw_socket = -1;
#define s6_addr32 __u6_addr.__u6_addr32
#endif
#define CHECK_LENGTH(v, len) do { \
if ((v) < (len)) \
errx(EX_DATAERR, "Rule too long"); \
} while (0)
/*
* Check if we have enough space in cmd buffer. Note that since
* first 8? u32 words are reserved by reserved header, full cmd
* buffer can't be used, so we need to protect from buffer overrun
* only. At the beginnig, cblen is less than actual buffer size by
* size of ipfw_insn_u32 instruction + 1 u32 work. This eliminates need
* for checking small instructions fitting in given range.
* We also (ab)use the fact that ipfw_insn is always the first field
* for any custom instruction.
*/
#define CHECK_CMDLEN CHECK_LENGTH(cblen, F_LEN((ipfw_insn *)cmd))
#define GET_UINT_ARG(arg, min, max, tok, s_x) do { \
if (!av[0]) \
errx(EX_USAGE, "%s: missing argument", match_value(s_x, tok)); \
@ -653,7 +669,7 @@ strtoport(char *s, char **end, int base, int proto)
* Fill the body of the command with the list of port ranges.
*/
static int
fill_newports(ipfw_insn_u16 *cmd, char *av, int proto)
fill_newports(ipfw_insn_u16 *cmd, char *av, int proto, int cblen)
{
uint16_t a, b, *p = cmd->ports;
int i = 0;
@ -664,6 +680,8 @@ fill_newports(ipfw_insn_u16 *cmd, char *av, int proto)
if (s == av) /* empty or invalid argument */
return (0);
CHECK_LENGTH(cblen, i + 2);
switch (*s) {
case '-': /* a range */
av = s + 1;
@ -2068,7 +2086,7 @@ lookup_host (char *host, struct in_addr *ipaddr)
* We can have multiple comma-separated address/mask entries.
*/
static void
fill_ip(ipfw_insn_ip *cmd, char *av)
fill_ip(ipfw_insn_ip *cmd, char *av, int cblen)
{
int len = 0;
uint32_t *d = ((ipfw_insn_u32 *)cmd)->d;
@ -2108,6 +2126,8 @@ fill_ip(ipfw_insn_ip *cmd, char *av)
int masklen;
char md, nd = '\0';
CHECK_LENGTH(cblen, F_INSN_SIZE(ipfw_insn) + 2 + len);
if (p) {
md = *p;
*p++ = '\0';
@ -2366,11 +2386,13 @@ ipfw_delete(char *av[])
* patterns which match interfaces.
*/
static void
fill_iface(ipfw_insn_if *cmd, char *arg)
fill_iface(ipfw_insn_if *cmd, char *arg, int cblen)
{
cmd->name[0] = '\0';
cmd->o.len |= F_INSN_SIZE(ipfw_insn_if);
CHECK_CMDLEN;
/* Parse the interface or address */
if (strcmp(arg, "any") == 0)
cmd->o.len = 0; /* effectively ignore this command */
@ -2441,8 +2463,10 @@ get_mac_addr_mask(const char *p, uint8_t *addr, uint8_t *mask)
* the new command in case it has been clobbered before.
*/
static ipfw_insn *
next_cmd(ipfw_insn *cmd)
next_cmd(ipfw_insn *cmd, int *len)
{
*len -= F_LEN(cmd);
CHECK_LENGTH(*len, 0);
cmd += F_LEN(cmd);
bzero(cmd, sizeof(*cmd));
return cmd;
@ -2452,7 +2476,7 @@ next_cmd(ipfw_insn *cmd)
* Takes arguments and copies them into a comment
*/
static void
fill_comment(ipfw_insn *cmd, char **av)
fill_comment(ipfw_insn *cmd, char **av, int cblen)
{
int i, l;
char *p = (char *)(cmd + 1);
@ -2470,6 +2494,8 @@ fill_comment(ipfw_insn *cmd, char **av)
"comment too long (max 80 chars)");
l = 1 + (l+3)/4;
cmd->len = (cmd->len & (F_NOT | F_OR)) | l;
CHECK_CMDLEN;
for (i = 0; av[i] != NULL; i++) {
strcpy(p, av[i]);
p += strlen(av[i]);
@ -2495,7 +2521,7 @@ fill_cmd(ipfw_insn *cmd, enum ipfw_opcodes opcode, int flags, uint16_t arg)
* two microinstructions, and returns the pointer to the last one.
*/
static ipfw_insn *
add_mac(ipfw_insn *cmd, char *av[])
add_mac(ipfw_insn *cmd, char *av[], int cblen)
{
ipfw_insn_mac *mac;
@ -2504,6 +2530,7 @@ add_mac(ipfw_insn *cmd, char *av[])
cmd->opcode = O_MACADDR2;
cmd->len = (cmd->len & (F_NOT | F_OR)) | F_INSN_SIZE(ipfw_insn_mac);
CHECK_CMDLEN;
mac = (ipfw_insn_mac *)cmd;
get_mac_addr_mask(av[0], mac->addr, mac->mask); /* dst */
@ -2513,12 +2540,13 @@ add_mac(ipfw_insn *cmd, char *av[])
}
static ipfw_insn *
add_mactype(ipfw_insn *cmd, char *av)
add_mactype(ipfw_insn *cmd, char *av, int cblen)
{
if (!av)
errx(EX_DATAERR, "missing MAC type");
if (strcmp(av, "any") != 0) { /* we have a non-null type */
fill_newports((ipfw_insn_u16 *)cmd, av, IPPROTO_ETHERTYPE);
fill_newports((ipfw_insn_u16 *)cmd, av, IPPROTO_ETHERTYPE,
cblen);
cmd->opcode = O_MAC_TYPE;
return cmd;
} else
@ -2587,9 +2615,9 @@ add_proto_compat(ipfw_insn *cmd, char *av, u_char *protop)
}
static ipfw_insn *
add_srcip(ipfw_insn *cmd, char *av)
add_srcip(ipfw_insn *cmd, char *av, int cblen)
{
fill_ip((ipfw_insn_ip *)cmd, av);
fill_ip((ipfw_insn_ip *)cmd, av, cblen);
if (cmd->opcode == O_IP_DST_SET) /* set */
cmd->opcode = O_IP_SRC_SET;
else if (cmd->opcode == O_IP_DST_LOOKUP) /* table */
@ -2604,9 +2632,9 @@ add_srcip(ipfw_insn *cmd, char *av)
}
static ipfw_insn *
add_dstip(ipfw_insn *cmd, char *av)
add_dstip(ipfw_insn *cmd, char *av, int cblen)
{
fill_ip((ipfw_insn_ip *)cmd, av);
fill_ip((ipfw_insn_ip *)cmd, av, cblen);
if (cmd->opcode == O_IP_DST_SET) /* set */
;
else if (cmd->opcode == O_IP_DST_LOOKUP) /* table */
@ -2621,12 +2649,12 @@ add_dstip(ipfw_insn *cmd, char *av)
}
static ipfw_insn *
add_ports(ipfw_insn *cmd, char *av, u_char proto, int opcode)
add_ports(ipfw_insn *cmd, char *av, u_char proto, int opcode, int cblen)
{
/* XXX "any" is trapped before. Perhaps "to" */
if (_substrcmp(av, "any") == 0) {
return NULL;
} else if (fill_newports((ipfw_insn_u16 *)cmd, av, proto)) {
} else if (fill_newports((ipfw_insn_u16 *)cmd, av, proto, cblen)) {
/* XXX todo: check that we have a protocol with ports */
cmd->opcode = opcode;
return cmd;
@ -2635,7 +2663,7 @@ add_ports(ipfw_insn *cmd, char *av, u_char proto, int opcode)
}
static ipfw_insn *
add_src(ipfw_insn *cmd, char *av, u_char proto)
add_src(ipfw_insn *cmd, char *av, u_char proto, int cblen)
{
struct in6_addr a;
char *host, *ch;
@ -2648,11 +2676,11 @@ add_src(ipfw_insn *cmd, char *av, u_char proto)
if (proto == IPPROTO_IPV6 || strcmp(av, "me6") == 0 ||
inet_pton(AF_INET6, host, &a) == 1)
ret = add_srcip6(cmd, av);
ret = add_srcip6(cmd, av, cblen);
/* XXX: should check for IPv4, not !IPv6 */
if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
inet_pton(AF_INET6, host, &a) != 1))
ret = add_srcip(cmd, av);
ret = add_srcip(cmd, av, cblen);
if (ret == NULL && strcmp(av, "any") != 0)
ret = cmd;
@ -2661,7 +2689,7 @@ add_src(ipfw_insn *cmd, char *av, u_char proto)
}
static ipfw_insn *
add_dst(ipfw_insn *cmd, char *av, u_char proto)
add_dst(ipfw_insn *cmd, char *av, u_char proto, int cblen)
{
struct in6_addr a;
char *host, *ch;
@ -2674,11 +2702,11 @@ add_dst(ipfw_insn *cmd, char *av, u_char proto)
if (proto == IPPROTO_IPV6 || strcmp(av, "me6") == 0 ||
inet_pton(AF_INET6, host, &a) == 1)
ret = add_dstip6(cmd, av);
ret = add_dstip6(cmd, av, cblen);
/* XXX: should check for IPv4, not !IPv6 */
if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 ||
inet_pton(AF_INET6, host, &a) != 1))
ret = add_dstip(cmd, av);
ret = add_dstip(cmd, av, cblen);
if (ret == NULL && strcmp(av, "any") != 0)
ret = cmd;
@ -2708,6 +2736,7 @@ ipfw_add(char *av[])
* go into actbuf[].
*/
static uint32_t rulebuf[255], actbuf[255], cmdbuf[255];
int rblen, ablen, cblen;
ipfw_insn *src, *dst, *cmd, *action, *prev=NULL;
ipfw_insn *first_cmd; /* first match pattern */
@ -2738,6 +2767,15 @@ ipfw_add(char *av[])
cmd = (ipfw_insn *)cmdbuf;
action = (ipfw_insn *)actbuf;
rblen = sizeof(rulebuf) / sizeof(rulebuf[0]);
rblen -= offsetof(struct ip_fw, cmd) / sizeof(rulebuf[0]);
ablen = sizeof(actbuf) / sizeof(actbuf[0]);
cblen = sizeof(cmdbuf) / sizeof(cmdbuf[0]);
cblen -= F_INSN_SIZE(ipfw_insn_u32) + 1;
#define CHECK_RBUFLEN(len) { CHECK_LENGTH(rblen, len); rblen -= len; }
#define CHECK_ACTLEN CHECK_LENGTH(ablen, action->len)
av++;
/* [rule N] -- Rule number optional */
@ -2769,6 +2807,7 @@ ipfw_add(char *av[])
i = match_token(rule_actions, *av);
av++;
action->len = 1; /* default */
CHECK_ACTLEN;
switch(i) {
case TOK_CHECKSTATE:
have_state = action;
@ -2820,6 +2859,7 @@ ipfw_add(char *av[])
case TOK_NAT:
action->opcode = O_NAT;
action->len = F_INSN_SIZE(ipfw_insn_nat);
CHECK_ACTLEN;
if (_substrcmp(*av, "global") == 0) {
action->arg1 = 0;
av++;
@ -2936,6 +2976,7 @@ ipfw_add(char *av[])
action->opcode = O_FORWARD_IP;
action->len = F_INSN_SIZE(ipfw_insn_sa);
CHECK_ACTLEN;
/*
* In the kernel we assume AF_INET and use only
@ -2952,6 +2993,7 @@ ipfw_add(char *av[])
action->opcode = O_FORWARD_IP6;
action->len = F_INSN_SIZE(ipfw_insn_sa6);
CHECK_ACTLEN;
p->sa.sin6_len = sizeof(struct sockaddr_in6);
p->sa.sin6_family = AF_INET6;
@ -3005,7 +3047,7 @@ ipfw_add(char *av[])
default:
errx(EX_DATAERR, "invalid action %s\n", av[-1]);
}
action = next_cmd(action);
action = next_cmd(action, &ablen);
/*
* [altq queuename] -- altq tag, optional
@ -3027,6 +3069,7 @@ ipfw_add(char *av[])
"log cannot be specified more than once");
have_log = (ipfw_insn *)c;
cmd->len = F_INSN_SIZE(ipfw_insn_log);
CHECK_CMDLEN;
cmd->opcode = O_LOG;
if (av[0] && _substrcmp(*av, "logamount") == 0) {
av++;
@ -3058,6 +3101,7 @@ ipfw_add(char *av[])
"altq cannot be specified more than once");
have_altq = (ipfw_insn *)a;
cmd->len = F_INSN_SIZE(ipfw_insn_altq);
CHECK_CMDLEN;
cmd->opcode = O_ALTQ;
a->qid = altq_name_to_qid(*av);
av++;
@ -3083,7 +3127,7 @@ ipfw_add(char *av[])
default:
abort();
}
cmd = next_cmd(cmd);
cmd = next_cmd(cmd, &cblen);
}
if (have_state) /* must be a check-state, we are done */
@ -3168,7 +3212,7 @@ ipfw_add(char *av[])
av++;
if (F_LEN(cmd) != 0) {
prev = cmd;
cmd = next_cmd(cmd);
cmd = next_cmd(cmd, &cblen);
}
} else if (first_cmd != cmd) {
errx(EX_DATAERR, "invalid protocol ``%s''", *av);
@ -3189,11 +3233,11 @@ ipfw_add(char *av[])
OR_START(source_ip);
NOT_BLOCK; /* optional "not" */
NEED1("missing source address");
if (add_src(cmd, *av, proto)) {
if (add_src(cmd, *av, proto, cblen)) {
av++;
if (F_LEN(cmd) != 0) { /* ! any */
prev = cmd;
cmd = next_cmd(cmd);
cmd = next_cmd(cmd, &cblen);
}
} else
errx(EX_USAGE, "bad source address %s", *av);
@ -3205,10 +3249,10 @@ ipfw_add(char *av[])
NOT_BLOCK; /* optional "not" */
if ( av[0] != NULL ) {
if (_substrcmp(*av, "any") == 0 ||
add_ports(cmd, *av, proto, O_IP_SRCPORT)) {
add_ports(cmd, *av, proto, O_IP_SRCPORT, cblen)) {
av++;
if (F_LEN(cmd) != 0)
cmd = next_cmd(cmd);
cmd = next_cmd(cmd, &cblen);
}
}
@ -3225,11 +3269,11 @@ ipfw_add(char *av[])
OR_START(dest_ip);
NOT_BLOCK; /* optional "not" */
NEED1("missing dst address");
if (add_dst(cmd, *av, proto)) {
if (add_dst(cmd, *av, proto, cblen)) {
av++;
if (F_LEN(cmd) != 0) { /* ! any */
prev = cmd;
cmd = next_cmd(cmd);
cmd = next_cmd(cmd, &cblen);
}
} else
errx( EX_USAGE, "bad destination address %s", *av);
@ -3241,10 +3285,10 @@ ipfw_add(char *av[])
NOT_BLOCK; /* optional "not" */
if (av[0]) {
if (_substrcmp(*av, "any") == 0 ||
add_ports(cmd, *av, proto, O_IP_DSTPORT)) {
add_ports(cmd, *av, proto, O_IP_DSTPORT, cblen)) {
av++;
if (F_LEN(cmd) != 0)
cmd = next_cmd(cmd);
cmd = next_cmd(cmd, &cblen);
}
}
@ -3332,7 +3376,7 @@ ipfw_add(char *av[])
case TOK_VIA:
NEED1("recv, xmit, via require interface name"
" or address");
fill_iface((ipfw_insn_if *)cmd, av[0]);
fill_iface((ipfw_insn_if *)cmd, av[0], cblen);
av++;
if (F_LEN(cmd) == 0) /* not a valid address */
break;
@ -3352,14 +3396,14 @@ ipfw_add(char *av[])
case TOK_ICMP6TYPES:
NEED1("icmptypes requires list of types");
fill_icmp6types((ipfw_insn_icmp6 *)cmd, *av);
fill_icmp6types((ipfw_insn_icmp6 *)cmd, *av, cblen);
av++;
break;
case TOK_IPTTL:
NEED1("ipttl requires TTL");
if (strpbrk(*av, "-,")) {
if (!add_ports(cmd, *av, 0, O_IPTTL))
if (!add_ports(cmd, *av, 0, O_IPTTL, cblen))
errx(EX_DATAERR, "invalid ipttl %s", *av);
} else
fill_cmd(cmd, O_IPTTL, 0, strtoul(*av, NULL, 0));
@ -3369,7 +3413,7 @@ ipfw_add(char *av[])
case TOK_IPID:
NEED1("ipid requires id");
if (strpbrk(*av, "-,")) {
if (!add_ports(cmd, *av, 0, O_IPID))
if (!add_ports(cmd, *av, 0, O_IPID, cblen))
errx(EX_DATAERR, "invalid ipid %s", *av);
} else
fill_cmd(cmd, O_IPID, 0, strtoul(*av, NULL, 0));
@ -3379,7 +3423,7 @@ ipfw_add(char *av[])
case TOK_IPLEN:
NEED1("iplen requires length");
if (strpbrk(*av, "-,")) {
if (!add_ports(cmd, *av, 0, O_IPLEN))
if (!add_ports(cmd, *av, 0, O_IPLEN, cblen))
errx(EX_DATAERR, "invalid ip len %s", *av);
} else
fill_cmd(cmd, O_IPLEN, 0, strtoul(*av, NULL, 0));
@ -3475,7 +3519,7 @@ ipfw_add(char *av[])
case TOK_TCPDATALEN:
NEED1("tcpdatalen requires length");
if (strpbrk(*av, "-,")) {
if (!add_ports(cmd, *av, 0, O_TCPDATALEN))
if (!add_ports(cmd, *av, 0, O_TCPDATALEN, cblen))
errx(EX_DATAERR, "invalid tcpdata len %s", *av);
} else
fill_cmd(cmd, O_TCPDATALEN, 0,
@ -3501,7 +3545,7 @@ ipfw_add(char *av[])
case TOK_TCPWIN:
NEED1("tcpwin requires length");
if (strpbrk(*av, "-,")) {
if (!add_ports(cmd, *av, 0, O_TCPWIN))
if (!add_ports(cmd, *av, 0, O_TCPWIN, cblen))
errx(EX_DATAERR, "invalid tcpwin len %s", *av);
} else
fill_cmd(cmd, O_TCPWIN, 0,
@ -3540,6 +3584,7 @@ ipfw_add(char *av[])
have_state = cmd;
cmd->len = F_INSN_SIZE(ipfw_insn_limit);
CHECK_CMDLEN;
cmd->opcode = O_LIMIT;
c->limit_mask = c->conn_limit = 0;
@ -3571,28 +3616,28 @@ ipfw_add(char *av[])
case TOK_SRCIP:
NEED1("missing source IP");
if (add_srcip(cmd, *av)) {
if (add_srcip(cmd, *av, cblen)) {
av++;
}
break;
case TOK_DSTIP:
NEED1("missing destination IP");
if (add_dstip(cmd, *av)) {
if (add_dstip(cmd, *av, cblen)) {
av++;
}
break;
case TOK_SRCIP6:
NEED1("missing source IP6");
if (add_srcip6(cmd, *av)) {
if (add_srcip6(cmd, *av, cblen)) {
av++;
}
break;
case TOK_DSTIP6:
NEED1("missing destination IP6");
if (add_dstip6(cmd, *av)) {
if (add_dstip6(cmd, *av, cblen)) {
av++;
}
break;
@ -3600,7 +3645,7 @@ ipfw_add(char *av[])
case TOK_SRCPORT:
NEED1("missing source port");
if (_substrcmp(*av, "any") == 0 ||
add_ports(cmd, *av, proto, O_IP_SRCPORT)) {
add_ports(cmd, *av, proto, O_IP_SRCPORT, cblen)) {
av++;
} else
errx(EX_DATAERR, "invalid source port %s", *av);
@ -3609,7 +3654,7 @@ ipfw_add(char *av[])
case TOK_DSTPORT:
NEED1("missing destination port");
if (_substrcmp(*av, "any") == 0 ||
add_ports(cmd, *av, proto, O_IP_DSTPORT)) {
add_ports(cmd, *av, proto, O_IP_DSTPORT, cblen)) {
av++;
} else
errx(EX_DATAERR, "invalid destination port %s",
@ -3617,13 +3662,13 @@ ipfw_add(char *av[])
break;
case TOK_MAC:
if (add_mac(cmd, av))
if (add_mac(cmd, av, cblen))
av += 2;
break;
case TOK_MACTYPE:
NEED1("missing mac type");
if (!add_mactype(cmd, *av))
if (!add_mactype(cmd, *av, cblen))
errx(EX_DATAERR, "invalid mac type %s", *av);
av++;
break;
@ -3661,18 +3706,18 @@ ipfw_add(char *av[])
if (proto != IPPROTO_IPV6 )
errx( EX_USAGE, "flow-id filter is active "
"only for ipv6 protocol\n");
fill_flow6( (ipfw_insn_u32 *) cmd, *av );
fill_flow6( (ipfw_insn_u32 *) cmd, *av, cblen);
av++;
break;
case TOK_COMMENT:
fill_comment(cmd, av);
fill_comment(cmd, av, cblen);
av[0]=NULL;
break;
case TOK_TAGGED:
if (av[0] && strpbrk(*av, "-,")) {
if (!add_ports(cmd, *av, 0, O_TAGGED))
if (!add_ports(cmd, *av, 0, O_TAGGED, cblen))
errx(EX_DATAERR, "tagged: invalid tag"
" list: %s", *av);
}
@ -3725,7 +3770,7 @@ ipfw_add(char *av[])
}
if (F_LEN(cmd) > 0) { /* prepare to advance */
prev = cmd;
cmd = next_cmd(cmd);
cmd = next_cmd(cmd, &cblen);
}
}
@ -3754,12 +3799,13 @@ ipfw_add(char *av[])
*/
if (have_state && have_state->opcode != O_CHECK_STATE) {
fill_cmd(dst, O_PROBE_STATE, 0, 0);
dst = next_cmd(dst);
dst = next_cmd(dst, &rblen);
}
/* copy all commands but O_LOG, O_KEEP_STATE, O_LIMIT, O_ALTQ, O_TAG */
for (src = (ipfw_insn *)cmdbuf; src != cmd; src += i) {
i = F_LEN(src);
CHECK_RBUFLEN(i);
switch (src->opcode) {
case O_LOG:
@ -3779,6 +3825,7 @@ ipfw_add(char *av[])
*/
if (have_state && have_state->opcode != O_CHECK_STATE) {
i = F_LEN(have_state);
CHECK_RBUFLEN(i);
bcopy(have_state, dst, i * sizeof(uint32_t));
dst += i;
}
@ -3790,24 +3837,29 @@ ipfw_add(char *av[])
/* put back O_LOG, O_ALTQ, O_TAG if necessary */
if (have_log) {
i = F_LEN(have_log);
CHECK_RBUFLEN(i);
bcopy(have_log, dst, i * sizeof(uint32_t));
dst += i;
}
if (have_altq) {
i = F_LEN(have_altq);
CHECK_RBUFLEN(i);
bcopy(have_altq, dst, i * sizeof(uint32_t));
dst += i;
}
if (have_tag) {
i = F_LEN(have_tag);
CHECK_RBUFLEN(i);
bcopy(have_tag, dst, i * sizeof(uint32_t));
dst += i;
}
/*
* copy all other actions
*/
for (src = (ipfw_insn *)actbuf; src != action; src += i) {
i = F_LEN(src);
CHECK_RBUFLEN(i);
bcopy(src, dst, i * sizeof(uint32_t));
dst += i;
}

View File

@ -283,10 +283,10 @@ void print_flow6id(struct _ipfw_insn_u32 *cmd);
void print_icmp6types(struct _ipfw_insn_u32 *cmd);
void print_ext6hdr(struct _ipfw_insn *cmd );
struct _ipfw_insn *add_srcip6(struct _ipfw_insn *cmd, char *av);
struct _ipfw_insn *add_dstip6(struct _ipfw_insn *cmd, char *av);
struct _ipfw_insn *add_srcip6(struct _ipfw_insn *cmd, char *av, int cblen);
struct _ipfw_insn *add_dstip6(struct _ipfw_insn *cmd, char *av, int cblen);
void fill_flow6(struct _ipfw_insn_u32 *cmd, char *av );
void fill_flow6(struct _ipfw_insn_u32 *cmd, char *av, int cblen);
void fill_unreach6_code(u_short *codep, char *str);
void fill_icmp6types(struct _ipfw_insn_icmp6 *cmd, char *av);
void fill_icmp6types(struct _ipfw_insn_icmp6 *cmd, char *av, int cblen);
int fill_ext6hdr(struct _ipfw_insn *cmd, char *av);

View File

@ -42,6 +42,11 @@
#include <netinet/ip_fw.h>
#include <arpa/inet.h>
#define CHECK_LENGTH(v, len) do { \
if ((v) < (len)) \
errx(EX_DATAERR, "Rule too long"); \
} while (0)
static struct _s_x icmp6codes[] = {
{ "no-route", ICMP6_DST_UNREACH_NOROUTE },
{ "admin-prohib", ICMP6_DST_UNREACH_ADMIN },
@ -131,10 +136,12 @@ print_ip6(ipfw_insn_ip6 *cmd, char const *s)
}
void
fill_icmp6types(ipfw_insn_icmp6 *cmd, char *av)
fill_icmp6types(ipfw_insn_icmp6 *cmd, char *av, int cblen)
{
uint8_t type;
CHECK_LENGTH(cblen, F_INSN_SIZE(ipfw_insn_icmp6));
bzero(cmd, sizeof(*cmd));
while (*av) {
if (*av == ',')
@ -327,7 +334,7 @@ lookup_host6 (char *host, struct in6_addr *ip6addr)
* Return 1 on success, 0 on failure.
*/
static int
fill_ip6(ipfw_insn_ip6 *cmd, char *av)
fill_ip6(ipfw_insn_ip6 *cmd, char *av, int cblen)
{
int len = 0;
struct in6_addr *d = &(cmd->addr6);
@ -379,6 +386,8 @@ fill_ip6(ipfw_insn_ip6 *cmd, char *av)
int masklen;
char md = '\0';
CHECK_LENGTH(cblen, 1 + len + 2 * F_INSN_SIZE(struct in6_addr));
if ((p = strpbrk(av, "/,")) ) {
md = *p; /* save the separator */
*p = '\0'; /* terminate address string */
@ -453,7 +462,7 @@ fill_ip6(ipfw_insn_ip6 *cmd, char *av)
* additional flow-id we want to filter, the basic is 1
*/
void
fill_flow6( ipfw_insn_u32 *cmd, char *av )
fill_flow6( ipfw_insn_u32 *cmd, char *av, int cblen)
{
u_int32_t type; /* Current flow number */
u_int16_t nflow = 0; /* Current flow index */
@ -461,6 +470,8 @@ fill_flow6( ipfw_insn_u32 *cmd, char *av )
cmd->d[0] = 0; /* Initializing the base number*/
while (s) {
CHECK_LENGTH(cblen, F_INSN_SIZE(ipfw_insn_u32) + nflow + 1);
av = strsep( &s, ",") ;
type = strtoul(av, &av, 0);
if (*av != ',' && *av != '\0')
@ -481,10 +492,10 @@ fill_flow6( ipfw_insn_u32 *cmd, char *av )
}
ipfw_insn *
add_srcip6(ipfw_insn *cmd, char *av)
add_srcip6(ipfw_insn *cmd, char *av, int cblen)
{
fill_ip6((ipfw_insn_ip6 *)cmd, av);
fill_ip6((ipfw_insn_ip6 *)cmd, av, cblen);
if (cmd->opcode == O_IP_DST_SET) /* set */
cmd->opcode = O_IP_SRC_SET;
else if (cmd->opcode == O_IP_DST_LOOKUP) /* table */
@ -503,10 +514,10 @@ add_srcip6(ipfw_insn *cmd, char *av)
}
ipfw_insn *
add_dstip6(ipfw_insn *cmd, char *av)
add_dstip6(ipfw_insn *cmd, char *av, int cblen)
{
fill_ip6((ipfw_insn_ip6 *)cmd, av);
fill_ip6((ipfw_insn_ip6 *)cmd, av, cblen);
if (cmd->opcode == O_IP_DST_SET) /* set */
;
else if (cmd->opcode == O_IP_DST_LOOKUP) /* table */

View File

@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd April 27, 2010
.Dd March 3, 2013
.Dt MVS 4
.Os
.Sh NAME
@ -62,7 +62,7 @@ command latency.
.It Va hint.mvs. Ns Ar X Ns Va .cccc
defines number of completed commands for CCC, which trigger interrupt without
waiting for specified coalescing timeout.
.It Va hint.mvs. Ns Ar X Ns Va .pm_level
.It Va hint.mvsch. Ns Ar X Ns Va .pm_level
controls SATA interface Power Management for the specified channel,
allowing some power to be saved at the cost of additional command
latency.
@ -82,7 +82,7 @@ driver initiates SLUMBER PM state transition 125ms after port becomes idle.
Note that interface Power Management is not compatible with
device presence detection.
A manual bus reset is needed on device hot-plug.
.It Va hint.mvs. Ns Ar X Ns Va .sata_rev
.It Va hint.mvsch. Ns Ar X Ns Va .sata_rev
setting to nonzero value limits maximum SATA revision (speed).
Values 1, 2 and 3 are respectively 1.5, 3 and 6Gbps.
.El

View File

@ -386,8 +386,7 @@ linprocfs_domtab(PFS_FILL_ARGS)
sbuf_printf(sb, " 0 0\n");
}
mtx_unlock(&mountlist_mtx);
if (flep != NULL)
free(flep, M_TEMP);
free(flep, M_TEMP);
return (error);
}
@ -447,8 +446,7 @@ linprocfs_dopartitions(PFS_FILL_ARGS)
}
g_topology_unlock();
if (flep != NULL)
free(flep, M_TEMP);
free(flep, M_TEMP);
return (error);
}

View File

@ -517,8 +517,7 @@ getdents_common(struct thread *td, struct linux_getdents64_args *args,
td->td_retval[0] = nbytes - resid;
out:
if (cookies)
free(cookies, M_TEMP);
free(cookies, M_TEMP);
VOP_UNLOCK(vp, 0);
foffset_unlock(fp, off, 0);

View File

@ -1443,10 +1443,8 @@ linux_recvmsg(struct thread *td, struct linux_recvmsg_args *args)
bad:
free(iov, M_IOV);
if (control != NULL)
m_freem(control);
if (linux_cmsg != NULL)
free(linux_cmsg, M_TEMP);
m_freem(control);
free(linux_cmsg, M_TEMP);
return (error);
}

View File

@ -1527,11 +1527,13 @@ struct ath_hal {
struct ath_desc *, u_int);
void __ahdecl(*ah_set11nAggrLast)(struct ath_hal *,
struct ath_desc *);
void __ahdecl(*ah_clr11nAggr)(struct ath_hal *,
struct ath_desc *);
void __ahdecl(*ah_set11nBurstDuration)(struct ath_hal *,
struct ath_desc *, u_int);
void __ahdecl(*ah_set11nVirtMoreFrag)(struct ath_hal *,
struct ath_desc *, u_int);
HAL_BOOL __ahdecl(*ah_getMibCycleCounts) (struct ath_hal *,
HAL_SURVEY_SAMPLE *);

View File

@ -409,8 +409,9 @@ extern void ar5416Set11nAggrFirst(struct ath_hal *ah, struct ath_desc *ds,
u_int aggrLen, u_int numDelims);
extern void ar5416Set11nAggrMiddle(struct ath_hal *ah, struct ath_desc *ds, u_int numDelims);
extern void ar5416Set11nAggrLast(struct ath_hal *ah, struct ath_desc *ds);
extern void ar5416Clr11nAggr(struct ath_hal *ah, struct ath_desc *ds);
extern void ar5416Set11nVirtualMoreFrag(struct ath_hal *ah,
struct ath_desc *ds, u_int vmf);
extern void ar5416Set11nBurstDuration(struct ath_hal *ah, struct ath_desc *ds, u_int burstDuration);

View File

@ -194,6 +194,7 @@ ar5416InitState(struct ath_hal_5416 *ahp5416, uint16_t devid, HAL_SOFTC sc,
ah->ah_set11nMac2040 = ar5416Set11nMac2040;
ah->ah_get11nRxClear = ar5416Get11nRxClear;
ah->ah_set11nRxClear = ar5416Set11nRxClear;
ah->ah_set11nVirtMoreFrag = ar5416Set11nVirtualMoreFrag;
/* Interrupt functions */
ah->ah_isInterruptPending = ar5416IsInterruptPending;

View File

@ -825,6 +825,17 @@ ar5416Clr11nAggr(struct ath_hal *ah, struct ath_desc *ds)
ads->ds_ctl6 &= ~AR_AggrLen;
}
void
ar5416Set11nVirtualMoreFrag(struct ath_hal *ah, struct ath_desc *ds,
u_int vmf)
{
struct ar5416_desc *ads = AR5416DESC(ds);
if (vmf)
ads->ds_ctl0 |= AR_VirtMoreFrag;
else
ads->ds_ctl0 &= ~AR_VirtMoreFrag;
}
/*
* Program the burst duration, with the included BA delta if it's
* applicable.

View File

@ -1297,6 +1297,8 @@ void ath_intr(void *);
((*(_ah)->ah_set11nBurstDuration)((_ah), (_ds), (_dur)))
#define ath_hal_clr11n_aggr(_ah, _ds) \
((*(_ah)->ah_clr11nAggr)((_ah), (_ds)))
#define ath_hal_set11n_virtmorefrag(_ah, _ds, _v) \
((*(_ah)->ah_set11nVirtMoreFrag)((_ah), (_ds), (_v)))
#define ath_hal_gpioCfgOutput(_ah, _gpio, _type) \
((*(_ah)->ah_gpioCfgOutput)((_ah), (_gpio), (_type)))

View File

@ -104,6 +104,7 @@ static MALLOC_DEFINE(M_FILEDESC, "filedesc", "Open file descriptor table");
static MALLOC_DEFINE(M_FILEDESC_TO_LEADER, "filedesc_to_leader",
"file desc to leader structures");
static MALLOC_DEFINE(M_SIGIO, "sigio", "sigio structures");
MALLOC_DEFINE(M_FILECAPS, "filecaps", "descriptor capabilities");
MALLOC_DECLARE(M_FADVISE);
@ -1389,7 +1390,7 @@ filecaps_copy(const struct filecaps *src, struct filecaps *dst)
("fc_ioctls != NULL, but fc_nioctls=%hd", src->fc_nioctls));
size = sizeof(src->fc_ioctls[0]) * src->fc_nioctls;
dst->fc_ioctls = malloc(size, M_TEMP, M_WAITOK);
dst->fc_ioctls = malloc(size, M_FILECAPS, M_WAITOK);
bcopy(src->fc_ioctls, dst->fc_ioctls, size);
}
}
@ -1397,7 +1398,7 @@ filecaps_copy(const struct filecaps *src, struct filecaps *dst)
/*
* Move filecaps structure to the new place and clear the old place.
*/
static void
void
filecaps_move(struct filecaps *src, struct filecaps *dst)
{
@ -1425,7 +1426,7 @@ void
filecaps_free(struct filecaps *fcaps)
{
free(fcaps->fc_ioctls, M_TEMP);
free(fcaps->fc_ioctls, M_FILECAPS);
bzero(fcaps, sizeof(*fcaps));
}

View File

@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/callout.h>
#include <sys/condvar.h>
#include <sys/interrupt.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
@ -84,7 +83,7 @@ SYSCTL_INT(_debug, OID_AUTO, to_avg_mpcalls, CTLFLAG_RD, &avg_mpcalls, 0,
* TODO:
* allocate more timeout table slots when table overflows.
*/
int callwheelsize, callwheelmask;
u_int callwheelsize, callwheelmask;
/*
* The callout cpu migration entity represents informations necessary for

View File

@ -102,6 +102,8 @@ __FBSDID("$FreeBSD$");
#include <vm/uma.h>
MALLOC_DECLARE(M_FILECAPS);
/*
* Locking key:
* (l) Locked using list lock
@ -282,7 +284,7 @@ static void unp_drop(struct unpcb *, int);
static void unp_gc(__unused void *, int);
static void unp_scan(struct mbuf *, void (*)(struct file *));
static void unp_discard(struct file *);
static void unp_freerights(struct filedescent *, int);
static void unp_freerights(struct filedescent **, int);
static void unp_init(void);
static int unp_internalize(struct mbuf **, struct thread *);
static void unp_internalize_fp(struct file *);
@ -1679,16 +1681,17 @@ unp_drop(struct unpcb *unp, int errno)
}
static void
unp_freerights(struct filedescent *fde, int fdcount)
unp_freerights(struct filedescent **fdep, int fdcount)
{
struct file *fp;
int i;
for (i = 0; i < fdcount; i++, fde++) {
fp = fde->fde_file;
bzero(fde, sizeof(*fde));
for (i = 0; i < fdcount; i++) {
fp = fdep[i]->fde_file;
filecaps_free(&fdep[i]->fde_caps);
unp_discard(fp);
}
free(fdep[0], M_FILECAPS);
}
static int
@ -1699,7 +1702,7 @@ unp_externalize(struct mbuf *control, struct mbuf **controlp)
int i;
int *fdp;
struct filedesc *fdesc = td->td_proc->p_fd;
struct filedescent *fde, *fdep;
struct filedescent *fde, **fdep;
void *data;
socklen_t clen = control->m_len, datalen;
int error, newfds;
@ -1755,16 +1758,18 @@ unp_externalize(struct mbuf *control, struct mbuf **controlp)
fdp = (int *)
CMSG_DATA(mtod(*controlp, struct cmsghdr *));
for (i = 0; i < newfds; i++, fdep++, fdp++) {
for (i = 0; i < newfds; i++, fdp++) {
if (fdalloc(td, 0, &f))
panic("unp_externalize fdalloc failed");
fde = &fdesc->fd_ofiles[f];
fde->fde_file = fdep->fde_file;
filecaps_copy(&fdep->fde_caps, &fde->fde_caps);
fde->fde_file = fdep[0]->fde_file;
filecaps_move(&fdep[0]->fde_caps,
&fde->fde_caps);
unp_externalize_fp(fde->fde_file);
*fdp = f;
}
FILEDESC_XUNLOCK(fdesc);
free(fdep[0], M_FILECAPS);
} else {
/* We can just copy anything else across. */
if (error || controlp == NULL)
@ -1839,7 +1844,7 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
struct bintime *bt;
struct cmsghdr *cm = mtod(control, struct cmsghdr *);
struct cmsgcred *cmcred;
struct filedescent *fde, *fdep;
struct filedescent *fde, **fdep, *fdev;
struct file *fp;
struct timeval *tv;
int i, fd, *fdp;
@ -1913,7 +1918,7 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
* Now replace the integer FDs with pointers to the
* file structure and capability rights.
*/
newlen = oldfds * sizeof(*fdep);
newlen = oldfds * sizeof(fdep[0]);
*controlp = sbcreatecontrol(NULL, newlen,
SCM_RIGHTS, SOL_SOCKET);
if (*controlp == NULL) {
@ -1922,13 +1927,17 @@ unp_internalize(struct mbuf **controlp, struct thread *td)
goto out;
}
fdp = data;
fdep = (struct filedescent *)
fdep = (struct filedescent **)
CMSG_DATA(mtod(*controlp, struct cmsghdr *));
for (i = 0; i < oldfds; i++, fdep++, fdp++) {
fdev = malloc(sizeof(*fdev) * oldfds, M_FILECAPS,
M_WAITOK);
for (i = 0; i < oldfds; i++, fdev++, fdp++) {
fde = &fdesc->fd_ofiles[*fdp];
fdep->fde_file = fde->fde_file;
filecaps_copy(&fde->fde_caps, &fdep->fde_caps);
unp_internalize_fp(fdep->fde_file);
fdep[i] = fdev;
fdep[i]->fde_file = fde->fde_file;
filecaps_copy(&fde->fde_caps,
&fdep[i]->fde_caps);
unp_internalize_fp(fdep[i]->fde_file);
}
FILEDESC_SUNLOCK(fdesc);
break;
@ -2290,7 +2299,7 @@ static void
unp_scan(struct mbuf *m0, void (*op)(struct file *))
{
struct mbuf *m;
struct filedescent *fdep;
struct filedescent **fdep;
struct cmsghdr *cm;
void *data;
int i;
@ -2317,8 +2326,8 @@ unp_scan(struct mbuf *m0, void (*op)(struct file *))
cm->cmsg_type == SCM_RIGHTS) {
qfds = datalen / sizeof(*fdep);
fdep = data;
for (i = 0; i < qfds; i++, fdep++)
(*op)(fdep->fde_file);
for (i = 0; i < qfds; i++)
(*op)(fdep[i]->fde_file);
}
if (CMSG_SPACE(datalen) < clen) {

View File

@ -5,6 +5,6 @@
KMOD= mqueuefs
SRCS= uipc_mqueue.c \
vnode_if.h \
opt_posix.h opt_compat.h
opt_posix.h opt_compat.h opt_capsicum.h
.include <bsd.kmod.mk>

View File

@ -136,6 +136,7 @@ struct thread;
void filecaps_init(struct filecaps *fcaps);
void filecaps_copy(const struct filecaps *src, struct filecaps *dst);
void filecaps_move(struct filecaps *src, struct filecaps *dst);
void filecaps_free(struct filecaps *fcaps);
int closef(struct file *fp, struct thread *td);

View File

@ -44,7 +44,6 @@
#include <sys/cdefs.h>
#include <sys/queue.h>
#include <sys/stdint.h> /* for people using printf mainly */
#include <sys/time.h>
extern int cold; /* nonzero if we are doing a cold boot */
extern int rebooting; /* kern_reboot() has been called. */

View File

@ -0,0 +1,10 @@
# $FreeBSD$
f() {
trap 'return 42' USR1
kill -USR1 $$
return 3
}
f
r=$?
[ "$r" = 42 ]

View File

@ -6,6 +6,7 @@
#ifndef _calendar_birthday_
#define _calendar_birthday_
#undef unix
01/01 J.D. Salinger born, 1919
01/01 Paul Revere born in Boston, 1735

View File

@ -73,6 +73,7 @@ creat_f c_regex;
creat_f c_samefile;
creat_f c_simple;
creat_f c_size;
creat_f c_sparse;
creat_f c_type;
creat_f c_user;
creat_f c_xdev;
@ -109,6 +110,7 @@ exec_f f_prune;
exec_f f_quit;
exec_f f_regex;
exec_f f_size;
exec_f f_sparse;
exec_f f_type;
exec_f f_user;

View File

@ -816,6 +816,10 @@ terabytes (1024 gigabytes)
.It Cm P
petabytes (1024 terabytes)
.El
.It Ic -sparse
True if the current file is sparse,
i.e. has fewer blocks allocated than expected based on its size in bytes.
This might also match files that have been compressed by the filesystem.
.It Ic -type Ar t
True if the file is of the specified type.
Possible file types are as follows:
@ -997,7 +1001,7 @@ and
as well as
.Ic -amin , -anewer , -cmin , -cnewer , -delete , -empty , -fstype ,
.Ic -iname , -inum , -iregex , -ls , -maxdepth , -mindepth , -mmin ,
.Ic -path , -print0 , -regex
.Ic -path , -print0 , -regex, -sparse
and all of the
.Ic -B*
birthtime related primaries are extensions to

View File

@ -1496,6 +1496,29 @@ c_size(OPTION *option, char ***argvp)
return new;
}
/*
* -sparse functions --
*
* Check if a file is sparse by finding if it occupies fewer blocks
* than we expect based on its size.
*/
int
f_sparse(PLAN *plan __unused, FTSENT *entry)
{
off_t expected_blocks;
expected_blocks = (entry->fts_statp->st_size + 511) / 512;
return entry->fts_statp->st_blocks < expected_blocks;
}
PLAN *
c_sparse(OPTION *option, char ***argvp __unused)
{
ftsoptions &= ~FTS_NOSTAT;
return palloc(option);
}
/*
* -type c functions --
*

View File

@ -145,6 +145,7 @@ static OPTION const options[] = {
{ "-regex", c_regex, f_regex, 0 },
{ "-samefile", c_samefile, f_inum, 0 },
{ "-size", c_size, f_size, 0 },
{ "-sparse", c_sparse, f_sparse, 0 },
{ "-true", c_simple, f_always_true, 0 },
{ "-type", c_type, f_type, 0 },
{ "-uid", c_user, f_user, 0 },

View File

@ -151,7 +151,7 @@ conv_u(PR *pr, u_char *p)
static char const * list[] = {
"nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
"bs", "ht", "lf", "vt", "ff", "cr", "so", "si",
"dle", "dcl", "dc2", "dc3", "dc4", "nak", "syn", "etb",
"dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb",
"can", "em", "sub", "esc", "fs", "gs", "rs", "us",
};

View File

@ -62,7 +62,18 @@ get_fs_line_xvars()
echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2|3)?|spare|log|cache):" 2>/dev/null
if [ $? -eq 0 ] ; then
ZTYPE=`echo $ZFSVARS | cut -f1 -d:`
ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"`
tmpVars=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"`
ZFSVARS=""
# make sure we have a '/dev' in front of the extra devices
for i in $tmpVars
do
echo $i | grep -q '/dev/'
if [ $? -ne 0 ] ; then
ZFSVARS="$ZFSVARS /dev/${i}"
else
ZFSVARS="$ZFSVARS $i"
fi
done
fi
# Return the ZFS options

View File

@ -33,6 +33,7 @@ is_disk()
for _dsk in `sysctl -n kern.disks`
do
[ "$_dsk" = "${1}" ] && return 0
[ "/dev/$_dsk" = "${1}" ] && return 0
done
return 1

View File

@ -76,50 +76,113 @@ fetch_package_dependencies()
# Check for any packages specified, and begin loading them
install_packages()
{
echo "Checking for packages to install..."
sleep 2
# First, lets check and see if we even have any packages to install
get_value_from_cfg installPackages
if [ -n "${VAL}" ]
then
HERE=`pwd`
rc_nohalt "mkdir -p ${FSMNT}/${PKGTMPDIR}"
rc_nohalt "cd ${FSMNT}/${PKGTMPDIR}"
if [ ! -f "${CONFDIR}/INDEX" ]
# Nothing to do?
if [ -z "${VAL}" ]; then return; fi
echo "Installing packages..."
sleep 3
local PKGPTH
HERE=`pwd`
rc_halt "mkdir -p ${FSMNT}${PKGTMPDIR}"
# Determine the directory we will install packages from
get_package_location
rc_halt "cd ${PKGDLDIR}"
# Set the location of the INDEXFILE
INDEXFILE="${TMPDIR}/INDEX"
if [ ! -f "${INDEXFILE}" ]; then
get_package_index
fi
if [ ! -f "${TMPDIR}/INDEX.parsed" -a "$INSTALLMEDIUM" = "ftp" ]; then
parse_package_index
fi
# What extension are we using for pkgs?
PKGEXT="txz"
get_value_from_cfg pkgExt
if [ -n "${VAL}" ]; then
strip_white_space ${VAL}
PKGEXT="$VAL"
fi
export PKGEXT
# We dont want to be bothered with scripts asking questions
PACKAGE_BUILDING=yes
export PACKAGE_BUILDING
# Lets start by cleaning up the string and getting it ready to parse
get_value_from_cfg_with_spaces installPackages
PACKAGES="${VAL}"
echo_log "Packages to install: `echo $PACKAGES | wc -w | awk '{print $1}'`"
for i in $PACKAGES
do
if ! get_package_name "${i}"
then
get_package_index
echo_log "Unable to locate package ${i}"
continue
fi
if [ ! -f "${CONFDIR}/INDEX.parsed" ]
then
parse_package_index
PKGNAME="${VAL}"
# Fetch package + deps, but skip if installing from local media
if [ "${INSTALLMEDIUM}" = "ftp" ] ; then
DEPFILE="${FSMNT}/${PKGTMPDIR}/.${PKGNAME}.deps"
rc_nohalt "touch ${DEPFILE}"
determine_package_dependencies "${PKGNAME}" "${DEPFILE}"
fetch_package_dependencies "${DEPFILE}" "${FSMNT}/${PKGTMPDIR}"
fi
# Lets start by cleaning up the string and getting it ready to parse
strip_white_space ${VAL}
PACKAGES=`echo ${VAL} | sed -e "s|,| |g"`
for i in $PACKAGES
do
if get_package_name "${i}"
then
PKGNAME="${VAL}"
DEPFILE="${FSMNT}/${PKGTMPDIR}/.${PKGNAME}.deps"
# Set package location
case "${INSTALLMEDIUM}" in
usb|dvd|local) PKGPTH="${PKGTMPDIR}/All/${PKGNAME}" ;;
*) PKGPTH="${PKGTMPDIR}/${PKGNAME}" ;;
esac
rc_nohalt "touch ${DEPFILE}"
determine_package_dependencies "${PKGNAME}" "${DEPFILE}"
fetch_package_dependencies "${DEPFILE}" "${FSMNT}/${PKGTMPDIR}"
# If the package is not already installed, install it!
if ! run_chroot_cmd "pkg_info -e ${PKGNAME}"
then
rc_nohalt "pkg_add -C ${FSMNT} ${PKGTMPDIR}/${PKGNAME}.tbz"
fi
rc_nohalt "rm ${DEPFILE}"
# See if we need to determine the package format we are working with
if [ -z "${PKGINFO}" ] ; then
tar tqf "${FSMNT}${PKGPTH}" '+MANIFEST' >/dev/null 2>/dev/null
if [ $? -ne 0 ] ; then
PKGADD="pkg_add -C ${FSMNT}"
PKGINFO="pkg_info"
else
PKGADD="pkg -c ${FSMNT} add"
PKGINFO="pkg info"
bootstrap_pkgng
fi
fi
rc_nohalt "cd ${HERE}"
done
# If the package is not already installed, install it!
if ! run_chroot_cmd "${PKGINFO} -e ${PKGNAME}" >/dev/null 2>/dev/null
then
echo_log "Installing package: ${PKGNAME}"
rc_nohalt "${PKGADD} ${PKGPTH}"
fi
rm -rf "${FSMNT}/${PKGTMPDIR}"
if [ "${INSTALLMEDIUM}" = "ftp" ] ; then
rc_nohalt "rm ${DEPFILE}"
fi
done
echo_log "Package installation complete!"
# Cleanup after ourselves
rc_halt "cd ${HERE}"
if [ "${INSTALLMEDIUM}" = "ftp" ] ; then
rc_halt "rm -rf ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null
else
rc_halt "umount ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null
rc_halt "rmdir ${FSMNT}${PKGTMPDIR}" >/dev/null 2>/dev/null
fi
};

View File

@ -149,12 +149,12 @@ mount_all_filesystems()
for PART in `ls ${PARTDIR}`
do
PARTDEV=`echo $PART | sed 's|-|/|g'`
if [ ! -e "${PARTDEV}" ]
PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
if [ ! -e "${PARTDEV}" -a "${PARTFS}" != "ZFS" ]
then
exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?"
fi
PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"
@ -186,12 +186,12 @@ mount_all_filesystems()
for PART in `ls ${PARTDIR}`
do
PARTDEV=`echo $PART | sed 's|-|/|g'`
if [ ! -e "${PARTDEV}" ]
PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
if [ ! -e "${PARTDEV}" -a "${PARTFS}" != "ZFS" ]
then
exit_err "ERROR: The partition ${PARTDEV} does not exist. Failure in bsdlabel?"
fi
PARTFS="`cat ${PARTDIR}/${PART} | cut -d '#' -f 1`"
PARTMNT="`cat ${PARTDIR}/${PART} | cut -d '#' -f 2`"
PARTENC="`cat ${PARTDIR}/${PART} | cut -d '#' -f 3`"

View File

@ -60,18 +60,56 @@ setup_zfs_filesystem()
fi
done
# Check if we have some custom zpool arguments and use them if so
if [ ! -z "${ZPOOLOPTS}" ] ; then
rc_halt "zpool create -m none -f ${ZPOOLNAME} ${ZPOOLOPTS}"
# Sort through devices and run gnop on them
local gnopDev=""
local newOpts=""
for i in $ZPOOLOPTS
do
echo "$i" | grep -q '/dev/'
if [ $? -eq 0 ] ; then
rc_halt "gnop create -S 4096 ${i}"
gnopDev="$gnopDev $i"
newOpts="$newOpts ${i}.nop"
else
newOpts="$newOpts $i"
fi
done
echo_log "Creating zpool ${ZPOOLNAME} with $newOpts"
rc_halt "zpool create -m none -f ${ZPOOLNAME} ${newOpts}"
# Export the pool
rc_halt "zpool export ${ZPOOLNAME}"
# Destroy the gnop devices
for i in $gnopDev
do
rc_halt "gnop destroy ${i}.nop"
done
# And lastly re-import the pool
rc_halt "zpool import ${ZPOOLNAME}"
else
# Lets do our pseudo-4k drive
rc_halt "gnop create -S 4096 ${PART}${EXT}"
# No zpool options, create pool on single device
rc_halt "zpool create -m none -f ${ZPOOLNAME} ${PART}${EXT}"
echo_log "Creating zpool ${ZPOOLNAME} on ${PART}${EXT}"
rc_halt "zpool create -m none -f ${ZPOOLNAME} ${PART}${EXT}.nop"
# Finish up the gnop 4k trickery
rc_halt "zpool export ${ZPOOLNAME}"
rc_halt "gnop destroy ${PART}${EXT}.nop"
rc_halt "zpool import ${ZPOOLNAME}"
fi
# Disable atime for this zfs partition, speed increase
rc_nohalt "zfs set atime=off ${ZPOOLNAME}"
};
# Runs newfs on all the partiions which we've setup with bsdlabel

View File

@ -45,9 +45,11 @@ get_package_index_by_ftp()
then
INDEX_FILE="${INDEX_FILE}.bz2"
USE_BZIP2=1
INDEX_PATH="${INDEXFILE}.bz2"
else
INDEX_PATH="${INDEXFILE}"
fi
INDEX_PATH="${CONFDIR}/${INDEX_FILE}"
fetch_file "${FTP_SERVER}/${INDEX_FILE}" "${INDEX_PATH}" "1"
if [ -f "${INDEX_PATH}" ] && [ "${USE_BZIP2}" -eq "1" ]
then
@ -57,17 +59,18 @@ get_package_index_by_ftp()
get_package_index_by_fs()
{
local INDEX_FILE
INDEX_FILE="${CDMNT}/packages/INDEX"
fetch_file "${INDEX_FILE}" "${CONFDIR}/" "0"
if [ "$INSTALLMEDIUM" = "local" ] ; then
INDEXFILE="${LOCALPATH}/packages/INDEX"
else
INDEXFILE="${CDMNT}/packages/INDEX"
fi
};
get_package_index_size()
{
if [ -f "${CONFDIR}/INDEX" ]
if [ -f "${INDEXFILE}" ]
then
SIZE=`ls -l ${CONFDIR}/INDEX | awk '{ print $5 }'`
SIZE=`ls -l ${INDEXFILE} | awk '{ print $5 }'`
else
get_ftp_mirror
FTPHOST="${VAL}"
@ -94,28 +97,24 @@ get_package_index()
get_package_index_by_ftp "${FTPPATH}"
else
get_value_from_cfg ftpHost
if [ -z "$VAL" ]
then
exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
fi
FTPHOST="${VAL}"
get_value_from_cfg ftpDir
if [ -z "$VAL" ]
then
exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
fi
FTPDIR="${VAL}"
FTPPATH="ftp://${FTPHOST}${FTPDIR}"
case "${INSTALLMEDIUM}" in
usb|dvd) get_package_index_by_fs ;;
ftp) get_package_index_by_ftp "${FTPPATH}" ;;
sftp) ;;
*) RES=1 ;;
usb|dvd|local) get_package_index_by_fs ;;
ftp) get_value_from_cfg ftpHost
if [ -z "$VAL" ]; then
exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
fi
FTPHOST="${VAL}"
get_value_from_cfg ftpDir
if [ -z "$VAL" ]; then
exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
fi
FTPDIR="${VAL}"
FTPPATH="ftp://${FTPHOST}${FTPDIR}"
get_package_index_by_ftp "${FTPPATH}" ;;
sftp) ;;
*) RES=1 ;;
esac
fi
@ -125,10 +124,11 @@ get_package_index()
parse_package_index()
{
echo_log "Building package dep list.. Please wait.."
INDEX_FILE="${PKGDIR}/INDEX"
exec 3<&0
exec 0<"${INDEX_FILE}"
exec 0<"${INDEXFILE}"
while read -r line
do
@ -257,20 +257,38 @@ get_package_name()
{
PACKAGE="${1}"
RES=0
local PKGPTH
INDEX_FILE="${PKGDIR}/INDEX.deps"
REGEX="^${PACKAGE}|"
# If we are on a local medium, we can parse the Latest/ directory
if [ "${INSTALLMEDIUM}" != "ftp" ] ; then
case "${INSTALLMEDIUM}" in
usb|dvd) PKGPTH="${CDMNT}/packages" ;;
*) PKGPTH="${LOCALPATH}/packages" ;;
esac
# Check the /Latest dir for generic names, then look for specific version in All/
if [ -e "${PKGPTH}/Latest/${PACKAGE}.${PKGEXT}" ] ; then
NAME=`ls -al ${PKGPTH}/Latest/${PACKAGE}.${PKGEXT} 2>/dev/null | cut -d '>' -f 2 | rev | cut -f1 -d'/' | rev | tr -s ' '`
else
NAME=`ls -al ${PKGPTH}/All/${PACKAGE}.${PKGEXT} 2>/dev/null | cut -d '>' -f 2 | rev | cut -f1 -d'/' | rev | tr -s ' '`
fi
export VAL="${NAME}"
else
# Doing remote fetch, we we will look up, but some generic names like
# "perl" wont work, since we don't know the default version
INDEX_FILE="${PKGDIR}/INDEX.deps"
REGEX="^${PACKAGE}|"
LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
NAME=`echo "${LINE}"|cut -f2 -d'|'`
LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
NAME=`echo "${LINE}"|cut -f2 -d'|'`
export VAL="${NAME}"
export VAL="${NAME}"
fi
if [ -z "${VAL}" ]
then
RES=1
fi
return ${RES}
};
@ -334,7 +352,7 @@ fetch_package_by_ftp()
fi
FTPDIR="${VAL}"
PACKAGE="${PACKAGE}.tbz"
PACKAGE="${PACKAGE}.${PKGEXT}"
FTP_SERVER="ftp://${FTPHOST}${FTPDIR}"
if [ ! -f "${SAVEDIR}/${PACKAGE}" ]
@ -345,28 +363,49 @@ fetch_package_by_ftp()
fi
};
fetch_package_by_fs()
{
CATEGORY="${1}"
PACKAGE="${2}"
SAVEDIR="${3}"
PACKAGE="${PACKAGE}.tbz"
if [ ! -f "${SAVEDIR}/${PACKAGE}" ]
then
fetch_file "${CDMNT}/packages/${CATEGORY}/${PACKAGE}" "${SAVEDIR}/" "0"
fi
};
fetch_package()
{
CATEGORY="${1}"
PACKAGE="${2}"
SAVEDIR="${3}"
# Fetch package, but skip if installing from local media
case "${INSTALLMEDIUM}" in
usb|dvd) fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
usb|dvd|local) return ;;
ftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
sftp) ;;
esac
};
bootstrap_pkgng()
{
# Check if we need to boot-strap pkgng
if run_chroot_cmd "which pkg-static" >/dev/null 2>/dev/null
then
return
fi
local PKGPTH
# Ok, lets boot-strap this sucker
echo_log "Bootstraping pkgng.."
fetch_package "Latest" "pkg" "${PKGDLDIR}"
# Figure out real location of "pkg" package
case "${INSTALLMEDIUM}" in
usb|dvd|local) PKGPTH="${PKGTMPDIR}/Latest/pkg.${PKGEXT}" ;;
*) PKGPTH="${PKGTMPDIR}/pkg.${PKGEXT}" ;;
esac
rc_halt "pkg -c ${FSMNT} add ${PKGPTH}" ; run_chroot_cmd "pkg2ng"
}
get_package_location()
{
case "${INSTALLMEDIUM}" in
usb|dvd) rc_halt "mount_nullfs ${CDMNT}/packages ${FSMNT}${PKGTMPDIR}"
PKGDLDIR="${FSMNT}${PKGTMPDIR}/All" ;;
local) rc_halt "mount_nullfs ${LOCALPATH}/packages ${FSMNT}${PKGTMPDIR}"
PKGDLDIR="${FSMNT}${PKGTMPDIR}/All" ;;
*) PKGDLDIR="${FSMNT}${PKGTMPDIR}" ;;
esac
export PKGDLDIR
}

View File

@ -277,7 +277,11 @@ get_zpool_name()
while :
do
NEWNAME="${BASENAME}${NUM}"
zpool import | grep -qw "${NEWNAME}" || break
zpool list | grep -qw "${NEWNAME}"
local chk1=$?
zpool import | grep -qw "${NEWNAME}"
local chk2=$?
if [ $chk1 -eq 1 -a $chk2 -eq 1 ] ; then break ; fi
NUM=$((NUM+1))
done

View File

@ -5,11 +5,9 @@
TMPDIR="/tmp/.pc-sysinstall"
export TMPDIR
if [ ! -d "${TMPDIR}" ]
then
mkdir -p ${TMPDIR}
chmod 777 ${TMPDIR}
fi
# Create a fresh TMPDIR
if [ -d "${TMPDIR}" -a "$TMPDIR" != '/' ]; then rm -rf ${TMPDIR}; fi
mkdir -p ${TMPDIR}
# Set our temp directory for storing partition information
PARTDIR="${TMPDIR}/part-info"