svn commit: r220051 - head/sys/mips/atheros
Author: adrian Date: Sun Mar 27 08:32:47 2011 New Revision: 220051 URL: http://svn.freebsd.org/changeset/base/220051 Log: Add some missing flags needed for AR913x/AR724x USB to correctly operate. The AR913x/AR724x USB lives at a different offset to the AR71xx USB, so this needs to be either adjusted for in a subsequent commit, or updated in hints for kernels compiled for those platforms. Submitted by: Luiz Otavio O Souzau loos...@gmail.com Modified: head/sys/mips/atheros/ar71xx_ehci.c Modified: head/sys/mips/atheros/ar71xx_ehci.c == --- head/sys/mips/atheros/ar71xx_ehci.c Sun Mar 27 05:09:21 2011 (r220050) +++ head/sys/mips/atheros/ar71xx_ehci.c Sun Mar 27 08:32:47 2011 (r220051) @@ -54,6 +54,7 @@ __FBSDID($FreeBSD$); #include dev/usb/controller/ehci.h #include dev/usb/controller/ehcireg.h +#include mips/atheros/ar71xx_setup.h #include mips/atheros/ar71xx_bus_space_reversed.h #define EHCI_HC_DEVSTR AR71XX Integrated USB 2.0 controller @@ -192,6 +193,19 @@ ar71xx_ehci_attach(device_t self) * register following a port enable. */ sc-sc_flags = EHCI_SCFLG_SETMODE; + + switch (ar71xx_soc) { + case AR71XX_SOC_AR7241: + case AR71XX_SOC_AR7242: + case AR71XX_SOC_AR9130: + case AR71XX_SOC_AR9132: + sc-sc_flags |= EHCI_SCFLG_TT | EHCI_SCFLG_NORESTERM; + break; + default: + /* fallthrough */ + break; + } + (void) ehci_reset(sc); err = ehci_init(sc); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r220052 - in head/sys: conf mips/atheros
Author: adrian Date: Sun Mar 27 08:44:27 2011 New Revision: 220052 URL: http://svn.freebsd.org/changeset/base/220052 Log: Add an option - AR71XX_REALMEM - which overrides the amount of memory detected from Redboot, or overrides the otherwise case if no Redboot information was found. Some AR71XX platforms don't use Redboot (eg TP-LINK devices using UBoot; some later Ubiquiti devices which apparently also use UBoot) and at least one plain out lies - the Ubiquiti LS-SR71A Redboot says there's 16mb of RAM when in fact there's 32mb. A more clean solution will be needed at a later date. Modified: head/sys/conf/options head/sys/mips/atheros/ar71xx_machdep.c Modified: head/sys/conf/options == --- head/sys/conf/options Sun Mar 27 08:32:47 2011(r220051) +++ head/sys/conf/options Sun Mar 27 08:44:27 2011(r220052) @@ -872,3 +872,9 @@ SDP opt_ofed.h SDP_DEBUG opt_ofed.h IPOIB_DEBUGopt_ofed.h IPOIB_CM opt_ofed.h + +# At least one of the AR71XX ubiquiti boards has a Redboot configuration +# that lies about the amount of RAM it has. Until a cleaner method is +# defined, this option will suffice in overriding what Redboot says. +AR71XX_REALMEMopt_global.h + Modified: head/sys/mips/atheros/ar71xx_machdep.c == --- head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 08:32:47 2011 (r220051) +++ head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 08:44:27 2011 (r220052) @@ -180,6 +180,20 @@ platform_start(__register_t a0 __unused, if (realmem == 0) realmem = btoc(32*1024*1024); + /* +* Allow build-time override in case Redboot lies +* or in other situations (eg where there's u-boot) +* where there isn't (yet) a convienent method of +* being told how much RAM is available. +* +* This happens on at least the Ubiquiti LS-SR71A +* board, where redboot says there's 16mb of RAM +* but in fact there's 32mb. +*/ +#ifdefined(AR71XX_REALMEM) + realmem = btoc(MIPS_REALMEM); +#endif + /* phys_avail regions are in bytes */ phys_avail[0] = MIPS_KSEG0_TO_PHYS(kernel_kseg0_end); phys_avail[1] = ctob(realmem); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r220055 - head/usr.bin/su
Author: ume Date: Sun Mar 27 12:53:20 2011 New Revision: 220055 URL: http://svn.freebsd.org/changeset/base/220055 Log: getpwnam(3) may return NULL. Requested by: nork Reviewed by:Takeharu KATO takeharu1219__at__ybb.ne.jp, nork MFC after: 1 week Modified: head/usr.bin/su/su.c Modified: head/usr.bin/su/su.c == --- head/usr.bin/su/su.cSun Mar 27 10:35:39 2011(r220054) +++ head/usr.bin/su/su.cSun Mar 27 12:53:20 2011(r220055) @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) { static char *cleanenv; - struct passwd *pwd; + struct passwd *pwd = NULL; struct pam_conv conv = { openpam_ttyconv, NULL }; enum tristate iscsh; login_cap_t *lc; @@ -255,8 +255,9 @@ main(int argc, char *argv[]) /* get current login name, real uid and shell */ ruid = getuid(); username = getlogin(); - pwd = getpwnam(username); - if (username == NULL || pwd == NULL || pwd-pw_uid != ruid) + if (username != NULL) + pwd = getpwnam(username); + if (pwd == NULL || pwd-pw_uid != ruid) pwd = getpwuid(ruid); if (pwd == NULL) { #ifdef USE_BSM_AUDIT ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r220056 - head/sys/mips/atheros
Author: adrian Date: Sun Mar 27 13:55:35 2011 New Revision: 220056 URL: http://svn.freebsd.org/changeset/base/220056 Log: Refactor out the ar71xx mac address code into something that's just for Redboot. At some point we're going to need to build options for different boot environments - for example, the UBoot setups I've seen simply have the MAC address hard-coded at a fixed location in flash. The OpenWRT support simply yanks the if_arge MAC directly from that in code, rather than trying to find a uboot environment to pull it from. Modified: head/sys/mips/atheros/ar71xx_machdep.c Modified: head/sys/mips/atheros/ar71xx_machdep.c == --- head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 12:53:20 2011 (r220055) +++ head/sys/mips/atheros/ar71xx_machdep.c Sun Mar 27 13:55:35 2011 (r220056) @@ -139,13 +139,39 @@ platform_trap_exit(void) } +/* + * Obtain the MAC address via the Redboot environment. + */ +static void +ar71xx_redboot_get_macaddr(void) +{ + char *var; + int count = 0; + + /* +* ethaddr is passed via envp on RedBoot platforms +* kmac is passed via argv on RouterBOOT platforms +*/ + if ((var = getenv(ethaddr)) != NULL || + (var = getenv(kmac)) != NULL) { + count = sscanf(var, %x%*c%x%*c%x%*c%x%*c%x%*c%x, + ar711_base_mac[0], ar711_base_mac[1], + ar711_base_mac[2], ar711_base_mac[3], + ar711_base_mac[4], ar711_base_mac[5]); + if (count 6) + memset(ar711_base_mac, 0, + sizeof(ar711_base_mac)); + freeenv(var); + } +} + void platform_start(__register_t a0 __unused, __register_t a1 __unused, __register_t a2 __unused, __register_t a3 __unused) { uint64_t platform_counter_freq; - int argc, i, count = 0; - char **argv, **envp, *var; + int argc, i; + char **argv, **envp; vm_offset_t kernend; /* @@ -252,21 +278,8 @@ platform_start(__register_t a0 __unused, else printf (envp is invalid\n); - /* -* ethaddr is passed via envp on RedBoot platforms -* kmac is passed via argv on RouterBOOT platforms -*/ - if ((var = getenv(ethaddr)) != NULL || - (var = getenv(kmac)) != NULL) { - count = sscanf(var, %x%*c%x%*c%x%*c%x%*c%x%*c%x, - ar711_base_mac[0], ar711_base_mac[1], - ar711_base_mac[2], ar711_base_mac[3], - ar711_base_mac[4], ar711_base_mac[5]); - if (count 6) - memset(ar711_base_mac, 0, - sizeof(ar711_base_mac)); - freeenv(var); - } + /* Redboot if_arge MAC address is in the environment */ + ar71xx_redboot_get_macaddr(); init_param2(physmem); mips_cpu_init(); ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r220057 - head/usr.sbin/pc-sysinstall/backend
Author: jpaetzel Date: Sun Mar 27 14:20:47 2011 New Revision: 220057 URL: http://svn.freebsd.org/changeset/base/220057 Log: Increase size of boot partition to give breathing room in the future. Approved by: kib (mentor) Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh == --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Sun Mar 27 13:55:35 2011(r220056) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh Sun Mar 27 14:20:47 2011(r220057) @@ -596,7 +596,7 @@ init_gpt_full_disk() echo_log Running gpart on ${_intDISK} rc_halt gpart create -s GPT ${_intDISK} - rc_halt gpart add -b 34 -s 64 -t freebsd-boot ${_intDISK} + rc_halt gpart add -b 34 -s 128 -t freebsd-boot ${_intDISK} echo_log Stamping boot sector on ${_intDISK} rc_halt gpart bootcode -b /boot/pmbr ${_intDISK} ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r220058 - in head/sys/amd64: amd64 include
Author: alc Date: Sun Mar 27 16:18:51 2011 New Revision: 220058 URL: http://svn.freebsd.org/changeset/base/220058 Log: Amd64 doesn't have a lazypmap ipi. Modified: head/sys/amd64/amd64/mp_machdep.c head/sys/amd64/include/smp.h Modified: head/sys/amd64/amd64/mp_machdep.c == --- head/sys/amd64/amd64/mp_machdep.c Sun Mar 27 14:20:47 2011 (r220057) +++ head/sys/amd64/amd64/mp_machdep.c Sun Mar 27 16:18:51 2011 (r220058) @@ -116,7 +116,6 @@ u_long *ipi_invlrng_counts[MAXCPU]; u_long *ipi_invlpg_counts[MAXCPU]; u_long *ipi_invlcache_counts[MAXCPU]; u_long *ipi_rendezvous_counts[MAXCPU]; -u_long *ipi_lazypmap_counts[MAXCPU]; static u_long *ipi_hardclock_counts[MAXCPU]; #endif @@ -1620,8 +1619,6 @@ mp_ipi_intrcnt(void *dummy) intrcnt_add(buf, ipi_ast_counts[i]); snprintf(buf, sizeof(buf), cpu%d:rendezvous, i); intrcnt_add(buf, ipi_rendezvous_counts[i]); - snprintf(buf, sizeof(buf), cpu%d:lazypmap, i); - intrcnt_add(buf, ipi_lazypmap_counts[i]); snprintf(buf, sizeof(buf), cpu%d:hardclock, i); intrcnt_add(buf, ipi_hardclock_counts[i]); } Modified: head/sys/amd64/include/smp.h == --- head/sys/amd64/include/smp.hSun Mar 27 14:20:47 2011 (r220057) +++ head/sys/amd64/include/smp.hSun Mar 27 16:18:51 2011 (r220058) @@ -41,7 +41,6 @@ extern u_long *ipi_invlrng_counts[MAXCPU extern u_long *ipi_invlpg_counts[MAXCPU]; extern u_long *ipi_invlcache_counts[MAXCPU]; extern u_long *ipi_rendezvous_counts[MAXCPU]; -extern u_long *ipi_lazypmap_counts[MAXCPU]; #endif /* IPI handlers */ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r220059 - head/usr.sbin/pc-sysinstall/backend
Author: jpaetzel Date: Sun Mar 27 16:57:54 2011 New Revision: 220059 URL: http://svn.freebsd.org/changeset/base/220059 Log: Fix a syntax error in a little-used function. Replace expr with $(()) Replace grep /dev/null with grep -q Replace $? = 0 with $? -eq 0 in tests Consolidate export statements with variable assignment Replace tests for ! -z with -n Approved by: kib (mentor) Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh head/usr.sbin/pc-sysinstall/backend/functions-disk.sh head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh head/usr.sbin/pc-sysinstall/backend/functions-ftp.sh head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh head/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh head/usr.sbin/pc-sysinstall/backend/functions-localize.sh head/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh head/usr.sbin/pc-sysinstall/backend/functions-networking.sh head/usr.sbin/pc-sysinstall/backend/functions-packages.sh head/usr.sbin/pc-sysinstall/backend/functions-parse.sh head/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh head/usr.sbin/pc-sysinstall/backend/functions-unmount.sh head/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh head/usr.sbin/pc-sysinstall/backend/functions-users.sh head/usr.sbin/pc-sysinstall/backend/functions.sh head/usr.sbin/pc-sysinstall/backend/parseconfig.sh head/usr.sbin/pc-sysinstall/backend/startautoinstall.sh Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh == --- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Sun Mar 27 16:18:51 2011(r220058) +++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh Sun Mar 27 16:57:54 2011(r220059) @@ -33,14 +33,14 @@ check_for_enc_pass() CURLINE=${1} get_next_cfg_line ${CFGF} ${CURLINE} - echo ${VAL} | grep ^encpass= /dev/null 2/dev/null - if [ $? = 0 ] ; then + echo ${VAL} | grep -q ^encpass= 2/dev/null + if [ $? -eq 0 ] ; then # Found a password, return it get_value_from_string ${VAL} return fi - VAL= ; export VAL + export VAL= return }; @@ -51,17 +51,17 @@ get_fs_line_xvars() ACTIVEDEV=${1} LINE=${2} - echo $LINE | grep ' (' /dev/null 2/dev/null - if [ $? = 0 ] ; then + echo $LINE | grep -q ' (' 2/dev/null + if [ $? -eq 0 ] ; then # See if we are looking for ZFS specific options -echo $LINE | grep '^ZFS' /dev/null 2/dev/null -if [ $? = 0 ] ; then +echo $LINE | grep -q '^ZFS' 2/dev/null +if [ $? -eq 0 ] ; then ZTYPE=NONE ZFSVARS=`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs` - echo $ZFSVARS | grep -E ^(disk|file|mirror|raidz(1|2)?|spare|log|cache): /dev/null 2/dev/null - if [ $? = 0 ] ; then + echo $ZFSVARS | grep -qE ^(disk|file|mirror|raidz(1|2)?|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` fi @@ -79,8 +79,7 @@ get_fs_line_xvars() fi # End of xtra-options block # If we got here, set VAR to empty and export - VAR= - export VAR + export VAR= return }; @@ -94,12 +93,12 @@ setup_zfs_mirror_parts() for _zvars in $_mirrline do echo Looping through _zvars: $_zvars ${LOGOUT} -echo $_zvars | grep ${2} /dev/null 2/dev/null -if [ $? = 0 ] ; then continue ; fi +echo $_zvars | grep -q ${2} 2/dev/null +if [ $? -eq 0 ] ; then continue ; fi if [ -z $_zvars ] ; then continue ; fi is_disk $_zvars /dev/null 2/dev/null -if [ $? = 0 ] ; then +if [ $? -eq 0 ] ; then echo Setting up ZFS mirror disk $_zvars ${LOGOUT} init_gpt_full_disk $_zvars /dev/null 2/dev/null rc_halt gpart bootcode -p /boot/gptzfsboot -i 1 ${_zvars} /dev/null 2/dev/null @@ -138,12 +137,12 @@ gen_glabel_name() while Z=1 do -glabel status | grep ${NAME}${NUM} /dev/null 2/dev/null -if [ $? != 0 ] +glabel status | grep -q ${NAME}${NUM} 2/dev/null +if [ $? -ne 0 ] then break else - NUM=`expr ${NUM} + 1` +NUM=$((NUM+1)) fi if [ $NUM -gt $MAXNUM ] @@ -154,8 +153,7 @@ gen_glabel_name() done - VAL=${NAME}${NUM} - export VAL + export VAL=${NAME}${NUM} }; # Function to setup partitions using gpart @@ -180,8 +178,8 @@ setup_gpart_partitions() while read line do # Check for data on this slice -echo $line | grep ^${_dTag}-part= /dev/null 2/dev/null -if [ $? = 0 ] +echo $line | grep -q ^${_dTag}-part= 2/dev/null +if [ $? -eq 0 ] then FOUNDPARTS=0 # Found a slice- entry, lets get the slice info @@ -194,8 +192,8 @@ setup_gpart_partitions() MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 3` # Check
Re: svn commit: r220059 - head/usr.sbin/pc-sysinstall/backend
On 03/27/2011 09:57, Josh Paetzel wrote: Log: Fix a syntax error in a little-used function. Since this is unique vs. all the other changes, IMO it should have been a separate commit. It doesn't hurt anything to split things up into multiple commits, and often helps make things more understandable down the road. Replace expr with $(()) Replace tests for ! -z with -n Good. :) Replace grep /dev/null with grep -q Consolidate export statements with variable assignment These 2 make the code slightly less portable, but in this case I don't think that's a problem at all. Replace $? = 0 with $? -eq 0 in tests Excellent! hth, Doug -- Nothin' ever doesn't change, but nothin' changes much. -- OK Go Breadth of IT experience, and depth of knowledge in the DNS. Yours for the right price. :) http://SupersetSolutions.com/ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r220062 - head/sys/geom/gate
Author: trociny Date: Sun Mar 27 19:56:55 2011 New Revision: 220062 URL: http://svn.freebsd.org/changeset/base/220062 Log: In g_gate_create() there is a window between when g_gate_softc is registered in g_gate_units array and when its sc_provider field is filled. If during this period g_gate_units is accessed by another thread that is checking for provider name collision the crash is possible. Fix this by adding sc_name field to struct g_gate_softc. In g_gate_create() when g_gate_softc is created but sc_provider is still not sc_name points to provider name stored in the local array. Approved by: pjd (mentor) Reported by: Freddie Cash fjwc...@gmail.com MFC after:1 week Modified: head/sys/geom/gate/g_gate.c head/sys/geom/gate/g_gate.h Modified: head/sys/geom/gate/g_gate.c == --- head/sys/geom/gate/g_gate.c Sun Mar 27 19:29:18 2011(r220061) +++ head/sys/geom/gate/g_gate.c Sun Mar 27 19:56:55 2011(r220062) @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * for (unit = 0; unit g_gate_maxunits; unit++) { if (g_gate_units[unit] == NULL) continue; - if (strcmp(name, g_gate_units[unit]-sc_provider-name) != 0) + if (strcmp(name, g_gate_units[unit]-sc_name) != 0) continue; mtx_unlock(g_gate_units_lock); mtx_destroy(sc-sc_queue_mtx); free(sc, M_GATE); return (EEXIST); } + sc-sc_name = name; g_gate_units[sc-sc_unit] = sc; g_gate_nunits++; mtx_unlock(g_gate_units_lock); @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * sc-sc_provider = pp; g_error_provider(pp, 0); g_topology_unlock(); + mtx_lock(g_gate_units_lock); + sc-sc_name = sc-sc_provider-name; + mtx_unlock(g_gate_units_lock); if (sc-sc_timeout 0) { callout_reset(sc-sc_callout, sc-sc_timeout * hz, Modified: head/sys/geom/gate/g_gate.h == --- head/sys/geom/gate/g_gate.h Sun Mar 27 19:29:18 2011(r220061) +++ head/sys/geom/gate/g_gate.h Sun Mar 27 19:56:55 2011(r220062) @@ -76,6 +76,7 @@ * 'P:' means 'Protected by'. */ struct g_gate_softc { + char*sc_name; /* P: (read-only) */ int sc_unit; /* P: (read-only) */ int sc_ref;/* P: g_gate_list_mtx */ struct g_provider *sc_provider; /* P: (read-only) */ @@ -96,7 +97,6 @@ struct g_gate_softc { LIST_ENTRY(g_gate_softc) sc_next; /* P: g_gate_list_mtx */ char sc_info[G_GATE_INFOSIZE]; /* P: (read-only) */ }; -#definesc_name sc_provider-geom-name #defineG_GATE_DEBUG(lvl, ...) do { \ if (g_gate_debug = (lvl)) {\ ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r220062 - head/sys/geom/gate
On Sun, Mar 27, 2011 at 07:56:55PM +, Mikolaj Golub wrote: Author: trociny Date: Sun Mar 27 19:56:55 2011 New Revision: 220062 URL: http://svn.freebsd.org/changeset/base/220062 Log: In g_gate_create() there is a window between when g_gate_softc is registered in g_gate_units array and when its sc_provider field is filled. If during this period g_gate_units is accessed by another thread that is checking for provider name collision the crash is possible. Fix this by adding sc_name field to struct g_gate_softc. In g_gate_create() when g_gate_softc is created but sc_provider is still not sc_name points to provider name stored in the local array. Approved by:pjd (mentor) Reported by:Freddie Cash fjwc...@gmail.com MFC after: 1 week Modified: head/sys/geom/gate/g_gate.c head/sys/geom/gate/g_gate.h Modified: head/sys/geom/gate/g_gate.c == --- head/sys/geom/gate/g_gate.c Sun Mar 27 19:29:18 2011 (r220061) +++ head/sys/geom/gate/g_gate.c Sun Mar 27 19:56:55 2011 (r220062) @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * for (unit = 0; unit g_gate_maxunits; unit++) { if (g_gate_units[unit] == NULL) continue; - if (strcmp(name, g_gate_units[unit]-sc_provider-name) != 0) + if (strcmp(name, g_gate_units[unit]-sc_name) != 0) continue; mtx_unlock(g_gate_units_lock); mtx_destroy(sc-sc_queue_mtx); free(sc, M_GATE); return (EEXIST); } + sc-sc_name = name; g_gate_units[sc-sc_unit] = sc; g_gate_nunits++; mtx_unlock(g_gate_units_lock); @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * sc-sc_provider = pp; g_error_provider(pp, 0); g_topology_unlock(); + mtx_lock(g_gate_units_lock); + sc-sc_name = sc-sc_provider-name; + mtx_unlock(g_gate_units_lock); I think you do not need a mutex locked around the single assignment. As I understand, sc_provider-name is constant ? pgpTGmgGo5TJY.pgp Description: PGP signature
Re: svn commit: r220062 - head/sys/geom/gate
On Sun, 27 Mar 2011 23:08:04 +0300 Kostik Belousov wrote: KB On Sun, Mar 27, 2011 at 07:56:55PM +, Mikolaj Golub wrote: Author: trociny Date: Sun Mar 27 19:56:55 2011 New Revision: 220062 URL: http://svn.freebsd.org/changeset/base/220062 Log: In g_gate_create() there is a window between when g_gate_softc is registered in g_gate_units array and when its sc_provider field is filled. If during this period g_gate_units is accessed by another thread that is checking for provider name collision the crash is possible. Fix this by adding sc_name field to struct g_gate_softc. In g_gate_create() when g_gate_softc is created but sc_provider is still not sc_name points to provider name stored in the local array. Approved by:pjd (mentor) Reported by:Freddie Cash fjwc...@gmail.com MFC after:1 week Modified: head/sys/geom/gate/g_gate.c head/sys/geom/gate/g_gate.h Modified: head/sys/geom/gate/g_gate.c == --- head/sys/geom/gate/g_gate.cSun Mar 27 19:29:18 2011 (r220061) +++ head/sys/geom/gate/g_gate.cSun Mar 27 19:56:55 2011 (r220062) @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * for (unit = 0; unit g_gate_maxunits; unit++) { if (g_gate_units[unit] == NULL) continue; -if (strcmp(name, g_gate_units[unit]-sc_provider-name) != 0) +if (strcmp(name, g_gate_units[unit]-sc_name) != 0) continue; mtx_unlock(g_gate_units_lock); mtx_destroy(sc-sc_queue_mtx); free(sc, M_GATE); return (EEXIST); } +sc-sc_name = name; g_gate_units[sc-sc_unit] = sc; g_gate_nunits++; mtx_unlock(g_gate_units_lock); @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * sc-sc_provider = pp; g_error_provider(pp, 0); g_topology_unlock(); +mtx_lock(g_gate_units_lock); +sc-sc_name = sc-sc_provider-name; +mtx_unlock(g_gate_units_lock); KB I think you do not need a mutex locked around the single assignment. KB As I understand, sc_provider-name is constant ? Is the following scenario impossible? Thread A is looking for name collision and is accessing g_gate_units[unit]-sc_name of the unit that is being created by a thread B, so sc_name is pointing to thread B local buffer. At this time the thread B creates provider, does sc-sc_name = sc-sc_provider-name and returns from g_gate_create(). Thread A, if it is still working with g_gate_units[unit]-sc_name, is accessing invalid memory. -- Mikolaj Golub ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r220062 - head/sys/geom/gate
On Sun, Mar 27, 2011 at 11:49:15PM +0300, Mikolaj Golub wrote: On Sun, 27 Mar 2011 23:08:04 +0300 Kostik Belousov wrote: KB On Sun, Mar 27, 2011 at 07:56:55PM +, Mikolaj Golub wrote: Author: trociny Date: Sun Mar 27 19:56:55 2011 New Revision: 220062 URL: http://svn.freebsd.org/changeset/base/220062 Log: In g_gate_create() there is a window between when g_gate_softc is registered in g_gate_units array and when its sc_provider field is filled. If during this period g_gate_units is accessed by another thread that is checking for provider name collision the crash is possible. Fix this by adding sc_name field to struct g_gate_softc. In g_gate_create() when g_gate_softc is created but sc_provider is still not sc_name points to provider name stored in the local array. Approved by:pjd (mentor) Reported by:Freddie Cash fjwc...@gmail.com MFC after:1 week Modified: head/sys/geom/gate/g_gate.c head/sys/geom/gate/g_gate.h Modified: head/sys/geom/gate/g_gate.c == --- head/sys/geom/gate/g_gate.cSun Mar 27 19:29:18 2011 (r220061) +++ head/sys/geom/gate/g_gate.cSun Mar 27 19:56:55 2011 (r220062) @@ -409,13 +409,14 @@ g_gate_create(struct g_gate_ctl_create * for (unit = 0; unit g_gate_maxunits; unit++) { if (g_gate_units[unit] == NULL) continue; -if (strcmp(name, g_gate_units[unit]-sc_provider-name) != 0) +if (strcmp(name, g_gate_units[unit]-sc_name) != 0) continue; mtx_unlock(g_gate_units_lock); mtx_destroy(sc-sc_queue_mtx); free(sc, M_GATE); return (EEXIST); } +sc-sc_name = name; g_gate_units[sc-sc_unit] = sc; g_gate_nunits++; mtx_unlock(g_gate_units_lock); @@ -434,6 +435,9 @@ g_gate_create(struct g_gate_ctl_create * sc-sc_provider = pp; g_error_provider(pp, 0); g_topology_unlock(); +mtx_lock(g_gate_units_lock); +sc-sc_name = sc-sc_provider-name; +mtx_unlock(g_gate_units_lock); KB I think you do not need a mutex locked around the single assignment. KB As I understand, sc_provider-name is constant ? Is the following scenario impossible? Thread A is looking for name collision and is accessing g_gate_units[unit]-sc_name of the unit that is being created by a thread B, so sc_name is pointing to thread B local buffer. At this time the thread B creates provider, does sc-sc_name = sc-sc_provider-name and returns from g_gate_create(). Thread A, if it is still working with g_gate_units[unit]-sc_name, is accessing invalid memory. Ok, name is local variable. Apparently, what you need is a barrier. It would be enough to do sc-sc_name = sc-sc_provider-name; mtx_lock(g_gate_units_lock); mtx_unlock(g_gate_units_lock); The change is fine as is. pgpXjbRAphIvZ.pgp Description: PGP signature
Re: svn commit: r220059 - head/usr.sbin/pc-sysinstall/backend
On Mar 27, 2011, at 11:22 AM, Doug Barton wrote: On 03/27/2011 09:57, Josh Paetzel wrote: Replace $? = 0 with $? -eq 0 in tests Excellent! Most of the time I've found that moving the command up to the if makes the code clearer too. At jobs I've had in the past when I've written code similar to what we have here, it almost always got flagged... Warner ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r220080 - head/usr.sbin/bsdinstall/scripts
Author: nwhitehorn Date: Sun Mar 27 23:43:32 2011 New Revision: 220080 URL: http://svn.freebsd.org/changeset/base/220080 Log: Add mirror selection for FTP installs. To support TBEMD installs (e.g. powerpc64), this looks in a slightly different default path than now, specifying both $MACHINE and $MACHINE_ARCH: MIRROR/pub/FreeBSD/releases/`uname -p`/`uname -m`/`uname -r` How to handle TBEMD properly probably merits some more discussion, but, since no such 9.0-CURRENT distfiles exist at the moment, all existing mirrors presently fail anyway. Added: head/usr.sbin/bsdinstall/scripts/mirrorselect (contents, props changed) Modified: head/usr.sbin/bsdinstall/scripts/Makefile head/usr.sbin/bsdinstall/scripts/auto Modified: head/usr.sbin/bsdinstall/scripts/Makefile == --- head/usr.sbin/bsdinstall/scripts/Makefile Sun Mar 27 23:14:02 2011 (r220079) +++ head/usr.sbin/bsdinstall/scripts/Makefile Sun Mar 27 23:43:32 2011 (r220080) @@ -1,7 +1,7 @@ # $FreeBSD$ -SCRIPTS= auto adduser checksum config hostname jail keymap mount netconfig \ -rootpass services time umount wlanconfig +SCRIPTS= auto adduser checksum config hostname jail keymap mirrorselect \ +mount netconfig rootpass services time umount wlanconfig BINDIR= /usr/libexec/bsdinstall NO_MAN=true Modified: head/usr.sbin/bsdinstall/scripts/auto == --- head/usr.sbin/bsdinstall/scripts/auto Sun Mar 27 23:14:02 2011 (r220079) +++ head/usr.sbin/bsdinstall/scripts/auto Sun Mar 27 23:43:32 2011 (r220080) @@ -35,6 +35,7 @@ error() { if [ $? -ne 0 ]; then exit else + test -n $DISTDIR_IS_UNIONFS umount -f $BSDINSTALL_DISTDIR test -f $PATH_FSTAB bsdinstall umount exec $0 fi @@ -72,13 +73,23 @@ for dist in $DISTRIBUTIONS; do FETCH_DISTRIBUTIONS=$FETCH_DISTRIBUTIONS $dist fi done +FETCH_DISTRIBUTIONS=`echo $FETCH_DISTRIBUTIONS`# Trim white space -if [ ! -z $FETCH_DISTRIBUTIONS -a ! -z $BSDINSTALL_CONFIGCURRENT ]; then +if [ -n $FETCH_DISTRIBUTIONS -a -n $BSDINSTALL_CONFIGCURRENT ]; then dialog --backtitle FreeBSD Installer --title Network Installation --msgbox No installation files were found on the boot volume. The next few screens will allow you to configure networking so that they can be downloaded from the Internet. 0 0 bsdinstall netconfig || error NETCONFIG_DONE=yes fi +if [ -n $FETCH_DISTRIBUTIONS -a -z $BSDINSTALL_DISTSITE ]; then + exec 31 + BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 21 13` + MIRROR_BUTTON=$? + exec 3- + test $MIRROR_BUTTON -eq 0 || error + export BSDINSTALL_DISTSITE +fi + rm $PATH_FSTAB touch $PATH_FSTAB @@ -114,7 +125,11 @@ if [ ! -z $FETCH_DISTRIBUTIONS ]; then export DISTRIBUTIONS=$FETCH_DISTRIBUTIONS # Try to use any existing distfiles - [ -d $BSDINSTALL_DISTDIR -a $FETCH_DISTRIBUTIONS != $ALL_DISTRIBUTIONS ] mount_unionfs $BSDINSTALL_FETCHDEST $BSDINSTALL_DISTDIR + if [ -d $BSDINSTALL_DISTDIR -a $FETCH_DISTRIBUTIONS != \ + $ALL_DISTRIBUTIONS ]; then + DISTDIR_IS_UNIONFS=1 + mount_unionfs $BSDINSTALL_FETCHDEST $BSDINSTALL_DISTDIR + fi # Otherwise, fetch everything if [ $? -ne 0 ]; then @@ -126,6 +141,8 @@ if [ ! -z $FETCH_DISTRIBUTIONS ]; then export DISTRIBUTIONS=$ALL_DISTRIBUTIONS fi +error + bsdinstall checksum || error bsdinstall distextract || error bsdinstall rootpass || error Added: head/usr.sbin/bsdinstall/scripts/mirrorselect == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.sbin/bsdinstall/scripts/mirrorselect Sun Mar 27 23:43:32 2011(r220080) @@ -0,0 +1,214 @@ +#!/bin/sh +#- +# Copyright (c) 2011 Nathan Whitehorn +# All rights reserved. +# +# 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. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT,
svn commit: r220081 - head/release
Author: nwhitehorn Date: Sun Mar 27 23:46:12 2011 New Revision: 220081 URL: http://svn.freebsd.org/changeset/base/220081 Log: Add infrastructure for generation of boot-only ISO images. These have a reduced world, though still reasonably complete for fixit purposes. Modified: head/release/Makefile Modified: head/release/Makefile == --- head/release/Makefile Sun Mar 27 23:43:32 2011(r220080) +++ head/release/Makefile Sun Mar 27 23:46:12 2011(r220081) @@ -122,13 +122,38 @@ system: packagesystem ln -s /tmp/bsdinstall_etc/resolv.conf ${.OBJDIR}/release/etc/resolv.conf echo sendmail_enable=\NONE\ ${.OBJDIR}/release/etc/rc.conf echo hostid_enable=\NO\ ${.OBJDIR}/release/etc/rc.conf - touch ${.OBJDIR}/release/etc/fstab cp ${.CURDIR}/rc.local ${.OBJDIR}/release/etc touch ${.OBJDIR}/${.TARGET} +bootonly: packagesystem +# Install system + mkdir ${.OBJDIR}/bootonly + cd ${WORLDDIR} ${IMAKE} installkernel installworld distribution \ + DESTDIR=${.OBJDIR}/bootonly WITHOUT_AMD=1 WITHOUT_AT=1 \ + WITHOUT_BIND_DNSSEC=1 WITHOUT_BIND_ETC=1 WITHOUT_BIND_MTREE=1 \ + WITHOUT_BIND_NAMED=1 WITHOUT_GAMES=1 WITHOUT_GROFF=1 \ + WITHOUT_INSTALLLIB=1 WITHOUT_LIB32=1 WITHOUT_MAIL=1 \ + WITHOUT_NCP=1 WITHOUT_TOOLCHAIN=1 WITHOUT_RESCUE=1 WITHOUT_DICT=1 + -rm ${.OBJDIR}/bootonly/boot/kernel/*.symbols +# Copy manifest only (no distfiles) to get checksums + mkdir ${.OBJDIR}/bootonly/usr/freebsd-dist + cp ${.OBJDIR}/MANIFEST ${.OBJDIR}/bootonly/usr/freebsd-dist +# Copy documentation, if generated +.if !defined(NODOC) + cp ${.OBJDIR}/reldoc/* ${.OBJDIR}/bootonly +.endif +# Set up installation environment + ln -s /tmp/bsdinstall_etc/resolv.conf ${.OBJDIR}/bootonly/etc/resolv.conf + echo sendmail_enable=\NONE\ ${.OBJDIR}/bootonly/etc/rc.conf + echo hostid_enable=\NO\ ${.OBJDIR}/bootonly/etc/rc.conf + cp ${.CURDIR}/rc.local ${.OBJDIR}/bootonly/etc + release.iso: system sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.OBJDIR}/release.iso ${.OBJDIR}/release +bootonly.iso: bootonly + sh ${.CURDIR}/${TARGET}/mkisoimages.sh -b FreeBSD_Install ${.OBJDIR}/bootonly.iso ${.OBJDIR}/bootonly + memstick: system sh ${.CURDIR}/${TARGET}/make-memstick.sh ${.OBJDIR}/release ${.OBJDIR}/memstick @@ -136,7 +161,7 @@ packagesystem: base.txz kernel.txz ${EXT sh ${.CURDIR}/scripts/make-manifest.sh ${.OBJDIR}/*.txz ${.OBJDIR}/MANIFEST touch ${.OBJDIR}/${.TARGET} -cdrom: release.iso +cdrom: release.iso bootonly.iso ftp: packagesystem rm -rf ${.OBJDIR}/ftp mkdir ${.OBJDIR}/ftp ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r220082 - head/release
Author: nwhitehorn Date: Sun Mar 27 23:46:52 2011 New Revision: 220082 URL: http://svn.freebsd.org/changeset/base/220082 Log: Copy all generated ISO images into the release area. Modified: head/release/generate-release.sh Modified: head/release/generate-release.sh == --- head/release/generate-release.shSun Mar 27 23:46:12 2011 (r220081) +++ head/release/generate-release.shSun Mar 27 23:46:52 2011 (r220082) @@ -62,5 +62,5 @@ fi chroot $2 /bin/sh -c cd /usr/src make $MAKE_FLAGS buildworld buildkernel || exit 1 chroot $2 /bin/sh -c cd /usr/src/release make release || exit 1 mkdir $2/R -cp -pRP $2/usr/obj/usr/src/release/release.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R +cp -pRP $2/usr/obj/usr/src/release/*.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
Re: svn commit: r220082 - head/release
On Sun Mar 27 11, Nathan Whitehorn wrote: Author: nwhitehorn Date: Sun Mar 27 23:46:52 2011 New Revision: 220082 URL: http://svn.freebsd.org/changeset/base/220082 Log: Copy all generated ISO images into the release area. s/cp -pRP/cp -a/ ? Modified: head/release/generate-release.sh Modified: head/release/generate-release.sh == --- head/release/generate-release.sh Sun Mar 27 23:46:12 2011 (r220081) +++ head/release/generate-release.sh Sun Mar 27 23:46:52 2011 (r220082) @@ -62,5 +62,5 @@ fi chroot $2 /bin/sh -c cd /usr/src make $MAKE_FLAGS buildworld buildkernel || exit 1 chroot $2 /bin/sh -c cd /usr/src/release make release || exit 1 mkdir $2/R -cp -pRP $2/usr/obj/usr/src/release/release.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R +cp -pRP $2/usr/obj/usr/src/release/*.iso $2/usr/obj/usr/src/release/memstick $2/usr/obj/usr/src/release/ftp $2/R -- a13x ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r220088 - head/usr.sbin/bsdinstall/scripts
Author: nwhitehorn Date: Mon Mar 28 02:37:05 2011 New Revision: 220088 URL: http://svn.freebsd.org/changeset/base/220088 Log: Improve error handling. Modified: head/usr.sbin/bsdinstall/scripts/auto Modified: head/usr.sbin/bsdinstall/scripts/auto == --- head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 01:24:20 2011 (r220087) +++ head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 02:37:05 2011 (r220088) @@ -29,14 +29,14 @@ echo Begun Installation at $(date) $BSDINSTALL_LOG error() { + test -n $DISTDIR_IS_UNIONFS umount -f $BSDINSTALL_DISTDIR + test -f $PATH_FSTAB bsdinstall umount dialog --backtitle FreeBSD Installer --title Abort \ --no-label Exit --yes-label Restart --yesno \ An installation step has been aborted. Would you like to restart the installation or exit the installer? 0 0 if [ $? -ne 0 ]; then exit else - test -n $DISTDIR_IS_UNIONFS umount -f $BSDINSTALL_DISTDIR - test -f $PATH_FSTAB bsdinstall umount exec $0 fi } @@ -81,7 +81,7 @@ if [ -n $FETCH_DISTRIBUTIONS -a -n $B NETCONFIG_DONE=yes fi -if [ -n $FETCH_DISTRIBUTIONS -a -z $BSDINSTALL_DISTSITE ]; then +if [ -n $FETCH_DISTRIBUTIONS ]; then exec 31 BSDINSTALL_DISTSITE=`bsdinstall mirrorselect 21 13` MIRROR_BUTTON=$? @@ -125,8 +125,7 @@ if [ ! -z $FETCH_DISTRIBUTIONS ]; then export DISTRIBUTIONS=$FETCH_DISTRIBUTIONS # Try to use any existing distfiles - if [ -d $BSDINSTALL_DISTDIR -a $FETCH_DISTRIBUTIONS != \ - $ALL_DISTRIBUTIONS ]; then + if [ -d $BSDINSTALL_DISTDIR ]; then DISTDIR_IS_UNIONFS=1 mount_unionfs $BSDINSTALL_FETCHDEST $BSDINSTALL_DISTDIR fi ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org
svn commit: r220089 - head/usr.sbin/bsdinstall/scripts
Author: nwhitehorn Date: Mon Mar 28 04:29:50 2011 New Revision: 220089 URL: http://svn.freebsd.org/changeset/base/220089 Log: Committing while tired is never a good idea. Remove an unconditional error exit left over from debugging. Modified: head/usr.sbin/bsdinstall/scripts/auto Modified: head/usr.sbin/bsdinstall/scripts/auto == --- head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 02:37:05 2011 (r220088) +++ head/usr.sbin/bsdinstall/scripts/auto Mon Mar 28 04:29:50 2011 (r220089) @@ -140,8 +140,6 @@ if [ ! -z $FETCH_DISTRIBUTIONS ]; then export DISTRIBUTIONS=$ALL_DISTRIBUTIONS fi -error - bsdinstall checksum || error bsdinstall distextract || error bsdinstall rootpass || error ___ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org