From d59dd76c224fe6d8d156a02d5694f286fb3dbc1f Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Mon, 16 May 2011 23:20:12 +0000 Subject: [PATCH 01/31] Merge r221278 from largeSMP project: idle_cpus_mask is just used in sched_4bsd, thus make it private for it. Tested by: several --- sys/kern/sched_4bsd.c | 2 ++ sys/kern/subr_smp.c | 1 - sys/sys/smp.h | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/sched_4bsd.c b/sys/kern/sched_4bsd.c index 9424f73d2d8..668ecd165e5 100644 --- a/sys/kern/sched_4bsd.c +++ b/sys/kern/sched_4bsd.c @@ -155,6 +155,8 @@ static struct runq runq; */ static struct runq runq_pcpu[MAXCPU]; long runq_length[MAXCPU]; + +static cpumask_t idle_cpus_mask; #endif struct pcpuidlestat { diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 9ae63810f72..aba6f0e1ea7 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$"); #ifdef SMP volatile cpumask_t stopped_cpus; volatile cpumask_t started_cpus; -cpumask_t idle_cpus_mask; cpumask_t hlt_cpus_mask; cpumask_t logical_cpus_mask; diff --git a/sys/sys/smp.h b/sys/sys/smp.h index 6104d3e2242..544cb9575f9 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -73,7 +73,6 @@ extern int smp_active; extern int smp_cpus; extern volatile cpumask_t started_cpus; extern volatile cpumask_t stopped_cpus; -extern cpumask_t idle_cpus_mask; extern cpumask_t hlt_cpus_mask; extern cpumask_t logical_cpus_mask; #endif /* SMP */ From 7c1b3c092065a2522eab5aec906676b4bb479fcf Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Mon, 16 May 2011 23:35:14 +0000 Subject: [PATCH 02/31] Merge r221279,221280 from largeSMP project: pmc_mask doesn't need to use memory barriers. Reviewed by: fabient Tested by: several MFC after: 1 week --- sys/dev/hwpmc/hwpmc_mod.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c index 4fa169c6b34..d6225d8f5ae 100644 --- a/sys/dev/hwpmc/hwpmc_mod.c +++ b/sys/dev/hwpmc/hwpmc_mod.c @@ -4083,7 +4083,7 @@ pmc_process_interrupt(int cpu, struct pmc *pm, struct trapframe *tf, done: /* mark CPU as needing processing */ - atomic_set_rel_int(&pmc_cpumask, (1 << cpu)); + atomic_set_int(&pmc_cpumask, (1 << cpu)); return (error); } @@ -4193,7 +4193,7 @@ pmc_process_samples(int cpu) break; if (ps->ps_nsamples == PMC_SAMPLE_INUSE) { /* Need a rescan at a later time. */ - atomic_set_rel_int(&pmc_cpumask, (1 << cpu)); + atomic_set_int(&pmc_cpumask, (1 << cpu)); break; } @@ -4782,7 +4782,7 @@ pmc_cleanup(void) PMCDBG(MOD,INI,0, "%s", "cleanup"); /* switch off sampling */ - atomic_store_rel_int(&pmc_cpumask, 0); + pmc_cpumask = 0; pmc_intr = NULL; sx_xlock(&pmc_sx); From c43431465e547c3f81c10553710a2aaf6068301e Mon Sep 17 00:00:00 2001 From: Navdeep Parhar Date: Tue, 17 May 2011 00:40:11 +0000 Subject: [PATCH 03/31] Add missing header. The test for VLAN_CAPABILITIES later in the file doesn't make sense without it. MFC after: 3 days --- sys/dev/cxgbe/t4_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 929f31b06de..e336566d380 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "common/t4_hw.h" #include "common/common.h" From eb05ee7a71ff589e31ef69e6efae5009ee891d04 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 17 May 2011 06:36:32 +0000 Subject: [PATCH 04/31] Don't expect PAGE_SIZE to exist on all platforms (It is a pretty arbitrary choice of default size in the first place) Reverse the order of arguments to the internal static sbuf_put_byte() function to match everything else in this file. Move sbuf_putc_func() inside the kernel version of sbuf_vprintf where it belongs. sbuf_putc() incorrectly used sbuf_putc_func() which supress NUL characters, it should use sbuf_put_byte(). Make sbuf_finish() return -1 on error. Minor stylistic nits fixed. --- sys/kern/subr_sbuf.c | 60 ++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c index 793e17ec4eb..bf4e73c0f03 100644 --- a/sys/kern/subr_sbuf.c +++ b/sys/kern/subr_sbuf.c @@ -67,7 +67,7 @@ static MALLOC_DEFINE(M_SBUF, "sbuf", "string buffers"); #define SBUF_ISDYNSTRUCT(s) ((s)->s_flags & SBUF_DYNSTRUCT) #define SBUF_ISFINISHED(s) ((s)->s_flags & SBUF_FINISHED) #define SBUF_HASROOM(s) ((s)->s_len < (s)->s_size - 1) -#define SBUF_FREESPACE(s) ((s)->s_size - (s)->s_len - 1) +#define SBUF_FREESPACE(s) ((s)->s_size - ((s)->s_len + 1)) #define SBUF_CANEXTEND(s) ((s)->s_flags & SBUF_AUTOEXTEND) /* @@ -77,8 +77,14 @@ static MALLOC_DEFINE(M_SBUF, "sbuf", "string buffers"); #define SBUF_CLEARFLAG(s, f) do { (s)->s_flags &= ~(f); } while (0) #define SBUF_MINEXTENDSIZE 16 /* Should be power of 2. */ + +#ifdef PAGE_SIZE #define SBUF_MAXEXTENDSIZE PAGE_SIZE #define SBUF_MAXEXTENDINCR PAGE_SIZE +#else +#define SBUF_MAXEXTENDSIZE 4096 +#define SBUF_MAXEXTENDINCR 4096 +#endif /* * Debugging support @@ -328,7 +334,7 @@ sbuf_drain(struct sbuf *s) * buffer and marking overflow. */ static void -sbuf_put_byte(int c, struct sbuf *s) +sbuf_put_byte(struct sbuf *s, int c) { assert_sbuf_integrity(s); @@ -337,7 +343,7 @@ sbuf_put_byte(int c, struct sbuf *s) if (s->s_error != 0) return; if (SBUF_FREESPACE(s) <= 0) { - /* + /* * If there is a drain, use it, otherwise extend the * buffer. */ @@ -351,18 +357,6 @@ sbuf_put_byte(int c, struct sbuf *s) s->s_buf[s->s_len++] = c; } -/* - * Append a non-NUL character to an sbuf. This prototype signature is - * suitable for use with kvprintf(9). - */ -static void -sbuf_putc_func(int c, void *arg) -{ - - if (c != '\0') - sbuf_put_byte(c, arg); -} - /* * Append a byte string to an sbuf. */ @@ -378,10 +372,10 @@ sbuf_bcat(struct sbuf *s, const void *buf, size_t len) if (s->s_error != 0) return (-1); for (; str < end; str++) { - sbuf_put_byte(*str, s); + sbuf_put_byte(s, *str); if (s->s_error != 0) return (-1); - } + } return (0); } @@ -443,7 +437,7 @@ sbuf_cat(struct sbuf *s, const char *str) return (-1); while (*str != '\0') { - sbuf_put_byte(*str++, s); + sbuf_put_byte(s, *str++); if (s->s_error != 0) return (-1); } @@ -507,6 +501,19 @@ sbuf_cpy(struct sbuf *s, const char *str) * Format the given argument list and append the resulting string to an sbuf. */ #ifdef _KERNEL + +/* + * Append a non-NUL character to an sbuf. This prototype signature is + * suitable for use with kvprintf(9). + */ +static void +sbuf_putc_func(int c, void *arg) +{ + + if (c != '\0') + sbuf_put_byte(arg, c); +} + int sbuf_vprintf(struct sbuf *s, const char *fmt, va_list ap) { @@ -611,7 +618,7 @@ int sbuf_putc(struct sbuf *s, int c) { - sbuf_putc_func(c, s); + sbuf_put_byte(s, c); if (s->s_error != 0) return (-1); return (0); @@ -654,24 +661,23 @@ sbuf_error(const struct sbuf *s) int sbuf_finish(struct sbuf *s) { - int error; assert_sbuf_integrity(s); assert_sbuf_state(s, 0); - error = s->s_error; if (s->s_drain_func != NULL) { - while (s->s_len > 0 && error == 0) - error = sbuf_drain(s); + while (s->s_len > 0 && s->s_error == 0) + s->s_error = sbuf_drain(s); } s->s_buf[s->s_len] = '\0'; - s->s_error = 0; SBUF_SETFLAG(s, SBUF_FINISHED); #ifdef _KERNEL - return (error); + return (s->s_error); #else - errno = error; - return (-1); + errno = s->s_error; + if (s->s_error) + return (-1); + return (0); #endif } From 88492dfb20fb0b7c880af51ead18875f83e35731 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Tue, 17 May 2011 07:40:13 +0000 Subject: [PATCH 05/31] Remove redundant keywords. Submitted by: wxs --- etc/rc.d/ipfilter | 2 +- etc/rc.d/pf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/rc.d/ipfilter b/etc/rc.d/ipfilter index fd1e99bbe08..b6bdb4bcb2e 100755 --- a/etc/rc.d/ipfilter +++ b/etc/rc.d/ipfilter @@ -23,7 +23,7 @@ resync_precmd="$stop_precmd" resync_cmd="ipfilter_resync" status_precmd="$stop_precmd" status_cmd="ipfilter_status" -extra_commands="reload resync status" +extra_commands="reload resync" required_modules="ipl:ipfilter" ipfilter_start() diff --git a/etc/rc.d/pf b/etc/rc.d/pf index 3426e90f413..3180a2c5183 100755 --- a/etc/rc.d/pf +++ b/etc/rc.d/pf @@ -19,7 +19,7 @@ check_cmd="pf_check" reload_cmd="pf_reload" resync_cmd="pf_resync" status_cmd="pf_status" -extra_commands="check reload resync status" +extra_commands="check reload resync" required_files="$pf_rules" required_modules="pf" From b7f54343cc5c4e9c4c354fae11f18318420e5b20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Tue, 17 May 2011 08:12:59 +0000 Subject: [PATCH 06/31] Typos, wording and mdoc fixes. --- share/man/man4/geom_map.4 | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/share/man/man4/geom_map.4 b/share/man/man4/geom_map.4 index 3d65dcd7650..36a5b419b66 100644 --- a/share/man/man4/geom_map.4 +++ b/share/man/man4/geom_map.4 @@ -30,7 +30,7 @@ .Os .Sh NAME .Nm geom_map -.Nd "GEOM module that map difined items as separate partitions" +.Nd "GEOM module that maps defined items as separate partitions" .Sh SYNOPSIS To compile this driver into the kernel, place the following line in your @@ -41,16 +41,16 @@ kernel configuration file: .Sh DESCRIPTION The .Nm -framework provides support for mapping defined parts of the media. Basicaly it -is helpful in the embedded devices where in the one continous flash are loader, -kernel and rootfs parts. The +framework provides support for mapping defined parts of the media. +Basically it is helpful for embedded devices where in the one continuous +flash are loader, kernel and rootfs parts. .Nm -allows making them available as separate parts and protect loader from -overwriting. +allows making them available as separate parts and protects the loader from +being overwritten. .Pp At boot time .Nm -partitions listed (only with bootverbose) as: +partitions are listed (only with bootverbose) as: .Bd -literal -offset indent MAP: 0x30000, data=0x30000 "/dev/map/bootloader" MAP: 30000x10000, data=0x10000 "/dev/map/factory" @@ -62,10 +62,12 @@ MAP: 150000x690000, data=0x690000 "/dev/map/rootfs" MAP: 7e0000x20000, data=0x20000 "/dev/map/config" .Ed .Pp -Also +The current .Nm -current configuration can be accessible with sysctl's kern.geom.conftxt, -kern.geom.confxml, kern.geom.confdot or geom map list. +configuration can be accessed with the following +.Xr sysctl 8 +nodes: kern.geom.conftxt, kern.geom.confxml, and kern.geom.confdot +or by using "geom map list". .Bd -literal -offset indent # sysctl kern.geom.conftxt kern.geom.conftxt: 0 MD md0 10485760 512 u 0 s 512 f 0 fs 0 l 10485760 t malloc @@ -84,7 +86,7 @@ Driver configuration can be done in device hints file. List of used parameters: .It Fa at select media to attach .It Fa name -name of partiton (will create device /dev/map/that_name) +name of partition (will create device /dev/map/that_name) .It Fa start offset from the beginning of the parent media to start of the mapped partition. This field can also have special value @@ -119,9 +121,7 @@ MAP: 150000x690000, data=0x690000 "/dev/map/rootfs" "map/rootfs" - new media will be accessible via /dev/map/rootfs dev. .Ed .Sh EXAMPLES -.Pp -.Bl -bullet -compact -If we need to implement layout shown above, we need to define the folowing +If we need to implement layout shown above, we need to define the following hints: .Bd -literal -offset indent hint.map.0.at="cfid0" @@ -129,8 +129,8 @@ hint.map.0.start=0x00000000 hint.map.0.end=0x00030000 hint.map.0.name="bootloader" hint.map.0.readonly=1 - .Ed +.Pp define "/dev/map/bootloader" at disk "cfid0" starting at 0x00000000 and end 0x00030000, also marked as readonly. .Bd -literal -offset indent @@ -148,8 +148,8 @@ hint.map.3.at="cfid0" hint.map.3.name="kernel" hint.map.3.start=0x00040000 hint.map.3.end="search:0x00100000:0x10000:.!/bin/sh" - .Ed +.Pp define "/dev/map/kernel" at disk "cfid0" starting at 0x00040000, but end position must be searched by the key ".!/bin/sh", from offset 0x00100000 to end of media with step 0x10000. Real marker in that case is "#!/bin/sh", but "#" @@ -166,7 +166,6 @@ hint.map.5.start=0x007e0000 hint.map.5.end=0x00800000 hint.map.5.name="config" .Ed -.El .Sh SEE ALSO .Xr GEOM 4 , .Xr geom 8 , From f93fa1cb17fcd1fa2b144205f3b67e5b7bddb7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Tue, 17 May 2011 08:13:10 +0000 Subject: [PATCH 07/31] Typo fix. --- share/man/man4/cc_hd.4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man4/cc_hd.4 b/share/man/man4/cc_hd.4 index d761539d14d..5c4c2deb92a 100644 --- a/share/man/man4/cc_hd.4 +++ b/share/man/man4/cc_hd.4 @@ -98,7 +98,7 @@ Community Foundation Silicon Valley. .Sh FUTURE WORK The Hamilton Institute have recently made some improvements to the algorithm implemented by this module and have called it Coexistent-TCP (C-TCP). -The improvments should be evaluated and potentially incorporated into this +The improvements should be evaluated and potentially incorporated into this module. .Sh HISTORY The From 60134116ed3b7bd40cbd1310d2c5fddf1ee1e8f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Tue, 17 May 2011 08:13:18 +0000 Subject: [PATCH 08/31] Whitespace and typo fixes. Found by: codespell Reviewed by: ru --- share/misc/iso3166 | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/share/misc/iso3166 b/share/misc/iso3166 index 70ca84f497b..b01fe149a0a 100644 --- a/share/misc/iso3166 +++ b/share/misc/iso3166 @@ -395,7 +395,7 @@ ZW ZWE 716 Zimbabwe # Newsletter III-41 1993-07-28 # MAURITIUS, changes outside this document # -# Newletter III-42 1993-07-12 +# Newsletter III-42 1993-07-12 # SAINT VINCENT AND THE GRENADINES, changes outside this document # # Newsletter III-43 1993-07-12 @@ -426,15 +426,15 @@ ZW ZWE 716 Zimbabwe # Czechoslovakia officially deleted # # Newsletter III-52, 1993-07-02 -# Angola, changing information not included in this file. Offical name +# Angola, changing information not included in this file. Official name # change to Republic of Angola # # Newsletter III-53, 1993-07-12 -# Madagascar, changing information not included in this file. Official +# Madagascar, changing information not included in this file. Official # name change to Republic of Madagascar # # Newsletter III-54, 1993-07-23 -# South Georgia and the South Sandwich Islands, previously covered by +# South Georgia and the South Sandwich Islands, previously covered by # Falkland Islands # # Newsletter III-55, 1993-07-16 @@ -450,23 +450,23 @@ ZW ZWE 716 Zimbabwe # # Newsletter III-58, 1993-07-16 # Afghanistan, changing information not included in this file -# Official name change to Islamic State of Afghanistan +# Official name change to Islamic State of Afghanistan # -# Newsletter III-32, 1993-07-25 ammendment -# Kyrgyzstan, changing information not included in this file. Offical name +# Newsletter III-32, 1993-07-25 amendment +# Kyrgyzstan, changing information not included in this file. Official name # change to Kyrgyz Republic # # Newsletter III-59, 1994-01-26 -# Andorra, changing information not included in this file. Offical name +# Andorra, changing information not included in this file. Official name # change to Pricipality of Andorra # # Newsletter III-60, 1994-01-26 -# Cambodia, changing information not included in this file. Offical name +# Cambodia, changing information not included in this file. Official name # change to Kingdom of Cambodia # # Thu Feb 10 1994 # At this point the fourth edition of ISO 3166 appears. It can *now* be -# ordered from national standards institutions. The RIPE NCC will continue +# ordered from national standards institutions. The RIPE NCC will continue # tracking changes. # # [deletia] From f8037af57c43cbb1bd4764bb15f33e902a9dd5ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Tue, 17 May 2011 08:13:27 +0000 Subject: [PATCH 09/31] ISO3166: Update for newsletters VI-7 and VI-8 from 2010 - Name change for SH - BQ, CW, and SX replace AN Reviewed by: ru --- share/misc/iso3166 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/share/misc/iso3166 b/share/misc/iso3166 index b01fe149a0a..45c4d0ba70c 100644 --- a/share/misc/iso3166 +++ b/share/misc/iso3166 @@ -46,6 +46,7 @@ BJ BEN 204 Benin BM BMU 060 Bermuda BT BTN 064 Bhutan BO BOL 068 Bolivia, Plurinational State of +BQ BES 535 Bonaire, Saint Eustatius and Saba BA BIH 070 Bosnia and Herzegovina BW BWA 072 Botswana BV BVT 074 Bouvet Island @@ -75,6 +76,7 @@ CR CRI 188 Costa Rica CI CIV 384 Cote d'Ivoire HR HRV 191 Croatia CU CUB 192 Cuba +CW CUW 531 Curacao CY CYP 196 Cyprus CZ CZE 203 Czech Republic DK DNK 208 Denmark @@ -174,7 +176,6 @@ NA NAM 516 Namibia NR NRU 520 Nauru NP NPL 524 Nepal NL NLD 528 Netherlands -AN ANT 530 Netherlands Antilles NC NCL 540 New Caledonia NZ NZL 554 New Zealand NI NIC 558 Nicaragua @@ -216,6 +217,7 @@ RS SRB 688 Serbia SC SYC 690 Seychelles SL SLE 694 Sierra Leone SG SGP 702 Singapore +SX SXM 534 Sint Maarten (Dutch part) SK SVK 703 Slovakia SI SVN 705 Slovenia SB SLB 090 Solomon Islands @@ -224,7 +226,7 @@ ZA ZAF 710 South Africa GS SGS 239 South Georgia and the South Sandwich Islands ES ESP 724 Spain LK LKA 144 Sri Lanka -SH SHN 654 Saint Helena +SH SHN 654 Saint Helena, Ascension and Tristan da Cunha PM SPM 666 Saint Pierre and Miquelon SD SDN 736 Sudan SR SUR 740 Suriname @@ -537,3 +539,11 @@ ZW ZWE 716 Zimbabwe # # Newsletter VI-6 2009-05-08 # Name change for Plurinational State of Bolivia. +# +# Newsletter VI-7 2010-02-22 +# Name change for Saint Helena, Ascension and Tristan da Cunha +# +# Newsletter VI-8 2010-12-15 +# BONAIRE, SAINT EUSTATIUS AND SABA (BQ), CURACAO (CW) and +# SINT MAARTEN (DUTCH PART) (SX) added as new entries. +# NETHERLANDS ANTILLES (AN) removed. From 1da306338fd86b13685dd5bd0028c784f5eac0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20Sp=C3=B6rlein?= Date: Tue, 17 May 2011 09:51:02 +0000 Subject: [PATCH 10/31] More thorough mdoc and language fixes. Submitted by: ru --- share/man/man4/geom_map.4 | 103 +++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 35 deletions(-) diff --git a/share/man/man4/geom_map.4 b/share/man/man4/geom_map.4 index 36a5b419b66..6af91be5d82 100644 --- a/share/man/man4/geom_map.4 +++ b/share/man/man4/geom_map.4 @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 5, 2011 +.Dd May 17, 2011 .Dt GEOM_MAP 4 .Os .Sh NAME @@ -66,11 +66,15 @@ The current .Nm configuration can be accessed with the following .Xr sysctl 8 -nodes: kern.geom.conftxt, kern.geom.confxml, and kern.geom.confdot -or by using "geom map list". +nodes: +.Va kern.geom.conftxt , kern.geom.confxml , +and +.Va kern.geom.confdot +or by using +.Dq Li "geom map list" . .Bd -literal -offset indent -# sysctl kern.geom.conftxt -kern.geom.conftxt: 0 MD md0 10485760 512 u 0 s 512 f 0 fs 0 l 10485760 t malloc +# sysctl -n kern.geom.conftxt +0 MD md0 10485760 512 u 0 s 512 f 0 fs 0 l 10485760 t malloc 0 DISK cfid0 8388608 4 hd 0 sc 0 1 MAP map/config 131072 4 i 5 o 8257536 entry 0 dsize 131072 1 MAP map/rootfs 6881280 4 i 4 o 1376256 entry 0 dsize 6881280 @@ -81,40 +85,48 @@ kern.geom.conftxt: 0 MD md0 10485760 512 u 0 s 512 f 0 fs 0 l 10485760 t malloc 1 MAP map/bootloader 196608 4 i 0 o 0 entry 0 dsize 196608 .Ed .Pp -Driver configuration can be done in device hints file. List of used parameters: +Driver configuration can be done in +.Xr device.hints 5 . +List of used parameters: .Bl -tag -width indent -.It Fa at +.It Va at select media to attach -.It Fa name -name of partition (will create device /dev/map/that_name) -.It Fa start +.It Va name +name of partition (will create device +.Pa /dev/map/ Ns Ar that_name ) +.It Va start offset from the beginning of the parent media to start of the mapped partition. -This field can also have special value -"search:searchstart:searchstep:searchkey", where: +This field can also have a special value +.Qq Li search: Ns Ar searchstart Ns Li : Ns Ar searchstep Ns Li : Ns Ar searchkey , +where: .Bl -tag -width indent -.It Fa searchstart +.It Ar searchstart offset from the beginning of the parent media where search will be started -.It Fa searchstep +.It Ar searchstep value of the increment used while searching for the partition boundary markers -.It Fa searchkey -key which will be used to find partition boundary markers. Wildcard "." char -can be used to match any char on that position +.It Ar searchkey +key which will be used to find partition boundary markers. +The wildcard +.Ql .\& +can be used to match any character on that position .El -.It Fa end -offset from the beginning of the parent media to end of the mapped partition. -This field can also have special value -"search:searchstart:searchstep:searchkey", look "start" for details. -.It Fa offset -offset where the data of mapped partition begins +.It Va end +offset from the beginning of the parent media to the end of the mapped partition. +This field can also have the special value +.Qq Li search: Ns Ar searchstart Ns Li : Ns Ar searchstep Ns Li : Ns Ar searchkey , +as described above. +.It Va offset +offset where the data of the mapped partition begins .El .Pp -Each record contains start address(bytes) from the media begin, size(bytes), -offset where the data of mapped partition begins, and the name of new device. +Each record contains the start address (in bytes) from the media begin, size +(in bytes), offset where the data of mapped partition begins, and the name of +new device. .Bd -literal -offset indent MAP: 150000x690000, data=0x690000 "/dev/map/rootfs" .Ed .Bd -literal -00150000 - begin address +00150000 - start address 00690000 - size 00000000 - data begin from zero offset 00690000 - data size @@ -131,8 +143,15 @@ hint.map.0.name="bootloader" hint.map.0.readonly=1 .Ed .Pp -define "/dev/map/bootloader" at disk "cfid0" starting at 0x00000000 and end -0x00030000, also marked as readonly. +This defines +.Pa /dev/map/bootloader +at disk +.Pa cfid0 +starting at +.Li 0x00000000 +and ending at +.Li 0x00030000 , +it is also marked as readonly. .Bd -literal -offset indent hint.map.1.at="cfid0" hint.map.1.start=0x00030000 @@ -150,11 +169,26 @@ hint.map.3.start=0x00040000 hint.map.3.end="search:0x00100000:0x10000:.!/bin/sh" .Ed .Pp -define "/dev/map/kernel" at disk "cfid0" starting at 0x00040000, but end -position must be searched by the key ".!/bin/sh", from offset 0x00100000 to end -of media with step 0x10000. Real marker in that case is "#!/bin/sh", but "#" -terminates the line when hints file is parsed, so we need to use wildcard "." -instead of "#". +This defines +.Pa /dev/map/kernel +at disk +.Pa cfid0 +starting at +.Li 0x00040000 , +but the end position must be searched by finding the key +.Dq Li ".!/bin/sh" , +from offset +.Li 0x00100000 +to the end of media with step +.Li 0x10000 . +The real marker in this case is +.Dq Li "#!/bin/sh" , +but +.Ql # +terminates the line when the hints file is parsed, so we need to use wildcard +.Ql .\& +instead of +.Ql # . .Bd -literal -offset indent hint.map.4.at="cfid0" hint.map.4.name="rootfs" @@ -167,11 +201,10 @@ hint.map.5.end=0x00800000 hint.map.5.name="config" .Ed .Sh SEE ALSO -.Xr GEOM 4 , +.Xr geom 4 , .Xr geom 8 , .Xr sysctl 8 .Sh AUTHORS -.An -nosplit The .Nm driver was written by From e61b0f4a3d1aa0526350fec3d8e3e951fdae931e Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Tue, 17 May 2011 10:38:44 +0000 Subject: [PATCH 11/31] Add missing section number for .Xr jail. MFC after: 3 days --- share/man/man5/rc.conf.5 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 16f247be81a..cf062c57c3b 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -3772,7 +3772,7 @@ Set to .Dq Li -l -U root by default. These are flags to pass to -.Xr jail . +.Xr jail 8 . .It Va jail_ Ns Ao Ar jname Ac Ns Va _interface .Pq Vt str Unset by default. From cf7d1a17c23aa891d9cfa04e3e87e0f0795fd0b4 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 17 May 2011 10:44:11 +0000 Subject: [PATCH 12/31] Revert change to "MF" I made in r189767. I bet that at the time of r189767 I checked with http://www.iso.org/iso/country_codes/iso_3166_code_lists.htm and "MF" was officially spelled in English as "Saint Martin" there, but now that "SX" exists (for "Sint Maarten (Dutch part)") (nice official "English" spelling!) they seem to have added a "(French part)" suffix to "MF". Since this is also in line with Newsletter VI-1 (2007-09-21), catch up. --- share/misc/iso3166 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/misc/iso3166 b/share/misc/iso3166 index 45c4d0ba70c..23c9bd65e31 100644 --- a/share/misc/iso3166 +++ b/share/misc/iso3166 @@ -206,7 +206,7 @@ RW RWA 646 Rwanda BL BLM 652 Saint Barthelemy KN KNA 659 Saint Kitts and Nevis LC LCA 662 Saint Lucia -MF MAF 663 Saint Martin +MF MAF 663 Saint Martin (French Part) VC VCT 670 Saint Vincent and the Grenadines WS WSM 882 Samoa SM SMR 674 San Marino From 384bf94c48a3d82e88f00737ebf4a68a5d51414e Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 17 May 2011 11:04:50 +0000 Subject: [PATCH 13/31] Use memset() instead of bzero() and memcpy() instead of bcopy(), there is no relevant difference for sbufs, and it increases portability of the source code. Split the actual initialization of the sbuf into a separate local function, so that certain static code checkers can understand what sbuf_new() does, thus eliminating on silly annoyance of MISRA compliance testing. Contributed by: An anonymous company in the last business I expected sbufs to invade. --- sys/kern/subr_sbuf.c | 69 +++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c index bf4e73c0f03..e931e655033 100644 --- a/sys/kern/subr_sbuf.c +++ b/sys/kern/subr_sbuf.c @@ -144,7 +144,6 @@ sbuf_extendsize(int size) return (newsize); } - /* * Extend an sbuf. */ @@ -160,7 +159,7 @@ sbuf_extend(struct sbuf *s, int addlen) newbuf = SBMALLOC(newsize); if (newbuf == NULL) return (-1); - bcopy(s->s_buf, newbuf, s->s_size); + memcpy(newbuf, s->s_buf, s->s_size); if (SBUF_ISDYNAMIC(s)) SBFREE(s->s_buf); else @@ -170,6 +169,38 @@ sbuf_extend(struct sbuf *s, int addlen) return (0); } +/* + * Initialize the internals of an sbuf. + * If buf is non-NULL, it points to a static or already-allocated string + * big enough to hold at least length characters. + */ +static struct sbuf * +sbuf_newbuf(struct sbuf *s, char *buf, int length, int flags) +{ + + memset(s, 0, sizeof(*s)); + s->s_flags = flags; + s->s_size = length; + s->s_buf = buf; + + if ((s->s_flags & SBUF_AUTOEXTEND) == 0) { + KASSERT(s->s_size > 1, + ("attempt to create a too small sbuf")); + } + + if (s->s_buf != NULL) + return (s); + + if ((flags & SBUF_AUTOEXTEND) != 0) + s->s_size = sbuf_extendsize(s->s_size); + + s->s_buf = SBMALLOC(s->s_size); + if (s->s_buf == NULL) + return (NULL); + SBUF_SETFLAG(s, SBUF_DYNAMIC); + return (s); +} + /* * Initialize an sbuf. * If buf is non-NULL, it points to a static or already-allocated string @@ -185,31 +216,17 @@ sbuf_new(struct sbuf *s, char *buf, int length, int flags) ("%s called with invalid flags", __func__)); flags &= SBUF_USRFLAGMSK; - if (s == NULL) { - s = SBMALLOC(sizeof(*s)); - if (s == NULL) - return (NULL); - bzero(s, sizeof(*s)); - s->s_flags = flags; - SBUF_SETFLAG(s, SBUF_DYNSTRUCT); - } else { - bzero(s, sizeof(*s)); - s->s_flags = flags; - } - s->s_size = length; - if (buf != NULL) { - s->s_buf = buf; - return (s); - } - if ((flags & SBUF_AUTOEXTEND) != 0) - s->s_size = sbuf_extendsize(s->s_size); - s->s_buf = SBMALLOC(s->s_size); - if (s->s_buf == NULL) { - if (SBUF_ISDYNSTRUCT(s)) - SBFREE(s); + if (s != NULL) + return (sbuf_newbuf(s, buf, length, flags)); + + s = SBMALLOC(sizeof(*s)); + if (s == NULL) + return (NULL); + if (sbuf_newbuf(s, buf, length, flags) == NULL) { + SBFREE(s); return (NULL); } - SBUF_SETFLAG(s, SBUF_DYNAMIC); + SBUF_SETFLAG(s, SBUF_DYNSTRUCT); return (s); } @@ -727,7 +744,7 @@ sbuf_delete(struct sbuf *s) if (SBUF_ISDYNAMIC(s)) SBFREE(s->s_buf); isdyn = SBUF_ISDYNSTRUCT(s); - bzero(s, sizeof(*s)); + memset(s, 0, sizeof(*s)); if (isdyn) SBFREE(s); } From 1562ef0218faf3566975ebfe95bbbb76940278c0 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 17 May 2011 11:06:41 +0000 Subject: [PATCH 14/31] Added description for WITH_OFED. --- tools/build/options/WITH_OFED | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tools/build/options/WITH_OFED diff --git a/tools/build/options/WITH_OFED b/tools/build/options/WITH_OFED new file mode 100644 index 00000000000..a995fb8cdab --- /dev/null +++ b/tools/build/options/WITH_OFED @@ -0,0 +1,4 @@ +.\" $FreeBSD$ +Set to build the +.Dq "OpenFabrics Enterprise Distribution" +Infiniband software stack. From ff7794059ea703f28fb7fac9499254bddbda52d9 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 17 May 2011 11:08:15 +0000 Subject: [PATCH 15/31] Regen for WITH_OFED. --- share/man/man5/src.conf.5 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5 index 134e4f310fb..acae4c03fc8 100644 --- a/share/man/man5/src.conf.5 +++ b/share/man/man5/src.conf.5 @@ -1,7 +1,7 @@ .\" DO NOT EDIT-- this file is automatically generated. .\" from FreeBSD: head/tools/build/options/makeman 221733 2011-05-10 13:01:11Z ru .\" $FreeBSD$ -.Dd May 10, 2011 +.Dd May 17, 2011 .Dt SRC.CONF 5 .Os .Sh NAME @@ -712,6 +712,11 @@ will not be built either if this option is set. Set to not build .Xr ntpd 8 and related programs. +.It Va WITH_OFED +.\" from FreeBSD: head/tools/build/options/WITH_OFED 222016 2011-05-17 11:06:41Z ru +Set to build the +.Dq "OpenFabrics Enterprise Distribution" +Infiniband software stack. .It Va WITHOUT_OPENSSH .\" from FreeBSD: head/tools/build/options/WITHOUT_OPENSSH 156932 2006-03-21 07:50:50Z ru Set to not build OpenSSH. From 934d7bccdbf4d67bce00c2469de596a6f5b53594 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 17 May 2011 11:23:43 +0000 Subject: [PATCH 16/31] Renamed PCI_INTERFACE_XHCI to PCIP_SERIALBUS_USB_XHCI and moved it to . Reviewed by: hselasky MFC after: 3 days --- sys/dev/pci/pcireg.h | 1 + sys/dev/usb/controller/xhci_pci.c | 2 +- sys/dev/usb/controller/xhcireg.h | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/dev/pci/pcireg.h b/sys/dev/pci/pcireg.h index db74809d531..216882c8336 100644 --- a/sys/dev/pci/pcireg.h +++ b/sys/dev/pci/pcireg.h @@ -367,6 +367,7 @@ #define PCIP_SERIALBUS_USB_UHCI 0x00 #define PCIP_SERIALBUS_USB_OHCI 0x10 #define PCIP_SERIALBUS_USB_EHCI 0x20 +#define PCIP_SERIALBUS_USB_XHCI 0x30 #define PCIP_SERIALBUS_USB_DEVICE 0xfe #define PCIS_SERIALBUS_FC 0x04 #define PCIS_SERIALBUS_SMBUS 0x05 diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhci_pci.c index 984ed39dcb0..40358bfa570 100644 --- a/sys/dev/usb/controller/xhci_pci.c +++ b/sys/dev/usb/controller/xhci_pci.c @@ -137,7 +137,7 @@ xhci_pci_match(device_t self) { if ((pci_get_class(self) == PCIC_SERIALBUS) && (pci_get_subclass(self) == PCIS_SERIALBUS_USB) - && (pci_get_progif(self) == PCI_INTERFACE_XHCI)) { + && (pci_get_progif(self) == PCIP_SERIALBUS_USB_XHCI)) { return ("XHCI (generic) USB 3.0 controller"); } return (NULL); /* dunno */ diff --git a/sys/dev/usb/controller/xhcireg.h b/sys/dev/usb/controller/xhcireg.h index fb2d1cad21e..71c5c284a17 100644 --- a/sys/dev/usb/controller/xhcireg.h +++ b/sys/dev/usb/controller/xhcireg.h @@ -33,7 +33,6 @@ #define PCI_XHCI_USBREV 0x60 /* RO USB protocol revision */ #define PCI_USB_REV_3_0 0x30 /* USB 3.0 */ #define PCI_XHCI_FLADJ 0x61 /* RW frame length adjust */ -#define PCI_INTERFACE_XHCI 0x30 /* USB 3.0 - XHCI */ /* XHCI capability registers */ #define XHCI_CAPLENGTH 0x00 /* RO capability */ From 1d40404b7bdd664a1eaf47664001eda386fefcf4 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Tue, 17 May 2011 11:26:59 +0000 Subject: [PATCH 17/31] Document the supported hardware, somewhat. Reviewed by: hselasky MFC after: 3 days --- share/man/man4/xhci.4 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/share/man/man4/xhci.4 b/share/man/man4/xhci.4 index 670d395b9b7..09f3185353c 100644 --- a/share/man/man4/xhci.4 +++ b/share/man/man4/xhci.4 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 24, 2011 +.Dd May 17, 2011 .Dt XHCI 4 .Os .Sh NAME @@ -49,6 +49,13 @@ The controller supports .Tn USB connection speeds up to 5.0Gbps when using a USB 3.0 compliant device. +.Sh HARDWARE +The +.Nm +driver supports +.Tn XHCI +compatible controllers having PCI class 12 (serial bus), +subclass 3 (USB) and programming interface 48 (XHCI). .Sh SEE ALSO .Xr ehci 4 , .Xr ohci 4 , From 90de864a5e7b61743483e8b6025bb729ae75fd9e Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 17 May 2011 11:52:53 +0000 Subject: [PATCH 18/31] Set this HAL capabilities flag correctly even though it isn't currently being used. --- sys/dev/ath/ath_hal/ar5416/ar5416_attach.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c index d54573352c9..6779bf9f846 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c @@ -816,7 +816,7 @@ ar5416FillCapabilityInfo(struct ath_hal *ah) pCap->halPSPollBroken = AH_TRUE; /* XXX fixed in later revs? */ pCap->halVEOLSupport = AH_TRUE; pCap->halBssIdMaskSupport = AH_TRUE; - pCap->halMcastKeySrchSupport = AH_FALSE; + pCap->halMcastKeySrchSupport = AH_TRUE; /* Works on AR5416 and later */ pCap->halTsfAddSupport = AH_TRUE; pCap->hal4AddrAggrSupport = AH_FALSE; /* Broken in Owl */ From 655a610236f0d758ba5ed43d813a87649354a032 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 17 May 2011 11:56:50 +0000 Subject: [PATCH 19/31] Use the halMcastKeySrchSupport capability bit to selectively enable/disable the multicast key search support for AR5212, AR5416 and later. The general HAL routine ath_hal_getcapability() implement checking this but it's overridden by a check in ar5212_misc:ar5212GetCapability(). This restores the later functionality in case it's found to be broken in any of the 11n chipsets. --- sys/dev/ath/ath_hal/ar5212/ar5212_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c index 15f38644869..7677f6c832a 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c +++ b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c @@ -857,7 +857,7 @@ ar5212GetCapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type, case HAL_CAP_MCAST_KEYSRCH: /* multicast frame keycache search */ switch (capability) { case 0: /* hardware capability */ - return HAL_OK; + return pcap->halMcastKeySrchSupport ? HAL_OK : HAL_ENXIO; case 1: return (ahp->ah_staId1Defaults & AR_STA_ID1_MCAST_KSRCH) ? HAL_OK : HAL_ENXIO; From 3e71d7d04e1cf9ed7ecc8b172730c3efd0d0e10c Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Tue, 17 May 2011 12:58:19 +0000 Subject: [PATCH 20/31] mdoc: - use a proper macro for interface name ipfw0. - add missing section number for bpf cross reference. --- sbin/ipfw/ipfw.8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbin/ipfw/ipfw.8 b/sbin/ipfw/ipfw.8 index a984f70cb9e..710996b7fce 100644 --- a/sbin/ipfw/ipfw.8 +++ b/sbin/ipfw/ipfw.8 @@ -565,9 +565,9 @@ if the sysctl variable is set to 0 (default), one can use .Xr bpf 4 attached to the -.Xr ipfw0 +.Li ipfw0 pseudo interface. There is no overhead if no -.Xr bpf +.Xr bpf 4 is attached to the pseudo interface. .Pp If From 5c0e8d8a88f5b039f6bfaee1e23813ebf834b3d9 Mon Sep 17 00:00:00 2001 From: Sergey Kandaurov Date: Tue, 17 May 2011 14:46:28 +0000 Subject: [PATCH 21/31] Fix manual section number for netstat(1). MFC after: 5 days --- usr.sbin/ifmcstat/ifmcstat.8 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/ifmcstat/ifmcstat.8 b/usr.sbin/ifmcstat/ifmcstat.8 index 5a6956d52e9..9794d70a44d 100644 --- a/usr.sbin/ifmcstat/ifmcstat.8 +++ b/usr.sbin/ifmcstat/ifmcstat.8 @@ -125,7 +125,7 @@ This support is recommended for debugging purposes. It requires super-user privilege if used to inspect a running kernel. .Pp .Sh SEE ALSO +.Xr netstat 1 , .Xr getifaddrs 3 , .Xr getifmaddrs 3 , -.Xr kvm 3 , -.Xr netstat 8 +.Xr kvm 3 From fdc2e66c57dd08126913182bf5313c07416b44b4 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 17 May 2011 15:03:39 +0000 Subject: [PATCH 22/31] Fix case, introduced in my previous commit. Pointy hat goes to: adrian, for having multiple build screens open and checking the wrong one. --- sys/dev/ath/ath_hal/ar5212/ar5212_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c index 7677f6c832a..0d6adc13e98 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c +++ b/sys/dev/ath/ath_hal/ar5212/ar5212_misc.c @@ -857,7 +857,7 @@ ar5212GetCapability(struct ath_hal *ah, HAL_CAPABILITY_TYPE type, case HAL_CAP_MCAST_KEYSRCH: /* multicast frame keycache search */ switch (capability) { case 0: /* hardware capability */ - return pcap->halMcastKeySrchSupport ? HAL_OK : HAL_ENXIO; + return pCap->halMcastKeySrchSupport ? HAL_OK : HAL_ENXIO; case 1: return (ahp->ah_staId1Defaults & AR_STA_ID1_MCAST_KSRCH) ? HAL_OK : HAL_ENXIO; From c954cac48b1c87e0edc9cc957ba673e3ca4bd993 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Tue, 17 May 2011 15:46:28 +0000 Subject: [PATCH 23/31] Fix whitespacing. Reported by scf@ MFC after: 1 week. --- sys/netinet/sctp_output.c | 46 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/sys/netinet/sctp_output.c b/sys/netinet/sctp_output.c index 0dad4e51f83..aea43b2dbe3 100644 --- a/sys/netinet/sctp_output.c +++ b/sys/netinet/sctp_output.c @@ -2210,26 +2210,26 @@ sctp_is_ifa_addr_preferred(struct sctp_ifa *ifa, * means it is the same scope or higher scope then the destination. * L = loopback, P = private, G = global * ----------------------------------------- - * src | dest | result - * ---------------------------------------- - * L | L | yes - * ----------------------------------------- - * P | L | yes-v4 no-v6 - * ----------------------------------------- - * G | L | yes-v4 no-v6 - * ----------------------------------------- - * L | P | no - * ----------------------------------------- - * P | P | yes - * ----------------------------------------- - * G | P | no - * ----------------------------------------- - * L | G | no - * ----------------------------------------- - * P | G | no - * ----------------------------------------- - * G | G | yes - * ----------------------------------------- + * src | dest | result + * ---------------------------------------- + * L | L | yes + * ----------------------------------------- + * P | L | yes-v4 no-v6 + * ----------------------------------------- + * G | L | yes-v4 no-v6 + * ----------------------------------------- + * L | P | no + * ----------------------------------------- + * P | P | yes + * ----------------------------------------- + * G | P | no + * ----------------------------------------- + * L | G | no + * ----------------------------------------- + * P | G | no + * ----------------------------------------- + * G | G | yes + * ----------------------------------------- */ if (ifa->address.sa.sa_family != fam) { @@ -2310,14 +2310,14 @@ sctp_is_ifa_addr_acceptable(struct sctp_ifa *ifa, * * L = loopback, P = private, G = global * ----------------------------------------- - * src | dest | result + * src | dest | result * ----------------------------------------- * L | L | yes * ----------------------------------------- * P | L | yes-v4 no-v6 * ----------------------------------------- * G | L | yes - * ----------------------------------------- + * ----------------------------------------- * L | P | no * ----------------------------------------- * P | P | yes @@ -2325,7 +2325,7 @@ sctp_is_ifa_addr_acceptable(struct sctp_ifa *ifa, * G | P | yes - May not work * ----------------------------------------- * L | G | no - * ----------------------------------------- + * ----------------------------------------- * P | G | yes - May not work * ----------------------------------------- * G | G | yes From 4f36da915f9997be5e8a3f485705f2b06d9c4f4f Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Tue, 17 May 2011 15:57:31 +0000 Subject: [PATCH 24/31] Copy out the mtu when calling getsockopt() with SCTP_GET_PEER_ADDR_INFO. MFC after: 1 week. --- sys/netinet/sctp_usrreq.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index c9fad80f01c..b3eb805edfb 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -2489,6 +2489,7 @@ flags_out: paddri->spinfo_srtt = net->lastsa >> SCTP_RTT_SHIFT; paddri->spinfo_rto = net->RTO; paddri->spinfo_assoc_id = sctp_get_associd(stcb); + paddri->spinfo_mtu = net->mtu; SCTP_TCB_UNLOCK(stcb); } else { if (stcb) { From 6c63a20b4939d86a62970f62be6e78a055da0df2 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Tue, 17 May 2011 16:30:34 +0000 Subject: [PATCH 25/31] Fix the debugging code path to correctly support HAL_DEBUG_UNMASKABLE. --- sys/dev/ath/ah_osdep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/dev/ath/ah_osdep.c b/sys/dev/ath/ah_osdep.c index 090b690943c..b14bba037e5 100644 --- a/sys/dev/ath/ah_osdep.c +++ b/sys/dev/ath/ah_osdep.c @@ -140,16 +140,20 @@ ath_hal_ether_sprintf(const u_int8_t *mac) } #ifdef AH_DEBUG + +/* This must match the definition in ath_hal/ah_debug.h */ +#define HAL_DEBUG_UNMASKABLE 0xf0000000 void DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...) { - if (ath_hal_debug & mask) { + if ((mask == HAL_DEBUG_UNMASKABLE) || (ath_hal_debug & mask)) { __va_list ap; va_start(ap, fmt); ath_hal_vprintf(ah, fmt, ap); va_end(ap); } } +#undef HAL_DEBUG_UNMASKABLE #endif /* AH_DEBUG */ #ifdef AH_DEBUG_ALQ From f83e8b25c1ef10af62fabdd117aec0db71d33cc3 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Tue, 17 May 2011 16:39:08 +0000 Subject: [PATCH 26/31] Fix a race in the SMP rendezvous code. Specifically, the write by the last CPU to to finish the rendezvous action may become visible to different CPUs at different times. As a result, the CPU that initiated the rendezvous may exit the rendezvous and drop the lock allowing another rendezvous to be initiated on the same CPU or a different CPU. In that case the exit sentinel may be cleared before all CPUs have noticed causing those CPUs to hang forever. Workaround this by using a generation count to notice when this race occurs and to exit the rendezvous in that case. The problem was independently diagnosted by mlaier@ and avg@ as well. Submitted by: neel Reviewed by: avg, mlaier Obtained from: NetApp MFC after: 1 week --- sys/kern/subr_smp.c | 63 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index aba6f0e1ea7..0c2c286f1d0 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -110,6 +110,7 @@ static void (*volatile smp_rv_action_func)(void *arg); static void (*volatile smp_rv_teardown_func)(void *arg); static void *volatile smp_rv_func_arg; static volatile int smp_rv_waiters[3]; +static volatile int smp_rv_generation; /* * Shared mutex to restrict busywaits between smp_rendezvous() and @@ -310,39 +311,63 @@ restart_cpus(cpumask_t map) void smp_rendezvous_action(void) { - void* local_func_arg = smp_rv_func_arg; - void (*local_setup_func)(void*) = smp_rv_setup_func; - void (*local_action_func)(void*) = smp_rv_action_func; - void (*local_teardown_func)(void*) = smp_rv_teardown_func; + void *local_func_arg; + void (*local_setup_func)(void*); + void (*local_action_func)(void*); + void (*local_teardown_func)(void*); + int generation; /* Ensure we have up-to-date values. */ atomic_add_acq_int(&smp_rv_waiters[0], 1); while (smp_rv_waiters[0] < smp_rv_ncpus) cpu_spinwait(); - /* setup function */ + /* Fetch rendezvous parameters after acquire barrier. */ + local_func_arg = smp_rv_func_arg; + local_setup_func = smp_rv_setup_func; + local_action_func = smp_rv_action_func; + local_teardown_func = smp_rv_teardown_func; + generation = smp_rv_generation; + + /* + * If requested, run a setup function before the main action + * function. Ensure all CPUs have completed the setup + * function before moving on to the action function. + */ if (local_setup_func != smp_no_rendevous_barrier) { if (smp_rv_setup_func != NULL) smp_rv_setup_func(smp_rv_func_arg); - - /* spin on entry rendezvous */ atomic_add_int(&smp_rv_waiters[1], 1); while (smp_rv_waiters[1] < smp_rv_ncpus) cpu_spinwait(); } - /* action function */ if (local_action_func != NULL) local_action_func(local_func_arg); - /* spin on exit rendezvous */ + /* + * Signal that the main action has been completed. If a + * full exit rendezvous is requested, then all CPUs will + * wait here until all CPUs have finished the main action. + * + * Note that the write by the last CPU to finish the action + * may become visible to different CPUs at different times. + * As a result, the CPU that initiated the rendezvous may + * exit the rendezvous and drop the lock allowing another + * rendezvous to be initiated on the same CPU or a different + * CPU. In that case the exit sentinel may be cleared before + * all CPUs have noticed causing those CPUs to hang forever. + * Workaround this by using a generation count to notice when + * this race occurs and to exit the rendezvous in that case. + */ + MPASS(generation == smp_rv_generation); atomic_add_int(&smp_rv_waiters[2], 1); if (local_teardown_func == smp_no_rendevous_barrier) return; - while (smp_rv_waiters[2] < smp_rv_ncpus) + while (smp_rv_waiters[2] < smp_rv_ncpus && + generation == smp_rv_generation) cpu_spinwait(); - /* teardown function */ if (local_teardown_func != NULL) local_teardown_func(local_func_arg); } @@ -373,10 +398,11 @@ smp_rendezvous_cpus(cpumask_t map, if (ncpus == 0) panic("ncpus is 0 with map=0x%x", map); - /* obtain rendezvous lock */ mtx_lock_spin(&smp_ipi_mtx); - /* set static function pointers */ + atomic_add_acq_int(&smp_rv_generation, 1); + + /* Pass rendezvous parameters via global variables. */ smp_rv_ncpus = ncpus; smp_rv_setup_func = setup_func; smp_rv_action_func = action_func; @@ -386,18 +412,25 @@ smp_rendezvous_cpus(cpumask_t map, smp_rv_waiters[2] = 0; atomic_store_rel_int(&smp_rv_waiters[0], 0); - /* signal other processors, which will enter the IPI with interrupts off */ + /* + * Signal other processors, which will enter the IPI with + * interrupts off. + */ ipi_selected(map & ~(1 << curcpu), IPI_RENDEZVOUS); /* Check if the current CPU is in the map */ if ((map & (1 << curcpu)) != 0) smp_rendezvous_action(); + /* + * If the caller did not request an exit barrier to be enforced + * on each CPU, ensure that this CPU waits for all the other + * CPUs to finish the rendezvous. + */ if (teardown_func == smp_no_rendevous_barrier) while (atomic_load_acq_int(&smp_rv_waiters[2]) < ncpus) cpu_spinwait(); - /* release lock */ mtx_unlock_spin(&smp_ipi_mtx); } From 09eed402a241ee5ac91525bd4394c12401e398cc Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 17 May 2011 17:37:58 +0000 Subject: [PATCH 27/31] Bump shlib version Instigate symbol versioning Pray that I don't break the build. --- lib/libsbuf/Makefile | 11 ++++++++--- lib/libsbuf/Symbol.map | 24 ++++++++++++++++++++++++ lib/libsbuf/Version.def | 6 ++++++ 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 lib/libsbuf/Symbol.map create mode 100644 lib/libsbuf/Version.def diff --git a/lib/libsbuf/Makefile b/lib/libsbuf/Makefile index 5d96c0e983e..79d3fe973e0 100644 --- a/lib/libsbuf/Makefile +++ b/lib/libsbuf/Makefile @@ -1,8 +1,13 @@ # $FreeBSD$ -LIB= sbuf -SHLIBDIR?= /lib -SRCS= subr_sbuf.c +LIB= sbuf +SHLIBDIR?= /lib +SRCS= subr_sbuf.c + +SHLIB_MAJOR = 6 + +SYMBOL_MAPS= ${.CURDIR}/Symbol.map +VERSION_DEF= ${.CURDIR}/Version.def .PATH: ${.CURDIR}/../../sys/kern diff --git a/lib/libsbuf/Symbol.map b/lib/libsbuf/Symbol.map new file mode 100644 index 00000000000..75af5583887 --- /dev/null +++ b/lib/libsbuf/Symbol.map @@ -0,0 +1,24 @@ +/* + * $FreeBSD$ + */ + +FBSD_1.2 { + sbuf_new; + sbuf_clear; + sbuf_setpos; + sbuf_bcat; + sbuf_bcpy; + sbuf_cat; + sbuf_cpy; + sbuf_printf; + sbuf_vprintf; + sbuf_putc; + sbuf_set_drain; + sbuf_trim; + sbuf_error; + sbuf_finish; + sbuf_data; + sbuf_len; + sbuf_done; + sbuf_delete; +}; diff --git a/lib/libsbuf/Version.def b/lib/libsbuf/Version.def new file mode 100644 index 00000000000..cf8a7d41d29 --- /dev/null +++ b/lib/libsbuf/Version.def @@ -0,0 +1,6 @@ +/* + * $FreeBSD$ + */ + +FBSD_1.2 { +}; From 6ab7244a4dce57de8e59a16d6d3285af0cf1b07e Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 17 May 2011 18:24:59 +0000 Subject: [PATCH 28/31] Try to explain what sbufs do and add an example to show it. Clarify return values. --- share/man/man9/sbuf.9 | 45 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/share/man/man9/sbuf.9 b/share/man/man9/sbuf.9 index 4b93df58ee5..500bfbdc9e9 100644 --- a/share/man/man9/sbuf.9 +++ b/share/man/man9/sbuf.9 @@ -52,7 +52,7 @@ .Nm sbuf_len , .Nm sbuf_done , .Nm sbuf_delete -.Nd safe string formatting +.Nd safe string composition .Sh SYNOPSIS .In sys/types.h .In sys/sbuf.h @@ -106,14 +106,20 @@ .Sh DESCRIPTION The .Nm -family of functions allows one to safely allocate, construct and -release bounded NUL-terminated strings in kernel space. +family of functions allows one to safely allocate, compose and +release strings in kernel or user space. +.Pp Instead of arrays of characters, these functions operate on structures called .Fa sbufs , defined in .In sys/sbuf.h . .Pp +Any errors encountered during the allocation or composition of the +string will be latched in the data structure, +making a single error test at the end of the composition +sufficient to determine success or failure of the entire process. +.Pp The .Fn sbuf_new function initializes the @@ -468,14 +474,35 @@ The function returns \-1 if copying string from userland failed, and number of bytes copied otherwise. +.Pp The -.Fn sbuf_finish -function returns ENOMEM if the sbuf overflowed before being finished, +.Fn sbuf_finish 9 +function (the kernel version) returns ENOMEM if the sbuf overflowed before +being finished, or returns the error code from the drain if one is attached. -When used as -.Xr sbuf_finish 3 , -.Fn sbuf_finish -will return \-1 and set errno on error instead. +.Pp +The +.Fn sbuf_finish 3 +function (the userland version) +will return zero for success and \-1 and set errno on error. +.Sh EXAMPLES +.Bd -literal -compact +#include + +struct sbuf *sb; + +sb = sbuf_new_auto(); +sbuf_cat("Customers found:\en"); +TAILQ_FOREACH(foo, &foolist, list) { + sbuf_printf(" %4d %s\en", foo->index, foo->name); + sbuf_printf(" Address: %s\en", foo->address); + sbuf_printf(" Zip: %s\en", foo->zipcode); +} +if (sbuf_finish(sb)) + err(1,"Could not generate message"); +transmit_msg(sbuf_data(sb), sbuf_len(sb)); +sbuf_delete(sb); +.Ed .Sh SEE ALSO .Xr printf 3 , .Xr strcat 3 , From 2eb4b00cbb86ee4591b3a60e96b94e51085c3939 Mon Sep 17 00:00:00 2001 From: Florent Thoumie Date: Tue, 17 May 2011 19:11:47 +0000 Subject: [PATCH 29/31] Backout libinstall.a -> libpkg commit. Discussed with: erwin, brooks, bapt --- Makefile.inc1 | 5 +- lib/Makefile | 5 -- lib/libpkg/Makefile | 47 ---------- lib/libpkg/pkgwrap.c | 90 ------------------- share/mk/bsd.libnames.mk | 1 - usr.sbin/pkg_install/Makefile | 4 +- usr.sbin/pkg_install/Makefile.inc | 13 ++- usr.sbin/pkg_install/add/Makefile | 7 +- usr.sbin/pkg_install/add/extract.c | 2 +- usr.sbin/pkg_install/add/futil.c | 2 +- usr.sbin/pkg_install/add/main.c | 4 +- usr.sbin/pkg_install/add/perform.c | 2 +- usr.sbin/pkg_install/create/Makefile | 6 +- usr.sbin/pkg_install/create/main.c | 4 +- usr.sbin/pkg_install/create/perform.c | 2 +- usr.sbin/pkg_install/create/pl.c | 2 +- usr.sbin/pkg_install/delete/Makefile | 5 ++ usr.sbin/pkg_install/delete/main.c | 4 +- usr.sbin/pkg_install/delete/perform.c | 2 +- usr.sbin/pkg_install/info/Makefile | 6 +- usr.sbin/pkg_install/info/info.h | 39 ++++---- usr.sbin/pkg_install/info/main.c | 14 +-- usr.sbin/pkg_install/info/perform.c | 2 +- usr.sbin/pkg_install/info/show.c | 2 +- usr.sbin/pkg_install/lib/Makefile | 11 +++ .../pkg_install/lib}/deps.c | 2 +- .../pkg_install/lib}/exec.c | 2 +- .../pkg_install/lib}/file.c | 2 +- .../pkg_install/lib}/global.c | 2 +- .../pkg.h => usr.sbin/pkg_install/lib/lib.h | 12 +-- .../pkg_install/lib}/match.c | 4 +- .../libpkg => usr.sbin/pkg_install/lib}/msg.c | 9 +- .../libpkg => usr.sbin/pkg_install/lib}/pen.c | 17 ++-- usr.sbin/pkg_install/lib/pkgwrap.c | 89 ++++++++++++++++++ .../pkg_install/lib}/plist.c | 2 +- .../libpkg => usr.sbin/pkg_install/lib}/str.c | 2 +- .../libpkg => usr.sbin/pkg_install/lib}/url.c | 4 +- .../pkg_install/lib}/version.c | 14 +-- usr.sbin/pkg_install/updating/Makefile | 5 ++ usr.sbin/pkg_install/updating/main.c | 4 +- usr.sbin/pkg_install/version/Makefile | 5 ++ usr.sbin/pkg_install/version/main.c | 4 +- usr.sbin/pkg_install/version/perform.c | 2 +- 43 files changed, 211 insertions(+), 251 deletions(-) delete mode 100644 lib/libpkg/Makefile delete mode 100644 lib/libpkg/pkgwrap.c create mode 100644 usr.sbin/pkg_install/lib/Makefile rename {lib/libpkg => usr.sbin/pkg_install/lib}/deps.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/exec.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/file.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/global.c (98%) rename lib/libpkg/pkg.h => usr.sbin/pkg_install/lib/lib.h (96%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/match.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/msg.c (91%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/pen.c (90%) create mode 100644 usr.sbin/pkg_install/lib/pkgwrap.c rename {lib/libpkg => usr.sbin/pkg_install/lib}/plist.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/str.c (99%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/url.c (98%) rename {lib/libpkg => usr.sbin/pkg_install/lib}/version.c (98%) diff --git a/Makefile.inc1 b/Makefile.inc1 index 907cdce7d5b..4aa53da83d2 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1205,7 +1205,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \ ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \ ${_kerberos5_lib_libroken} \ lib/libbz2 lib/libcom_err lib/libcrypt \ - lib/libexpat lib/libfetch \ + lib/libexpat \ ${_lib_libgssapi} ${_lib_libipx} \ lib/libkiconv lib/libkvm lib/liblzma lib/libmd \ lib/ncurses/ncurses lib/ncurses/ncursesw \ @@ -1238,7 +1238,6 @@ _cddl_lib= cddl/lib _secure_lib_libcrypto= secure/lib/libcrypto _secure_lib_libssl= secure/lib/libssl lib/libradius__L secure/lib/libssl__L: secure/lib/libcrypto__L -lib/libfetch__L: secure/lib/libcrypto__L secure/lib/libssl__L lib/libmd__L .if ${MK_OPENSSH} != "no" _secure_lib_libssh= secure/lib/libssh secure/lib/libssh__L: lib/libz__L secure/lib/libcrypto__L lib/libcrypt__L @@ -1274,7 +1273,7 @@ _lib_libypclnt= lib/libypclnt .endif .if ${MK_OPENSSL} == "no" -lib/libfetch__L lib/libradius__L: lib/libmd__L +lib/libradius__L: lib/libmd__L .endif .for _lib in ${_prereq_libs} diff --git a/lib/Makefile b/lib/Makefile index 7be186fca21..eef204899cd 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -89,7 +89,6 @@ SUBDIR= ${SUBDIR_ORDERED} \ libopie \ libpam \ libpcap \ - ${_libpkg} \ ${_libpmc} \ ${_libproc} \ libprocstat \ @@ -215,10 +214,6 @@ _libmp= libmp _libpmc= libpmc .endif -.if ${MK_PKGTOOLS} != "no" -_libpkg= libpkg -.endif - .if ${MK_SENDMAIL} != "no" _libmilter= libmilter _libsm= libsm diff --git a/lib/libpkg/Makefile b/lib/libpkg/Makefile deleted file mode 100644 index 8f2b325f098..00000000000 --- a/lib/libpkg/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# $FreeBSD$ - -.include - -LIB= pkg - -SHLIBDIR?= /usr/lib -SHLIB_MAJOR= 0 - -SRCS= deps.c \ - exec.c \ - file.c \ - global.c \ - match.c \ - msg.c \ - pen.c \ - pkgwrap.c \ - plist.c \ - str.c \ - url.c \ - version.c -INCS= pkg.h - -CFLAGS+= -DYES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE - -DPADD= ${LIBFETCH} ${LIBMD} ${LIBUTIL} -LDADD= -lfetch -lmd -lutil - -.if ${MK_OPENSSL} != "no" -DPADD+= ${LIBSSL} ${LIBCRYPTO} -LDADD+= -lssl -lcrypto -.endif - -WARNS?= 3 - -DATE!= grep LIBPKG_VERSION ${.CURDIR}/pkg.h | sed 's|.*[ ]||' - -distfile: clean - @(cd ${.CURDIR}/..; \ - cp -r libpkg libpkg-${DATE}; \ - tar -czf libpkg/libpkg-${DATE}.tar.gz \ - --exclude .#* --exclude *~ --exclude CVS \ - --exclude .svn --exclude libpkg-*.tar.gz \ - libpkg-${DATE}; \ - rm -rf libpkg-${DATE}) - -.include diff --git a/lib/libpkg/pkgwrap.c b/lib/libpkg/pkgwrap.c deleted file mode 100644 index 9c8c0c3d0a2..00000000000 --- a/lib/libpkg/pkgwrap.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * FreeBSD install - a package for the installation and maintenance - * of non-core utilities. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Maxim Sobolev - * 8 September 2002 - * - */ - -#include -__FBSDID("$FreeBSD$"); - -#include "pkg.h" -#include -#include -#include -#include - -extern char **environ; - -void -pkg_wrap(long curver, char **argv) -{ - FILE* f; - char ver[9]; /* Format is: 'YYYYMMDD\0' */ - char buffer[FILENAME_MAX+10]; /* Format is: 'YYYYMMDD ' */ - char cmd[FILENAME_MAX+5]; /* Format is: ' -PPq' */ - char *path, *cp; - long ptver, lpver; - - if (getenv("PKG_NOWRAP") != NULL) - goto nowrap; - - setenv("PKG_NOWRAP", "1", 1); - - /* Get alternative location for package tools. */ - if ((f = fopen(PKG_WRAPCONF_FNAME, "r")) == NULL) { - goto nowrap; - } else { - if (get_string(buffer, FILENAME_MAX+9, f) == NULL) { - goto nowrap; - } else { - if ((path = strrchr(buffer, ' ')) == NULL) { - goto nowrap; - } else { - *path++ = '\0'; - } - } - } - - if ((cp = strrchr(argv[0], '/')) == NULL) { - cp = argv[0]; - } else { - cp++; - } - - /* Get version of the other pkg_install and libpkg */ - snprintf(cmd, FILENAME_MAX+10, "%s/%s -PPq", path, cp); - if ((f = popen(cmd, "r")) == NULL) { - perror("popen()"); - goto nowrap; - } else { - if (get_string(ver, 9, f) == NULL) - goto nowrap; - else - ptver = strtol(ver, NULL, 10); - if (get_string(ver, 9, f) == NULL) - goto nowrap; - else - lpver = strtol(ver, NULL, 10); - pclose(f); - } - - if ((lpver >= LIBPKG_VERSION) && (ptver > curver)) { - snprintf(cmd, FILENAME_MAX, "%s/%s", path, cp); - execve(cmd, argv, environ); - } - -nowrap: - unsetenv("PKG_NOWRAP"); -} diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk index 9a948ff4bbe..d3fb51a9a73 100644 --- a/share/mk/bsd.libnames.mk +++ b/share/mk/bsd.libnames.mk @@ -129,7 +129,6 @@ MINUSLPAM+= -lypclnt LIBPANEL?= ${DESTDIR}${LIBDIR}/libpanel.a LIBPCAP?= ${DESTDIR}${LIBDIR}/libpcap.a -LIBPKG?= ${DESTDIR}${LIBDIR}/libpkg.a LIBPMC?= ${DESTDIR}${LIBDIR}/libpmc.a LIBPROC?= ${DESTDIR}${LIBDIR}/libproc.a LIBPTHREAD?= ${DESTDIR}${LIBDIR}/libpthread.a diff --git a/usr.sbin/pkg_install/Makefile b/usr.sbin/pkg_install/Makefile index 0aa19415441..bf1a2135cc7 100644 --- a/usr.sbin/pkg_install/Makefile +++ b/usr.sbin/pkg_install/Makefile @@ -2,11 +2,11 @@ .include -SUBDIR= add create delete info updating version +SUBDIR= lib add create delete info updating version .include -DATE!= grep PKG_INSTALL_VERSION ${.CURDIR}/Makefile.inc | sed 's|.*=||' +DATE!= grep PKG_INSTALL_VERSION ${.CURDIR}/lib/lib.h | sed 's|.*[ ]||' distfile: clean @(cd ${.CURDIR}/..; \ diff --git a/usr.sbin/pkg_install/Makefile.inc b/usr.sbin/pkg_install/Makefile.inc index d929f245700..2fa20aa1c39 100644 --- a/usr.sbin/pkg_install/Makefile.inc +++ b/usr.sbin/pkg_install/Makefile.inc @@ -2,11 +2,16 @@ .include -CFLAGS+= -DPKG_INSTALL_VERSION=20101012 -CFLAGS+= -DYES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE +LIBINSTALL= ${.OBJDIR}/../lib/libinstall.a -DPADD+= ${LIBPKG} -LDADD+= -lpkg +DPADD+= ${LIBUTIL} +LDADD+= -lutil + +.if ${MK_OPENSSL} != "no" && \ + defined(LDADD) && ${LDADD:M-lfetch} != "" +DPADD+= ${LIBSSL} ${LIBCRYPTO} +LDADD+= -lssl -lcrypto +.endif # Inherit BINDIR from one level up. .include "../Makefile.inc" diff --git a/usr.sbin/pkg_install/add/Makefile b/usr.sbin/pkg_install/add/Makefile index 03a43f068b7..89988e78b22 100644 --- a/usr.sbin/pkg_install/add/Makefile +++ b/usr.sbin/pkg_install/add/Makefile @@ -1,11 +1,14 @@ # $FreeBSD$ -.include - PROG= pkg_add SRCS= main.c perform.c futil.c extract.c +CFLAGS+= -I${.CURDIR}/../lib + WARNS?= 3 WFORMAT?= 1 +DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD} +LDADD= ${LIBINSTALL} -lfetch -lmd + .include diff --git a/usr.sbin/pkg_install/add/extract.c b/usr.sbin/pkg_install/add/extract.c index 6c2c4fc7b92..732a13fea44 100644 --- a/usr.sbin/pkg_install/add/extract.c +++ b/usr.sbin/pkg_install/add/extract.c @@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "add.h" diff --git a/usr.sbin/pkg_install/add/futil.c b/usr.sbin/pkg_install/add/futil.c index c5253202ca5..ca095ea7ae2 100644 --- a/usr.sbin/pkg_install/add/futil.c +++ b/usr.sbin/pkg_install/add/futil.c @@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include "lib.h" #include "add.h" /* diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index b8b9b54bcf6..f73312a626e 100644 --- a/usr.sbin/pkg_install/add/main.c +++ b/usr.sbin/pkg_install/add/main.c @@ -26,7 +26,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "add.h" char *Prefix = NULL; @@ -132,8 +132,6 @@ main(int argc, char **argv) static char temppackageroot[MAXPATHLEN]; static char pkgaddpath[MAXPATHLEN]; - pkg_wrap(PKG_INSTALL_VERSION, argv); - if (*argv[0] != '/' && strchr(argv[0], '/') != NULL) PkgAddCmd = realpath(argv[0], pkgaddpath); else diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index 653a1d6296f..b23cd5232a3 100644 --- a/usr.sbin/pkg_install/add/perform.c +++ b/usr.sbin/pkg_install/add/perform.c @@ -23,7 +23,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "add.h" #include diff --git a/usr.sbin/pkg_install/create/Makefile b/usr.sbin/pkg_install/create/Makefile index 333403778fe..42718c6f927 100644 --- a/usr.sbin/pkg_install/create/Makefile +++ b/usr.sbin/pkg_install/create/Makefile @@ -3,10 +3,12 @@ PROG= pkg_create SRCS= main.c perform.c pl.c +CFLAGS+= -I${.CURDIR}/../lib + WARNS?= 3 WFORMAT?= 1 -DPADD= ${LIBMD} -LDADD= -lmd +DPADD= ${LIBINSTALL} ${LIBMD} +LDADD= ${LIBINSTALL} -lmd .include diff --git a/usr.sbin/pkg_install/create/main.c b/usr.sbin/pkg_install/create/main.c index 5e999dae335..e4af62128ae 100644 --- a/usr.sbin/pkg_install/create/main.c +++ b/usr.sbin/pkg_install/create/main.c @@ -15,7 +15,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "create.h" match_t MatchType = MATCH_GLOB; @@ -72,8 +72,6 @@ main(int argc, char **argv) int ch; char **pkgs, **start, *tmp; - pkg_wrap(PKG_INSTALL_VERSION, argv); - pkgs = start = argv; while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) switch(ch) { diff --git a/usr.sbin/pkg_install/create/perform.c b/usr.sbin/pkg_install/create/perform.c index 149bcbd0851..45786b62b87 100644 --- a/usr.sbin/pkg_install/create/perform.c +++ b/usr.sbin/pkg_install/create/perform.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "create.h" #include diff --git a/usr.sbin/pkg_install/create/pl.c b/usr.sbin/pkg_install/create/pl.c index fe62d421014..18bbaf24734 100644 --- a/usr.sbin/pkg_install/create/pl.c +++ b/usr.sbin/pkg_install/create/pl.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "create.h" #include #include diff --git a/usr.sbin/pkg_install/delete/Makefile b/usr.sbin/pkg_install/delete/Makefile index 4f3b3906e63..c9a0fdebea2 100644 --- a/usr.sbin/pkg_install/delete/Makefile +++ b/usr.sbin/pkg_install/delete/Makefile @@ -3,6 +3,11 @@ PROG= pkg_delete SRCS= main.c perform.c +CFLAGS+= -I${.CURDIR}/../lib + WFORMAT?= 1 +DPADD= ${LIBINSTALL} ${LIBMD} +LDADD= ${LIBINSTALL} -lmd + .include diff --git a/usr.sbin/pkg_install/delete/main.c b/usr.sbin/pkg_install/delete/main.c index 7677fe9d44b..f09a432f2bb 100644 --- a/usr.sbin/pkg_install/delete/main.c +++ b/usr.sbin/pkg_install/delete/main.c @@ -27,7 +27,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "delete.h" char *Prefix = NULL; @@ -67,8 +67,6 @@ main(int argc, char **argv) const char *tmp; struct stat stat_s; - pkg_wrap(PKG_INSTALL_VERSION, argv); - pkgs = start = argv; while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) switch(ch) { diff --git a/usr.sbin/pkg_install/delete/perform.c b/usr.sbin/pkg_install/delete/perform.c index 02f9717a091..2557dbcd105 100644 --- a/usr.sbin/pkg_install/delete/perform.c +++ b/usr.sbin/pkg_install/delete/perform.c @@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include "lib.h" #include "delete.h" static int pkg_do(char *); diff --git a/usr.sbin/pkg_install/info/Makefile b/usr.sbin/pkg_install/info/Makefile index ba3909d17da..485cb226321 100644 --- a/usr.sbin/pkg_install/info/Makefile +++ b/usr.sbin/pkg_install/info/Makefile @@ -3,9 +3,11 @@ PROG= pkg_info SRCS= main.c perform.c show.c +CFLAGS+= -I${.CURDIR}/../lib + WFORMAT?= 1 -DPADD= ${LIBMD} -LDADD= -lmd +DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD} +LDADD= ${LIBINSTALL} -lfetch -lmd .include diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h index 68ec7107a3c..46e29b1202d 100644 --- a/usr.sbin/pkg_install/info/info.h +++ b/usr.sbin/pkg_install/info/info.h @@ -33,26 +33,25 @@ #define MAXNAMESIZE 20 #endif -#define SHOW_COMMENT 0x000001 -#define SHOW_DESC 0x000002 -#define SHOW_PLIST 0x000004 -#define SHOW_INSTALL 0x000008 -#define SHOW_DEINSTALL 0x000010 -#define SHOW_REQUIRE 0x000020 -#define SHOW_PREFIX 0x000040 -#define SHOW_INDEX 0x000080 -#define SHOW_FILES 0x000100 -#define SHOW_DISPLAY 0x000200 -#define SHOW_REQBY 0x000400 -#define SHOW_MTREE 0x000800 -#define SHOW_SIZE 0x001000 -#define SHOW_ORIGIN 0x002000 -#define SHOW_CKSUM 0x004000 -#define SHOW_FMTREV 0x008000 -#define SHOW_PTREV 0x010000 -#define SHOW_DEPEND 0x020000 -#define SHOW_PKGNAME 0x040000 -#define SHOW_LPREV 0x100000 +#define SHOW_COMMENT 0x00001 +#define SHOW_DESC 0x00002 +#define SHOW_PLIST 0x00004 +#define SHOW_INSTALL 0x00008 +#define SHOW_DEINSTALL 0x00010 +#define SHOW_REQUIRE 0x00020 +#define SHOW_PREFIX 0x00040 +#define SHOW_INDEX 0x00080 +#define SHOW_FILES 0x00100 +#define SHOW_DISPLAY 0x00200 +#define SHOW_REQBY 0x00400 +#define SHOW_MTREE 0x00800 +#define SHOW_SIZE 0x01000 +#define SHOW_ORIGIN 0x02000 +#define SHOW_CKSUM 0x04000 +#define SHOW_FMTREV 0x08000 +#define SHOW_PTREV 0x10000 +#define SHOW_DEPEND 0x20000 +#define SHOW_PKGNAME 0x40000 struct which_entry { TAILQ_ENTRY(which_entry) next; diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c index ca4e477f999..2de638e4cad 100644 --- a/usr.sbin/pkg_install/info/main.c +++ b/usr.sbin/pkg_install/info/main.c @@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "info.h" int Flags = 0; @@ -68,8 +68,6 @@ main(int argc, char **argv) char **pkgs, **start; char *pkgs_split; - pkg_wrap(PKG_INSTALL_VERSION, argv); - whead = malloc(sizeof(struct which_head)); if (whead == NULL) err(2, NULL); @@ -227,10 +225,7 @@ main(int argc, char **argv) } case 'P': - if (Flags & SHOW_PTREV) - Flags |= SHOW_LPREV; - else - Flags = SHOW_PTREV; + Flags = SHOW_PTREV; break; case 'h': @@ -247,11 +242,6 @@ main(int argc, char **argv) if (!Quiet) printf("Package tools revision: "); printf("%d\n", PKG_INSTALL_VERSION); - if (Flags & SHOW_LPREV) { - if (!Quiet) - printf("Libpkg revision: "); - printf("%d\n", libpkg_version()); - } exit(0); } diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c index d2956120822..09cad78ad3f 100644 --- a/usr.sbin/pkg_install/info/perform.c +++ b/usr.sbin/pkg_install/info/perform.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "info.h" #include #include diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c index 0d3b4ad73d2..c65c312a506 100644 --- a/usr.sbin/pkg_install/info/show.c +++ b/usr.sbin/pkg_install/info/show.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "info.h" #include #include diff --git a/usr.sbin/pkg_install/lib/Makefile b/usr.sbin/pkg_install/lib/Makefile new file mode 100644 index 00000000000..84a41b8d7f1 --- /dev/null +++ b/usr.sbin/pkg_install/lib/Makefile @@ -0,0 +1,11 @@ +# $FreeBSD$ + +LIB= install +INTERNALLIB= +SRCS= file.c msg.c plist.c str.c exec.c global.c pen.c match.c \ + deps.c version.c pkgwrap.c url.c + +WARNS?= 3 +WFORMAT?= 1 + +.include diff --git a/lib/libpkg/deps.c b/usr.sbin/pkg_install/lib/deps.c similarity index 99% rename from lib/libpkg/deps.c rename to usr.sbin/pkg_install/lib/deps.c index 101d0460219..66f44a9c6fe 100644 --- a/lib/libpkg/deps.c +++ b/usr.sbin/pkg_install/lib/deps.c @@ -22,7 +22,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include diff --git a/lib/libpkg/exec.c b/usr.sbin/pkg_install/lib/exec.c similarity index 99% rename from lib/libpkg/exec.c rename to usr.sbin/pkg_install/lib/exec.c index 04891d3cc09..fc8220c5f39 100644 --- a/lib/libpkg/exec.c +++ b/usr.sbin/pkg_install/lib/exec.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include /* diff --git a/lib/libpkg/file.c b/usr.sbin/pkg_install/lib/file.c similarity index 99% rename from lib/libpkg/file.c rename to usr.sbin/pkg_install/lib/file.c index 7c95f995a2f..c7ab9d6b297 100644 --- a/lib/libpkg/file.c +++ b/usr.sbin/pkg_install/lib/file.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include diff --git a/lib/libpkg/global.c b/usr.sbin/pkg_install/lib/global.c similarity index 98% rename from lib/libpkg/global.c rename to usr.sbin/pkg_install/lib/global.c index 8103126e693..e136ec86a6f 100644 --- a/lib/libpkg/global.c +++ b/usr.sbin/pkg_install/lib/global.c @@ -22,7 +22,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" /* These are global for all utils */ Boolean Quiet = FALSE; diff --git a/lib/libpkg/pkg.h b/usr.sbin/pkg_install/lib/lib.h similarity index 96% rename from lib/libpkg/pkg.h rename to usr.sbin/pkg_install/lib/lib.h index 12e35623bc8..089bfa3630b 100644 --- a/lib/libpkg/pkg.h +++ b/usr.sbin/pkg_install/lib/lib.h @@ -23,10 +23,6 @@ #ifndef _INST_LIB_LIB_H_ #define _INST_LIB_LIB_H_ -#ifndef YES_I_KNOW_THE_API_IS_RUBBISH_AND_IS_DOOMED_TO_CHANGE -#error "You obviously have no idea what you're doing." -#endif - /* Includes */ #include #include @@ -100,12 +96,13 @@ #define PKG_PREFIX_VNAME "PKG_PREFIX" /* - * Version of the package library - increase whenever you make a change + * Version of the package tools - increase whenever you make a change * in the code that is not cosmetic only. */ -#define LIBPKG_VERSION 20100423 +#define PKG_INSTALL_VERSION 20100403 #define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf" +#define main(argc, argv) real_main(argc, argv) /* Version numbers to assist with changes in package file format */ #define PLIST_FMT_VER_MAJOR 1 @@ -217,7 +214,7 @@ Boolean make_preserve_name(char *, int, const char *, const char *); /* For all */ int pkg_perform(char **); -void pkg_wrap(long, char **); +int real_main(int, char **); /* Query installed packages */ char **matchinstalled(match_t, char **, int *); @@ -232,7 +229,6 @@ int chkifdepends(const char *, const char *); int requiredby(const char *, struct reqr_by_head **, Boolean, Boolean); /* Version */ -int libpkg_version(void); int verscmp(Package *, int, int); int version_cmp(const char *, const char *); diff --git a/lib/libpkg/match.c b/usr.sbin/pkg_install/lib/match.c similarity index 99% rename from lib/libpkg/match.c rename to usr.sbin/pkg_install/lib/match.c index ba6544224dc..6c1b2bfcf00 100644 --- a/lib/libpkg/match.c +++ b/usr.sbin/pkg_install/lib/match.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include @@ -292,7 +292,7 @@ matchallbyorigin(const char **origins, int *retval) break; } } - if (cmd != PLIST_ORIGIN && 0 != strncmp("bsdpan-", installed[i], 7)) + if (cmd != PLIST_ORIGIN && ( Verbose || 0 != strncmp("bsdpan-", installed[i], 7 ) ) ) warnx("package %s has no origin recorded", installed[i]); fclose(fp); } diff --git a/lib/libpkg/msg.c b/usr.sbin/pkg_install/lib/msg.c similarity index 91% rename from lib/libpkg/msg.c rename to usr.sbin/pkg_install/lib/msg.c index 0d25ad19900..5b17624016d 100644 --- a/lib/libpkg/msg.c +++ b/usr.sbin/pkg_install/lib/msg.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include @@ -61,7 +61,12 @@ y_or_n(Boolean def, const char *msg, ...) else fprintf(stderr, " [no]? "); fflush(stderr); - ch = toupper(fgetc(tty)); + if (AutoAnswer) { + ch = (AutoAnswer == YES) ? 'Y' : 'N'; + fprintf(stderr, "%c\n", ch); + } + else + ch = toupper(fgetc(tty)); if (ch == '\n') ch = (def) ? 'Y' : 'N'; } diff --git a/lib/libpkg/pen.c b/usr.sbin/pkg_install/lib/pen.c similarity index 90% rename from lib/libpkg/pen.c rename to usr.sbin/pkg_install/lib/pen.c index 6e30445b759..2b405a3a43a 100644 --- a/lib/libpkg/pen.c +++ b/usr.sbin/pkg_install/lib/pen.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include @@ -103,7 +103,7 @@ popPen(char *pen) const char * make_playpen(char *pen, off_t sz) { - char humbuf[6]; + char humbuf1[6], humbuf2[6]; char cwd[FILENAME_MAX]; if (!find_play_pen(pen, sz)) @@ -114,15 +114,22 @@ make_playpen(char *pen, off_t sz) errx(2, "%s: can't mktemp '%s'", __func__, pen); } - humanize_number(humbuf, sizeof humbuf, sz, "", HN_AUTOSCALE, HN_NOSPACE); + if (Verbose) { + if (sz) { + humanize_number(humbuf1, sizeof humbuf1, sz, "", HN_AUTOSCALE, + HN_NOSPACE); + humanize_number(humbuf2, sizeof humbuf2, min_free(pen), + "", HN_AUTOSCALE, HN_NOSPACE); + fprintf(stderr, "Requested space: %s bytes, free space: %s bytes in %s\n", humbuf1, humbuf2, pen); + } + } if (min_free(pen) < sz) { rmdir(pen); cleanup(0); errx(2, "%s: not enough free space to create '%s'.\n" "Please set your PKG_TMPDIR environment variable to a location\n" - "with at least %s and try the command again", - __func__, humbuf, pen); + "with more space and\ntry the command again", __func__, pen); } if (!getcwd(cwd, FILENAME_MAX)) { diff --git a/usr.sbin/pkg_install/lib/pkgwrap.c b/usr.sbin/pkg_install/lib/pkgwrap.c new file mode 100644 index 00000000000..cbd15cd7b44 --- /dev/null +++ b/usr.sbin/pkg_install/lib/pkgwrap.c @@ -0,0 +1,89 @@ +/* + * FreeBSD install - a package for the installation and maintenance + * of non-core utilities. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Maxim Sobolev + * 8 September 2002 + * + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "lib.h" +#include +#include +#include +#include + +#undef main + +#define SEPARATORS " \t" + +extern char **environ; + +int +main(int argc, char **argv) +{ + FILE *f; + char buffer[FILENAME_MAX], *cp, *verstr; + int len; + + if (getenv("PKG_NOWRAP") != NULL) + goto nowrap; + f = fopen(PKG_WRAPCONF_FNAME, "r"); + if (f == NULL) + goto nowrap; + cp = fgets(buffer, 256, f); + fclose(f); + if (cp == NULL) + goto nowrap; + len = strlen(cp); + if (cp[len - 1] == '\n') + cp[len - 1] = '\0'; + while (strchr(SEPARATORS, *cp) != NULL) + cp++; + verstr = cp; + cp = strpbrk(cp, SEPARATORS); + if (cp == NULL) + goto nowrap; + *cp = '\0'; + for (cp = verstr; *cp != '\0'; cp++) + if (isdigit(*cp) == 0) + goto nowrap; + if (atoi(verstr) < PKG_INSTALL_VERSION) + goto nowrap; + cp++; + while (*cp != '\0' && strchr(SEPARATORS, *cp) != NULL) + cp++; + if (*cp == '\0') + goto nowrap; + bcopy(cp, buffer, strlen(cp) + 1); + cp = strpbrk(buffer, SEPARATORS); + if (cp != NULL) + *cp = '\0'; + if (!isdir(buffer)) + goto nowrap; + cp = strrchr(argv[0], '/'); + if (cp == NULL) + cp = argv[0]; + else + cp++; + strlcat(buffer, "/", sizeof(buffer)); + strlcat(buffer, cp, sizeof(buffer)); + setenv("PKG_NOWRAP", "1", 1); + execve(buffer, argv, environ); + +nowrap: + unsetenv("PKG_NOWRAP"); + return(real_main(argc, argv)); +} diff --git a/lib/libpkg/plist.c b/usr.sbin/pkg_install/lib/plist.c similarity index 99% rename from lib/libpkg/plist.c rename to usr.sbin/pkg_install/lib/plist.c index b14ac20aafc..545b541c3f1 100644 --- a/lib/libpkg/plist.c +++ b/usr.sbin/pkg_install/lib/plist.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include diff --git a/lib/libpkg/str.c b/usr.sbin/pkg_install/lib/str.c similarity index 99% rename from lib/libpkg/str.c rename to usr.sbin/pkg_install/lib/str.c index c26e6cce660..0d9e288b757 100644 --- a/lib/libpkg/str.c +++ b/usr.sbin/pkg_install/lib/str.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" char * strconcat(const char *s1, const char *s2) diff --git a/lib/libpkg/url.c b/usr.sbin/pkg_install/lib/url.c similarity index 98% rename from lib/libpkg/url.c rename to usr.sbin/pkg_install/lib/url.c index 4c108499428..8c553471199 100644 --- a/lib/libpkg/url.c +++ b/usr.sbin/pkg_install/lib/url.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include #include #include @@ -109,7 +109,7 @@ fileGetURL(const char *base, const char *spec, int keep_package) printf("Error: Unable to get %s: %s\n", fname, fetchLastErrString); /* If the fetch fails, yank the package. */ - if (keep_package && unlink(pkg) < 0) { + if (keep_package && unlink(pkg) < 0 && Verbose) { warnx("failed to remove partially fetched package: %s", pkg); } return NULL; diff --git a/lib/libpkg/version.c b/usr.sbin/pkg_install/lib/version.c similarity index 98% rename from lib/libpkg/version.c rename to usr.sbin/pkg_install/lib/version.c index 123fd5d20e5..d9c4fe7e070 100644 --- a/lib/libpkg/version.c +++ b/usr.sbin/pkg_install/lib/version.c @@ -19,19 +19,9 @@ #include __FBSDID("$FreeBSD$"); -#include "pkg.h" +#include "lib.h" #include -/* - * This routine could easily go somewhere else. - * - */ -int -libpkg_version(void) -{ - return LIBPKG_VERSION; -} - /* * Routines to assist with PLIST_FMT_VER numbers in the packing * lists. @@ -76,7 +66,7 @@ split_version(const char *pkgname, const char **endname, unsigned long *epoch, u if (pkgname == NULL) errx(2, "%s: Passed NULL pkgname.", __func__); - /* Look for the last '-' the pkgname */ + /* Look for the last '-' the the pkgname */ ch = strrchr(pkgname, '-'); /* Cheat if we are just passed a version, not a valid package name */ versionstr = ch ? ch + 1 : pkgname; diff --git a/usr.sbin/pkg_install/updating/Makefile b/usr.sbin/pkg_install/updating/Makefile index f5b7525ddb5..b0d3689779e 100644 --- a/usr.sbin/pkg_install/updating/Makefile +++ b/usr.sbin/pkg_install/updating/Makefile @@ -3,6 +3,11 @@ PROG= pkg_updating SRCS= main.c +CFLAGS+= -I${.CURDIR}/../lib + WFORMAT?= 1 +DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD} +LDADD= ${LIBINSTALL} -lfetch -lmd + .include diff --git a/usr.sbin/pkg_install/updating/main.c b/usr.sbin/pkg_install/updating/main.c index 993ccd52310..0ab2ec0fe8e 100644 --- a/usr.sbin/pkg_install/updating/main.c +++ b/usr.sbin/pkg_install/updating/main.c @@ -19,7 +19,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "pathnames.h" typedef struct installedport { @@ -87,8 +87,6 @@ main(int argc, char *argv[]) DIR *dir; FILE *fd; - pkg_wrap(PKG_INSTALL_VERSION, argv); - while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) { switch (ch) { case 'd': diff --git a/usr.sbin/pkg_install/version/Makefile b/usr.sbin/pkg_install/version/Makefile index fb079e34c7a..3e1d7a522f2 100644 --- a/usr.sbin/pkg_install/version/Makefile +++ b/usr.sbin/pkg_install/version/Makefile @@ -3,8 +3,13 @@ PROG= pkg_version SRCS= main.c perform.c +CFLAGS+= -I${.CURDIR}/../lib + WFORMAT?= 1 +DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD} +LDADD= ${LIBINSTALL} -lfetch -lmd + test: sh ${.CURDIR}/test-pkg_version.sh diff --git a/usr.sbin/pkg_install/version/main.c b/usr.sbin/pkg_install/version/main.c index 42384970603..cad8583c23b 100644 --- a/usr.sbin/pkg_install/version/main.c +++ b/usr.sbin/pkg_install/version/main.c @@ -25,7 +25,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include "lib.h" #include "version.h" char *LimitChars = NULL; @@ -58,8 +58,6 @@ main(int argc, char **argv) { int ch, cmp = 0; - pkg_wrap(PKG_INSTALL_VERSION, argv); - if (argc == 4 && !strcmp(argv[1], "-t")) { cmp = version_cmp(argv[2], argv[3]); printf(cmp > 0 ? ">\n" : (cmp < 0 ? "<\n" : "=\n")); diff --git a/usr.sbin/pkg_install/version/perform.c b/usr.sbin/pkg_install/version/perform.c index 79575a32ba2..dc85696cfc1 100644 --- a/usr.sbin/pkg_install/version/perform.c +++ b/usr.sbin/pkg_install/version/perform.c @@ -21,7 +21,7 @@ #include __FBSDID("$FreeBSD$"); -#include +#include "lib.h" #include "version.h" #include #include From cb315db5989ed2a9a37e44f294478454027f0671 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Tue, 17 May 2011 19:20:32 +0000 Subject: [PATCH 30/31] Ok, so we use different comment conventions in Symbol.map and Version.def "#notimpressed" as my twittering friends would say. --- lib/libsbuf/Version.def | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/libsbuf/Version.def b/lib/libsbuf/Version.def index cf8a7d41d29..ab673d91771 100644 --- a/lib/libsbuf/Version.def +++ b/lib/libsbuf/Version.def @@ -1,6 +1,4 @@ -/* - * $FreeBSD$ - */ +# $FreeBSD$ FBSD_1.2 { }; From 7a18096ceacb88e0804cac1c0175300f60bc6a08 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Tue, 17 May 2011 21:03:34 +0000 Subject: [PATCH 31/31] mq_setattr(2): Add missing const to man page. The declaration in the header file is correct. MFC after: 1 week --- lib/libc/sys/mq_setattr.2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/sys/mq_setattr.2 b/lib/libc/sys/mq_setattr.2 index 2e5a6b1ad04..79e523d6dd7 100644 --- a/lib/libc/sys/mq_setattr.2 +++ b/lib/libc/sys/mq_setattr.2 @@ -37,7 +37,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 29, 2005 +.Dd May 17, 2011 .Dt MQ_SETATTR 2 .Os .Sh NAME @@ -50,7 +50,7 @@ .Ft int .Fo mq_setattr .Fa "mqd_t mqdes" -.Fa "struct mq_attr *restrict mqstat" +.Fa "const struct mq_attr *restrict mqstat" .Fa "struct mq_attr *restrict omqstat" .Fc .Sh DESCRIPTION