diff options
author | attilio <attilio@FreeBSD.org> | 2011-09-28 12:13:15 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2011-09-28 12:13:15 +0000 |
commit | ddd6ad1bbabe9c2e96c3acc65b3acfc2ca18f699 (patch) | |
tree | 081b555117cb8cae2fbee8a7cdda047571b254fd | |
parent | 86f03335bdfb87f976f37fa03a2e3512303069ca (diff) | |
download | FreeBSD-src-ddd6ad1bbabe9c2e96c3acc65b3acfc2ca18f699.zip FreeBSD-src-ddd6ad1bbabe9c2e96c3acc65b3acfc2ca18f699.tar.gz |
MFC
77 files changed, 642 insertions, 421 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1 index 7228f85..a594050 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -1218,7 +1218,8 @@ _startup_libs+= lib/libc gnu/lib/libgcc__L: lib/libc__L -_prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libheimntlm} \ +_prebuild_libs= ${_kerberos5_lib_libasn1} ${_kerberos5_lib_libhdb} \ + ${_kerberos5_lib_libheimntlm} \ ${_kerberos5_lib_libhx509} ${_kerberos5_lib_libkrb5} \ ${_kerberos5_lib_libroken} \ lib/libbz2 lib/libcom_err lib/libcrypt \ @@ -1268,6 +1269,19 @@ secure/lib/libssh__L: lib/libgssapi__L kerberos5/lib/libkrb5__L \ _secure_lib= secure/lib .endif +.if ${MK_KERBEROS} != "no" +kerberos5/lib/libasn1__L: lib/libcom_err__L kerberos5/lib/libroken__L +kerberos5/lib/libhdb__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ + kerberos5/lib/libkrb5__L kerberos5/lib/libroken__L +kerberos5/lib/libheimntlm__L: secure/lib/libcrypto__L kerberos5/lib/libkrb5__L +kerberos5/lib/libhx509__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ + secure/lib/libcrypto__L kerberos5/lib/libroken__L +kerberos5/lib/libkrb5__L: kerberos5/lib/libasn1__L lib/libcom_err__L \ + lib/libcrypt__L secure/lib/libcrypto__L kerberos5/lib/libhx509__L \ + kerberos5/lib/libroken__L +kerberos5/lib/libroken__L: lib/libcrypt__L +.endif + .if ${MK_GSSAPI} != "no" _lib_libgssapi= lib/libgssapi .endif @@ -1279,6 +1293,7 @@ _lib_libipx= lib/libipx .if ${MK_KERBEROS} != "no" _kerberos5_lib= kerberos5/lib _kerberos5_lib_libasn1= kerberos5/lib/libasn1 +_kerberos5_lib_libhdb= kerberos5/lib/libhdb _kerberos5_lib_libkrb5= kerberos5/lib/libkrb5 _kerberos5_lib_libhx509= kerberos5/lib/libhx509 _kerberos5_lib_libroken= kerberos5/lib/libroken @@ -9,8 +9,8 @@ handbook. Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. -NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.x IS SLOW: - FreeBSD 9.x has many debugging features turned on, in both the kernel +NOTE TO PEOPLE WHO THINK THAT FreeBSD 10.x IS SLOW: + FreeBSD 10.x has many debugging features turned on, in both the kernel and userland. These features attempt to detect incorrect use of system primitives, and encourage loud failure through extra sanity checking and fail stop semantics. They also substantially impact @@ -22,6 +22,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 9.x IS SLOW: machines to maximize performance. (To disable malloc debugging, run ln -s aj /etc/malloc.conf.) +20110923: + The stable/9 branch created in subversion. This corresponds to the + RELENG_9 branch in CVS. + 20110913: This commit modifies vfs_register() so that it uses a hash calculation to set vfc_typenum, which is enabled by default. diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.include.dist index f960c52..5ec7239 100644 --- a/etc/mtree/BSD.include.dist +++ b/etc/mtree/BSD.include.dist @@ -96,6 +96,8 @@ .. bktr .. + ciss + .. firewire .. hwpmc diff --git a/gnu/usr.bin/groff/tmac/mdoc.local b/gnu/usr.bin/groff/tmac/mdoc.local index 8c356f5..4436c60 100644 --- a/gnu/usr.bin/groff/tmac/mdoc.local +++ b/gnu/usr.bin/groff/tmac/mdoc.local @@ -71,12 +71,13 @@ .ds doc-volume-as-arm arm . .\" Default .Os value -.ds doc-default-operating-system FreeBSD\~9.0 +.ds doc-default-operating-system FreeBSD\~10.0 . .\" FreeBSD releases not found in doc-common .ds doc-operating-system-FreeBSD-7.4 7.4 .ds doc-operating-system-FreeBSD-8.3 8.3 .ds doc-operating-system-FreeBSD-9.0 9.0 +.ds doc-operating-system-FreeBSD-10.0 10.0 . .\" Definitions not (yet) in doc-syms . diff --git a/include/Makefile b/include/Makefile index 7c8ab1a..3e6705c 100644 --- a/include/Makefile +++ b/include/Makefile @@ -39,7 +39,7 @@ LDIRS= bsm cam geom net net80211 netatalk netgraph netinet netinet6 \ sys vm LSUBDIRS= cam/ata cam/scsi \ - dev/acpica dev/an dev/bktr dev/firewire dev/hwpmc \ + dev/acpica dev/an dev/bktr dev/ciss dev/firewire dev/hwpmc \ dev/ic dev/iicbus ${_dev_ieee488} dev/io dev/lmc dev/mfi dev/ofw \ dev/pbio ${_dev_powermac_nvram} dev/ppbus dev/smbus \ dev/speaker dev/usb dev/utopia dev/vkbd dev/wi \ diff --git a/include/iso646.h b/include/iso646.h index d38bf4b..a11101e 100644 --- a/include/iso646.h +++ b/include/iso646.h @@ -29,6 +29,8 @@ #ifndef _ISO646_H_ #define _ISO646_H_ +#ifndef __cplusplus + #define and && #define and_eq &= #define bitand & @@ -41,4 +43,6 @@ #define xor ^ #define xor_eq ^= +#endif /* !__cplusplus */ + #endif /* !_ISO646_H_ */ diff --git a/kerberos5/lib/libasn1/Makefile b/kerberos5/lib/libasn1/Makefile index 4a9c21e..cf91a4b 100644 --- a/kerberos5/lib/libasn1/Makefile +++ b/kerberos5/lib/libasn1/Makefile @@ -1,7 +1,10 @@ # $FreeBSD$ LIB= asn1 +LDFLAGS= -Wl,--no-undefined INCS= asn1_err.h heim_asn1.h +LDADD= -lcom_err -lroken +DPADD= ${LIBCOM_ERR} ${LIBROKEN} SRCS= asn1_err.c \ asn1_err.h \ diff --git a/kerberos5/lib/libgssapi_krb5/Makefile b/kerberos5/lib/libgssapi_krb5/Makefile index 6c2f421..943e875 100644 --- a/kerberos5/lib/libgssapi_krb5/Makefile +++ b/kerberos5/lib/libgssapi_krb5/Makefile @@ -1,7 +1,7 @@ # $FreeBSD$ LIB= gssapi_krb5 -LDFLAGS= -Wl,-Bsymbolic +LDFLAGS= -Wl,-Bsymbolic -Wl,--no-undefined LDADD= -lgssapi -lkrb5 -lhx509 -lcrypto -lroken -lasn1 -lcom_err -lcrypt DPADD= ${LIBGSSAPI} ${LIBKRB5} ${LIBHX509} ${LIBCRYPTO} ${LIBROKEN} ${LIBASN1} \ ${LIBCOM_ERR} ${LIBCRYPT} diff --git a/kerberos5/lib/libgssapi_ntlm/Makefile b/kerberos5/lib/libgssapi_ntlm/Makefile index cbecc2d..98b47f7 100644 --- a/kerberos5/lib/libgssapi_ntlm/Makefile +++ b/kerberos5/lib/libgssapi_ntlm/Makefile @@ -1,9 +1,9 @@ # $FreeBSD$ LIB= gssapi_ntlm -LDFLAGS= -Wl,-Bsymbolic -LDADD= -lkrb5 -lhx509 -lheimntlm -lroken -DPADD= ${LIBKRB5} ${LIBHX509} ${LIBHEIMNTLM} ${LIBROKEN} +LDFLAGS= -Wl,-Bsymbolic -Wl,--no-undefined +LDADD= -lcrypto -lgssapi -lkrb5 -lhx509 -lheimntlm -lroken +DPADD= ${LIBCRYPTO} ${LIBGSSAPI} ${LIBKRB5} ${LIBHX509} ${LIBHEIMNTLM} ${LIBROKEN} SRCS= accept_sec_context.c \ acquire_cred.c \ diff --git a/kerberos5/lib/libgssapi_spnego/Makefile b/kerberos5/lib/libgssapi_spnego/Makefile index 32348ec..ce44dbe 100644 --- a/kerberos5/lib/libgssapi_spnego/Makefile +++ b/kerberos5/lib/libgssapi_spnego/Makefile @@ -1,9 +1,9 @@ # $FreeBSD$ LIB= gssapi_spnego -LDFLAGS= -Wl,-Bsymbolic -LDADD= -lgssapi -lasn1 -DPADD= ${LIBGSSAPI} ${LIBASN1} +LDFLAGS= -Wl,-Bsymbolic -Wl,--no-undefined +LDADD= -lgssapi -lasn1 -lroken +DPADD= ${LIBGSSAPI} ${LIBASN1} ${LIBROKEN} SRCS= accept_sec_context.c \ compat.c \ diff --git a/kerberos5/lib/libhdb/Makefile b/kerberos5/lib/libhdb/Makefile index 75465d3..653690a 100644 --- a/kerberos5/lib/libhdb/Makefile +++ b/kerberos5/lib/libhdb/Makefile @@ -1,6 +1,9 @@ # $FreeBSD$ LIB= hdb +LDFLAGS= -Wl,--no-undefined +LDADD= -lasn1 -lcom_err -lkrb5 -lroken +DPADD= ${LIBASN1} ${LIBCOM_ERR} ${LIBKRB5} ${LIBROKEN} INCS= hdb-private.h \ hdb-protos.h \ diff --git a/kerberos5/lib/libheimntlm/Makefile b/kerberos5/lib/libheimntlm/Makefile index e223258..ba7c922 100644 --- a/kerberos5/lib/libheimntlm/Makefile +++ b/kerberos5/lib/libheimntlm/Makefile @@ -1,6 +1,9 @@ # $FreeBSD$ LIB= heimntlm +LDFLAGS= -Wl,--no-undefined +LDADD= -lcrypto -lkrb5 +DPADD= ${LIBCRYPTO} ${LIBKRB5} SRCS= ntlm.c INCS= heimntlm.h heimntlm-protos.h CFLAGS+=-I${KRB5DIR}/lib/ntlm diff --git a/kerberos5/lib/libhx509/Makefile b/kerberos5/lib/libhx509/Makefile index e94831a..9238a74 100644 --- a/kerberos5/lib/libhx509/Makefile +++ b/kerberos5/lib/libhx509/Makefile @@ -1,7 +1,10 @@ # $FreeBSD$ LIB= hx509 +LDFLAGS= -Wl,--no-undefined VERSION_MAP= ${KRB5DIR}/lib/hx509/version-script.map +LDADD= -lasn1 -lcom_err -lcrypto -lroken +DPADD= ${LIBASN1} ${LIBCOM_ERR} ${LIBCRYPTO} ${LIBROKEN} INCS= hx509-private.h \ hx509-protos.h \ diff --git a/kerberos5/lib/libkadm5clnt/Makefile b/kerberos5/lib/libkadm5clnt/Makefile index 3390866..dd93847 100644 --- a/kerberos5/lib/libkadm5clnt/Makefile +++ b/kerberos5/lib/libkadm5clnt/Makefile @@ -1,6 +1,9 @@ # $FreeBSD$ LIB= kadm5clnt +LDFLAGS= -Wl,--no-undefined +LDADD= -lcom_err -lkrb5 -lroken +DPADD= ${LIBCOM_ERR} ${LIBKRB5} ${LIBROKEN} INCS= admin.h \ kadm5-private.h \ diff --git a/kerberos5/lib/libkadm5srv/Makefile b/kerberos5/lib/libkadm5srv/Makefile index c0be477..43bd6e0 100644 --- a/kerberos5/lib/libkadm5srv/Makefile +++ b/kerberos5/lib/libkadm5srv/Makefile @@ -1,6 +1,9 @@ # $FreeBSD$ LIB= kadm5srv +LDFLAGS= -Wl,--no-undefined +LDADD= -lcom_err -lhdb -lkrb5 -lroken +DPADD= ${LIBCOM_ERR} ${LIBHDB} ${LIBKRB5} ${LIBROKEN} VERSION_MAP= ${KRB5DIR}/lib/kadm5/version-script.map SRCS= acl.c \ diff --git a/kerberos5/lib/libkafs5/Makefile b/kerberos5/lib/libkafs5/Makefile index e0e0b30..962a900 100644 --- a/kerberos5/lib/libkafs5/Makefile +++ b/kerberos5/lib/libkafs5/Makefile @@ -1,6 +1,9 @@ # $FreeBSD$ LIB= kafs5 +LDFLAGS= -Wl,--no-undefined +LDADD= -lasn1 -lkrb5 -lroken +DPADD= ${LIBASN1} ${LIBKRB5} ${LIBROKEN} INCS= kafs.h MAN= kafs5.3 diff --git a/kerberos5/lib/libkrb5/Makefile b/kerberos5/lib/libkrb5/Makefile index 2965338..71175cd 100644 --- a/kerberos5/lib/libkrb5/Makefile +++ b/kerberos5/lib/libkrb5/Makefile @@ -1,7 +1,10 @@ # $FreeBSD$ LIB= krb5 +LDFLAGS= -Wl,--no-undefined VERSION_MAP= ${KRB5DIR}/lib/krb5/version-script.map +LDADD= -lasn1 -lcom_err -lcrypt -lcrypto -lhx509 -lroken +DPADD= ${LIBASN1} ${LIBCOM_ERR} ${LIBCRYPT} ${LIBCRYPTO} ${LIBHX509} ${LIBROKEN} INCS= heim_err.h \ heim_threads.h \ diff --git a/kerberos5/lib/libroken/Makefile b/kerberos5/lib/libroken/Makefile index 92f38a8..c88e1ce 100644 --- a/kerberos5/lib/libroken/Makefile +++ b/kerberos5/lib/libroken/Makefile @@ -1,6 +1,8 @@ # $FreeBSD$ LIB= roken +LDADD= -lcrypt +DPADD= ${LIBCRYPT} INCS= roken.h roken-common.h SRCS= base64.c \ diff --git a/lib/libc/locale/isspace.3 b/lib/libc/locale/isspace.3 index f1e08d6..eab6cfc 100644 --- a/lib/libc/locale/isspace.3 +++ b/lib/libc/locale/isspace.3 @@ -47,16 +47,16 @@ .Sh DESCRIPTION The .Fn isspace -function tests for the white-space characters. +function tests for white-space characters. For any locale, this includes the following standard characters: .Pp .Bl -column \&`\et''___ \&``\et''___ \&``\et''___ \&``\et''___ \&``\et''___ \&``\et''___ .It "\&``\et''\t``\en''\t``\ev''\t``\ef''\t``\er''\t`` ''" .El .Pp -In the "C" locale +In the "C" locale, .Fn isspace -successful test is limited to this characters only. +returns non-zero for these characters only. The value of the argument must be representable as an .Vt "unsigned char" or the value of diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index fefc4c5..f43ed0c 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * Copyright (c) 1998-2011 Dag-Erling Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/lib/libfetch/common.h b/lib/libfetch/common.h index 05bee03..a353758 100644 --- a/lib/libfetch/common.h +++ b/lib/libfetch/common.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * Copyright (c) 1998-2011 Dag-Erling Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/lib/libfetch/fetch.3 b/lib/libfetch/fetch.3 index aaf1a8d..c5a7b31 100644 --- a/lib/libfetch/fetch.3 +++ b/lib/libfetch/fetch.3 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 1998-2011 Dag-Erling Smørgrav .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 26, 2010 +.Dd September 27, 2011 .Dt FETCH 3 .Os .Sh NAME @@ -318,9 +318,19 @@ and implement the FTP protocol as described in RFC959. .Pp If the +.Ql P +(not passive) flag is specified, an active (rather than passive) +connection will be attempted. +.Pp +The .Ql p -(passive) flag is specified, a passive (rather than active) connection -will be attempted. +flag is supported for compatibility with earlier versions where active +connections were the default. +It has precedence over the +.Ql P +flag, so if both are specified, +.Nm +will use a passive connection. .Pp If the .Ql l @@ -475,9 +485,11 @@ connections will be bound. .It Ev FTP_LOGIN Default FTP login if none was provided in the URL. .It Ev FTP_PASSIVE_MODE -If set to anything but +If set to .Ql no , -forces the FTP code to use passive mode. +forces the FTP code to use active mode. +If set to any other value, forces passive mode even if the application +requested active mode. .It Ev FTP_PASSWORD Default FTP password if the remote server requests one and none was provided in the URL. diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c index 5044fe3..9463df9 100644 --- a/lib/libfetch/fetch.c +++ b/lib/libfetch/fetch.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * Copyright (c) 1998-2004 Dag-Erling Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/lib/libfetch/fetch.h b/lib/libfetch/fetch.h index e620a01..277524c 100644 --- a/lib/libfetch/fetch.h +++ b/lib/libfetch/fetch.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * Copyright (c) 1998-2004 Dag-Erling Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/lib/libfetch/file.c b/lib/libfetch/file.c index dffaad8..cdf804c 100644 --- a/lib/libfetch/file.c +++ b/lib/libfetch/file.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * Copyright (c) 1998-2011 Dag-Erling Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/lib/libfetch/ftp.c b/lib/libfetch/ftp.c index 04ae07e..cf5ec09 100644 --- a/lib/libfetch/ftp.c +++ b/lib/libfetch/ftp.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav + * Copyright (c) 1998-2011 Dag-Erling Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -633,13 +633,12 @@ ftp_transfer(conn_t *conn, const char *oper, const char *file, /* check flags */ low = CHECK_FLAG('l'); - pasv = CHECK_FLAG('p'); + pasv = CHECK_FLAG('p') || !CHECK_FLAG('P'); verbose = CHECK_FLAG('v'); /* passive mode */ - if (!pasv) - pasv = ((s = getenv("FTP_PASSIVE_MODE")) != NULL && - strncasecmp(s, "no", 2) != 0); + if ((s = getenv("FTP_PASSIVE_MODE")) != NULL) + pasv = (strncasecmp(s, "no", 2) != 0); /* isolate filename */ filename = ftp_filename(file, &filenamelen, &type); diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c index 309cbf2..a839c1b 100644 --- a/lib/libfetch/http.c +++ b/lib/libfetch/http.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav + * Copyright (c) 2000-2011 Dag-Erling Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/release/Makefile.sysinstall b/release/Makefile.sysinstall index 740ab42..6f78a2a 100644 --- a/release/Makefile.sysinstall +++ b/release/Makefile.sysinstall @@ -24,16 +24,16 @@ # Set these, release builder! # # Fixed version: -#BUILDNAME=9.0-CURRENT +#BUILDNAME=10.0-CURRENT # # Automatic SNAP versioning: DATE != date +%Y%m%d -BASE = 9.0 +BASE = 10.0 BUILDNAME?=${BASE}-${DATE}-SNAP # #CHROOTDIR=/junk/release # If this is a -stable snapshot, then set -#RELEASETAG=RELENG_8 +#RELEASETAG=RELENG_9 # # To test a release with a source tree containing patches and # other work. This tree will get copied instead of getting the @@ -72,7 +72,7 @@ BUILDNAME?=${BASE}-${DATE}-SNAP # # Subversion branch to build for src. If this is not set then it is # automatically computed from RELEASETAG. -#SVNBRANCH=stable/8 +#SVNBRANCH=stable/9 # # Non-zero if ${RELEASETAG} is in the form "RELENG_ver_RELEASE"; we # are building an official release. Otherwise, we are building for @@ -588,7 +588,7 @@ release rerelease: echo " for i in ${MAKEINDEXPORTS}" >> ${_MK} echo " do" >> ${_MK} echo " cd /usr/ports/\$${i}" >> ${_MK} - echo " env -i HTTP_PROXY=$${HTTP_PROXY} FTP_PROXY=$${FTP_PROXY} FTP_PASSIVE_MODE=$${FTP_PASSIVE_MODE:-no} PATH=$${PATH} \\" >> ${_MK} + echo " env -i HTTP_PROXY=$${HTTP_PROXY} FTP_PROXY=$${FTP_PROXY} FTP_PASSIVE_MODE=$${FTP_PASSIVE_MODE:-yes} PATH=$${PATH} \\" >> ${_MK} echo " make all install clean BATCH=yes FORCE_PKG_REGISTER=yes" >> ${_MK} echo " done" >> ${_MK} echo " cd /usr/ports" >> ${_MK} diff --git a/sbin/hastctl/hastctl.c b/sbin/hastctl/hastctl.c index 233b948..838e11d 100644 --- a/sbin/hastctl/hastctl.c +++ b/sbin/hastctl/hastctl.c @@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$"); #include <sys/stat.h> #include <sys/sysctl.h> -#include <assert.h> #include <err.h> #include <errno.h> #include <fcntl.h> @@ -433,19 +432,19 @@ main(int argc, char *argv[]) pjdlog_debug_set(debug); cfg = yy_config_parse(cfgpath, true); - assert(cfg != NULL); + PJDLOG_ASSERT(cfg != NULL); switch (cmd) { case CMD_CREATE: control_create(argc, argv, mediasize, extentsize, keepdirty); /* NOTREACHED */ - assert(!"What are we doing here?!"); + PJDLOG_ABORT("What are we doing here?!"); break; case CMD_DUMP: /* Dump metadata from local component of the given resource. */ control_dump(argc, argv); /* NOTREACHED */ - assert(!"What are we doing here?!"); + PJDLOG_ABORT("What are we doing here?!"); break; case CMD_ROLE: /* Change role for the given resources. */ @@ -476,7 +475,7 @@ main(int argc, char *argv[]) } break; default: - assert(!"Impossible command!"); + PJDLOG_ABORT("Impossible command!"); } /* Setup control connection... */ @@ -523,7 +522,7 @@ main(int argc, char *argv[]) error = control_status(nv); break; default: - assert(!"Impossible command!"); + PJDLOG_ABORT("Impossible command!"); } exit(error); diff --git a/sbin/hastd/activemap.c b/sbin/hastd/activemap.c index 127b2c8..e388bb2 100644 --- a/sbin/hastd/activemap.c +++ b/sbin/hastd/activemap.c @@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> /* powerof2() */ #include <sys/queue.h> -#include <assert.h> #include <bitstring.h> #include <errno.h> #include <stdint.h> @@ -41,7 +40,14 @@ __FBSDID("$FreeBSD$"); #include <stdlib.h> #include <string.h> -#include <activemap.h> +#include <pjdlog.h> + +#include "activemap.h" + +#ifndef PJDLOG_ASSERT +#include <assert.h> +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#endif #define ACTIVEMAP_MAGIC 0xac71e4 struct activemap { @@ -93,9 +99,9 @@ off2ext(const struct activemap *amp, off_t offset) { int extent; - assert(offset >= 0 && offset < amp->am_mediasize); + PJDLOG_ASSERT(offset >= 0 && offset < amp->am_mediasize); extent = (offset >> amp->am_extentshift); - assert(extent >= 0 && extent < amp->am_nextents); + PJDLOG_ASSERT(extent >= 0 && extent < amp->am_nextents); return (extent); } @@ -104,9 +110,9 @@ ext2off(const struct activemap *amp, int extent) { off_t offset; - assert(extent >= 0 && extent < amp->am_nextents); + PJDLOG_ASSERT(extent >= 0 && extent < amp->am_nextents); offset = ((off_t)extent << amp->am_extentshift); - assert(offset >= 0 && offset < amp->am_mediasize); + PJDLOG_ASSERT(offset >= 0 && offset < amp->am_mediasize); return (offset); } @@ -122,7 +128,7 @@ ext2reqs(const struct activemap *amp, int ext) if (ext < amp->am_nextents - 1) return (((amp->am_extentsize - 1) / MAXPHYS) + 1); - assert(ext == amp->am_nextents - 1); + PJDLOG_ASSERT(ext == amp->am_nextents - 1); left = amp->am_mediasize % amp->am_extentsize; if (left == 0) left = amp->am_extentsize; @@ -139,13 +145,13 @@ activemap_init(struct activemap **ampp, uint64_t mediasize, uint32_t extentsize, { struct activemap *amp; - assert(ampp != NULL); - assert(mediasize > 0); - assert(extentsize > 0); - assert(powerof2(extentsize)); - assert(sectorsize > 0); - assert(powerof2(sectorsize)); - assert(keepdirty > 0); + PJDLOG_ASSERT(ampp != NULL); + PJDLOG_ASSERT(mediasize > 0); + PJDLOG_ASSERT(extentsize > 0); + PJDLOG_ASSERT(powerof2(extentsize)); + PJDLOG_ASSERT(sectorsize > 0); + PJDLOG_ASSERT(powerof2(sectorsize)); + PJDLOG_ASSERT(keepdirty > 0); amp = malloc(sizeof(*amp)); if (amp == NULL) @@ -225,10 +231,10 @@ keepdirty_add(struct activemap *amp, int extent) */ if (amp->am_nkeepdirty >= amp->am_nkeepdirty_limit) { kd = TAILQ_LAST(&->am_keepdirty, skeepdirty); - assert(kd != NULL); + PJDLOG_ASSERT(kd != NULL); TAILQ_REMOVE(&->am_keepdirty, kd, kd_next); amp->am_nkeepdirty--; - assert(amp->am_nkeepdirty > 0); + PJDLOG_ASSERT(amp->am_nkeepdirty > 0); } if (kd == NULL) kd = malloc(sizeof(*kd)); @@ -261,7 +267,7 @@ keepdirty_free(struct activemap *amp) amp->am_nkeepdirty--; free(kd); } - assert(amp->am_nkeepdirty == 0); + PJDLOG_ASSERT(amp->am_nkeepdirty == 0); } /* @@ -271,7 +277,7 @@ void activemap_free(struct activemap *amp) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); amp->am_magic = 0; @@ -293,8 +299,8 @@ activemap_write_start(struct activemap *amp, off_t offset, off_t length) off_t end; int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(length > 0); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(length > 0); modified = false; end = offset + length - 1; @@ -307,7 +313,7 @@ activemap_write_start(struct activemap *amp, off_t offset, off_t length) * was modified and has to be flushed to disk. */ if (amp->am_memtab[ext]++ == 0) { - assert(!bit_test(amp->am_memmap, ext)); + PJDLOG_ASSERT(!bit_test(amp->am_memmap, ext)); bit_set(amp->am_memmap, ext); amp->am_ndirty++; } @@ -329,8 +335,8 @@ activemap_write_complete(struct activemap *amp, off_t offset, off_t length) off_t end; int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(length > 0); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(length > 0); modified = false; end = offset + length - 1; @@ -342,8 +348,8 @@ activemap_write_complete(struct activemap *amp, off_t offset, off_t length) * By returning true we inform the caller that on-disk bitmap * was modified and has to be flushed to disk. */ - assert(amp->am_memtab[ext] > 0); - assert(bit_test(amp->am_memmap, ext)); + PJDLOG_ASSERT(amp->am_memtab[ext] > 0); + PJDLOG_ASSERT(bit_test(amp->am_memmap, ext)); if (--amp->am_memtab[ext] == 0) { bit_clear(amp->am_memmap, ext); amp->am_ndirty--; @@ -365,15 +371,15 @@ activemap_extent_complete(struct activemap *amp, int extent) bool modified; int reqs; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(extent >= 0 && extent < amp->am_nextents); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(extent >= 0 && extent < amp->am_nextents); modified = false; reqs = ext2reqs(amp, extent); - assert(amp->am_memtab[extent] >= reqs); + PJDLOG_ASSERT(amp->am_memtab[extent] >= reqs); amp->am_memtab[extent] -= reqs; - assert(bit_test(amp->am_memmap, extent)); + PJDLOG_ASSERT(bit_test(amp->am_memmap, extent)); if (amp->am_memtab[extent] == 0) { bit_clear(amp->am_memmap, extent); amp->am_ndirty--; @@ -390,7 +396,7 @@ uint64_t activemap_ndirty(const struct activemap *amp) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); return (amp->am_ndirty); } @@ -403,7 +409,7 @@ bool activemap_differ(const struct activemap *amp) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); return (memcmp(amp->am_diskmap, amp->am_memmap, amp->am_mapsize) != 0); @@ -416,7 +422,7 @@ size_t activemap_size(const struct activemap *amp) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); return (amp->am_mapsize); } @@ -429,7 +435,7 @@ size_t activemap_ondisk_size(const struct activemap *amp) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); return (amp->am_diskmapsize); } @@ -442,8 +448,8 @@ activemap_copyin(struct activemap *amp, const unsigned char *buf, size_t size) { int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(size >= amp->am_mapsize); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(size >= amp->am_mapsize); memcpy(amp->am_diskmap, buf, amp->am_mapsize); memcpy(amp->am_memmap, buf, amp->am_mapsize); @@ -481,8 +487,8 @@ activemap_merge(struct activemap *amp, const unsigned char *buf, size_t size) bitstr_t *remmap = __DECONST(bitstr_t *, buf); int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(size >= amp->am_mapsize); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(size >= amp->am_mapsize); bit_ffs(remmap, amp->am_nextents, &ext); if (ext == -1) { @@ -521,7 +527,7 @@ const unsigned char * activemap_bitmap(struct activemap *amp, size_t *sizep) { - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); if (sizep != NULL) *sizep = amp->am_diskmapsize; @@ -539,11 +545,11 @@ activemap_calc_ondisk_size(uint64_t mediasize, uint32_t extentsize, { uint64_t nextents, mapsize; - assert(mediasize > 0); - assert(extentsize > 0); - assert(powerof2(extentsize)); - assert(sectorsize > 0); - assert(powerof2(sectorsize)); + PJDLOG_ASSERT(mediasize > 0); + PJDLOG_ASSERT(extentsize > 0); + PJDLOG_ASSERT(powerof2(extentsize)); + PJDLOG_ASSERT(sectorsize > 0); + PJDLOG_ASSERT(powerof2(sectorsize)); nextents = ((mediasize - 1) / extentsize) + 1; mapsize = sizeof(bitstr_t) * bitstr_size(nextents); @@ -558,7 +564,7 @@ activemap_sync_rewind(struct activemap *amp) { int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); bit_ffs(amp->am_syncmap, amp->am_nextents, &ext); if (ext == -1) { @@ -581,9 +587,9 @@ activemap_sync_offset(struct activemap *amp, off_t *lengthp, int *syncextp) off_t syncoff, left; int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); - assert(lengthp != NULL); - assert(syncextp != NULL); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(lengthp != NULL); + PJDLOG_ASSERT(syncextp != NULL); *syncextp = -1; @@ -632,9 +638,10 @@ activemap_sync_offset(struct activemap *amp, off_t *lengthp, int *syncextp) if (left > MAXPHYS) left = MAXPHYS; - assert(left >= 0 && left <= MAXPHYS); - assert(syncoff >= 0 && syncoff < amp->am_mediasize); - assert(syncoff + left >= 0 && syncoff + left <= amp->am_mediasize); + PJDLOG_ASSERT(left >= 0 && left <= MAXPHYS); + PJDLOG_ASSERT(syncoff >= 0 && syncoff < amp->am_mediasize); + PJDLOG_ASSERT(syncoff + left >= 0 && + syncoff + left <= amp->am_mediasize); *lengthp = left; return (syncoff); @@ -651,7 +658,7 @@ activemap_need_sync(struct activemap *amp, off_t offset, off_t length) off_t end; int ext; - assert(amp->am_magic == ACTIVEMAP_MAGIC); + PJDLOG_ASSERT(amp->am_magic == ACTIVEMAP_MAGIC); modified = false; end = offset + length - 1; @@ -659,7 +666,7 @@ activemap_need_sync(struct activemap *amp, off_t offset, off_t length) for (ext = off2ext(amp, offset); ext <= off2ext(amp, end); ext++) { if (bit_test(amp->am_syncmap, ext)) { /* Already marked for synchronization. */ - assert(bit_test(amp->am_memmap, ext)); + PJDLOG_ASSERT(bit_test(amp->am_memmap, ext)); continue; } bit_set(amp->am_syncmap, ext); diff --git a/sbin/hastd/control.c b/sbin/hastd/control.c index 57a1c8a..93bfbb7 100644 --- a/sbin/hastd/control.c +++ b/sbin/hastd/control.c @@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/wait.h> -#include <assert.h> #include <errno.h> #include <pthread.h> #include <signal.h> @@ -82,8 +81,8 @@ control_set_role_common(struct hastd_config *cfg, struct nv *nvout, nv_add_string(nvout, name, "resource%u", no); if (res == NULL) { - assert(cfg != NULL); - assert(name != NULL); + PJDLOG_ASSERT(cfg != NULL); + PJDLOG_ASSERT(name != NULL); TAILQ_FOREACH(res, &cfg->hc_resources, hr_next) { if (strcmp(res->hr_name, name) == 0) @@ -94,7 +93,7 @@ control_set_role_common(struct hastd_config *cfg, struct nv *nvout, return; } } - assert(res != NULL); + PJDLOG_ASSERT(res != NULL); /* Send previous role back. */ nv_add_string(nvout, role2str(res->hr_role), "role%u", no); @@ -222,9 +221,9 @@ control_status(struct hastd_config *cfg, struct nv *nvout, struct hast_resource *res, const char *name, unsigned int no) { - assert(cfg != NULL); - assert(nvout != NULL); - assert(name != NULL); + PJDLOG_ASSERT(cfg != NULL); + PJDLOG_ASSERT(nvout != NULL); + PJDLOG_ASSERT(name != NULL); /* Name is always needed. */ nv_add_string(nvout, name, "resource%u", no); @@ -239,7 +238,7 @@ control_status(struct hastd_config *cfg, struct nv *nvout, return; } } - assert(res != NULL); + PJDLOG_ASSERT(res != NULL); nv_add_string(nvout, res->hr_provname, "provname%u", no); nv_add_string(nvout, res->hr_localpath, "localpath%u", no); nv_add_string(nvout, res->hr_remoteaddr, "remoteaddr%u", no); @@ -267,7 +266,7 @@ control_status(struct hastd_config *cfg, struct nv *nvout, switch (res->hr_role) { case HAST_ROLE_PRIMARY: - assert(res->hr_workerpid != 0); + PJDLOG_ASSERT(res->hr_workerpid != 0); /* FALLTHROUGH */ case HAST_ROLE_SECONDARY: if (res->hr_workerpid != 0) @@ -470,7 +469,7 @@ ctrl_thread(void *arg) * something related to us has changes, it sends reload * message to us. */ - assert(res->hr_role == HAST_ROLE_PRIMARY); + PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY); primary_config_reload(res, nvin); nv_add_int16(nvout, 0, "error"); break; diff --git a/sbin/hastd/ebuf.c b/sbin/hastd/ebuf.c index 0bccd18..f5908a4 100644 --- a/sbin/hastd/ebuf.c +++ b/sbin/hastd/ebuf.c @@ -32,15 +32,21 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> -#include <assert.h> #include <errno.h> #include <stdbool.h> #include <stdint.h> #include <strings.h> #include <unistd.h> +#include <pjdlog.h> + #include "ebuf.h" +#ifndef PJDLOG_ASSERT +#include <assert.h> +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#endif + #define EBUF_MAGIC 0xeb0f41c struct ebuf { /* Magic to assert the caller uses valid structure. */ @@ -91,7 +97,7 @@ void ebuf_free(struct ebuf *eb) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); eb->eb_magic = 0; @@ -103,7 +109,7 @@ int ebuf_add_head(struct ebuf *eb, const void *data, size_t size) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); if (size > (size_t)(eb->eb_used - eb->eb_start)) { /* @@ -113,7 +119,7 @@ ebuf_add_head(struct ebuf *eb, const void *data, size_t size) if (ebuf_head_extend(eb, size) < 0) return (-1); } - assert(size <= (size_t)(eb->eb_used - eb->eb_start)); + PJDLOG_ASSERT(size <= (size_t)(eb->eb_used - eb->eb_start)); eb->eb_size += size; eb->eb_used -= size; @@ -130,7 +136,7 @@ int ebuf_add_tail(struct ebuf *eb, const void *data, size_t size) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); if (size > (size_t)(eb->eb_end - (eb->eb_used + eb->eb_size))) { /* @@ -140,7 +146,8 @@ ebuf_add_tail(struct ebuf *eb, const void *data, size_t size) if (ebuf_tail_extend(eb, size) < 0) return (-1); } - assert(size <= (size_t)(eb->eb_end - (eb->eb_used + eb->eb_size))); + PJDLOG_ASSERT(size <= + (size_t)(eb->eb_end - (eb->eb_used + eb->eb_size))); /* * If data is NULL the caller just wants to reserve space. @@ -156,8 +163,8 @@ void ebuf_del_head(struct ebuf *eb, size_t size) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); - assert(size <= eb->eb_size); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(size <= eb->eb_size); eb->eb_used += size; eb->eb_size -= size; @@ -167,8 +174,8 @@ void ebuf_del_tail(struct ebuf *eb, size_t size) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); - assert(size <= eb->eb_size); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(size <= eb->eb_size); eb->eb_size -= size; } @@ -180,7 +187,7 @@ void * ebuf_data(struct ebuf *eb, size_t *sizep) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); if (sizep != NULL) *sizep = eb->eb_size; @@ -194,7 +201,7 @@ size_t ebuf_size(struct ebuf *eb) { - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); return (eb->eb_size); } @@ -208,7 +215,7 @@ ebuf_head_extend(struct ebuf *eb, size_t size) unsigned char *newstart, *newused; size_t newsize; - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); newsize = eb->eb_end - eb->eb_start + (PAGE_SIZE / 4) + size; @@ -236,7 +243,7 @@ ebuf_tail_extend(struct ebuf *eb, size_t size) unsigned char *newstart; size_t newsize; - assert(eb != NULL && eb->eb_magic == EBUF_MAGIC); + PJDLOG_ASSERT(eb != NULL && eb->eb_magic == EBUF_MAGIC); newsize = eb->eb_end - eb->eb_start + size + ((3 * PAGE_SIZE) / 4); diff --git a/sbin/hastd/event.c b/sbin/hastd/event.c index d772f69..d895f67 100644 --- a/sbin/hastd/event.c +++ b/sbin/hastd/event.c @@ -27,7 +27,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <assert.h> #include <errno.h> #include "hast.h" @@ -46,8 +45,8 @@ event_send(const struct hast_resource *res, int event) struct nv *nvin, *nvout; int error; - assert(res != NULL); - assert(event >= EVENT_MIN && event <= EVENT_MAX); + PJDLOG_ASSERT(res != NULL); + PJDLOG_ASSERT(event >= EVENT_MIN && event <= EVENT_MAX); nvin = nvout = NULL; @@ -89,7 +88,7 @@ event_recv(const struct hast_resource *res) uint8_t event; int error; - assert(res != NULL); + PJDLOG_ASSERT(res != NULL); nvin = nvout = NULL; diff --git a/sbin/hastd/hast_proto.c b/sbin/hastd/hast_proto.c index 8956891..439b0f3 100644 --- a/sbin/hastd/hast_proto.c +++ b/sbin/hastd/hast_proto.c @@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$"); #include <sys/endian.h> -#include <assert.h> #include <errno.h> #include <strings.h> @@ -158,7 +157,7 @@ hast_proto_recv_hdr(const struct proto_conn *conn, struct nv **nvp) if (ebuf_add_tail(eb, NULL, hdr.size) < 0) goto fail; hptr = ebuf_data(eb, NULL); - assert(hptr != NULL); + PJDLOG_ASSERT(hptr != NULL); if (proto_recv(conn, hptr, hdr.size) < 0) goto fail; nv = nv_ntoh(eb); @@ -183,8 +182,8 @@ hast_proto_recv_data(const struct hast_resource *res, struct proto_conn *conn, void *dptr; int ret; - assert(data != NULL); - assert(size > 0); + PJDLOG_ASSERT(data != NULL); + PJDLOG_ASSERT(size > 0); ret = -1; freedata = false; diff --git a/sbin/hastd/hooks.c b/sbin/hastd/hooks.c index b161c0c..60d48d1 100644 --- a/sbin/hastd/hooks.c +++ b/sbin/hastd/hooks.c @@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$"); #include <sys/sysctl.h> #include <sys/wait.h> -#include <assert.h> #include <errno.h> #include <fcntl.h> #include <libgen.h> @@ -138,7 +137,7 @@ void hook_init(void) { - assert(!hooks_initialized); + PJDLOG_ASSERT(!hooks_initialized); mtx_init(&hookprocs_lock); TAILQ_INIT(&hookprocs); @@ -150,12 +149,12 @@ hook_fini(void) { struct hookproc *hp; - assert(hooks_initialized); + PJDLOG_ASSERT(hooks_initialized); mtx_lock(&hookprocs_lock); while ((hp = TAILQ_FIRST(&hookprocs)) != NULL) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); - assert(hp->hp_pid > 0); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); + PJDLOG_ASSERT(hp->hp_pid > 0); hook_remove(hp); hook_free(hp); @@ -201,8 +200,8 @@ static void hook_add(struct hookproc *hp, pid_t pid) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ALLOCATED); - assert(hp->hp_pid == 0); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ALLOCATED); + PJDLOG_ASSERT(hp->hp_pid == 0); hp->hp_pid = pid; mtx_lock(&hookprocs_lock); @@ -215,9 +214,9 @@ static void hook_remove(struct hookproc *hp) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); - assert(hp->hp_pid > 0); - assert(mtx_owned(&hookprocs_lock)); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); + PJDLOG_ASSERT(hp->hp_pid > 0); + PJDLOG_ASSERT(mtx_owned(&hookprocs_lock)); TAILQ_REMOVE(&hookprocs, hp, hp_next); hp->hp_magic = HOOKPROC_MAGIC_ALLOCATED; @@ -227,8 +226,8 @@ static void hook_free(struct hookproc *hp) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ALLOCATED); - assert(hp->hp_pid > 0); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ALLOCATED); + PJDLOG_ASSERT(hp->hp_pid > 0); hp->hp_magic = 0; free(hp); @@ -239,11 +238,11 @@ hook_find(pid_t pid) { struct hookproc *hp; - assert(mtx_owned(&hookprocs_lock)); + PJDLOG_ASSERT(mtx_owned(&hookprocs_lock)); TAILQ_FOREACH(hp, &hookprocs, hp_next) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); - assert(hp->hp_pid > 0); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); + PJDLOG_ASSERT(hp->hp_pid > 0); if (hp->hp_pid == pid) break; @@ -286,7 +285,7 @@ hook_check(void) struct hookproc *hp, *hp2; time_t now; - assert(hooks_initialized); + PJDLOG_ASSERT(hooks_initialized); pjdlog_debug(2, "Checking hooks."); @@ -296,8 +295,8 @@ hook_check(void) now = time(NULL); mtx_lock(&hookprocs_lock); TAILQ_FOREACH_SAFE(hp, &hookprocs, hp_next, hp2) { - assert(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); - assert(hp->hp_pid > 0); + PJDLOG_ASSERT(hp->hp_magic == HOOKPROC_MAGIC_ONLIST); + PJDLOG_ASSERT(hp->hp_pid > 0); /* * If process doesn't exists we somehow missed it. @@ -347,7 +346,7 @@ hook_execv(const char *path, va_list ap) sigset_t mask; pid_t pid; - assert(hooks_initialized); + PJDLOG_ASSERT(hooks_initialized); if (path == NULL || path[0] == '\0') return; @@ -359,7 +358,7 @@ hook_execv(const char *path, va_list ap) if (args[ii] == NULL) break; } - assert(ii < sizeof(args) / sizeof(args[0])); + PJDLOG_ASSERT(ii < sizeof(args) / sizeof(args[0])); hp = hook_alloc(path, args); if (hp == NULL) diff --git a/sbin/hastd/metadata.c b/sbin/hastd/metadata.c index de21b53..ad6c75b 100644 --- a/sbin/hastd/metadata.c +++ b/sbin/hastd/metadata.c @@ -30,7 +30,6 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <assert.h> #include <errno.h> #include <fcntl.h> #include <string.h> @@ -100,7 +99,7 @@ metadata_read(struct hast_resource *res, bool openrw) goto fail; } buf = ebuf_data(eb, NULL); - assert(buf != NULL); + PJDLOG_ASSERT(buf != NULL); done = pread(res->hr_localfd, buf, METADATA_SIZE, 0); if (done < 0 || done != METADATA_SIZE) { rerrno = errno; @@ -197,7 +196,7 @@ metadata_write(struct hast_resource *res) nv_add_uint64(nv, res->hr_primary_localcnt, "localcnt"); nv_add_uint64(nv, res->hr_primary_remotecnt, "remotecnt"); } else /* if (res->hr_role == HAST_ROLE_SECONDARY) */ { - assert(res->hr_role == HAST_ROLE_SECONDARY); + PJDLOG_ASSERT(res->hr_role == HAST_ROLE_SECONDARY); nv_add_uint64(nv, res->hr_secondary_localcnt, "localcnt"); nv_add_uint64(nv, res->hr_secondary_remotecnt, "remotecnt"); } @@ -208,10 +207,10 @@ metadata_write(struct hast_resource *res) } res->hr_previous_role = res->hr_role; eb = nv_hton(nv); - assert(eb != NULL); + PJDLOG_ASSERT(eb != NULL); ptr = ebuf_data(eb, &size); - assert(ptr != NULL); - assert(size < METADATA_SIZE); + PJDLOG_ASSERT(ptr != NULL); + PJDLOG_ASSERT(size < METADATA_SIZE); bcopy(ptr, buf, size); done = pwrite(res->hr_localfd, buf, METADATA_SIZE, 0); if (done < 0 || done != METADATA_SIZE) { diff --git a/sbin/hastd/nv.c b/sbin/hastd/nv.c index 1f994ee..89c174a 100644 --- a/sbin/hastd/nv.c +++ b/sbin/hastd/nv.c @@ -33,7 +33,6 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/endian.h> -#include <assert.h> #include <bitstring.h> #include <errno.h> #include <stdarg.h> @@ -44,7 +43,17 @@ __FBSDID("$FreeBSD$"); #include <unistd.h> #include <ebuf.h> -#include <nv.h> +#include <pjdlog.h> + +#include "nv.h" + +#ifndef PJDLOG_ASSERT +#include <assert.h> +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#endif +#ifndef PJDLOG_ABORT +#define PJDLOG_ABORT(...) abort() +#endif #define NV_TYPE_NONE 0 @@ -98,8 +107,8 @@ struct nvhdr { #define NVH_SIZE(nvh) (NVH_HSIZE(nvh) + roundup2(NVH_DSIZE(nvh), 8)) #define NV_CHECK(nv) do { \ - assert((nv) != NULL); \ - assert((nv)->nv_magic == NV_MAGIC); \ + PJDLOG_ASSERT((nv) != NULL); \ + PJDLOG_ASSERT((nv)->nv_magic == NV_MAGIC); \ } while (0) static void nv_add(struct nv *nv, const unsigned char *value, size_t vsize, @@ -200,7 +209,7 @@ nv_validate(struct nv *nv, size_t *extrap) } NV_CHECK(nv); - assert(nv->nv_error == 0); + PJDLOG_ASSERT(nv->nv_error == 0); /* TODO: Check that names are unique? */ @@ -308,7 +317,7 @@ nv_validate(struct nv *nv, size_t *extrap) } break; default: - assert(!"invalid condition"); + PJDLOG_ABORT("invalid condition"); } if (error != 0) break; @@ -338,7 +347,7 @@ nv_hton(struct nv *nv) size_t size; NV_CHECK(nv); - assert(nv->nv_error == 0); + PJDLOG_ASSERT(nv->nv_error == 0); ptr = ebuf_data(nv->nv_ebuf, &size); while (size > 0) { @@ -346,9 +355,9 @@ nv_hton(struct nv *nv) * Minimum size at this point is size of nvhdr structure, * one character long name plus terminating '\0'. */ - assert(size >= sizeof(*nvh) + 2); + PJDLOG_ASSERT(size >= sizeof(*nvh) + 2); nvh = (struct nvhdr *)ptr; - assert(NVH_SIZE(nvh) <= size); + PJDLOG_ASSERT(NVH_SIZE(nvh) <= size); nv_swap(nvh, false); ptr += NVH_SIZE(nvh); size -= NVH_SIZE(nvh); @@ -367,7 +376,7 @@ nv_ntoh(struct ebuf *eb) size_t extra; int rerrno; - assert(eb != NULL); + PJDLOG_ASSERT(eb != NULL); nv = malloc(sizeof(*nv)); if (nv == NULL) @@ -494,8 +503,8 @@ nv_get_##type(struct nv *nv, const char *namefmt, ...) \ va_end(nameap); \ if (nvh == NULL) \ return (0); \ - assert((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST); \ - assert(sizeof(value) == nvh->nvh_dsize); \ + PJDLOG_ASSERT((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST);\ + PJDLOG_ASSERT(sizeof(value) == nvh->nvh_dsize); \ bcopy(NVH_DATA(nvh), &value, sizeof(value)); \ \ return (value); \ @@ -525,8 +534,8 @@ nv_get_##type##_array(struct nv *nv, size_t *sizep, \ va_end(nameap); \ if (nvh == NULL) \ return (NULL); \ - assert((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST); \ - assert((nvh->nvh_dsize % sizeof(type##_t)) == 0); \ + PJDLOG_ASSERT((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST);\ + PJDLOG_ASSERT((nvh->nvh_dsize % sizeof(type##_t)) == 0); \ if (sizep != NULL) \ *sizep = nvh->nvh_dsize / sizeof(type##_t); \ return ((type##_t *)(void *)NVH_DATA(nvh)); \ @@ -555,11 +564,11 @@ nv_get_string(struct nv *nv, const char *namefmt, ...) va_end(nameap); if (nvh == NULL) return (NULL); - assert((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST); - assert(nvh->nvh_dsize >= 1); + PJDLOG_ASSERT((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_HOST); + PJDLOG_ASSERT(nvh->nvh_dsize >= 1); str = NVH_DATA(nvh); - assert(str[nvh->nvh_dsize - 1] == '\0'); - assert(strlen(str) == nvh->nvh_dsize - 1); + PJDLOG_ASSERT(str[nvh->nvh_dsize - 1] == '\0'); + PJDLOG_ASSERT(strlen(str) == nvh->nvh_dsize - 1); return (str); } @@ -602,7 +611,7 @@ nv_assert(struct nv *nv, const char *namefmt, ...) va_list nameap; va_start(nameap, namefmt); - assert(nv_vexists(nv, namefmt, nameap)); + PJDLOG_ASSERT(nv_vexists(nv, namefmt, nameap)); va_end(nameap); } @@ -624,13 +633,13 @@ nv_dump(struct nv *nv) } NV_CHECK(nv); - assert(nv->nv_error == 0); + PJDLOG_ASSERT(nv->nv_error == 0); ptr = ebuf_data(nv->nv_ebuf, &size); while (size > 0) { - assert(size >= sizeof(*nvh) + 2); + PJDLOG_ASSERT(size >= sizeof(*nvh) + 2); nvh = (struct nvhdr *)ptr; - assert(size >= NVH_SIZE(nvh)); + PJDLOG_ASSERT(size >= NVH_SIZE(nvh)); swap = ((nvh->nvh_type & NV_ORDER_MASK) == NV_ORDER_NETWORK); dsize = NVH_DSIZE(nvh); data = NVH_DATA(nvh); @@ -734,7 +743,7 @@ nv_dump(struct nv *nv) printf("(string): %s", (char *)data); break; default: - assert(!"invalid condition"); + PJDLOG_ABORT("invalid condition"); } printf("\n"); ptr += NVH_SIZE(nvh); @@ -776,7 +785,7 @@ nv_add(struct nv *nv, const unsigned char *value, size_t vsize, int type, /* Add header first. */ if (ebuf_add_tail(nv->nv_ebuf, nvh, NVH_HSIZE(nvh)) < 0) { - assert(errno != 0); + PJDLOG_ASSERT(errno != 0); if (nv->nv_error == 0) nv->nv_error = errno; free(nvh); @@ -785,7 +794,7 @@ nv_add(struct nv *nv, const unsigned char *value, size_t vsize, int type, free(nvh); /* Add the actual data. */ if (ebuf_add_tail(nv->nv_ebuf, value, vsize) < 0) { - assert(errno != 0); + PJDLOG_ASSERT(errno != 0); if (nv->nv_error == 0) nv->nv_error = errno; return; @@ -794,9 +803,9 @@ nv_add(struct nv *nv, const unsigned char *value, size_t vsize, int type, vsize = roundup2(vsize, 8) - vsize; if (vsize == 0) return; - assert(vsize > 0 && vsize <= sizeof(align)); + PJDLOG_ASSERT(vsize > 0 && vsize <= sizeof(align)); if (ebuf_add_tail(nv->nv_ebuf, align, vsize) < 0) { - assert(errno != 0); + PJDLOG_ASSERT(errno != 0); if (nv->nv_error == 0) nv->nv_error = errno; return; @@ -811,7 +820,7 @@ nv_addv(struct nv *nv, const unsigned char *value, size_t vsize, int type, size_t namesize; namesize = vsnprintf(name, sizeof(name), namefmt, nameap); - assert(namesize > 0 && namesize < sizeof(name)); + PJDLOG_ASSERT(namesize > 0 && namesize < sizeof(name)); nv_add(nv, value, vsize, type, name); } @@ -832,14 +841,14 @@ nv_find(struct nv *nv, int type, const char *namefmt, va_list nameap) NV_CHECK(nv); namesize = vsnprintf(name, sizeof(name), namefmt, nameap); - assert(namesize > 0 && namesize < sizeof(name)); + PJDLOG_ASSERT(namesize > 0 && namesize < sizeof(name)); namesize++; ptr = ebuf_data(nv->nv_ebuf, &size); while (size > 0) { - assert(size >= sizeof(*nvh) + 2); + PJDLOG_ASSERT(size >= sizeof(*nvh) + 2); nvh = (struct nvhdr *)ptr; - assert(size >= NVH_SIZE(nvh)); + PJDLOG_ASSERT(size >= NVH_SIZE(nvh)); nv_swap(nvh, true); if (strcmp(nvh->nvh_name, name) == 0) { if (type != NV_TYPE_NONE && @@ -927,7 +936,7 @@ nv_swap(struct nvhdr *nvh, bool tohost) le64toh(*(uint64_t *)(void *)p); break; default: - assert(!"invalid condition"); + PJDLOG_ABORT("invalid condition"); } } else { switch (vsize) { @@ -944,7 +953,7 @@ nv_swap(struct nvhdr *nvh, bool tohost) htole64(*(uint64_t *)(void *)p); break; default: - assert(!"invalid condition"); + PJDLOG_ABORT("invalid condition"); } } } @@ -952,6 +961,6 @@ nv_swap(struct nvhdr *nvh, bool tohost) case NV_TYPE_STRING: break; default: - assert(!"unrecognized type"); + PJDLOG_ABORT("unrecognized type"); } } diff --git a/sbin/hastd/parse.y b/sbin/hastd/parse.y index 6e8351d..01e8593a 100644 --- a/sbin/hastd/parse.y +++ b/sbin/hastd/parse.y @@ -38,7 +38,6 @@ #include <arpa/inet.h> -#include <assert.h> #include <err.h> #include <errno.h> #include <stdio.h> @@ -282,9 +281,9 @@ yy_config_parse(const char *config, bool exitonerror) } } TAILQ_FOREACH(curres, &lconfig->hc_resources, hr_next) { - assert(curres->hr_provname[0] != '\0'); - assert(curres->hr_localpath[0] != '\0'); - assert(curres->hr_remoteaddr[0] != '\0'); + PJDLOG_ASSERT(curres->hr_provname[0] != '\0'); + PJDLOG_ASSERT(curres->hr_localpath[0] != '\0'); + PJDLOG_ASSERT(curres->hr_remoteaddr[0] != '\0'); if (curres->hr_replication == -1) { /* @@ -426,7 +425,7 @@ control_statement: CONTROL STR } break; default: - assert(!"control at wrong depth level"); + PJDLOG_ABORT("control at wrong depth level"); } free($2); } @@ -460,7 +459,7 @@ listen_statement: LISTEN STR free(lst); break; default: - assert(!"listen at wrong depth level"); + PJDLOG_ABORT("listen at wrong depth level"); } free($2); } @@ -473,11 +472,11 @@ replication_statement: REPLICATION replication_type depth0_replication = $2; break; case 1: - if (curres != NULL) - curres->hr_replication = $2; + PJDLOG_ASSERT(curres != NULL); + curres->hr_replication = $2; break; default: - assert(!"replication at wrong depth level"); + PJDLOG_ABORT("replication at wrong depth level"); } } ; @@ -497,11 +496,11 @@ checksum_statement: CHECKSUM checksum_type depth0_checksum = $2; break; case 1: - if (curres != NULL) - curres->hr_checksum = $2; + PJDLOG_ASSERT(curres != NULL); + curres->hr_checksum = $2; break; default: - assert(!"checksum at wrong depth level"); + PJDLOG_ABORT("checksum at wrong depth level"); } } ; @@ -521,11 +520,11 @@ compression_statement: COMPRESSION compression_type depth0_compression = $2; break; case 1: - if (curres != NULL) - curres->hr_compression = $2; + PJDLOG_ASSERT(curres != NULL); + curres->hr_compression = $2; break; default: - assert(!"compression at wrong depth level"); + PJDLOG_ABORT("compression at wrong depth level"); } } ; @@ -549,11 +548,11 @@ timeout_statement: TIMEOUT NUM depth0_timeout = $2; break; case 1: - if (curres != NULL) - curres->hr_timeout = $2; + PJDLOG_ASSERT(curres != NULL); + curres->hr_timeout = $2; break; default: - assert(!"timeout at wrong depth level"); + PJDLOG_ABORT("timeout at wrong depth level"); } } ; @@ -570,8 +569,7 @@ exec_statement: EXEC STR } break; case 1: - if (curres == NULL) - break; + PJDLOG_ASSERT(curres != NULL); if (strlcpy(curres->hr_exec, $2, sizeof(curres->hr_exec)) >= sizeof(curres->hr_exec)) { @@ -581,7 +579,7 @@ exec_statement: EXEC STR } break; default: - assert(!"exec at wrong depth level"); + PJDLOG_ABORT("exec at wrong depth level"); } free($2); } @@ -605,7 +603,7 @@ node_start: STR mynode = true; break; default: - assert(!"invalid isitme() return value"); + PJDLOG_ABORT("invalid isitme() return value"); } free($1); } @@ -640,7 +638,7 @@ resource_statement: RESOURCE resource_start OB resource_entries CB } /* - * Let's see there are some resource-level settings + * Let's see if there are some resource-level settings * that we can use for node-level settings. */ if (curres->hr_provname[0] == '\0' && @@ -785,7 +783,7 @@ name_statement: NAME STR case 2: if (!mynode) break; - assert(curres != NULL); + PJDLOG_ASSERT(curres != NULL); if (strlcpy(curres->hr_provname, $2, sizeof(curres->hr_provname)) >= sizeof(curres->hr_provname)) { @@ -795,7 +793,7 @@ name_statement: NAME STR } break; default: - assert(!"name at wrong depth level"); + PJDLOG_ABORT("name at wrong depth level"); } free($2); } @@ -816,7 +814,7 @@ local_statement: LOCAL STR case 2: if (!mynode) break; - assert(curres != NULL); + PJDLOG_ASSERT(curres != NULL); if (strlcpy(curres->hr_localpath, $2, sizeof(curres->hr_localpath)) >= sizeof(curres->hr_localpath)) { @@ -826,7 +824,7 @@ local_statement: LOCAL STR } break; default: - assert(!"local at wrong depth level"); + PJDLOG_ABORT("local at wrong depth level"); } free($2); } @@ -851,7 +849,7 @@ resource_node_start: STR mynode = hadmynode = true; break; default: - assert(!"invalid isitme() return value"); + PJDLOG_ABORT("invalid isitme() return value"); } } free($1); @@ -875,9 +873,9 @@ resource_node_entry: remote_statement: REMOTE remote_str { - assert(depth == 2); + PJDLOG_ASSERT(depth == 2); if (mynode) { - assert(curres != NULL); + PJDLOG_ASSERT(curres != NULL); if (strlcpy(curres->hr_remoteaddr, $2, sizeof(curres->hr_remoteaddr)) >= sizeof(curres->hr_remoteaddr)) { @@ -898,9 +896,9 @@ remote_str: source_statement: SOURCE STR { - assert(depth == 2); + PJDLOG_ASSERT(depth == 2); if (mynode) { - assert(curres != NULL); + PJDLOG_ASSERT(curres != NULL); if (strlcpy(curres->hr_sourceaddr, $2, sizeof(curres->hr_sourceaddr)) >= sizeof(curres->hr_sourceaddr)) { diff --git a/sbin/hastd/pjdlog.c b/sbin/hastd/pjdlog.c index 16ecf4d..bc4018f 100644 --- a/sbin/hastd/pjdlog.c +++ b/sbin/hastd/pjdlog.c @@ -148,11 +148,14 @@ pjdlog_printf_render_sockaddr(struct __printf_io *io, void pjdlog_init(int mode) { + int saved_errno; assert(pjdlog_initialized == PJDLOG_NEVER_INITIALIZED || pjdlog_initialized == PJDLOG_NOT_INITIALIZED); assert(mode == PJDLOG_MODE_STD || mode == PJDLOG_MODE_SYSLOG); + saved_errno = errno; + if (pjdlog_initialized == PJDLOG_NEVER_INITIALIZED) { __use_xprintf = 1; register_printf_render_std("T"); @@ -171,18 +174,25 @@ pjdlog_init(int mode) bzero(pjdlog_prefix, sizeof(pjdlog_prefix)); pjdlog_initialized = PJDLOG_INITIALIZED; + + errno = saved_errno; } void pjdlog_fini(void) { + int saved_errno; assert(pjdlog_initialized == PJDLOG_INITIALIZED); + saved_errno = errno; + if (pjdlog_mode == PJDLOG_MODE_SYSLOG) closelog(); pjdlog_initialized = PJDLOG_NOT_INITIALIZED; + + errno = saved_errno; } /* @@ -194,6 +204,7 @@ pjdlog_fini(void) void pjdlog_mode_set(int mode) { + int saved_errno; assert(pjdlog_initialized == PJDLOG_INITIALIZED); assert(mode == PJDLOG_MODE_STD || mode == PJDLOG_MODE_SYSLOG); @@ -201,12 +212,16 @@ pjdlog_mode_set(int mode) if (pjdlog_mode == mode) return; + saved_errno = errno; + if (mode == PJDLOG_MODE_SYSLOG) openlog(NULL, LOG_PID | LOG_NDELAY, LOG_DAEMON); else /* if (mode == PJDLOG_MODE_STD) */ closelog(); pjdlog_mode = mode; + + errno = saved_errno; } /* @@ -270,11 +285,16 @@ pjdlog_prefix_set(const char *fmt, ...) void pjdlogv_prefix_set(const char *fmt, va_list ap) { + int saved_errno; assert(pjdlog_initialized == PJDLOG_INITIALIZED); assert(fmt != NULL); + saved_errno = errno; + vsnprintf(pjdlog_prefix, sizeof(pjdlog_prefix), fmt, ap); + + errno = saved_errno; } /* @@ -329,6 +349,7 @@ void pjdlogv_common(int loglevel, int debuglevel, int error, const char *fmt, va_list ap) { + int saved_errno; assert(pjdlog_initialized == PJDLOG_INITIALIZED); assert(loglevel == LOG_EMERG || loglevel == LOG_ALERT || @@ -342,6 +363,8 @@ pjdlogv_common(int loglevel, int debuglevel, int error, const char *fmt, if (loglevel == LOG_DEBUG && debuglevel > pjdlog_debug_level) return; + saved_errno = errno; + switch (pjdlog_mode) { case PJDLOG_MODE_STD: { @@ -398,6 +421,8 @@ pjdlogv_common(int loglevel, int debuglevel, int error, const char *fmt, default: assert(!"Invalid mode."); } + + errno = saved_errno; } /* diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c index dd414f8..ebb758e 100644 --- a/sbin/hastd/primary.c +++ b/sbin/hastd/primary.c @@ -293,8 +293,7 @@ hast_activemap_flush(struct hast_resource *res) PJDLOG_ASSERT((size % res->hr_local_sectorsize) == 0); if (pwrite(res->hr_localfd, buf, size, METADATA_SIZE) != (ssize_t)size) { - KEEP_ERRNO(pjdlog_errno(LOG_ERR, - "Unable to flush activemap to disk")); + pjdlog_errno(LOG_ERR, "Unable to flush activemap to disk"); return (-1); } return (0); @@ -1421,8 +1420,7 @@ remote_send_thread(void *arg) length = 0; break; default: - PJDLOG_ASSERT(!"invalid condition"); - abort(); + PJDLOG_ABORT("invalid condition"); } nv = nv_alloc(); nv_add_uint8(nv, cmd, "cmd"); @@ -1621,8 +1619,7 @@ remote_recv_thread(void *arg) case BIO_FLUSH: break; default: - PJDLOG_ASSERT(!"invalid condition"); - abort(); + PJDLOG_ABORT("invalid condition"); } hio->hio_errors[ncomp] = 0; nv_free(nv); diff --git a/sbin/hastd/proto_tcp.c b/sbin/hastd/proto_tcp.c index 8f0f157..44eb13b 100644 --- a/sbin/hastd/proto_tcp.c +++ b/sbin/hastd/proto_tcp.c @@ -298,8 +298,7 @@ tcp_connect(void *ctx, int timeout) flags = fcntl(tctx->tc_fd, F_GETFL); if (flags == -1) { - KEEP_ERRNO(pjdlog_common(LOG_DEBUG, 1, errno, - "fcntl(F_GETFL) failed")); + pjdlog_common(LOG_DEBUG, 1, errno, "fcntl(F_GETFL) failed"); return (errno); } /* @@ -308,8 +307,8 @@ tcp_connect(void *ctx, int timeout) */ flags |= O_NONBLOCK; if (fcntl(tctx->tc_fd, F_SETFL, flags) == -1) { - KEEP_ERRNO(pjdlog_common(LOG_DEBUG, 1, errno, - "fcntl(F_SETFL, O_NONBLOCK) failed")); + pjdlog_common(LOG_DEBUG, 1, errno, + "fcntl(F_SETFL, O_NONBLOCK) failed"); return (errno); } diff --git a/sbin/hastd/rangelock.c b/sbin/hastd/rangelock.c index 02247d6..5ff1f19 100644 --- a/sbin/hastd/rangelock.c +++ b/sbin/hastd/rangelock.c @@ -32,13 +32,19 @@ __FBSDID("$FreeBSD$"); #include <sys/queue.h> -#include <assert.h> #include <stdbool.h> #include <stdlib.h> #include <unistd.h> +#include <pjdlog.h> + #include "rangelock.h" +#ifndef PJDLOG_ASSERT +#include <assert.h> +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#endif + #define RANGELOCKS_MAGIC 0x94310c struct rangelocks { int rls_magic; /* Magic value. */ @@ -56,7 +62,7 @@ rangelock_init(struct rangelocks **rlsp) { struct rangelocks *rls; - assert(rlsp != NULL); + PJDLOG_ASSERT(rlsp != NULL); rls = malloc(sizeof(*rls)); if (rls == NULL) @@ -75,7 +81,7 @@ rangelock_free(struct rangelocks *rls) { struct rlock *rl; - assert(rls->rls_magic == RANGELOCKS_MAGIC); + PJDLOG_ASSERT(rls->rls_magic == RANGELOCKS_MAGIC); rls->rls_magic = 0; @@ -91,7 +97,7 @@ rangelock_add(struct rangelocks *rls, off_t offset, off_t length) { struct rlock *rl; - assert(rls->rls_magic == RANGELOCKS_MAGIC); + PJDLOG_ASSERT(rls->rls_magic == RANGELOCKS_MAGIC); rl = malloc(sizeof(*rl)); if (rl == NULL) @@ -107,13 +113,13 @@ rangelock_del(struct rangelocks *rls, off_t offset, off_t length) { struct rlock *rl; - assert(rls->rls_magic == RANGELOCKS_MAGIC); + PJDLOG_ASSERT(rls->rls_magic == RANGELOCKS_MAGIC); TAILQ_FOREACH(rl, &rls->rls_locks, rl_next) { if (rl->rl_start == offset && rl->rl_end == offset + length) break; } - assert(rl != NULL); + PJDLOG_ASSERT(rl != NULL); TAILQ_REMOVE(&rls->rls_locks, rl, rl_next); free(rl); } @@ -123,7 +129,7 @@ rangelock_islocked(struct rangelocks *rls, off_t offset, off_t length) { struct rlock *rl; - assert(rls->rls_magic == RANGELOCKS_MAGIC); + PJDLOG_ASSERT(rls->rls_magic == RANGELOCKS_MAGIC); TAILQ_FOREACH(rl, &rls->rls_locks, rl_next) { if (rl->rl_start >= offset && rl->rl_start < offset + length) diff --git a/sbin/hastd/secondary.c b/sbin/hastd/secondary.c index 7120d3d..fc0c898 100644 --- a/sbin/hastd/secondary.c +++ b/sbin/hastd/secondary.c @@ -791,8 +791,8 @@ send_thread(void *arg) length = 0; break; default: - abort(); - break; + PJDLOG_ABORT("Unexpected command (cmd=%hhu).", + hio->hio_cmd); } if (hio->hio_error != 0) nv_add_int16(nvout, hio->hio_error, "error"); diff --git a/sbin/hastd/subr.c b/sbin/hastd/subr.c index 89ffda0..45218bb 100644 --- a/sbin/hastd/subr.c +++ b/sbin/hastd/subr.c @@ -87,14 +87,13 @@ provinfo(struct hast_resource *res, bool dowrite) res->hr_localfd = open(res->hr_localpath, dowrite ? O_RDWR : O_RDONLY); if (res->hr_localfd < 0) { - KEEP_ERRNO(pjdlog_errno(LOG_ERR, "Unable to open %s", - res->hr_localpath)); + pjdlog_errno(LOG_ERR, "Unable to open %s", + res->hr_localpath); return (-1); } } if (fstat(res->hr_localfd, &sb) < 0) { - KEEP_ERRNO(pjdlog_errno(LOG_ERR, "Unable to stat %s", - res->hr_localpath)); + pjdlog_errno(LOG_ERR, "Unable to stat %s", res->hr_localpath); return (-1); } if (S_ISCHR(sb.st_mode)) { @@ -103,16 +102,16 @@ provinfo(struct hast_resource *res, bool dowrite) */ if (ioctl(res->hr_localfd, DIOCGMEDIASIZE, &res->hr_local_mediasize) < 0) { - KEEP_ERRNO(pjdlog_errno(LOG_ERR, + pjdlog_errno(LOG_ERR, "Unable obtain provider %s mediasize", - res->hr_localpath)); + res->hr_localpath); return (-1); } if (ioctl(res->hr_localfd, DIOCGSECTORSIZE, &res->hr_local_sectorsize) < 0) { - KEEP_ERRNO(pjdlog_errno(LOG_ERR, + pjdlog_errno(LOG_ERR, "Unable obtain provider %s sectorsize", - res->hr_localpath)); + res->hr_localpath); return (-1); } } else if (S_ISREG(sb.st_mode)) { @@ -169,8 +168,8 @@ drop_privs(struct hast_resource *res) pw = getpwnam(HAST_USER); if (pw == NULL) { if (errno != 0) { - KEEP_ERRNO(pjdlog_errno(LOG_ERR, - "Unable to find info about '%s' user", HAST_USER)); + pjdlog_errno(LOG_ERR, + "Unable to find info about '%s' user", HAST_USER); return (-1); } else { pjdlog_error("'%s' user doesn't exist.", HAST_USER); @@ -201,28 +200,27 @@ drop_privs(struct hast_resource *res) pjdlog_errno(LOG_WARNING, "Unable to jail to directory to %s", pw->pw_dir); if (chroot(pw->pw_dir) == -1) { - KEEP_ERRNO(pjdlog_errno(LOG_ERR, + pjdlog_errno(LOG_ERR, "Unable to change root directory to %s", - pw->pw_dir)); + pw->pw_dir); return (-1); } } PJDLOG_VERIFY(chdir("/") == 0); gidset[0] = pw->pw_gid; if (setgroups(1, gidset) == -1) { - KEEP_ERRNO(pjdlog_errno(LOG_ERR, - "Unable to set groups to gid %u", - (unsigned int)pw->pw_gid)); + pjdlog_errno(LOG_ERR, "Unable to set groups to gid %u", + (unsigned int)pw->pw_gid); return (-1); } if (setgid(pw->pw_gid) == -1) { - KEEP_ERRNO(pjdlog_errno(LOG_ERR, "Unable to set gid to %u", - (unsigned int)pw->pw_gid)); + pjdlog_errno(LOG_ERR, "Unable to set gid to %u", + (unsigned int)pw->pw_gid); return (-1); } if (setuid(pw->pw_uid) == -1) { - KEEP_ERRNO(pjdlog_errno(LOG_ERR, "Unable to set uid to %u", - (unsigned int)pw->pw_uid)); + pjdlog_errno(LOG_ERR, "Unable to set uid to %u", + (unsigned int)pw->pw_uid); return (-1); } diff --git a/sbin/hastd/synch.h b/sbin/hastd/synch.h index cf388d7..36e1927 100644 --- a/sbin/hastd/synch.h +++ b/sbin/hastd/synch.h @@ -32,20 +32,26 @@ #ifndef _SYNCH_H_ #define _SYNCH_H_ -#include <assert.h> #include <errno.h> #include <pthread.h> #include <pthread_np.h> #include <stdbool.h> #include <time.h> +#include <pjdlog.h> + +#ifndef PJDLOG_ASSERT +#include <assert.h> +#define PJDLOG_ASSERT(...) assert(__VA_ARGS__) +#endif + static __inline void mtx_init(pthread_mutex_t *lock) { int error; error = pthread_mutex_init(lock, NULL); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline void mtx_destroy(pthread_mutex_t *lock) @@ -53,7 +59,7 @@ mtx_destroy(pthread_mutex_t *lock) int error; error = pthread_mutex_destroy(lock); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline void mtx_lock(pthread_mutex_t *lock) @@ -61,7 +67,7 @@ mtx_lock(pthread_mutex_t *lock) int error; error = pthread_mutex_lock(lock); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline bool mtx_trylock(pthread_mutex_t *lock) @@ -69,7 +75,7 @@ mtx_trylock(pthread_mutex_t *lock) int error; error = pthread_mutex_trylock(lock); - assert(error == 0 || error == EBUSY); + PJDLOG_ASSERT(error == 0 || error == EBUSY); return (error == 0); } static __inline void @@ -78,7 +84,7 @@ mtx_unlock(pthread_mutex_t *lock) int error; error = pthread_mutex_unlock(lock); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline bool mtx_owned(pthread_mutex_t *lock) @@ -93,7 +99,7 @@ rw_init(pthread_rwlock_t *lock) int error; error = pthread_rwlock_init(lock, NULL); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline void rw_destroy(pthread_rwlock_t *lock) @@ -101,7 +107,7 @@ rw_destroy(pthread_rwlock_t *lock) int error; error = pthread_rwlock_destroy(lock); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline void rw_rlock(pthread_rwlock_t *lock) @@ -109,7 +115,7 @@ rw_rlock(pthread_rwlock_t *lock) int error; error = pthread_rwlock_rdlock(lock); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline void rw_wlock(pthread_rwlock_t *lock) @@ -117,7 +123,7 @@ rw_wlock(pthread_rwlock_t *lock) int error; error = pthread_rwlock_wrlock(lock); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline void rw_unlock(pthread_rwlock_t *lock) @@ -125,7 +131,7 @@ rw_unlock(pthread_rwlock_t *lock) int error; error = pthread_rwlock_unlock(lock); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline void @@ -135,13 +141,13 @@ cv_init(pthread_cond_t *cv) int error; error = pthread_condattr_init(&attr); - assert(error == 0); + PJDLOG_ASSERT(error == 0); error = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); - assert(error == 0); + PJDLOG_ASSERT(error == 0); error = pthread_cond_init(cv, &attr); - assert(error == 0); + PJDLOG_ASSERT(error == 0); error = pthread_condattr_destroy(&attr); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline void cv_wait(pthread_cond_t *cv, pthread_mutex_t *lock) @@ -149,7 +155,7 @@ cv_wait(pthread_cond_t *cv, pthread_mutex_t *lock) int error; error = pthread_cond_wait(cv, lock); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline bool cv_timedwait(pthread_cond_t *cv, pthread_mutex_t *lock, int timeout) @@ -163,10 +169,10 @@ cv_timedwait(pthread_cond_t *cv, pthread_mutex_t *lock, int timeout) } error = clock_gettime(CLOCK_MONOTONIC, &ts); - assert(error == 0); + PJDLOG_ASSERT(error == 0); ts.tv_sec += timeout; error = pthread_cond_timedwait(cv, lock, &ts); - assert(error == 0 || error == ETIMEDOUT); + PJDLOG_ASSERT(error == 0 || error == ETIMEDOUT); return (error == ETIMEDOUT); } static __inline void @@ -175,7 +181,7 @@ cv_signal(pthread_cond_t *cv) int error; error = pthread_cond_signal(cv); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } static __inline void cv_broadcast(pthread_cond_t *cv) @@ -183,6 +189,6 @@ cv_broadcast(pthread_cond_t *cv) int error; error = pthread_cond_broadcast(cv); - assert(error == 0); + PJDLOG_ASSERT(error == 0); } #endif /* !_SYNCH_H_ */ diff --git a/share/examples/cvsup/stable-supfile b/share/examples/cvsup/stable-supfile index 041d564..341eb6b 100644 --- a/share/examples/cvsup/stable-supfile +++ b/share/examples/cvsup/stable-supfile @@ -66,11 +66,11 @@ *default host=CHANGE_THIS.FreeBSD.org *default base=/var/db *default prefix=/usr -# The following line is for 8-stable. If you want 7-stable, 6-stable, -# 5-stable, 4-stable, 3-stable, or 2.2-stable, change to "RELENG_7", -# "RELENG_6", "RELENG_5", "RELENG_4", "RELENG_3", or "RELENG_2_2" -# respectively. -*default release=cvs tag=RELENG_8 +# The following line is for 9-stable. If you want 8-stable, 7-stable, +# 6-stable, 5-stable, 4-stable, 3-stable, or 2.2-stable, change to "RELENG_8", +# "RELENG_7", "RELENG_6", "RELENG_5", "RELENG_4", "RELENG_3", or +# "RELENG_2_2" respectively. +*default release=cvs tag=RELENG_9 *default delete use-rel-suffix # If you seem to be limited by CPU rather than network or disk bandwidth, try diff --git a/share/man/man4/smp.4 b/share/man/man4/smp.4 index 5d0d983..5712dbd 100644 --- a/share/man/man4/smp.4 +++ b/share/man/man4/smp.4 @@ -120,25 +120,24 @@ tasks on CPUs that are closely grouped together. .Pp .Fx supports hyperthreading on Intel CPU's on the i386 and AMD64 platforms. -Since using logical CPUs can cause performance penalties under certain loads, +Because using logical CPUs can cause performance penalties under certain loads, the logical CPUs can be disabled by setting the .Va machdep.hyperthreading_allowed tunable to zero. -.Xr cpuset 1 . .Sh SEE ALSO +.Xr cpuset 1 , .Xr mptable 1 , +.Xr sched_4bsd 4 , +.Xr sched_ule 4 , .Xr loader 8 , .Xr sysctl 8 , .Xr condvar 9 , .Xr msleep 9 , .Xr mtx_pool 9 , .Xr mutex 9 , -.Xr sema 9 , -.Xr sx 9 , .Xr rwlock 9 , -.Xr sched_4bsd 4 , -.Xr sched_ule 4 , -.Xr cpuset 1 +.Xr sema 9 , +.Xr sx 9 .Sh HISTORY The .Nm diff --git a/share/man/man9/ifnet.9 b/share/man/man9/ifnet.9 index 05264dc..e015fb7 100644 --- a/share/man/man9/ifnet.9 +++ b/share/man/man9/ifnet.9 @@ -1252,7 +1252,7 @@ function is called to perform the operation; qq.v. The socket's protocol control routine is called to implement the requested action. .Pp -.It Dv OSIOGIFADDR +.It Dv OSIOCGIFADDR .It Dv OSIOCGIFDSTADDR .It Dv OSIOCGIFBRDADDR .It Dv OSIOCGIFNETMASK diff --git a/share/misc/committers-src.dot b/share/misc/committers-src.dot index 2fce08f..b1100c7 100644 --- a/share/misc/committers-src.dot +++ b/share/misc/committers-src.dot @@ -70,6 +70,7 @@ onoe [label="Atsushi Onoe\nonoe@FreeBSD.org\n2000/07/21\n2008/11/10"] rgrimes [label="Rod Grimes\nrgrimes@FreeBSD.org\n1993/06/12\n2003/03/08"] rink [label="Rink Springer\nrink@FreeBSD.org\n2006/01/16\n2010/11/04"] robert [label="Robert Drehmel\nrobert@FreeBSD.org\n2001/08/23\n2006/05/13"] +rmh [label="Robert Millan\nrmh@FreeBSD.org\n2011/09/18"] rpaulo [label="Rui Paulo\nrpaulo@FreeBSD.org\n2007/09/25\n2010/12/03"] sah [label="Sam Hopkins\nsah@FreeBSD.org\n2004/12/15\n2008/11/10"] shafeeq [label="Shafeeq Sinnamohideen\nshafeeq@FreeBSD.org\n2000/06/19\n2006/04/06"] @@ -270,6 +271,7 @@ day1 -> alm day1 -> dg adrian -> ray +adrian -> rmh andre -> qingli @@ -440,6 +442,7 @@ kib -> pho kib -> pluknet kib -> rdivacky kib -> rmacklem +kib -> rmh kib -> stas kib -> tijl kib -> trociny diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh index b7d02e7..36be77f 100644 --- a/sys/conf/newvers.sh +++ b/sys/conf/newvers.sh @@ -31,8 +31,8 @@ # $FreeBSD$ TYPE="FreeBSD" -REVISION="9.0" -BRANCH="BETA2" +REVISION="10.0" +BRANCH="CURRENT" if [ "X${BRANCH_OVERRIDE}" != "X" ]; then BRANCH=${BRANCH_OVERRIDE} fi diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c index 7be4cdb..0a20f2c 100644 --- a/sys/dev/ahci/ahci.c +++ b/sys/dev/ahci/ahci.c @@ -197,6 +197,7 @@ static struct { {0x91231b4b, 0x11, "Marvell 88SE912x", AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG}, {0x91231b4b, 0x00, "Marvell 88SE912x", AHCI_Q_EDGEIS|AHCI_Q_SATA2|AHCI_Q_NOBSYRES}, {0x91251b4b, 0x00, "Marvell 88SE9125", AHCI_Q_NOBSYRES}, + {0x91281b4b, 0x00, "Marvell 88SE9128", AHCI_Q_NOBSYRES|AHCI_Q_ALTSIG}, {0x91721b4b, 0x00, "Marvell 88SE9172", AHCI_Q_NOBSYRES}, {0x91821b4b, 0x00, "Marvell 88SE9182", AHCI_Q_NOBSYRES}, {0x06201103, 0x00, "HighPoint RocketRAID 620", AHCI_Q_NOBSYRES}, diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212_beacon.c b/sys/dev/ath/ath_hal/ar5212/ar5212_beacon.c index 1b4b342..a411d31 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212_beacon.c +++ b/sys/dev/ath/ath_hal/ar5212/ar5212_beacon.c @@ -44,6 +44,7 @@ ar5212GetNextTBTT(struct ath_hal *ah) void ar5212SetBeaconTimers(struct ath_hal *ah, const HAL_BEACON_TIMERS *bt) { + struct ath_hal_5212 *ahp = AH5212(ah); OS_REG_WRITE(ah, AR_TIMER0, bt->bt_nexttbtt); OS_REG_WRITE(ah, AR_TIMER1, bt->bt_nextdba); @@ -65,6 +66,7 @@ ar5212SetBeaconTimers(struct ath_hal *ah, const HAL_BEACON_TIMERS *bt) OS_REG_WRITE(ah, AR_BEACON, AR_BEACON_RESET_TSF); } OS_REG_WRITE(ah, AR_BEACON, bt->bt_intval); + ahp->ah_beaconInterval = (bt->bt_intval & HAL_BEACON_PERIOD); } /* diff --git a/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c b/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c index 3c6ddc0..fa0e883 100644 --- a/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c +++ b/sys/dev/ath/ath_hal/ar5212/ar5212_xmit.c @@ -263,6 +263,7 @@ ar5212ReleaseTxQueue(struct ath_hal *ah, u_int q) * Assumes: * phwChannel has been set to point to the current channel */ +#define TU_TO_USEC(_tu) ((_tu) << 10) HAL_BOOL ar5212ResetTxQueue(struct ath_hal *ah, u_int q) { @@ -270,7 +271,7 @@ ar5212ResetTxQueue(struct ath_hal *ah, u_int q) HAL_CAPABILITIES *pCap = &AH_PRIVATE(ah)->ah_caps; const struct ieee80211_channel *chan = AH_PRIVATE(ah)->ah_curchan; HAL_TX_QUEUE_INFO *qi; - uint32_t cwMin, chanCwMin, value, qmisc, dmisc; + uint32_t cwMin, chanCwMin, qmisc, dmisc; if (q >= pCap->halTotalQueues) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n", @@ -409,17 +410,40 @@ ar5212ResetTxQueue(struct ath_hal *ah, u_int q) | AR_Q_MISC_CBR_INCR_DIS1 | AR_Q_MISC_CBR_INCR_DIS0; - if (!qi->tqi_readyTime) { + if (qi->tqi_readyTime) { + HALDEBUG(ah, HAL_DEBUG_TXQUEUE, + "%s: using tqi_readyTime\n", __func__); + OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), + SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_INT) | + AR_Q_RDYTIMECFG_ENA); + } else { + int value; /* * NB: don't set default ready time if driver * has explicitly specified something. This is * here solely for backwards compatibility. */ - value = (ahp->ah_beaconInterval + /* + * XXX for now, hard-code a CAB interval of 70% + * XXX of the total beacon interval. + */ + + value = (ahp->ah_beaconInterval * 70 / 100) - (ah->ah_config.ah_sw_beacon_response_time - - ah->ah_config.ah_dma_beacon_response_time) - - ah->ah_config.ah_additional_swba_backoff) * 1024; - OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_ENA); + + ah->ah_config.ah_dma_beacon_response_time) + - ah->ah_config.ah_additional_swba_backoff; + /* + * XXX Ensure it isn't too low - nothing lower + * XXX than 10 TU + */ + if (value < 10) + value = 10; + HALDEBUG(ah, HAL_DEBUG_TXQUEUE, + "%s: defaulting to rdytime = %d uS\n", + __func__, value); + OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), + SM(TU_TO_USEC(value), AR_Q_RDYTIMECFG_INT) | + AR_Q_RDYTIMECFG_ENA); } dmisc |= SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL, AR_D_MISC_ARB_LOCKOUT_CNTRL); @@ -481,6 +505,7 @@ ar5212ResetTxQueue(struct ath_hal *ah, u_int q) return AH_TRUE; } +#undef TU_TO_USEC /* * Get the TXDP for the specified queue diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c b/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c index 8b61e14..e2bf6c7 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_beacon.c @@ -46,6 +46,7 @@ void ar5416SetBeaconTimers(struct ath_hal *ah, const HAL_BEACON_TIMERS *bt) { uint32_t bperiod; + struct ath_hal_5212 *ahp = AH5212(ah); OS_REG_WRITE(ah, AR_NEXT_TBTT, TU_TO_USEC(bt->bt_nexttbtt)); OS_REG_WRITE(ah, AR_NEXT_DBA, ONE_EIGHTH_TU_TO_USEC(bt->bt_nextdba)); @@ -53,6 +54,7 @@ ar5416SetBeaconTimers(struct ath_hal *ah, const HAL_BEACON_TIMERS *bt) OS_REG_WRITE(ah, AR_NEXT_NDP, TU_TO_USEC(bt->bt_nextatim)); bperiod = TU_TO_USEC(bt->bt_intval & HAL_BEACON_PERIOD); + ahp->ah_beaconInterval = bt->bt_intval & HAL_BEACON_PERIOD; OS_REG_WRITE(ah, AR5416_BEACON_PERIOD, bperiod); OS_REG_WRITE(ah, AR_DBA_PERIOD, bperiod); OS_REG_WRITE(ah, AR_SWBA_PERIOD, bperiod); diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c b/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c index 20791e8..3341b52 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_xmit.c @@ -879,6 +879,7 @@ setTxQInterrupts(struct ath_hal *ah, HAL_TX_QUEUE_INFO *qi) * Assumes: * phwChannel has been set to point to the current channel */ +#define TU_TO_USEC(_tu) ((_tu) << 10) HAL_BOOL ar5416ResetTxQueue(struct ath_hal *ah, u_int q) { @@ -886,7 +887,7 @@ ar5416ResetTxQueue(struct ath_hal *ah, u_int q) HAL_CAPABILITIES *pCap = &AH_PRIVATE(ah)->ah_caps; const struct ieee80211_channel *chan = AH_PRIVATE(ah)->ah_curchan; HAL_TX_QUEUE_INFO *qi; - uint32_t cwMin, chanCwMin, value, qmisc, dmisc; + uint32_t cwMin, chanCwMin, qmisc, dmisc; if (q >= pCap->halTotalQueues) { HALDEBUG(ah, HAL_DEBUG_ANY, "%s: invalid queue num %u\n", @@ -956,7 +957,8 @@ ar5416ResetTxQueue(struct ath_hal *ah, u_int q) if (qi->tqi_cbrOverflowLimit) qmisc |= AR_Q_MISC_CBR_EXP_CNTR_LIMIT; } - if (qi->tqi_readyTime) { + + if (qi->tqi_readyTime && (qi->tqi_type != HAL_TX_QUEUE_CAB)) { OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_INT) | AR_Q_RDYTIMECFG_ENA); @@ -1027,18 +1029,46 @@ ar5416ResetTxQueue(struct ath_hal *ah, u_int q) qmisc |= AR_Q_MISC_FSP_DBA_GATED | AR_Q_MISC_CBR_INCR_DIS1 | AR_Q_MISC_CBR_INCR_DIS0; - - if (!qi->tqi_readyTime) { + HALDEBUG(ah, HAL_DEBUG_TXQUEUE, "%s: CAB: tqi_readyTime = %d\n", + __func__, qi->tqi_readyTime); + if (qi->tqi_readyTime) { + HALDEBUG(ah, HAL_DEBUG_TXQUEUE, + "%s: using tqi_readyTime\n", __func__); + OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), + SM(qi->tqi_readyTime, AR_Q_RDYTIMECFG_INT) | + AR_Q_RDYTIMECFG_ENA); + } else { + int value; /* * NB: don't set default ready time if driver * has explicitly specified something. This is * here solely for backwards compatibility. */ - value = (ahp->ah_beaconInterval - - (ah->ah_config.ah_sw_beacon_response_time - - ah->ah_config.ah_dma_beacon_response_time) - - ah->ah_config.ah_additional_swba_backoff) * 1024; - OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), value | AR_Q_RDYTIMECFG_ENA); + /* + * XXX for now, hard-code a CAB interval of 70% + * XXX of the total beacon interval. + * + * XXX This keeps Merlin and later based MACs + * XXX quite a bit happier (stops stuck beacons, + * XXX which I gather is because of such a long + * XXX cabq time.) + */ + value = (ahp->ah_beaconInterval * 70 / 100) + - (ah->ah_config.ah_sw_beacon_response_time + + ah->ah_config.ah_dma_beacon_response_time) + - ah->ah_config.ah_additional_swba_backoff; + /* + * XXX Ensure it isn't too low - nothing lower + * XXX than 10 TU + */ + if (value < 10) + value = 10; + HALDEBUG(ah, HAL_DEBUG_TXQUEUE, + "%s: defaulting to rdytime = %d uS\n", + __func__, value); + OS_REG_WRITE(ah, AR_QRDYTIMECFG(q), + SM(TU_TO_USEC(value), AR_Q_RDYTIMECFG_INT) | + AR_Q_RDYTIMECFG_ENA); } dmisc |= SM(AR_D_MISC_ARB_LOCKOUT_CNTRL_GLOBAL, AR_D_MISC_ARB_LOCKOUT_CNTRL); @@ -1106,3 +1136,4 @@ ar5416ResetTxQueue(struct ath_hal *ah, u_int q) return AH_TRUE; } +#undef TU_TO_USEC diff --git a/sys/dev/ath/if_ath.c b/sys/dev/ath/if_ath.c index af61274..d74abe0 100644 --- a/sys/dev/ath/if_ath.c +++ b/sys/dev/ath/if_ath.c @@ -2619,9 +2619,10 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap) sc->sc_stats.ast_cabq_xmit += nmcastq; } /* NB: gated by beacon so safe to start here */ - ath_hal_txstart(ah, cabq->axq_qnum); - ATH_TXQ_UNLOCK(cabq); + if (! STAILQ_EMPTY(&(cabq->axq_q))) + ath_hal_txstart(ah, cabq->axq_qnum); ATH_TXQ_UNLOCK(&avp->av_mcastq); + ATH_TXQ_UNLOCK(cabq); } return bf; } diff --git a/sys/dev/ath/if_athvar.h b/sys/dev/ath/if_athvar.h index 5c468e7..1eaf709 100644 --- a/sys/dev/ath/if_athvar.h +++ b/sys/dev/ath/if_athvar.h @@ -64,7 +64,7 @@ #define ATH_TXMGTTRY 4 /* xmit attempts for mgt/ctl frames */ #define ATH_TXINTR_PERIOD 5 /* max number of batched tx descriptors */ -#define ATH_BEACON_AIFS_DEFAULT 0 /* default aifs for ap beacon q */ +#define ATH_BEACON_AIFS_DEFAULT 1 /* default aifs for ap beacon q */ #define ATH_BEACON_CWMIN_DEFAULT 0 /* default cwmin for ap beacon q */ #define ATH_BEACON_CWMAX_DEFAULT 0 /* default cwmax for ap beacon q */ diff --git a/sys/dev/usb/quirk/usb_quirk.c b/sys/dev/usb/quirk/usb_quirk.c index d3093f7..81a3e41 100644 --- a/sys/dev/usb/quirk/usb_quirk.c +++ b/sys/dev/usb/quirk/usb_quirk.c @@ -457,6 +457,13 @@ static struct usb_quirk_entry usb_quirks[USB_DEV_QUIRKS_MAX] = { USB_QUIRK(ROLAND, SD80, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), USB_QUIRK(ROLAND, UA700, 0x0000, 0xffff, UQ_AU_VENDOR_CLASS), USB_QUIRK(MEDELI, DD305, 0x0000, 0xffff, UQ_SINGLE_CMD_MIDI, UQ_MATCH_VENDOR_ONLY), + + /* + * Quirks for manufacturers which USB devices does not respond + * after issuing non-supported commands: + */ + USB_QUIRK(FEIYA, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY), + USB_QUIRK(REALTEK, DUMMY, 0x0000, 0xffff, UQ_MSC_NO_SYNC_CACHE, UQ_MATCH_VENDOR_ONLY), }; #undef USB_QUIRK_VP #undef USB_QUIRK diff --git a/sys/dev/usb/usbdevs b/sys/dev/usb/usbdevs index 6a729a2..d945a18 100644 --- a/sys/dev/usb/usbdevs +++ b/sys/dev/usb/usbdevs @@ -1569,6 +1569,7 @@ product EXTENDED XTNDACCESS 0x0100 XTNDAccess IrDA product FALCOM TWIST 0x0001 USB GSM/GPRS Modem /* FEIYA products */ +product FEIYA DUMMY 0x0000 Dummy product product FEIYA 5IN1 0x1132 5-in-1 Card Reader product FEIYA AC110 0x6300 AC-110 Card Reader @@ -2780,6 +2781,7 @@ product RATOC REXUSB60F 0xb020 USB serial adapter REX-USB60F /* ReakTek products */ /* Green House and CompUSA OEM this part */ +product REALTEK DUMMY 0x0000 Dummy product product REALTEK USB20CRW 0x0158 USB20CRW Card Reader product REALTEK USBKR100 0x8150 USBKR100 USB Ethernet product REALTEK RTL8187 0x8187 RTL8187 Wireless Adapter diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index 681b645..4f78073 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -842,7 +842,7 @@ watchdog_fire(void) curintr = intrcnt; curname = intrnames; inttotal = 0; - nintr = sintrcnt; + nintr = sintrcnt / sizeof(u_long); printf("interrupt total\n"); while (--nintr >= 0) { diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index fe01142..4545848 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -777,16 +777,6 @@ interpret: KNOTE_LOCKED(&p->p_klist, NOTE_EXEC); p->p_flag &= ~P_INEXEC; - /* - * If tracing the process, trap to the debugger so that - * breakpoints can be set before the program executes. We - * have to use tdsignal() to deliver the signal to the current - * thread since any other threads in this process will exit if - * execve() succeeds. - */ - if (p->p_flag & P_TRACED) - tdsignal(td, SIGTRAP); - /* clear "fork but no exec" flag, as we _are_ execing */ p->p_acflag &= ~AFORK; diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 2ee7dc6..76b37a9 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$"); #include "opt_kdb.h" #include "opt_stack.h" -#include "opt_watchdog.h" #include <sys/param.h> #include <sys/systm.h> @@ -42,9 +41,6 @@ __FBSDID("$FreeBSD$"); #include <sys/smp.h> #include <sys/stack.h> #include <sys/sysctl.h> -#ifdef SW_WATCHDOG -#include <sys/watchdog.h> -#endif #include <machine/kdb.h> #include <machine/pcb.h> @@ -591,9 +587,6 @@ kdb_trap(int type, int code, struct trapframe *tf) cpuset_t other_cpus; #endif struct kdb_dbbe *be; -#ifdef SW_WATCHDOG - u_int wdoglvt; -#endif register_t intr; int handled; @@ -607,10 +600,6 @@ kdb_trap(int type, int code, struct trapframe *tf) intr = intr_disable(); -#ifdef SW_WATCHDOG - wdoglvt = wdog_kern_last_timeout(); - wdog_kern_pat(WD_TO_NEVER); -#endif #ifdef SMP other_cpus = all_cpus; CPU_CLR(PCPU_GET(cpuid), &other_cpus); @@ -642,9 +631,6 @@ kdb_trap(int type, int code, struct trapframe *tf) #ifdef SMP restart_cpus(stopped_cpus); #endif -#ifdef SW_WATCHDOG - wdog_kern_pat(wdoglvt); -#endif intr_restore(intr); diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c index cb0d929..bba4479 100644 --- a/sys/kern/subr_syscall.c +++ b/sys/kern/subr_syscall.c @@ -204,9 +204,17 @@ syscallret(struct thread *td, int error, struct syscall_args *sa __unused) * is not the case, this code will need to be revisited. */ STOPEVENT(p, S_SCX, sa->code); - PTRACESTOP_SC(p, td, S_PT_SCX); if (traced || (td->td_dbgflags & (TDB_EXEC | TDB_FORK)) != 0) { PROC_LOCK(p); + /* + * If tracing the execed process, trap to the debugger + * so that breakpoints can be set before the program + * executes. If debugger requested tracing of syscall + * returns, do it now too. + */ + if (traced && ((td->td_dbgflags & TDB_EXEC) != 0 || + (p->p_stops & S_PT_SCX) != 0)) + ptracestop(td, SIGTRAP); td->td_dbgflags &= ~(TDB_SCX | TDB_EXEC | TDB_FORK); PROC_UNLOCK(p); } diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 3a34f58..801a244 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -462,6 +462,8 @@ uipc_bind(struct socket *so, struct sockaddr *nam, struct thread *td) unp = sotounpcb(so); KASSERT(unp != NULL, ("uipc_bind: unp == NULL")); + if (soun->sun_len > sizeof(struct sockaddr_un)) + return (EINVAL); namelen = soun->sun_len - offsetof(struct sockaddr_un, sun_path); if (namelen <= 0) return (EINVAL); @@ -1252,6 +1254,8 @@ unp_connect(struct socket *so, struct sockaddr *nam, struct thread *td) unp = sotounpcb(so); KASSERT(unp != NULL, ("unp_connect: unp == NULL")); + if (nam->sa_len > sizeof(struct sockaddr_un)) + return (EINVAL); len = nam->sa_len - offsetof(struct sockaddr_un, sun_path); if (len <= 0) return (EINVAL); diff --git a/sys/modules/ipfw/Makefile b/sys/modules/ipfw/Makefile index ec9b3cc..60ab848 100644 --- a/sys/modules/ipfw/Makefile +++ b/sys/modules/ipfw/Makefile @@ -8,7 +8,7 @@ KMOD= ipfw SRCS= ip_fw2.c ip_fw_pfil.c SRCS+= ip_fw_dynamic.c ip_fw_log.c SRCS+= ip_fw_sockopt.c ip_fw_table.c -SRCS+= opt_inet6.h opt_ipfw.h opt_ipsec.h +SRCS+= opt_inet.h opt_inet6.h opt_ipfw.h opt_ipsec.h CFLAGS+= -DIPFIREWALL CFLAGS+= -I${.CURDIR}/../../contrib/pf @@ -22,6 +22,10 @@ CFLAGS+= -I${.CURDIR}/../../contrib/pf # .if !defined(KERNBUILDDIR) +.if ${MK_INET_SUPPORT} != "no" +opt_inet.h: + echo "#define INET 1" > ${.TARGET} +.endif .if ${MK_INET6_SUPPORT} != "no" opt_inet6.h: echo "#define INET6 1" > ${.TARGET} diff --git a/sys/netinet/ipfw/ip_fw_pfil.c b/sys/netinet/ipfw/ip_fw_pfil.c index c470b1f..a09ca79 100644 --- a/sys/netinet/ipfw/ip_fw_pfil.c +++ b/sys/netinet/ipfw/ip_fw_pfil.c @@ -31,11 +31,11 @@ __FBSDID("$FreeBSD$"); #if !defined(KLD_MODULE) #include "opt_ipdn.h" #include "opt_inet.h" +#include "opt_inet6.h" #ifndef INET #error IPFIREWALL requires INET. #endif /* INET */ #endif /* KLD_MODULE */ -#include "opt_inet6.h" #include <sys/param.h> #include <sys/systm.h> @@ -154,7 +154,7 @@ again: /* next_hop may be set by ipfw_chk */ if (args.next_hop == NULL && args.next_hop6 == NULL) break; /* pass */ -#ifndef IPFIREWALL_FORWARD +#if !defined(IPFIREWALL_FORWARD) || (!defined(INET6) && !defined(INET)) ret = EACCES; #else { @@ -205,7 +205,7 @@ again: #endif m_tag_prepend(*m0, fwd_tag); } -#endif +#endif /* IPFIREWALL_FORWARD */ break; case IP_FW_DENY: diff --git a/sys/sys/param.h b/sys/sys/param.h index 0db0223..c10b433 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 900044 /* Master, propagated to newvers */ +#define __FreeBSD_version 1000000 /* Master, propagated to newvers */ #ifdef _KERNEL #define P_OSREL_SIGSEGV 700004 diff --git a/sys/ufs/ffs/ffs_snapshot.c b/sys/ufs/ffs/ffs_snapshot.c index c8dd4c6..c8d8969 100644 --- a/sys/ufs/ffs/ffs_snapshot.c +++ b/sys/ufs/ffs/ffs_snapshot.c @@ -203,7 +203,7 @@ ffs_snapshot(mp, snapfile) ufs2_daddr_t numblks, blkno, *blkp, *snapblklist; int error, cg, snaploc; int i, size, len, loc; - int flag; + uint64_t flag; struct timespec starttime = {0, 0}, endtime; char saved_nice = 0; long redo = 0, snaplistsize = 0; @@ -212,7 +212,7 @@ ffs_snapshot(mp, snapfile) struct fs *copy_fs = NULL, *fs; struct thread *td = curthread; struct inode *ip, *xp; - struct buf *bp, *nbp, *ibp, *sbp = NULL; + struct buf *bp, *nbp, *ibp; struct nameidata nd; struct mount *wrtmp; struct vattr vat; @@ -460,21 +460,14 @@ restart: * Grab a copy of the superblock and its summary information. * We delay writing it until the suspension is released below. */ - error = bread(vp, lblkno(fs, fs->fs_sblockloc), fs->fs_bsize, - KERNCRED, &sbp); - if (error) { - brelse(sbp); - sbp = NULL; - goto out1; - } - loc = blkoff(fs, fs->fs_sblockloc); - copy_fs = (struct fs *)(sbp->b_data + loc); + copy_fs = malloc((u_long)fs->fs_bsize, M_UFSMNT, M_WAITOK); bcopy(fs, copy_fs, fs->fs_sbsize); if ((fs->fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) == 0) copy_fs->fs_clean = 1; size = fs->fs_bsize < SBLOCKSIZE ? fs->fs_bsize : SBLOCKSIZE; if (fs->fs_sbsize < size) - bzero(&sbp->b_data[loc + fs->fs_sbsize], size - fs->fs_sbsize); + bzero(&((char *)copy_fs)[fs->fs_sbsize], + size - fs->fs_sbsize); size = blkroundup(fs, fs->fs_cssize); if (fs->fs_contigsumsize > 0) size += fs->fs_ncg * sizeof(int32_t); @@ -490,8 +483,8 @@ restart: len, KERNCRED, &bp)) != 0) { brelse(bp); free(copy_fs->fs_csp, M_UFSMNT); - bawrite(sbp); - sbp = NULL; + free(copy_fs, M_UFSMNT); + copy_fs = NULL; goto out1; } bcopy(bp->b_data, space, (u_int)len); @@ -606,8 +599,8 @@ loop: vdrop(xvp); if (error) { free(copy_fs->fs_csp, M_UFSMNT); - bawrite(sbp); - sbp = NULL; + free(copy_fs, M_UFSMNT); + copy_fs = NULL; MNT_VNODE_FOREACH_ABORT(mp, mvp); goto out1; } @@ -621,8 +614,8 @@ loop: error = softdep_journal_lookup(mp, &xvp); if (error) { free(copy_fs->fs_csp, M_UFSMNT); - bawrite(sbp); - sbp = NULL; + free(copy_fs, M_UFSMNT); + copy_fs = NULL; goto out1; } xp = VTOI(xvp); @@ -688,8 +681,8 @@ loop: VI_UNLOCK(devvp); ASSERT_VOP_LOCKED(vp, "ffs_snapshot vp"); out1: - KASSERT((sn != NULL && sbp != NULL && error == 0) || - (sn == NULL && sbp == NULL && error != 0), + KASSERT((sn != NULL && copy_fs != NULL && error == 0) || + (sn == NULL && copy_fs == NULL && error != 0), ("email phk@ and mckusick@")); /* * Resume operation on filesystem. @@ -703,7 +696,7 @@ out1: vp->v_mount->mnt_stat.f_mntonname, (long)endtime.tv_sec, endtime.tv_nsec / 1000000, redo, fs->fs_ncg); } - if (sbp == NULL) + if (copy_fs == NULL) goto out; /* * Copy allocation information from all the snapshots in @@ -793,6 +786,15 @@ out1: space = (char *)space + fs->fs_bsize; bawrite(nbp); } + error = bread(vp, lblkno(fs, fs->fs_sblockloc), fs->fs_bsize, + KERNCRED, &nbp); + if (error) { + brelse(nbp); + } else { + loc = blkoff(fs, fs->fs_sblockloc); + bcopy((char *)copy_fs, &nbp->b_data[loc], fs->fs_bsize); + bawrite(nbp); + } /* * As this is the newest list, it is the most inclusive, so * should replace the previous list. @@ -822,7 +824,8 @@ out1: vrele(vp); /* Drop extra reference */ done: free(copy_fs->fs_csp, M_UFSMNT); - bawrite(sbp); + free(copy_fs, M_UFSMNT); + copy_fs = NULL; out: NDFREE(&nd, NDF_ONLY_PNBUF); if (saved_nice > 0) { diff --git a/tools/make_libdeps.sh b/tools/make_libdeps.sh index b0b3f18..608422ae 100644 --- a/tools/make_libdeps.sh +++ b/tools/make_libdeps.sh @@ -52,7 +52,7 @@ sed -E -e's;-l(ncurses|termcap)!;lib/ncurses/ncurses;g' -e's;-l(gcc)!;gnu/lib/lib\1;g' -e's;-lssp_nonshared!;gnu/lib/libssp/libssp_nonshared;g' - -e's;-l(asn1|heimntlm|hx509|krb5|roken)!;kerberos5/lib/lib\1;g' + -e's;-l(asn1|hdb|heimntlm|hx509|krb5|roken)!;kerberos5/lib/lib\1;g' -e's;-l(crypto|ssh|ssl)!;secure/lib/lib\1;g' -e's;-l([^!]+)!;lib/lib\1;g' " diff --git a/usr.bin/compress/zopen.c b/usr.bin/compress/zopen.c index a729e13..8ae3d7d 100644 --- a/usr.bin/compress/zopen.c +++ b/usr.bin/compress/zopen.c @@ -486,7 +486,7 @@ zread(void *cookie, char *rbp, int num) block_compress = maxbits & BLOCK_MASK; maxbits &= BIT_MASK; maxmaxcode = 1L << maxbits; - if (maxbits > BITS) { + if (maxbits > BITS || maxbits < 12) { errno = EFTYPE; return (-1); } @@ -513,17 +513,28 @@ zread(void *cookie, char *rbp, int num) for (code = 255; code >= 0; code--) tab_prefixof(code) = 0; clear_flg = 1; - free_ent = FIRST - 1; - if ((code = getcode(zs)) == -1) /* O, untimely death! */ - break; + free_ent = FIRST; + oldcode = -1; + continue; } incode = code; - /* Special case for KwKwK string. */ + /* Special case for kWkWk string. */ if (code >= free_ent) { + if (code > free_ent || oldcode == -1) { + /* Bad stream. */ + errno = EINVAL; + return (-1); + } *stackp++ = finchar; code = oldcode; } + /* + * The above condition ensures that code < free_ent. + * The construction of tab_prefixof in turn guarantees that + * each iteration decreases code and therefore stack usage is + * bound by 1 << BITS - 256. + */ /* Generate output characters in reverse order. */ while (code >= 256) { @@ -540,7 +551,7 @@ middle: do { } while (stackp > de_stack); /* Generate the new entry. */ - if ((code = free_ent) < maxmaxcode) { + if ((code = free_ent) < maxmaxcode && oldcode != -1) { tab_prefixof(code) = (u_short) oldcode; tab_suffixof(code) = finchar; free_ent = code + 1; diff --git a/usr.bin/fetch/fetch.1 b/usr.bin/fetch/fetch.1 index 0dbbc0b..837ae4b 100644 --- a/usr.bin/fetch/fetch.1 +++ b/usr.bin/fetch/fetch.1 @@ -1,5 +1,5 @@ .\"- -.\" Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav +.\" Copyright (c) 2000-2011 Dag-Erling Smørgrav .\" All rights reserved. .\" Portions Copyright (c) 1999 Massachusetts Institute of Technology; used .\" by permission. @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 14, 2008 +.Dd September 27, 2011 .Dt FETCH 1 .Os .Sh NAME @@ -165,11 +165,13 @@ directory, with name(s) selected as in the default behaviour. .It Fl P .It Fl p Use passive FTP. -This is useful if you are behind a firewall which blocks incoming -connections. -Try this flag if -.Nm -seems to hang when retrieving FTP URLs. +These flags have no effect, since passive FTP is the default, but are +provided for compatibility with earlier versions where active FTP was +the default. +To force active mode, set the +.Ev FTP_PASSIVE_MODE +environment variable to +.Ql NO . .It Fl q Quiet mode. .It Fl R diff --git a/usr.bin/fetch/fetch.c b/usr.bin/fetch/fetch.c index d0e97ec..8d26671 100644 --- a/usr.bin/fetch/fetch.c +++ b/usr.bin/fetch/fetch.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav + * Copyright (c) 2000-2011 Dag-Erling Smørgrav * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -540,7 +540,7 @@ fetch(char *URL, const char *path) goto failure; } /* we got it, open local file */ - if ((of = fopen(path, "a")) == NULL) { + if ((of = fopen(path, "r+")) == NULL) { warn("%s: fopen()", path); goto failure; } @@ -559,13 +559,13 @@ fetch(char *URL, const char *path) sb = nsb; /* picked up again later */ } - /* seek to where we left off */ - if (of != NULL && fseek(of, url->offset, SEEK_SET) != 0) { - warn("%s: fseek()", path); - fclose(of); - of = NULL; - /* picked up again later */ - } + } + /* seek to where we left off */ + if (of != NULL && fseeko(of, url->offset, SEEK_SET) != 0) { + warn("%s: fseeko()", path); + fclose(of); + of = NULL; + /* picked up again later */ } } else if (m_flag && sb.st_size != -1) { /* mirror mode, local file exists */ diff --git a/usr.bin/gzip/zuncompress.c b/usr.bin/gzip/zuncompress.c index f68ba59..1d0b66f 100644 --- a/usr.bin/gzip/zuncompress.c +++ b/usr.bin/gzip/zuncompress.c @@ -247,7 +247,7 @@ zread(void *cookie, char *rbp, int num) zs->zs_block_compress = zs->zs_maxbits & BLOCK_MASK; zs->zs_maxbits &= BIT_MASK; zs->zs_maxmaxcode = 1L << zs->zs_maxbits; - if (zs->zs_maxbits > BITS) { + if (zs->zs_maxbits > BITS || zs->zs_maxbits < 12) { errno = EFTYPE; return (-1); } @@ -259,13 +259,7 @@ zread(void *cookie, char *rbp, int num) } zs->zs_free_ent = zs->zs_block_compress ? FIRST : 256; - zs->u.r.zs_finchar = zs->u.r.zs_oldcode = getcode(zs); - if (zs->u.r.zs_oldcode == -1) /* EOF already? */ - return (0); /* Get out of here */ - - /* First code must be 8 bits = char. */ - *bp++ = (u_char)zs->u.r.zs_finchar; - count--; + zs->u.r.zs_oldcode = -1; zs->u.r.zs_stackp = de_stack; while ((zs->u.r.zs_code = getcode(zs)) > -1) { @@ -275,17 +269,29 @@ zread(void *cookie, char *rbp, int num) zs->u.r.zs_code--) tab_prefixof(zs->u.r.zs_code) = 0; zs->zs_clear_flg = 1; - zs->zs_free_ent = FIRST - 1; - if ((zs->u.r.zs_code = getcode(zs)) == -1) /* O, untimely death! */ - break; + zs->zs_free_ent = FIRST; + zs->u.r.zs_oldcode = -1; + continue; } zs->u.r.zs_incode = zs->u.r.zs_code; /* Special case for KwKwK string. */ if (zs->u.r.zs_code >= zs->zs_free_ent) { + if (zs->u.r.zs_code > zs->zs_free_ent || + zs->u.r.zs_oldcode == -1) { + /* Bad stream. */ + errno = EINVAL; + return (-1); + } *zs->u.r.zs_stackp++ = zs->u.r.zs_finchar; zs->u.r.zs_code = zs->u.r.zs_oldcode; } + /* + * The above condition ensures that code < free_ent. + * The construction of tab_prefixof in turn guarantees that + * each iteration decreases code and therefore stack usage is + * bound by 1 << BITS - 256. + */ /* Generate output characters in reverse order. */ while (zs->u.r.zs_code >= 256) { @@ -302,7 +308,8 @@ middle: do { } while (zs->u.r.zs_stackp > de_stack); /* Generate the new entry. */ - if ((zs->u.r.zs_code = zs->zs_free_ent) < zs->zs_maxmaxcode) { + if ((zs->u.r.zs_code = zs->zs_free_ent) < zs->zs_maxmaxcode && + zs->u.r.zs_oldcode != -1) { tab_prefixof(zs->u.r.zs_code) = (u_short) zs->u.r.zs_oldcode; tab_suffixof(zs->u.r.zs_code) = zs->u.r.zs_finchar; zs->zs_free_ent = zs->u.r.zs_code + 1; diff --git a/usr.bin/script/script.1 b/usr.bin/script/script.1 index 3aa03e5..cd3f800 100644 --- a/usr.bin/script/script.1 +++ b/usr.bin/script/script.1 @@ -166,3 +166,12 @@ The slave terminal mode is checked for ECHO mode to check when to avoid manual echo logging. This does not work when in a raw mode where the program being run is doing manual echo. +.Pp +If the +.Nm +reads zero bytes from the terminal it switches to a mode when it probes read +only once a second until it gets some data. +This prevents the +.Nm +spinning on zero-byte reads, but might cause a 1-second delay in +processing of the user input. diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c index ad99721..ea5a1f6 100644 --- a/usr.bin/script/script.c +++ b/usr.bin/script/script.c @@ -86,6 +86,7 @@ main(int argc, char *argv[]) char ibuf[BUFSIZ]; fd_set rfd; int flushtime = 30; + int readstdin; aflg = kflg = 0; while ((ch = getopt(argc, argv, "aqkt:")) != -1) @@ -155,19 +156,21 @@ main(int argc, char *argv[]) doshell(argv); close(slave); - if (flushtime > 0) - tvp = &tv; - else - tvp = NULL; - - start = time(0); - FD_ZERO(&rfd); + start = tvec = time(0); + readstdin = 1; for (;;) { + FD_ZERO(&rfd); FD_SET(master, &rfd); - FD_SET(STDIN_FILENO, &rfd); - if (flushtime > 0) { - tv.tv_sec = flushtime; + if (readstdin) + FD_SET(STDIN_FILENO, &rfd); + if ((!readstdin && ttyflg) || flushtime > 0) { + tv.tv_sec = !readstdin && ttyflg ? 1 : + flushtime - (tvec - start); tv.tv_usec = 0; + tvp = &tv; + readstdin = 1; + } else { + tvp = NULL; } n = select(master + 1, &rfd, 0, 0, tvp); if (n < 0 && errno != EINTR) @@ -176,8 +179,13 @@ main(int argc, char *argv[]) cc = read(STDIN_FILENO, ibuf, BUFSIZ); if (cc < 0) break; - if (cc == 0) - (void)write(master, ibuf, 0); + if (cc == 0) { + if (tcgetattr(master, &stt) == 0 && + (stt.c_lflag & ICANON) != 0) { + (void)write(master, &stt.c_cc[VEOF], 1); + } + readstdin = 0; + } if (cc > 0) { (void)write(master, ibuf, cc); if (kflg && tcgetattr(master, &stt) >= 0 && diff --git a/usr.sbin/mfiutil/mfi_show.c b/usr.sbin/mfiutil/mfi_show.c index 9d9f7a1..4f83b52 100644 --- a/usr.sbin/mfiutil/mfi_show.c +++ b/usr.sbin/mfiutil/mfi_show.c @@ -141,7 +141,7 @@ show_battery(int ac, char **av) struct mfi_bbu_design_info design; struct mfi_bbu_status stat; uint8_t status; - int comma, error, fd; + int comma, error, fd, show_capacity; if (ac != 1) { warnx("show battery: extra arguments"); @@ -157,16 +157,17 @@ show_battery(int ac, char **av) if (mfi_dcmd_command(fd, MFI_DCMD_BBU_GET_CAPACITY_INFO, &cap, sizeof(cap), NULL, 0, &status) < 0) { - if (status == MFI_STAT_NO_HW_PRESENT) { - printf("mfi%d: No battery present\n", mfi_unit); - close(fd); - return (0); - } error = errno; warn("Failed to get capacity info"); close(fd); return (error); } + if (status == MFI_STAT_NO_HW_PRESENT) { + printf("mfi%d: No battery present\n", mfi_unit); + close(fd); + return (0); + } + show_capacity = (status == MFI_STAT_OK); if (mfi_dcmd_command(fd, MFI_DCMD_BBU_GET_DESIGN_INFO, &design, sizeof(design), NULL, 0, NULL) < 0) { @@ -192,10 +193,14 @@ show_battery(int ac, char **av) printf(" Model: %s\n", design.device_name); printf(" Chemistry: %s\n", design.device_chemistry); printf(" Design Capacity: %d mAh\n", design.design_capacity); - printf(" Full Charge Capacity: %d mAh\n", cap.full_charge_capacity); - printf(" Current Capacity: %d mAh\n", cap.remaining_capacity); - printf(" Charge Cycles: %d\n", cap.cycle_count); - printf(" Current Charge: %d%%\n", cap.relative_charge); + if (show_capacity) { + printf(" Full Charge Capacity: %d mAh\n", + cap.full_charge_capacity); + printf(" Current Capacity: %d mAh\n", + cap.remaining_capacity); + printf(" Charge Cycles: %d\n", cap.cycle_count); + printf(" Current Charge: %d%%\n", cap.relative_charge); + } printf(" Design Voltage: %d mV\n", design.design_voltage); printf(" Current Voltage: %d mV\n", stat.voltage); printf(" Temperature: %d C\n", stat.temperature); diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c index f73312a..b1eec7a 100644 --- a/usr.sbin/pkg_install/add/main.c +++ b/usr.sbin/pkg_install/add/main.c @@ -87,6 +87,7 @@ struct { { 800000, 800499, "/packages-8.0-release" }, { 801000, 801499, "/packages-8.1-release" }, { 802000, 802499, "/packages-8.2-release" }, + { 900000, 900499, "/packages-9.0-release" }, { 300000, 399000, "/packages-3-stable" }, { 400000, 499000, "/packages-4-stable" }, { 502100, 502128, "/packages-5-current" }, @@ -94,7 +95,8 @@ struct { { 600100, 699000, "/packages-6-stable" }, { 700100, 799000, "/packages-7-stable" }, { 800500, 899000, "/packages-8-stable" }, - { 900000, 999000, "/packages-9-current" }, + { 900500, 999000, "/packages-9-stable" }, + { 1000000, 1099000, "/packages-10-current" }, { 0, 9999999, "/packages-current" }, { 0, 0, NULL } }; |