From jhb at FreeBSD.org Sat Aug 1 01:54:44 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Sat Aug 1 01:54:57 2009 Subject: svn commit: r196009 - in stable/7/sys: compat/freebsd32 kern sys Message-ID: <200908010154.n711shIK087172@svn.freebsd.org> Author: jhb Date: Sat Aug 1 01:54:42 2009 New Revision: 196009 URL: http://svn.freebsd.org/changeset/base/196009 Log: Regen. Modified: stable/7/sys/compat/freebsd32/freebsd32_proto.h stable/7/sys/compat/freebsd32/freebsd32_syscall.h stable/7/sys/compat/freebsd32/freebsd32_syscalls.c stable/7/sys/compat/freebsd32/freebsd32_sysent.c stable/7/sys/kern/init_sysent.c stable/7/sys/kern/syscalls.c stable/7/sys/kern/systrace_args.c stable/7/sys/sys/syscall.h stable/7/sys/sys/syscall.mk stable/7/sys/sys/sysproto.h Modified: stable/7/sys/compat/freebsd32/freebsd32_proto.h ============================================================================== --- stable/7/sys/compat/freebsd32/freebsd32_proto.h Sat Aug 1 01:04:26 2009 (r196008) +++ stable/7/sys/compat/freebsd32/freebsd32_proto.h Sat Aug 1 01:54:42 2009 (r196009) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 195854 2009-07-24 19:35:06Z jhb + * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 196006 2009-07-31 20:32:55Z jhb */ #ifndef _FREEBSD32_SYSPROTO_H_ @@ -170,16 +170,16 @@ struct freebsd32_futimes_args { char fd_l_[PADL_(int)]; int fd; char fd_r_[PADR_(int)]; char tptr_l_[PADL_(struct timeval32 *)]; struct timeval32 * tptr; char tptr_r_[PADR_(struct timeval32 *)]; }; -struct freebsd32_semctl_args { +struct freebsd7_freebsd32_semctl_args { char semid_l_[PADL_(int)]; int semid; char semid_r_[PADR_(int)]; char semnum_l_[PADL_(int)]; int semnum; char semnum_r_[PADR_(int)]; char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; char arg_l_[PADL_(union semun32 *)]; union semun32 * arg; char arg_r_[PADR_(union semun32 *)]; }; -struct freebsd32_msgctl_args { +struct freebsd7_freebsd32_msgctl_args { char msqid_l_[PADL_(int)]; int msqid; char msqid_r_[PADR_(int)]; char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; - char buf_l_[PADL_(struct msqid_ds32 *)]; struct msqid_ds32 * buf; char buf_r_[PADR_(struct msqid_ds32 *)]; + char buf_l_[PADL_(struct msqid_ds32_old *)]; struct msqid_ds32_old * buf; char buf_r_[PADR_(struct msqid_ds32_old *)]; }; struct freebsd32_msgsnd_args { char msqid_l_[PADL_(int)]; int msqid; char msqid_r_[PADR_(int)]; @@ -194,10 +194,10 @@ struct freebsd32_msgrcv_args { char msgtyp_l_[PADL_(long)]; long msgtyp; char msgtyp_r_[PADR_(long)]; char msgflg_l_[PADL_(int)]; int msgflg; char msgflg_r_[PADR_(int)]; }; -struct freebsd32_shmctl_args { +struct freebsd7_freebsd32_shmctl_args { char shmid_l_[PADL_(int)]; int shmid; char shmid_r_[PADR_(int)]; char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; - char buf_l_[PADL_(struct shmid_ds *)]; struct shmid_ds * buf; char buf_r_[PADR_(struct shmid_ds *)]; + char buf_l_[PADL_(struct shmid_ds32_old *)]; struct shmid_ds32_old * buf; char buf_r_[PADR_(struct shmid_ds32_old *)]; }; struct freebsd32_clock_gettime_args { char clock_id_l_[PADL_(clockid_t)]; clockid_t clock_id; char clock_id_r_[PADR_(clockid_t)]; @@ -423,6 +423,22 @@ struct freebsd32_cpuset_setaffinity_args char cpusetsize_l_[PADL_(size_t)]; size_t cpusetsize; char cpusetsize_r_[PADR_(size_t)]; char mask_l_[PADL_(const cpuset_t *)]; const cpuset_t * mask; char mask_r_[PADR_(const cpuset_t *)]; }; +struct freebsd32_semctl_args { + char semid_l_[PADL_(int)]; int semid; char semid_r_[PADR_(int)]; + char semnum_l_[PADL_(int)]; int semnum; char semnum_r_[PADR_(int)]; + char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; + char arg_l_[PADL_(union semun32 *)]; union semun32 * arg; char arg_r_[PADR_(union semun32 *)]; +}; +struct freebsd32_msgctl_args { + char msqid_l_[PADL_(int)]; int msqid; char msqid_r_[PADR_(int)]; + char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; + char buf_l_[PADL_(struct msqid_ds32 *)]; struct msqid_ds32 * buf; char buf_r_[PADR_(struct msqid_ds32 *)]; +}; +struct freebsd32_shmctl_args { + char shmid_l_[PADL_(int)]; int shmid; char shmid_r_[PADR_(int)]; + char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; + char buf_l_[PADL_(struct shmid_ds32 *)]; struct shmid_ds32 * buf; char buf_r_[PADR_(struct shmid_ds32 *)]; +}; int freebsd32_wait4(struct thread *, struct freebsd32_wait4_args *); int freebsd32_recvmsg(struct thread *, struct freebsd32_recvmsg_args *); int freebsd32_sendmsg(struct thread *, struct freebsd32_sendmsg_args *); @@ -449,11 +465,11 @@ int freebsd32_lstat(struct thread *, str int freebsd32_getdirentries(struct thread *, struct freebsd32_getdirentries_args *); int freebsd32_sysctl(struct thread *, struct freebsd32_sysctl_args *); int freebsd32_futimes(struct thread *, struct freebsd32_futimes_args *); -int freebsd32_semctl(struct thread *, struct freebsd32_semctl_args *); -int freebsd32_msgctl(struct thread *, struct freebsd32_msgctl_args *); +int freebsd7_freebsd32_semctl(struct thread *, struct freebsd7_freebsd32_semctl_args *); +int freebsd7_freebsd32_msgctl(struct thread *, struct freebsd7_freebsd32_msgctl_args *); int freebsd32_msgsnd(struct thread *, struct freebsd32_msgsnd_args *); int freebsd32_msgrcv(struct thread *, struct freebsd32_msgrcv_args *); -int freebsd32_shmctl(struct thread *, struct freebsd32_shmctl_args *); +int freebsd7_freebsd32_shmctl(struct thread *, struct freebsd7_freebsd32_shmctl_args *); int freebsd32_clock_gettime(struct thread *, struct freebsd32_clock_gettime_args *); int freebsd32_clock_settime(struct thread *, struct freebsd32_clock_settime_args *); int freebsd32_clock_getres(struct thread *, struct freebsd32_clock_getres_args *); @@ -500,6 +516,9 @@ int freebsd32_cpuset_setid(struct thread int freebsd32_cpuset_getid(struct thread *, struct freebsd32_cpuset_getid_args *); int freebsd32_cpuset_getaffinity(struct thread *, struct freebsd32_cpuset_getaffinity_args *); int freebsd32_cpuset_setaffinity(struct thread *, struct freebsd32_cpuset_setaffinity_args *); +int freebsd32_semctl(struct thread *, struct freebsd32_semctl_args *); +int freebsd32_msgctl(struct thread *, struct freebsd32_msgctl_args *); +int freebsd32_shmctl(struct thread *, struct freebsd32_shmctl_args *); #ifdef COMPAT_43 @@ -689,11 +708,11 @@ int freebsd6_freebsd32_ftruncate(struct #define FREEBSD32_SYS_AUE_freebsd6_freebsd32_ftruncate AUE_FTRUNCATE #define FREEBSD32_SYS_AUE_freebsd32_sysctl AUE_SYSCTL #define FREEBSD32_SYS_AUE_freebsd32_futimes AUE_FUTIMES -#define FREEBSD32_SYS_AUE_freebsd32_semctl AUE_SEMCTL -#define FREEBSD32_SYS_AUE_freebsd32_msgctl AUE_MSGCTL +#define FREEBSD32_SYS_AUE_freebsd7_freebsd32_semctl AUE_SEMCTL +#define FREEBSD32_SYS_AUE_freebsd7_freebsd32_msgctl AUE_MSGCTL #define FREEBSD32_SYS_AUE_freebsd32_msgsnd AUE_MSGSND #define FREEBSD32_SYS_AUE_freebsd32_msgrcv AUE_MSGRCV -#define FREEBSD32_SYS_AUE_freebsd32_shmctl AUE_SHMCTL +#define FREEBSD32_SYS_AUE_freebsd7_freebsd32_shmctl AUE_SHMCTL #define FREEBSD32_SYS_AUE_freebsd32_clock_gettime AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_clock_settime AUE_CLOCK_SETTIME #define FREEBSD32_SYS_AUE_freebsd32_clock_getres AUE_NULL @@ -744,6 +763,9 @@ int freebsd6_freebsd32_ftruncate(struct #define FREEBSD32_SYS_AUE_freebsd32_cpuset_getid AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_cpuset_getaffinity AUE_NULL #define FREEBSD32_SYS_AUE_freebsd32_cpuset_setaffinity AUE_NULL +#define FREEBSD32_SYS_AUE_freebsd32_semctl AUE_SEMCTL +#define FREEBSD32_SYS_AUE_freebsd32_msgctl AUE_MSGCTL +#define FREEBSD32_SYS_AUE_freebsd32_shmctl AUE_SHMCTL #undef PAD_ #undef PADL_ Modified: stable/7/sys/compat/freebsd32/freebsd32_syscall.h ============================================================================== --- stable/7/sys/compat/freebsd32/freebsd32_syscall.h Sat Aug 1 01:04:26 2009 (r196008) +++ stable/7/sys/compat/freebsd32/freebsd32_syscall.h Sat Aug 1 01:54:42 2009 (r196009) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 195854 2009-07-24 19:35:06Z jhb + * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 196006 2009-07-31 20:32:55Z jhb */ #define FREEBSD32_SYS_syscall 0 @@ -190,15 +190,15 @@ #define FREEBSD32_SYS_freebsd32_futimes 206 #define FREEBSD32_SYS_getpgid 207 #define FREEBSD32_SYS_poll 209 -#define FREEBSD32_SYS_freebsd32_semctl 220 +#define FREEBSD32_SYS_freebsd7_freebsd32_semctl 220 #define FREEBSD32_SYS_semget 221 #define FREEBSD32_SYS_semop 222 -#define FREEBSD32_SYS_freebsd32_msgctl 224 +#define FREEBSD32_SYS_freebsd7_freebsd32_msgctl 224 #define FREEBSD32_SYS_msgget 225 #define FREEBSD32_SYS_freebsd32_msgsnd 226 #define FREEBSD32_SYS_freebsd32_msgrcv 227 #define FREEBSD32_SYS_shmat 228 -#define FREEBSD32_SYS_freebsd32_shmctl 229 +#define FREEBSD32_SYS_freebsd7_freebsd32_shmctl 229 #define FREEBSD32_SYS_shmdt 230 #define FREEBSD32_SYS_shmget 231 #define FREEBSD32_SYS_freebsd32_clock_gettime 232 @@ -362,4 +362,7 @@ #define FREEBSD32_SYS_freebsd32_cpuset_getaffinity 487 #define FREEBSD32_SYS_freebsd32_cpuset_setaffinity 488 #define FREEBSD32_SYS_closefrom 509 -#define FREEBSD32_SYS_MAXSYSCALL 510 +#define FREEBSD32_SYS_freebsd32_semctl 510 +#define FREEBSD32_SYS_freebsd32_msgctl 511 +#define FREEBSD32_SYS_freebsd32_shmctl 512 +#define FREEBSD32_SYS_MAXSYSCALL 513 Modified: stable/7/sys/compat/freebsd32/freebsd32_syscalls.c ============================================================================== --- stable/7/sys/compat/freebsd32/freebsd32_syscalls.c Sat Aug 1 01:04:26 2009 (r196008) +++ stable/7/sys/compat/freebsd32/freebsd32_syscalls.c Sat Aug 1 01:54:42 2009 (r196009) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 195854 2009-07-24 19:35:06Z jhb + * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 196006 2009-07-31 20:32:55Z jhb */ const char *freebsd32_syscallnames[] = { @@ -227,16 +227,16 @@ const char *freebsd32_syscallnames[] = { "lkmnosys", /* 217 = lkmnosys */ "lkmnosys", /* 218 = lkmnosys */ "lkmnosys", /* 219 = lkmnosys */ - "freebsd32_semctl", /* 220 = freebsd32_semctl */ + "freebsd7_freebsd32_semctl", /* 220 = freebsd7_freebsd32_semctl */ "semget", /* 221 = semget */ "semop", /* 222 = semop */ "#223", /* 223 = semconfig */ - "freebsd32_msgctl", /* 224 = freebsd32_msgctl */ + "freebsd7_freebsd32_msgctl", /* 224 = freebsd7_freebsd32_msgctl */ "msgget", /* 225 = msgget */ "freebsd32_msgsnd", /* 226 = freebsd32_msgsnd */ "freebsd32_msgrcv", /* 227 = freebsd32_msgrcv */ "shmat", /* 228 = shmat */ - "freebsd32_shmctl", /* 229 = freebsd32_shmctl */ + "freebsd7_freebsd32_shmctl", /* 229 = freebsd7_freebsd32_shmctl */ "shmdt", /* 230 = shmdt */ "shmget", /* 231 = shmget */ "freebsd32_clock_gettime", /* 232 = freebsd32_clock_gettime */ @@ -517,4 +517,7 @@ const char *freebsd32_syscallnames[] = { "#507", /* 507 = freebsd32_jail_set */ "#508", /* 508 = jail_remove */ "closefrom", /* 509 = closefrom */ + "freebsd32_semctl", /* 510 = freebsd32_semctl */ + "freebsd32_msgctl", /* 511 = freebsd32_msgctl */ + "freebsd32_shmctl", /* 512 = freebsd32_shmctl */ }; Modified: stable/7/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- stable/7/sys/compat/freebsd32/freebsd32_sysent.c Sat Aug 1 01:04:26 2009 (r196008) +++ stable/7/sys/compat/freebsd32/freebsd32_sysent.c Sat Aug 1 01:54:42 2009 (r196009) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 195854 2009-07-24 19:35:06Z jhb + * created from FreeBSD: stable/7/sys/compat/freebsd32/syscalls.master 196006 2009-07-31 20:32:55Z jhb */ #include "opt_compat.h" @@ -258,16 +258,16 @@ struct sysent freebsd32_sysent[] = { { AS(nosys_args), (sy_call_t *)lkmnosys, AUE_NULL, NULL, 0, 0 }, /* 217 = lkmnosys */ { AS(nosys_args), (sy_call_t *)lkmnosys, AUE_NULL, NULL, 0, 0 }, /* 218 = lkmnosys */ { AS(nosys_args), (sy_call_t *)lkmnosys, AUE_NULL, NULL, 0, 0 }, /* 219 = lkmnosys */ - { AS(freebsd32_semctl_args), (sy_call_t *)freebsd32_semctl, AUE_SEMCTL, NULL, 0, 0 }, /* 220 = freebsd32_semctl */ + { AS(freebsd7_freebsd32_semctl_args), (sy_call_t *)freebsd7_freebsd32_semctl, AUE_SEMCTL, NULL, 0, 0 }, /* 220 = freebsd7_freebsd32_semctl */ { AS(semget_args), (sy_call_t *)semget, AUE_SEMGET, NULL, 0, 0 }, /* 221 = semget */ { AS(semop_args), (sy_call_t *)semop, AUE_SEMOP, NULL, 0, 0 }, /* 222 = semop */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 223 = semconfig */ - { AS(freebsd32_msgctl_args), (sy_call_t *)freebsd32_msgctl, AUE_MSGCTL, NULL, 0, 0 }, /* 224 = freebsd32_msgctl */ + { AS(freebsd7_freebsd32_msgctl_args), (sy_call_t *)freebsd7_freebsd32_msgctl, AUE_MSGCTL, NULL, 0, 0 }, /* 224 = freebsd7_freebsd32_msgctl */ { AS(msgget_args), (sy_call_t *)msgget, AUE_MSGGET, NULL, 0, 0 }, /* 225 = msgget */ { AS(freebsd32_msgsnd_args), (sy_call_t *)freebsd32_msgsnd, AUE_MSGSND, NULL, 0, 0 }, /* 226 = freebsd32_msgsnd */ { AS(freebsd32_msgrcv_args), (sy_call_t *)freebsd32_msgrcv, AUE_MSGRCV, NULL, 0, 0 }, /* 227 = freebsd32_msgrcv */ { AS(shmat_args), (sy_call_t *)shmat, AUE_SHMAT, NULL, 0, 0 }, /* 228 = shmat */ - { AS(freebsd32_shmctl_args), (sy_call_t *)freebsd32_shmctl, AUE_SHMCTL, NULL, 0, 0 }, /* 229 = freebsd32_shmctl */ + { AS(freebsd7_freebsd32_shmctl_args), (sy_call_t *)freebsd7_freebsd32_shmctl, AUE_SHMCTL, NULL, 0, 0 }, /* 229 = freebsd7_freebsd32_shmctl */ { AS(shmdt_args), (sy_call_t *)shmdt, AUE_SHMDT, NULL, 0, 0 }, /* 230 = shmdt */ { AS(shmget_args), (sy_call_t *)shmget, AUE_SHMGET, NULL, 0, 0 }, /* 231 = shmget */ { AS(freebsd32_clock_gettime_args), (sy_call_t *)freebsd32_clock_gettime, AUE_NULL, NULL, 0, 0 }, /* 232 = freebsd32_clock_gettime */ @@ -548,4 +548,7 @@ struct sysent freebsd32_sysent[] = { { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 507 = freebsd32_jail_set */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 508 = jail_remove */ { AS(closefrom_args), (sy_call_t *)closefrom, AUE_CLOSEFROM, NULL, 0, 0 }, /* 509 = closefrom */ + { AS(freebsd32_semctl_args), (sy_call_t *)freebsd32_semctl, AUE_SEMCTL, NULL, 0, 0 }, /* 510 = freebsd32_semctl */ + { AS(freebsd32_msgctl_args), (sy_call_t *)freebsd32_msgctl, AUE_MSGCTL, NULL, 0, 0 }, /* 511 = freebsd32_msgctl */ + { AS(freebsd32_shmctl_args), (sy_call_t *)freebsd32_shmctl, AUE_SHMCTL, NULL, 0, 0 }, /* 512 = freebsd32_shmctl */ }; Modified: stable/7/sys/kern/init_sysent.c ============================================================================== --- stable/7/sys/kern/init_sysent.c Sat Aug 1 01:04:26 2009 (r196008) +++ stable/7/sys/kern/init_sysent.c Sat Aug 1 01:54:42 2009 (r196009) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/kern/syscalls.master 195854 2009-07-24 19:35:06Z jhb + * created from FreeBSD: stable/7/sys/kern/syscalls.master 196006 2009-07-31 20:32:55Z jhb */ #include "opt_compat.h" @@ -248,16 +248,16 @@ struct sysent sysent[] = { { AS(nosys_args), (sy_call_t *)lkmnosys, AUE_NULL, NULL, 0, 0 }, /* 217 = lkmnosys */ { AS(nosys_args), (sy_call_t *)lkmnosys, AUE_NULL, NULL, 0, 0 }, /* 218 = lkmnosys */ { AS(nosys_args), (sy_call_t *)lkmnosys, AUE_NULL, NULL, 0, 0 }, /* 219 = lkmnosys */ - { AS(__semctl_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 220 = __semctl */ + { AS(freebsd7___semctl_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 220 = freebsd7___semctl */ { AS(semget_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 221 = semget */ { AS(semop_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 222 = semop */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 223 = semconfig */ - { AS(msgctl_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 224 = msgctl */ + { AS(freebsd7_msgctl_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 224 = freebsd7_msgctl */ { AS(msgget_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 225 = msgget */ { AS(msgsnd_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 226 = msgsnd */ { AS(msgrcv_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 227 = msgrcv */ { AS(shmat_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 228 = shmat */ - { AS(shmctl_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 229 = shmctl */ + { AS(freebsd7_shmctl_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 229 = freebsd7_shmctl */ { AS(shmdt_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 230 = shmdt */ { AS(shmget_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 231 = shmget */ { AS(clock_gettime_args), (sy_call_t *)clock_gettime, AUE_NULL, NULL, 0, 0 }, /* 232 = clock_gettime */ @@ -538,4 +538,7 @@ struct sysent sysent[] = { { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 507 = jail_set */ { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0 }, /* 508 = jail_remove */ { AS(closefrom_args), (sy_call_t *)closefrom, AUE_CLOSEFROM, NULL, 0, 0 }, /* 509 = closefrom */ + { AS(__semctl_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 510 = __semctl */ + { AS(msgctl_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 511 = msgctl */ + { AS(shmctl_args), (sy_call_t *)lkmressys, AUE_NULL, NULL, 0, 0 }, /* 512 = shmctl */ }; Modified: stable/7/sys/kern/syscalls.c ============================================================================== --- stable/7/sys/kern/syscalls.c Sat Aug 1 01:04:26 2009 (r196008) +++ stable/7/sys/kern/syscalls.c Sat Aug 1 01:54:42 2009 (r196009) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/kern/syscalls.master 195854 2009-07-24 19:35:06Z jhb + * created from FreeBSD: stable/7/sys/kern/syscalls.master 196006 2009-07-31 20:32:55Z jhb */ const char *syscallnames[] = { @@ -227,16 +227,16 @@ const char *syscallnames[] = { "lkmnosys", /* 217 = lkmnosys */ "lkmnosys", /* 218 = lkmnosys */ "lkmnosys", /* 219 = lkmnosys */ - "__semctl", /* 220 = __semctl */ + "freebsd7___semctl", /* 220 = freebsd7___semctl */ "semget", /* 221 = semget */ "semop", /* 222 = semop */ "#223", /* 223 = semconfig */ - "msgctl", /* 224 = msgctl */ + "freebsd7_msgctl", /* 224 = freebsd7_msgctl */ "msgget", /* 225 = msgget */ "msgsnd", /* 226 = msgsnd */ "msgrcv", /* 227 = msgrcv */ "shmat", /* 228 = shmat */ - "shmctl", /* 229 = shmctl */ + "freebsd7_shmctl", /* 229 = freebsd7_shmctl */ "shmdt", /* 230 = shmdt */ "shmget", /* 231 = shmget */ "clock_gettime", /* 232 = clock_gettime */ @@ -517,4 +517,7 @@ const char *syscallnames[] = { "#507", /* 507 = jail_set */ "#508", /* 508 = jail_remove */ "closefrom", /* 509 = closefrom */ + "__semctl", /* 510 = __semctl */ + "msgctl", /* 511 = msgctl */ + "shmctl", /* 512 = shmctl */ }; Modified: stable/7/sys/kern/systrace_args.c ============================================================================== --- stable/7/sys/kern/systrace_args.c Sat Aug 1 01:04:26 2009 (r196008) +++ stable/7/sys/kern/systrace_args.c Sat Aug 1 01:54:42 2009 (r196009) @@ -1215,13 +1215,13 @@ systrace_args(int sysnum, void *params, *n_args = 0; break; } - /* __semctl */ + /* freebsd7___semctl */ case 220: { - struct __semctl_args *p = params; + struct freebsd7___semctl_args *p = params; iarg[0] = p->semid; /* int */ iarg[1] = p->semnum; /* int */ iarg[2] = p->cmd; /* int */ - uarg[3] = (intptr_t) p->arg; /* union semun * */ + uarg[3] = (intptr_t) p->arg; /* union semun_old * */ *n_args = 4; break; } @@ -1243,12 +1243,12 @@ systrace_args(int sysnum, void *params, *n_args = 3; break; } - /* msgctl */ + /* freebsd7_msgctl */ case 224: { - struct msgctl_args *p = params; + struct freebsd7_msgctl_args *p = params; iarg[0] = p->msqid; /* int */ iarg[1] = p->cmd; /* int */ - uarg[2] = (intptr_t) p->buf; /* struct msqid_ds * */ + uarg[2] = (intptr_t) p->buf; /* struct msqid_ds_old * */ *n_args = 3; break; } @@ -1290,12 +1290,12 @@ systrace_args(int sysnum, void *params, *n_args = 3; break; } - /* shmctl */ + /* freebsd7_shmctl */ case 229: { - struct shmctl_args *p = params; + struct freebsd7_shmctl_args *p = params; iarg[0] = p->shmid; /* int */ iarg[1] = p->cmd; /* int */ - uarg[2] = (intptr_t) p->buf; /* struct shmid_ds * */ + uarg[2] = (intptr_t) p->buf; /* struct shmid_ds_old * */ *n_args = 3; break; } @@ -2930,6 +2930,34 @@ systrace_args(int sysnum, void *params, *n_args = 1; break; } + /* __semctl */ + case 510: { + struct __semctl_args *p = params; + iarg[0] = p->semid; /* int */ + iarg[1] = p->semnum; /* int */ + iarg[2] = p->cmd; /* int */ + uarg[3] = (intptr_t) p->arg; /* union semun * */ + *n_args = 4; + break; + } + /* msgctl */ + case 511: { + struct msgctl_args *p = params; + iarg[0] = p->msqid; /* int */ + iarg[1] = p->cmd; /* int */ + uarg[2] = (intptr_t) p->buf; /* struct msqid_ds * */ + *n_args = 3; + break; + } + /* shmctl */ + case 512: { + struct shmctl_args *p = params; + iarg[0] = p->shmid; /* int */ + iarg[1] = p->cmd; /* int */ + uarg[2] = (intptr_t) p->buf; /* struct shmid_ds * */ + *n_args = 3; + break; + } default: *n_args = 0; break; @@ -4855,7 +4883,7 @@ systrace_setargdesc(int sysnum, int ndx, /* lkmnosys */ case 219: break; - /* __semctl */ + /* freebsd7___semctl */ case 220: switch(ndx) { case 0: @@ -4868,7 +4896,7 @@ systrace_setargdesc(int sysnum, int ndx, p = "int"; break; case 3: - p = "union semun *"; + p = "union semun_old *"; break; default: break; @@ -4906,7 +4934,7 @@ systrace_setargdesc(int sysnum, int ndx, break; }; break; - /* msgctl */ + /* freebsd7_msgctl */ case 224: switch(ndx) { case 0: @@ -4916,7 +4944,7 @@ systrace_setargdesc(int sysnum, int ndx, p = "int"; break; case 2: - p = "struct msqid_ds *"; + p = "struct msqid_ds_old *"; break; default: break; @@ -4992,7 +5020,7 @@ systrace_setargdesc(int sysnum, int ndx, break; }; break; - /* shmctl */ + /* freebsd7_shmctl */ case 229: switch(ndx) { case 0: @@ -5002,7 +5030,7 @@ systrace_setargdesc(int sysnum, int ndx, p = "int"; break; case 2: - p = "struct shmid_ds *"; + p = "struct shmid_ds_old *"; break; default: break; @@ -7739,6 +7767,57 @@ systrace_setargdesc(int sysnum, int ndx, break; }; break; + /* __semctl */ + case 510: + switch(ndx) { + case 0: + p = "int"; + break; + case 1: + p = "int"; + break; + case 2: + p = "int"; + break; + case 3: + p = "union semun *"; + break; + default: + break; + }; + break; + /* msgctl */ + case 511: + switch(ndx) { + case 0: + p = "int"; + break; + case 1: + p = "int"; + break; + case 2: + p = "struct msqid_ds *"; + break; + default: + break; + }; + break; + /* shmctl */ + case 512: + switch(ndx) { + case 0: + p = "int"; + break; + case 1: + p = "int"; + break; + case 2: + p = "struct shmid_ds *"; + break; + default: + break; + }; + break; default: break; }; Modified: stable/7/sys/sys/syscall.h ============================================================================== --- stable/7/sys/sys/syscall.h Sat Aug 1 01:04:26 2009 (r196008) +++ stable/7/sys/sys/syscall.h Sat Aug 1 01:54:42 2009 (r196009) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/kern/syscalls.master 195854 2009-07-24 19:35:06Z jhb + * created from FreeBSD: stable/7/sys/kern/syscalls.master 196006 2009-07-31 20:32:55Z jhb */ #define SYS_syscall 0 @@ -196,15 +196,15 @@ #define SYS_futimes 206 #define SYS_getpgid 207 #define SYS_poll 209 -#define SYS___semctl 220 +#define SYS_freebsd7___semctl 220 #define SYS_semget 221 #define SYS_semop 222 -#define SYS_msgctl 224 +#define SYS_freebsd7_msgctl 224 #define SYS_msgget 225 #define SYS_msgsnd 226 #define SYS_msgrcv 227 #define SYS_shmat 228 -#define SYS_shmctl 229 +#define SYS_freebsd7_shmctl 229 #define SYS_shmdt 230 #define SYS_shmget 231 #define SYS_clock_gettime 232 @@ -408,4 +408,7 @@ #define SYS_cpuset_getaffinity 487 #define SYS_cpuset_setaffinity 488 #define SYS_closefrom 509 -#define SYS_MAXSYSCALL 510 +#define SYS___semctl 510 +#define SYS_msgctl 511 +#define SYS_shmctl 512 +#define SYS_MAXSYSCALL 513 Modified: stable/7/sys/sys/syscall.mk ============================================================================== --- stable/7/sys/sys/syscall.mk Sat Aug 1 01:04:26 2009 (r196008) +++ stable/7/sys/sys/syscall.mk Sat Aug 1 01:54:42 2009 (r196009) @@ -1,7 +1,7 @@ # FreeBSD system call names. # DO NOT EDIT-- this file is automatically generated. # $FreeBSD$ -# created from FreeBSD: stable/7/sys/kern/syscalls.master 195854 2009-07-24 19:35:06Z jhb +# created from FreeBSD: stable/7/sys/kern/syscalls.master 196006 2009-07-31 20:32:55Z jhb MIASM = \ syscall.o \ exit.o \ @@ -148,15 +148,15 @@ MIASM = \ futimes.o \ getpgid.o \ poll.o \ - __semctl.o \ + freebsd7___semctl.o \ semget.o \ semop.o \ - msgctl.o \ + freebsd7_msgctl.o \ msgget.o \ msgsnd.o \ msgrcv.o \ shmat.o \ - shmctl.o \ + freebsd7_shmctl.o \ shmdt.o \ shmget.o \ clock_gettime.o \ @@ -356,4 +356,7 @@ MIASM = \ cpuset_getid.o \ cpuset_getaffinity.o \ cpuset_setaffinity.o \ - closefrom.o + closefrom.o \ + __semctl.o \ + msgctl.o \ + shmctl.o Modified: stable/7/sys/sys/sysproto.h ============================================================================== --- stable/7/sys/sys/sysproto.h Sat Aug 1 01:04:26 2009 (r196008) +++ stable/7/sys/sys/sysproto.h Sat Aug 1 01:54:42 2009 (r196009) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/7/sys/kern/syscalls.master 195854 2009-07-24 19:35:06Z jhb + * created from FreeBSD: stable/7/sys/kern/syscalls.master 196006 2009-07-31 20:32:55Z jhb */ #ifndef _SYS_SYSPROTO_H_ @@ -660,11 +660,11 @@ struct poll_args { char nfds_l_[PADL_(u_int)]; u_int nfds; char nfds_r_[PADR_(u_int)]; char timeout_l_[PADL_(int)]; int timeout; char timeout_r_[PADR_(int)]; }; -struct __semctl_args { +struct freebsd7___semctl_args { char semid_l_[PADL_(int)]; int semid; char semid_r_[PADR_(int)]; char semnum_l_[PADL_(int)]; int semnum; char semnum_r_[PADR_(int)]; char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; - char arg_l_[PADL_(union semun *)]; union semun * arg; char arg_r_[PADR_(union semun *)]; + char arg_l_[PADL_(union semun_old *)]; union semun_old * arg; char arg_r_[PADR_(union semun_old *)]; }; struct semget_args { char key_l_[PADL_(key_t)]; key_t key; char key_r_[PADR_(key_t)]; @@ -676,10 +676,10 @@ struct semop_args { char sops_l_[PADL_(struct sembuf *)]; struct sembuf * sops; char sops_r_[PADR_(struct sembuf *)]; char nsops_l_[PADL_(size_t)]; size_t nsops; char nsops_r_[PADR_(size_t)]; }; -struct msgctl_args { +struct freebsd7_msgctl_args { char msqid_l_[PADL_(int)]; int msqid; char msqid_r_[PADR_(int)]; char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; - char buf_l_[PADL_(struct msqid_ds *)]; struct msqid_ds * buf; char buf_r_[PADR_(struct msqid_ds *)]; + char buf_l_[PADL_(struct msqid_ds_old *)]; struct msqid_ds_old * buf; char buf_r_[PADR_(struct msqid_ds_old *)]; }; struct msgget_args { char key_l_[PADL_(key_t)]; key_t key; char key_r_[PADR_(key_t)]; @@ -703,10 +703,10 @@ struct shmat_args { char shmaddr_l_[PADL_(const void *)]; const void * shmaddr; char shmaddr_r_[PADR_(const void *)]; char shmflg_l_[PADL_(int)]; int shmflg; char shmflg_r_[PADR_(int)]; }; -struct shmctl_args { +struct freebsd7_shmctl_args { char shmid_l_[PADL_(int)]; int shmid; char shmid_r_[PADR_(int)]; char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; - char buf_l_[PADL_(struct shmid_ds *)]; struct shmid_ds * buf; char buf_r_[PADR_(struct shmid_ds *)]; + char buf_l_[PADL_(struct shmid_ds_old *)]; struct shmid_ds_old * buf; char buf_r_[PADR_(struct shmid_ds_old *)]; }; struct shmdt_args { char shmaddr_l_[PADL_(const void *)]; const void * shmaddr; char shmaddr_r_[PADR_(const void *)]; @@ -1557,6 +1557,22 @@ struct cpuset_setaffinity_args { struct closefrom_args { char lowfd_l_[PADL_(int)]; int lowfd; char lowfd_r_[PADR_(int)]; }; +struct __semctl_args { + char semid_l_[PADL_(int)]; int semid; char semid_r_[PADR_(int)]; + char semnum_l_[PADL_(int)]; int semnum; char semnum_r_[PADR_(int)]; + char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; + char arg_l_[PADL_(union semun *)]; union semun * arg; char arg_r_[PADR_(union semun *)]; +}; +struct msgctl_args { + char msqid_l_[PADL_(int)]; int msqid; char msqid_r_[PADR_(int)]; + char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; + char buf_l_[PADL_(struct msqid_ds *)]; struct msqid_ds * buf; char buf_r_[PADR_(struct msqid_ds *)]; +}; +struct shmctl_args { + char shmid_l_[PADL_(int)]; int shmid; char shmid_r_[PADR_(int)]; + char cmd_l_[PADL_(int)]; int cmd; char cmd_r_[PADR_(int)]; + char buf_l_[PADL_(struct shmid_ds *)]; struct shmid_ds * buf; char buf_r_[PADR_(struct shmid_ds *)]; +}; int nosys(struct thread *, struct nosys_args *); void sys_exit(struct thread *, struct sys_exit_args *); int fork(struct thread *, struct fork_args *); @@ -1698,15 +1714,15 @@ int undelete(struct thread *, struct und int futimes(struct thread *, struct futimes_args *); int getpgid(struct thread *, struct getpgid_args *); int poll(struct thread *, struct poll_args *); -int __semctl(struct thread *, struct __semctl_args *); +int freebsd7___semctl(struct thread *, struct freebsd7___semctl_args *); int semget(struct thread *, struct semget_args *); int semop(struct thread *, struct semop_args *); -int msgctl(struct thread *, struct msgctl_args *); +int freebsd7_msgctl(struct thread *, struct freebsd7_msgctl_args *); int msgget(struct thread *, struct msgget_args *); int msgsnd(struct thread *, struct msgsnd_args *); int msgrcv(struct thread *, struct msgrcv_args *); int shmat(struct thread *, struct shmat_args *); -int shmctl(struct thread *, struct shmctl_args *); +int freebsd7_shmctl(struct thread *, struct freebsd7_shmctl_args *); int shmdt(struct thread *, struct shmdt_args *); int shmget(struct thread *, struct shmget_args *); int clock_gettime(struct thread *, struct clock_gettime_args *); @@ -1901,6 +1917,9 @@ int cpuset_getid(struct thread *, struct int cpuset_getaffinity(struct thread *, struct cpuset_getaffinity_args *); int cpuset_setaffinity(struct thread *, struct cpuset_setaffinity_args *); int closefrom(struct thread *, struct closefrom_args *); +int __semctl(struct thread *, struct __semctl_args *); +int msgctl(struct thread *, struct msgctl_args *); +int shmctl(struct thread *, struct shmctl_args *); #ifdef COMPAT_43 @@ -2307,15 +2326,15 @@ int freebsd4_sigreturn(struct thread *, #define SYS_AUE_futimes AUE_FUTIMES #define SYS_AUE_getpgid AUE_GETPGID #define SYS_AUE_poll AUE_POLL -#define SYS_AUE___semctl AUE_SEMCTL +#define SYS_AUE_freebsd7___semctl AUE_SEMCTL #define SYS_AUE_semget AUE_SEMGET #define SYS_AUE_semop AUE_SEMOP -#define SYS_AUE_msgctl AUE_MSGCTL +#define SYS_AUE_freebsd7_msgctl AUE_MSGCTL #define SYS_AUE_msgget AUE_MSGGET #define SYS_AUE_msgsnd AUE_MSGSND #define SYS_AUE_msgrcv AUE_MSGRCV #define SYS_AUE_shmat AUE_SHMAT -#define SYS_AUE_shmctl AUE_SHMCTL +#define SYS_AUE_freebsd7_shmctl AUE_SHMCTL #define SYS_AUE_shmdt AUE_SHMDT #define SYS_AUE_shmget AUE_SHMGET #define SYS_AUE_clock_gettime AUE_NULL @@ -2514,6 +2533,9 @@ int freebsd4_sigreturn(struct thread *, #define SYS_AUE_cpuset_getaffinity AUE_NULL #define SYS_AUE_cpuset_setaffinity AUE_NULL #define SYS_AUE_closefrom AUE_CLOSEFROM +#define SYS_AUE___semctl AUE_SEMCTL +#define SYS_AUE_msgctl AUE_MSGCTL +#define SYS_AUE_shmctl AUE_SHMCTL #undef PAD_ #undef PADL_ From julian at FreeBSD.org Sat Aug 1 07:09:52 2009 From: julian at FreeBSD.org (Julian Elischer) Date: Sat Aug 1 07:10:08 2009 Subject: svn commit: r196010 - in stable/7/sys: . contrib/pf kern netinet Message-ID: <200908010709.n7179p7Y094603@svn.freebsd.org> Author: julian Date: Sat Aug 1 07:09:50 2009 New Revision: 196010 URL: http://svn.freebsd.org/changeset/base/196010 Log: MFC #195922 Fix accept on sockets using multiple routing tables Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/kern/uipc_socket.c stable/7/sys/netinet/tcp_input.c stable/7/sys/netinet/tcp_syncache.c Modified: stable/7/sys/kern/uipc_socket.c ============================================================================== --- stable/7/sys/kern/uipc_socket.c Sat Aug 1 01:54:42 2009 (r196009) +++ stable/7/sys/kern/uipc_socket.c Sat Aug 1 07:09:50 2009 (r196010) @@ -431,6 +431,7 @@ sonewconn(struct socket *head, int conns so->so_options = head->so_options &~ SO_ACCEPTCONN; so->so_linger = head->so_linger; so->so_state = head->so_state | SS_NOFDREF; + so->so_fibnum = head->so_fibnum; so->so_proto = head->so_proto; so->so_cred = crhold(head->so_cred); #ifdef MAC Modified: stable/7/sys/netinet/tcp_input.c ============================================================================== --- stable/7/sys/netinet/tcp_input.c Sat Aug 1 01:54:42 2009 (r196009) +++ stable/7/sys/netinet/tcp_input.c Sat Aug 1 07:09:50 2009 (r196010) @@ -577,6 +577,7 @@ findpcb: } inc.inc_fport = th->th_sport; inc.inc_lport = th->th_dport; + inc.inc_fibnum = so->so_fibnum; /* * Check for an existing connection attempt in syncache if Modified: stable/7/sys/netinet/tcp_syncache.c ============================================================================== --- stable/7/sys/netinet/tcp_syncache.c Sat Aug 1 01:54:42 2009 (r196009) +++ stable/7/sys/netinet/tcp_syncache.c Sat Aug 1 07:09:50 2009 (r196010) @@ -678,8 +678,7 @@ syncache_socket(struct syncache *sc, str #endif inp = sotoinpcb(so); - inp->inp_inc.inc_fibnum = sc->sc_inc.inc_fibnum; - so->so_fibnum = sc->sc_inc.inc_fibnum; + inp->inp_inc.inc_fibnum = so->so_fibnum; INP_WLOCK(inp); /* Insert new socket into PCB hash list. */ @@ -1173,8 +1172,6 @@ _syncache_add(struct in_conninfo *inc, s sc->sc_cred = cred; cred = NULL; sc->sc_ipopts = ipopts; - /* XXX-BZ this fib assignment is just useless. */ - sc->sc_inc.inc_fibnum = inp->inp_inc.inc_fibnum; bcopy(inc, &sc->sc_inc, sizeof(struct in_conninfo)); #ifdef INET6 if (!(inc->inc_flags & INC_ISIPV6)) @@ -1438,6 +1435,7 @@ syncache_respond(struct syncache *sc) } else optlen = 0; + M_SETFIB(m, sc->sc_inc.inc_fibnum); #ifdef INET6 if (sc->sc_inc.inc_flags & INC_ISIPV6) { th->th_sum = 0; From jhb at FreeBSD.org Sat Aug 1 11:40:48 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Sat Aug 1 11:40:59 2009 Subject: svn commit: r196013 - stable/7/sys/kern Message-ID: <200908011140.n71Beklu079623@svn.freebsd.org> Author: jhb Date: Sat Aug 1 11:40:46 2009 New Revision: 196013 URL: http://svn.freebsd.org/changeset/base/196013 Log: Fix compile of oshmctl() with MAC. Pointy hat to: jhb Modified: stable/7/sys/kern/sysv_shm.c Modified: stable/7/sys/kern/sysv_shm.c ============================================================================== --- stable/7/sys/kern/sysv_shm.c Sat Aug 1 09:54:52 2009 (r196012) +++ stable/7/sys/kern/sysv_shm.c Sat Aug 1 11:40:46 2009 (r196013) @@ -911,7 +911,7 @@ oshmctl(struct thread *td, struct oshmct if (error) goto done2; #ifdef MAC - error = mac_sysvshm_check_shmctl(td->td_ucred, shmseg, uap->cmd); + error = mac_check_sysv_shmctl(td->td_ucred, shmseg, uap->cmd); if (error != 0) goto done2; #endif From delphij at FreeBSD.org Sun Aug 2 10:48:27 2009 From: delphij at FreeBSD.org (Xin LI) Date: Sun Aug 2 10:48:44 2009 Subject: svn commit: r196032 - in stable/7/sys: . contrib/pf dev/mpt Message-ID: <200908021048.n72AmPJh012657@svn.freebsd.org> Author: delphij Date: Sun Aug 2 10:48:25 2009 New Revision: 196032 URL: http://svn.freebsd.org/changeset/base/196032 Log: MFC r195275: Use MPT_MAX_LUNS as maximium number of LUNs, not 7, for SAS and FC cases. This matches Linux driver behavior (except SPI case). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/mpt/mpt_cam.c Modified: stable/7/sys/dev/mpt/mpt_cam.c ============================================================================== --- stable/7/sys/dev/mpt/mpt_cam.c Sun Aug 2 10:27:54 2009 (r196031) +++ stable/7/sys/dev/mpt/mpt_cam.c Sun Aug 2 10:48:25 2009 (r196032) @@ -3605,7 +3605,10 @@ mpt_action(struct cam_sim *sim, union cc if (mpt->is_spi && cpi->max_target > 15) { cpi->max_target = 15; } - cpi->max_lun = 7; + if (mpt->is_spi) + cpi->max_lun = 7; + else + cpi->max_lun = MPT_MAX_LUNS; cpi->initiator_id = mpt->mpt_ini_id; cpi->bus_id = cam_sim_bus(sim); From brian at FreeBSD.org Mon Aug 3 09:43:07 2009 From: brian at FreeBSD.org (Brian Somers) Date: Mon Aug 3 09:43:23 2009 Subject: svn commit: r196048 - stable/7/usr.sbin/ppp Message-ID: <200908030943.n739h6cF043439@svn.freebsd.org> Author: brian Date: Mon Aug 3 09:43:06 2009 New Revision: 196048 URL: http://svn.freebsd.org/changeset/base/196048 Log: MFC: Add a missing phrase. Submitted by: Jason McIntyre jmc at kerhand dot co dot uk Obtained from: OpenBSD Modified: stable/7/usr.sbin/ppp/ (props changed) stable/7/usr.sbin/ppp/ppp.8.m4 Modified: stable/7/usr.sbin/ppp/ppp.8.m4 ============================================================================== --- stable/7/usr.sbin/ppp/ppp.8.m4 Mon Aug 3 09:42:11 2009 (r196047) +++ stable/7/usr.sbin/ppp/ppp.8.m4 Mon Aug 3 09:43:06 2009 (r196048) @@ -5471,7 +5471,7 @@ keywords. .It RAD_FRAMED_IPV6_PREFIX If this attribute is supplied, the value is substituted for IPV6PREFIX in a command. -You may pass it to such as DHCPv6 for delegating an +You may pass it to an upper layer protocol such as DHCPv6 for delegating an IPv6 prefix to a peer. .It RAD_FRAMED_IPV6_ROUTE The received string is expected to be in the format From brian at FreeBSD.org Mon Aug 3 09:55:05 2009 From: brian at FreeBSD.org (Brian Somers) Date: Mon Aug 3 09:55:26 2009 Subject: svn commit: r196049 - in stable/7: tools/regression/usr.bin/jot usr.bin/jot Message-ID: <200908030955.n739t3k5043973@svn.freebsd.org> Author: brian Date: Mon Aug 3 09:55:03 2009 New Revision: 196049 URL: http://svn.freebsd.org/changeset/base/196049 Log: MFC: Fix some uninitialised variables. PR: 136383 Submitted by: Ulrich Spoerlein - uqs at spoerlein dot net Added: stable/7/tools/regression/usr.bin/jot/regress.dddd.out - copied unchanged from r195443, head/tools/regression/usr.bin/jot/regress.dddd.out Modified: stable/7/tools/regression/usr.bin/jot/ (props changed) stable/7/tools/regression/usr.bin/jot/regress.sh stable/7/usr.bin/jot/ (props changed) stable/7/usr.bin/jot/jot.c Copied: stable/7/tools/regression/usr.bin/jot/regress.dddd.out (from r195443, head/tools/regression/usr.bin/jot/regress.dddd.out) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/tools/regression/usr.bin/jot/regress.dddd.out Mon Aug 3 09:55:03 2009 (r196049, copy of r195443, head/tools/regression/usr.bin/jot/regress.dddd.out) @@ -0,0 +1,100 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 Modified: stable/7/tools/regression/usr.bin/jot/regress.sh ============================================================================== --- stable/7/tools/regression/usr.bin/jot/regress.sh Mon Aug 3 09:43:06 2009 (r196048) +++ stable/7/tools/regression/usr.bin/jot/regress.sh Mon Aug 3 09:55:03 2009 (r196049) @@ -1,6 +1,6 @@ # $FreeBSD$ -echo 1..56 +echo 1..57 REGRESSION_START($1) @@ -20,6 +20,7 @@ REGRESSION_TEST(`dhdd', `jot - 20 - -') REGRESSION_TEST(`ddhh', `jot - - 120 2') REGRESSION_TEST(`ddhd', `jot - - 120 -') REGRESSION_TEST(`dddh', `jot - - - 2') +REGRESSION_TEST(`dddd', `jot - - - -') REGRESSION_TEST(`hhhh2', `jot 30 20 160 2') REGRESSION_TEST(`hhhd2', `jot 30 20 160 -') REGRESSION_TEST(`hhdh2', `jot 30 20 - 2') Modified: stable/7/usr.bin/jot/jot.c ============================================================================== --- stable/7/usr.bin/jot/jot.c Mon Aug 3 09:43:06 2009 (r196048) +++ stable/7/usr.bin/jot/jot.c Mon Aug 3 09:55:03 2009 (r196049) @@ -101,13 +101,13 @@ main(int argc, char **argv) int ch; int mask = 0; int n = 0; - double begin; + double begin = BEGIN_DEF; double divisor; - double ender; - double s; + double ender = ENDER_DEF; + double s = STEP_DEF; double x, y; long i; - long reps; + long reps = REPS_DEF; while ((ch = getopt(argc, argv, "b:cnp:rs:w:")) != -1) switch (ch) { From brian at FreeBSD.org Mon Aug 3 09:58:47 2009 From: brian at FreeBSD.org (Brian Somers) Date: Mon Aug 3 09:59:04 2009 Subject: svn commit: r196050 - stable/7/bin/ps Message-ID: <200908030958.n739wkWH044108@svn.freebsd.org> Author: brian Date: Mon Aug 3 09:58:46 2009 New Revision: 196050 URL: http://svn.freebsd.org/changeset/base/196050 Log: MFC: Add the -d switch to the usage message. Modified: stable/7/bin/ps/ (props changed) stable/7/bin/ps/ps.c Modified: stable/7/bin/ps/ps.c ============================================================================== --- stable/7/bin/ps/ps.c Mon Aug 3 09:55:03 2009 (r196049) +++ stable/7/bin/ps/ps.c Mon Aug 3 09:58:46 2009 (r196050) @@ -1331,7 +1331,7 @@ check_procfs(void) static void usage(void) { -#define SINGLE_OPTS "[-aCce" OPT_LAZY_f "HhjlmrSTuvwXxZ]" +#define SINGLE_OPTS "[-aCcde" OPT_LAZY_f "HhjlmrSTuvwXxZ]" (void)fprintf(stderr, "%s\n%s\n%s\n%s\n", "usage: ps " SINGLE_OPTS " [-O fmt | -o fmt] [-G gid[,gid...]]", From delphij at FreeBSD.org Mon Aug 3 18:43:28 2009 From: delphij at FreeBSD.org (Xin LI) Date: Mon Aug 3 18:43:45 2009 Subject: svn commit: r196051 - stable/7/contrib/netcat Message-ID: <200908031843.n73IhQ3O093863@svn.freebsd.org> Author: delphij Date: Mon Aug 3 18:43:26 2009 New Revision: 196051 URL: http://svn.freebsd.org/changeset/base/196051 Log: MFC r193021: Add an EXIT STATUS section to the manual page. Currently, nc(1) does not follow sysexits(3), and returns 1 for all error cases. PR: docs/126451 Modified: stable/7/contrib/netcat/ (props changed) stable/7/contrib/netcat/nc.1 Modified: stable/7/contrib/netcat/nc.1 ============================================================================== --- stable/7/contrib/netcat/nc.1 Mon Aug 3 09:58:46 2009 (r196050) +++ stable/7/contrib/netcat/nc.1 Mon Aug 3 18:43:26 2009 (r196051) @@ -433,6 +433,8 @@ The same example again, this time enabli if the proxy requires it: .Pp .Dl $ nc -x10.2.3.4:8080 -Xconnect -Pruser host.example.com 42 +.Sh EXIT STATUS +.Ex -std .Sh SEE ALSO .Xr cat 1 , .Xr ssh 1 From dougb at FreeBSD.org Mon Aug 3 20:09:55 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Mon Aug 3 20:10:07 2009 Subject: svn commit: r196053 - in stable/7: etc/defaults etc/namedb etc/rc.d share/man/man5 Message-ID: <200908032009.n73K9srk095654@svn.freebsd.org> Author: dougb Date: Mon Aug 3 20:09:54 2009 New Revision: 196053 URL: http://svn.freebsd.org/changeset/base/196053 Log: MFC r192210, a whitespace only change in rc.d/named, and MFC r192215: named_wait feature, auto-forward feature, add named-checkconf to startup Modified: stable/7/etc/defaults/rc.conf stable/7/etc/namedb/named.conf stable/7/etc/rc.d/named stable/7/share/man/man5/rc.conf.5 (contents, props changed) Modified: stable/7/etc/defaults/rc.conf ============================================================================== --- stable/7/etc/defaults/rc.conf Mon Aug 3 18:44:42 2009 (r196052) +++ stable/7/etc/defaults/rc.conf Mon Aug 3 20:09:54 2009 (r196053) @@ -241,6 +241,7 @@ inetd_flags="-wW -C 60" # Optional flag # named_enable="NO" # Run named, the DNS server (or NO). named_program="/usr/sbin/named" # Path to named, if you want a different one. +named_conf="/etc/namedb/named.conf" # Path to the configuration file #named_flags="-c /etc/namedb/named.conf" # Uncomment for named not in /usr/sbin named_pidfile="/var/run/named/pid" # Must set this in named.conf as well named_uid="bind" # User to run named as @@ -248,6 +249,10 @@ named_chrootdir="/var/named" # Chroot di named_chroot_autoupdate="YES" # Automatically install/update chrooted # components of named. See /etc/rc.d/named. named_symlink_enable="YES" # Symlink the chrooted pid file +named_wait="NO" # Wait for working name service before exiting +named_wait_host="localhost" # Hostname to check if named_wait is enabled +named_auto_forward="NO" # Set up forwarders from /etc/resolv.conf +named_auto_forward_only="NO" # Do "forward only" instead of "forward first" # # kerberos. Do not run the admin daemons on slave servers Modified: stable/7/etc/namedb/named.conf ============================================================================== --- stable/7/etc/namedb/named.conf Mon Aug 3 18:44:42 2009 (r196052) +++ stable/7/etc/namedb/named.conf Mon Aug 3 20:09:54 2009 (r196053) @@ -31,12 +31,6 @@ options { disable-empty-zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA"; disable-empty-zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA"; -// In addition to the "forwarders" clause, you can force your name -// server to never initiate queries of its own, but always ask its -// forwarders only, by enabling the following line: -// -// forward only; - // If you've got a DNS server around at your upstream provider, enter // its IP address here, and enable the line below. This will make you // benefit from its cache, thus reduce overall DNS traffic in the Internet. @@ -45,6 +39,20 @@ options { 127.0.0.1; }; */ + +// If the 'forwarders' clause is not empty the default is to 'forward first' +// which will fall back to sending a query from your local server if the name +// servers in 'forwarders' do not have the answer. Alternatively you can +// force your name server to never initiate queries of its own by enabling the +// following line: +// forward only; + +// If you wish to have forwarding configured automatically based on +// the entries in /etc/resolv.conf, uncomment the following line and +// set named_auto_forward=yes in /etc/rc.conf. You can also enable +// named_auto_forward_only (the effect of which is described above). +// include "/etc/namedb/auto_forward.conf"; + /* Modern versions of BIND use a random UDP port for each outgoing query by default in order to dramatically reduce the possibility Modified: stable/7/etc/rc.d/named ============================================================================== --- stable/7/etc/rc.d/named Mon Aug 3 18:44:42 2009 (r196052) +++ stable/7/etc/rc.d/named Mon Aug 3 20:09:54 2009 (r196053) @@ -16,7 +16,7 @@ command="/usr/sbin/named" extra_commands="reload" start_precmd="named_precmd" -start_postcmd="make_symlinks" +start_postcmd="named_poststart" reload_cmd="named_reload" stop_cmd="named_stop" stop_postcmd="named_poststop" @@ -79,7 +79,7 @@ chroot_autoupdate() fi fi - # Copy and/or update key files to the chroot /etc + # Copy and/or update key files to the chroot /etc # for file in localtime protocols services; do if [ -r /etc/$file ]; then @@ -97,6 +97,17 @@ make_symlinks() ln -fs "${named_chrootdir}${pidfile}" ${pidfile} } +named_poststart () { + make_symlinks + + if checkyesno named_wait; then + until ${command%/sbin/named}/bin/host $named_wait_host >/dev/null 2>&1; do + echo " Waiting for nameserver to resolve $named_wait_host" + sleep 1 + done + fi +} + named_reload() { ${command%/named}/rndc reload @@ -135,8 +146,19 @@ named_poststop() fi } +create_file () { + if [ -e "$1" ]; then + unlink $1 + fi + > $1 + chown root:wheel $1 + chmod 644 $1 +} + named_precmd() { + local line nsip firstns + # Is the user using a sandbox? # if [ -n "$named_chrootdir" ]; then @@ -161,6 +183,80 @@ named_precmd() else $confgen_command fi + + # Create a forwarder configuration based on /etc/resolv.conf + if checkyesno named_auto_forward; then + if [ ! -s /etc/resolv.conf ]; then + warn "named_auto_forward enabled, but no /etc/resolv.conf" + + # Empty the file in case it is included in named.conf + [ -s "${named_chrootdir}/etc/namedb/auto_forward.conf" ] && + create_file ${named_chrootdir}/etc/namedb/auto_forward.conf + + ${command%/named}/named-checkconf $named_conf || + err 3 'named-checkconf for $named_conf failed' + return + fi + + create_file /var/run/naf-resolv.conf + create_file /var/run/auto_forward.conf + + echo ' forwarders {' > /var/run/auto_forward.conf + + while read line; do + case "$line" in + 'nameserver '*|'nameserver '*) + nsip=${line##nameserver[ ]} + + if [ -z "$firstns" ]; then + if [ ! "$nsip" = '127.0.0.1' ]; then + echo 'nameserver 127.0.0.1' + echo " ${nsip};" >> /var/run/auto_forward.conf + fi + + firstns=1 + else + [ "$nsip" = '127.0.0.1' ] && continue + echo " ${nsip};" >> /var/run/auto_forward.conf + fi + ;; + esac + + echo $line + done < /etc/resolv.conf > /var/run/naf-resolv.conf + + echo ' };' >> /var/run/auto_forward.conf + echo '' >> /var/run/auto_forward.conf + if checkyesno named_auto_forward_only; then + echo " forward only;" >> /var/run/auto_forward.conf + else + echo " forward first;" >> /var/run/auto_forward.conf + fi + + if cmp -s /etc/resolv.conf /var/run/naf-resolv.conf; then + unlink /var/run/naf-resolv.conf + else + [ -e /etc/resolv.conf ] && unlink /etc/resolv.conf + mv /var/run/naf-resolv.conf /etc/resolv.conf + fi + + if cmp -s ${named_chrootdir}/etc/namedb/auto_forward.conf \ + /var/run/auto_forward.conf; then + unlink /var/run/auto_forward.conf + else + [ -e "${named_chrootdir}/etc/namedb/auto_forward.conf" ] && + unlink ${named_chrootdir}/etc/namedb/auto_forward.conf + mv /var/run/auto_forward.conf \ + ${named_chrootdir}/etc/namedb/auto_forward.conf + fi + else + # Empty the file in case it is included in named.conf + [ -s "${named_chrootdir}/etc/namedb/auto_forward.conf" ] && + create_file ${named_chrootdir}/etc/namedb/auto_forward.conf + fi + + ${command%/named}/named-checkconf $named_conf || + err 3 'named-checkconf for $named_conf failed' } load_rc_config $name Modified: stable/7/share/man/man5/rc.conf.5 ============================================================================== --- stable/7/share/man/man5/rc.conf.5 Mon Aug 3 18:44:42 2009 (r196052) +++ stable/7/share/man/man5/rc.conf.5 Mon Aug 3 20:09:54 2009 (r196053) @@ -1594,6 +1594,12 @@ Path to .Xr named 8 (default .Pa /usr/sbin/named ) . +.It Va named_conf +.Pq Vt str +Path to +.Xr named 8 +configuration file, (default +.Pa /etc/namedb/named.conf ) . .It Va named_flags .Pq Vt str If @@ -1641,6 +1647,26 @@ daemon's PID file into the .Xr chroot 8 environment. +.It Va named_wait +.Pq Vt bool +Set to have +.Pa /etc/rc.d/named +loop until working name service is established. +.It Va named_wait_host +.Pq Vt str +Name of host to lookup for the named_wait option. +(Default localhost) +.It Va named_auto_forward +.Pq Vt bool +Set to enable automatic creation of a forwarder +configuration file derived from +.Pa /etc/resolv.conf . +.It Va named_auto_forward_only +.Pq Vt bool +Set to change the default forwarder configuration from +.Dq forward first +to +.Dq forward only . .It Va kerberos5_server_enable .Pq Vt bool Set to From dougb at FreeBSD.org Mon Aug 3 20:20:16 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Mon Aug 3 20:20:27 2009 Subject: svn commit: r196055 - in stable/7/etc: . rc.d Message-ID: <200908032020.n73KKF0q096083@svn.freebsd.org> Author: dougb Date: Mon Aug 3 20:20:15 2009 New Revision: 196055 URL: http://svn.freebsd.org/changeset/base/196055 Log: MFC r193119, quotation marks around the value of name= (i.e., diff reduction to HEAD) Modified: stable/7/etc/ (props changed) stable/7/etc/rc.d/archdep stable/7/etc/rc.d/moused stable/7/etc/rc.d/nscd stable/7/etc/rc.d/ntpd stable/7/etc/termcap.small (props changed) Modified: stable/7/etc/rc.d/archdep ============================================================================== --- stable/7/etc/rc.d/archdep Mon Aug 3 20:14:00 2009 (r196054) +++ stable/7/etc/rc.d/archdep Mon Aug 3 20:20:15 2009 (r196055) @@ -9,7 +9,7 @@ . /etc/rc.subr -name=archdep +name="archdep" start_cmd="archdep_start" stop_cmd=":" Modified: stable/7/etc/rc.d/moused ============================================================================== --- stable/7/etc/rc.d/moused Mon Aug 3 20:14:00 2009 (r196054) +++ stable/7/etc/rc.d/moused Mon Aug 3 20:20:15 2009 (r196055) @@ -9,7 +9,7 @@ . /etc/rc.subr -name=moused +name="moused" rcvar=`set_rcvar` command="/usr/sbin/${name}" start_cmd="moused_start" Modified: stable/7/etc/rc.d/nscd ============================================================================== --- stable/7/etc/rc.d/nscd Mon Aug 3 20:14:00 2009 (r196054) +++ stable/7/etc/rc.d/nscd Mon Aug 3 20:20:15 2009 (r196055) @@ -18,7 +18,7 @@ . /etc/rc.subr -name=nscd +name="nscd" rcvar=`set_rcvar` command=/usr/sbin/nscd Modified: stable/7/etc/rc.d/ntpd ============================================================================== --- stable/7/etc/rc.d/ntpd Mon Aug 3 20:14:00 2009 (r196054) +++ stable/7/etc/rc.d/ntpd Mon Aug 3 20:20:15 2009 (r196055) @@ -10,7 +10,7 @@ . /etc/rc.subr -name=ntpd +name="ntpd" rcvar=`set_rcvar` command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" From dougb at FreeBSD.org Mon Aug 3 20:24:33 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Mon Aug 3 20:24:39 2009 Subject: svn commit: r196057 - in stable/7/etc: . rc.d Message-ID: <200908032024.n73KOWhN096290@svn.freebsd.org> Author: dougb Date: Mon Aug 3 20:24:31 2009 New Revision: 196057 URL: http://svn.freebsd.org/changeset/base/196057 Log: MFC r193197, substitute ypset for ypbind in REQUIRE lines. Modified: stable/7/etc/ (props changed) stable/7/etc/rc.d/amd stable/7/etc/rc.d/keyserv stable/7/etc/rc.d/nisdomain stable/7/etc/rc.d/quota stable/7/etc/rc.d/yppasswdd stable/7/etc/termcap.small (props changed) Modified: stable/7/etc/rc.d/amd ============================================================================== --- stable/7/etc/rc.d/amd Mon Aug 3 20:22:02 2009 (r196056) +++ stable/7/etc/rc.d/amd Mon Aug 3 20:24:31 2009 (r196057) @@ -4,7 +4,7 @@ # # PROVIDE: amd -# REQUIRE: rpcbind ypbind nfsclient cleanvar ldconfig +# REQUIRE: rpcbind ypset nfsclient cleanvar ldconfig # BEFORE: DAEMON # KEYWORD: nojail shutdown Modified: stable/7/etc/rc.d/keyserv ============================================================================== --- stable/7/etc/rc.d/keyserv Mon Aug 3 20:22:02 2009 (r196056) +++ stable/7/etc/rc.d/keyserv Mon Aug 3 20:24:31 2009 (r196057) @@ -6,7 +6,7 @@ # Start keyserv if we are running Secure RPC # PROVIDE: keyserv -# REQUIRE: ypbind +# REQUIRE: ypset # BEFORE: DAEMON # KEYWORD: shutdown Modified: stable/7/etc/rc.d/nisdomain ============================================================================== --- stable/7/etc/rc.d/nisdomain Mon Aug 3 20:22:02 2009 (r196056) +++ stable/7/etc/rc.d/nisdomain Mon Aug 3 20:24:31 2009 (r196057) @@ -28,7 +28,7 @@ # PROVIDE: nisdomain # REQUIRE: SERVERS rpcbind -# BEFORE: ypbind ypserv ypxfrd +# BEFORE: ypset ypbind ypserv ypxfrd . /etc/rc.subr Modified: stable/7/etc/rc.d/quota ============================================================================== --- stable/7/etc/rc.d/quota Mon Aug 3 20:22:02 2009 (r196056) +++ stable/7/etc/rc.d/quota Mon Aug 3 20:24:31 2009 (r196057) @@ -6,7 +6,7 @@ # Enable/Check the quotas (must be after ypbind if using NIS) # PROVIDE: quota -# REQUIRE: mountcritremote +# REQUIRE: mountcritremote ypset # BEFORE: DAEMON # KEYWORD: nojail Modified: stable/7/etc/rc.d/yppasswdd ============================================================================== --- stable/7/etc/rc.d/yppasswdd Mon Aug 3 20:22:02 2009 (r196056) +++ stable/7/etc/rc.d/yppasswdd Mon Aug 3 20:24:31 2009 (r196057) @@ -4,7 +4,7 @@ # # PROVIDE: yppasswdd -# REQUIRE: ypserv ypbind +# REQUIRE: ypserv ypset # BEFORE: LOGIN # KEYWORD: shutdown From maxim at FreeBSD.org Thu Aug 6 08:55:55 2009 From: maxim at FreeBSD.org (Maxim Konovalov) Date: Thu Aug 6 08:56:12 2009 Subject: svn commit: r196079 - stable/7/sbin/ipfw Message-ID: <200908060855.n768tsHw048928@svn.freebsd.org> Author: maxim Date: Thu Aug 6 08:55:54 2009 New Revision: 196079 URL: http://svn.freebsd.org/changeset/base/196079 Log: MFC r195036: kill grammar nits. Modified: stable/7/sbin/ipfw/ (props changed) stable/7/sbin/ipfw/ipfw.8 Modified: stable/7/sbin/ipfw/ipfw.8 ============================================================================== --- stable/7/sbin/ipfw/ipfw.8 Wed Aug 5 23:05:11 2009 (r196078) +++ stable/7/sbin/ipfw/ipfw.8 Thu Aug 6 08:55:54 2009 (r196079) @@ -311,7 +311,7 @@ file systems are mounted (yet) by the ti is being run (e.g.\& when they are mounted over NFS). Once .Fl p -has been specified, any additional arguments as passed on to the preprocessor +has been specified, any additional arguments are passed on to the preprocessor for interpretation. This allows for flexible configuration files (like conditionalizing them on the local hostname) and the use of macros to centralize @@ -1903,7 +1903,7 @@ with .Dq "options HZ=1000" to reduce the granularity to 1ms or less). -Default value is 0, meaning no delay. +The default value is 0, meaning no delay. .El .Pp The following parameters can be configured for a queue: From kib at FreeBSD.org Sun Aug 9 11:47:41 2009 From: kib at FreeBSD.org (Konstantin Belousov) Date: Sun Aug 9 11:47:58 2009 Subject: svn commit: r196087 - in stable/7/sys: . contrib/pf kern Message-ID: <200908091147.n79BleJ7067102@svn.freebsd.org> Author: kib Date: Sun Aug 9 11:47:39 2009 New Revision: 196087 URL: http://svn.freebsd.org/changeset/base/196087 Log: MFC r195773: When buffer write is failed, it is wrong for brelse() to invalidate portion of the page that was written. Among other problems, this page might be picked up by pagedaemon, with failed assertion in vm_pageout_flush() about validity of the page. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/kern/vfs_bio.c Modified: stable/7/sys/kern/vfs_bio.c ============================================================================== --- stable/7/sys/kern/vfs_bio.c Fri Aug 7 15:41:16 2009 (r196086) +++ stable/7/sys/kern/vfs_bio.c Sun Aug 9 11:47:39 2009 (r196087) @@ -1347,7 +1347,8 @@ brelse(struct buf *bp) m = bp->b_pages[i]; } if ((bp->b_flags & B_NOCACHE) || - (bp->b_ioflags & BIO_ERROR)) { + (bp->b_ioflags & BIO_ERROR && + bp->b_iocmd == BIO_READ)) { int poffset = foff & PAGE_MASK; int presid = resid > (PAGE_SIZE - poffset) ? (PAGE_SIZE - poffset) : resid; From brian at FreeBSD.org Sun Aug 9 18:39:25 2009 From: brian at FreeBSD.org (Brian Somers) Date: Sun Aug 9 18:39:41 2009 Subject: svn commit: r196088 - stable/7/usr.sbin/ppp Message-ID: <200908091839.n79IdONq075058@svn.freebsd.org> Author: brian Date: Sun Aug 9 18:39:23 2009 New Revision: 196088 URL: http://svn.freebsd.org/changeset/base/196088 Log: MFC: Don't get stuck in an infinite loop comparing (short++ <= maxshort) PR: 136893 Submitted by: Aragon Gouveia - aragon at phat dot za dot net (mostly) Modified: stable/7/usr.sbin/ppp/ (props changed) stable/7/usr.sbin/ppp/nat_cmd.c Modified: stable/7/usr.sbin/ppp/nat_cmd.c ============================================================================== --- stable/7/usr.sbin/ppp/nat_cmd.c Sun Aug 9 11:47:39 2009 (r196087) +++ stable/7/usr.sbin/ppp/nat_cmd.c Sun Aug 9 18:39:23 2009 (r196088) @@ -173,7 +173,7 @@ nat_RedirectPort(struct cmdargs const *a return -1; } - while (laliasport <= haliasport) { + do { link = PacketAliasRedirectPort(localaddr, htons(llocalport), remoteaddr, htons(lremoteport), aliasaddr, htons(laliasport), @@ -185,10 +185,9 @@ nat_RedirectPort(struct cmdargs const *a return 1; } llocalport++; - laliasport++; if (hremoteport) lremoteport++; - } + } while (laliasport++ < haliasport); return 0; } From mefistofelez at hotmail.com Tue Aug 11 17:52:03 2009 From: mefistofelez at hotmail.com (Pavel Kalousek) Date: Tue Aug 11 17:52:44 2009 Subject: Help In-Reply-To: <20090810120031.027341065795@hub.freebsd.org> References: <20090810120031.027341065795@hub.freebsd.org> Message-ID: I have tried several times to unsubscribne from the list via the link in this e-mail. It does not seem to work. Please unsubscribe me. Thank you, M. > From: svn-src-stable-7-request@freebsd.org > Subject: svn-src-stable-7 Digest, Vol 68, Issue 7 > To: svn-src-stable-7@freebsd.org > Date: Mon, 10 Aug 2009 12:00:31 +0000 > > Send svn-src-stable-7 mailing list submissions to > svn-src-stable-7@freebsd.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.freebsd.org/mailman/listinfo/svn-src-stable-7 > or, via email, send a message with subject or body 'help' to > svn-src-stable-7-request@freebsd.org > > You can reach the person managing the list at > svn-src-stable-7-owner@freebsd.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of svn-src-stable-7 digest..." > > > Today's Topics: > > 1. svn commit: r196088 - stable/7/usr.sbin/ppp (Brian Somers) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sun, 9 Aug 2009 18:39:24 +0000 (UTC) > From: Brian Somers > Subject: svn commit: r196088 - stable/7/usr.sbin/ppp > To: src-committers@freebsd.org, svn-src-all@freebsd.org, > svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org > Message-ID: <200908091839.n79IdONq075058@svn.freebsd.org> > Content-Type: text/plain; charset=UTF-8 > > Author: brian > Date: Sun Aug 9 18:39:23 2009 > New Revision: 196088 > URL: http://svn.freebsd.org/changeset/base/196088 > > Log: > MFC: Don't get stuck in an infinite loop comparing (short++ <= maxshort) > > PR: 136893 > Submitted by: Aragon Gouveia - aragon at phat dot za dot net (mostly) > > Modified: > stable/7/usr.sbin/ppp/ (props changed) > stable/7/usr.sbin/ppp/nat_cmd.c > > Modified: stable/7/usr.sbin/ppp/nat_cmd.c > ============================================================================== > --- stable/7/usr.sbin/ppp/nat_cmd.c Sun Aug 9 11:47:39 2009 (r196087) > +++ stable/7/usr.sbin/ppp/nat_cmd.c Sun Aug 9 18:39:23 2009 (r196088) > @@ -173,7 +173,7 @@ nat_RedirectPort(struct cmdargs const *a > return -1; > } > > - while (laliasport <= haliasport) { > + do { > link = PacketAliasRedirectPort(localaddr, htons(llocalport), > remoteaddr, htons(lremoteport), > aliasaddr, htons(laliasport), > @@ -185,10 +185,9 @@ nat_RedirectPort(struct cmdargs const *a > return 1; > } > llocalport++; > - laliasport++; > if (hremoteport) > lremoteport++; > - } > + } while (laliasport++ < haliasport); > > return 0; > } > > > ------------------------------ > > _______________________________________________ > svn-src-stable-7@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-stable-7 > To unsubscribe, send any mail to "svn-src-stable-7-unsubscribe@freebsd.org" > > End of svn-src-stable-7 Digest, Vol 68, Issue 7 > *********************************************** _________________________________________________________________ Express your personality in color! Preview and select themes for Hotmail?. http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:WM_HYGN_express:082009 From rnoland at FreeBSD.org Wed Aug 12 13:19:15 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Wed Aug 12 13:19:21 2009 Subject: svn commit: r196145 - in stable/7/sys: . contrib/pf dev/drm Message-ID: <200908121319.n7CDJEIU065817@svn.freebsd.org> Author: rnoland Date: Wed Aug 12 13:19:14 2009 New Revision: 196145 URL: http://svn.freebsd.org/changeset/base/196145 Log: Merge r196141 Add some additional radeon pci ids to drm. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/drm/drm_pciids.h Modified: stable/7/sys/dev/drm/drm_pciids.h ============================================================================== --- stable/7/sys/dev/drm/drm_pciids.h Wed Aug 12 13:12:09 2009 (r196144) +++ stable/7/sys/dev/drm/drm_pciids.h Wed Aug 12 13:19:14 2009 (r196145) @@ -259,9 +259,12 @@ {0x1002, 0x940F, CHIP_R600|RADEON_NEW_MEMMAP, "ATI FireGL V7600"}, \ {0x1002, 0x94A0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 4830"}, \ {0x1002, 0x94A1, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 4850"}, \ + {0x1002, 0x94A3, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI FirePro M7740"}, \ {0x1002, 0x94B1, CHIP_RV740|RADEON_NEW_MEMMAP, "ATI RV740"}, \ {0x1002, 0x94B3, CHIP_RV740|RADEON_NEW_MEMMAP, "ATI Radeon HD 4770"}, \ + {0x1002, 0x94B4, CHIP_RV740|RADEON_NEW_MEMMAP, "ATI Radeon HD 4700 Series"}, \ {0x1002, 0x94B5, CHIP_RV740|RADEON_NEW_MEMMAP, "ATI Radeon HD 4770"}, \ + {0x1002, 0x94B9, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI FirePro M5750"}, \ {0x1002, 0x94C0, CHIP_RV610|RADEON_NEW_MEMMAP, "RV610"}, \ {0x1002, 0x94C1, CHIP_RV610|RADEON_NEW_MEMMAP, "Radeon HD 2400 XT"}, \ {0x1002, 0x94C3, CHIP_RV610|RADEON_NEW_MEMMAP, "Radeon HD 2400 Pro"}, \ @@ -350,6 +353,7 @@ {0x1002, 0x9487, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI Radeon RV730 (AGP)"}, \ {0x1002, 0x948F, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI Radeon RV730 (AGP)"}, \ {0x1002, 0x9490, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI Radeon HD 4670"}, \ + {0x1002, 0x9495, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI Radeon HD 4600 Series"}, \ {0x1002, 0x9498, CHIP_RV730|RADEON_NEW_MEMMAP, "ATI Radeon HD 4650"}, \ {0x1002, 0x9480, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 4650"}, \ {0x1002, 0x9488, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon HD 4670"}, \ @@ -366,6 +370,7 @@ {0x1002, 0x9552, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon 4300 Series"}, \ {0x1002, 0x9553, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon 4500 Series"}, \ {0x1002, 0x9555, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Mobility Radeon 4500 Series"}, \ + {0x1002, 0x9557, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI FirePro RG220"}, \ {0, 0, 0, NULL} #define r128_PCI_IDS \ From rnoland at FreeBSD.org Wed Aug 12 13:20:43 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Wed Aug 12 13:20:55 2009 Subject: svn commit: r196146 - in stable/7/sys: . contrib/pf dev/drm Message-ID: <200908121320.n7CDKgW6065903@svn.freebsd.org> Author: rnoland Date: Wed Aug 12 13:20:42 2009 New Revision: 196146 URL: http://svn.freebsd.org/changeset/base/196146 Log: Merge r196142 Add support for radeon RS880 IGP chips to drm. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/drm/drm_pciids.h stable/7/sys/dev/drm/r600_cp.c stable/7/sys/dev/drm/radeon_drv.h Modified: stable/7/sys/dev/drm/drm_pciids.h ============================================================================== --- stable/7/sys/dev/drm/drm_pciids.h Wed Aug 12 13:19:14 2009 (r196145) +++ stable/7/sys/dev/drm/drm_pciids.h Wed Aug 12 13:20:42 2009 (r196146) @@ -330,6 +330,11 @@ {0x1002, 0x9614, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Radeon 3300 Graphics"}, \ {0x1002, 0x9615, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Radeon 3200 Graphics"}, \ {0x1002, 0x9616, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Radeon 3000 Graphics"}, \ + {0x1002, 0x9710, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Radeon HD 4200"}, \ + {0x1002, 0x9711, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Radeon 4100"}, \ + {0x1002, 0x9712, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Mobility Radeon HD 4200"}, \ + {0x1002, 0x9713, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI Mobility Radeon 4100"}, \ + {0x1002, 0x9714, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP, "ATI RS880"}, \ {0x1002, 0x9440, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4800 Series"}, \ {0x1002, 0x9441, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4870 X2"}, \ {0x1002, 0x9442, CHIP_RV770|RADEON_NEW_MEMMAP, "ATI Radeon 4800 Series"}, \ Modified: stable/7/sys/dev/drm/r600_cp.c ============================================================================== --- stable/7/sys/dev/drm/r600_cp.c Wed Aug 12 13:19:14 2009 (r196145) +++ stable/7/sys/dev/drm/r600_cp.c Wed Aug 12 13:20:42 2009 (r196146) @@ -318,7 +318,8 @@ static void r600_cp_load_microcode(drm_r pfp = RV670_pfp_microcode; break; case CHIP_RS780: - DRM_INFO("Loading RS780 Microcode\n"); + case CHIP_RS880: + DRM_INFO("Loading RS780/RS880 Microcode\n"); cp = RS780_cp_microcode; pfp = RS780_pfp_microcode; break; @@ -722,6 +723,7 @@ static void r600_gfx_init(struct drm_dev break; case CHIP_RV610: case CHIP_RS780: + case CHIP_RS880: case CHIP_RV620: dev_priv->r600_max_pipes = 1; dev_priv->r600_max_tile_pipes = 1; @@ -856,7 +858,8 @@ static void r600_gfx_init(struct drm_dev ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV630) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) || - ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780)) + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS880)) RADEON_WRITE(R600_DB_DEBUG, R600_PREZ_MUST_WAIT_FOR_POSTZ_DONE); else RADEON_WRITE(R600_DB_DEBUG, 0); @@ -874,7 +877,8 @@ static void r600_gfx_init(struct drm_dev sq_ms_fifo_sizes = RADEON_READ(R600_SQ_MS_FIFO_SIZES); if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) || - ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780)) { + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS880)) { sq_ms_fifo_sizes = (R600_CACHE_FIFO_SIZE(0xa) | R600_FETCH_FIFO_HIWATER(0xa) | R600_DONE_FIFO_HIWATER(0xe0) | @@ -917,7 +921,8 @@ static void r600_gfx_init(struct drm_dev R600_NUM_ES_STACK_ENTRIES(0)); } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) || - ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780)) { + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS880)) { /* no vertex cache */ sq_config &= ~R600_VC_ENABLE; @@ -974,7 +979,8 @@ static void r600_gfx_init(struct drm_dev if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) || ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) || - ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780)) + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780) || + ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS880)) RADEON_WRITE(R600_VGT_CACHE_INVALIDATION, R600_CACHE_INVALIDATION(R600_TC_ONLY)); else RADEON_WRITE(R600_VGT_CACHE_INVALIDATION, R600_CACHE_INVALIDATION(R600_VC_AND_TC)); @@ -1017,6 +1023,7 @@ static void r600_gfx_init(struct drm_dev break; case CHIP_RV610: case CHIP_RS780: + case CHIP_RS880: case CHIP_RV620: gs_prim_buffer_depth = 32; break; @@ -1062,6 +1069,7 @@ static void r600_gfx_init(struct drm_dev switch (dev_priv->flags & RADEON_FAMILY_MASK) { case CHIP_RV610: case CHIP_RS780: + case CHIP_RS880: case CHIP_RV620: tc_cntl = R600_TC_L2_SIZE(8); break; Modified: stable/7/sys/dev/drm/radeon_drv.h ============================================================================== --- stable/7/sys/dev/drm/radeon_drv.h Wed Aug 12 13:19:14 2009 (r196145) +++ stable/7/sys/dev/drm/radeon_drv.h Wed Aug 12 13:20:42 2009 (r196146) @@ -145,6 +145,7 @@ enum radeon_family { CHIP_RV635, CHIP_RV670, CHIP_RS780, + CHIP_RS880, CHIP_RV770, CHIP_RV740, CHIP_RV730, From n_hibma at FreeBSD.org Thu Aug 13 07:19:44 2009 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Aug 13 07:20:01 2009 Subject: svn commit: r196166 - stable/7/sys/dev/usb Message-ID: <200908130719.n7D7JhBA090783@svn.freebsd.org> Author: n_hibma Date: Thu Aug 13 07:19:43 2009 New Revision: 196166 URL: http://svn.freebsd.org/changeset/base/196166 Log: Reset the debugging flag to 0. Modified: stable/7/sys/dev/usb/u3g.c Modified: stable/7/sys/dev/usb/u3g.c ============================================================================== --- stable/7/sys/dev/usb/u3g.c Thu Aug 13 06:13:45 2009 (r196165) +++ stable/7/sys/dev/usb/u3g.c Thu Aug 13 07:19:43 2009 (r196166) @@ -52,7 +52,7 @@ #endif #include "usbdevs.h" -static int u3gdebug = 1; +static int u3gdebug = 0; SYSCTL_NODE(_hw_usb, OID_AUTO, u3g, CTLFLAG_RW, 0, "USB u3g"); SYSCTL_INT(_hw_usb_u3g, OID_AUTO, debug, CTLFLAG_RW, &u3gdebug, 0, "u3g debug level"); From n_hibma at FreeBSD.org Thu Aug 13 07:21:25 2009 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Aug 13 07:21:31 2009 Subject: svn commit: r196167 - stable/7/sys/dev/usb Message-ID: <200908130721.n7D7LOWd090861@svn.freebsd.org> Author: n_hibma Date: Thu Aug 13 07:21:24 2009 New Revision: 196167 URL: http://svn.freebsd.org/changeset/base/196167 Log: Restart the controller if it has halted. Restarting it makes the USB tree functional again (without reconnecting the devices, mind you). On my laptop there is probably a short somewhere on the motherboard and once in a while the host controller halts. Modified: stable/7/sys/dev/usb/uhci.c Modified: stable/7/sys/dev/usb/uhci.c ============================================================================== --- stable/7/sys/dev/usb/uhci.c Thu Aug 13 07:19:43 2009 (r196166) +++ stable/7/sys/dev/usb/uhci.c Thu Aug 13 07:21:24 2009 (r196167) @@ -1205,20 +1205,55 @@ uhci_intr1(uhci_softc_t *sc) device_get_nameunit(sc->sc_bus.bdev)); } if (status & UHCI_STS_HCH) { - /* no acknowledge needed */ if (!sc->sc_dying) { + ack |= UHCI_STS_HCH; printf("%s: host controller halted\n", - device_get_nameunit(sc->sc_bus.bdev)); -#ifdef USB_DEBUG - uhci_dump_all(sc); -#endif + device_get_nameunit(sc->sc_bus.bdev)); } - sc->sc_dying = 1; } if (!ack) return (0); /* nothing to acknowledge */ - UWRITE2(sc, UHCI_STS, ack); /* acknowledge the ints */ + + UWRITE2(sc, UHCI_STS, ack & ~UHCI_STS_HCH); /* acknowledge the ints */ + + if (ack & UHCI_STS_HCH) { + /* Restart the controller, by Manuel Bouyer */ + sc->sc_saved_frnum = UREAD2(sc, UHCI_FRNUM); + sc->sc_saved_sof = UREAD1(sc, UHCI_SOF); + + sc->sc_bus.use_polling++; + uhci_run(sc, 0); /* stop the controller */ + UWRITE2(sc, UHCI_INTR, 0); /* disable intrs */ + + uhci_globalreset(sc); + uhci_reset(sc); + + /* restore saved state */ + UWRITE4(sc, UHCI_FLBASEADDR, DMAADDR(&sc->sc_dma, 0)); + UWRITE2(sc, UHCI_FRNUM, sc->sc_saved_frnum); + UWRITE1(sc, UHCI_SOF, sc->sc_saved_sof); + + UWRITE2(sc, UHCI_INTR, UHCI_INTR_TOCRCIE | UHCI_INTR_RIE | + UHCI_INTR_IOCE | UHCI_INTR_SPIE); /* re-enable intrs */ + UHCICMD(sc, UHCI_CMD_MAXP); + + uhci_run(sc, 1); /* and start traffic again */ + sc->sc_bus.use_polling--; + + if (UREAD2(sc, UHCI_STS) & UHCI_STS_HCH) { + printf("%s: host controller couldn't be restarted\n", + device_get_nameunit(sc->sc_bus.bdev)); +#ifdef USB_DEBUG + uhci_dump_all(sc); +#endif + sc->sc_dying = 1; + return (0); + } + + printf("%s: host controller restarted\n", + device_get_nameunit(sc->sc_bus.bdev)); + } sc->sc_bus.no_intrs++; usb_schedsoftintr(&sc->sc_bus); From n_hibma at FreeBSD.org Thu Aug 13 08:18:30 2009 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Aug 13 08:18:36 2009 Subject: svn commit: r196168 - in stable/7/sys/modules: . ohci uhci Message-ID: <200908130818.n7D8ITDx093434@svn.freebsd.org> Author: n_hibma Date: Thu Aug 13 08:18:29 2009 New Revision: 196168 URL: http://svn.freebsd.org/changeset/base/196168 Log: Add these two modules to enable loading of 'the other' host controller if only one was compiled into the kernel. This happens on a laptop with an Intel chipset (UHCI) to which an Option 3G Cardbus card is added (which contains a NEC USB host controller (OHCI)). Added: stable/7/sys/modules/ohci/ stable/7/sys/modules/ohci/Makefile (contents, props changed) stable/7/sys/modules/uhci/ stable/7/sys/modules/uhci/Makefile (contents, props changed) Modified: stable/7/sys/modules/Makefile Modified: stable/7/sys/modules/Makefile ============================================================================== --- stable/7/sys/modules/Makefile Thu Aug 13 07:21:24 2009 (r196167) +++ stable/7/sys/modules/Makefile Thu Aug 13 08:18:29 2009 (r196168) @@ -206,6 +206,7 @@ SUBDIR= ${_3dfx} \ ${_nve} \ ${_nvram} \ ${_nwfs} \ + ohci \ ${_oltr} \ ${_opensolaris} \ ${_padlock} \ @@ -293,6 +294,7 @@ SUBDIR= ${_3dfx} \ ufoma \ uftdi \ ugen \ + uhci \ uhid \ ukbd \ ulpt \ Added: stable/7/sys/modules/ohci/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/modules/ohci/Makefile Thu Aug 13 08:18:29 2009 (r196168) @@ -0,0 +1,12 @@ +# $FreeBSD$ + +S= ${.CURDIR}/../.. + +.PATH: $S/dev/usb $S/pci + +KMOD= ohci +SRCS= bus_if.h device_if.h usb_if.h usb_if.c opt_usb.h +SRCS+= ohci_pci.c ohci.c ohcireg.h ohcivar.h +SRCS+= opt_bus.h pci_if.h + +.include Added: stable/7/sys/modules/uhci/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/sys/modules/uhci/Makefile Thu Aug 13 08:18:29 2009 (r196168) @@ -0,0 +1,12 @@ +# $FreeBSD$ + +S= ${.CURDIR}/../.. + +.PATH: $S/dev/usb $S/pci + +KMOD= uhci +SRCS= bus_if.h device_if.h usb_if.h usb_if.c opt_usb.h +SRCS+= uhci_pci.c uhci.c uhcireg.h uhcivar.h +SRCS+= opt_bus.h pci_if.h + +.include From n_hibma at FreeBSD.org Thu Aug 13 08:20:13 2009 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Aug 13 08:20:30 2009 Subject: svn commit: r196169 - stable/7/sys/pci Message-ID: <200908130820.n7D8KCgt093511@svn.freebsd.org> Author: n_hibma Date: Thu Aug 13 08:20:12 2009 New Revision: 196169 URL: http://svn.freebsd.org/changeset/base/196169 Log: Hide aperture size and stolen memory behind bootverbose. Modified: stable/7/sys/pci/agp_i810.c Modified: stable/7/sys/pci/agp_i810.c ============================================================================== --- stable/7/sys/pci/agp_i810.c Thu Aug 13 08:18:29 2009 (r196168) +++ stable/7/sys/pci/agp_i810.c Thu Aug 13 08:20:12 2009 (r196169) @@ -474,12 +474,13 @@ agp_i810_attach(device_t dev) agp_generic_detach(dev); return EINVAL; } - if (sc->stolen > 0) { - device_printf(dev, "detected %dk stolen memory\n", - sc->stolen * 4); + + if (bootverbose) { + device_print_prettyname(dev); + if (sc->stolen > 0) + printf("detected %dk stolen memory, ", sc->stolen * 4); + printf("aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); } - device_printf(dev, "aperture size is %dM\n", - sc->initial_aperture / 1024 / 1024); /* GATT address is already in there, make sure it's enabled */ pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL); @@ -664,9 +665,13 @@ agp_i810_attach(device_t dev) gtt_size += 4; sc->stolen = (stolen - gtt_size) * 1024 / 4096; - if (sc->stolen > 0) - device_printf(dev, "detected %dk stolen memory\n", sc->stolen * 4); - device_printf(dev, "aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); + + if (bootverbose) { + device_print_prettyname(dev); + if (sc->stolen > 0) + printf("detected %dk stolen memory, ", sc->stolen * 4); + printf("aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); + } /* GATT address is already in there, make sure it's enabled */ pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL); From n_hibma at FreeBSD.org Thu Aug 13 08:24:59 2009 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Aug 13 08:25:06 2009 Subject: svn commit: r196170 - stable/7/sys/dev/firewire Message-ID: <200908130824.n7D8OwO9093632@svn.freebsd.org> Author: n_hibma Date: Thu Aug 13 08:24:58 2009 New Revision: 196170 URL: http://svn.freebsd.org/changeset/base/196170 Log: Compact some output. Move some behind bootverbose. Modified: stable/7/sys/dev/firewire/fwohci.c Modified: stable/7/sys/dev/firewire/fwohci.c ============================================================================== --- stable/7/sys/dev/firewire/fwohci.c Thu Aug 13 08:20:12 2009 (r196169) +++ stable/7/sys/dev/firewire/fwohci.c Thu Aug 13 08:24:58 2009 (r196170) @@ -616,10 +616,9 @@ fwohci_init(struct fwohci_softc *sc, dev /* OHCI version */ reg = OREAD(sc, OHCI_VERSION); mver = (reg >> 16) & 0xff; - device_printf(dev, "OHCI version %x.%x (ROM=%d)\n", - mver, reg & 0xff, (reg>>24) & 1); if (mver < 1 || mver > 9) { - device_printf(dev, "invalid OHCI version\n"); + device_printf(dev, "invalid OHCI version %d (reg=0x%08x)\n", + mver, reg); return (ENXIO); } @@ -632,10 +631,15 @@ fwohci_init(struct fwohci_softc *sc, dev for (i = 0; i < 0x20; i++) if ((reg & (1 << i)) == 0) break; + if (i == 0) { + device_printf(dev, "0 isoc. channels"); + return ENXIO; + } sc->fc.nisodma = i; - device_printf(dev, "No. of Isochronous channels is %d.\n", i); - if (i == 0) - return (ENXIO); + + device_printf(dev, "OHCI version %x.%x (ROM=%d), %d isoc. channels\n", + mver, reg & 0xff, (reg>>24) & 1, + sc->fc.nisodma); sc->fc.arq = &sc->arrq.xferq; sc->fc.ars = &sc->arrs.xferq; @@ -1848,7 +1852,8 @@ fwohci_intr_core(struct fwohci_softc *sc /* Disable bus reset interrupt until sid recv. */ OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_PHY_BUS_R); - device_printf(fc->dev, "BUS reset\n"); + if (bootverbose) + device_printf(fc->dev, "BUS reset\n"); OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST); OWRITE(sc, OHCI_LNKCTLCLR, OHCI_CNTL_CYCSRC); @@ -2464,7 +2469,8 @@ fwohci_ibr(struct firewire_comm *fc) struct fwohci_softc *sc; uint32_t fun; - device_printf(fc->dev, "Initiate bus reset\n"); + if (bootverbose) + device_printf(fc->dev, "Initiate bus reset\n"); sc = (struct fwohci_softc *)fc; /* From n_hibma at FreeBSD.org Thu Aug 13 08:31:16 2009 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Aug 13 08:31:28 2009 Subject: svn commit: r196171 - stable/7/sys/netsmb Message-ID: <200908130831.n7D8VF7U093805@svn.freebsd.org> Author: n_hibma Date: Thu Aug 13 08:31:15 2009 New Revision: 196171 URL: http://svn.freebsd.org/changeset/base/196171 Log: Silence this module. Modified: stable/7/sys/netsmb/smb_dev.c Modified: stable/7/sys/netsmb/smb_dev.c ============================================================================== --- stable/7/sys/netsmb/smb_dev.c Thu Aug 13 08:24:58 2009 (r196170) +++ stable/7/sys/netsmb/smb_dev.c Thu Aug 13 08:31:15 2009 (r196171) @@ -341,7 +341,6 @@ nsmb_dev_load(module_t mod, int cmd, voi break; } nsmb_dev_tag = EVENTHANDLER_REGISTER(dev_clone, nsmb_dev_clone, 0, 1000); - printf("netsmb_dev: loaded\n"); break; case MOD_UNLOAD: smb_iod_done(); @@ -351,7 +350,6 @@ nsmb_dev_load(module_t mod, int cmd, voi EVENTHANDLER_DEREGISTER(dev_clone, nsmb_dev_tag); drain_dev_clone_events(); destroy_dev_drain(&nsmb_cdevsw); - printf("netsmb_dev: unloaded\n"); break; default: error = EINVAL; From kostikbel at gmail.com Thu Aug 13 08:32:42 2009 From: kostikbel at gmail.com (Kostik Belousov) Date: Thu Aug 13 08:32:54 2009 Subject: svn commit: r196170 - stable/7/sys/dev/firewire In-Reply-To: <200908130824.n7D8OwO9093632@svn.freebsd.org> References: <200908130824.n7D8OwO9093632@svn.freebsd.org> Message-ID: <20090813083236.GR1884@deviant.kiev.zoral.com.ua> On Thu, Aug 13, 2009 at 08:24:58AM +0000, Nick Hibma wrote: > Author: n_hibma > Date: Thu Aug 13 08:24:58 2009 > New Revision: 196170 > URL: http://svn.freebsd.org/changeset/base/196170 > > Log: > Compact some output. Move some behind bootverbose. > > Modified: > stable/7/sys/dev/firewire/fwohci.c > Please revert this commit and your previous r196169. Patches shall go into HEAD first and then merged back to stable branch after settle period. [I consider USB changes as relevant only to stable/7, due to new USB stack in HEAD ?]. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 195 bytes Desc: not available Url : http://lists.freebsd.org/pipermail/svn-src-stable-7/attachments/20090813/f8e5b8b9/attachment.pgp From rwatson at FreeBSD.org Thu Aug 13 08:36:11 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Thu Aug 13 08:36:22 2009 Subject: svn commit: r196171 - stable/7/sys/netsmb In-Reply-To: <200908130831.n7D8VF7U093805@svn.freebsd.org> References: <200908130831.n7D8VF7U093805@svn.freebsd.org> Message-ID: On Thu, 13 Aug 2009, Nick Hibma wrote: > Silence this module. I can't help but notice you're committing changes to a stable branch without first making them in head. For the USB stack, where there's a different implementation between head and stable/7, that's fine. For code that's shared, it's really not fine. Please stop. Robert N M Watson Computer Laboratory University of Cambridge > > Modified: > stable/7/sys/netsmb/smb_dev.c > > Modified: stable/7/sys/netsmb/smb_dev.c > ============================================================================== > --- stable/7/sys/netsmb/smb_dev.c Thu Aug 13 08:24:58 2009 (r196170) > +++ stable/7/sys/netsmb/smb_dev.c Thu Aug 13 08:31:15 2009 (r196171) > @@ -341,7 +341,6 @@ nsmb_dev_load(module_t mod, int cmd, voi > break; > } > nsmb_dev_tag = EVENTHANDLER_REGISTER(dev_clone, nsmb_dev_clone, 0, 1000); > - printf("netsmb_dev: loaded\n"); > break; > case MOD_UNLOAD: > smb_iod_done(); > @@ -351,7 +350,6 @@ nsmb_dev_load(module_t mod, int cmd, voi > EVENTHANDLER_DEREGISTER(dev_clone, nsmb_dev_tag); > drain_dev_clone_events(); > destroy_dev_drain(&nsmb_cdevsw); > - printf("netsmb_dev: unloaded\n"); > break; > default: > error = EINVAL; > From sean.bruno at dsl-only.net Thu Aug 13 10:18:17 2009 From: sean.bruno at dsl-only.net (Sean Bruno) Date: Thu Aug 13 10:18:49 2009 Subject: svn commit: r196170 - stable/7/sys/dev/firewire In-Reply-To: <200908130824.n7D8OwO9093632@svn.freebsd.org> References: <200908130824.n7D8OwO9093632@svn.freebsd.org> Message-ID: <1250157094.8589.11.camel@Lappy> Nick: I like your ideas in this code, but this change removes debugging output from the default output. I'm afraid that it's there for a reason, i.e. please revert this changeset and let's chat about it in IRC or via email to come up with something that makes sense. :) Sean On Thu, 2009-08-13 at 08:24 +0000, Nick Hibma wrote: > Author: n_hibma > Date: Thu Aug 13 08:24:58 2009 > New Revision: 196170 > URL: http://svn.freebsd.org/changeset/base/196170 > > Log: > Compact some output. Move some behind bootverbose. > > Modified: > stable/7/sys/dev/firewire/fwohci.c > > Modified: stable/7/sys/dev/firewire/fwohci.c > ============================================================================== > --- stable/7/sys/dev/firewire/fwohci.c Thu Aug 13 08:20:12 2009 (r196169) > +++ stable/7/sys/dev/firewire/fwohci.c Thu Aug 13 08:24:58 2009 (r196170) > @@ -616,10 +616,9 @@ fwohci_init(struct fwohci_softc *sc, dev > /* OHCI version */ > reg = OREAD(sc, OHCI_VERSION); > mver = (reg >> 16) & 0xff; > - device_printf(dev, "OHCI version %x.%x (ROM=%d)\n", > - mver, reg & 0xff, (reg>>24) & 1); > if (mver < 1 || mver > 9) { > - device_printf(dev, "invalid OHCI version\n"); > + device_printf(dev, "invalid OHCI version %d (reg=0x%08x)\n", > + mver, reg); > return (ENXIO); > } > > @@ -632,10 +631,15 @@ fwohci_init(struct fwohci_softc *sc, dev > for (i = 0; i < 0x20; i++) > if ((reg & (1 << i)) == 0) > break; > + if (i == 0) { > + device_printf(dev, "0 isoc. channels"); > + return ENXIO; > + } > sc->fc.nisodma = i; > - device_printf(dev, "No. of Isochronous channels is %d.\n", i); > - if (i == 0) > - return (ENXIO); > + > + device_printf(dev, "OHCI version %x.%x (ROM=%d), %d isoc. channels\n", > + mver, reg & 0xff, (reg>>24) & 1, > + sc->fc.nisodma); > > sc->fc.arq = &sc->arrq.xferq; > sc->fc.ars = &sc->arrs.xferq; > @@ -1848,7 +1852,8 @@ fwohci_intr_core(struct fwohci_softc *sc > /* Disable bus reset interrupt until sid recv. */ > OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_PHY_BUS_R); > > - device_printf(fc->dev, "BUS reset\n"); > + if (bootverbose) > + device_printf(fc->dev, "BUS reset\n"); > OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST); > OWRITE(sc, OHCI_LNKCTLCLR, OHCI_CNTL_CYCSRC); > > @@ -2464,7 +2469,8 @@ fwohci_ibr(struct firewire_comm *fc) > struct fwohci_softc *sc; > uint32_t fun; > > - device_printf(fc->dev, "Initiate bus reset\n"); > + if (bootverbose) > + device_printf(fc->dev, "Initiate bus reset\n"); > sc = (struct fwohci_softc *)fc; > > /* From n_hibma at FreeBSD.org Thu Aug 13 10:27:24 2009 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Thu Aug 13 10:27:36 2009 Subject: svn commit: r196177 - stable/7/sys/dev/firewire Message-ID: <200908131027.n7DARNFs097748@svn.freebsd.org> Author: n_hibma Date: Thu Aug 13 10:27:22 2009 New Revision: 196177 URL: http://svn.freebsd.org/changeset/base/196177 Log: Revert he previous commit as requested by Sean Bruno. Modified: stable/7/sys/dev/firewire/fwohci.c Modified: stable/7/sys/dev/firewire/fwohci.c ============================================================================== --- stable/7/sys/dev/firewire/fwohci.c Thu Aug 13 10:26:34 2009 (r196176) +++ stable/7/sys/dev/firewire/fwohci.c Thu Aug 13 10:27:22 2009 (r196177) @@ -616,9 +616,10 @@ fwohci_init(struct fwohci_softc *sc, dev /* OHCI version */ reg = OREAD(sc, OHCI_VERSION); mver = (reg >> 16) & 0xff; + device_printf(dev, "OHCI version %x.%x (ROM=%d)\n", + mver, reg & 0xff, (reg>>24) & 1); if (mver < 1 || mver > 9) { - device_printf(dev, "invalid OHCI version %d (reg=0x%08x)\n", - mver, reg); + device_printf(dev, "invalid OHCI version\n"); return (ENXIO); } @@ -631,15 +632,10 @@ fwohci_init(struct fwohci_softc *sc, dev for (i = 0; i < 0x20; i++) if ((reg & (1 << i)) == 0) break; - if (i == 0) { - device_printf(dev, "0 isoc. channels"); - return ENXIO; - } sc->fc.nisodma = i; - - device_printf(dev, "OHCI version %x.%x (ROM=%d), %d isoc. channels\n", - mver, reg & 0xff, (reg>>24) & 1, - sc->fc.nisodma); + device_printf(dev, "No. of Isochronous channels is %d.\n", i); + if (i == 0) + return (ENXIO); sc->fc.arq = &sc->arrq.xferq; sc->fc.ars = &sc->arrs.xferq; @@ -1852,8 +1848,7 @@ fwohci_intr_core(struct fwohci_softc *sc /* Disable bus reset interrupt until sid recv. */ OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_PHY_BUS_R); - if (bootverbose) - device_printf(fc->dev, "BUS reset\n"); + device_printf(fc->dev, "BUS reset\n"); OWRITE(sc, FWOHCI_INTMASKCLR, OHCI_INT_CYC_LOST); OWRITE(sc, OHCI_LNKCTLCLR, OHCI_CNTL_CYCSRC); @@ -2469,8 +2464,7 @@ fwohci_ibr(struct firewire_comm *fc) struct fwohci_softc *sc; uint32_t fun; - if (bootverbose) - device_printf(fc->dev, "Initiate bus reset\n"); + device_printf(fc->dev, "Initiate bus reset\n"); sc = (struct fwohci_softc *)fc; /* From rnoland at FreeBSD.org Thu Aug 13 10:42:14 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Thu Aug 13 10:42:20 2009 Subject: svn commit: r196169 - stable/7/sys/pci In-Reply-To: <200908130820.n7D8KCgt093511@svn.freebsd.org> References: <200908130820.n7D8KCgt093511@svn.freebsd.org> Message-ID: <1250160126.1823.11.camel@balrog.2hip.net> On Thu, 2009-08-13 at 08:20 +0000, Nick Hibma wrote: > Author: n_hibma > Date: Thu Aug 13 08:20:12 2009 > New Revision: 196169 > URL: http://svn.freebsd.org/changeset/base/196169 > > Log: > Hide aperture size and stolen memory behind bootverbose. Why? This information can be useful and doesn't need to be buried in the verbose boot log. robert. > Modified: > stable/7/sys/pci/agp_i810.c > > Modified: stable/7/sys/pci/agp_i810.c > ============================================================================== > --- stable/7/sys/pci/agp_i810.c Thu Aug 13 08:18:29 2009 (r196168) > +++ stable/7/sys/pci/agp_i810.c Thu Aug 13 08:20:12 2009 (r196169) > @@ -474,12 +474,13 @@ agp_i810_attach(device_t dev) > agp_generic_detach(dev); > return EINVAL; > } > - if (sc->stolen > 0) { > - device_printf(dev, "detected %dk stolen memory\n", > - sc->stolen * 4); > + > + if (bootverbose) { > + device_print_prettyname(dev); > + if (sc->stolen > 0) > + printf("detected %dk stolen memory, ", sc->stolen * 4); > + printf("aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); > } > - device_printf(dev, "aperture size is %dM\n", > - sc->initial_aperture / 1024 / 1024); > > /* GATT address is already in there, make sure it's enabled */ > pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL); > @@ -664,9 +665,13 @@ agp_i810_attach(device_t dev) > gtt_size += 4; > > sc->stolen = (stolen - gtt_size) * 1024 / 4096; > - if (sc->stolen > 0) > - device_printf(dev, "detected %dk stolen memory\n", sc->stolen * 4); > - device_printf(dev, "aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); > + > + if (bootverbose) { > + device_print_prettyname(dev); > + if (sc->stolen > 0) > + printf("detected %dk stolen memory, ", sc->stolen * 4); > + printf("aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); > + } > > /* GATT address is already in there, make sure it's enabled */ > pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL); -- Robert Noland FreeBSD From jhb at FreeBSD.org Thu Aug 13 15:00:20 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Thu Aug 13 15:00:26 2009 Subject: svn commit: r196186 - in stable/7/usr.bin/locate: . locate Message-ID: <200908131500.n7DF0Iaf004398@svn.freebsd.org> Author: jhb Date: Thu Aug 13 15:00:18 2009 New Revision: 196186 URL: http://svn.freebsd.org/changeset/base/196186 Log: MFC: Move the check to ensure the locate database has the minimum required size when using mmap() before invoking mmap(). Modified: stable/7/usr.bin/locate/ (props changed) stable/7/usr.bin/locate/locate/fastfind.c stable/7/usr.bin/locate/locate/locate.c Modified: stable/7/usr.bin/locate/locate/fastfind.c ============================================================================== --- stable/7/usr.bin/locate/locate/fastfind.c Thu Aug 13 14:59:04 2009 (r196185) +++ stable/7/usr.bin/locate/locate/fastfind.c Thu Aug 13 15:00:18 2009 (r196186) @@ -154,9 +154,6 @@ fastfind /* init bigram table */ #ifdef FF_MMAP - if (len < (2*NBG)) - errx(1, "database too small: %s", database); - for (c = 0, p = bigram1, s = bigram2; c < NBG; c++, len-= 2) { p[c] = check_bigram_char(*paddr++); s[c] = check_bigram_char(*paddr++); Modified: stable/7/usr.bin/locate/locate/locate.c ============================================================================== --- stable/7/usr.bin/locate/locate/locate.c Thu Aug 13 14:59:04 2009 (r196185) +++ stable/7/usr.bin/locate/locate/locate.c Thu Aug 13 15:00:18 2009 (r196186) @@ -291,6 +291,8 @@ search_mmap(db, s) fstat(fd, &sb) == -1) err(1, "`%s'", db); len = sb.st_size; + if (len < (2*NBG)) + errx(1, "database too small: %s", db); if ((p = mmap((caddr_t)0, (size_t)len, PROT_READ, MAP_SHARED, From jhb at FreeBSD.org Thu Aug 13 15:06:09 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Thu Aug 13 15:06:25 2009 Subject: svn commit: r196189 - in stable/7/usr.sbin/acpi: . acpidump Message-ID: <200908131506.n7DF68qt004671@svn.freebsd.org> Author: jhb Date: Thu Aug 13 15:06:08 2009 New Revision: 196189 URL: http://svn.freebsd.org/changeset/base/196189 Log: MFC: Parse the System Resource Affinity Table ('SRAT') used to describe affinity relationships between CPUs and memory. Modified: stable/7/usr.sbin/acpi/ (props changed) stable/7/usr.sbin/acpi/acpidump/acpi.c stable/7/usr.sbin/acpi/acpidump/acpidump.h Modified: stable/7/usr.sbin/acpi/acpidump/acpi.c ============================================================================== --- stable/7/usr.sbin/acpi/acpidump/acpi.c Thu Aug 13 15:02:02 2009 (r196188) +++ stable/7/usr.sbin/acpi/acpidump/acpi.c Thu Aug 13 15:06:08 2009 (r196189) @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -57,6 +58,11 @@ static void acpi_print_intr(u_int32_t in static void acpi_print_apic(struct MADT_APIC *mp); static void acpi_handle_apic(struct ACPIsdt *sdp); static void acpi_handle_hpet(struct ACPIsdt *sdp); +static void acpi_print_srat_cpu(uint32_t apic_id, uint32_t proximity_domain, + uint32_t flags); +static void acpi_print_srat_memory(struct SRAT_memory *mp); +static void acpi_print_srat(struct SRATentry *srat); +static void acpi_handle_srat(struct ACPIsdt *sdp); static void acpi_print_sdt(struct ACPIsdt *sdp); static void acpi_print_fadt(struct ACPIsdt *sdp); static void acpi_print_facs(struct FACSbody *facs); @@ -256,7 +262,10 @@ static void acpi_print_apic(struct MADT_APIC *mp) { - printf("\tType=%s\n", apic_types[mp->type]); + if (mp->type < sizeof(apic_types) / sizeof(apic_types[0])) + printf("\tType=%s\n", apic_types[mp->type]); + else + printf("\tType=%d (unknown)\n", mp->type); switch (mp->type) { case ACPI_MADT_APIC_TYPE_LOCAL_APIC: acpi_print_local_apic(mp->body.local_apic.cpu_id, @@ -305,9 +314,6 @@ acpi_print_apic(struct MADT_APIC *mp) acpi_print_intr(mp->body.int_src.intr, mp->body.int_src.mps_flags); break; - default: - printf("\tUnknown type %d\n", (u_int)mp->type); - break; } } @@ -391,10 +397,92 @@ acpi_handle_mcfg(struct ACPIsdt *sdp) sizeof(*mcfg->s); for (i = 0; i < e; i++, mcfg++) { printf("\n"); - printf("\tBase Address= 0x%016jx\n", mcfg->s[i].baseaddr); - printf("\tSegment Group= 0x%04x\n", mcfg->s[i].seg_grp); - printf("\tStart Bus= %d\n", mcfg->s[i].start); - printf("\tEnd Bus= %d\n", mcfg->s[i].end); + printf("\tBase Address=0x%016jx\n", mcfg->s[i].baseaddr); + printf("\tSegment Group=0x%04x\n", mcfg->s[i].seg_grp); + printf("\tStart Bus=%d\n", mcfg->s[i].start); + printf("\tEnd Bus=%d\n", mcfg->s[i].end); + } + printf(END_COMMENT); +} + +static void +acpi_print_srat_cpu(uint32_t apic_id, uint32_t proximity_domain, + uint32_t flags) +{ + + printf("\tFlags={"); + if (flags & ACPI_SRAT_CPU_ENABLED) + printf("ENABLED"); + else + printf("DISABLED"); + printf("}\n"); + printf("\tAPIC ID=%d\n", apic_id); + printf("\tProximity Domain=%d\n", proximity_domain); +} + +static void +acpi_print_srat_memory(struct SRAT_memory *mp) +{ + + printf("\tFlags={"); + if (mp->flags & ACPI_SRAT_MEM_ENABLED) + printf("ENABLED"); + else + printf("DISABLED"); + if (mp->flags & ACPI_SRAT_MEM_HOT_PLUGGABLE) + printf(",HOT_PLUGGABLE"); + if (mp->flags & ACPI_SRAT_MEM_NON_VOLATILE) + printf(",NON_VOLATILE"); + printf("}\n"); + printf("\tBase Address=0x%016jx\n", (uintmax_t)mp->base_address); + printf("\tLength=0x%016jx\n", (uintmax_t)mp->length); + printf("\tProximity Domain=%d\n", mp->proximity_domain); +} + +const char *srat_types[] = { "CPU", "Memory", "X2APIC" }; + +static void +acpi_print_srat(struct SRATentry *srat) +{ + + if (srat->type < sizeof(srat_types) / sizeof(srat_types[0])) + printf("\tType=%s\n", srat_types[srat->type]); + else + printf("\tType=%d (unknown)\n", srat->type); + switch (srat->type) { + case ACPI_SRAT_TYPE_CPU_AFFINITY: + acpi_print_srat_cpu(srat->body.cpu.apic_id, + srat->body.cpu.proximity_domain_hi[2] << 24 | + srat->body.cpu.proximity_domain_hi[1] << 16 | + srat->body.cpu.proximity_domain_hi[0] << 0 | + srat->body.cpu.proximity_domain_lo, srat->body.cpu.flags); + break; + case ACPI_SRAT_TYPE_MEMORY_AFFINITY: + acpi_print_srat_memory(&srat->body.mem); + break; + case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY: + acpi_print_srat_cpu(srat->body.x2apic.apic_id, + srat->body.x2apic.proximity_domain, + srat->body.x2apic.flags); + break; + } +} + +static void +acpi_handle_srat(struct ACPIsdt *sdp) +{ + struct SRATbody *sratp; + struct SRATentry *entry; + + printf(BEGIN_COMMENT); + acpi_print_sdt(sdp); + sratp = (struct SRATbody *)sdp->body; + printf("\tTable Revision=%d\n", sratp->table_revision); + entry = sratp->body; + while (((uintptr_t)entry) - ((uintptr_t)sdp) < sdp->len) { + printf("\n"); + acpi_print_srat(entry); + entry = (struct SRATentry *)((char *)entry + entry->len); } printf(END_COMMENT); } @@ -708,6 +796,8 @@ acpi_handle_rsdt(struct ACPIsdt *rsdp) acpi_handle_ecdt(sdp); else if (!memcmp(sdp->signature, "MCFG", 4)) acpi_handle_mcfg(sdp); + else if (!memcmp(sdp->signature, "SRAT", 4)) + acpi_handle_srat(sdp); else { printf(BEGIN_COMMENT); acpi_print_sdt(sdp); Modified: stable/7/usr.sbin/acpi/acpidump/acpidump.h ============================================================================== --- stable/7/usr.sbin/acpi/acpidump/acpidump.h Thu Aug 13 15:02:02 2009 (r196188) +++ stable/7/usr.sbin/acpi/acpidump/acpidump.h Thu Aug 13 15:06:08 2009 (r196189) @@ -304,6 +304,56 @@ struct MCFGbody { } s[1] __packed; } __packed; +/* System Resource Affinity Table */ +struct SRAT_cpu { + uint8_t proximity_domain_lo; + uint8_t apic_id; + uint32_t flags; +#define ACPI_SRAT_CPU_ENABLED 0x00000001 + uint8_t sapic_eid; + uint8_t proximity_domain_hi[3]; + uint32_t reserved; +} __packed; + +struct SRAT_memory { + uint32_t proximity_domain; + uint16_t reserved; + uint64_t base_address; + uint64_t length; + uint32_t reserved1; + uint32_t flags; +#define ACPI_SRAT_MEM_ENABLED 0x00000001 +#define ACPI_SRAT_MEM_HOT_PLUGGABLE 0x00000002 +#define ACPI_SRAT_MEM_NON_VOLATILE 0x00000002 + uint64_t reserved2; +} __packed; + +struct SRAT_x2apic { + uint16_t reserved; + uint32_t proximity_domain; + uint32_t apic_id; + uint32_t flags; +} __packed; + +struct SRATentry { + uint8_t type; +#define ACPI_SRAT_TYPE_CPU_AFFINITY 0 +#define ACPI_SRAT_TYPE_MEMORY_AFFINITY 1 +#define ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY 2 + uint8_t len; + union { + struct SRAT_cpu cpu; + struct SRAT_memory mem; + struct SRAT_x2apic x2apic; + } body; +} __packed; + +struct SRATbody { + uint32_t table_revision; + uint64_t reserved; + struct SRATentry body[0]; +} __packed; + /* * Addresses to scan on ia32 for the RSD PTR. According to section 5.2.2 * of the ACPI spec, we only consider two regions for the base address: From bz at FreeBSD.org Thu Aug 13 15:16:31 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Thu Aug 13 15:16:43 2009 Subject: svn commit: r196192 - in stable/7/sys: . contrib/pf netinet netinet6 Message-ID: <200908131516.n7DFGUSC005047@svn.freebsd.org> Author: bz Date: Thu Aug 13 15:16:30 2009 New Revision: 196192 URL: http://svn.freebsd.org/changeset/base/196192 Log: MFC: r192649 Implement UDP control block support. Add udpcb support with own fields and flags for UDP instead of further sticking things into in_pcb and flags fields. Attach the udpcb to the inp_ppcb in the kernel. Note: the udp tunneling parts are not (yet) existing in 7 and thus were not merged. Reviewed by: rwatson Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/netinet/udp_usrreq.c stable/7/sys/netinet/udp_var.h stable/7/sys/netinet6/udp6_usrreq.c Modified: stable/7/sys/netinet/udp_usrreq.c ============================================================================== --- stable/7/sys/netinet/udp_usrreq.c Thu Aug 13 15:14:02 2009 (r196191) +++ stable/7/sys/netinet/udp_usrreq.c Thu Aug 13 15:16:30 2009 (r196192) @@ -138,6 +138,7 @@ SYSCTL_INT(_net_inet_udp, OID_AUTO, sore struct inpcbhead udb; /* from udp_var.h */ struct inpcbinfo udbinfo; +static uma_zone_t udpcb_zone; #ifndef UDBHASHSIZE #define UDBHASHSIZE 128 @@ -156,6 +157,7 @@ udp_zone_change(void *tag) { uma_zone_set_max(udbinfo.ipi_zone, maxsockets); + uma_zone_set_max(udpcb_zone, maxsockets); } static int @@ -179,9 +181,14 @@ udp_init(void) &udbinfo.ipi_hashmask); udbinfo.ipi_porthashbase = hashinit(UDBHASHSIZE, M_PCB, &udbinfo.ipi_porthashmask); - udbinfo.ipi_zone = uma_zcreate("udpcb", sizeof(struct inpcb), NULL, - NULL, udp_inpcb_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); + udbinfo.ipi_zone = uma_zcreate("udp_inpcb", sizeof(struct inpcb), + NULL, NULL, udp_inpcb_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); uma_zone_set_max(udbinfo.ipi_zone, maxsockets); + + udpcb_zone = uma_zcreate("udpcb", sizeof(struct udpcb), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); + uma_zone_set_max(udpcb_zone, maxsockets); + EVENTHANDLER_REGISTER(maxsockets_change, udp_zone_change, NULL, EVENTHANDLER_PRI_ANY); TUNABLE_INT_FETCH("net.inet.udp.soreceive_dgram_enabled", @@ -194,6 +201,25 @@ udp_init(void) } } +int +udp_newudpcb(struct inpcb *inp) +{ + struct udpcb *up; + + up = uma_zalloc(udpcb_zone, M_NOWAIT | M_ZERO); + if (up == NULL) + return (ENOBUFS); + inp->inp_ppcb = up; + return (0); +} + +void +udp_discardcb(struct udpcb *up) +{ + + uma_zfree(udpcb_zone, up); +} + /* * Subroutine of udp_input(), which appends the provided mbuf chain to the * passed pcb/socket. The caller must provide a sockaddr_in via udp_in that @@ -1129,10 +1155,19 @@ udp_attach(struct socket *so, int proto, } inp = (struct inpcb *)so->so_pcb; - INP_INFO_WUNLOCK(&udbinfo); inp->inp_vflag |= INP_IPV4; inp->inp_ip_ttl = ip_defttl; + + error = udp_newudpcb(inp); + if (error) { + in_pcbdetach(inp); + in_pcbfree(inp); + INP_INFO_WUNLOCK(&udbinfo); + return (error); + } + INP_WUNLOCK(inp); + INP_INFO_WUNLOCK(&udbinfo); return (0); } @@ -1205,6 +1240,7 @@ static void udp_detach(struct socket *so) { struct inpcb *inp; + struct udpcb *up; inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp_detach: inp == NULL")); @@ -1212,9 +1248,13 @@ udp_detach(struct socket *so) ("udp_detach: not disconnected")); INP_INFO_WLOCK(&udbinfo); INP_WLOCK(inp); + up = intoudpcb(inp); + KASSERT(up != NULL, ("%s: up == NULL", __func__)); + inp->inp_ppcb = NULL; in_pcbdetach(inp); in_pcbfree(inp); INP_INFO_WUNLOCK(&udbinfo); + udp_discardcb(up); } static int Modified: stable/7/sys/netinet/udp_var.h ============================================================================== --- stable/7/sys/netinet/udp_var.h Thu Aug 13 15:14:02 2009 (r196191) +++ stable/7/sys/netinet/udp_var.h Thu Aug 13 15:16:30 2009 (r196192) @@ -51,6 +51,17 @@ struct udpiphdr { #define ui_ulen ui_u.uh_ulen #define ui_sum ui_u.uh_sum +/* + * UDP control block; one per udp. + */ +struct udpcb { + void *u_pspare; + u_int u_flags; /* Generic UDP flags. */ +}; + +#define intoudpcb(ip) ((struct udpcb *)(ip)->inp_ppcb) +#define sotoudpcb(so) (intoudpcb(sotoinpcb(so))) + struct udpstat { /* input statistics: */ u_long udps_ipackets; /* total input packets */ @@ -102,6 +113,9 @@ extern struct udpstat udpstat; extern int udp_blackhole; extern int udp_log_in_vain; +int udp_newudpcb(struct inpcb *); +void udp_discardcb(struct udpcb *); + void udp_ctlinput(int, struct sockaddr *, void *); void udp_init(void); void udp_input(struct mbuf *, int); Modified: stable/7/sys/netinet6/udp6_usrreq.c ============================================================================== --- stable/7/sys/netinet6/udp6_usrreq.c Thu Aug 13 15:14:02 2009 (r196191) +++ stable/7/sys/netinet6/udp6_usrreq.c Thu Aug 13 15:16:30 2009 (r196192) @@ -739,7 +739,6 @@ udp6_attach(struct socket *so, int proto return (error); } inp = (struct inpcb *)so->so_pcb; - INP_INFO_WUNLOCK(&udbinfo); inp->inp_vflag |= INP_IPV6; if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) inp->inp_vflag |= INP_IPV4; @@ -752,7 +751,16 @@ udp6_attach(struct socket *so, int proto * which may match an IPv4-mapped IPv6 address. */ inp->inp_ip_ttl = ip_defttl; + + error = udp_newudpcb(inp); + if (error) { + in_pcbdetach(inp); + in_pcbfree(inp); + INP_INFO_WUNLOCK(&udbinfo); + return (error); + } INP_WUNLOCK(inp); + INP_INFO_WUNLOCK(&udbinfo); return (0); } @@ -883,15 +891,19 @@ static void udp6_detach(struct socket *so) { struct inpcb *inp; + struct udpcb *up; inp = sotoinpcb(so); KASSERT(inp != NULL, ("udp6_detach: inp == NULL")); INP_INFO_WLOCK(&udbinfo); INP_WLOCK(inp); + up = intoudpcb(inp); + KASSERT(up != NULL, ("%s: up == NULL", __func__)); in_pcbdetach(inp); in_pcbfree(inp); INP_INFO_WUNLOCK(&udbinfo); + udp_discardcb(up); } static int From bz at FreeBSD.org Thu Aug 13 15:45:30 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Thu Aug 13 15:45:36 2009 Subject: svn commit: r196192 - in stable/7/sys: . contrib/pf netinet netinet6 In-Reply-To: <200908131516.n7DFGUSC005047@svn.freebsd.org> References: <200908131516.n7DFGUSC005047@svn.freebsd.org> Message-ID: <20090813151939.H93661@maildrop.int.zabbadoz.net> On Thu, 13 Aug 2009, Bjoern A. Zeeb wrote: > Author: bz > Date: Thu Aug 13 15:16:30 2009 > New Revision: 196192 > URL: http://svn.freebsd.org/changeset/base/196192 > > Log: > MFC: r192649 > > Implement UDP control block support. > > Add udpcb support with own fields and flags for UDP instead > of further sticking things into in_pcb and flags fields. > Attach the udpcb to the inp_ppcb in the kernel. > > Note: the udp tunneling parts are not (yet) existing in 7 > and thus were not merged. > > Reviewed by: rwatson I forgot: Submitted by: jhb (original 7.x version before detour via HEAD) Not that there are consumers out there using an UDPCB in 7-STABLE already and thus can reduce their patchset now, this gives us the possibility to generate a IPSEC NAT-T patch that will be compatible with what is in FreeBSD 8 and HEAD (9) reducing problems on maintainance for ports and and tools (I'll post that patch in a bit on net@). We can also MFC the generic in-kernel UDP tunneling support now, even if the SCTP changes might not be MFCable, externel kernel modules can still make use of this then. > Modified: > stable/7/sys/ (props changed) > stable/7/sys/contrib/pf/ (props changed) > stable/7/sys/netinet/udp_usrreq.c > stable/7/sys/netinet/udp_var.h > stable/7/sys/netinet6/udp6_usrreq.c -- Bjoern A. Zeeb What was I talking about and who are you again? From jhb at FreeBSD.org Thu Aug 13 17:51:27 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Thu Aug 13 17:51:39 2009 Subject: svn commit: r196197 - in stable/7/sys: . contrib/pf fs/unionfs kern Message-ID: <200908131751.n7DHpQpU008608@svn.freebsd.org> Author: jhb Date: Thu Aug 13 17:51:26 2009 New Revision: 196197 URL: http://svn.freebsd.org/changeset/base/196197 Log: MFC: Fix some LORs between vnode locks and filedescriptor table locks. - Don't grab the filedesc lock just to read fd_cmask. - Drop vnode locks earlier when mounting the root filesystem and before sanitizing stdin/out/err file descriptors during execve(). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/fs/unionfs/union_subr.c stable/7/sys/kern/kern_exec.c stable/7/sys/kern/vfs_mount.c stable/7/sys/kern/vfs_syscalls.c Modified: stable/7/sys/fs/unionfs/union_subr.c ============================================================================== --- stable/7/sys/fs/unionfs/union_subr.c Thu Aug 13 17:09:45 2009 (r196196) +++ stable/7/sys/fs/unionfs/union_subr.c Thu Aug 13 17:51:26 2009 (r196197) @@ -488,9 +488,7 @@ unionfs_create_uppervattr_core(struct un } break; default: /* UNIONFS_TRADITIONAL */ - FILEDESC_SLOCK(td->td_proc->p_fd); uva->va_mode = 0777 & ~td->td_proc->p_fd->fd_cmask; - FILEDESC_SUNLOCK(td->td_proc->p_fd); uva->va_uid = ump->um_uid; uva->va_gid = ump->um_gid; break; Modified: stable/7/sys/kern/kern_exec.c ============================================================================== --- stable/7/sys/kern/kern_exec.c Thu Aug 13 17:09:45 2009 (r196196) +++ stable/7/sys/kern/kern_exec.c Thu Aug 13 17:51:26 2009 (r196197) @@ -615,8 +615,8 @@ interpret: * allocate memory, so temporarily drop the process lock. */ PROC_UNLOCK(p); - setugidsafety(td); VOP_UNLOCK(imgp->vp, 0, td); + setugidsafety(td); error = fdcheckstd(td); vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY, td); if (error != 0) Modified: stable/7/sys/kern/vfs_mount.c ============================================================================== --- stable/7/sys/kern/vfs_mount.c Thu Aug 13 17:09:45 2009 (r196196) +++ stable/7/sys/kern/vfs_mount.c Thu Aug 13 17:51:26 2009 (r196197) @@ -1083,9 +1083,10 @@ vfs_domount( vfs_event_signal(NULL, VQ_MOUNT, 0); if (VFS_ROOT(mp, LK_EXCLUSIVE, &newdp, td)) panic("mount: lost mount"); - mountcheckdirs(vp, newdp); - vput(newdp); + VOP_UNLOCK(newdp, 0, td); VOP_UNLOCK(vp, 0, td); + mountcheckdirs(vp, newdp); + vrele(newdp); if ((mp->mnt_flag & MNT_RDONLY) == 0) error = vfs_allocate_syncvnode(mp); vfs_unbusy(mp, td); @@ -1468,8 +1469,10 @@ set_rootvnode(struct thread *td) if (VFS_ROOT(TAILQ_FIRST(&mountlist), LK_EXCLUSIVE, &rootvnode, td)) panic("Cannot find root vnode"); + VOP_UNLOCK(rootvnode, 0, td); + p = td->td_proc; - FILEDESC_SLOCK(p->p_fd); + FILEDESC_XLOCK(p->p_fd); if (p->p_fd->fd_cdir != NULL) vrele(p->p_fd->fd_cdir); @@ -1481,9 +1484,7 @@ set_rootvnode(struct thread *td) p->p_fd->fd_rdir = rootvnode; VREF(rootvnode); - FILEDESC_SUNLOCK(p->p_fd); - - VOP_UNLOCK(rootvnode, 0, td); + FILEDESC_XUNLOCK(p->p_fd); } /* Modified: stable/7/sys/kern/vfs_syscalls.c ============================================================================== --- stable/7/sys/kern/vfs_syscalls.c Thu Aug 13 17:09:45 2009 (r196196) +++ stable/7/sys/kern/vfs_syscalls.c Thu Aug 13 17:51:26 2009 (r196197) @@ -1238,10 +1238,8 @@ restart: return (EEXIST); } else { VATTR_NULL(&vattr); - FILEDESC_SLOCK(td->td_proc->p_fd); vattr.va_mode = (mode & ALLPERMS) & ~td->td_proc->p_fd->fd_cmask; - FILEDESC_SUNLOCK(td->td_proc->p_fd); vattr.va_rdev = dev; whiteout = 0; @@ -1351,9 +1349,7 @@ restart: } VATTR_NULL(&vattr); vattr.va_type = VFIFO; - FILEDESC_SLOCK(td->td_proc->p_fd); vattr.va_mode = (mode & ALLPERMS) & ~td->td_proc->p_fd->fd_cmask; - FILEDESC_SUNLOCK(td->td_proc->p_fd); #ifdef MAC error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd, &vattr); @@ -1564,9 +1560,7 @@ restart: goto restart; } VATTR_NULL(&vattr); - FILEDESC_SLOCK(td->td_proc->p_fd); vattr.va_mode = ACCESSPERMS &~ td->td_proc->p_fd->fd_cmask; - FILEDESC_SUNLOCK(td->td_proc->p_fd); #ifdef MAC vattr.va_type = VLNK; error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd, @@ -3502,9 +3496,7 @@ restart: } VATTR_NULL(&vattr); vattr.va_type = VDIR; - FILEDESC_SLOCK(td->td_proc->p_fd); vattr.va_mode = (mode & ACCESSPERMS) &~ td->td_proc->p_fd->fd_cmask; - FILEDESC_SUNLOCK(td->td_proc->p_fd); #ifdef MAC error = mac_check_vnode_create(td->td_ucred, nd.ni_dvp, &nd.ni_cnd, &vattr); From dougb at FreeBSD.org Thu Aug 13 22:49:15 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Thu Aug 13 22:49:26 2009 Subject: svn commit: r196169 - stable/7/sys/pci In-Reply-To: <1250160126.1823.11.camel@balrog.2hip.net> References: <200908130820.n7D8KCgt093511@svn.freebsd.org> <1250160126.1823.11.camel@balrog.2hip.net> Message-ID: <4A849222.3090004@FreeBSD.org> Robert Noland wrote: > On Thu, 2009-08-13 at 08:20 +0000, Nick Hibma wrote: >> Author: n_hibma >> Date: Thu Aug 13 08:20:12 2009 >> New Revision: 196169 >> URL: http://svn.freebsd.org/changeset/base/196169 >> >> Log: >> Hide aperture size and stolen memory behind bootverbose. > > Why? This information can be useful and doesn't need to be buried in > the verbose boot log. Useful to developers maybe, but not to the average user. Personally I'd like to see most of what we print at boot time hidden behind bootverbose, but that's just me. Doug -- This .signature sanitized for your protection From rnoland at FreeBSD.org Thu Aug 13 23:09:32 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Thu Aug 13 23:09:37 2009 Subject: svn commit: r196169 - stable/7/sys/pci In-Reply-To: <4A849222.3090004@FreeBSD.org> References: <200908130820.n7D8KCgt093511@svn.freebsd.org> <1250160126.1823.11.camel@balrog.2hip.net> <4A849222.3090004@FreeBSD.org> Message-ID: <1250204964.33905.7.camel@balrog.2hip.net> On Thu, 2009-08-13 at 15:22 -0700, Doug Barton wrote: > Robert Noland wrote: > > On Thu, 2009-08-13 at 08:20 +0000, Nick Hibma wrote: > >> Author: n_hibma > >> Date: Thu Aug 13 08:20:12 2009 > >> New Revision: 196169 > >> URL: http://svn.freebsd.org/changeset/base/196169 > >> > >> Log: > >> Hide aperture size and stolen memory behind bootverbose. > > > > Why? This information can be useful and doesn't need to be buried in > > the verbose boot log. > > Useful to developers maybe, but not to the average user. While it certainly isn't critical information for the user to see, it is informative and not excessively chatty. At any rate this change should not have been made directly to 7. If people want to discuss this for HEAD, I will argue there... robert. > Personally I'd like to see most of what we print at boot time hidden > behind bootverbose, but that's just me. > > > Doug > -- Robert Noland FreeBSD From rwatson at FreeBSD.org Fri Aug 14 13:28:52 2009 From: rwatson at FreeBSD.org (Robert Watson) Date: Fri Aug 14 13:28:57 2009 Subject: svn commit: r196170 - stable/7/sys/dev/firewire In-Reply-To: <20090813083236.GR1884@deviant.kiev.zoral.com.ua> References: <200908130824.n7D8OwO9093632@svn.freebsd.org> <20090813083236.GR1884@deviant.kiev.zoral.com.ua> Message-ID: On Thu, 13 Aug 2009, Kostik Belousov wrote: >> Log: >> Compact some output. Move some behind bootverbose. >> >> Modified: >> stable/7/sys/dev/firewire/fwohci.c >> > Please revert this commit and your previous r196169. Patches shall go into > HEAD first and then merged back to stable branch after settle period. > > [I consider USB changes as relevant only to stable/7, due to new USB stack > in HEAD ?]. You have received several requests to backout your changes, including this one from a member of the release engineering team. Please comply. Robert N M Watson Computer Laboratory University of Cambridge From remko at FreeBSD.org Fri Aug 14 19:36:55 2009 From: remko at FreeBSD.org (Remko Lodder) Date: Fri Aug 14 19:37:06 2009 Subject: svn commit: r196218 - stable/7/usr.sbin/arp Message-ID: <200908141936.n7EJatN2045525@svn.freebsd.org> Author: remko Date: Fri Aug 14 19:36:54 2009 New Revision: 196218 URL: http://svn.freebsd.org/changeset/base/196218 Log: Remove bogus char cast. PR: 118014 Submitted by: Gardner Bell Approved by: re (rwatson), imp (mentor, implicit) MFC after: immediate Approved by: imp (mentor, implicit) Modified: stable/7/usr.sbin/arp/ (props changed) stable/7/usr.sbin/arp/arp.c Modified: stable/7/usr.sbin/arp/arp.c ============================================================================== --- stable/7/usr.sbin/arp/arp.c Fri Aug 14 19:30:59 2009 (r196217) +++ stable/7/usr.sbin/arp/arp.c Fri Aug 14 19:36:54 2009 (r196218) @@ -120,7 +120,7 @@ main(int argc, char *argv[]) int aflag = 0; /* do it for all entries */ while ((ch = getopt(argc, argv, "andfsSi:")) != -1) - switch((char)ch) { + switch(ch) { case 'a': aflag = 1; break; From n_hibma at FreeBSD.org Fri Aug 14 21:07:42 2009 From: n_hibma at FreeBSD.org (Nick Hibma) Date: Fri Aug 14 21:07:58 2009 Subject: svn commit: r196225 - stable/7/sys/pci Message-ID: <200908142107.n7EL7fGl047798@svn.freebsd.org> Author: n_hibma Date: Fri Aug 14 21:07:41 2009 New Revision: 196225 URL: http://svn.freebsd.org/changeset/base/196225 Log: Revert r196169. Modified: stable/7/sys/pci/agp_i810.c Modified: stable/7/sys/pci/agp_i810.c ============================================================================== --- stable/7/sys/pci/agp_i810.c Fri Aug 14 21:05:08 2009 (r196224) +++ stable/7/sys/pci/agp_i810.c Fri Aug 14 21:07:41 2009 (r196225) @@ -474,13 +474,12 @@ agp_i810_attach(device_t dev) agp_generic_detach(dev); return EINVAL; } - - if (bootverbose) { - device_print_prettyname(dev); - if (sc->stolen > 0) - printf("detected %dk stolen memory, ", sc->stolen * 4); - printf("aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); + if (sc->stolen > 0) { + device_printf(dev, "detected %dk stolen memory\n", + sc->stolen * 4); } + device_printf(dev, "aperture size is %dM\n", + sc->initial_aperture / 1024 / 1024); /* GATT address is already in there, make sure it's enabled */ pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL); @@ -665,13 +664,9 @@ agp_i810_attach(device_t dev) gtt_size += 4; sc->stolen = (stolen - gtt_size) * 1024 / 4096; - - if (bootverbose) { - device_print_prettyname(dev); - if (sc->stolen > 0) - printf("detected %dk stolen memory, ", sc->stolen * 4); - printf("aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); - } + if (sc->stolen > 0) + device_printf(dev, "detected %dk stolen memory\n", sc->stolen * 4); + device_printf(dev, "aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); /* GATT address is already in there, make sure it's enabled */ pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL); From remko at elvandar.org Fri Aug 14 21:30:03 2009 From: remko at elvandar.org (Remko Lodder) Date: Fri Aug 14 21:30:09 2009 Subject: svn commit: r196218 - stable/7/usr.sbin/arp In-Reply-To: <200908141936.n7EJatN2045525@svn.freebsd.org> References: <200908141936.n7EJatN2045525@svn.freebsd.org> Message-ID: On Aug 14, 2009, at 9:36 PM, Remko Lodder wrote: > Author: remko > Date: Fri Aug 14 19:36:54 2009 > New Revision: 196218 > URL: http://svn.freebsd.org/changeset/base/196218 > > Log: > Remove bogus char cast. > > PR: 118014 > Submitted by: Gardner Bell > Approved by: re (rwatson), imp (mentor, implicit) > MFC after: immediate > Sorry, I should have kept a little time in between the commit to stable/7. I was just so excited to do the MFC's that I instantly did stable/7 as well, where I normally kept a few days in between. If someone objects to this I can revert it and MFC it a few days later. Pointyhat for instant MFC: remko Pointed out by: simon -- /"\ Best regards, | remko@FreeBSD.org \ / Remko Lodder | remko@EFnet X http://www.evilcoder.org/ | / \ ASCII Ribbon Campaign | Against HTML Mail and News From rnoland at FreeBSD.org Fri Aug 14 21:35:25 2009 From: rnoland at FreeBSD.org (Robert Noland) Date: Fri Aug 14 21:35:57 2009 Subject: svn commit: r196225 - stable/7/sys/pci In-Reply-To: <200908142107.n7EL7fGl047798@svn.freebsd.org> References: <200908142107.n7EL7fGl047798@svn.freebsd.org> Message-ID: <1250285717.21931.0.camel@balrog.2hip.net> On Fri, 2009-08-14 at 21:07 +0000, Nick Hibma wrote: > Author: n_hibma > Date: Fri Aug 14 21:07:41 2009 > New Revision: 196225 > URL: http://svn.freebsd.org/changeset/base/196225 > > Log: > Revert r196169. Thanks, robert. > Modified: > stable/7/sys/pci/agp_i810.c > > Modified: stable/7/sys/pci/agp_i810.c > ============================================================================== > --- stable/7/sys/pci/agp_i810.c Fri Aug 14 21:05:08 2009 (r196224) > +++ stable/7/sys/pci/agp_i810.c Fri Aug 14 21:07:41 2009 (r196225) > @@ -474,13 +474,12 @@ agp_i810_attach(device_t dev) > agp_generic_detach(dev); > return EINVAL; > } > - > - if (bootverbose) { > - device_print_prettyname(dev); > - if (sc->stolen > 0) > - printf("detected %dk stolen memory, ", sc->stolen * 4); > - printf("aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); > + if (sc->stolen > 0) { > + device_printf(dev, "detected %dk stolen memory\n", > + sc->stolen * 4); > } > + device_printf(dev, "aperture size is %dM\n", > + sc->initial_aperture / 1024 / 1024); > > /* GATT address is already in there, make sure it's enabled */ > pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL); > @@ -665,13 +664,9 @@ agp_i810_attach(device_t dev) > gtt_size += 4; > > sc->stolen = (stolen - gtt_size) * 1024 / 4096; > - > - if (bootverbose) { > - device_print_prettyname(dev); > - if (sc->stolen > 0) > - printf("detected %dk stolen memory, ", sc->stolen * 4); > - printf("aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); > - } > + if (sc->stolen > 0) > + device_printf(dev, "detected %dk stolen memory\n", sc->stolen * 4); > + device_printf(dev, "aperture size is %dM\n", sc->initial_aperture / 1024 / 1024); > > /* GATT address is already in there, make sure it's enabled */ > pgtblctl = bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL); -- Robert Noland FreeBSD From stas at FreeBSD.org Sat Aug 15 15:41:10 2009 From: stas at FreeBSD.org (Stanislav Sedov) Date: Sat Aug 15 15:41:27 2009 Subject: svn commit: r196249 - in stable/7/lib/libc: . arm/string Message-ID: <200908151541.n7FFfA4C075853@svn.freebsd.org> Author: stas Date: Sat Aug 15 15:41:10 2009 New Revision: 196249 URL: http://svn.freebsd.org/changeset/base/196249 Log: - MFC r194583: Fix strncmp on arm. Return 0 as result without performing the main cycle only if the len passed is equal to 0. If end address overflows use last possible address as the end address. Modified: stable/7/lib/libc/ (props changed) stable/7/lib/libc/arm/string/strncmp.S Modified: stable/7/lib/libc/arm/string/strncmp.S ============================================================================== --- stable/7/lib/libc/arm/string/strncmp.S Sat Aug 15 15:40:30 2009 (r196248) +++ stable/7/lib/libc/arm/string/strncmp.S Sat Aug 15 15:41:10 2009 (r196249) @@ -33,13 +33,17 @@ __FBSDID("$FreeBSD$"); ENTRY(strncmp) -/* if ((len - 1) < 0) return 0 */ - subs r2, r2, #1 - movmi r0, #0 - movmi pc, lr +/* if (len == 0) return 0 */ + cmp r2, #0 + moveq r0, #0 + moveq pc, lr /* ip == last src address to compare */ - add ip, r0, r2 + adds ip, r0, r2 + sub ip, ip, #1 +/* Use last possible address on overflow. */ + movcs ip, #0 + subcs ip, ip, #1 1: ldrb r2, [r0], #1 ldrb r3, [r1], #1 From stas at FreeBSD.org Sat Aug 15 15:48:11 2009 From: stas at FreeBSD.org (Stanislav Sedov) Date: Sat Aug 15 15:48:28 2009 Subject: svn commit: r196250 - in stable/7/sys: . contrib/pf dev/sound/pci Message-ID: <200908151548.n7FFmAVK076135@svn.freebsd.org> Author: stas Date: Sat Aug 15 15:48:10 2009 New Revision: 196250 URL: http://svn.freebsd.org/changeset/base/196250 Log: - MFC r191308, r191310: Properly unlock mutex on failure in channel_trigger. Before this the function just returned with the mutex held. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/sound/pci/envy24.c stable/7/sys/dev/sound/pci/envy24ht.c Modified: stable/7/sys/dev/sound/pci/envy24.c ============================================================================== --- stable/7/sys/dev/sound/pci/envy24.c Sat Aug 15 15:41:10 2009 (r196249) +++ stable/7/sys/dev/sound/pci/envy24.c Sat Aug 15 15:48:10 2009 (r196250) @@ -1721,6 +1721,7 @@ envy24chan_trigger(kobj_t obj, void *dat struct sc_info *sc = ch->parent; u_int32_t ptr; int slot; + int error = 0; #if 0 int i; @@ -1742,8 +1743,10 @@ envy24chan_trigger(kobj_t obj, void *dat sc->caps[0].minspeed = sc->caps[0].maxspeed = sc->speed; sc->caps[1].minspeed = sc->caps[1].maxspeed = sc->speed; } - else if (ch->speed != 0 && ch->speed != sc->speed) - return -1; + else if (ch->speed != 0 && ch->speed != sc->speed) { + error = -1; + goto fail; + } if (ch->speed == 0) ch->channel->speed = sc->speed; /* start or enable channel */ @@ -1773,16 +1776,20 @@ envy24chan_trigger(kobj_t obj, void *dat #if(0) device_printf(sc->dev, "envy24chan_trigger(): emldmawr\n"); #endif - if (ch->run != 1) - return -1; + if (ch->run != 1) { + error = -1; + goto fail; + } ch->emldma(ch); break; case PCMTRIG_EMLDMARD: #if(0) device_printf(sc->dev, "envy24chan_trigger(): emldmard\n"); #endif - if (ch->run != 1) - return -1; + if (ch->run != 1) { + error = -1; + goto fail; + } ch->emldma(ch); break; case PCMTRIG_ABORT: @@ -1814,9 +1821,9 @@ envy24chan_trigger(kobj_t obj, void *dat } break; } +fail: snd_mtxunlock(sc->lock); - - return 0; + return (error); } static int Modified: stable/7/sys/dev/sound/pci/envy24ht.c ============================================================================== --- stable/7/sys/dev/sound/pci/envy24ht.c Sat Aug 15 15:41:10 2009 (r196249) +++ stable/7/sys/dev/sound/pci/envy24ht.c Sat Aug 15 15:48:10 2009 (r196250) @@ -1668,6 +1668,7 @@ envy24htchan_trigger(kobj_t obj, void *d struct sc_info *sc = ch->parent; u_int32_t ptr; int slot; + int error = 0; #if 0 int i; @@ -1689,8 +1690,10 @@ envy24htchan_trigger(kobj_t obj, void *d sc->caps[0].minspeed = sc->caps[0].maxspeed = sc->speed; sc->caps[1].minspeed = sc->caps[1].maxspeed = sc->speed; } - else if (ch->speed != 0 && ch->speed != sc->speed) - return -1; + else if (ch->speed != 0 && ch->speed != sc->speed) { + error = -1; + goto fail; + } if (ch->speed == 0) ch->channel->speed = sc->speed; /* start or enable channel */ @@ -1720,16 +1723,20 @@ envy24htchan_trigger(kobj_t obj, void *d #if(0) device_printf(sc->dev, "envy24htchan_trigger(): emldmawr\n"); #endif - if (ch->run != 1) - return -1; + if (ch->run != 1) { + error = -1; + goto fail; + } ch->emldma(ch); break; case PCMTRIG_EMLDMARD: #if(0) device_printf(sc->dev, "envy24htchan_trigger(): emldmard\n"); #endif - if (ch->run != 1) - return -1; + if (ch->run != 1) { + error = -1; + goto fail; + } ch->emldma(ch); break; case PCMTRIG_ABORT: @@ -1759,9 +1766,9 @@ envy24htchan_trigger(kobj_t obj, void *d } break; } +fail: snd_mtxunlock(sc->lock); - - return 0; + return (error); } static int From stas at FreeBSD.org Sat Aug 15 15:52:21 2009 From: stas at FreeBSD.org (Stanislav Sedov) Date: Sat Aug 15 15:52:26 2009 Subject: svn commit: r196251 - in stable/7/sys: . contrib/pf dev/cpuctl Message-ID: <200908151552.n7FFqKJQ076297@svn.freebsd.org> Author: stas Date: Sat Aug 15 15:52:20 2009 New Revision: 196251 URL: http://svn.freebsd.org/changeset/base/196251 Log: - MFC r195081: - Don't zero data field in case of MSR write operation. Before this change the value written to MSR register was always 0 regardless of value passed by user. - Use proper data pointer when performing AMD microcode update. Previously, the pointer to user-space data has been provided instead, which is totally incorrect. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cpuctl/cpuctl.c Modified: stable/7/sys/dev/cpuctl/cpuctl.c ============================================================================== --- stable/7/sys/dev/cpuctl/cpuctl.c Sat Aug 15 15:48:10 2009 (r196250) +++ stable/7/sys/dev/cpuctl/cpuctl.c Sat Aug 15 15:52:20 2009 (r196251) @@ -223,14 +223,17 @@ cpuctl_do_msr(int cpu, cpuctl_msr_args_t * Explicitly clear cpuid data to avoid returning stale * info */ - data->data = 0; DPRINTF("[cpuctl,%d]: operating on MSR %#0x for %d cpu\n", __LINE__, data->msr, cpu); oldcpu = td->td_oncpu; is_bound = cpu_sched_is_bound(td); set_cpu(cpu, td); - ret = cmd == CPUCTL_RDMSR ? rdmsr_safe(data->msr, &data->data) : - wrmsr_safe(data->msr, data->data); + if (cmd == CPUCTL_RDMSR) { + data->data = 0; + ret = rdmsr_safe(data->msr, &data->data); + } else { + ret = wrmsr_safe(data->msr, data->data); + } restore_cpu(oldcpu, is_bound, td); return (ret); } @@ -369,7 +372,7 @@ update_amd(int cpu, cpuctl_update_args_t /* * Perform update. */ - wrmsr_safe(MSR_K8_UCODE_UPDATE, (uintptr_t)args->data); + wrmsr_safe(MSR_K8_UCODE_UPDATE, (uintptr_t)ptr); /* * Serialize instruction flow. From stas at FreeBSD.org Sat Aug 15 16:15:50 2009 From: stas at FreeBSD.org (Stanislav Sedov) Date: Sat Aug 15 16:15:57 2009 Subject: svn commit: r196253 - in stable/7: share/man/man4 sys sys/contrib/pf sys/dev/cpuctl sys/sys usr.sbin/cpucontrol Message-ID: <200908151615.n7FGFoEb077460@svn.freebsd.org> Author: stas Date: Sat Aug 15 16:15:50 2009 New Revision: 196253 URL: http://svn.freebsd.org/changeset/base/196253 Log: - Merge r195189: - Add support to atomically set/clear individual bits of a MSR register via cpuctl(4) driver. Two new CPUCTL_MSRSBIT and CPUCTL_MSRCBIT ioctl(2) calls treat the data field of the argument struct passed as a mask and set/clear bits of the MSR register according to the mask value. - Allow user to perform atomic bitwise AND and OR operaions on MSR registers via cpucontrol(8) utility. Two new operations ("&=" and "|=") have been added. The first one applies bitwise AND operaion between the current contents of the MSR register and the mask, and the second performs bitwise OR. The argument can be optionally prefixed with "~" inversion operator. This allows one to mimic the "clear bit" behavior by using the command like this: cpucontrol -m 0x10&=~0x02 # clear the second bit of TSC MSR Inversion operator support in all modes (assignment, OR, AND). Modified: stable/7/share/man/man4/ (props changed) stable/7/share/man/man4/cpuctl.4 stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cpuctl/cpuctl.c stable/7/sys/sys/cpuctl.h stable/7/usr.sbin/cpucontrol/ (props changed) stable/7/usr.sbin/cpucontrol/cpucontrol.8 stable/7/usr.sbin/cpucontrol/cpucontrol.c Modified: stable/7/share/man/man4/cpuctl.4 ============================================================================== --- stable/7/share/man/man4/cpuctl.4 Sat Aug 15 16:04:36 2009 (r196252) +++ stable/7/share/man/man4/cpuctl.4 Sat Aug 15 16:15:50 2009 (r196253) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 31, 2008 +.Dd June 30, 2009 .Dt CPUCTL 4 .Os .Sh NAME @@ -81,6 +81,11 @@ typedef struct { uint64_t data; } cpuctl_msr_args_t; .Ed +.It Dv CPUCTL_MSRSBIT Fa cpuctl_msr_args_t *args +.It Dv CPUCTL_MSRCBIT Fa cpuctl_msr_args_t *args +Set/clear MSR bits according to the mask given in the +.Va data +field. .It Dv CPUCTL_CPUID Fa cpuctl_cpuid_args_t *args Retrieve CPUID information. Arguments are supplied in Modified: stable/7/sys/dev/cpuctl/cpuctl.c ============================================================================== --- stable/7/sys/dev/cpuctl/cpuctl.c Sat Aug 15 16:04:36 2009 (r196252) +++ stable/7/sys/dev/cpuctl/cpuctl.c Sat Aug 15 16:15:50 2009 (r196253) @@ -159,6 +159,8 @@ cpuctl_ioctl(struct cdev *dev, u_long cm case CPUCTL_RDMSR: ret = cpuctl_do_msr(cpu, (cpuctl_msr_args_t *)data, cmd, td); break; + case CPUCTL_MSRSBIT: + case CPUCTL_MSRCBIT: case CPUCTL_WRMSR: ret = priv_check(td, PRIV_CPUCTL_WRMSR); if (ret != 0) @@ -212,6 +214,7 @@ cpuctl_do_cpuid(int cpu, cpuctl_cpuid_ar static int cpuctl_do_msr(int cpu, cpuctl_msr_args_t *data, u_long cmd, struct thread *td) { + uint64_t reg; int is_bound = 0; int oldcpu; int ret; @@ -231,9 +234,22 @@ cpuctl_do_msr(int cpu, cpuctl_msr_args_t if (cmd == CPUCTL_RDMSR) { data->data = 0; ret = rdmsr_safe(data->msr, &data->data); - } else { + } else if (cmd == CPUCTL_WRMSR) { ret = wrmsr_safe(data->msr, data->data); - } + } else if (cmd == CPUCTL_MSRSBIT) { + critical_enter(); + ret = rdmsr_safe(data->msr, ®); + if (ret == 0) + ret = wrmsr_safe(data->msr, reg | data->data); + critical_exit(); + } else if (cmd == CPUCTL_MSRCBIT) { + critical_enter(); + ret = rdmsr_safe(data->msr, ®); + if (ret == 0) + ret = wrmsr_safe(data->msr, reg & ~data->data); + critical_exit(); + } else + panic("[cpuctl,%d]: unknown operation requested: %lu", __LINE__, cmd); restore_cpu(oldcpu, is_bound, td); return (ret); } Modified: stable/7/sys/sys/cpuctl.h ============================================================================== --- stable/7/sys/sys/cpuctl.h Sat Aug 15 16:04:36 2009 (r196252) +++ stable/7/sys/sys/cpuctl.h Sat Aug 15 16:15:50 2009 (r196253) @@ -48,5 +48,7 @@ typedef struct { #define CPUCTL_WRMSR _IOWR('c', 2, cpuctl_msr_args_t) #define CPUCTL_CPUID _IOWR('c', 3, cpuctl_cpuid_args_t) #define CPUCTL_UPDATE _IOWR('c', 4, cpuctl_update_args_t) +#define CPUCTL_MSRSBIT _IOWR('c', 5, cpuctl_msr_args_t) +#define CPUCTL_MSRCBIT _IOWR('c', 6, cpuctl_msr_args_t) #endif /* _CPUCTL_H_ */ Modified: stable/7/usr.sbin/cpucontrol/cpucontrol.8 ============================================================================== --- stable/7/usr.sbin/cpucontrol/cpucontrol.8 Sat Aug 15 16:04:36 2009 (r196252) +++ stable/7/usr.sbin/cpucontrol/cpucontrol.8 Sat Aug 15 16:15:50 2009 (r196253) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 4, 2008 +.Dd June 30, 2009 .Dt CPUCONTROL 8 .Os .Sh NAME @@ -35,7 +35,25 @@ device. .Sh SYNOPSIS .Nm .Op Fl vh -.Fl m Ar msr Ns Op = Ns Ar value +.Fl m Ar msr +.Bk +.Ar device +.Ek +.Nm +.Op Fl vh +.Fl m Ar msr Ns = Ns Ar value +.Bk +.Ar device +.Ek +.Nm +.Op Fl vh +.Fl m Ar msr Ns &= Ns Ar mask +.Bk +.Ar device +.Ek +.Nm +.Op Fl vh +.Fl m Ar msr Ns |= Ns Ar mask .Bk .Ar device .Ek @@ -67,8 +85,32 @@ The following options are available: Where to look for microcode images. The option can be specified multiple times. .It Fl m Ar msr Ns Op = Ns Ar value -Read/write the specified MSR. -Both the MSR and the value should be given as a hex number. +Show value of the specified MSR. +MSR register number should be given as a hexadecimal number. +.It Fl m Ar msr Ns = Ns Ar value +Store the +.Ar value +in the specified MSR register. +The +.Ar value +argument can be prefixed with ~ operator. +In this case the inverted value of argument will be stored in the register. +.It Fl m Ar msr Ns &= Ns Ar mask +Store the result of bitwise AND operation between +.Ar mask +and the current MSR value in the MSR register. +The +.Ar mask +argument can be prefixed with ~ operator. +In this case the inverted value of mask will be used. +.It Fl m Ar msr Ns |= Ns Ar mask +Store the result of bitwise OR operation between +.Ar mask +and the current MSR value in the MSR register. +The +.Ar mask +argument can be prefixed with ~ operator. +In this case the inverted value of mask will be used. .It Fl i Ar level Retrieve CPUID info. Level should be given as a hex number. @@ -94,7 +136,15 @@ will read the contents of TSC MSR from C .Pp To set the CPU 0 TSC MSR register value to 0x1 issue .Pp -.Dq Li "cpucontrol -m 0x10=0x1 /dev/cpuctl0" +.Dq Li "cpucontrol -m 0x10=0x1 /dev/cpuctl0" . +.Pp +The following command will clear the second bit of TSC register: +.Pp +.Dq Li "cpucontrol -m 0x10&=~0x02 /dev/cpuctl0" . +.Pp +The following command will set the forth and second bit of TSC register: +.Pp +.Dq Li "cpucontrol -m 0x10|=0x0a /dev/cpuctl0" . .Pp The command .Pp Modified: stable/7/usr.sbin/cpucontrol/cpucontrol.c ============================================================================== --- stable/7/usr.sbin/cpucontrol/cpucontrol.c Sat Aug 15 16:04:36 2009 (r196252) +++ stable/7/usr.sbin/cpucontrol/cpucontrol.c Sat Aug 15 16:15:50 2009 (r196253) @@ -60,6 +60,12 @@ int verbosity_level = 0; #define FLAG_M 0x02 #define FLAG_U 0x04 +#define OP_INVAL 0x00 +#define OP_READ 0x01 +#define OP_WRITE 0x02 +#define OP_OR 0x04 +#define OP_AND 0x08 + #define HIGH(val) (uint32_t)(((val) >> 32) & 0xffffffff) #define LOW(val) (uint32_t)((val) & 0xffffffff) @@ -166,28 +172,64 @@ do_msr(const char *cmdarg, const char *d { unsigned int msr; cpuctl_msr_args_t args; + size_t len; + uint64_t data = 0; + unsigned long command; + int do_invert = 0, op; int fd, error; - int wr = 0; - char *p; char *endptr; + char *p; assert(cmdarg != NULL); assert(dev != NULL); + len = strlen(cmdarg); + if (len == 0) { + WARNX(0, "MSR register expected"); + usage(); + /* NOTREACHED */ + } - p = strchr(cmdarg, '='); - if (p != NULL) { - wr = 1; - *p++ = '\0'; - args.data = strtoull(p, &endptr, 16); - if (*p == '\0' || *endptr != '\0') { - WARNX(0, "incorrect MSR value: %s", p); - usage(); - /* NOTREACHED */ + /* + * Parse command string. + */ + msr = strtoul(cmdarg, &endptr, 16); + switch (*endptr) { + case '\0': + op = OP_READ; + break; + case '=': + op = OP_WRITE; + break; + case '&': + op = OP_AND; + endptr++; + break; + case '|': + op = OP_OR; + endptr++; + break; + default: + op = OP_INVAL; + } + if (op != OP_READ) { /* Complex operation. */ + if (*endptr != '=') + op = OP_INVAL; + else { + p = ++endptr; + if (*p == '~') { + do_invert = 1; + p++; + } + data = strtoull(p, &endptr, 16); + if (*p == '\0' || *endptr != '\0') { + WARNX(0, "argument required: %s", cmdarg); + usage(); + /* NOTREACHED */ + } } } - msr = strtoul(cmdarg, &endptr, 16); - if (*cmdarg == '\0' || *endptr != '\0') { - WARNX(0, "incorrect MSR register: %s", cmdarg); + if (op == OP_INVAL) { + WARNX(0, "invalid operator: %s", cmdarg); usage(); /* NOTREACHED */ } @@ -196,20 +238,39 @@ do_msr(const char *cmdarg, const char *d * Fill ioctl argument structure. */ args.msr = msr; - fd = open(dev, wr == 0 ? O_RDONLY : O_WRONLY); + if ((do_invert != 0) ^ (op == OP_AND)) + args.data = ~data; + else + args.data = data; + switch (op) { + case OP_READ: + command = CPUCTL_RDMSR; + break; + case OP_WRITE: + command = CPUCTL_WRMSR; + break; + case OP_OR: + command = CPUCTL_MSRSBIT; + break; + case OP_AND: + command = CPUCTL_MSRCBIT; + break; + default: + abort(); + } + fd = open(dev, op == OP_READ ? O_RDONLY : O_WRONLY); if (fd < 0) { WARN(0, "error opening %s for %s", dev, - wr == 0 ? "reading" : "writing"); + op == OP_READ ? "reading" : "writing"); return (1); } - error = ioctl(fd, wr == 0 ? CPUCTL_RDMSR : CPUCTL_WRMSR, &args); + error = ioctl(fd, command, &args); if (error < 0) { - WARN(0, "ioctl(%s, %s)", dev, - wr == 0 ? "CPUCTL_RDMSR" : "CPUCTL_WRMSR"); + WARN(0, "ioctl(%s, %lu)", dev, command); close(fd); return (1); } - if (wr == 0) + if (op == OP_READ) fprintf(stdout, "MSR 0x%x: 0x%.8x 0x%.8x\n", msr, HIGH(args.data), LOW(args.data)); close(fd); From jhb at FreeBSD.org Mon Aug 17 17:31:43 2009 From: jhb at FreeBSD.org (John Baldwin) Date: Mon Aug 17 17:31:49 2009 Subject: svn commit: r196339 - stable/7/usr.sbin/sysinstall Message-ID: <200908171731.n7HHVg1h085276@svn.freebsd.org> Author: jhb Date: Mon Aug 17 17:31:42 2009 New Revision: 196339 URL: http://svn.freebsd.org/changeset/base/196339 Log: MFC 196147: Fix references to the kernel distributions to use the correct names (uppercase). Modified: stable/7/usr.sbin/sysinstall/ (props changed) stable/7/usr.sbin/sysinstall/install.c stable/7/usr.sbin/sysinstall/sysinstall.8 Modified: stable/7/usr.sbin/sysinstall/install.c ============================================================================== --- stable/7/usr.sbin/sysinstall/install.c Mon Aug 17 17:13:17 2009 (r196338) +++ stable/7/usr.sbin/sysinstall/install.c Mon Aug 17 17:31:42 2009 (r196339) @@ -903,7 +903,7 @@ installFixupKernel(dialogMenuItem *self, if (RunningAsInit) { /* * Install something as /boot/kernel. Prefer SMP - * over generic--this should handle the case where + * over GENERIC--this should handle the case where * both SMP and GENERIC are installed (otherwise we * select the one kernel that was installed). * Modified: stable/7/usr.sbin/sysinstall/sysinstall.8 ============================================================================== --- stable/7/usr.sbin/sysinstall/sysinstall.8 Mon Aug 17 17:13:17 2009 (r196338) +++ stable/7/usr.sbin/sysinstall/sysinstall.8 Mon Aug 17 17:31:42 2009 (r196339) @@ -411,9 +411,9 @@ Possible distribution values are: .Bl -tag -width indentxx .It Li base The base binary distribution. -.It Li generic +.It Li GENERIC The GENERIC kernel. -.It Li smp +.It Li SMP A kernel suitable for multiple processor systems. .It Li doc Miscellaneous documentation From jkim at FreeBSD.org Mon Aug 17 18:02:47 2009 From: jkim at FreeBSD.org (Jung-uk Kim) Date: Mon Aug 17 18:02:58 2009 Subject: svn commit: r196340 - in stable/7/sys: . contrib/pf net Message-ID: <200908171802.n7HI2kkN086020@svn.freebsd.org> Author: jkim Date: Mon Aug 17 18:02:46 2009 New Revision: 196340 URL: http://svn.freebsd.org/changeset/base/196340 Log: MFC: (partial) r196150 Always embed pointer to BPF JIT function in BPF descriptor to avoid inconsistency when opt_bpf.h is not included. Note: bpf_buffer.c and bpf_zerocopy.c do not exist on stable/7. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/net/bpf.c stable/7/sys/net/bpfdesc.h Modified: stable/7/sys/net/bpf.c ============================================================================== --- stable/7/sys/net/bpf.c Mon Aug 17 17:31:42 2009 (r196339) +++ stable/7/sys/net/bpf.c Mon Aug 17 18:02:46 2009 (r196340) @@ -1288,6 +1288,9 @@ void bpf_tap(struct bpf_if *bp, u_char *pkt, u_int pktlen) { struct bpf_d *d; +#ifdef BPF_JITTER + bpf_jit_filter *bf; +#endif u_int slen; int gottime; struct timeval tv; @@ -1298,8 +1301,9 @@ bpf_tap(struct bpf_if *bp, u_char *pkt, BPFD_LOCK(d); ++d->bd_rcount; #ifdef BPF_JITTER - if (bpf_jitter_enable != 0 && d->bd_bfilter != NULL) - slen = (*(d->bd_bfilter->func))(pkt, pktlen, pktlen); + bf = bpf_jitter_enable != 0 ? d->bd_bfilter : NULL; + if (bf != NULL) + slen = (*(bf->func))(pkt, pktlen, pktlen); else #endif slen = bpf_filter(d->bd_rfilter, pkt, pktlen, pktlen); @@ -1354,6 +1358,9 @@ void bpf_mtap(struct bpf_if *bp, struct mbuf *m) { struct bpf_d *d; +#ifdef BPF_JITTER + bpf_jit_filter *bf; +#endif u_int pktlen, slen; int gottime; struct timeval tv; @@ -1375,11 +1382,10 @@ bpf_mtap(struct bpf_if *bp, struct mbuf BPFD_LOCK(d); ++d->bd_rcount; #ifdef BPF_JITTER + bf = bpf_jitter_enable != 0 ? d->bd_bfilter : NULL; /* XXX We cannot handle multiple mbufs. */ - if (bpf_jitter_enable != 0 && d->bd_bfilter != NULL && - m->m_next == NULL) - slen = (*(d->bd_bfilter->func))(mtod(m, u_char *), - pktlen, pktlen); + if (bf != NULL && m->m_next == NULL) + slen = (*(bf->func))(mtod(m, u_char *), pktlen, pktlen); else #endif slen = bpf_filter(d->bd_rfilter, (u_char *)m, pktlen, 0); Modified: stable/7/sys/net/bpfdesc.h ============================================================================== --- stable/7/sys/net/bpfdesc.h Mon Aug 17 17:31:42 2009 (r196339) +++ stable/7/sys/net/bpfdesc.h Mon Aug 17 18:02:46 2009 (r196340) @@ -71,9 +71,7 @@ struct bpf_d { u_long bd_rtout; /* Read timeout in 'ticks' */ struct bpf_insn *bd_rfilter; /* read filter code */ struct bpf_insn *bd_wfilter; /* write filter code */ -#ifdef BPF_JITTER - bpf_jit_filter *bd_bfilter; /* binary filter code */ -#endif + void *bd_bfilter; /* binary filter code */ u_long bd_rcount; /* number of packets received */ u_long bd_dcount; /* number of packets dropped */ From simon at FreeBSD.org Wed Aug 19 21:33:10 2009 From: simon at FreeBSD.org (Simon L. Nielsen) Date: Wed Aug 19 21:33:27 2009 Subject: svn commit: r196394 - stable/7/bin/df Message-ID: <200908192133.n7JLX9xX066003@svn.freebsd.org> Author: simon Date: Wed Aug 19 21:33:09 2009 New Revision: 196394 URL: http://svn.freebsd.org/changeset/base/196394 Log: MFC r193629: Make "human-readable" (-H/-h) output also "humanize" inode counts. Base 10 is always used for the inode counts as I could not think of any reason base 2 inode counts would be useful. Minor mdoc markup fix to df(1) while here anyway. Modified: stable/7/bin/df/ (props changed) stable/7/bin/df/df.1 stable/7/bin/df/df.c Modified: stable/7/bin/df/df.1 ============================================================================== --- stable/7/bin/df/df.1 Wed Aug 19 21:01:32 2009 (r196393) +++ stable/7/bin/df/df.1 Wed Aug 19 21:33:09 2009 (r196394) @@ -78,15 +78,20 @@ this overrides the .Ev BLOCKSIZE specification from the environment. .It Fl H -"Human-readable" output. +.Dq Human-readable +output. Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the number of digits to four or fewer using base 10 for sizes. .It Fl h -"Human-readable" output. +.Dq Human-readable +output. Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte in order to reduce the number of digits to four or fewer using base 2 for sizes. +Inodes statistics, if enabled with +.Fl i , +are always printed in base 10. .It Fl i Include statistics on the number of free inodes. .It Fl k Modified: stable/7/bin/df/df.c ============================================================================== --- stable/7/bin/df/df.c Wed Aug 19 21:01:32 2009 (r196393) +++ stable/7/bin/df/df.c Wed Aug 19 21:33:09 2009 (r196394) @@ -365,6 +365,23 @@ prthumanval(int64_t bytes) } /* + * Print an inode count in "human-readable" format. + */ +static void +prthumanvalinode(int64_t bytes) +{ + char buf[6]; + int flags; + + flags = HN_NOSPACE | HN_DECIMAL | HN_DIVISOR_1000; + + humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1), + bytes, "", HN_AUTOSCALE, flags); + + (void)printf(" %5s", buf); +} + +/* * Convert statfs returned file system size into BLOCKSIZE units. * Attempts to avoid overflow for large file systems. */ @@ -406,8 +423,10 @@ prtstat(struct statfs *sfsp, struct maxw mwp->mntfrom, "Filesystem", mwp->total, header, mwp->used, "Used", mwp->avail, "Avail"); if (iflag) { - mwp->iused = imax(mwp->iused, (int)strlen(" iused")); - mwp->ifree = imax(mwp->ifree, (int)strlen("ifree")); + mwp->iused = imax(hflag ? 0 : mwp->iused, + (int)strlen(" iused")); + mwp->ifree = imax(hflag ? 0 : mwp->ifree, + (int)strlen("ifree")); (void)printf(" %*s %*s %%iused", mwp->iused - 2, "iused", mwp->ifree, "ifree"); } @@ -431,8 +450,15 @@ prtstat(struct statfs *sfsp, struct maxw if (iflag) { inodes = sfsp->f_files; used = inodes - sfsp->f_ffree; - (void)printf(" %*jd %*jd %4.0f%% ", mwp->iused, (intmax_t)used, - mwp->ifree, (intmax_t)sfsp->f_ffree, inodes == 0 ? 100.0 : + if (hflag) { + (void)printf(" "); + prthumanvalinode(used); + prthumanvalinode(sfsp->f_ffree); + } else { + (void)printf(" %*jd %*jd", mwp->iused, (intmax_t)used, + mwp->ifree, (intmax_t)sfsp->f_ffree); + } + (void)printf(" %4.0f%% ", inodes == 0 ? 100.0 : (double)used / (double)inodes * 100.0); } else (void)printf(" "); From stas at FreeBSD.org Sat Aug 22 09:09:45 2009 From: stas at FreeBSD.org (Stanislav Sedov) Date: Sat Aug 22 09:09:52 2009 Subject: svn commit: r196430 - stable/7/usr.sbin/pstat Message-ID: <200908220909.n7M99iad049377@svn.freebsd.org> Author: stas Date: Sat Aug 22 09:09:44 2009 New Revision: 196430 URL: http://svn.freebsd.org/changeset/base/196430 Log: - MFC r196244: - Avoid overflowing the swap size counters in human-readable mode by introducing the new CONVERT_BLOCKS macro which operates on sizes already converted to number of blocks. With this macro it is not longer needed to perform needless multiplication by blocksize just to divide on it later in CONVERT macro. Modified: stable/7/usr.sbin/pstat/ (props changed) stable/7/usr.sbin/pstat/pstat.c Modified: stable/7/usr.sbin/pstat/pstat.c ============================================================================== --- stable/7/usr.sbin/pstat/pstat.c Sat Aug 22 00:56:47 2009 (r196429) +++ stable/7/usr.sbin/pstat/pstat.c Sat Aug 22 09:09:44 2009 (r196430) @@ -479,6 +479,7 @@ getfiles(char **abuf, size_t *alen) */ #define CONVERT(v) ((int64_t)(v) * pagesize / blocksize) +#define CONVERT_BLOCKS(v) ((int64_t)(v) * pagesize) static struct kvm_swap swtot; static int nswdev; @@ -511,10 +512,10 @@ print_swap_line(const char *devname, int printf("%-15s %*jd ", devname, hlen, CONVERT(nblks)); if (humanflag) { humanize_number(usedbuf, sizeof(usedbuf), - CONVERT(blocksize * bused), "", + CONVERT_BLOCKS(bused), "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); humanize_number(availbuf, sizeof(availbuf), - CONVERT(blocksize * bavail), "", + CONVERT_BLOCKS(bavail), "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); printf("%8s %8s %5.0f%%\n", usedbuf, availbuf, bpercent); } else { From stas at FreeBSD.org Sat Aug 22 09:17:50 2009 From: stas at FreeBSD.org (Stanislav Sedov) Date: Sat Aug 22 09:18:19 2009 Subject: svn commit: r196431 - in stable/7/sys: . arm/at91 contrib/pf Message-ID: <200908220917.n7M9HnSJ049586@svn.freebsd.org> Author: stas Date: Sat Aug 22 09:17:49 2009 New Revision: 196431 URL: http://svn.freebsd.org/changeset/base/196431 Log: - MFC r196246: - Proprely intialize UART parameters at probe stage, so uart(4) will initialize the FIFO memory correctly on attach. Before that this values was intialized in only in at91_usart_bus_attach which is called after the uart(4) memory allocation happens. Modified: stable/7/sys/ (props changed) stable/7/sys/arm/at91/uart_dev_at91usart.c stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/arm/at91/uart_dev_at91usart.c ============================================================================== --- stable/7/sys/arm/at91/uart_dev_at91usart.c Sat Aug 22 09:09:44 2009 (r196430) +++ stable/7/sys/arm/at91/uart_dev_at91usart.c Sat Aug 22 09:17:49 2009 (r196431) @@ -305,6 +305,10 @@ static kobj_method_t at91_usart_methods[ int at91_usart_bus_probe(struct uart_softc *sc) { + + sc->sc_txfifosz = USART_BUFFER_SIZE; + sc->sc_rxfifosz = USART_BUFFER_SIZE; + sc->sc_hwiflow = 0; return (0); } @@ -342,10 +346,6 @@ at91_usart_bus_attach(struct uart_softc atsc->flags |= HAS_TIMEOUT; WR4(&sc->sc_bas, USART_IDR, 0xffffffff); - sc->sc_txfifosz = USART_BUFFER_SIZE; - sc->sc_rxfifosz = USART_BUFFER_SIZE; - sc->sc_hwiflow = 0; - #ifndef SKYEYE_WORKAROUNDS /* * Allocate DMA tags and maps From bz at FreeBSD.org Tue Aug 25 11:44:17 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Tue Aug 25 11:44:38 2009 Subject: svn commit: r196537 - in stable/7/sys: . contrib/pf netinet Message-ID: <200908251144.n7PBiH8m026684@svn.freebsd.org> Author: bz Date: Tue Aug 25 11:44:17 2009 New Revision: 196537 URL: http://svn.freebsd.org/changeset/base/196537 Log: MFC r182841: Add a second KASSERT checking for len >= 0 in the tcp output path. This is different to the first one (as len gets updated between those two) and would have caught various edge cases (read bugs) at a well defined place I had been debugging the last months instead of triggering (random) panics further down the call graph. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/netinet/tcp_output.c Modified: stable/7/sys/netinet/tcp_output.c ============================================================================== --- stable/7/sys/netinet/tcp_output.c Tue Aug 25 10:09:25 2009 (r196536) +++ stable/7/sys/netinet/tcp_output.c Tue Aug 25 11:44:17 2009 (r196537) @@ -391,7 +391,7 @@ after_sack_rexmit: } /* len will be >= 0 after this point. */ - KASSERT(len >= 0, ("%s: len < 0", __func__)); + KASSERT(len >= 0, ("[%s:%d]: len < 0", __func__, __LINE__)); /* * Automatic sizing of send socket buffer. Often the send buffer @@ -741,6 +741,12 @@ send: /*#endif*/ /* + * This KASSERT is here to catch edge cases at a well defined place. + * Before, those had triggered (random) panic conditions further down. + */ + KASSERT(len >= 0, ("[%s:%d]: len < 0", __func__, __LINE__)); + + /* * Grab a header mbuf, attaching a copy of data to * be transmitted, and initialize the header from * the template for sends on this connection. From bz at FreeBSD.org Tue Aug 25 12:32:16 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Tue Aug 25 12:32:23 2009 Subject: svn commit: r196538 - in stable/7/sys: . contrib/pf kern Message-ID: <200908251232.n7PCWGt1027748@svn.freebsd.org> Author: bz Date: Tue Aug 25 12:32:16 2009 New Revision: 196538 URL: http://svn.freebsd.org/changeset/base/196538 Log: MFC r182842: Catch a possible NULL pointer deref in case the offsets got mangled somehow. As a consequence we may now get an unexpected result(*). Catch that error cases with a well defined panic giving appropriate pointers to ease debugging. (*) While the concensus was that the case should never happen unless there was a bug, noone was definitively sure. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/kern/uipc_sockbuf.c Modified: stable/7/sys/kern/uipc_sockbuf.c ============================================================================== --- stable/7/sys/kern/uipc_sockbuf.c Tue Aug 25 11:44:17 2009 (r196537) +++ stable/7/sys/kern/uipc_sockbuf.c Tue Aug 25 12:32:16 2009 (r196538) @@ -930,11 +930,13 @@ sbsndptr(struct sockbuf *sb, u_int off, /* Advance by len to be as close as possible for the next transmit. */ for (off = off - sb->sb_sndptroff + len - 1; - off > 0 && off >= m->m_len; + off > 0 && m != NULL && off >= m->m_len; m = m->m_next) { sb->sb_sndptroff += m->m_len; off -= m->m_len; } + if (off > 0 && m == NULL) + panic("%s: sockbuf %p and mbuf %p clashing", __func__, sb, ret); sb->sb_sndptr = m; return (ret); From bz at FreeBSD.org Tue Aug 25 13:01:51 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Tue Aug 25 13:02:08 2009 Subject: svn commit: r196539 - in stable/7/sys: . contrib/pf netinet6 Message-ID: <200908251301.n7PD1paj028682@svn.freebsd.org> Author: bz Date: Tue Aug 25 13:01:51 2009 New Revision: 196539 URL: http://svn.freebsd.org/changeset/base/196539 Log: MFC r191433: Compare protosw pointer with NULL. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/netinet6/ip6_input.c Modified: stable/7/sys/netinet6/ip6_input.c ============================================================================== --- stable/7/sys/netinet6/ip6_input.c Tue Aug 25 12:32:16 2009 (r196538) +++ stable/7/sys/netinet6/ip6_input.c Tue Aug 25 13:01:51 2009 (r196539) @@ -152,7 +152,7 @@ ip6_init(void) panic("sizeof(protosw) != sizeof(ip6protosw)"); #endif pr = (struct ip6protosw *)pffindproto(PF_INET6, IPPROTO_RAW, SOCK_RAW); - if (pr == 0) + if (pr == NULL) panic("ip6_init"); /* Initialize the entire ip6_protox[] array to IPPROTO_RAW. */ From bz at FreeBSD.org Tue Aug 25 13:04:14 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Tue Aug 25 13:04:30 2009 Subject: svn commit: r196540 - in stable/7/sys: . contrib/pf sys Message-ID: <200908251304.n7PD4DES028772@svn.freebsd.org> Author: bz Date: Tue Aug 25 13:04:13 2009 New Revision: 196540 URL: http://svn.freebsd.org/changeset/base/196540 Log: MFC r191529: Whitespace (use tabs like for all other lines). Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/sys/mbuf.h Modified: stable/7/sys/sys/mbuf.h ============================================================================== --- stable/7/sys/sys/mbuf.h Tue Aug 25 13:01:51 2009 (r196539) +++ stable/7/sys/sys/mbuf.h Tue Aug 25 13:04:13 2009 (r196540) @@ -853,7 +853,7 @@ struct mbuf *m_unshare(struct mbuf *, in #define PACKET_TAG_PF 21 /* PF + ALTQ information */ #define PACKET_TAG_RTSOCKFAM 25 /* rtsock sa family */ #define PACKET_TAG_IPOPTIONS 27 /* Saved IP options */ -#define PACKET_TAG_CARP 28 /* CARP info */ +#define PACKET_TAG_CARP 28 /* CARP info */ /* Specific cookies and tags. */ From bms at FreeBSD.org Tue Aug 25 13:39:15 2009 From: bms at FreeBSD.org (Bruce M Simpson) Date: Tue Aug 25 13:39:22 2009 Subject: svn commit: r196541 - stable/7/etc Message-ID: <200908251339.n7PDdEcD029562@svn.freebsd.org> Author: bms Date: Tue Aug 25 13:39:14 2009 New Revision: 196541 URL: http://svn.freebsd.org/changeset/base/196541 Log: MFC r179014: Add support for /conf/T/M/remount_optional. The rc.initdiskless functionality is used by NanoBSD to allow configuration files to live on a separate configuration slice, which acts as NVRAM, whilst the system image is mounted read-only. Normally, if the remount command fails during boot, this is regarded as a fatal error. If /conf/T/M/remount_optional is present, this error is non-fatal. If the file is not present, the default behaviour is unchanged. This is very useful for people building live CD images using FreeBSD, where the NVRAM lives somewhere completely differently from the system image, and may be present on removable media which is not present during the initial boot. Modified: stable/7/etc/ (props changed) stable/7/etc/rc.initdiskless stable/7/etc/termcap.small (props changed) Modified: stable/7/etc/rc.initdiskless ============================================================================== --- stable/7/etc/rc.initdiskless Tue Aug 25 13:04:13 2009 (r196540) +++ stable/7/etc/rc.initdiskless Tue Aug 25 13:39:14 2009 (r196541) @@ -69,6 +69,10 @@ # /conf/1.2.3.4/foo/remount contains "mount -o ro /dev/ad0s3", # then /dev/ad0s3 will be be mounted on /conf/1.2.3.4/foo/ # +# /conf/T/M/remount_optional +# If this file exists, then failure to execute the mount +# command contained in /conf/T/M/remount is non-fatal. +# # /conf/T/M/diskless_remount # The contents of the file points to an NFS filesystem, # possibly followed by mount_nfs options. If the server name @@ -147,8 +151,12 @@ log() { # # checks error code and drops into shell on failure. # if shell exits, terminates script as well as /etc/rc. +# if remount_optional exists under the mountpoint, skip this check. # chkerr() { + lastitem () ( n=$(($# - 1)) ; shift $n ; echo $1 ) + mountpoint="$(lastitem $2)" + [ -r $mountpoint/remount_optional ] && ( echo "$2 failed: ignoring due to remount_optional" ; return ) case $1 in 0) ;; From bms at FreeBSD.org Tue Aug 25 13:40:46 2009 From: bms at FreeBSD.org (Bruce M Simpson) Date: Tue Aug 25 13:40:58 2009 Subject: svn commit: r196542 - stable/7/etc Message-ID: <200908251340.n7PDekQn029645@svn.freebsd.org> Author: bms Date: Tue Aug 25 13:40:46 2009 New Revision: 196542 URL: http://svn.freebsd.org/changeset/base/196542 Log: MFC r182895: Add support to rc.initdiskless for /conf/T/M/remount_subdir. This allows the location of the configuration data to be relocated within the filesystem containing it. A nullfs mount is used in order to achieve this. Obtained from: XORP, Inc. Modified: stable/7/etc/ (props changed) stable/7/etc/rc.initdiskless stable/7/etc/termcap.small (props changed) Modified: stable/7/etc/rc.initdiskless ============================================================================== --- stable/7/etc/rc.initdiskless Tue Aug 25 13:39:14 2009 (r196541) +++ stable/7/etc/rc.initdiskless Tue Aug 25 13:40:46 2009 (r196542) @@ -73,6 +73,16 @@ # If this file exists, then failure to execute the mount # command contained in /conf/T/M/remount is non-fatal. # +# /conf/T/M/remount_subdir +# If this file exists, then the behaviour of /conf/T/M/remount +# changes as follows: +# 1. /conf/T/M/remount is invoked to mount the root of the +# filesystem where the configuration data exists on a +# temporary mountpoint. +# 2. /conf/T/M/remount_subdir is then invoked to mount a +# *subdirectory* of the filesystem mounted by +# /conf/T/M/remount on /conf/T/M/. +# # /conf/T/M/diskless_remount # The contents of the file points to an NFS filesystem, # possibly followed by mount_nfs options. If the server name @@ -296,10 +306,33 @@ for i in ${templates} ; do # remount. Beware, the command is in the file itself! if [ -f $j/remount ]; then - nfspt=`/bin/cat $j/remount` - $nfspt $j - chkerr $? "$nfspt $j" - to_umount="$j ${to_umount}" # XXX hope it is really a mount! + if [ -f $j/remount_subdir ]; then + k="/conf.tmp/$i/$subdir" + [ -d $k ] || continue + + # Mount the filesystem root where the config data is + # on the temporary mount point. + nfspt=`/bin/cat $j/remount` + $nfspt $k + chkerr $? "$nfspt $k" + + # Now use a nullfs mount to get the data where we + # really want to see it. + remount_subdir=`/bin/cat $j/remount_subdir` + remount_subdir_cmd="mount -t nullfs $k/$remount_subdir" + + $remount_subdir_cmd $j + chkerr $? "$remount_subdir_cmd $j" + + # XXX check order -- we must force $k to be unmounted + # after j, as j depends on k. + to_umount="$j $k ${to_umount}" + else + nfspt=`/bin/cat $j/remount` + $nfspt $j + chkerr $? "$nfspt $j" + to_umount="$j ${to_umount}" # XXX hope it is really a mount! + fi fi # NFS remount From bz at FreeBSD.org Tue Aug 25 15:54:54 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Tue Aug 25 15:55:06 2009 Subject: svn commit: r196544 - in stable/7: sys sys/contrib/pf sys/kern usr.bin/cpuset usr.sbin/jail Message-ID: <200908251554.n7PFsrRQ032504@svn.freebsd.org> Author: bz Date: Tue Aug 25 15:54:52 2009 New Revision: 196544 URL: http://svn.freebsd.org/changeset/base/196544 Log: Backout r191596: Document an issue of jail(8) in conjunction with cpuset(1). MFC r191639: Prevent a superuser inside a jail from modifying the dedicated root cpuset of that jail. Processes inside the jail will still be able to change child sets. A superuser outside of a jail will still be able to change the jail cpuset and thus limit the number of cpus available to the jail. Problem reported by: 000.fbsd@quip.cz (Miroslav Lachman) PR: kern/134050 Reviewed by: jeff Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/kern/kern_cpuset.c stable/7/usr.bin/cpuset/cpuset.1 stable/7/usr.sbin/jail/jail.8 Modified: stable/7/sys/kern/kern_cpuset.c ============================================================================== --- stable/7/sys/kern/kern_cpuset.c Tue Aug 25 14:08:33 2009 (r196543) +++ stable/7/sys/kern/kern_cpuset.c Tue Aug 25 15:54:52 2009 (r196544) @@ -357,6 +357,15 @@ cpuset_modify(struct cpuset *set, cpuset if (error) return (error); /* + * In case we are called from within the jail + * we do not allow modifying the dedicated root + * cpuset of the jail but may still allow to + * change child sets. + */ + if (jailed(curthread->td_ucred) && + set->cs_flags & CPU_SET_ROOT) + return (EPERM); + /* * Verify that we have access to this set of * cpus. */ Modified: stable/7/usr.bin/cpuset/cpuset.1 ============================================================================== --- stable/7/usr.bin/cpuset/cpuset.1 Tue Aug 25 14:08:33 2009 (r196543) +++ stable/7/usr.bin/cpuset/cpuset.1 Tue Aug 25 15:54:52 2009 (r196544) @@ -177,9 +177,3 @@ command first appeared in .Fx 7.1 . .Sh AUTHORS .An Jeffrey Roberson Aq jeff@FreeBSD.org -.Sh BUGS -At the moment it is possible for a superuser inside a -.Xr jail 8 -to modify the root -.Xr cpuset 2 -of that jail. Modified: stable/7/usr.sbin/jail/jail.8 ============================================================================== --- stable/7/usr.sbin/jail/jail.8 Tue Aug 25 14:08:33 2009 (r196543) +++ stable/7/usr.sbin/jail/jail.8 Tue Aug 25 15:54:52 2009 (r196544) @@ -699,9 +699,3 @@ Currently, the simplest answer is to min offered on the host, possibly limiting it to services offered from .Xr inetd 8 which is easily configurable. -.Pp -At the moment it is possible for a superuser inside a -.Nm -to modify the root -.Xr cpuset 2 -of that jail. From bz at FreeBSD.org Tue Aug 25 15:58:08 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Tue Aug 25 15:58:24 2009 Subject: svn commit: r196545 - in stable/7/sys: . contrib/pf kern Message-ID: <200908251558.n7PFw7qn032632@svn.freebsd.org> Author: bz Date: Tue Aug 25 15:58:07 2009 New Revision: 196545 URL: http://svn.freebsd.org/changeset/base/196545 Log: MFC r191403: Correct a comment: the function name given had never existed in any (relevant) version of this file orany of my patches. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/kern/kern_cpuset.c Modified: stable/7/sys/kern/kern_cpuset.c ============================================================================== --- stable/7/sys/kern/kern_cpuset.c Tue Aug 25 15:54:52 2009 (r196544) +++ stable/7/sys/kern/kern_cpuset.c Tue Aug 25 15:58:07 2009 (r196545) @@ -731,7 +731,8 @@ cpuset_thread0(void) * Create a cpuset, which would be cpuset_create() but * mark the new 'set' as root. * - * We are not going to reparent the td to it. Use cpuset_reparentproc() for that. + * We are not going to reparent the td to it. Use cpuset_setproc_update_set() + * for that. * * In case of no error, returns the set in *setp locked with a reference. */ From bz at FreeBSD.org Tue Aug 25 16:56:34 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Tue Aug 25 16:56:51 2009 Subject: svn commit: r196546 - in stable/7/sys: . contrib/pf netinet6 Message-ID: <200908251656.n7PGuXOs033981@svn.freebsd.org> Author: bz Date: Tue Aug 25 16:56:33 2009 New Revision: 196546 URL: http://svn.freebsd.org/changeset/base/196546 Log: MFC r187939: Remove 4 entirely unsued ip6 variables. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/netinet6/ip6_input.c stable/7/sys/netinet6/ip6_var.h Modified: stable/7/sys/netinet6/ip6_input.c ============================================================================== --- stable/7/sys/netinet6/ip6_input.c Tue Aug 25 15:58:07 2009 (r196545) +++ stable/7/sys/netinet6/ip6_input.c Tue Aug 25 16:56:33 2009 (r196546) @@ -120,12 +120,6 @@ struct in6_ifaddr *in6_ifaddr; extern struct callout in6_tmpaddrtimer_ch; -int ip6_forward_srcrt; /* XXX */ -int ip6_sourcecheck; /* XXX */ -int ip6_sourcecheck_interval; /* XXX */ - -int ip6_ours_check_algorithm; - struct pfil_head inet6_pfil_hook; struct ip6stat ip6stat; Modified: stable/7/sys/netinet6/ip6_var.h ============================================================================== --- stable/7/sys/netinet6/ip6_var.h Tue Aug 25 15:58:07 2009 (r196545) +++ stable/7/sys/netinet6/ip6_var.h Tue Aug 25 16:56:33 2009 (r196546) @@ -282,7 +282,6 @@ extern struct ip6stat ip6stat; /* statis extern int ip6_defhlim; /* default hop limit */ extern int ip6_defmcasthlim; /* default multicast hop limit */ extern int ip6_forwarding; /* act as router? */ -extern int ip6_forward_srcrt; /* forward src-routed? */ extern int ip6_gif_hlim; /* Hop limit for gif encap packet */ extern int ip6_use_deprecated; /* allow deprecated addr as source */ extern int ip6_rr_prune; /* router renumbering prefix @@ -294,8 +293,6 @@ extern struct socket *ip6_mrouter; /* mu extern int ip6_sendredirects; /* send IP redirects when forwarding? */ extern int ip6_maxfragpackets; /* Maximum packets in reassembly queue */ extern int ip6_maxfrags; /* Maximum fragments in reassembly queue */ -extern int ip6_sourcecheck; /* Verify source interface */ -extern int ip6_sourcecheck_interval; /* Interval between log messages */ extern int ip6_accept_rtadv; /* Acts as a host not a router */ extern int ip6_keepfaith; /* Firewall Aided Internet Translator */ extern int ip6_log_interval; From bz at FreeBSD.org Tue Aug 25 17:00:25 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Tue Aug 25 17:00:48 2009 Subject: svn commit: r196548 - in stable/7/sys: . contrib/pf netipsec Message-ID: <200908251700.n7PH0ON0034159@svn.freebsd.org> Author: bz Date: Tue Aug 25 17:00:24 2009 New Revision: 196548 URL: http://svn.freebsd.org/changeset/base/196548 Log: MFC r187936: Use NULL rather than 0 when comparing pointers. Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/netipsec/ipsec_output.c Modified: stable/7/sys/netipsec/ipsec_output.c ============================================================================== --- stable/7/sys/netipsec/ipsec_output.c Tue Aug 25 16:59:55 2009 (r196547) +++ stable/7/sys/netipsec/ipsec_output.c Tue Aug 25 17:00:24 2009 (r196548) @@ -782,14 +782,14 @@ ipsec6_output_tunnel(struct ipsec_output RTFREE(state->ro->ro_rt); state->ro->ro_rt = NULL; } - if (state->ro->ro_rt == 0) { + if (state->ro->ro_rt == NULL) { bzero(dst6, sizeof(*dst6)); dst6->sin6_family = AF_INET6; dst6->sin6_len = sizeof(*dst6); dst6->sin6_addr = ip6->ip6_dst; rtalloc(state->ro); } - if (state->ro->ro_rt == 0) { + if (state->ro->ro_rt == NULL) { ip6stat.ip6s_noroute++; ipsec6stat.ips_out_noroute++; error = EHOSTUNREACH; From bz at FreeBSD.org Tue Aug 25 19:04:22 2009 From: bz at FreeBSD.org (Bjoern A. Zeeb) Date: Tue Aug 25 19:04:29 2009 Subject: svn commit: r196549 - in stable/7/sys: . contrib/pf netinet6 Message-ID: <200908251904.n7PJ4MHP036760@svn.freebsd.org> Author: bz Date: Tue Aug 25 19:04:22 2009 New Revision: 196549 URL: http://svn.freebsd.org/changeset/base/196549 Log: MFC r187946: Like with r185713 make sure to not leak a lock as rtalloc1(9) returns a locked route. Thus we have to use RTFREE_LOCKED(9) to get it unlocked and rtfree(9)d rather than just rtfree(9)d. PR: kern/129793 Submitted by: Dheeraj Reddy Originally committed from: Bugathon #6 Modified: stable/7/sys/ (props changed) stable/7/sys/contrib/pf/ (props changed) stable/7/sys/netinet6/in6_gif.c stable/7/sys/netinet6/in6_ifattach.c stable/7/sys/netinet6/nd6_nbr.c Modified: stable/7/sys/netinet6/in6_gif.c ============================================================================== --- stable/7/sys/netinet6/in6_gif.c Tue Aug 25 17:00:24 2009 (r196548) +++ stable/7/sys/netinet6/in6_gif.c Tue Aug 25 19:04:22 2009 (r196549) @@ -389,10 +389,10 @@ gif_validate6(const struct ip6_hdr *ip6, ip6_sprintf(ip6buf, &sin6.sin6_addr)); #endif if (rt) - rtfree(rt); + RTFREE_LOCKED(rt); return 0; } - rtfree(rt); + RTFREE_LOCKED(rt); } return 128 * 2; Modified: stable/7/sys/netinet6/in6_ifattach.c ============================================================================== --- stable/7/sys/netinet6/in6_ifattach.c Tue Aug 25 17:00:24 2009 (r196548) +++ stable/7/sys/netinet6/in6_ifattach.c Tue Aug 25 19:04:22 2009 (r196549) @@ -767,7 +767,7 @@ in6_ifdetach(struct ifnet *ifp) if ((ia->ia_flags & IFA_ROUTE) && (rt = rtalloc1((struct sockaddr *)&ia->ia_addr, 0, 0UL))) { rtflags = rt->rt_flags; - rtfree(rt); + RTFREE_LOCKED(rt); rtrequest(RTM_DELETE, (struct sockaddr *)&ia->ia_addr, (struct sockaddr *)&ia->ia_addr, (struct sockaddr *)&ia->ia_prefixmask, Modified: stable/7/sys/netinet6/nd6_nbr.c ============================================================================== --- stable/7/sys/netinet6/nd6_nbr.c Tue Aug 25 17:00:24 2009 (r196548) +++ stable/7/sys/netinet6/nd6_nbr.c Tue Aug 25 19:04:22 2009 (r196549) @@ -236,7 +236,7 @@ nd6_ns_input(struct mbuf *m, int off, in need_proxy = (rt && (rt->rt_flags & RTF_ANNOUNCE) != 0 && rt->rt_gateway->sa_family == AF_LINK); if (rt) - rtfree(rt); + RTFREE_LOCKED(rt); if (need_proxy) { /* * proxy NDP for single entry From peter at FreeBSD.org Wed Aug 26 19:45:20 2009 From: peter at FreeBSD.org (Peter Wemm) Date: Wed Aug 26 19:45:31 2009 Subject: svn commit: r196561 - stable/7/sys/netinet Message-ID: <200908261945.n7QJjJnR071944@svn.freebsd.org> Author: peter Date: Wed Aug 26 19:45:17 2009 New Revision: 196561 URL: http://svn.freebsd.org/changeset/base/196561 Log: MFC r194304: Fix ticks overflow in the handling of t_badtrxtwin. Modified: stable/7/sys/netinet/tcp_input.c Modified: stable/7/sys/netinet/tcp_input.c ============================================================================== --- stable/7/sys/netinet/tcp_input.c Wed Aug 26 14:32:37 2009 (r196560) +++ stable/7/sys/netinet/tcp_input.c Wed Aug 26 19:45:17 2009 (r196561) @@ -1030,7 +1030,7 @@ tcp_do_segment(struct mbuf *m, struct tc * "bad retransmit" recovery. */ if (tp->t_rxtshift == 1 && - ticks < tp->t_badrxtwin) { + (int)(ticks - tp->t_badrxtwin) < 0) { ++tcpstat.tcps_sndrexmitbad; tp->snd_cwnd = tp->snd_cwnd_prev; tp->snd_ssthresh = @@ -1961,7 +1961,7 @@ process_ACK: * original cwnd and ssthresh, and proceed to transmit where * we left off. */ - if (tp->t_rxtshift == 1 && ticks < tp->t_badrxtwin) { + if (tp->t_rxtshift == 1 && (int)(ticks - tp->t_badrxtwin) < 0) { ++tcpstat.tcps_sndrexmitbad; tp->snd_cwnd = tp->snd_cwnd_prev; tp->snd_ssthresh = tp->snd_ssthresh_prev; From dougb at FreeBSD.org Wed Aug 26 21:05:17 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Wed Aug 26 21:05:34 2009 Subject: svn commit: r196565 - in stable/7/release: . scripts Message-ID: <200908262105.n7QL5Ho7074091@svn.freebsd.org> Author: dougb Date: Wed Aug 26 21:05:17 2009 New Revision: 196565 URL: http://svn.freebsd.org/changeset/base/196565 Log: MFC 196434: Add a script to create the /var/db/mergemaster.mtree file for new releases so that when users subsequently update their source trees they can make use of mergemaster's -U option. Added: stable/7/release/scripts/mm-mtree.sh - copied unchanged from r196434, head/release/scripts/mm-mtree.sh Modified: stable/7/release/ (props changed) stable/7/release/scripts/src-install.sh (props changed) Copied: stable/7/release/scripts/mm-mtree.sh (from r196434, head/release/scripts/mm-mtree.sh) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/7/release/scripts/mm-mtree.sh Wed Aug 26 21:05:17 2009 (r196565, copy of r196434, head/release/scripts/mm-mtree.sh) @@ -0,0 +1,155 @@ +#!/bin/sh + +# mergemaster mtree database generator + +# This script is intended to be used as part of the release building +# process to generate the /var/db/mergemaster.mtree file relevant to +# the source tree used to create the release so that users can make +# use of mergemaster's -U option to update their files after csup'ing +# to -stable. + +# Copyright 2009 Douglas Barton +# dougb@FreeBSD.org + +# $FreeBSD$ + +PATH=/bin:/usr/bin:/usr/sbin + +display_usage () { + VERSION_NUMBER=`grep "[$]FreeBSD:" $0 | cut -d ' ' -f 4` + echo "${0##*/} version ${VERSION_NUMBER}" + echo "Usage: ${0##*/} [-m /path] [-t /path] [-A arch] [-F ] [-D /path]" + echo "Options:" + echo " -m /path/directory Specify location of source to do the make in" + echo " -t /path/directory Specify temp root directory" + echo " -A architecture Alternative architecture name to pass to make" + echo " -F Specify what to put on the make command line" + echo ' -D /path/directory Specify the destination directory to install files to' + echo '' +} + +# Set the default path for the temporary root environment +# +TEMPROOT='/var/tmp/temproot' + +# Assign the location of the mtree database +# +MTREEDB=${MTREEDB:-/var/db} +MTREEFILE="${MTREEDB}/mergemaster.mtree" + +# Check the command line options +# +while getopts "m:t:A:F:D:h" COMMAND_LINE_ARGUMENT ; do + case "${COMMAND_LINE_ARGUMENT}" in + m) + SOURCEDIR=${OPTARG} + ;; + t) + TEMPROOT=${OPTARG} + ;; + A) + ARCHSTRING='TARGET_ARCH='${OPTARG} + ;; + F) + MM_MAKE_ARGS="${OPTARG}" + ;; + D) + DESTDIR=${OPTARG} + ;; + h) + display_usage + exit 0 + ;; + *) + echo '' + display_usage + exit 1 + ;; + esac +done + +# Assign the source directory +# +SOURCEDIR=${SOURCEDIR:-/usr/src} +if [ ! -f ${SOURCEDIR}/Makefile.inc1 -a \ + -f ${SOURCEDIR}/../Makefile.inc1 ]; then + echo " *** The source directory you specified (${SOURCEDIR})" + echo " will be reset to ${SOURCEDIR}/.." + echo '' + sleep 3 + SOURCEDIR=${SOURCEDIR}/.. +fi + +# Setup make to use system files from SOURCEDIR +MM_MAKE="make ${ARCHSTRING} ${MM_MAKE_ARGS} -m ${SOURCEDIR}/share/mk" + +delete_temproot () { + rm -rf "${TEMPROOT}" 2>/dev/null + chflags -R 0 "${TEMPROOT}" 2>/dev/null + rm -rf "${TEMPROOT}" || exit 1 +} + +[ -d "${TEMPROOT}" ] && delete_temproot + +echo "*** Creating the temporary root environment in ${TEMPROOT}" + +if mkdir -p "${TEMPROOT}"; then + echo " *** ${TEMPROOT} ready for use" +fi + +if [ ! -d "${TEMPROOT}" ]; then + echo '' + echo " *** FATAL ERROR: Cannot create ${TEMPROOT}" + echo '' + exit 1 +fi + +echo " *** Creating and populating directory structure in ${TEMPROOT}" +echo '' + +{ cd ${SOURCEDIR} || { echo "*** Cannot cd to ${SOURCEDIR}" ; exit 1;} + case "${DESTDIR}" in + '') ;; + *) + ${MM_MAKE} DESTDIR=${DESTDIR} distrib-dirs + ;; + esac + od=${TEMPROOT}/usr/obj + ${MM_MAKE} DESTDIR=${TEMPROOT} distrib-dirs && + MAKEOBJDIRPREFIX=$od ${MM_MAKE} _obj SUBDIR_OVERRIDE=etc && + MAKEOBJDIRPREFIX=$od ${MM_MAKE} everything SUBDIR_OVERRIDE=etc && + MAKEOBJDIRPREFIX=$od ${MM_MAKE} DESTDIR=${TEMPROOT} distribution;} || + { echo ''; + echo " *** FATAL ERROR: Cannot 'cd' to ${SOURCEDIR} and install files to"; + echo " the temproot environment"; + echo ''; + exit 1;} + +# We really don't want to have to deal with files like login.conf.db, pwd.db, +# or spwd.db. Instead, we want to compare the text versions, and run *_mkdb. +# Prompt the user to do so below, as needed. +# +rm -f ${TEMPROOT}/etc/*.db ${TEMPROOT}/etc/passwd + +# We only need to compare things like freebsd.cf once +find ${TEMPROOT}/usr/obj -type f -delete 2>/dev/null + +# Delete stuff we do not need to keep the mtree database small, +# and to make the actual comparison faster. +find ${TEMPROOT}/usr -type l -delete 2>/dev/null +find ${TEMPROOT} -type f -size 0 -delete 2>/dev/null +find -d ${TEMPROOT} -type d -empty -delete 2>/dev/null + +# Build the mtree database in a temporary location. +MTREENEW=`mktemp -t mergemaster.mtree` +mtree -ci -p ${TEMPROOT} -k size,md5digest > ${MTREENEW} 2>/dev/null + +if [ -s "${MTREENEW}" ]; then + echo "*** Saving mtree database for future upgrades" + test -e "${DESTDIR}${MTREEFILE}" && unlink ${DESTDIR}${MTREEFILE} + mv ${MTREENEW} ${DESTDIR}${MTREEFILE} +fi + +delete_temproot + +exit 0 From dougb at FreeBSD.org Wed Aug 26 22:50:14 2009 From: dougb at FreeBSD.org (Doug Barton) Date: Wed Aug 26 22:50:39 2009 Subject: svn commit: r196572 - in stable/7/sys: . conf Message-ID: <200908262250.n7QMoERq077329@svn.freebsd.org> Author: dougb Date: Wed Aug 26 22:50:14 2009 New Revision: 196572 URL: http://svn.freebsd.org/changeset/base/196572 Log: MFC r196435: The svnversion string is only relevant when newvers.sh is called during the kernel build process, the other places that call the script do not make use of that information. So restrict execution of the svnversion-related code to the kernel build context. Modified: stable/7/sys/ (props changed) stable/7/sys/conf/ (props changed) stable/7/sys/conf/newvers.sh Modified: stable/7/sys/conf/newvers.sh ============================================================================== --- stable/7/sys/conf/newvers.sh Wed Aug 26 22:32:14 2009 (r196571) +++ stable/7/sys/conf/newvers.sh Wed Aug 26 22:50:14 2009 (r196572) @@ -87,29 +87,25 @@ touch version v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date` i=`${MAKE:-make} -V KERN_IDENT` -for dir in /bin /usr/bin /usr/local/bin; do - if [ -x "${dir}/svnversion" ]; then - svnversion=${dir}/svnversion - SRCDIR=${d##*obj} - if [ -n "$MACHINE" ]; then - SRCDIR=${SRCDIR##/$MACHINE} +case "$d" in +*/sys/*) + for dir in /bin /usr/bin /usr/local/bin; do + if [ -x "${dir}/svnversion" ]; then + svnversion=${dir}/svnversion + SRCDIR=${d##*obj} + if [ -n "$MACHINE" ]; then + SRCDIR=${SRCDIR##/$MACHINE} + fi + SRCDIR=${SRCDIR%%/sys/*} + break fi - SRCDIR=${SRCDIR%%/sys/*} - break - fi -done + done -if [ -n "$svnversion" -a -d "${SRCDIR}/.svn" ] ; then - # If we are called from the kernel build, limit - # the scope of svnversion to sys/ . - if [ -e "${SRCDIR}/sys/conf/newvers.sh" ] ; then - svn=" r`cd $SRCDIR/sys && $svnversion`" - else - svn=" r`cd $SRCDIR && $svnversion`" + if [ -n "$svnversion" -a -d "${SRCDIR}/sys/.svn" ] ; then + svn=" r`cd ${SRCDIR}/sys && $svnversion`" fi -else - svn="" -fi + ;; +esac cat << EOF > vers.c $COPYRIGHT From attilio at FreeBSD.org Thu Aug 27 00:45:01 2009 From: attilio at FreeBSD.org (Attilio Rao) Date: Thu Aug 27 00:45:14 2009 Subject: svn commit: r196574 - stable/7/sys/kern Message-ID: <200908270045.n7R0j1xs079837@svn.freebsd.org> Author: attilio Date: Thu Aug 27 00:45:00 2009 New Revision: 196574 URL: http://svn.freebsd.org/changeset/base/196574 Log: Fix a problem introduced when MFCing the rw_try_wlock() operation from HEAD: __rw_wunlock() relies on the cookie state to not be cleanly 'tid' when some conditions needing of special care happens, and lock recursion is among those. Dirty the cookie by adding the RW_LOCK_RECURSE flag in the case of a successfull try lock operation. This is not a problem on -CURRENT and STABLE_8 where the unlocking algorithm works differently. Submitted by: Andrew Brampton Modified: stable/7/sys/kern/kern_rwlock.c Modified: stable/7/sys/kern/kern_rwlock.c ============================================================================== --- stable/7/sys/kern/kern_rwlock.c Wed Aug 26 22:51:14 2009 (r196573) +++ stable/7/sys/kern/kern_rwlock.c Thu Aug 27 00:45:00 2009 (r196574) @@ -204,6 +204,7 @@ _rw_try_wlock(struct rwlock *rw, const c if (rw_wlocked(rw) && (rw->lock_object.lo_flags & RW_RECURSE) != 0) { rw->rw_recurse++; + atomic_set_ptr(&rw->rw_lock, RW_LOCK_RECURSED); rval = 1; } else rval = atomic_cmpset_acq_ptr(&rw->rw_lock, RW_UNLOCKED, From brian at FreeBSD.org Thu Aug 27 07:10:58 2009 From: brian at FreeBSD.org (Brian Somers) Date: Thu Aug 27 07:11:09 2009 Subject: svn commit: r196577 - stable/7/usr.sbin/ppp Message-ID: <200908270710.n7R7Av56087747@svn.freebsd.org> Author: brian Date: Thu Aug 27 07:10:57 2009 New Revision: 196577 URL: http://svn.freebsd.org/changeset/base/196577 Log: MFC: When realloc()ing device memory for transfer to another ppp process, don't continue to use the realloc()d pointer - it might have changed! Remove some stray diagnostics while I'm here. Modified: stable/7/usr.sbin/ppp/ (props changed) stable/7/usr.sbin/ppp/ether.c stable/7/usr.sbin/ppp/netgraph.c stable/7/usr.sbin/ppp/tty.c Modified: stable/7/usr.sbin/ppp/ether.c ============================================================================== --- stable/7/usr.sbin/ppp/ether.c Thu Aug 27 07:07:38 2009 (r196576) +++ stable/7/usr.sbin/ppp/ether.c Thu Aug 27 07:10:57 2009 (r196577) @@ -193,17 +193,18 @@ static void ether_device2iov(struct device *d, struct iovec *iov, int *niov, int maxiov __unused, int *auxfd, int *nauxfd) { - struct etherdevice *dev = device2ether(d); + struct etherdevice *dev; int sz = physical_MaxDeviceSize(); - iov[*niov].iov_base = realloc(d, sz); - if (iov[*niov].iov_base == NULL) { + iov[*niov].iov_base = d = realloc(d, sz); + if (d == NULL) { log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); AbortProgram(EX_OSERR); } iov[*niov].iov_len = sz; (*niov)++; + dev = device2ether(d); if (dev->cs >= 0) { *auxfd = dev->cs; (*nauxfd)++; Modified: stable/7/usr.sbin/ppp/netgraph.c ============================================================================== --- stable/7/usr.sbin/ppp/netgraph.c Thu Aug 27 07:07:38 2009 (r196576) +++ stable/7/usr.sbin/ppp/netgraph.c Thu Aug 27 07:10:57 2009 (r196577) @@ -235,7 +235,6 @@ ng_Read(struct physical *p, void *v, siz { char hook[NG_HOOKSIZ]; -log_Printf(LogDEBUG, "ng_Read\n"); switch (p->dl->state) { case DATALINK_DIAL: case DATALINK_LOGIN: @@ -282,17 +281,18 @@ static void ng_device2iov(struct device *d, struct iovec *iov, int *niov, int maxiov __unused, int *auxfd, int *nauxfd) { - struct ngdevice *dev = device2ng(d); + struct ngdevice *dev; int sz = physical_MaxDeviceSize(); - iov[*niov].iov_base = realloc(d, sz); - if (iov[*niov].iov_base == NULL) { + iov[*niov].iov_base = d = realloc(d, sz); + if (d == NULL) { log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); AbortProgram(EX_OSERR); } iov[*niov].iov_len = sz; (*niov)++; + dev = device2ng(d); *auxfd = dev->cs; (*nauxfd)++; } Modified: stable/7/usr.sbin/ppp/tty.c ============================================================================== --- stable/7/usr.sbin/ppp/tty.c Thu Aug 27 07:07:38 2009 (r196576) +++ stable/7/usr.sbin/ppp/tty.c Thu Aug 27 07:10:57 2009 (r196577) @@ -384,7 +384,6 @@ UnloadLineDiscipline(struct physical *p) struct ttydevice *dev = device2tty(p->handler); if (isngtty(dev)) { -log_Printf(LogPHASE, "back to speed %d\n", dev->real.speed); if (!physical_SetSpeed(p, dev->real.speed)) log_Printf(LogWARN, "Couldn't reset tty speed to %d\n", dev->real.speed); dev->real.speed = 0; @@ -582,17 +581,19 @@ tty_device2iov(struct device *d, struct #endif ) { - struct ttydevice *dev = device2tty(d); + struct ttydevice *dev; int sz = physical_MaxDeviceSize(); - iov[*niov].iov_base = realloc(d, sz); - if (iov[*niov].iov_base == NULL) { + iov[*niov].iov_base = d = realloc(d, sz); + if (d == NULL) { log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); AbortProgram(EX_OSERR); } iov[*niov].iov_len = sz; (*niov)++; + dev = device2tty(d); + #ifndef NONETGRAPH if (dev->cs >= 0) { *auxfd = dev->cs; From brian at FreeBSD.org Thu Aug 27 07:11:47 2009 From: brian at FreeBSD.org (Brian Somers) Date: Thu Aug 27 07:12:00 2009 Subject: svn commit: r196578 - stable/7/usr.sbin/ppp Message-ID: <200908270711.n7R7BlR6087825@svn.freebsd.org> Author: brian Date: Thu Aug 27 07:11:47 2009 New Revision: 196578 URL: http://svn.freebsd.org/changeset/base/196578 Log: MFC: When ``ppp -direct'' is invoked by a program that uses pipe(2) to create stdin and stdout, don't blindly try to use stdin as a bi-directional channel. Instead, detect the pipe and set up a special exec handler that indirects write() calls through stdout. This fixes the problem where ``set device "!ssh -e none host ppp -direct label"'' no longer works with an openssh-5.2 server side as that version of openssh ignores the USE_PIPES config setting and *always* uses pipes (rather than socketpair) for stdin/stdout channels. Modified: stable/7/usr.sbin/ppp/ (props changed) stable/7/usr.sbin/ppp/exec.c stable/7/usr.sbin/ppp/exec.h stable/7/usr.sbin/ppp/main.c stable/7/usr.sbin/ppp/physical.c Modified: stable/7/usr.sbin/ppp/exec.c ============================================================================== --- stable/7/usr.sbin/ppp/exec.c Thu Aug 27 07:10:57 2009 (r196577) +++ stable/7/usr.sbin/ppp/exec.c Thu Aug 27 07:11:47 2009 (r196578) @@ -35,7 +35,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -63,24 +65,106 @@ #include "cbcp.h" #include "datalink.h" #include "id.h" +#include "main.h" #include "exec.h" -static struct device execdevice = { + +struct execdevice { + struct device dev; /* What struct physical knows about */ + int fd_out; /* output descriptor */ +}; + +#define device2exec(d) ((d)->type == EXEC_DEVICE ? (struct execdevice *)d : NULL) + +unsigned +exec_DeviceSize(void) +{ + return sizeof(struct execdevice); +} + +static void +exec_Free(struct physical *p) +{ + struct execdevice *dev = device2exec(p->handler); + + if (dev->fd_out != -1) + close(dev->fd_out); + free(dev); +} + +static void +exec_device2iov(struct device *d, struct iovec *iov, int *niov, + int maxiov __unused, int *auxfd, int *nauxfd) +{ + struct execdevice *dev; + int sz = physical_MaxDeviceSize(); + + iov[*niov].iov_base = d = realloc(d, sz); + if (d == NULL) { + log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz); + AbortProgram(EX_OSERR); + } + iov[*niov].iov_len = sz; + (*niov)++; + + dev = device2exec(d); + if (dev->fd_out >= 0) { + *auxfd = dev->fd_out; + (*nauxfd)++; + } +} + +static int +exec_RemoveFromSet(struct physical *p, fd_set *r, fd_set *w, fd_set *e) +{ + struct execdevice *dev = device2exec(p->handler); + int sets; + + p->handler->removefromset = NULL; + sets = physical_RemoveFromSet(p, r, w, e); + p->handler->removefromset = exec_RemoveFromSet; + + if (dev->fd_out >= 0) { + if (w && FD_ISSET(dev->fd_out, w)) { + FD_CLR(dev->fd_out, w); + log_Printf(LogTIMER, "%s: fdunset(w) %d\n", p->link.name, dev->fd_out); + sets++; + } + if (e && FD_ISSET(dev->fd_out, e)) { + FD_CLR(dev->fd_out, e); + log_Printf(LogTIMER, "%s: fdunset(e) %d\n", p->link.name, dev->fd_out); + sets++; + } + } + + return sets; +} + +static ssize_t +exec_Write(struct physical *p, const void *v, size_t n) +{ + struct execdevice *dev = device2exec(p->handler); + int fd = dev->fd_out == -1 ? p->fd : dev->fd_out; + + return write(fd, v, n); +} + +static struct device baseexecdevice = { EXEC_DEVICE, "exec", 0, { CD_NOTREQUIRED, 0 }, NULL, + exec_RemoveFromSet, NULL, NULL, NULL, NULL, NULL, + exec_Free, NULL, - NULL, - NULL, - NULL, - NULL, + exec_Write, + exec_device2iov, NULL, NULL, NULL @@ -88,146 +172,238 @@ static struct device execdevice = { struct device * exec_iov2device(int type, struct physical *p, struct iovec *iov, - int *niov, int maxiov __unused, int *auxfd __unused, - int *nauxfd __unused) + int *niov, int maxiov __unused, int *auxfd, int *nauxfd) { if (type == EXEC_DEVICE) { - free(iov[(*niov)++].iov_base); - physical_SetupStack(p, execdevice.name, PHYSICAL_NOFORCE); - return &execdevice; + struct execdevice *dev = (struct execdevice *)iov[(*niov)++].iov_base; + + dev = realloc(dev, sizeof *dev); /* Reduce to the correct size */ + if (dev == NULL) { + log_Printf(LogALERT, "Failed to allocate memory: %d\n", + (int)(sizeof *dev)); + AbortProgram(EX_OSERR); + } + + if (*nauxfd) { + dev->fd_out = *auxfd; + (*nauxfd)--; + } else + dev->fd_out = -1; + + /* Refresh function pointers etc */ + memcpy(&dev->dev, &baseexecdevice, sizeof dev->dev); + + physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); + return &dev->dev; } return NULL; } +static int +exec_UpdateSet(struct fdescriptor *d, fd_set *r, fd_set *w, fd_set *e, int *n) +{ + struct physical *p = descriptor2physical(d); + struct execdevice *dev = device2exec(p->handler); + int result = 0; + + if (w && dev->fd_out >= 0) { + FD_SET(dev->fd_out, w); + log_Printf(LogTIMER, "%s: fdset(w) %d\n", p->link.name, dev->fd_out); + result++; + w = NULL; + } + + if (e && dev->fd_out >= 0) { + FD_SET(dev->fd_out, e); + log_Printf(LogTIMER, "%s: fdset(e) %d\n", p->link.name, dev->fd_out); + result++; + } + + if (result && *n <= dev->fd_out) + *n = dev->fd_out + 1; + + return result + physical_doUpdateSet(d, r, w, e, n, 0); +} + +static int +exec_IsSet(struct fdescriptor *d, const fd_set *fdset) +{ + struct physical *p = descriptor2physical(d); + struct execdevice *dev = device2exec(p->handler); + int result = dev->fd_out >= 0 && FD_ISSET(dev->fd_out, fdset); + result += physical_IsSet(d, fdset); + + return result; +} + struct device * exec_Create(struct physical *p) { - if (p->fd < 0 && *p->name.full == '!') { - int fids[2], type; - - p->fd--; /* We own the device but maybe can't use it - change fd */ - type = physical_IsSync(p) ? SOCK_DGRAM : SOCK_STREAM; + struct execdevice *dev; - if (socketpair(AF_UNIX, type, PF_UNSPEC, fids) < 0) - log_Printf(LogPHASE, "Unable to create pipe for line exec: %s\n", - strerror(errno)); - else { - static int child_status; /* This variable is abused ! */ - int stat, argc, i, ret, wret, pidpipe[2]; - pid_t pid, realpid; - char *argv[MAXARGS]; - - stat = fcntl(fids[0], F_GETFL, 0); - if (stat > 0) { - stat |= O_NONBLOCK; - fcntl(fids[0], F_SETFL, stat); + dev = NULL; + if (p->fd < 0) { + if (*p->name.full == '!') { + int fids[2], type; + + if ((dev = malloc(sizeof *dev)) == NULL) { + log_Printf(LogWARN, "%s: Cannot allocate an exec device: %s\n", + p->link.name, strerror(errno)); + return NULL; } - realpid = getpid(); - if (pipe(pidpipe) == -1) { - log_Printf(LogPHASE, "Unable to pipe for line exec: %s\n", + dev->fd_out = -1; + + p->fd--; /* We own the device but maybe can't use it - change fd */ + type = physical_IsSync(p) ? SOCK_DGRAM : SOCK_STREAM; + + if (socketpair(AF_UNIX, type, PF_UNSPEC, fids) < 0) { + log_Printf(LogPHASE, "Unable to create pipe for line exec: %s\n", strerror(errno)); - close(fids[1]); - } else switch ((pid = fork())) { - case -1: - log_Printf(LogPHASE, "Unable to fork for line exec: %s\n", + free(dev); + dev = NULL; + } else { + static int child_status; /* This variable is abused ! */ + int stat, argc, i, ret, wret, pidpipe[2]; + pid_t pid, realpid; + char *argv[MAXARGS]; + + stat = fcntl(fids[0], F_GETFL, 0); + if (stat > 0) { + stat |= O_NONBLOCK; + fcntl(fids[0], F_SETFL, stat); + } + realpid = getpid(); + if (pipe(pidpipe) == -1) { + log_Printf(LogPHASE, "Unable to pipe for line exec: %s\n", strerror(errno)); - close(pidpipe[0]); - close(pidpipe[1]); close(fids[1]); - break; - - case 0: - close(pidpipe[0]); close(fids[0]); - timer_TermService(); -#ifndef NOSUID - setuid(ID0realuid()); -#endif - - child_status = 0; - switch ((pid = vfork())) { - case 0: - close(pidpipe[1]); - break; - - case -1: - ret = errno; - log_Printf(LogPHASE, "Unable to vfork to drop parent: %s\n", - strerror(errno)); - close(pidpipe[1]); - _exit(ret); - - default: - write(pidpipe[1], &pid, sizeof pid); - close(pidpipe[1]); - _exit(child_status); /* The error from exec() ! */ - } - - log_Printf(LogDEBUG, "Exec'ing ``%s''\n", p->name.base); - - if ((argc = MakeArgs(p->name.base, argv, VECSIZE(argv), - PARSE_REDUCE|PARSE_NOHASH)) < 0) { - log_Printf(LogWARN, "Syntax error in exec command\n"); - _exit(ESRCH); - } - - command_Expand(argv, argc, (char const *const *)argv, - p->dl->bundle, 0, realpid); - - dup2(fids[1], STDIN_FILENO); - dup2(fids[1], STDOUT_FILENO); - dup2(fids[1], STDERR_FILENO); - for (i = getdtablesize(); i > STDERR_FILENO; i--) - fcntl(i, F_SETFD, 1); - - execvp(*argv, argv); - child_status = errno; /* Only works for vfork() */ - printf("execvp failed: %s: %s\r\n", *argv, strerror(child_status)); - _exit(child_status); - break; - - default: - close(pidpipe[1]); - close(fids[1]); - if (read(pidpipe[0], &p->session_owner, sizeof p->session_owner) != - sizeof p->session_owner) - p->session_owner = (pid_t)-1; - close(pidpipe[0]); - while ((wret = waitpid(pid, &stat, 0)) == -1 && errno == EINTR) - ; - if (wret == -1) { - log_Printf(LogWARN, "Waiting for child process: %s\n", + free(dev); + dev = NULL; + } else switch ((pid = fork())) { + case -1: + log_Printf(LogPHASE, "Unable to fork for line exec: %s\n", strerror(errno)); + close(pidpipe[0]); + close(pidpipe[1]); + close(fids[1]); close(fids[0]); - p->session_owner = (pid_t)-1; - break; - } else if (WIFSIGNALED(stat)) { - log_Printf(LogWARN, "Child process received sig %d !\n", - WTERMSIG(stat)); - close(fids[0]); - p->session_owner = (pid_t)-1; break; - } else if (WIFSTOPPED(stat)) { - log_Printf(LogWARN, "Child process received stop sig %d !\n", - WSTOPSIG(stat)); - /* I guess that's ok.... */ - } else if ((ret = WEXITSTATUS(stat))) { - log_Printf(LogWARN, "Cannot exec \"%s\": %s\n", p->name.base, - strerror(ret)); + + case 0: + close(pidpipe[0]); close(fids[0]); - p->session_owner = (pid_t)-1; + timer_TermService(); + #ifndef NOSUID + setuid(ID0realuid()); + #endif + + child_status = 0; + switch ((pid = vfork())) { + case 0: + close(pidpipe[1]); + break; + + case -1: + ret = errno; + log_Printf(LogPHASE, "Unable to vfork to drop parent: %s\n", + strerror(errno)); + close(pidpipe[1]); + _exit(ret); + + default: + write(pidpipe[1], &pid, sizeof pid); + close(pidpipe[1]); + _exit(child_status); /* The error from exec() ! */ + } + + log_Printf(LogDEBUG, "Exec'ing ``%s''\n", p->name.base); + + if ((argc = MakeArgs(p->name.base, argv, VECSIZE(argv), + PARSE_REDUCE|PARSE_NOHASH)) < 0) { + log_Printf(LogWARN, "Syntax error in exec command\n"); + _exit(ESRCH); + } + + command_Expand(argv, argc, (char const *const *)argv, + p->dl->bundle, 0, realpid); + + dup2(fids[1], STDIN_FILENO); + dup2(fids[1], STDOUT_FILENO); + dup2(fids[1], STDERR_FILENO); + for (i = getdtablesize(); i > STDERR_FILENO; i--) + fcntl(i, F_SETFD, 1); + + execvp(*argv, argv); + child_status = errno; /* Only works for vfork() */ + printf("execvp failed: %s: %s\r\n", *argv, strerror(child_status)); + _exit(child_status); break; - } - p->fd = fids[0]; - log_Printf(LogDEBUG, "Using descriptor %d for child\n", p->fd); - physical_SetupStack(p, execdevice.name, PHYSICAL_NOFORCE); - if (p->cfg.cd.necessity != CD_DEFAULT) - log_Printf(LogWARN, "Carrier settings ignored\n"); - return &execdevice; + + default: + close(pidpipe[1]); + close(fids[1]); + if (read(pidpipe[0], &p->session_owner, sizeof p->session_owner) != + sizeof p->session_owner) + p->session_owner = (pid_t)-1; + close(pidpipe[0]); + while ((wret = waitpid(pid, &stat, 0)) == -1 && errno == EINTR) + ; + if (wret == -1) { + log_Printf(LogWARN, "Waiting for child process: %s\n", + strerror(errno)); + close(fids[0]); + p->session_owner = (pid_t)-1; + break; + } else if (WIFSIGNALED(stat)) { + log_Printf(LogWARN, "Child process received sig %d !\n", + WTERMSIG(stat)); + close(fids[0]); + p->session_owner = (pid_t)-1; + break; + } else if (WIFSTOPPED(stat)) { + log_Printf(LogWARN, "Child process received stop sig %d !\n", + WSTOPSIG(stat)); + /* I guess that's ok.... */ + } else if ((ret = WEXITSTATUS(stat))) { + log_Printf(LogWARN, "Cannot exec \"%s\": %s\n", p->name.base, + strerror(ret)); + close(fids[0]); + p->session_owner = (pid_t)-1; + break; + } + p->fd = fids[0]; + log_Printf(LogDEBUG, "Using descriptor %d for child\n", p->fd); + } } - close(fids[0]); } + } else { + struct stat st; + + if (fstat(p->fd, &st) != -1 && (st.st_mode & S_IFIFO)) { + if ((dev = malloc(sizeof *dev)) == NULL) + log_Printf(LogWARN, "%s: Cannot allocate an exec device: %s\n", + p->link.name, strerror(errno)); + else if (p->fd == STDIN_FILENO) { + log_Printf(LogPHASE, "%s: Using stdin/stdout to communicate with " + "parent (pipe mode)\n", p->link.name); + dev->fd_out = dup(STDOUT_FILENO); + + /* Hook things up so that we monitor dev->fd_out */ + p->desc.UpdateSet = exec_UpdateSet; + p->desc.IsSet = exec_IsSet; + } else + dev->fd_out = -1; + } + } + + if (dev) { + memcpy(&dev->dev, &baseexecdevice, sizeof dev->dev); + physical_SetupStack(p, dev->dev.name, PHYSICAL_NOFORCE); + if (p->cfg.cd.necessity != CD_DEFAULT) + log_Printf(LogWARN, "Carrier settings ignored\n"); + return &dev->dev; } return NULL; Modified: stable/7/usr.sbin/ppp/exec.h ============================================================================== --- stable/7/usr.sbin/ppp/exec.h Thu Aug 27 07:10:57 2009 (r196577) +++ stable/7/usr.sbin/ppp/exec.h Thu Aug 27 07:11:47 2009 (r196578) @@ -32,4 +32,4 @@ struct device; extern struct device *exec_Create(struct physical *); extern struct device *exec_iov2device(int, struct physical *, struct iovec *, int *, int, int *, int *); -#define exec_DeviceSize physical_DeviceSize +extern unsigned exec_DeviceSize(void); Modified: stable/7/usr.sbin/ppp/main.c ============================================================================== --- stable/7/usr.sbin/ppp/main.c Thu Aug 27 07:10:57 2009 (r196577) +++ stable/7/usr.sbin/ppp/main.c Thu Aug 27 07:11:47 2009 (r196578) @@ -508,9 +508,11 @@ main(int argc, char **argv) if (!sw.fg) setsid(); } else { - /* -direct - STDIN_FILENO gets used by physical_Open */ + /* + * -direct - STDIN_FILENO gets used by physical_Open. STDOUT_FILENO + * *may* get used in exec/pipe mode. + */ prompt_TtyInit(NULL); - close(STDOUT_FILENO); close(STDERR_FILENO); } } else { Modified: stable/7/usr.sbin/ppp/physical.c ============================================================================== --- stable/7/usr.sbin/ppp/physical.c Thu Aug 27 07:10:57 2009 (r196577) +++ stable/7/usr.sbin/ppp/physical.c Thu Aug 27 07:11:47 2009 (r196578) @@ -1027,6 +1027,7 @@ physical_Open(struct physical *p) p->fd = STDIN_FILENO; for (h = 0; h < NDEVICES && p->handler == NULL && p->fd >= 0; h++) p->handler = (*devices[h].create)(p); + close(STDOUT_FILENO); if (p->fd >= 0) { if (p->handler == NULL) { physical_SetupStack(p, "unknown", PHYSICAL_NOFORCE); From edwin at FreeBSD.org Thu Aug 27 12:27:06 2009 From: edwin at FreeBSD.org (Edwin Groothuis) Date: Thu Aug 27 12:27:13 2009 Subject: svn commit: r196583 - stable/7/share/zoneinfo Message-ID: <200908271227.n7RCR6FB095857@svn.freebsd.org> Author: edwin Date: Thu Aug 27 12:27:06 2009 New Revision: 196583 URL: http://svn.freebsd.org/changeset/base/196583 Log: MFC of r196581: Import of tzdata2009k - Changes in Mauritius and Bangladesh - No leapsecond at the end of December 2009 Modified: stable/7/share/zoneinfo/ (props changed) stable/7/share/zoneinfo/africa stable/7/share/zoneinfo/asia stable/7/share/zoneinfo/europe stable/7/share/zoneinfo/leapseconds Modified: stable/7/share/zoneinfo/africa ============================================================================== --- stable/7/share/zoneinfo/africa Thu Aug 27 12:24:21 2009 (r196582) +++ stable/7/share/zoneinfo/africa Thu Aug 27 12:27:06 2009 (r196583) @@ -1,5 +1,5 @@ #
-# @(#)africa	8.21
+# @(#)africa	8.22
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -502,11 +502,33 @@ Zone Africa/Nouakchott	-1:03:48 -	LMT	19
 # http://www.gov.mu/portal/goc/assemblysite/file/bill2708.pdf
 # 
 
+# From Steffen Thorsen (2009-06-05):
+# According to several sources, Mauritius will not continue to observe
+# DST the coming summer...
+#
+# Some sources, in French:
+# 
+# http://www.defimedia.info/news/946/Rashid-Beebeejaun-:-%C2%AB-L%E2%80%99heure-d%E2%80%99%C3%A9t%C3%A9-ne-sera-pas-appliqu%C3%A9e-cette-ann%C3%A9e-%C2%BB
+# 
+# 
+# http://lexpress.mu/Story/3398~Beebeejaun---Les-objectifs-d-%C3%A9conomie-d-%C3%A9nergie-de-l-heure-d-%C3%A9t%C3%A9-ont-%C3%A9t%C3%A9-atteints-
+# 
+#
+# Our wrap-up:
+# 
+# http://www.timeanddate.com/news/time/mauritius-dst-will-not-repeat.html
+# 
+
+# From Arthur David Olson (2009-07-11):
+# The "mauritius-dst-will-not-repeat" wrapup includes this: 
+# "The trial ended on March 29, 2009, when the clocks moved back by one hour
+# at 2am (or 02:00) local time..."
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule Mauritius	1982	only	-	Oct	10	0:00	1:00	S
 Rule Mauritius	1983	only	-	Mar	21	0:00	0	-
-Rule Mauritius	2008	max	-	Oct	lastSun	2:00s	1:00	S
-Rule Mauritius	2009	max	-	Mar	lastSun	2:00s	0	-
+Rule Mauritius	2008	only	-	Oct	lastSun	2:00	1:00	S
+Rule Mauritius	2009	only	-	Mar	lastSun	2:00	0	-
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Indian/Mauritius	3:50:00 -	LMT	1907		# Port Louis
 			4:00 Mauritius	MU%sT	# Mauritius Time

Modified: stable/7/share/zoneinfo/asia
==============================================================================
--- stable/7/share/zoneinfo/asia	Thu Aug 27 12:24:21 2009	(r196582)
+++ stable/7/share/zoneinfo/asia	Thu Aug 27 12:27:06 2009	(r196583)
@@ -1,5 +1,5 @@
 # 
-# @(#)asia	8.35
+# @(#)asia	8.36
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -172,6 +172,12 @@ Zone	Asia/Bahrain	3:22:20 -	LMT	1920		# 
 #
 # No DST end date has been announced yet.
 
+# From Arthur David Olson (2009-07-11):
+# Arbitrarily end DST at the end of 2009 so that a POSIX-sytle time zone string
+# can appear in the Dhaka binary file and for the benefit of old glibc
+# reimplementations of the time zone software that mishandle permanent DST.
+# A change will be required once the end date is known.
+
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Asia/Dhaka	6:01:40 -	LMT	1890
 			5:53:20	-	HMT	1941 Oct    # Howrah Mean Time?
@@ -180,7 +186,8 @@ Zone	Asia/Dhaka	6:01:40 -	LMT	1890
 			6:30	-	BURT	1951 Sep 30
 			6:00	-	DACT	1971 Mar 26 # Dacca Time
 			6:00	-	BDT	2009 Jun 19 23:00 # Bangladesh Time
-			6:00	1:00	BDST
+			6:00	1:00	BDST	2010
+			6:00	-	BDT
 
 # Bhutan
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]

Modified: stable/7/share/zoneinfo/europe
==============================================================================
--- stable/7/share/zoneinfo/europe	Thu Aug 27 12:24:21 2009	(r196582)
+++ stable/7/share/zoneinfo/europe	Thu Aug 27 12:27:06 2009	(r196583)
@@ -1,5 +1,5 @@
 # 
-# @(#)europe	8.21
+# @(#)europe	8.22
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -459,7 +459,7 @@ Rule	EU	1979	1995	-	Sep	lastSun	 1:00u	0
 Rule	EU	1981	max	-	Mar	lastSun	 1:00u	1:00	S
 Rule	EU	1996	max	-	Oct	lastSun	 1:00u	0	-
 # The most recent directive covers the years starting in 2002.  See:
-# 
+# 
 # Directive 2000/84/EC of the European Parliament and of the Council
 # of 19 January 2001 on summer-time arrangements.
 # 

Modified: stable/7/share/zoneinfo/leapseconds
==============================================================================
--- stable/7/share/zoneinfo/leapseconds	Thu Aug 27 12:24:21 2009	(r196582)
+++ stable/7/share/zoneinfo/leapseconds	Thu Aug 27 12:27:06 2009	(r196583)
@@ -1,5 +1,5 @@
 # 
-# @(#)leapseconds	8.8
+# @(#)leapseconds	8.9
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -58,29 +58,30 @@ Leap	2008	Dec	31	23:59:60	+	S
 # 61, Av. de l'Observatoire 75014 PARIS (France)
 # Tel.      : 33 (0) 1 40 51 22 26
 # FAX       : 33 (0) 1 40 51 22 91
-# e-mail    : services.iers@obspm.fr
-# http://hpiers.obspm.fr/eop-pc
+# Internet  : services.iers@obspm.fr
 #
-# Paris, 15 January 2009
+# Paris, 4 July 2009
 #
-# Bulletin C 37
+# Bulletin C 38
 #
 # To authorities responsible
 # for the measurement and
 # distribution of time
 #
-# NO positive leap second will be introduced at the end of June 2009.
-# The difference between Coordinated Universal Time UTC and the 
-# International Atomic Time TAI is :             
-#                
-#     from 2009 January 1, 0h UTC, until further notice : UTC-TAI = -34 s
+# INFORMATION ON UTC - TAI
+#
+# NO positive leap second will be introduced at the end of December 2009.
+# The difference between Coordinated Universal Time UTC and the
+# International Atomic Time TAI is :		
+#
+# from 2009 January 1, 0h UTC, until further notice : UTC-TAI = -34 s
 #
 # Leap seconds can be introduced in UTC at the end of the months of December
-# or June, depending on the evolution of UT1-TAI. Bulletin C is mailed every
-# six months, either to announce a time step in UTC or to confirm that there
+# or June,  depending on the evolution of UT1-TAI. Bulletin C is mailed every
+# six months, either to announce a time step in UTC, or to confirm that there
 # will be no time step at the next possible date.
 #
 # Daniel GAMBIS
-# Head		
+# Director			
 # Earth Orientation Center of IERS
 # Observatoire de Paris, France
From edwin at FreeBSD.org  Thu Aug 27 12:29:24 2009
From: edwin at FreeBSD.org (Edwin Groothuis)
Date: Thu Aug 27 12:29:56 2009
Subject: svn commit: r196586 - stable/7/share/zoneinfo
Message-ID: <200908271229.n7RCTNOv096070@svn.freebsd.org>

Author: edwin
Date: Thu Aug 27 12:29:23 2009
New Revision: 196586
URL: http://svn.freebsd.org/changeset/base/196586

Log:
  MFC of r196582: Import of tzdata2009l
  
  - Egypt will go to Wintertime on 21 August 2009
  - Heads up for a possible DST in Samoa

Modified:
  stable/7/share/zoneinfo/   (props changed)
  stable/7/share/zoneinfo/africa
  stable/7/share/zoneinfo/australasia

Modified: stable/7/share/zoneinfo/africa
==============================================================================
--- stable/7/share/zoneinfo/africa	Thu Aug 27 12:29:22 2009	(r196585)
+++ stable/7/share/zoneinfo/africa	Thu Aug 27 12:29:23 2009	(r196586)
@@ -1,5 +1,5 @@
 # 
-# @(#)africa	8.22
+# @(#)africa	8.23
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -276,8 +276,27 @@ Rule	Egypt	2007	only	-	Sep	Thu>=1	23:00s
 # In 2009 (and for the next several years), Ramadan ends before the fourth
 # Thursday in September; Egypt is expected to revert to the last Thursday
 # in September.
+
+# From Steffen Thorsen (2009-08-11):
+# We have been able to confirm the August change with the Egyptian Cabinet 
+# Information and Decision Support Center:
+# 
+# http://www.timeanddate.com/news/time/egypt-dst-ends-2009.html
+# 
+# 
+# The Middle East News Agency
+# 
+# http://www.mena.org.eg/index.aspx
+# 
+# also reports "Egypt starts winter time on August 21"
+# today in article numbered "71, 11/08/2009 12:25 GMT." 
+# Only the title above is available without a subscription to their service,
+# and can be found by searching for "winter" in their search engine
+# (at least today).
+
 Rule	Egypt	2008	only	-	Aug	lastThu	23:00s	0	-
-Rule	Egypt	2009	max	-	Sep	lastThu	23:00s	0	-
+Rule	Egypt	2009	only	-	Aug	20	23:00s	0	-
+Rule	Egypt	2010	max	-	Sep	lastThu	23:00s	0	-
 
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	Africa/Cairo	2:05:00 -	LMT	1900 Oct

Modified: stable/7/share/zoneinfo/australasia
==============================================================================
--- stable/7/share/zoneinfo/australasia	Thu Aug 27 12:29:22 2009	(r196585)
+++ stable/7/share/zoneinfo/australasia	Thu Aug 27 12:29:23 2009	(r196586)
@@ -1,5 +1,5 @@
 # 
-# @(#)australasia	8.11
+# @(#)australasia	8.12
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 
@@ -427,6 +427,22 @@ Zone Pacific/Pago_Pago	 12:37:12 -	LMT	1
 			-11:00	-	SST			# S=Samoa
 
 # Samoa
+
+# From Alexander Krivenyshev (2008-12-06):
+# The Samoa government (Western Samoa) may implement DST on the first Sunday of 
+# October 2009 (October 4, 2009) until the last Sunday of March 2010 (March 28, 
+# 2010). 
+# 
+# "Selected Committee reports to Cabinet on Daylight Saving Time",
+# Government of Samoa:
+# 
+# http://www.govt.ws/pr_article.cfm?pr_id=560
+# 
+# or
+# 
+# http://www.worldtimezone.com/dst_news/dst_news_samoa01.html
+# 
+
 Zone Pacific/Apia	 12:33:04 -	LMT	1879 Jul  5
 			-11:26:56 -	LMT	1911
 			-11:30	-	SAMT	1950		# Samoa Time
From jhb at FreeBSD.org  Thu Aug 27 15:48:59 2009
From: jhb at FreeBSD.org (John Baldwin)
Date: Thu Aug 27 15:49:16 2009
Subject: svn commit: r196590 - in stable/7/sys: . contrib/pf vm
Message-ID: <200908271548.n7RFmxVj000457@svn.freebsd.org>

Author: jhb
Date: Thu Aug 27 15:48:58 2009
New Revision: 196590
URL: http://svn.freebsd.org/changeset/base/196590

Log:
  MFC 181019, 183474, 191277, and 191626:
  - Move the code for doing out-of-memory grass from vm_pageout_scan()
    into the separate function vm_pageout_oom(). Supply a parameter for
    vm_pageout_oom() describing a reason for the call.
  - Call vm_pageout_oom() from the swp_pager_meta_build() when swap zone
    is exhausted.
  - In both pageout oom handler and vm_daemon, acquire the reference to
    the vmspace of the examined process instead of directly accessing its
    vmspace, that may change. Also, as an optimization, check for P_INEXEC
    flag before examining the process.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/vm/swap_pager.c
  stable/7/sys/vm/vm_pageout.c
  stable/7/sys/vm/vm_pageout.h

Modified: stable/7/sys/vm/swap_pager.c
==============================================================================
--- stable/7/sys/vm/swap_pager.c	Thu Aug 27 15:24:26 2009	(r196589)
+++ stable/7/sys/vm/swap_pager.c	Thu Aug 27 15:48:58 2009	(r196590)
@@ -1711,9 +1711,12 @@ retry:
 		if (swap == NULL) {
 			mtx_unlock(&swhash_mtx);
 			VM_OBJECT_UNLOCK(object);
-			if (uma_zone_exhausted(swap_zone))
+			if (uma_zone_exhausted(swap_zone)) {
 				printf("swap zone exhausted, increase kern.maxswzone\n");
-			VM_WAIT;
+				vm_pageout_oom(VM_OOM_SWAPZ);
+				pause("swzonex", 10);
+			} else
+				VM_WAIT;
 			VM_OBJECT_LOCK(object);
 			goto retry;
 		}

Modified: stable/7/sys/vm/vm_pageout.c
==============================================================================
--- stable/7/sys/vm/vm_pageout.c	Thu Aug 27 15:24:26 2009	(r196589)
+++ stable/7/sys/vm/vm_pageout.c	Thu Aug 27 15:48:58 2009	(r196590)
@@ -681,9 +681,6 @@ vm_pageout_scan(int pass)
 	struct vm_page marker;
 	int page_shortage, maxscan, pcount;
 	int addl_page_shortage, addl_page_shortage_init;
-	struct proc *p, *bigproc;
-	struct thread *td;
-	vm_offset_t size, bigsize;
 	vm_object_t object;
 	int actcount;
 	int vnodes_skipped = 0;
@@ -1173,7 +1170,23 @@ unlock_and_continue:
 	 * doing this on the first pass in order to give ourselves a
 	 * chance to flush out dirty vnode-backed pages and to allow
 	 * active pages to be moved to the inactive queue and reclaimed.
-	 *
+	 */
+	if (pass != 0 &&
+	    ((swap_pager_avail < 64 && vm_page_count_min()) ||
+	     (swap_pager_full && vm_paging_target() > 0)))
+		vm_pageout_oom(VM_OOM_MEM);
+}
+
+
+void
+vm_pageout_oom(int shortage)
+{
+	struct proc *p, *bigproc;
+	vm_offset_t size, bigsize;
+	struct thread *td;
+	struct vmspace *vm;
+
+	/*
 	 * We keep the process bigproc locked once we find it to keep anyone
 	 * from messing with it; however, there is a possibility of
 	 * deadlock if process B is bigproc and one of it's child processes
@@ -1181,79 +1194,83 @@ unlock_and_continue:
 	 * lock while walking this list.  To avoid this, we don't block on
 	 * the process lock but just skip a process if it is already locked.
 	 */
-	if (pass != 0 &&
-	    ((swap_pager_avail < 64 && vm_page_count_min()) ||
-	     (swap_pager_full && vm_paging_target() > 0))) {
-		bigproc = NULL;
-		bigsize = 0;
-		sx_slock(&allproc_lock);
-		FOREACH_PROC_IN_SYSTEM(p) {
-			int breakout;
+	bigproc = NULL;
+	bigsize = 0;
+	sx_slock(&allproc_lock);
+	FOREACH_PROC_IN_SYSTEM(p) {
+		int breakout;
 
-			if (PROC_TRYLOCK(p) == 0)
-				continue;
-			/*
-			 * If this is a system or protected process, skip it.
-			 */
-			if ((p->p_flag & P_SYSTEM) || (p->p_pid == 1) ||
-			    (p->p_flag & P_PROTECTED) ||
-			    ((p->p_pid < 48) && (swap_pager_avail != 0))) {
-				PROC_UNLOCK(p);
-				continue;
-			}
-			/*
-			 * If the process is in a non-running type state,
-			 * don't touch it.  Check all the threads individually.
-			 */
-			PROC_SLOCK(p);
-			breakout = 0;
-			FOREACH_THREAD_IN_PROC(p, td) {
-				thread_lock(td);
-				if (!TD_ON_RUNQ(td) &&
-				    !TD_IS_RUNNING(td) &&
-				    !TD_IS_SLEEPING(td)) {
-					thread_unlock(td);
-					breakout = 1;
-					break;
-				}
+		if (PROC_TRYLOCK(p) == 0)
+			continue;
+		/*
+		 * If this is a system or protected process, skip it.
+		 */
+		if ((p->p_flag & (P_INEXEC | P_PROTECTED | P_SYSTEM)) ||
+		    (p->p_pid == 1) ||
+		    ((p->p_pid < 48) && (swap_pager_avail != 0))) {
+			PROC_UNLOCK(p);
+			continue;
+		}
+		/*
+		 * If the process is in a non-running type state,
+		 * don't touch it.  Check all the threads individually.
+		 */
+		PROC_SLOCK(p);
+		breakout = 0;
+		FOREACH_THREAD_IN_PROC(p, td) {
+			thread_lock(td);
+			if (!TD_ON_RUNQ(td) &&
+			    !TD_IS_RUNNING(td) &&
+			    !TD_IS_SLEEPING(td)) {
 				thread_unlock(td);
+				breakout = 1;
+				break;
 			}
-			PROC_SUNLOCK(p);
-			if (breakout) {
-				PROC_UNLOCK(p);
-				continue;
-			}
-			/*
-			 * get the process size
-			 */
-			if (!vm_map_trylock_read(&p->p_vmspace->vm_map)) {
-				PROC_UNLOCK(p);
-				continue;
-			}
-			size = vmspace_swap_count(p->p_vmspace);
-			vm_map_unlock_read(&p->p_vmspace->vm_map);
-			size += vmspace_resident_count(p->p_vmspace);
-			/*
-			 * if the this process is bigger than the biggest one
-			 * remember it.
-			 */
-			if (size > bigsize) {
-				if (bigproc != NULL)
-					PROC_UNLOCK(bigproc);
-				bigproc = p;
-				bigsize = size;
-			} else
-				PROC_UNLOCK(p);
+			thread_unlock(td);
 		}
-		sx_sunlock(&allproc_lock);
-		if (bigproc != NULL) {
-			killproc(bigproc, "out of swap space");
-			PROC_SLOCK(bigproc);
-			sched_nice(bigproc, PRIO_MIN);
-			PROC_SUNLOCK(bigproc);
-			PROC_UNLOCK(bigproc);
-			wakeup(&cnt.v_free_count);
+		PROC_SUNLOCK(p);
+		if (breakout) {
+			PROC_UNLOCK(p);
+			continue;
+		}
+		/*
+		 * get the process size
+		 */
+		vm = vmspace_acquire_ref(p);
+		if (vm == NULL) {
+			PROC_UNLOCK(p);
+			continue;
 		}
+		if (!vm_map_trylock_read(&vm->vm_map)) {
+			vmspace_free(vm);
+			PROC_UNLOCK(p);
+			continue;
+		}
+		size = vmspace_swap_count(vm);
+		vm_map_unlock_read(&vm->vm_map);
+		if (shortage == VM_OOM_MEM)
+			size += vmspace_resident_count(vm);
+		vmspace_free(vm);
+		/*
+		 * if the this process is bigger than the biggest one
+		 * remember it.
+		 */
+		if (size > bigsize) {
+			if (bigproc != NULL)
+				PROC_UNLOCK(bigproc);
+			bigproc = p;
+			bigsize = size;
+		} else
+			PROC_UNLOCK(p);
+	}
+	sx_sunlock(&allproc_lock);
+	if (bigproc != NULL) {
+		killproc(bigproc, "out of swap space");
+		PROC_SLOCK(bigproc);
+		sched_nice(bigproc, PRIO_MIN);
+		PROC_SUNLOCK(bigproc);
+		PROC_UNLOCK(bigproc);
+		wakeup(&cnt.v_free_count);
 	}
 }
 
@@ -1528,6 +1545,7 @@ vm_daemon()
 	struct rlimit rsslim;
 	struct proc *p;
 	struct thread *td;
+	struct vmspace *vm;
 	int breakout, swapout_flags;
 
 	while (TRUE) {
@@ -1552,7 +1570,7 @@ vm_daemon()
 			 * looked at this process, skip it.
 			 */
 			PROC_LOCK(p);
-			if (p->p_flag & (P_SYSTEM | P_WEXIT)) {
+			if (p->p_flag & (P_INEXEC | P_SYSTEM | P_WEXIT)) {
 				PROC_UNLOCK(p);
 				continue;
 			}
@@ -1592,13 +1610,17 @@ vm_daemon()
 			 */
 			if ((p->p_flag & P_INMEM) == 0)
 				limit = 0;	/* XXX */
+			vm = vmspace_acquire_ref(p);
 			PROC_UNLOCK(p);
+			if (vm == NULL)
+				continue;
 
-			size = vmspace_resident_count(p->p_vmspace);
+			size = vmspace_resident_count(vm);
 			if (limit >= 0 && size >= limit) {
 				vm_pageout_map_deactivate_pages(
-				    &p->p_vmspace->vm_map, limit);
+				    &vm->vm_map, limit);
 			}
+			vmspace_free(vm);
 		}
 		sx_sunlock(&allproc_lock);
 	}

Modified: stable/7/sys/vm/vm_pageout.h
==============================================================================
--- stable/7/sys/vm/vm_pageout.h	Thu Aug 27 15:24:26 2009	(r196589)
+++ stable/7/sys/vm/vm_pageout.h	Thu Aug 27 15:48:58 2009	(r196590)
@@ -83,6 +83,9 @@ extern int vm_pageout_page_count;
 #define VM_SWAP_NORMAL 1
 #define VM_SWAP_IDLE 2
 
+#define	VM_OOM_MEM	1
+#define	VM_OOM_SWAPZ	2
+
 /*
  *	Exported routines.
  */
@@ -100,5 +103,6 @@ extern void vm_waitpfault(void);
 #ifdef _KERNEL
 boolean_t vm_pageout_fallback_object_lock(vm_page_t, vm_page_t *);
 int vm_pageout_flush(vm_page_t *, int, int);
+void vm_pageout_oom(int shortage);
 #endif
 #endif	/* _VM_VM_PAGEOUT_H_ */
From jhb at FreeBSD.org  Thu Aug 27 16:15:32 2009
From: jhb at FreeBSD.org (John Baldwin)
Date: Thu Aug 27 16:15:39 2009
Subject: svn commit: r196591 - stable/7/contrib/top
Message-ID: <200908271615.n7RGFW8g001119@svn.freebsd.org>

Author: jhb
Date: Thu Aug 27 16:15:32 2009
New Revision: 196591
URL: http://svn.freebsd.org/changeset/base/196591

Log:
  MFC 196382:
  Explicitly line up the CPU state labels with the calculated starting column
  that takes into account the width of the largest CPU ID.

Modified:
  stable/7/contrib/top/   (props changed)
  stable/7/contrib/top/display.c

Modified: stable/7/contrib/top/display.c
==============================================================================
--- stable/7/contrib/top/display.c	Thu Aug 27 15:48:58 2009	(r196590)
+++ stable/7/contrib/top/display.c	Thu Aug 27 16:15:32 2009	(r196591)
@@ -452,6 +452,7 @@ for (cpu = 0; cpu < num_cpus; cpu++) {
     lastline++;
 
     /* now walk thru the names and print the line */
+    Move_to(cpustates_column, y_cpustates + cpu);
     while ((thisname = *names++) != NULL)
     {
 	if (*thisname != '\0')
@@ -543,6 +544,7 @@ for (cpu = 0; cpu < num_cpus; cpu++) {
 	printf("\nCPU %d: ", cpu);
     lastline++;
 
+    Move_to(cpustates_column, y_cpustates + cpu);
     while ((thisname = *names++) != NULL)
     {
 	if (*thisname != '\0')
From jhb at FreeBSD.org  Thu Aug 27 17:16:43 2009
From: jhb at FreeBSD.org (John Baldwin)
Date: Thu Aug 27 17:16:55 2009
Subject: svn commit: r196595 - in stable/7/release: . scripts
Message-ID: <200908271716.n7RHGhme002541@svn.freebsd.org>

Author: jhb
Date: Thu Aug 27 17:16:42 2009
New Revision: 196595
URL: http://svn.freebsd.org/changeset/base/196595

Log:
  MFC 196521:
  Fix a few issues with the lib32 dist so that it includes ldd32.
  - Use a better find invocation to purge empty directories from all the dist
    trees during a release build.  The previous version did not purge
    directories whose contents were all empty directories.
  - Explicitly blacklist a few files from the lib32 dist instead of using a
    whitelist.  A better longterm solution is to fix the few offenders to not
    install data files during a lib32 install.

Modified:
  stable/7/release/   (props changed)
  stable/7/release/Makefile
  stable/7/release/scripts/lib32-make.sh
  stable/7/release/scripts/src-install.sh   (props changed)

Modified: stable/7/release/Makefile
==============================================================================
--- stable/7/release/Makefile	Thu Aug 27 17:16:23 2009	(r196594)
+++ stable/7/release/Makefile	Thu Aug 27 17:16:42 2009	(r196595)
@@ -653,7 +653,7 @@ release.5:
 	# Remove all the directories we don't need.
 	-cd ${RD}/trees && \
 		(find ${OTHER_DISTS} -path '*/var/empty' | xargs chflags noschg; \
-		find ${OTHER_DISTS} -depth -type d -empty -print | xargs rmdir)
+		find ${OTHER_DISTS} -depth -type d -empty -delete)
 	touch ${.TARGET}
 
 #

Modified: stable/7/release/scripts/lib32-make.sh
==============================================================================
--- stable/7/release/scripts/lib32-make.sh	Thu Aug 27 17:16:23 2009	(r196594)
+++ stable/7/release/scripts/lib32-make.sh	Thu Aug 27 17:16:42 2009	(r196595)
@@ -5,4 +5,4 @@
 
 # Clean the dust.
 cd ${RD}/trees/lib32 && \
-    find . ! -path '*/libexec/*' ! -path '*/usr/lib32/*' -delete
+    find . '(' -path '*/usr/share/*' -or -path '*/usr/lib/*' ')' -delete
From jhb at FreeBSD.org  Thu Aug 27 17:24:05 2009
From: jhb at FreeBSD.org (John Baldwin)
Date: Thu Aug 27 17:24:16 2009
Subject: svn commit: r196596 - in stable/7/release: . scripts
Message-ID: <200908271724.n7RHO56p002763@svn.freebsd.org>

Author: jhb
Date: Thu Aug 27 17:24:05 2009
New Revision: 196596
URL: http://svn.freebsd.org/changeset/base/196596

Log:
  Move mergeinfo for 180008 up to src/release.

Modified:
  stable/7/release/   (props changed)
  stable/7/release/scripts/src-install.sh   (props changed)
From jhb at FreeBSD.org  Thu Aug 27 17:26:09 2009
From: jhb at FreeBSD.org (John Baldwin)
Date: Thu Aug 27 17:26:30 2009
Subject: svn commit: r196598 - stable/7/release
Message-ID: <200908271726.n7RHQ9Ol002935@svn.freebsd.org>

Author: jhb
Date: Thu Aug 27 17:26:09 2009
New Revision: 196598
URL: http://svn.freebsd.org/changeset/base/196598

Log:
  MFC 196522:
  Invoke the recently added mm-mtree.sh release script to store a pre-built
  mergemaster mtree database in the 'base' dist.

Modified:
  stable/7/release/   (props changed)
  stable/7/release/Makefile

Modified: stable/7/release/Makefile
==============================================================================
--- stable/7/release/Makefile	Thu Aug 27 17:25:58 2009	(r196597)
+++ stable/7/release/Makefile	Thu Aug 27 17:26:09 2009	(r196598)
@@ -603,6 +603,7 @@ release.2:
 	cd ${.CURDIR}/.. && ${CROSSMAKE} distrib-dirs DESTDIR=${RD}/trees/base
 	cd ${.CURDIR}/.. && ${CROSSMAKE} ${WORLD_FLAGS} distributeworld \
 	    DISTDIR=${RD}/trees
+	sh ${.CURDIR}/scripts/mm-mtree.sh -F "${CROSSENV}" -D "${RD}/trees/base"
 	touch ${.TARGET}
 
 # Make and install the generic kernel(s).
From bz at FreeBSD.org  Thu Aug 27 17:37:00 2009
From: bz at FreeBSD.org (Bjoern A. Zeeb)
Date: Thu Aug 27 17:37:13 2009
Subject: svn commit: r196602 - in stable/7/sys: . amd64/amd64 amd64/linux32
	compat/ia32 conf contrib/pf i386/i386 i386/linux kern sys
Message-ID: <200908271737.n7RHb0KM003313@svn.freebsd.org>

Author: bz
Date: Thu Aug 27 17:36:59 2009
New Revision: 196602
URL: http://svn.freebsd.org/changeset/base/196602

Log:
  MFC r196512:
  
    Fix handling of .note.ABI-tag section for GNU systems [1].
    Handle GNU/Linux according to LSB Core Specification 4.0,
    Chapter 11. Object Format, 11.8. ABI note tag.
  
    Also check the first word of desc, not only name, according to
    glibc abi-tags specification to distinguish between Linux and
    kFreeBSD.
  
    Add explicit handling for Debian GNU/kFreeBSD, which runs
    on our kernels as well [2].
  
    In {amd64,i386}/trap.c, when checking osrel of the current process,
    also check the ABI to not change the signal behaviour for Linux
    binary processes, now that we save an osrel version for all three
    from the lists above in struct proc [2] (slightly different to HEAD).
  
    These changes make it possible to run FreeBSD, Debian GNU/kFreeBSD
    and Linux binaries on the same machine again for at least i386 and
    amd64, and no longer break kFreeBSD which was detected as GNU(/Linux).
  
  PR:		kern/135468
  Submitted by:	dchagin [1] (initial patch)
  Suggested by:	kib [2]
  Tested by:	Petr Salinger (Petr.Salinger seznam.cz) for kFreeBSD
  Reviewed by:	kib

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/amd64/elf_machdep.c
  stable/7/sys/amd64/amd64/trap.c
  stable/7/sys/amd64/linux32/linux32_sysvec.c
  stable/7/sys/compat/ia32/ia32_sysvec.c
  stable/7/sys/conf/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/i386/i386/elf_machdep.c
  stable/7/sys/i386/i386/trap.c
  stable/7/sys/i386/linux/linux_sysvec.c
  stable/7/sys/kern/imgact_elf.c
  stable/7/sys/sys/imgact_elf.h

Modified: stable/7/sys/amd64/amd64/elf_machdep.c
==============================================================================
--- stable/7/sys/amd64/amd64/elf_machdep.c	Thu Aug 27 17:34:13 2009	(r196601)
+++ stable/7/sys/amd64/amd64/elf_machdep.c	Thu Aug 27 17:36:59 2009	(r196602)
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -107,6 +108,22 @@ SYSINIT(oelf64, SI_SUB_EXEC, SI_ORDER_AN
 	(sysinit_cfunc_t) elf64_insert_brand_entry,
 	&freebsd_brand_oinfo);
 
+static Elf64_Brandinfo kfreebsd_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_X86_64,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/lib/ld-kfreebsd-x86-64.so.1",
+	.sysvec		= &elf64_freebsd_sysvec,
+	.interp_newpath	= NULL,
+	.brand_note	= &elf64_kfreebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
+};
+
+SYSINIT(kelf64, SI_SUB_EXEC, SI_ORDER_ANY,
+	(sysinit_cfunc_t) elf64_insert_brand_entry,
+	&kfreebsd_brand_info);
+
 
 void
 elf64_dump_thread(struct thread *td __unused, void *dst __unused,

Modified: stable/7/sys/amd64/amd64/trap.c
==============================================================================
--- stable/7/sys/amd64/amd64/trap.c	Thu Aug 27 17:34:13 2009	(r196601)
+++ stable/7/sys/amd64/amd64/trap.c	Thu Aug 27 17:36:59 2009	(r196602)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
  */
 
 #include "opt_clock.h"
+#include "opt_compat.h"
 #include "opt_cpu.h"
 #include "opt_hwpmc_hooks.h"
 #include "opt_isa.h"
@@ -115,6 +116,13 @@ dtrace_doubletrap_func_t	dtrace_doubletr
 systrace_probe_func_t	systrace_probe_func;
 #endif
 
+/* Defined in amd64/amd64/elf_machdep.c. */
+extern struct sysentvec elf64_freebsd_sysvec;
+#ifdef COMPAT_IA32
+/* Defined in compat/ia32/ia32_sysvec.c. */
+extern struct sysentvec ia32_freebsd_sysvec;
+#endif
+
 extern void trap(struct trapframe *frame);
 extern void syscall(struct trapframe *frame);
 void dblfault_handler(struct trapframe *frame);
@@ -359,7 +367,13 @@ trap(struct trapframe *frame)
 					 * This check also covers the images
 					 * without the ABI-tag ELF note.
 					 */
-					if (p->p_osrel >= 700004) {
+					if ((curproc->p_sysent ==
+					    &elf64_freebsd_sysvec
+#ifdef COMPAT_IA32
+					    || curproc->p_sysent ==
+					    &ia32_freebsd_sysvec
+#endif
+					    ) && p->p_osrel >= 700004) {
 						i = SIGSEGV;
 						ucode = SEGV_ACCERR;
 					} else {

Modified: stable/7/sys/amd64/linux32/linux32_sysvec.c
==============================================================================
--- stable/7/sys/amd64/linux32/linux32_sysvec.c	Thu Aug 27 17:34:13 2009	(r196601)
+++ stable/7/sys/amd64/linux32/linux32_sysvec.c	Thu Aug 27 17:36:59 2009	(r196602)
@@ -126,6 +126,7 @@ static void     linux_sendsig(sig_t catc
 static void	exec_linux_setregs(struct thread *td, u_long entry,
 				   u_long stack, u_long ps_strings);
 static void	linux32_fixlimit(struct rlimit *rl, int which);
+static boolean_t linux32_trans_osrel(const Elf_Note *note, int32_t *osrel);
 
 static eventhandler_tag linux_exit_tag;
 static eventhandler_tag linux_schedtail_tag;
@@ -1055,14 +1056,38 @@ struct sysentvec elf_linux_sysvec = {
 	.sv_maxssiz	= &linux32_maxssiz,
 };
 
-static char GNULINUX_ABI_VENDOR[] = "GNU";
+static char GNU_ABI_VENDOR[] = "GNU";
+static int GNULINUX_ABI_DESC = 0;
+
+static boolean_t
+linux32_trans_osrel(const Elf_Note *note, int32_t *osrel)
+{
+	const Elf32_Word *desc;
+	uintptr_t p;
+
+	p = (uintptr_t)(note + 1);
+	p += roundup2(note->n_namesz, sizeof(Elf32_Addr));
+
+	desc = (const Elf32_Word *)p;
+	if (desc[0] != GNULINUX_ABI_DESC)
+		return (FALSE);
+
+	/*
+	 * For linux we encode osrel as follows (see linux_mib.c):
+	 * VVVMMMIII (version, major, minor), see linux_mib.c.
+	 */
+	*osrel = desc[1] * 1000000 + desc[2] * 1000 + desc[3];
+
+	return (TRUE);
+}
 
 static Elf_Brandnote linux32_brandnote = {
-	.hdr.n_namesz	= sizeof(GNULINUX_ABI_VENDOR),
-	.hdr.n_descsz	= 16,
+	.hdr.n_namesz	= sizeof(GNU_ABI_VENDOR),
+	.hdr.n_descsz	= 16,	/* XXX at least 16 */
 	.hdr.n_type	= 1,
-	.vendor		= GNULINUX_ABI_VENDOR,
-	.flags		= 0
+	.vendor		= GNU_ABI_VENDOR,
+	.flags		= BN_TRANSLATE_OSREL,
+	.trans_osrel	= linux32_trans_osrel
 };
 
 static Elf32_Brandinfo linux_brand = {

Modified: stable/7/sys/compat/ia32/ia32_sysvec.c
==============================================================================
--- stable/7/sys/compat/ia32/ia32_sysvec.c	Thu Aug 27 17:34:13 2009	(r196601)
+++ stable/7/sys/compat/ia32/ia32_sysvec.c	Thu Aug 27 17:36:59 2009	(r196602)
@@ -171,6 +171,21 @@ SYSINIT(oia32, SI_SUB_EXEC, SI_ORDER_ANY
 	(sysinit_cfunc_t) elf32_insert_brand_entry,
 	&ia32_brand_oinfo);
 
+static Elf32_Brandinfo kia32_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_386,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/lib/ld.so.1",
+	.sysvec		= &ia32_freebsd_sysvec,
+	.brand_note	= &elf32_kfreebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
+};
+
+SYSINIT(kia32, SI_SUB_EXEC, SI_ORDER_ANY,
+	(sysinit_cfunc_t) elf32_insert_brand_entry,
+	&kia32_brand_info);
+
 
 void
 elf32_dump_thread(struct thread *td __unused, void *dst __unused,

Modified: stable/7/sys/i386/i386/elf_machdep.c
==============================================================================
--- stable/7/sys/i386/i386/elf_machdep.c	Thu Aug 27 17:34:13 2009	(r196601)
+++ stable/7/sys/i386/i386/elf_machdep.c	Thu Aug 27 17:36:59 2009	(r196602)
@@ -107,6 +107,22 @@ SYSINIT(oelf32, SI_SUB_EXEC, SI_ORDER_AN
 	(sysinit_cfunc_t) elf32_insert_brand_entry,
 	&freebsd_brand_oinfo);
 
+static Elf32_Brandinfo kfreebsd_brand_info = {
+	.brand		= ELFOSABI_FREEBSD,
+	.machine	= EM_386,
+	.compat_3_brand	= "FreeBSD",
+	.emul_path	= NULL,
+	.interp_path	= "/lib/ld.so.1",
+	.sysvec		= &elf32_freebsd_sysvec,
+	.interp_newpath	= NULL,
+	.brand_note	= &elf32_kfreebsd_brandnote,
+	.flags		= BI_CAN_EXEC_DYN | BI_BRAND_NOTE
+};
+
+SYSINIT(kelf32, SI_SUB_EXEC, SI_ORDER_ANY,
+	(sysinit_cfunc_t) elf32_insert_brand_entry,
+	&kfreebsd_brand_info);
+
 
 void
 elf32_dump_thread(struct thread *td __unused, void *dst __unused,

Modified: stable/7/sys/i386/i386/trap.c
==============================================================================
--- stable/7/sys/i386/i386/trap.c	Thu Aug 27 17:34:13 2009	(r196601)
+++ stable/7/sys/i386/i386/trap.c	Thu Aug 27 17:36:59 2009	(r196602)
@@ -123,6 +123,9 @@ dtrace_doubletrap_func_t	dtrace_doubletr
 systrace_probe_func_t	systrace_probe_func;
 #endif
 
+/* Defined in i386/i386/elf_machdep.c. */
+extern struct sysentvec elf32_freebsd_sysvec;
+
 extern void trap(struct trapframe *frame);
 extern void syscall(struct trapframe *frame);
 
@@ -423,7 +426,9 @@ trap(struct trapframe *frame)
 					 * This check also covers the images
 					 * without the ABI-tag ELF note.
 					 */
-					if (p->p_osrel >= 700004) {
+					if (curproc->p_sysent ==
+					    &elf32_freebsd_sysvec &&
+					    p->p_osrel >= 700004) {
 						i = SIGSEGV;
 						ucode = SEGV_ACCERR;
 					} else {

Modified: stable/7/sys/i386/linux/linux_sysvec.c
==============================================================================
--- stable/7/sys/i386/linux/linux_sysvec.c	Thu Aug 27 17:34:13 2009	(r196601)
+++ stable/7/sys/i386/linux/linux_sysvec.c	Thu Aug 27 17:36:59 2009	(r196602)
@@ -107,6 +107,7 @@ static void     linux_sendsig(sig_t catc
 static void	exec_linux_setregs(struct thread *td, u_long entry,
 				   u_long stack, u_long ps_strings);
 static register_t *linux_copyout_strings(struct image_params *imgp);
+static boolean_t linux_trans_osrel(const Elf_Note *note, int32_t *osrel);
 
 static int linux_szplatform;
 const char *linux_platform;
@@ -1025,14 +1026,38 @@ struct sysentvec elf_linux_sysvec = {
 	.sv_maxssiz	= NULL
 };
 
-static char GNULINUX_ABI_VENDOR[] = "GNU";
+static char GNU_ABI_VENDOR[] = "GNU";
+static int GNULINUX_ABI_DESC = 0;
+
+static boolean_t
+linux_trans_osrel(const Elf_Note *note, int32_t *osrel)
+{
+	const Elf32_Word *desc;
+	uintptr_t p;
+
+	p = (uintptr_t)(note + 1);
+	p += roundup2(note->n_namesz, sizeof(Elf32_Addr));
+
+	desc = (const Elf32_Word *)p;
+	if (desc[0] != GNULINUX_ABI_DESC)
+		return (FALSE);
+
+	/*
+	 * For linux we encode osrel as follows (see linux_mib.c):
+	 * VVVMMMIII (version, major, minor), see linux_mib.c.
+	 */
+	*osrel = desc[1] * 1000000 + desc[2] * 1000 + desc[3];
+
+	return (TRUE);
+}
 
 static Elf_Brandnote linux_brandnote = {
-	.hdr.n_namesz	= sizeof(GNULINUX_ABI_VENDOR),
-	.hdr.n_descsz	= 16,
+	.hdr.n_namesz	= sizeof(GNU_ABI_VENDOR),
+	.hdr.n_descsz	= 16,	/* XXX at least 16 */
 	.hdr.n_type	= 1,
-	.vendor		= GNULINUX_ABI_VENDOR,
-	.flags		= 0
+	.vendor		= GNU_ABI_VENDOR,
+	.flags		= BN_TRANSLATE_OSREL,
+	.trans_osrel	= linux_trans_osrel
 };
 
 static Elf32_Brandinfo linux_brand = {

Modified: stable/7/sys/kern/imgact_elf.c
==============================================================================
--- stable/7/sys/kern/imgact_elf.c	Thu Aug 27 17:34:13 2009	(r196601)
+++ stable/7/sys/kern/imgact_elf.c	Thu Aug 27 17:36:59 2009	(r196602)
@@ -86,6 +86,9 @@ static int __elfN(load_section)(struct v
     vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz,
     vm_prot_t prot, size_t pagesize);
 static int __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp);
+static boolean_t __elfN(freebsd_trans_osrel)(const Elf_Note *note,
+    int32_t *osrel);
+static boolean_t kfreebsd_trans_osrel(const Elf_Note *note, int32_t *osrel);
 static boolean_t __elfN(check_note)(struct image_params *imgp,
     Elf_Brandnote *checknote, int32_t *osrel);
 
@@ -119,9 +122,56 @@ Elf_Brandnote __elfN(freebsd_brandnote) 
 	.hdr.n_descsz	= sizeof(int32_t),
 	.hdr.n_type	= 1,
 	.vendor		= FREEBSD_ABI_VENDOR,
-	.flags		= BN_CAN_FETCH_OSREL
+	.flags		= BN_TRANSLATE_OSREL,
+	.trans_osrel	= __elfN(freebsd_trans_osrel)
 };
 
+static boolean_t
+__elfN(freebsd_trans_osrel)(const Elf_Note *note, int32_t *osrel)
+{
+	uintptr_t p;
+
+	p = (uintptr_t)(note + 1);
+	p += roundup2(note->n_namesz, sizeof(Elf32_Addr));
+	*osrel = *(const int32_t *)(p);
+
+	return (TRUE);
+}
+
+static const char GNU_ABI_VENDOR[] = "GNU";
+static int GNU_KFREEBSD_ABI_DESC = 3;
+
+Elf_Brandnote __elfN(kfreebsd_brandnote) = {
+	.hdr.n_namesz	= sizeof(GNU_ABI_VENDOR),
+	.hdr.n_descsz	= 16,	/* XXX at least 16 */
+	.hdr.n_type	= 1,
+	.vendor		= GNU_ABI_VENDOR,
+	.flags		= BN_TRANSLATE_OSREL,
+	.trans_osrel	= kfreebsd_trans_osrel
+};
+
+static boolean_t
+kfreebsd_trans_osrel(const Elf_Note *note, int32_t *osrel)
+{
+	const Elf32_Word *desc;
+	uintptr_t p;
+
+	p = (uintptr_t)(note + 1);
+	p += roundup2(note->n_namesz, sizeof(Elf32_Addr));
+
+	desc = (const Elf32_Word *)p;
+	if (desc[0] != GNU_KFREEBSD_ABI_DESC)
+		return (FALSE);
+
+	/*
+	 * Debian GNU/kFreeBSD embed the earliest compatible kernel version
+	 * (__FreeBSD_version: Rxx) in the LSB way.
+	 */
+	*osrel = desc[1] * 100000 + desc[2] * 1000 + desc[3];
+
+	return (TRUE);
+}
+
 int
 __elfN(insert_brand_entry)(Elf_Brandinfo *entry)
 {
@@ -1382,11 +1432,9 @@ __elfN(check_note)(struct image_params *
 		 * Fetch the osreldate for binary
 		 * from the ELF OSABI-note if necessary.
 		 */
-		if ((checknote->flags & BN_CAN_FETCH_OSREL) != 0 &&
-		    osrel != NULL)
-			*osrel = *(const int32_t *) (note_name +
-			    roundup2(checknote->hdr.n_namesz,
-			    sizeof(Elf32_Addr)));
+		if ((checknote->flags & BN_TRANSLATE_OSREL) != 0 &&
+		    checknote->trans_osrel != NULL)
+			return (checknote->trans_osrel(note, osrel));
 		return (TRUE);
 
 nextnote:

Modified: stable/7/sys/sys/imgact_elf.h
==============================================================================
--- stable/7/sys/sys/imgact_elf.h	Thu Aug 27 17:34:13 2009	(r196601)
+++ stable/7/sys/sys/imgact_elf.h	Thu Aug 27 17:36:59 2009	(r196602)
@@ -59,7 +59,10 @@ typedef struct {
 	Elf_Note	hdr;
 	const char *	vendor;
 	int		flags;
-#define	BN_CAN_FETCH_OSREL	0x0001
+	boolean_t	(*trans_osrel)(const Elf_Note *, int32_t *);
+#define	BN_CAN_FETCH_OSREL	0x0001	/* Deprecated. */
+#define	BN_TRANSLATE_OSREL	0x0002	/* Use trans_osrel fetch osrel after */
+					/* checking ABI contraint if needed. */
 } Elf_Brandnote;
 
 typedef struct {
@@ -92,6 +95,7 @@ void	__elfN(dump_thread)(struct thread *
 
 extern	int __elfN(fallback_brand);
 extern Elf_Brandnote __elfN(freebsd_brandnote);
+extern Elf_Brandnote __elfN(kfreebsd_brandnote);
 #endif /* _KERNEL */
 
 #endif /* !_SYS_IMGACT_ELF_H_ */
From jhb at FreeBSD.org  Thu Aug 27 18:52:55 2009
From: jhb at FreeBSD.org (John Baldwin)
Date: Thu Aug 27 18:53:08 2009
Subject: svn commit: r196606 - in stable/7/sys: . conf contrib/pf
Message-ID: <200908271852.n7RIqtdX005105@svn.freebsd.org>

Author: jhb
Date: Thu Aug 27 18:52:55 2009
New Revision: 196606
URL: http://svn.freebsd.org/changeset/base/196606

Log:
  Tidy up some confused mergeinfo in sys/.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/conf/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
From jhb at FreeBSD.org  Fri Aug 28 14:22:01 2009
From: jhb at FreeBSD.org (John Baldwin)
Date: Fri Aug 28 14:22:19 2009
Subject: svn commit: r196616 - in stable/7/sys: . amd64/amd64 amd64/include
	contrib/pf dev/hwpmc i386/i386 i386/include
Message-ID: <200908281422.n7SEM13j027214@svn.freebsd.org>

Author: jhb
Date: Fri Aug 28 14:22:01 2009
New Revision: 196616
URL: http://svn.freebsd.org/changeset/base/196616

Log:
  MFC 196224:
  Adjust the handling of the local APIC PMC interrupt vector:
  - Provide lapic_disable_pmc(), lapic_enable_pmc(), and lapic_reenable_pmc()
    routines in the local APIC code that the hwpmc(4) driver can use to
    manage the local APIC PMC interrupt vector.
  - Do not enable the local APIC PMC interrupt vector by default when
    HWPMC_HOOKS is enabled.  Instead, the hwpmc(4) driver explicitly
    enables the interrupt when it is succesfully initialized and disables
    the interrupt when it is unloaded.  This avoids enabling the interrupt
    on unsupported CPUs which may result in spurious NMIs.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/amd64/amd64/local_apic.c
  stable/7/sys/amd64/include/apicvar.h
  stable/7/sys/amd64/include/pmc_mdep.h
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/hwpmc/hwpmc_core.c
  stable/7/sys/dev/hwpmc/hwpmc_piv.c
  stable/7/sys/dev/hwpmc/hwpmc_ppro.c
  stable/7/sys/dev/hwpmc/hwpmc_x86.c
  stable/7/sys/i386/i386/local_apic.c
  stable/7/sys/i386/include/apicvar.h
  stable/7/sys/i386/include/pmc_mdep.h

Modified: stable/7/sys/amd64/amd64/local_apic.c
==============================================================================
--- stable/7/sys/amd64/amd64/local_apic.c	Fri Aug 28 14:06:55 2009	(r196615)
+++ stable/7/sys/amd64/amd64/local_apic.c	Fri Aug 28 14:22:01 2009	(r196616)
@@ -119,7 +119,7 @@ static struct lvt lvts[LVT_MAX + 1] = {
 	{ 1, 1, 0, 1, APIC_LVT_DM_NMI, 0 },	/* LINT1: NMI */
 	{ 1, 1, 1, 1, APIC_LVT_DM_FIXED, APIC_TIMER_INT },	/* Timer */
 	{ 1, 1, 1, 1, APIC_LVT_DM_FIXED, APIC_ERROR_INT },	/* Error */
-	{ 1, 1, 0, 1, APIC_LVT_DM_NMI, 0 },	/* PMC */
+	{ 1, 1, 1, 1, APIC_LVT_DM_NMI, 0 },	/* PMC */
 	{ 1, 1, 1, 1, APIC_LVT_DM_FIXED, APIC_THERMAL_INT },	/* Thermal */
 };
 
@@ -299,11 +299,9 @@ lapic_setup(int boot)
 	/* Program LINT[01] LVT entries. */
 	lapic->lvt_lint0 = lvt_mode(la, LVT_LINT0, lapic->lvt_lint0);
 	lapic->lvt_lint1 = lvt_mode(la, LVT_LINT1, lapic->lvt_lint1);
-#ifdef	HWPMC_HOOKS
 	/* Program the PMC LVT entry if present. */
 	if (maxlvt >= LVT_PMC)
 		lapic->lvt_pcint = lvt_mode(la, LVT_PMC, lapic->lvt_pcint);
-#endif
 
 	/* Program timer LVT and setup handler. */
 	lapic->lvt_timer = lvt_mode(la, LVT_TIMER, lapic->lvt_timer);
@@ -349,6 +347,88 @@ lapic_setup(int boot)
 	intr_restore(eflags);
 }
 
+void
+lapic_reenable_pmc(void)
+{
+#ifdef HWPMC_HOOKS
+	uint32_t value;
+
+	value =  lapic->lvt_pcint;
+	value &= ~APIC_LVT_M;
+	lapic->lvt_pcint = value;
+#endif
+}
+
+#ifdef HWPMC_HOOKS
+static void
+lapic_update_pmc(void *dummy)
+{
+	struct lapic *la;
+
+	la = &lapics[lapic_id()];
+	lapic->lvt_pcint = lvt_mode(la, LVT_PMC, lapic->lvt_pcint);
+}
+#endif
+
+int
+lapic_enable_pmc(void)
+{
+#ifdef HWPMC_HOOKS
+	u_int32_t maxlvt;
+
+	/* Fail if the local APIC is not present. */
+	if (lapic == NULL)
+		return (0);
+
+	/* Fail if the PMC LVT is not present. */
+	maxlvt = (lapic->version & APIC_VER_MAXLVT) >> MAXLVTSHIFT;
+	if (maxlvt < LVT_PMC)
+		return (0);
+
+	lvts[LVT_PMC].lvt_masked = 0;
+
+#ifdef SMP
+	/*
+	 * If hwpmc was loaded at boot time then the APs may not be
+	 * started yet.  In that case, don't forward the request to
+	 * them as they will program the lvt when they start.
+	 */
+	if (smp_started)
+		smp_rendezvous(NULL, lapic_update_pmc, NULL, NULL);
+	else
+#endif
+		lapic_update_pmc(NULL);
+	return (1);
+#else
+	return (0);
+#endif
+}
+
+void
+lapic_disable_pmc(void)
+{
+#ifdef HWPMC_HOOKS
+	u_int32_t maxlvt;
+
+	/* Fail if the local APIC is not present. */
+	if (lapic == NULL)
+		return;
+
+	/* Fail if the PMC LVT is not present. */
+	maxlvt = (lapic->version & APIC_VER_MAXLVT) >> MAXLVTSHIFT;
+	if (maxlvt < LVT_PMC)
+		return;
+
+	lvts[LVT_PMC].lvt_masked = 1;
+
+#ifdef SMP
+	/* The APs should always be started when hwpmc is unloaded. */
+	KASSERT(mp_ncpus == 1 || smp_started, ("hwpmc unloaded too early"));
+#endif
+	smp_rendezvous(NULL, lapic_update_pmc, NULL, NULL);
+#endif
+}
+
 /*
  * Called by cpu_initclocks() on the BSP to setup the local APIC timer so
  * that it can drive hardclock, statclock, and profclock.  This function

Modified: stable/7/sys/amd64/include/apicvar.h
==============================================================================
--- stable/7/sys/amd64/include/apicvar.h	Fri Aug 28 14:06:55 2009	(r196615)
+++ stable/7/sys/amd64/include/apicvar.h	Fri Aug 28 14:22:01 2009	(r196616)
@@ -198,7 +198,9 @@ int	ioapic_set_triggermode(void *cookie,
 int	ioapic_set_smi(void *cookie, u_int pin);
 void	lapic_create(u_int apic_id, int boot_cpu);
 void	lapic_disable(void);
+void	lapic_disable_pmc(void);
 void	lapic_dump(const char *str);
+int	lapic_enable_pmc(void);
 void	lapic_eoi(void);
 int	lapic_id(void);
 void	lapic_init(vm_paddr_t addr);
@@ -208,6 +210,7 @@ void	lapic_ipi_vectored(u_int vector, in
 int	lapic_ipi_wait(int delay);
 void	lapic_handle_intr(int vector, struct trapframe *frame);
 void	lapic_handle_timer(struct trapframe *frame);
+void	lapic_reenable_pmc(void);
 void	lapic_set_logical_id(u_int apic_id, u_int cluster, u_int cluster_id);
 int	lapic_set_lvt_mask(u_int apic_id, u_int lvt, u_char masked);
 int	lapic_set_lvt_mode(u_int apic_id, u_int lvt, u_int32_t mode);

Modified: stable/7/sys/amd64/include/pmc_mdep.h
==============================================================================
--- stable/7/sys/amd64/include/pmc_mdep.h	Fri Aug 28 14:06:55 2009	(r196615)
+++ stable/7/sys/amd64/include/pmc_mdep.h	Fri Aug 28 14:22:01 2009	(r196616)
@@ -115,7 +115,6 @@ union pmc_md_pmc {
  */
 
 void	start_exceptions(void), end_exceptions(void);
-void	pmc_x86_lapic_enable_pmc_interrupt(void);
 
 struct pmc_mdep *pmc_amd_initialize(void);
 void	pmc_amd_finalize(struct pmc_mdep *_md);

Modified: stable/7/sys/dev/hwpmc/hwpmc_core.c
==============================================================================
--- stable/7/sys/dev/hwpmc/hwpmc_core.c	Fri Aug 28 14:06:55 2009	(r196615)
+++ stable/7/sys/dev/hwpmc/hwpmc_core.c	Fri Aug 28 14:22:01 2009	(r196616)
@@ -32,10 +32,13 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
 #include 
 #include 
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -1771,7 +1774,7 @@ core_intr(int cpu, struct trapframe *tf)
 	}
 
 	if (found_interrupt)
-		pmc_x86_lapic_enable_pmc_interrupt();
+		lapic_reenable_pmc();
 
 	atomic_add_int(found_interrupt ? &pmc_stats.pm_intr_processed :
 	    &pmc_stats.pm_intr_ignored, 1);
@@ -1895,7 +1898,7 @@ core2_intr(int cpu, struct trapframe *tf
 	    (uintmax_t) rdmsr(IA_GLOBAL_OVF_CTRL));
 
 	if (found_interrupt)
-		pmc_x86_lapic_enable_pmc_interrupt();
+		lapic_reenable_pmc();
 
 	atomic_add_int(found_interrupt ? &pmc_stats.pm_intr_processed :
 	    &pmc_stats.pm_intr_ignored, 1);

Modified: stable/7/sys/dev/hwpmc/hwpmc_piv.c
==============================================================================
--- stable/7/sys/dev/hwpmc/hwpmc_piv.c	Fri Aug 28 14:06:55 2009	(r196615)
+++ stable/7/sys/dev/hwpmc/hwpmc_piv.c	Fri Aug 28 14:22:01 2009	(r196616)
@@ -32,6 +32,7 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -39,6 +40,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -1537,7 +1540,7 @@ p4_intr(int cpu, struct trapframe *tf)
 	 */
 
 	if (did_interrupt)
-		pmc_x86_lapic_enable_pmc_interrupt();
+		lapic_reenable_pmc();
 
 	atomic_add_int(did_interrupt ? &pmc_stats.pm_intr_processed :
 	    &pmc_stats.pm_intr_ignored, 1);

Modified: stable/7/sys/dev/hwpmc/hwpmc_ppro.c
==============================================================================
--- stable/7/sys/dev/hwpmc/hwpmc_ppro.c	Fri Aug 28 14:06:55 2009	(r196615)
+++ stable/7/sys/dev/hwpmc/hwpmc_ppro.c	Fri Aug 28 14:22:01 2009	(r196616)
@@ -32,6 +32,7 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -39,6 +40,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -718,7 +721,7 @@ p6_intr(int cpu, struct trapframe *tf)
 	 * unmasked after a PMC interrupt.
 	 */
 	if (retval)
-		pmc_x86_lapic_enable_pmc_interrupt();
+		lapic_reenable_pmc();
 
 	atomic_add_int(retval ? &pmc_stats.pm_intr_processed :
 	    &pmc_stats.pm_intr_ignored, 1);

Modified: stable/7/sys/dev/hwpmc/hwpmc_x86.c
==============================================================================
--- stable/7/sys/dev/hwpmc/hwpmc_x86.c	Fri Aug 28 14:06:55 2009	(r196615)
+++ stable/7/sys/dev/hwpmc/hwpmc_x86.c	Fri Aug 28 14:22:01 2009	(r196616)
@@ -39,7 +39,8 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
+#include 
+#include 
 #include 
 #include 
 
@@ -47,18 +48,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-extern volatile lapic_t *lapic;
-
-void
-pmc_x86_lapic_enable_pmc_interrupt(void)
-{
-	uint32_t value;
-
-	value =  lapic->lvt_pcint;
-	value &= ~APIC_LVT_M;
-	lapic->lvt_pcint = value;
-}
-
 /*
  * Attempt to walk a user call stack using a too-simple algorithm.
  * In the general case we need unwind information associated with
@@ -252,16 +241,15 @@ pmc_md_initialize()
 	struct pmc_mdep *md;
 
 	/* determine the CPU kind */
-	md = NULL;
 	if (cpu_vendor_id == CPU_VENDOR_AMD)
 		md = pmc_amd_initialize();
 	else if (cpu_vendor_id == CPU_VENDOR_INTEL)
 		md = pmc_intel_initialize();
 	else
-		KASSERT(0, ("[x86,%d] Unknown vendor", __LINE__));
+		return (NULL);
 
 	/* disallow sampling if we do not have an LAPIC */
-	if (md != NULL && lapic == NULL)
+	if (!lapic_enable_pmc())
 		for (i = 1; i < md->pmd_nclass; i++)
 			md->pmd_classdep[i].pcd_caps &= ~PMC_CAP_INTERRUPT;
 
@@ -271,6 +259,8 @@ pmc_md_initialize()
 void
 pmc_md_finalize(struct pmc_mdep *md)
 {
+
+	lapic_disable_pmc();
 	if (cpu_vendor_id == CPU_VENDOR_AMD)
 		pmc_amd_finalize(md);
 	else if (cpu_vendor_id == CPU_VENDOR_INTEL)

Modified: stable/7/sys/i386/i386/local_apic.c
==============================================================================
--- stable/7/sys/i386/i386/local_apic.c	Fri Aug 28 14:06:55 2009	(r196615)
+++ stable/7/sys/i386/i386/local_apic.c	Fri Aug 28 14:22:01 2009	(r196616)
@@ -119,7 +119,7 @@ static struct lvt lvts[LVT_MAX + 1] = {
 	{ 1, 1, 0, 1, APIC_LVT_DM_NMI, 0 },	/* LINT1: NMI */
 	{ 1, 1, 1, 1, APIC_LVT_DM_FIXED, APIC_TIMER_INT },	/* Timer */
 	{ 1, 1, 1, 1, APIC_LVT_DM_FIXED, APIC_ERROR_INT },	/* Error */
-	{ 1, 1, 0, 1, APIC_LVT_DM_NMI, 0 },	/* PMC */
+	{ 1, 1, 1, 1, APIC_LVT_DM_NMI, 0 },	/* PMC */
 	{ 1, 1, 1, 1, APIC_LVT_DM_FIXED, APIC_THERMAL_INT },	/* Thermal */
 };
 
@@ -301,11 +301,9 @@ lapic_setup(int boot)
 	/* Program LINT[01] LVT entries. */
 	lapic->lvt_lint0 = lvt_mode(la, LVT_LINT0, lapic->lvt_lint0);
 	lapic->lvt_lint1 = lvt_mode(la, LVT_LINT1, lapic->lvt_lint1);
-#ifdef	HWPMC_HOOKS
 	/* Program the PMC LVT entry if present. */
 	if (maxlvt >= LVT_PMC)
 		lapic->lvt_pcint = lvt_mode(la, LVT_PMC, lapic->lvt_pcint);
-#endif
 
 	/* Program timer LVT and setup handler. */
 	lapic->lvt_timer = lvt_mode(la, LVT_TIMER, lapic->lvt_timer);
@@ -351,6 +349,88 @@ lapic_setup(int boot)
 	intr_restore(eflags);
 }
 
+void
+lapic_reenable_pmc(void)
+{
+#ifdef HWPMC_HOOKS
+	uint32_t value;
+
+	value =  lapic->lvt_pcint;
+	value &= ~APIC_LVT_M;
+	lapic->lvt_pcint = value;
+#endif
+}
+
+#ifdef HWPMC_HOOKS
+static void
+lapic_update_pmc(void *dummy)
+{
+	struct lapic *la;
+
+	la = &lapics[lapic_id()];
+	lapic->lvt_pcint = lvt_mode(la, LVT_PMC, lapic->lvt_pcint);
+}
+#endif
+
+int
+lapic_enable_pmc(void)
+{
+#ifdef HWPMC_HOOKS
+	u_int32_t maxlvt;
+
+	/* Fail if the local APIC is not present. */
+	if (lapic == NULL)
+		return (0);
+
+	/* Fail if the PMC LVT is not present. */
+	maxlvt = (lapic->version & APIC_VER_MAXLVT) >> MAXLVTSHIFT;
+	if (maxlvt < LVT_PMC)
+		return (0);
+
+	lvts[LVT_PMC].lvt_masked = 0;
+
+#ifdef SMP
+	/*
+	 * If hwpmc was loaded at boot time then the APs may not be
+	 * started yet.  In that case, don't forward the request to
+	 * them as they will program the lvt when they start.
+	 */
+	if (smp_started)
+		smp_rendezvous(NULL, lapic_update_pmc, NULL, NULL);
+	else
+#endif
+		lapic_update_pmc(NULL);
+	return (1);
+#else
+	return (0);
+#endif
+}
+
+void
+lapic_disable_pmc(void)
+{
+#ifdef HWPMC_HOOKS
+	u_int32_t maxlvt;
+
+	/* Fail if the local APIC is not present. */
+	if (lapic == NULL)
+		return;
+
+	/* Fail if the PMC LVT is not present. */
+	maxlvt = (lapic->version & APIC_VER_MAXLVT) >> MAXLVTSHIFT;
+	if (maxlvt < LVT_PMC)
+		return;
+
+	lvts[LVT_PMC].lvt_masked = 1;
+
+#ifdef SMP
+	/* The APs should always be started when hwpmc is unloaded. */
+	KASSERT(mp_ncpus == 1 || smp_started, ("hwpmc unloaded too early"));
+#endif
+	smp_rendezvous(NULL, lapic_update_pmc, NULL, NULL);
+#endif
+}
+
 /*
  * Called by cpu_initclocks() on the BSP to setup the local APIC timer so
  * that it can drive hardclock, statclock, and profclock.  This function

Modified: stable/7/sys/i386/include/apicvar.h
==============================================================================
--- stable/7/sys/i386/include/apicvar.h	Fri Aug 28 14:06:55 2009	(r196615)
+++ stable/7/sys/i386/include/apicvar.h	Fri Aug 28 14:22:01 2009	(r196616)
@@ -197,7 +197,9 @@ int	ioapic_set_triggermode(void *cookie,
 int	ioapic_set_smi(void *cookie, u_int pin);
 void	lapic_create(u_int apic_id, int boot_cpu);
 void	lapic_disable(void);
+void	lapic_disable_pmc(void);
 void	lapic_dump(const char *str);
+int	lapic_enable_pmc(void);
 void	lapic_eoi(void);
 int	lapic_id(void);
 void	lapic_init(vm_paddr_t addr);
@@ -207,6 +209,7 @@ void	lapic_ipi_vectored(u_int vector, in
 int	lapic_ipi_wait(int delay);
 void	lapic_handle_intr(int vector, struct trapframe *frame);
 void	lapic_handle_timer(struct trapframe *frame);
+void	lapic_reenable_pmc(void);
 void	lapic_set_logical_id(u_int apic_id, u_int cluster, u_int cluster_id);
 int	lapic_set_lvt_mask(u_int apic_id, u_int lvt, u_char masked);
 int	lapic_set_lvt_mode(u_int apic_id, u_int lvt, u_int32_t mode);

Modified: stable/7/sys/i386/include/pmc_mdep.h
==============================================================================
--- stable/7/sys/i386/include/pmc_mdep.h	Fri Aug 28 14:06:55 2009	(r196615)
+++ stable/7/sys/i386/include/pmc_mdep.h	Fri Aug 28 14:22:01 2009	(r196616)
@@ -150,7 +150,6 @@ struct pmc_mdep;
  */
 
 void	start_exceptions(void), end_exceptions(void);
-void	pmc_x86_lapic_enable_pmc_interrupt(void);
 
 struct pmc_mdep *pmc_amd_initialize(void);
 void	pmc_amd_finalize(struct pmc_mdep *_md);
From dougb at FreeBSD.org  Sat Aug 29 19:47:39 2009
From: dougb at FreeBSD.org (Doug Barton)
Date: Sat Aug 29 19:47:56 2009
Subject: svn commit: r196646 - stable/7/etc
Message-ID: <200908291947.n7TJldIb073101@svn.freebsd.org>

Author: dougb
Date: Sat Aug 29 19:47:39 2009
New Revision: 196646
URL: http://svn.freebsd.org/changeset/base/196646

Log:
  MFC 196478:
  Prior to the dire warning about values of network_interfaces other than
  AUTO the biggest mistake users made was leaving lo0 off the list. Since
  lo0 is effectively mandatory, check for it and add it to the list if
  it's not there.
  
  MFC 196523:
  Improve the case test to detect the presence of lo0 in the list of
  network_interfaces.
  Submitted by:	Christoph Mallon 

Modified:
  stable/7/etc/   (props changed)
  stable/7/etc/network.subr
  stable/7/etc/termcap.small   (props changed)

Modified: stable/7/etc/network.subr
==============================================================================
--- stable/7/etc/network.subr	Sat Aug 29 19:45:03 2009	(r196645)
+++ stable/7/etc/network.subr	Sat Aug 29 19:47:39 2009	(r196646)
@@ -643,6 +643,13 @@ list_net_interfaces()
 			    "AUTO are deprecated"
 		fi
 		_tmplist="${network_interfaces} ${cloned_interfaces}"
+
+		# lo0 is effectively mandatory, so help prevent foot-shooting
+		#
+		case "$_tmplist" in
+		lo0|'lo0 '*|*' lo0'|*' lo0 '*) ;; # This is fine, do nothing
+		*)	_tmplist="lo0 ${_tmplist}" ;;
+		esac
 		;;
 	esac
 
From mlaier at FreeBSD.org  Mon Aug 31 00:52:11 2009
From: mlaier at FreeBSD.org (Max Laier)
Date: Mon Aug 31 00:52:16 2009
Subject: svn commit: r196680 - in stable/7/sys: . contrib/pf contrib/pf/net
Message-ID: <200908310052.n7V0qA6P011357@svn.freebsd.org>

Author: mlaier
Date: Mon Aug 31 00:52:10 2009
New Revision: 196680
URL: http://svn.freebsd.org/changeset/base/196680

Log:
  MFC r196551:
    Fix argument ordering to memcpy as well as the size of the copy in the
    (theoretical) case that pfi_buffer_cnt should be greater than ~_max.
  
    Submitted by:	pjd
    Reviewed by:	{krw,sthen,markus}@openbsd.org

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/contrib/pf/net/pf_if.c

Modified: stable/7/sys/contrib/pf/net/pf_if.c
==============================================================================
--- stable/7/sys/contrib/pf/net/pf_if.c	Mon Aug 31 00:18:17 2009	(r196679)
+++ stable/7/sys/contrib/pf/net/pf_if.c	Mon Aug 31 00:52:10 2009	(r196680)
@@ -660,7 +660,7 @@ pfi_address_add(struct sockaddr *sa, int
 			    "(%d/%d)\n", pfi_buffer_cnt, PFI_BUFFER_MAX);
 			return;
 		}
-		memcpy(pfi_buffer, p, pfi_buffer_cnt * sizeof(*pfi_buffer));
+		memcpy(p, pfi_buffer, pfi_buffer_max * sizeof(*pfi_buffer));
 		/* no need to zero buffer */
 		free(pfi_buffer, PFI_MTYPE);
 		pfi_buffer = p;
From mlaier at FreeBSD.org  Mon Aug 31 00:54:15 2009
From: mlaier at FreeBSD.org (Max Laier)
Date: Mon Aug 31 00:54:21 2009
Subject: svn commit: r196681 - in stable/7/sys: . contrib/pf contrib/pf/net
Message-ID: <200908310054.n7V0sEKO011434@svn.freebsd.org>

Author: mlaier
Date: Mon Aug 31 00:54:14 2009
New Revision: 196681
URL: http://svn.freebsd.org/changeset/base/196681

Log:
  MFC r196372:
    If we cannot immediately get the pf_consistency_lock in the purge thread,
    restart the scan after acquiring the lock the hard way.  Otherwise we
    might end up with a dead reference.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/contrib/pf/net/pf.c
  stable/7/sys/contrib/pf/net/pfvar.h

Modified: stable/7/sys/contrib/pf/net/pf.c
==============================================================================
--- stable/7/sys/contrib/pf/net/pf.c	Mon Aug 31 00:52:10 2009	(r196680)
+++ stable/7/sys/contrib/pf/net/pf.c	Mon Aug 31 00:54:14 2009	(r196681)
@@ -972,6 +972,9 @@ void
 pf_purge_thread(void *v)
 {
 	int nloops = 0, s;
+#ifdef __FreeBSD__
+	int locked;
+#endif
 
 	for (;;) {
 		tsleep(pf_purge_thread, PWAIT, "pftm", 1 * hz);
@@ -979,14 +982,19 @@ pf_purge_thread(void *v)
 #ifdef __FreeBSD__
 		sx_slock(&pf_consistency_lock);
 		PF_LOCK();
+		locked = 0;
 
 		if (pf_end_threads) {
-			pf_purge_expired_states(pf_status.states);
+			PF_UNLOCK();
+			sx_sunlock(&pf_consistency_lock);
+			sx_xlock(&pf_consistency_lock);
+			PF_LOCK();
+			pf_purge_expired_states(pf_status.states, 1);
 			pf_purge_expired_fragments();
-			pf_purge_expired_src_nodes(0);
+			pf_purge_expired_src_nodes(1);
 			pf_end_threads++;
 
-			sx_sunlock(&pf_consistency_lock);
+			sx_xunlock(&pf_consistency_lock);
 			PF_UNLOCK();
 			wakeup(pf_purge_thread);
 			kthread_exit(0);
@@ -995,20 +1003,44 @@ pf_purge_thread(void *v)
 		s = splsoftnet();
 
 		/* process a fraction of the state table every second */
+#ifdef __FreeBSD__
+		if(!pf_purge_expired_states(1 + (pf_status.states
+		    / pf_default_rule.timeout[PFTM_INTERVAL]), 0)) {
+			PF_UNLOCK();
+			sx_sunlock(&pf_consistency_lock);
+			sx_xlock(&pf_consistency_lock);
+			PF_LOCK();
+			locked = 1;
+
+			pf_purge_expired_states(1 + (pf_status.states
+			    / pf_default_rule.timeout[PFTM_INTERVAL]), 1);
+		}
+#else
 		pf_purge_expired_states(1 + (pf_status.states
 		    / pf_default_rule.timeout[PFTM_INTERVAL]));
+#endif
 
 		/* purge other expired types every PFTM_INTERVAL seconds */
 		if (++nloops >= pf_default_rule.timeout[PFTM_INTERVAL]) {
 			pf_purge_expired_fragments();
-			pf_purge_expired_src_nodes(0);
+			if (!pf_purge_expired_src_nodes(locked)) {
+				PF_UNLOCK();
+				sx_sunlock(&pf_consistency_lock);
+				sx_xlock(&pf_consistency_lock);
+				PF_LOCK();
+				locked = 1;
+				pf_purge_expired_src_nodes(1);
+			}
 			nloops = 0;
 		}
 
 		splx(s);
 #ifdef __FreeBSD__
 		PF_UNLOCK();
-		sx_sunlock(&pf_consistency_lock);
+		if (locked)
+			sx_xunlock(&pf_consistency_lock);
+		else
+			sx_sunlock(&pf_consistency_lock);
 #endif
 	}
 }
@@ -1057,8 +1089,13 @@ pf_state_expires(const struct pf_state *
 	return (state->expire + timeout);
 }
 
+#ifdef __FreeBSD__
+int
+pf_purge_expired_src_nodes(int waslocked)
+#else
 void
 pf_purge_expired_src_nodes(int waslocked)
+#endif
 {
 	 struct pf_src_node		*cur, *next;
 	 int				 locked = waslocked;
@@ -1069,12 +1106,8 @@ pf_purge_expired_src_nodes(int waslocked
 		 if (cur->states <= 0 && cur->expire <= time_second) {
 			 if (! locked) {
 #ifdef __FreeBSD__
-				 if (!sx_try_upgrade(&pf_consistency_lock)) {
-					 PF_UNLOCK();
-					 sx_sunlock(&pf_consistency_lock);
-					 sx_xlock(&pf_consistency_lock);
-					 PF_LOCK();
-				 }
+				 if (!sx_try_upgrade(&pf_consistency_lock))
+				 	return (0);
 #else
 				 rw_enter_write(&pf_consistency_lock);
 #endif
@@ -1101,6 +1134,10 @@ pf_purge_expired_src_nodes(int waslocked
 #else
 		rw_exit_write(&pf_consistency_lock);
 #endif
+
+#ifdef __FreeBSD__
+	return (1);
+#endif
 }
 
 void
@@ -1203,12 +1240,21 @@ pf_free_state(struct pf_state *cur)
 	pf_status.states--;
 }
 
+#ifdef __FreeBSD__
+int
+pf_purge_expired_states(u_int32_t maxcheck, int waslocked)
+#else
 void
 pf_purge_expired_states(u_int32_t maxcheck)
+#endif
 {
 	static struct pf_state	*cur = NULL;
 	struct pf_state		*next;
+#ifdef __FreeBSD__
+	int 			 locked = waslocked;
+#else
 	int 			 locked = 0;
+#endif
 
 	while (maxcheck--) {
 		/* wrap to start of list when we hit the end */
@@ -1225,12 +1271,8 @@ pf_purge_expired_states(u_int32_t maxche
 			/* free unlinked state */
 			if (! locked) {
 #ifdef __FreeBSD__
-				 if (!sx_try_upgrade(&pf_consistency_lock)) {
-					 PF_UNLOCK();
-					 sx_sunlock(&pf_consistency_lock);
-					 sx_xlock(&pf_consistency_lock);
-					 PF_LOCK();
-				 }
+				 if (!sx_try_upgrade(&pf_consistency_lock))
+				 	return (0);
 #else
 				rw_enter_write(&pf_consistency_lock);
 #endif
@@ -1242,12 +1284,8 @@ pf_purge_expired_states(u_int32_t maxche
 			pf_unlink_state(cur);
 			if (! locked) {
 #ifdef __FreeBSD__
-				 if (!sx_try_upgrade(&pf_consistency_lock)) {
-					 PF_UNLOCK();
-					 sx_sunlock(&pf_consistency_lock);
-					 sx_xlock(&pf_consistency_lock);
-					 PF_LOCK();
-				 }
+				 if (!sx_try_upgrade(&pf_consistency_lock))
+				 	return (0);
 #else
 				rw_enter_write(&pf_consistency_lock);
 #endif
@@ -1258,10 +1296,13 @@ pf_purge_expired_states(u_int32_t maxche
 		cur = next;
 	}
 
-	if (locked)
 #ifdef __FreeBSD__
+	if (!waslocked && locked)
 		sx_downgrade(&pf_consistency_lock);
+
+	return (1);
 #else
+	if (locked)
 		rw_exit_write(&pf_consistency_lock);
 #endif
 }

Modified: stable/7/sys/contrib/pf/net/pfvar.h
==============================================================================
--- stable/7/sys/contrib/pf/net/pfvar.h	Mon Aug 31 00:52:10 2009	(r196680)
+++ stable/7/sys/contrib/pf/net/pfvar.h	Mon Aug 31 00:54:14 2009	(r196681)
@@ -1593,8 +1593,13 @@ extern struct pool		 pf_state_pl, pf_alt
 extern struct pool		 pf_state_scrub_pl;
 #endif
 extern void			 pf_purge_thread(void *);
+#ifdef __FreeBSD__
+extern int			 pf_purge_expired_src_nodes(int);
+extern int			 pf_purge_expired_states(u_int32_t, int);
+#else
 extern void			 pf_purge_expired_src_nodes(int);
 extern void			 pf_purge_expired_states(u_int32_t);
+#endif
 extern void			 pf_unlink_state(struct pf_state *);
 extern void			 pf_free_state(struct pf_state *);
 extern int			 pf_insert_state(struct pfi_kif *,
From edwin at FreeBSD.org  Mon Aug 31 02:22:20 2009
From: edwin at FreeBSD.org (Edwin Groothuis)
Date: Mon Aug 31 02:22:39 2009
Subject: svn commit: r196683 - in stable/7: lib/libc lib/libc/stdtime
	usr.sbin/zic
Message-ID: <200908310222.n7V2MISr013278@svn.freebsd.org>

Author: edwin
Date: Mon Aug 31 02:22:18 2009
New Revision: 196683
URL: http://svn.freebsd.org/changeset/base/196683

Log:
  MFC of r192625, r192890, r194783, r196587:
  
  r192625:
  MFC of tzcode2009e:
  
  Upgrade of the tzcode from 2004a to 2009e.
  
  Changes are numerous, but include...
  
  - New format of the output of zic, which supports both 32 and 64
    bit time_t formats.
  
  - zdump on 64 bit platforms will actually produce some output instead
    of doing nothing for a looooooooong time.
  
  - linux_base-fX, with X >= at least 8, will work without problems related
    to the local time again.
  
  The original patch, based on the 2008e, has been running for a long
  time on both my laptop and desktop machine and have been tested by
  other people.
  
  After the installation of this code and the running of zic(8), you
  need to run tzsetup(8) again to install the new datafile.
  
  r192890:
  
  MFC of tzcode2009h
  
  - Clarify the license for the tzcode: public domain
  
  r194783:
  
  Remove duplicate if-statement on gmt_is_set in gmtsub().
  
  r196587:
  
  MFC of tzcode2009k
  
  zic.c:
      Do not end a binary file with a POSIX-style time zone string
      for locations that end up in permanent DST (thanks to Andreas
      Schwab).

Deleted:
  stable/7/usr.sbin/zic/Arts.htm
  stable/7/usr.sbin/zic/tz-art.htm
  stable/7/usr.sbin/zic/tz-link.htm
Modified:
  stable/7/lib/libc/   (props changed)
  stable/7/lib/libc/stdtime/asctime.c
  stable/7/lib/libc/stdtime/difftime.c
  stable/7/lib/libc/stdtime/localtime.c
  stable/7/lib/libc/stdtime/private.h
  stable/7/lib/libc/stdtime/strftime.c
  stable/7/lib/libc/stdtime/time2posix.3
  stable/7/lib/libc/stdtime/tzfile.5
  stable/7/lib/libc/stdtime/tzfile.h
  stable/7/usr.sbin/zic/   (props changed)
  stable/7/usr.sbin/zic/README
  stable/7/usr.sbin/zic/Theory
  stable/7/usr.sbin/zic/ialloc.c
  stable/7/usr.sbin/zic/private.h
  stable/7/usr.sbin/zic/scheck.c
  stable/7/usr.sbin/zic/zdump.8
  stable/7/usr.sbin/zic/zdump.c
  stable/7/usr.sbin/zic/zic.8
  stable/7/usr.sbin/zic/zic.c

Modified: stable/7/lib/libc/stdtime/asctime.c
==============================================================================
--- stable/7/lib/libc/stdtime/asctime.c	Mon Aug 31 00:56:06 2009	(r196682)
+++ stable/7/lib/libc/stdtime/asctime.c	Mon Aug 31 02:22:18 2009	(r196683)
@@ -1,12 +1,18 @@
 /*
 ** This file is in the public domain, so clarified as of
-** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
+** 1996-06-05 by Arthur David Olson.
+*/
+
+/*
+** Avoid the temptation to punt entirely to strftime;
+** the output of strftime is supposed to be locale specific
+** whereas the output of asctime is supposed to be constant.
 */
 
 #include 
 #ifndef lint
 #ifndef NOID
-static char	elsieid[] __unused = "@(#)asctime.c	7.9";
+static char	elsieid[] __unused = "@(#)asctime.c	8.2";
 #endif /* !defined NOID */
 #endif /* !defined lint */
 __FBSDID("$FreeBSD$");
@@ -19,7 +25,57 @@ __FBSDID("$FreeBSD$");
 #include "tzfile.h"
 
 /*
-** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, Second Edition, 1996-07-12.
+** Some systems only handle "%.2d"; others only handle "%02d";
+** "%02.2d" makes (most) everybody happy.
+** At least some versions of gcc warn about the %02.2d;
+** we conditionalize below to avoid the warning.
+*/
+/*
+** All years associated with 32-bit time_t values are exactly four digits long;
+** some years associated with 64-bit time_t values are not.
+** Vintage programs are coded for years that are always four digits long
+** and may assume that the newline always lands in the same place.
+** For years that are less than four digits, we pad the output with
+** leading zeroes to get the newline in the traditional place.
+** The -4 ensures that we get four characters of output even if
+** we call a strftime variant that produces fewer characters for some years.
+** The ISO C 1999 and POSIX 1003.1-2004 standards prohibit padding the year,
+** but many implementations pad anyway; most likely the standards are buggy.
+*/
+#ifdef __GNUC__
+#define ASCTIME_FMT	"%.3s %.3s%3d %2.2d:%2.2d:%2.2d %-4s\n"
+#else /* !defined __GNUC__ */
+#define ASCTIME_FMT	"%.3s %.3s%3d %02.2d:%02.2d:%02.2d %-4s\n"
+#endif /* !defined __GNUC__ */
+/*
+** For years that are more than four digits we put extra spaces before the year
+** so that code trying to overwrite the newline won't end up overwriting
+** a digit within a year and truncating the year (operating on the assumption
+** that no output is better than wrong output).
+*/
+#ifdef __GNUC__
+#define ASCTIME_FMT_B	"%.3s %.3s%3d %2.2d:%2.2d:%2.2d     %s\n"
+#else /* !defined __GNUC__ */
+#define ASCTIME_FMT_B	"%.3s %.3s%3d %02.2d:%02.2d:%02.2d     %s\n"
+#endif /* !defined __GNUC__ */
+
+#define STD_ASCTIME_BUF_SIZE	26
+/*
+** Big enough for something such as
+** ??? ???-2147483648 -2147483648:-2147483648:-2147483648     -2147483648\n
+** (two three-character abbreviations, five strings denoting integers,
+** seven explicit spaces, two explicit colons, a newline,
+** and a trailing ASCII nul).
+** The values above are for systems where an int is 32 bits and are provided
+** as an example; the define below calculates the maximum for the system at
+** hand.
+*/
+#define MAX_ASCTIME_BUF_SIZE	(2*3+5*INT_STRLEN_MAXIMUM(int)+7+2+1+1)
+
+static char	buf_asctime[MAX_ASCTIME_BUF_SIZE];
+
+/*
+** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition.
 */
 
 char *
@@ -36,6 +92,8 @@ char *			buf;
 	};
 	const char *	wn;
 	const char *	mn;
+	char			year[INT_STRLEN_MAXIMUM(int) + 2];
+	char			result[MAX_ASCTIME_BUF_SIZE];
 
 	if (timeptr->tm_wday < 0 || timeptr->tm_wday >= DAYSPERWEEK)
 		wn = "???";
@@ -44,35 +102,41 @@ char *			buf;
 		mn = "???";
 	else	mn = mon_name[timeptr->tm_mon];
 	/*
-	** The X3J11-suggested format is
-	**	"%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n"
-	** Since the .2 in 02.2d is ignored, we drop it.
+	** Use strftime's %Y to generate the year, to avoid overflow problems
+	** when computing timeptr->tm_year + TM_YEAR_BASE.
+	** Assume that strftime is unaffected by other out-of-range members
+	** (e.g., timeptr->tm_mday) when processing "%Y".
 	*/
-	(void) sprintf(buf, "%.3s %.3s%3d %02d:%02d:%02d %d\n",
+	(void) strftime(year, sizeof year, "%Y", timeptr);
+	/*
+	** We avoid using snprintf since it's not available on all systems.
+	*/
+	(void) sprintf(result,
+		((strlen(year) <= 4) ? ASCTIME_FMT : ASCTIME_FMT_B),
 		wn, mn,
 		timeptr->tm_mday, timeptr->tm_hour,
 		timeptr->tm_min, timeptr->tm_sec,
-		TM_YEAR_BASE + timeptr->tm_year);
-	return buf;
+		year);
+	if (strlen(result) < STD_ASCTIME_BUF_SIZE || buf == buf_asctime) {
+		(void) strcpy(buf, result);
+		return buf;
+	} else {
+#ifdef EOVERFLOW
+		errno = EOVERFLOW;
+#else /* !defined EOVERFLOW */
+		errno = EINVAL;
+#endif /* !defined EOVERFLOW */
+		return NULL;
+	}
 }
 
 /*
-** A la X3J11, with core dump avoidance.
+** A la ISO/IEC 9945-1, ANSI/IEEE Std 1003.1, 2004 Edition.
 */
 
 char *
 asctime(timeptr)
 const struct tm *	timeptr;
 {
-	/*
-	** Big enough for something such as
-	** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n
-	** (two three-character abbreviations, five strings denoting integers,
-	** three explicit spaces, two explicit colons, a newline,
-	** and a trailing ASCII nul).
-	*/
-	static char		result[3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) +
-					3 + 2 + 1 + 1];
-
-	return asctime_r(timeptr, result);
+	return asctime_r(timeptr, buf_asctime);
 }

Modified: stable/7/lib/libc/stdtime/difftime.c
==============================================================================
--- stable/7/lib/libc/stdtime/difftime.c	Mon Aug 31 00:56:06 2009	(r196682)
+++ stable/7/lib/libc/stdtime/difftime.c	Mon Aug 31 02:22:18 2009	(r196683)
@@ -1,12 +1,12 @@
 /*
 ** This file is in the public domain, so clarified as of
-** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov).
+** 1996-06-05 by Arthur David Olson.
 */
 
 #include 
 #ifndef lint
 #ifndef NOID
-static char	elsieid[] __unused = "@(#)difftime.c	7.9";
+static char	elsieid[] __unused = "@(#)difftime.c	8.1";
 #endif /* !defined NOID */
 #endif /* !defined lint */
 __FBSDID("$FreeBSD$");
@@ -14,74 +14,56 @@ __FBSDID("$FreeBSD$");
 /*LINTLIBRARY*/
 
 #include "namespace.h"
-#include "private.h"
+#include "private.h"	/* for time_t, TYPE_INTEGRAL, and TYPE_SIGNED */
 #include "un-namespace.h"
 
-/*
-** Algorithm courtesy Paul Eggert (eggert@twinsun.com).
-*/
-
-#ifdef HAVE_LONG_DOUBLE
-#define long_double	long double
-#endif /* defined HAVE_LONG_DOUBLE */
-#ifndef HAVE_LONG_DOUBLE
-#define long_double	double
-#endif /* !defined HAVE_LONG_DOUBLE */
-
 double
 difftime(time1, time0)
 const time_t	time1;
 const time_t	time0;
 {
-	time_t	delta;
-	time_t	hibit;
-
-	{
-		time_t		tt;
-		double		d;
-		long_double	ld;
-
-		if (sizeof tt < sizeof d)
-			return (double) time1 - (double) time0;
-		if (sizeof tt < sizeof ld)
-			return (long_double) time1 - (long_double) time0;
+	/*
+	** If (sizeof (double) > sizeof (time_t)) simply convert and subtract
+	** (assuming that the larger type has more precision).
+	** This is the common real-world case circa 2004.
+	*/
+	if (sizeof (double) > sizeof (time_t))
+		return (double) time1 - (double) time0;
+	if (!TYPE_INTEGRAL(time_t)) {
+		/*
+		** time_t is floating.
+		*/
+		return time1 - time0;
+	}
+	if (!TYPE_SIGNED(time_t)) {
+		/*
+		** time_t is integral and unsigned.
+		** The difference of two unsigned values can't overflow
+		** if the minuend is greater than or equal to the subtrahend.
+		*/
+		if (time1 >= time0)
+			return time1 - time0;
+		else	return -((double) (time0 - time1));
 	}
-	if (time1 < time0)
-		return -difftime(time0, time1);
 	/*
-	** As much as possible, avoid loss of precision
-	** by computing the difference before converting to double.
+	** time_t is integral and signed.
+	** Handle cases where both time1 and time0 have the same sign
+	** (meaning that their difference cannot overflow).
 	*/
-	delta = time1 - time0;
-	if (delta >= 0)
-		return delta;
+	if ((time1 < 0) == (time0 < 0))
+		return time1 - time0;
 	/*
-	** Repair delta overflow.
+	** time1 and time0 have opposite signs.
+	** Punt if unsigned long is too narrow.
 	*/
-	hibit = (~ (time_t) 0) << (TYPE_BIT(time_t) - 1);
+	if (sizeof (unsigned long) < sizeof (time_t))
+		return (double) time1 - (double) time0;
 	/*
-	** The following expression rounds twice, which means
-	** the result may not be the closest to the true answer.
-	** For example, suppose time_t is 64-bit signed int,
-	** long_double is IEEE 754 double with default rounding,
-	** time1 = 9223372036854775807 and time0 = -1536.
-	** Then the true difference is 9223372036854777343,
-	** which rounds to 9223372036854777856
-	** with a total error of 513.
-	** But delta overflows to -9223372036854774273,
-	** which rounds to -9223372036854774784, and correcting
-	** this by subtracting 2 * (long_double) hibit
-	** (i.e. by adding 2**64 = 18446744073709551616)
-	** yields 9223372036854776832, which
-	** rounds to 9223372036854775808
-	** with a total error of 1535 instead.
-	** This problem occurs only with very large differences.
-	** It's too painful to fix this portably.
-	** We are not alone in this problem;
-	** some C compilers round twice when converting
-	** large unsigned types to small floating types,
-	** so if time_t is unsigned the "return delta" above
-	** has the same double-rounding problem with those compilers.
+	** Stay calm...decent optimizers will eliminate the complexity below.
 	*/
-	return delta - 2 * (long_double) hibit;
+	if (time1 >= 0 /* && time0 < 0 */)
+		return (unsigned long) time1 +
+			(unsigned long) (-(time0 + 1)) + 1;
+	return -(double) ((unsigned long) time0 +
+		(unsigned long) (-(time1 + 1)) + 1);
 }

Modified: stable/7/lib/libc/stdtime/localtime.c
==============================================================================
--- stable/7/lib/libc/stdtime/localtime.c	Mon Aug 31 00:56:06 2009	(r196682)
+++ stable/7/lib/libc/stdtime/localtime.c	Mon Aug 31 02:22:18 2009	(r196683)
@@ -1,20 +1,19 @@
 /*
 ** This file is in the public domain, so clarified as of
-** 1996-06-05 by Arthur David Olson (arthur_david_olson@nih.gov).
+** 1996-06-05 by Arthur David Olson.
 */
 
 #include 
 #ifndef lint
 #ifndef NOID
-static char	elsieid[] __unused = "@(#)localtime.c	7.78";
+static char	elsieid[] __unused = "@(#)localtime.c	8.9";
 #endif /* !defined NOID */
 #endif /* !defined lint */
 __FBSDID("$FreeBSD$");
 
 /*
-** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu).
-** POSIX-style TZ environment variable handling from Guy Harris
-** (guy@auspex.com).
+** Leap second handling from Bradley White.
+** POSIX-style TZ environment variable handling from Guy Harris.
 */
 
 /*LINTLIBRARY*/
@@ -28,6 +27,20 @@ __FBSDID("$FreeBSD$");
 #include "un-namespace.h"
 
 #include "tzfile.h"
+#include "float.h"	/* for FLT_MAX and DBL_MAX */
+
+#ifndef TZ_ABBR_MAX_LEN
+#define TZ_ABBR_MAX_LEN	16
+#endif /* !defined TZ_ABBR_MAX_LEN */
+
+#ifndef TZ_ABBR_CHAR_SET
+#define TZ_ABBR_CHAR_SET \
+	"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :+-._"
+#endif /* !defined TZ_ABBR_CHAR_SET */
+
+#ifndef TZ_ABBR_ERR_CHAR
+#define TZ_ABBR_ERR_CHAR	'_'
+#endif /* !defined TZ_ABBR_ERR_CHAR */
 
 #include "libc_private.h"
 
@@ -74,16 +87,16 @@ __FBSDID("$FreeBSD$");
 **	5.	They might reference tm.TM_ZONE after calling offtime.
 ** What's best to do in the above cases is open to debate;
 ** for now, we just set things up so that in any of the five cases
-** WILDABBR is used.  Another possibility:  initialize tzname[0] to the
+** WILDABBR is used. Another possibility: initialize tzname[0] to the
 ** string "tzname[0] used before set", and similarly for the other cases.
-** And another:  initialize tzname[0] to "ERA", with an explanation in the
+** And another: initialize tzname[0] to "ERA", with an explanation in the
 ** manual page of what this "time zone abbreviation" means (doing this so
 ** that tzname[0] has the "normal" length of three characters).
 */
 #define WILDABBR	"   "
 #endif /* !defined WILDABBR */
 
-static char		wildabbr[] = "WILDABBR";
+static char		wildabbr[] = WILDABBR;
 
 /*
  * In June 2004 it was decided UTC was a more appropriate default time
@@ -130,6 +143,8 @@ struct state {
 	int		timecnt;
 	int		typecnt;
 	int		charcnt;
+	int		goback;
+	int		goahead;
 	time_t		ats[TZ_MAX_TIMES];
 	unsigned char	types[TZ_MAX_TIMES];
 	struct ttinfo	ttis[TZ_MAX_TYPES];
@@ -155,40 +170,49 @@ struct rule {
 */
 
 static long		detzcode(const char * codep);
+static time_t		detzcode64(const char * codep);
+static int		differ_by_repeat(time_t t1, time_t t0);
 static const char *	getzname(const char * strp);
+static const char *	getqzname(const char * strp, const int delim);
 static const char *	getnum(const char * strp, int * nump, int min,
 				int max);
 static const char *	getsecs(const char * strp, long * secsp);
 static const char *	getoffset(const char * strp, long * offsetp);
 static const char *	getrule(const char * strp, struct rule * rulep);
 static void		gmtload(struct state * sp);
-static void		gmtsub(const time_t * timep, long offset,
+static struct tm *	gmtsub(const time_t * timep, long offset,
 				struct tm * tmp);
-static void		localsub(const time_t * timep, long offset,
+static struct tm *	localsub(const time_t * timep, long offset,
 				struct tm * tmp);
 static int		increment_overflow(int * number, int delta);
+static int		leaps_thru_end_of(int y);
+static int		long_increment_overflow(long * number, int delta);
+static int		long_normalize_overflow(long * tensptr,
+				int * unitsptr, int base);
 static int		normalize_overflow(int * tensptr, int * unitsptr,
 				int base);
 static void		settzname(void);
 static time_t		time1(struct tm * tmp,
-				void(*funcp) (const time_t *,
+				struct tm * (*funcp)(const time_t *,
 				long, struct tm *),
 				long offset);
 static time_t		time2(struct tm *tmp,
-				void(*funcp) (const time_t *,
+				struct tm * (*funcp)(const time_t *,
 				long, struct tm*),
 				long offset, int * okayp);
 static time_t		time2sub(struct tm *tmp,
-				void(*funcp) (const time_t *,
+				struct tm * (*funcp)(const time_t *,
 				long, struct tm*),
 				long offset, int * okayp, int do_norm_secs);
-static void		timesub(const time_t * timep, long offset,
+static struct tm *	timesub(const time_t * timep, long offset,
 				const struct state * sp, struct tm * tmp);
 static int		tmcomp(const struct tm * atmp,
 				const struct tm * btmp);
 static time_t		transtime(time_t janfirst, int year,
 				const struct rule * rulep, long offset);
-static int		tzload(const char * name, struct state * sp);
+static int		typesequiv(const struct state * sp, int a, int b);
+static int		tzload(const char * name, struct state * sp,
+				int doextend);
 static int		tzparse(const char * name, struct state * sp,
 				int lastditch);
 
@@ -224,7 +248,7 @@ char *			tzname[2] = {
 **	Except for the strftime function, these functions [asctime,
 **	ctime, gmtime, localtime] return values in one of two static
 **	objects: a broken-down time structure and an array of char.
-** Thanks to Paul Eggert (eggert@twinsun.com) for noting this.
+** Thanks to Paul Eggert for noting this.
 */
 
 static struct tm	tm;
@@ -245,12 +269,25 @@ const char * const	codep;
 	long	result;
 	int	i;
 
-	result = (codep[0] & 0x80) ? ~0L : 0L;
+	result = (codep[0] & 0x80) ? ~0L : 0;
 	for (i = 0; i < 4; ++i)
 		result = (result << 8) | (codep[i] & 0xff);
 	return result;
 }
 
+static time_t
+detzcode64(codep)
+const char * const	codep;
+{
+	register time_t	result;
+	register int	i;
+
+	result = (codep[0] & 0x80) ?  (~(int_fast64_t) 0) : 0;
+	for (i = 0; i < 8; ++i)
+		result = result * 256 + (codep[i] & 0xff);
+	return result;
+}
+
 static void
 settzname(void)
 {
@@ -299,16 +336,58 @@ settzname(void)
 		tzname[ttisp->tt_isdst] =
 			&sp->chars[ttisp->tt_abbrind];
 	}
+	/*
+	** Finally, scrub the abbreviations.
+	** First, replace bogus characters.
+	*/
+	for (i = 0; i < sp->charcnt; ++i)
+		if (strchr(TZ_ABBR_CHAR_SET, sp->chars[i]) == NULL)
+			sp->chars[i] = TZ_ABBR_ERR_CHAR;
+	/*
+	** Second, truncate long abbreviations.
+	*/
+	for (i = 0; i < sp->typecnt; ++i) {
+		register const struct ttinfo * const	ttisp = &sp->ttis[i];
+		register char *				cp = &sp->chars[ttisp->tt_abbrind];
+
+		if (strlen(cp) > TZ_ABBR_MAX_LEN &&
+			strcmp(cp, GRANDPARENTED) != 0)
+				*(cp + TZ_ABBR_MAX_LEN) = '\0';
+	}
+}
+
+static int
+differ_by_repeat(t1, t0)
+const time_t	t1;
+const time_t	t0;
+{
+	int_fast64_t _t0 = t0;
+	int_fast64_t _t1 = t1;
+
+	if (TYPE_INTEGRAL(time_t) &&
+		TYPE_BIT(time_t) - TYPE_SIGNED(time_t) < SECSPERREPEAT_BITS)
+			return 0;
+	//turn ((int_fast64_t)(t1 - t0) == SECSPERREPEAT);
+	return _t1 - _t0 == SECSPERREPEAT;
 }
 
 static int
-tzload(name, sp)
+tzload(name, sp, doextend)
 const char *		name;
 struct state * const	sp;
+register const int	doextend;
 {
 	const char *	p;
 	int		i;
 	int		fid;
+	int		stored;
+	int		nread;
+	union {
+		struct tzhead	tzhead;
+		char		buf[2 * sizeof(struct tzhead) +
+					2 * sizeof *sp +
+					4 * TZ_MAX_TIMES];
+	} u;
 
 	/* XXX The following is from OpenBSD, and I'm not sure it is correct */
 	if (name != NULL && issetugid() != 0)
@@ -356,18 +435,13 @@ struct state * const	sp;
 			return -1;
 		}
 	}
-	{
-		struct tzhead *	tzhp;
-		union {
-			struct tzhead	tzhead;
-			char		buf[sizeof *sp + sizeof *tzhp];
-		} u;
+	nread = _read(fid, u.buf, sizeof u.buf);
+	if (_close(fid) < 0 || nread <= 0)
+		return -1;
+	for (stored = 4; stored <= 8; stored *= 2) {
 		int		ttisstdcnt;
 		int		ttisgmtcnt;
 
-		i = _read(fid, u.buf, sizeof u.buf);
-		if (_close(fid) != 0)
-			return -1;
 		ttisstdcnt = (int) detzcode(u.tzhead.tzh_ttisstdcnt);
 		ttisgmtcnt = (int) detzcode(u.tzhead.tzh_ttisgmtcnt);
 		sp->leapcnt = (int) detzcode(u.tzhead.tzh_leapcnt);
@@ -382,17 +456,19 @@ struct state * const	sp;
 			(ttisstdcnt != sp->typecnt && ttisstdcnt != 0) ||
 			(ttisgmtcnt != sp->typecnt && ttisgmtcnt != 0))
 				return -1;
-		if (i - (p - u.buf) < sp->timecnt * 4 +	/* ats */
+		if (nread - (p - u.buf) <
+			sp->timecnt * stored +		/* ats */
 			sp->timecnt +			/* types */
-			sp->typecnt * (4 + 2) +		/* ttinfos */
+			sp->typecnt * 6 +		/* ttinfos */
 			sp->charcnt +			/* chars */
-			sp->leapcnt * (4 + 4) +		/* lsinfos */
+			sp->leapcnt * (stored + 4) +	/* lsinfos */
 			ttisstdcnt +			/* ttisstds */
 			ttisgmtcnt)			/* ttisgmts */
 				return -1;
 		for (i = 0; i < sp->timecnt; ++i) {
-			sp->ats[i] = detzcode(p);
-			p += 4;
+			sp->ats[i] = (stored == 4) ?
+				detzcode(p) : detzcode64(p);
+			p += stored;
 		}
 		for (i = 0; i < sp->timecnt; ++i) {
 			sp->types[i] = (unsigned char) *p++;
@@ -420,8 +496,9 @@ struct state * const	sp;
 			struct lsinfo *	lsisp;
 
 			lsisp = &sp->lsis[i];
-			lsisp->ls_trans = detzcode(p);
-			p += 4;
+			lsisp->ls_trans = (stored == 4) ?
+				detzcode(p) : detzcode64(p);
+			p += stored;
 			lsisp->ls_corr = detzcode(p);
 			p += 4;
 		}
@@ -451,10 +528,127 @@ struct state * const	sp;
 						return -1;
 			}
 		}
+		/*
+		** Out-of-sort ats should mean we're running on a
+		** signed time_t system but using a data file with
+		** unsigned values (or vice versa).
+		*/
+		for (i = 0; i < sp->timecnt - 2; ++i)
+			if (sp->ats[i] > sp->ats[i + 1]) {
+				++i;
+				if (TYPE_SIGNED(time_t)) {
+					/*
+					** Ignore the end (easy).
+					*/
+					sp->timecnt = i;
+				} else {
+					/*
+					** Ignore the beginning (harder).
+					*/
+					register int	j;
+
+					for (j = 0; j + i < sp->timecnt; ++j) {
+						sp->ats[j] = sp->ats[j + i];
+						sp->types[j] = sp->types[j + i];
+					}
+					sp->timecnt = j;
+				}
+				break;
+			}
+		/*
+		** If this is an old file, we're done.
+		*/
+		if (u.tzhead.tzh_version[0] == '\0')
+			break;
+		nread -= p - u.buf;
+		for (i = 0; i < nread; ++i)
+			u.buf[i] = p[i];
+		/*
+		** If this is a narrow integer time_t system, we're done.
+		*/
+		if (stored >= (int) sizeof(time_t) && TYPE_INTEGRAL(time_t))
+			break;
+	}
+	if (doextend && nread > 2 &&
+		u.buf[0] == '\n' && u.buf[nread - 1] == '\n' &&
+		sp->typecnt + 2 <= TZ_MAX_TYPES) {
+			struct state	ts;
+			register int	result;
+
+			u.buf[nread - 1] = '\0';
+			result = tzparse(&u.buf[1], &ts, FALSE);
+			if (result == 0 && ts.typecnt == 2 &&
+				sp->charcnt + ts.charcnt <= TZ_MAX_CHARS) {
+					for (i = 0; i < 2; ++i)
+						ts.ttis[i].tt_abbrind +=
+							sp->charcnt;
+					for (i = 0; i < ts.charcnt; ++i)
+						sp->chars[sp->charcnt++] =
+							ts.chars[i];
+					i = 0;
+					while (i < ts.timecnt &&
+						ts.ats[i] <=
+						sp->ats[sp->timecnt - 1])
+							++i;
+					while (i < ts.timecnt &&
+					    sp->timecnt < TZ_MAX_TIMES) {
+						sp->ats[sp->timecnt] =
+							ts.ats[i];
+						sp->types[sp->timecnt] =
+							sp->typecnt +
+							ts.types[i];
+						++sp->timecnt;
+						++i;
+					}
+					sp->ttis[sp->typecnt++] = ts.ttis[0];
+					sp->ttis[sp->typecnt++] = ts.ttis[1];
+			}
+	}
+	sp->goback = sp->goahead = FALSE;
+	if (sp->timecnt > 1) {
+		for (i = 1; i < sp->timecnt; ++i)
+			if (typesequiv(sp, sp->types[i], sp->types[0]) &&
+				differ_by_repeat(sp->ats[i], sp->ats[0])) {
+					sp->goback = TRUE;
+					break;
+				}
+		for (i = sp->timecnt - 2; i >= 0; --i)
+			if (typesequiv(sp, sp->types[sp->timecnt - 1],
+				sp->types[i]) &&
+				differ_by_repeat(sp->ats[sp->timecnt - 1],
+				sp->ats[i])) {
+					sp->goahead = TRUE;
+					break;
+		}
 	}
 	return 0;
 }
 
+static int
+typesequiv(sp, a, b)
+const struct state * const	sp;
+const int			a;
+const int			b;
+{
+	register int	result;
+
+	if (sp == NULL ||
+		a < 0 || a >= sp->typecnt ||
+		b < 0 || b >= sp->typecnt)
+			result = FALSE;
+	else {
+		register const struct ttinfo *	ap = &sp->ttis[a];
+		register const struct ttinfo *	bp = &sp->ttis[b];
+		result = ap->tt_gmtoff == bp->tt_gmtoff &&
+			ap->tt_isdst == bp->tt_isdst &&
+			ap->tt_ttisstd == bp->tt_ttisstd &&
+			ap->tt_ttisgmt == bp->tt_ttisgmt &&
+			strcmp(&sp->chars[ap->tt_abbrind],
+			&sp->chars[bp->tt_abbrind]) == 0;
+	}
+	return result;
+}
+
 static const int	mon_lengths[2][MONSPERYEAR] = {
 	{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
 	{ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
@@ -466,7 +660,7 @@ static const int	year_lengths[2] = {
 
 /*
 ** Given a pointer into a time zone string, scan until a character that is not
-** a valid character in a zone name is found.  Return a pointer to that
+** a valid character in a zone name is found. Return a pointer to that
 ** character.
 */
 
@@ -483,6 +677,25 @@ const char *	strp;
 }
 
 /*
+** Given a pointer into an extended time zone string, scan until the ending
+** delimiter of the zone name is located. Return a pointer to the delimiter.
+**
+** As with getzname above, the legal character set is actually quite
+** restricted, with other characters producing undefined results.
+** We don't do any checking here; checking is done later in common-case code.
+*/
+
+static const char *
+getqzname(register const char *strp, const int delim)
+{
+	register int	c;
+
+	while ((c = *strp) != '\0' && c != delim)
+		++strp;
+	return strp;
+}
+
+/*
 ** Given a pointer into a time zone string, extract a number from that string.
 ** Check that the number is within a specified range; if it is not, return
 ** NULL.
@@ -547,7 +760,7 @@ long * const		secsp;
 		*secsp += num * SECSPERMIN;
 		if (*strp == ':') {
 			++strp;
-			/* `SECSPERMIN' allows for leap seconds.  */
+			/* `SECSPERMIN' allows for leap seconds. */
 			strp = getnum(strp, &num, 0, SECSPERMIN);
 			if (strp == NULL)
 				return NULL;
@@ -586,7 +799,7 @@ long * const		offsetp;
 
 /*
 ** Given a pointer into a time zone string, extract a rule in the form
-** date[/time].  See POSIX section 8 for the format of "date" and "time".
+** date[/time]. See POSIX section 8 for the format of "date" and "time".
 ** If a valid rule is not found, return NULL.
 ** Otherwise, return a pointer to the first character not part of the rule.
 */
@@ -705,7 +918,7 @@ const long				offset;
 			dow += DAYSPERWEEK;
 
 		/*
-		** "dow" is the day-of-week of the first day of the month.  Get
+		** "dow" is the day-of-week of the first day of the month. Get
 		** the day-of-month (zero-origin) of the first "dow" day of the
 		** month.
 		*/
@@ -728,7 +941,7 @@ const long				offset;
 
 	/*
 	** "value" is the Epoch-relative time of 00:00:00 UTC on the day in
-	** question.  To get the Epoch-relative time of the specified local
+	** question. To get the Epoch-relative time of the specified local
 	** time on that day, add the transition time and the current offset
 	** from UTC.
 	*/
@@ -766,10 +979,18 @@ const int			lastditch;
 			stdlen = (sizeof sp->chars) - 1;
 		stdoffset = 0;
 	} else {
-		name = getzname(name);
-		stdlen = name - stdname;
-		if (stdlen < 3)
-			return -1;
+		if (*name == '<') {
+			name++;
+			stdname = name;
+			name = getqzname(name, '>');
+			if (*name != '>')
+				return (-1);
+			stdlen = name - stdname;
+			name++;
+		} else {
+			name = getzname(name);
+			stdlen = name - stdname;
+		}
 		if (*name == '\0')
 			return -1;	/* was "stdoffset = 0;" */
 		else {
@@ -778,15 +999,22 @@ const int			lastditch;
 				return -1;
 		}
 	}
-	load_result = tzload(TZDEFRULES, sp);
+	load_result = tzload(TZDEFRULES, sp, FALSE);
 	if (load_result != 0)
 		sp->leapcnt = 0;		/* so, we're off a little */
 	if (*name != '\0') {
-		dstname = name;
-		name = getzname(name);
-		dstlen = name - dstname;	/* length of DST zone name */
-		if (dstlen < 3)
-			return -1;
+		if (*name == '<') {
+			dstname = ++name;
+			name = getqzname(name, '>');
+			if (*name != '>')
+				return -1;
+			dstlen = name - dstname;
+			name++;
+		} else {
+			dstname = name;
+			name = getzname(name);
+			dstlen = name - dstname; /* length of DST zone name */
+		}
 		if (*name != '\0' && *name != ',' && *name != ';') {
 			name = getoffset(name, &dstoffset);
 			if (name == NULL)
@@ -813,11 +1041,8 @@ const int			lastditch;
 				return -1;
 			sp->typecnt = 2;	/* standard time and DST */
 			/*
-			** Two transitions per year, from EPOCH_YEAR to 2037.
+			** Two transitions per year, from EPOCH_YEAR forward.
 			*/
-			sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1);
-			if (sp->timecnt > TZ_MAX_TIMES)
-				return -1;
 			sp->ttis[0].tt_gmtoff = -dstoffset;
 			sp->ttis[0].tt_isdst = 1;
 			sp->ttis[0].tt_abbrind = stdlen + 1;
@@ -827,7 +1052,12 @@ const int			lastditch;
 			atp = sp->ats;
 			typep = sp->types;
 			janfirst = 0;
-			for (year = EPOCH_YEAR; year <= 2037; ++year) {
+			sp->timecnt = 0;
+			for (year = EPOCH_YEAR;
+			    sp->timecnt + 2 <= TZ_MAX_TIMES;
+			    ++year) {
+			    	time_t	newfirst;
+
 				starttime = transtime(janfirst, year, &start,
 					stdoffset);
 				endtime = transtime(janfirst, year, &end,
@@ -843,8 +1073,13 @@ const int			lastditch;
 					*atp++ = endtime;
 					*typep++ = 1;	/* DST ends */
 				}
-				janfirst += year_lengths[isleap(year)] *
+				sp->timecnt += 2;
+				newfirst = janfirst;
+				newfirst += year_lengths[isleap(year)] *
 					SECSPERDAY;
+				if (newfirst <= janfirst)
+					break;
+				janfirst = newfirst;
 			}
 		} else {
 			long	theirstdoffset;
@@ -959,7 +1194,7 @@ static void
 gmtload(sp)
 struct state * const	sp;
 {
-	if (tzload(gmt, sp) != 0)
+	if (tzload(gmt, sp, TRUE) != 0)
 		(void) tzparse(gmt, sp, TRUE);
 }
 
@@ -990,7 +1225,7 @@ tzsetwall_basic(int rdlocked)
 		}
 	}
 #endif /* defined ALL_STATE */
-	if (tzload((char *) NULL, lclptr) != 0)
+	if (tzload((char *) NULL, lclptr, TRUE) != 0)
 		gmtload(lclptr);
 	settzname();
 	_RWLOCK_UNLOCK(&lcl_rwlock);
@@ -1053,7 +1288,7 @@ tzset_basic(int rdlocked)
 		lclptr->ttis[0].tt_gmtoff = 0;
 		lclptr->ttis[0].tt_abbrind = 0;
 		(void) strcpy(lclptr->chars, gmt);
-	} else if (tzload(name, lclptr) != 0)
+	} else if (tzload(name, lclptr, TRUE) != 0)
 		if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0)
 			(void) gmtload(lclptr);
 	settzname();
@@ -1072,14 +1307,14 @@ tzset(void)
 /*
 ** The easy way to behave "as if no library function calls" localtime
 ** is to not call it--so we drop its guts into "localsub", which can be
-** freely called.  (And no, the PANS doesn't require the above behavior--
+** freely called. (And no, the PANS doesn't require the above behavior--
 ** but it *is* desirable.)
 **
 ** The unused offset argument is for the benefit of mktime variants.
 */
 
 /*ARGSUSED*/
-static void
+static struct tm *
 localsub(timep, offset, tmp)
 const time_t * const	timep;
 const long		offset;
@@ -1088,15 +1323,53 @@ struct tm * const	tmp;
 	struct state *		sp;
 	const struct ttinfo *	ttisp;
 	int			i;
-	const time_t			t = *timep;
+	struct tm *		result;
+	const time_t		t = *timep;
 
 	sp = lclptr;
 #ifdef ALL_STATE
-	if (sp == NULL) {
-		gmtsub(timep, offset, tmp);
-		return;
-	}
+	if (sp == NULL)
+		return gmtsub(timep, offset, tmp);
 #endif /* defined ALL_STATE */
+	if ((sp->goback && t < sp->ats[0]) ||
+		(sp->goahead && t > sp->ats[sp->timecnt - 1])) {
+			time_t			newt = t;
+			register time_t		seconds;
+			register time_t		tcycles;
+			register int_fast64_t	icycles;
+
+			if (t < sp->ats[0])
+				seconds = sp->ats[0] - t;
+			else	seconds = t - sp->ats[sp->timecnt - 1];
+			--seconds;
+			tcycles = seconds / YEARSPERREPEAT / AVGSECSPERYEAR;
+			++tcycles;
+			icycles = tcycles;
+			if (tcycles - icycles >= 1 || icycles - tcycles >= 1)
+				return NULL;
+			seconds = icycles;
+			seconds *= YEARSPERREPEAT;
+			seconds *= AVGSECSPERYEAR;
+			if (t < sp->ats[0])
+				newt += seconds;
+			else	newt -= seconds;
+			if (newt < sp->ats[0] ||
+				newt > sp->ats[sp->timecnt - 1])
+					return NULL;	/* "cannot happen" */
+			result = localsub(&newt, offset, tmp);
+			if (result == tmp) {
+				register time_t	newy;
+
+				newy = tmp->tm_year;
+				if (t < sp->ats[0])
+					newy -= icycles * YEARSPERREPEAT;
+				else	newy += icycles * YEARSPERREPEAT;
+				tmp->tm_year = newy;
+				if (tmp->tm_year != newy)
+					return NULL;
+			}
+			return result;
+	}
 	if (sp->timecnt == 0 || t < sp->ats[0]) {
 		i = 0;
 		while (sp->ttis[i].tt_isdst)
@@ -1105,10 +1378,17 @@ struct tm * const	tmp;
 				break;
 			}
 	} else {
-		for (i = 1; i < sp->timecnt; ++i)
-			if (t < sp->ats[i])
-				break;
-		i = sp->types[i - 1];
+		register int	lo = 1;
+		register int	hi = sp->timecnt;
+
+		while (lo < hi) {
+			register int	mid = (lo + hi) >> 1;
+
+			if (t < sp->ats[mid])
+				hi = mid;
+			else	lo = mid + 1;
+		}
+		i = (int) sp->types[lo - 1];
 	}
 	ttisp = &sp->ttis[i];
 	/*
@@ -1117,12 +1397,13 @@ struct tm * const	tmp;
 	**	t += ttisp->tt_gmtoff;
 	**	timesub(&t, 0L, sp, tmp);
 	*/
-	timesub(&t, ttisp->tt_gmtoff, sp, tmp);
+	result = timesub(&t, ttisp->tt_gmtoff, sp, tmp);
 	tmp->tm_isdst = ttisp->tt_isdst;
 	tzname[tmp->tm_isdst] = &sp->chars[ttisp->tt_abbrind];
 #ifdef TM_ZONE
 	tmp->TM_ZONE = &sp->chars[ttisp->tt_abbrind];
 #endif /* defined TM_ZONE */

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
From edwin at FreeBSD.org  Mon Aug 31 02:45:47 2009
From: edwin at FreeBSD.org (Edwin Groothuis)
Date: Mon Aug 31 02:45:53 2009
Subject: svn commit: r196684 - stable/7
Message-ID: <200908310245.n7V2jliD013837@svn.freebsd.org>

Author: edwin
Date: Mon Aug 31 02:45:47 2009
New Revision: 196684
URL: http://svn.freebsd.org/changeset/base/196684

Log:
  MFC of r192625:
  
  Throw alert about the newly generated format of zic(8) and the
  necessarity to run tzsetup(8).

Modified:
  stable/7/UPDATING   (contents, props changed)

Modified: stable/7/UPDATING
==============================================================================
--- stable/7/UPDATING	Mon Aug 31 02:22:18 2009	(r196683)
+++ stable/7/UPDATING	Mon Aug 31 02:45:47 2009	(r196684)
@@ -8,6 +8,11 @@ Items affecting the ports and packages s
 /usr/ports/UPDATING.  Please read that file before running
 portupgrade.
 
+20090831:
+	The newly imported zic(8) produces a new format in the
+	output. Please run tzsetup(8) to install the newly created
+	data to /etc/localtime.
+
 20090731:
 	The ABI of various structures related to the SYSV IPC API have
 	been changed.  Bump __FreeBSD_version to 702105.
From kib at FreeBSD.org  Mon Aug 31 09:20:38 2009
From: kib at FreeBSD.org (Konstantin Belousov)
Date: Mon Aug 31 09:20:54 2009
Subject: svn commit: r196688 - in stable/7/sys: . contrib/pf kern
Message-ID: <200908310920.n7V9Kb31022093@svn.freebsd.org>

Author: kib
Date: Mon Aug 31 09:20:37 2009
New Revision: 196688
URL: http://svn.freebsd.org/changeset/base/196688

Log:
  MFC r196560:
  Honor the vfs.timestamp_precision sysctl settings for utimes(path, NULL)
  and similar calls.

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/kern/vfs_syscalls.c

Modified: stable/7/sys/kern/vfs_syscalls.c
==============================================================================
--- stable/7/sys/kern/vfs_syscalls.c	Mon Aug 31 09:08:14 2009	(r196687)
+++ stable/7/sys/kern/vfs_syscalls.c	Mon Aug 31 09:20:37 2009	(r196688)
@@ -2843,8 +2843,7 @@ getutimes(usrtvp, tvpseg, tsp)
 	int error;
 
 	if (usrtvp == NULL) {
-		microtime(&tv[0]);
-		TIMEVAL_TO_TIMESPEC(&tv[0], &tsp[0]);
+		vfs_timestamp(&tsp[0]);
 		tsp[1] = tsp[0];
 	} else {
 		if (tvpseg == UIO_SYSSPACE) {
From jhb at FreeBSD.org  Mon Aug 31 11:54:14 2009
From: jhb at FreeBSD.org (John Baldwin)
Date: Mon Aug 31 11:54:24 2009
Subject: svn commit: r196693 - stable/7/sys/ufs/ufs
Message-ID: <200908311154.n7VBsDMP026596@svn.freebsd.org>

Author: jhb
Date: Mon Aug 31 11:54:13 2009
New Revision: 196693
URL: http://svn.freebsd.org/changeset/base/196693

Log:
  MFC a part of 191990:
  Fix compile of UFS_EXTATTR without UFS_EXTATTR_AUTOSTART.
  
  PR:		kern/138350

Modified:
  stable/7/sys/ufs/ufs/ufs_extattr.c

Modified: stable/7/sys/ufs/ufs/ufs_extattr.c
==============================================================================
--- stable/7/sys/ufs/ufs/ufs_extattr.c	Mon Aug 31 10:20:52 2009	(r196692)
+++ stable/7/sys/ufs/ufs/ufs_extattr.c	Mon Aug 31 11:54:13 2009	(r196693)
@@ -93,8 +93,10 @@ static int	ufs_extattr_set(struct vnode 
 		    struct thread *td);
 static int	ufs_extattr_rm(struct vnode *vp, int attrnamespace,
 		    const char *name, struct ucred *cred, struct thread *td);
+#ifdef UFS_EXTATTR_AUTOSTART
 static int	ufs_extattr_autostart_locked(struct mount *mp,
 		    struct thread *td);
+#endif
 static int	ufs_extattr_start_locked(struct ufsmount *ump,
 		    struct thread *td);
 
From jhb at FreeBSD.org  Mon Aug 31 19:07:20 2009
From: jhb at FreeBSD.org (John Baldwin)
Date: Mon Aug 31 19:07:37 2009
Subject: svn commit: r196708 - in stable/7: share/man/man9 sys sys/conf
	sys/contrib/pf sys/kern sys/sys
Message-ID: <200908311907.n7VJ7J9Z036296@svn.freebsd.org>

Author: jhb
Date: Mon Aug 31 19:07:19 2009
New Revision: 196708
URL: http://svn.freebsd.org/changeset/base/196708

Log:
  MFC 193260 and 196417:
  Add a simple API to manage scatter/gather lists of phyiscal addresses.
  Each list describes a logical memory object that is backed by one or more
  physical address ranges.  To minimize locking, the sglist objects
  themselves are immutable once they are shared.

Added:
  stable/7/share/man/man9/sglist.9
     - copied, changed from r193260, head/share/man/man9/sglist.9
  stable/7/sys/kern/subr_sglist.c
     - copied, changed from r193260, head/sys/kern/subr_sglist.c
  stable/7/sys/sys/sglist.h
     - copied unchanged from r193260, head/sys/sys/sglist.h
Modified:
  stable/7/share/man/man9/   (props changed)
  stable/7/share/man/man9/Makefile
  stable/7/sys/   (props changed)
  stable/7/sys/conf/files
  stable/7/sys/contrib/pf/   (props changed)

Modified: stable/7/share/man/man9/Makefile
==============================================================================
--- stable/7/share/man/man9/Makefile	Mon Aug 31 18:41:13 2009	(r196707)
+++ stable/7/share/man/man9/Makefile	Mon Aug 31 19:07:19 2009	(r196708)
@@ -210,6 +210,7 @@ MAN=	accept_filter.9 \
 	selrecord.9 \
 	sema.9 \
 	sf_buf.9 \
+	sglist.9 \
 	signal.9 \
 	sleep.9 \
 	sleepqueue.9 \
@@ -983,6 +984,24 @@ MLINKS+=sf_buf.9 sf_buf_alloc.9 \
 	sf_buf.9 sf_buf_free.9 \
 	sf_buf.9 sf_buf_kva.9 \
 	sf_buf.9 sf_buf_page.9
+MLINKS+=sglist.9 sglist_alloc.9 \
+	sglist.9 sglist_append.9 \
+	sglist.9 sglist_append_mbuf.9 \
+	sglist.9 sglist_append_phys.9 \
+	sglist.9 sglist_append_uio.9 \
+	sglist.9 sglist_append_user.9 \
+	sglist.9 sglist_build.9 \
+	sglist.9 sglist_clone.9 \
+	sglist.9 sglist_consume_uio.9 \
+	sglist.9 sglist_count.9 \
+	sglist.9 sglist_free.9 \
+	sglist.9 sglist_hold.9 \
+	sglist.9 sglist_init.9 \
+	sglist.9 sglist_join.9 \
+	sglist.9 sglist_length.9 \
+	sglist.9 sglist_reset.9 \
+	sglist.9 sglist_slice.9 \
+	sglist.9 sglist_split.9
 MLINKS+=signal.9 cursig.9 \
 	signal.9 execsigs.9 \
 	signal.9 issignal.9 \

Copied and modified: stable/7/share/man/man9/sglist.9 (from r193260, head/share/man/man9/sglist.9)
==============================================================================
--- head/share/man/man9/sglist.9	Mon Jun  1 20:35:39 2009	(r193260, copy source)
+++ stable/7/share/man/man9/sglist.9	Mon Aug 31 19:07:19 2009	(r196708)
@@ -191,6 +191,8 @@ Specifically, the
 family of routines can be used to append the physical address ranges described
 by an object to the end of a scatter/gather list.
 All of these routines return 0 on success or an error on failure.
+If a request to append an address range to a scatter/gather list fails,
+the scatter/gather list will remain unchanged.
 .Pp
 The
 .Nm sglist_append
@@ -445,6 +447,7 @@ There are not enough available segments 
 to append the physical address ranges from
 .Fa second .
 .El
+.Pp
 The
 .Nm sglist_slice
 function returns the following errors on failure:
@@ -470,6 +473,7 @@ list in
 .Fa *slice
 to describe the requested physical address ranges.
 .El
+.Pp
 The
 .Nm sglist_split
 function returns the following errors on failure:

Modified: stable/7/sys/conf/files
==============================================================================
--- stable/7/sys/conf/files	Mon Aug 31 18:41:13 2009	(r196707)
+++ stable/7/sys/conf/files	Mon Aug 31 19:07:19 2009	(r196708)
@@ -1630,6 +1630,7 @@ kern/kern_proc.c		standard
 kern/kern_prot.c		standard
 kern/kern_resource.c		standard
 kern/kern_rwlock.c		standard
+kern/kern_sdt.c			optional kdtrace_hooks
 kern/kern_sema.c		standard
 kern/kern_shutdown.c		standard
 kern/kern_sig.c			standard
@@ -1683,7 +1684,7 @@ kern/subr_rman.c		standard
 kern/subr_rtc.c			optional genclock
 kern/subr_sbuf.c		standard
 kern/subr_scanf.c		standard
-kern/kern_sdt.c			optional kdtrace_hooks
+kern/subr_sglist.c		standard
 kern/subr_sleepqueue.c		standard
 kern/subr_smp.c			standard
 kern/subr_stack.c		optional ddb | stack

Copied and modified: stable/7/sys/kern/subr_sglist.c (from r193260, head/sys/kern/subr_sglist.c)
==============================================================================
--- head/sys/kern/subr_sglist.c	Mon Jun  1 20:35:39 2009	(r193260, copy source)
+++ stable/7/sys/kern/subr_sglist.c	Mon Aug 31 19:07:19 2009	(r196708)
@@ -48,6 +48,32 @@ __FBSDID("$FreeBSD$");
 static MALLOC_DEFINE(M_SGLIST, "sglist", "scatter/gather lists");
 
 /*
+ * Convenience macros to save the state of an sglist so it can be restored
+ * if an append attempt fails.  Since sglist's only grow we only need to
+ * save the current count of segments and the length of the ending segment.
+ * Earlier segments will not be changed by an append, and the only change
+ * that can occur to the ending segment is that it can be extended.
+ */
+struct sgsave {
+	u_short sg_nseg;
+	size_t ss_len;
+};
+
+#define	SGLIST_SAVE(sg, sgsave) do {					\
+	(sgsave).sg_nseg = (sg)->sg_nseg;				\
+	if ((sgsave).sg_nseg > 0)					\
+		(sgsave).ss_len = (sg)->sg_segs[(sgsave).sg_nseg - 1].ss_len; \
+	else								\
+		(sgsave).ss_len = 0;					\
+} while (0)
+
+#define	SGLIST_RESTORE(sg, sgsave) do {					\
+	(sg)->sg_nseg = (sgsave).sg_nseg;				\
+	if ((sgsave).sg_nseg > 0)					\
+		(sg)->sg_segs[(sgsave).sg_nseg - 1].ss_len = (sgsave).ss_len; \
+} while (0)
+
+/*
  * Append a single (paddr, len) to a sglist.  sg is the list and ss is
  * the current segment in the list.  If we run out of segments then
  * EFBIG will be returned.
@@ -62,10 +88,8 @@ _sglist_append_range(struct sglist *sg, 
 	if (ss->ss_paddr + ss->ss_len == paddr)
 		ss->ss_len += len;
 	else {
-		if (sg->sg_nseg == sg->sg_maxseg) {
-			sg->sg_nseg = 0;
+		if (sg->sg_nseg == sg->sg_maxseg)
 			return (EFBIG);
-		}
 		ss++;
 		ss->ss_paddr = paddr;
 		ss->ss_len = len;
@@ -107,26 +131,33 @@ _sglist_append_buf(struct sglist *sg, vo
 		ss->ss_paddr = paddr;
 		ss->ss_len = seglen;
 		sg->sg_nseg = 1;
-		error = 0;
 	} else {
 		ss = &sg->sg_segs[sg->sg_nseg - 1];
 		error = _sglist_append_range(sg, &ss, paddr, seglen);
+		if (error)
+			return (error);
 	}
+	vaddr += seglen;
+	len -= seglen;
+	if (donep)
+		*donep += seglen;
 
-	while (error == 0 && len > seglen) {
-		vaddr += seglen;
-		len -= seglen;
-		if (donep)
-			*donep += seglen;
+	while (len > 0) {
 		seglen = MIN(len, PAGE_SIZE);
 		if (pmap != NULL)
 			paddr = pmap_extract(pmap, vaddr);
 		else
 			paddr = pmap_kextract(vaddr);
 		error = _sglist_append_range(sg, &ss, paddr, seglen);
+		if (error)
+			return (error);
+		vaddr += seglen;
+		len -= seglen;
+		if (donep)
+			*donep += seglen;
 	}
 
-	return (error);
+	return (0);
 }
 
 /*
@@ -195,10 +226,16 @@ sglist_free(struct sglist *sg)
 int
 sglist_append(struct sglist *sg, void *buf, size_t len)
 {
+	struct sgsave save;
+	int error;
 
 	if (sg->sg_maxseg == 0)
 		return (EINVAL);
-	return (_sglist_append_buf(sg, buf, len, NULL, NULL));
+	SGLIST_SAVE(sg, save);
+	error = _sglist_append_buf(sg, buf, len, NULL, NULL);
+	if (error)
+		SGLIST_RESTORE(sg, save);
+	return (error);
 }
 
 /*
@@ -209,6 +246,8 @@ int
 sglist_append_phys(struct sglist *sg, vm_paddr_t paddr, size_t len)
 {
 	struct sglist_seg *ss;
+	struct sgsave save;
+	int error;
 
 	if (sg->sg_maxseg == 0)
 		return (EINVAL);
@@ -222,7 +261,11 @@ sglist_append_phys(struct sglist *sg, vm
 		return (0);
 	}
 	ss = &sg->sg_segs[sg->sg_nseg - 1];
-	return (_sglist_append_range(sg, &ss, paddr, len));
+	SGLIST_SAVE(sg, save);
+	error = _sglist_append_range(sg, &ss, paddr, len);
+	if (error)
+		SGLIST_RESTORE(sg, save);
+	return (error);
 }
 
 /*
@@ -233,6 +276,7 @@ sglist_append_phys(struct sglist *sg, vm
 int
 sglist_append_mbuf(struct sglist *sg, struct mbuf *m0)
 {
+	struct sgsave save;
 	struct mbuf *m;
 	int error;
 
@@ -240,11 +284,14 @@ sglist_append_mbuf(struct sglist *sg, st
 		return (EINVAL);
 
 	error = 0;
+	SGLIST_SAVE(sg, save);
 	for (m = m0; m != NULL; m = m->m_next) {
 		if (m->m_len > 0) {
 			error = sglist_append(sg, m->m_data, m->m_len);
-			if (error)
+			if (error) {
+				SGLIST_RESTORE(sg, save);
 				return (error);
+			}
 		}
 	}
 	return (0);
@@ -258,11 +305,17 @@ sglist_append_mbuf(struct sglist *sg, st
 int
 sglist_append_user(struct sglist *sg, void *buf, size_t len, struct thread *td)
 {
+	struct sgsave save;
+	int error;
 
 	if (sg->sg_maxseg == 0)
 		return (EINVAL);
-	return (_sglist_append_buf(sg, buf, len,
-	    vmspace_pmap(td->td_proc->p_vmspace), NULL));
+	SGLIST_SAVE(sg, save);
+	error = _sglist_append_buf(sg, buf, len,
+	    vmspace_pmap(td->td_proc->p_vmspace), NULL);
+	if (error)
+		SGLIST_RESTORE(sg, save);
+	return (error);
 }
 
 /*
@@ -274,6 +327,7 @@ int
 sglist_append_uio(struct sglist *sg, struct uio *uio)
 {
 	struct iovec *iov;
+	struct sgsave save;
 	size_t resid, minlen;
 	pmap_t pmap;
 	int error, i;
@@ -292,6 +346,7 @@ sglist_append_uio(struct sglist *sg, str
 		pmap = NULL;
 
 	error = 0;
+	SGLIST_SAVE(sg, save);
 	for (i = 0; i < uio->uio_iovcnt && resid != 0; i++) {
 		/*
 		 * Now at the first iovec to load.  Load each iovec
@@ -301,8 +356,10 @@ sglist_append_uio(struct sglist *sg, str
 		if (minlen > 0) {
 			error = _sglist_append_buf(sg, iov[i].iov_base, minlen,
 			    pmap, NULL);
-			if (error)
+			if (error) {
+				SGLIST_RESTORE(sg, save);
 				return (error);
+			}
 			resid -= minlen;
 		}
 	}
@@ -397,6 +454,7 @@ sglist_clone(struct sglist *sg, int mfla
 	new = sglist_alloc(sg->sg_maxseg, mflags);
 	if (new == NULL)
 		return (NULL);
+	new->sg_nseg = sg->sg_nseg;
 	bcopy(sg->sg_segs, new->sg_segs, sizeof(struct sglist_seg) *
 	    sg->sg_nseg);
 	return (new);

Copied: stable/7/sys/sys/sglist.h (from r193260, head/sys/sys/sglist.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/7/sys/sys/sglist.h	Mon Aug 31 19:07:19 2009	(r196708, copy of r193260, head/sys/sys/sglist.h)
@@ -0,0 +1,104 @@
+/*-
+ * Copyright (c) 2008 Yahoo!, Inc.
+ * All rights reserved.
+ * Written by: John Baldwin 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+/*
+ * A scatter/gather list describes a group of physical address ranges.
+ * Each physical address range consists of a starting address and a
+ * length.
+ */
+
+#ifndef __SGLIST_H__
+#define	__SGLIST_H__
+
+#include 
+
+struct sglist_seg {
+	vm_paddr_t	ss_paddr;
+	size_t		ss_len;
+};
+
+struct sglist {
+	struct sglist_seg *sg_segs;
+	int		sg_refs;
+	u_short		sg_nseg;
+	u_short		sg_maxseg;
+};
+
+struct mbuf;
+struct uio;
+
+static __inline void
+sglist_init(struct sglist *sg, u_short maxsegs, struct sglist_seg *segs)
+{
+
+	sg->sg_segs = segs;
+	sg->sg_nseg = 0;
+	sg->sg_maxseg = maxsegs;
+	refcount_init(&sg->sg_refs, 1);
+}
+
+static __inline void
+sglist_reset(struct sglist *sg)
+{
+
+	sg->sg_nseg = 0;
+}
+
+static __inline struct sglist *
+sglist_hold(struct sglist *sg)
+{
+
+	refcount_acquire(&sg->sg_refs);
+	return (sg);
+}
+
+struct sglist *sglist_alloc(int nsegs, int mflags);
+int	sglist_append(struct sglist *sg, void *buf, size_t len);
+int	sglist_append_mbuf(struct sglist *sg, struct mbuf *m0);
+int	sglist_append_phys(struct sglist *sg, vm_paddr_t paddr,
+	    size_t len);
+int	sglist_append_uio(struct sglist *sg, struct uio *uio);
+int	sglist_append_user(struct sglist *sg, void *buf, size_t len,
+	    struct thread *td);
+struct sglist *sglist_build(void *buf, size_t len, int mflags);
+struct sglist *sglist_clone(struct sglist *sg, int mflags);
+int	sglist_consume_uio(struct sglist *sg, struct uio *uio, int resid);
+int	sglist_count(void *buf, size_t len);
+void	sglist_free(struct sglist *sg);
+int	sglist_join(struct sglist *first, struct sglist *second);
+size_t	sglist_length(struct sglist *sg);
+int	sglist_slice(struct sglist *original, struct sglist **slice,
+	    size_t offset, size_t length, int mflags);
+int	sglist_split(struct sglist *original, struct sglist **head,
+	    size_t length, int mflags);
+
+#endif	/* !__SGLIST_H__ */