From owner-svn-src-stable-9@FreeBSD.ORG Sun Mar 17 14:10:59 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D65D0437; Sun, 17 Mar 2013 14:10:59 +0000 (UTC) (envelope-from marck@rinet.ru) Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68]) by mx1.freebsd.org (Postfix) with ESMTP id 465FB2A4; Sun, 17 Mar 2013 14:10:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by woozle.rinet.ru (8.14.5/8.14.5) with ESMTP id r2HEAwVO082879; Sun, 17 Mar 2013 18:10:58 +0400 (MSK) (envelope-from marck@rinet.ru) Date: Sun, 17 Mar 2013 18:10:58 +0400 (MSK) From: Dmitry Morozovsky To: Brooks Davis Subject: Re: svn commit: r248352 - in stable/9: etc share/mk In-Reply-To: <201303152132.r2FLWfwx076672@svn.freebsd.org> Message-ID: References: <201303152132.r2FLWfwx076672@svn.freebsd.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) X-NCC-RegID: ru.rinet X-OpenPGP-Key-ID: 6B691B03 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (woozle.rinet.ru [0.0.0.0]); Sun, 17 Mar 2013 18:10:58 +0400 (MSK) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Mar 2013 14:10:59 -0000 On Fri, 15 Mar 2013, Brooks Davis wrote: > Author: brooks > Date: Fri Mar 15 21:32:40 2013 > New Revision: 248352 > URL: http://svnweb.freebsd.org/changeset/base/248352 > > Log: > MFC r245752,246913,247162 > > Replace all known uses of ln in the build process with appropriate > install -l invocations via new INSTALL_LINK and INSTALL_SYMLINK > variables. It seems this merge breaks ``make distribution'' and hence mergemaster if your base system is not updated yet (for example, while updating jail): root@castor:/FreeBSD/rinet/src.9.newcarp# uname -a FreeBSD castor.rinet.ru 9.1-STABLE FreeBSD 9.1-STABLE #0 r245742: Mon Jan 21 21:29:07 MSK 2013 marck@castor.rinet.ru:/usr/obj/usr/src/sys/CASTOR amd64 root@castor:/FreeBSD/rinet/src.9.newcarp# make hierarchy DESTDIR=/tmp/xxx cd /FreeBSD/rinet/src.9.newcarp/etc; /usr/obj/FreeBSD/rinet/src.9.newcarp/make.amd64/make LOCAL_MTREE= distrib-dirs mtree -deU -f /FreeBSD/rinet/src.9.newcarp/etc/mtree/BSD.root.dist -p /tmp/xxx/ mtree -deU -f /FreeBSD/rinet/src.9.newcarp/etc/mtree/BSD.var.dist -p /tmp/xxx/var mtree -deU -f /FreeBSD/rinet/src.9.newcarp/etc/mtree/BSD.usr.dist -p /tmp/xxx/usr mtree -deU -f /FreeBSD/rinet/src.9.newcarp/etc/mtree/BSD.include.dist -p /tmp/xxx/usr/include mtree -deU -f /FreeBSD/rinet/src.9.newcarp/etc/mtree/BIND.chroot.dist -p /tmp/xxx/var/named mtree -deU -f /FreeBSD/rinet/src.9.newcarp/etc/mtree/BSD.groff.dist -p /tmp/xxx/usr mtree -deU -f /FreeBSD/rinet/src.9.newcarp/etc/mtree/BSD.sendmail.dist -p /tmp/xxx/ install -l s usr/src/sys /tmp/xxx/sys install: illegal option -- l usage: install [-bCcMpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcMpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... *** [distrib-dirs] Error code 64 Stop in /FreeBSD/rinet/src.9.newcarp/etc. [snip] -- Sincerely, D.Marck [DM5020, MCK-RIPE, DM3-RIPN] [ FreeBSD committer: marck@FreeBSD.org ] ------------------------------------------------------------------------ *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru *** ------------------------------------------------------------------------ From owner-svn-src-stable-9@FreeBSD.ORG Mon Mar 18 02:49:24 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AA7DACD4 for ; Mon, 18 Mar 2013 02:49:24 +0000 (UTC) (envelope-from jdc@koitsu.org) Received: from qmta01.emeryville.ca.mail.comcast.net (qmta01.emeryville.ca.mail.comcast.net [IPv6:2001:558:fe2d:43:76:96:30:16]) by mx1.freebsd.org (Postfix) with ESMTP id 8DAFDF76 for ; Mon, 18 Mar 2013 02:49:24 +0000 (UTC) Received: from omta06.emeryville.ca.mail.comcast.net ([76.96.30.51]) by qmta01.emeryville.ca.mail.comcast.net with comcast id CjJs1l00816AWCUA1qpQQd; Mon, 18 Mar 2013 02:49:24 +0000 Received: from koitsu.strangled.net ([67.180.84.87]) by omta06.emeryville.ca.mail.comcast.net with comcast id CqpP1l0031t3BNj8SqpPTU; Mon, 18 Mar 2013 02:49:23 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id DBD8073A1C; Sun, 17 Mar 2013 19:49:22 -0700 (PDT) Date: Sun, 17 Mar 2013 19:49:22 -0700 From: Jeremy Chadwick To: Brooks Davis Subject: Re: svn commit: r248331 - in stable/9: . usr.bin/xinstall Message-ID: <20130318024922.GA24535@icarus.home.lan> References: <201303151519.r2FFJYjS060493@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201303151519.r2FFJYjS060493@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1363574964; bh=fstX/Whi4zbUmVC21RU3Pc8yzaKt55o1pZuuTN5XGe8=; h=Received:Received:Received:Date:From:To:Subject:Message-ID: MIME-Version:Content-Type; b=Jk4gaZnnWC4NlUFnUZbXgwev5AH1aVffgyJ8x3B+prN/+MNrRZ6bLpJw6vUgUnUgh oib7eK7FI1n9zOwJBB5OKbwjughox0QUUlQwXYmIffXfQ8ziomlzKEqrXmXOhV2CyX RbFode4L3WPWRq0odGdFirxBU0aIrcfRJRucTsbKIMLb2MwZWUd7hpLO3KGRLh+sdL P+pxYxDductc6MFkcJ1plP1unht+EAi+B+HU9zxJSooSXzZ2Kg/cwCxMtozRl3z3hZ tDomKkGP+wRZh4u5YDveKr04gnPelW09Gi3PChBq7X5xg4FPqqaVDmnFHe3QhMRknT aeNzhJwzcuB+w== Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Mar 2013 02:49:24 -0000 Please see PR 177055. This MFC has broken mergmaster for at least a couple people. The PR should really be rated high priority: http://www.freebsd.org/cgi/query-pr.cgi?pr=177055 http://lists.freebsd.org/pipermail/freebsd-stable/2013-March/072848.html -- | Jeremy Chadwick jdc@koitsu.org | | UNIX Systems Administrator http://jdc.koitsu.org/ | | Mountain View, CA, US | | Making life hard for others since 1977. PGP 4BD6C0CB | On Fri, Mar 15, 2013 at 03:19:34PM +0000, Brooks Davis wrote: > Author: brooks > Date: Fri Mar 15 15:19:33 2013 > New Revision: 248331 > URL: http://svnweb.freebsd.org/changeset/base/248331 > > Log: > MFC all changes to install(1) through r246784. Notable functional > changes are: > > r245617: > Introduce six new options from NetBSD: > * -M Log metadata in mtree format. > * -D Log paths relative to . > * -h Log digest of type . > * -T Specify which mtree tags to log. > * -l Create hard or symbolic links (allows logging). > * -U Install without root privileges (owner, group, mode, > and flags can be logged via -M > > NOTE: In the interest of compatibility with NetBSD and because it is the > obvious letter, the nearly useless -M option (disable mmap) has been > repurposed. > > Sponsored by: DARPA, AFRL > Obtained from: NetBSD > Reviewed by: bz > > r245312: > Implement the -N option which allows an alternate passwd and > group file to be used. This is useful for installing on systems where > a user or group does not currently exist. > > Sponsored by: DARPA, AFRL > Obtained from: NetBSD > > Modified: > stable/9/UPDATING (contents, props changed) > stable/9/usr.bin/xinstall/Makefile > stable/9/usr.bin/xinstall/install.1 > stable/9/usr.bin/xinstall/xinstall.c > Directory Properties: > stable/9/usr.bin/xinstall/ (props changed) > > Modified: stable/9/UPDATING > ============================================================================== > --- stable/9/UPDATING Fri Mar 15 14:53:29 2013 (r248330) > +++ stable/9/UPDATING Fri Mar 15 15:19:33 2013 (r248331) > @@ -11,6 +11,15 @@ handbook: > Items affecting the ports and packages system can be found in > /usr/ports/UPDATING. Please read that file before running portupgrade. > > +20130315: > + The install(1) option -M has changed meaning and now takes an > + argument that is a file or path to append logs to. In the > + unlikely event that -M was the last option on the command line > + and the command line contained at least two files and a target > + directory the first file will have logs appended to it. The -M > + option served little practical purpose in the last decade so it's > + used expected to be extremely rare. > + > 20130225: > A new compression method (lz4) has been merged to. Please refer to > zpool-features(7) for more information. > > Modified: stable/9/usr.bin/xinstall/Makefile > ============================================================================== > --- stable/9/usr.bin/xinstall/Makefile Fri Mar 15 14:53:29 2013 (r248330) > +++ stable/9/usr.bin/xinstall/Makefile Fri Mar 15 15:19:33 2013 (r248331) > @@ -3,6 +3,16 @@ > > PROG= xinstall > PROGNAME= install > +SRCS= xinstall.c getid.c > MAN= install.1 > > +.PATH: ${.CURDIR}/../../contrib/mtree > +.PATH: ${.CURDIR}/../../lib/libmd > +CFLAGS+= -I${.CURDIR}/../../contrib/mtree > +CFLAGS+= -I${.CURDIR}/../../lib/libnetbsd > +CFLAGS+= -I${.CURDIR}/../../lib/libmd > + > +DPADD+= ${LIBMD} > +LDADD+= -lmd > + > .include > > Modified: stable/9/usr.bin/xinstall/install.1 > ============================================================================== > --- stable/9/usr.bin/xinstall/install.1 Fri Mar 15 14:53:29 2013 (r248330) > +++ stable/9/usr.bin/xinstall/install.1 Fri Mar 15 15:19:33 2013 (r248331) > @@ -28,7 +28,7 @@ > .\" From: @(#)install.1 8.1 (Berkeley) 6/6/93 > .\" $FreeBSD$ > .\" > -.Dd March 6, 2006 > +.Dd January 18, 2013 > .Dt INSTALL 1 > .Os > .Sh NAME > @@ -36,31 +36,50 @@ > .Nd install binaries > .Sh SYNOPSIS > .Nm > -.Op Fl bCcMpSsv > +.Op Fl bCcpSsUv > .Op Fl B Ar suffix > +.Op Fl D Ar destdir > .Op Fl f Ar flags > .Op Fl g Ar group > +.Op Fl h Ar hash > +.Op Fl l Ar linkflags > +.Op Fl M Ar metalog > .Op Fl m Ar mode > +.Op Fl N Ar dbdir > .Op Fl o Ar owner > +.Op Fl T Ar tags > .Ar file1 file2 > .Nm > -.Op Fl bCcMpSsv > +.Op Fl bCcpSsUv > .Op Fl B Ar suffix > +.Op Fl D Ar destdir > .Op Fl f Ar flags > .Op Fl g Ar group > +.Op Fl h Ar hash > +.Op Fl l Ar linkflags > +.Op Fl M Ar metalog > .Op Fl m Ar mode > +.Op Fl N Ar dbdir > .Op Fl o Ar owner > +.Op Fl T Ar tags > .Ar file1 ... fileN directory > .Nm > .Fl d > -.Op Fl v > +.Op Fl Uv > +.Op Fl D Ar destdir > .Op Fl g Ar group > +.Op Fl h Ar hash > +.Op Fl M Ar metalog > .Op Fl m Ar mode > +.Op Fl N Ar dbdir > .Op Fl o Ar owner > +.Op Fl T Ar tags > .Ar directory ... > .Sh DESCRIPTION > The file(s) are copied > -to the target file or directory. > +(or linked if the > +.Fl l > +option is specified) to the target file or directory. > If the destination is a directory, then the > .Ar file > is copied into > @@ -105,6 +124,17 @@ This is actually the default. > The > .Fl c > option is only included for backwards compatibility. > +.It Fl D Ar destdir > +Specify the > +.Ev DESTDIR > +(top of the file hierarchy) that the items are installed in to. > +If > +.Fl M Ar metalog > +is in use, a leading string of > +.Dq Ar destdir > +will be removed from the file names logged to the > +.Ar metalog . > +This option does not affect where the actual files are installed. > .It Fl d > Create directories. > Missing parent directories are created as required. > @@ -115,15 +145,82 @@ for a list of possible flags and their m > .It Fl g > Specify a group. > A numeric GID is allowed. > -.It Fl M > -Disable all use of > -.Xr mmap 2 . > +.It Fl h Ar hash > +When copying, calculate the digest of the files with > +.Ar hash > +to store in the > +.Fl M Ar metalog . > +When > +.Fl d > +is given no hash is emitted. > +Supported digests: > +.Bl -tag -width rmd160 -offset indent > +.It Sy none > +No hash. > +This is the default. > +.It Sy md5 > +The MD5 cryptographic message digest. > +.It Sy rmd160 > +The RMD-160 cryptographic message digest. > +.It Sy sha1 > +The SHA-1 cryptographic message digest. > +.It Sy sha256 > +The 256-bits > +.Tn SHA-2 > +cryptographic message digest of the file. > +.It Sy sha512 > +The 512-bits > +.Tn SHA-2 > +cryptographic message digest of the file. > +.El > +.It Fl l Ar linkflags > +Instead of copying the file make a link to the source. > +The type of the link is determined by the > +.Ar linkflags > +argument. > +Valid > +.Ar linkflags > +are: > +.Ar a > +(absolute), > +.Ar r > +(relative), > +.Ar h > +(hard), > +.Ar s > +(symbolic), > +.Ar m > +(mixed). > +Absolute and relative have effect only for symbolic links. > +Mixed links > +are hard links for files on the same filesystem, symbolic otherwise. > +.It Fl M Ar metalog > +Write the metadata associated with each item installed to > +.Ar metalog > +in an > +.Xr mtree 8 > +.Dq full path > +specification line. > +The metadata includes: the file name and file type, and depending upon > +other options, the owner, group, file flags, modification time, and tags. > .It Fl m > Specify an alternate mode. > The default mode is set to rwxr-xr-x (0755). > The specified mode may be either an octal or symbolic value; see > .Xr chmod 1 > for a description of possible mode values. > +.It Fl N > +Use the user database text file > +.Pa master.passwd > +and group database text file > +.Pa group > +from > +.Ar dbdir , > +rather than using the results from the system's > +.Xr getpwnam 3 > +and > +.Xr getgrnam 3 > +(and related) library calls. > .It Fl o > Specify an owner. > A numeric UID is allowed. > @@ -156,6 +253,17 @@ number of systems and binary types. > See below for how > .Nm > can be instructed to use another program to strip binaries. > +.It Fl T Ar tags > +Specify the > +.Xr mtree 8 > +tags to write out for the file when using > +.Fl M Ar metalog . > +.It Fl U > +Indicate that install is running unprivileged, and that it should not > +try to change the owner, the group, or the file flags of the destination. > +The information that would have been updated can be stored in a log > +file with > +.Fl M Ar metalog . > .It Fl v > Cause > .Nm > @@ -231,6 +339,8 @@ The default was changed to copy in > .Xr mv 1 , > .Xr strip 1 , > .Xr mmap 2 , > +.Xr getgrnam 3 , > +.Xr getpwnam 3 , > .Xr chown 8 > .Sh HISTORY > The > @@ -238,6 +348,16 @@ The > utility appeared in > .Bx 4.2 . > .Sh BUGS > +The meaning of the > +.Fl M > +option has changed as of > +.Fx 10 > +and it now takes an argument. > +Command lines that used the old > +.Fl M > +will get an error or in rare cases will append logs to the first of > +multiple source files rather than installing it. > +.Pp > Temporary files may be left in the target directory if > .Nm > exits abnormally. > > Modified: stable/9/usr.bin/xinstall/xinstall.c > ============================================================================== > --- stable/9/usr.bin/xinstall/xinstall.c Fri Mar 15 14:53:29 2013 (r248330) > +++ stable/9/usr.bin/xinstall/xinstall.c Fri Mar 15 15:19:33 2013 (r248331) > @@ -1,4 +1,5 @@ > /* > + * Copyright (c) 2012, 2013 SRI International > * Copyright (c) 1987, 1993 > * The Regents of the University of California. All rights reserved. > * > @@ -53,14 +54,23 @@ __FBSDID("$FreeBSD$"); > #include > #include > #include > +#include > +#include > #include > #include > +#include > +#include > +#include > +#include > #include > #include > #include > #include > #include > #include > +#include > + > +#include "mtree.h" > > /* Bootstrap aid - this doesn't exist in most older releases */ > #ifndef MAP_FAILED > @@ -69,26 +79,63 @@ __FBSDID("$FreeBSD$"); > > #define MAX_CMP_SIZE (16 * 1024 * 1024) > > +#define LN_ABSOLUTE 0x01 > +#define LN_RELATIVE 0x02 > +#define LN_HARD 0x04 > +#define LN_SYMBOLIC 0x08 > +#define LN_MIXED 0x10 > + > #define DIRECTORY 0x01 /* Tell install it's a directory. */ > #define SETFLAGS 0x02 /* Tell install to set flags. */ > #define NOCHANGEBITS (UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_APPEND) > #define BACKUP_SUFFIX ".old" > > -struct passwd *pp; > -struct group *gp; > -gid_t gid; > -uid_t uid; > -int dobackup, docompare, dodir, dopreserve, dostrip, nommap, safecopy, verbose; > -mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; > -const char *suffix = BACKUP_SUFFIX; > - > -static int compare(int, const char *, size_t, int, const char *, size_t); > -static void copy(int, const char *, int, const char *, off_t); > +typedef union { > + MD5_CTX MD5; > + RIPEMD160_CTX RIPEMD160; > + SHA1_CTX SHA1; > + SHA256_CTX SHA256; > + SHA512_CTX SHA512; > +} DIGEST_CTX; > + > +static enum { > + DIGEST_NONE = 0, > + DIGEST_MD5, > + DIGEST_RIPEMD160, > + DIGEST_SHA1, > + DIGEST_SHA256, > + DIGEST_SHA512, > +} digesttype = DIGEST_NONE; > + > +static gid_t gid; > +static uid_t uid; > +static int dobackup, docompare, dodir, dolink, dopreserve, dostrip, dounpriv, > + safecopy, verbose; > +static int haveopt_f, haveopt_g, haveopt_m, haveopt_o; > +static mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; > +static FILE *metafp; > +static const char *group, *owner; > +static const char *suffix = BACKUP_SUFFIX; > +static char *destdir, *digest, *fflags, *metafile, *tags; > + > +static int compare(int, const char *, size_t, int, const char *, size_t, > + char **); > +static char *copy(int, const char *, int, const char *, off_t); > static int create_newfile(const char *, int, struct stat *); > static int create_tempfile(const char *, char *, size_t); > +static char *quiet_mktemp(char *template); > +static char *digest_file(const char *); > +static void digest_init(DIGEST_CTX *); > +static void digest_update(DIGEST_CTX *, const unsigned char *, size_t); > +static char *digest_end(DIGEST_CTX *, char *); > +static int do_link(const char *, const char *, const struct stat *); > +static void do_symlink(const char *, const char *, const struct stat *); > +static void makelink(const char *, const char *, const struct stat *); > static void install(const char *, const char *, u_long, u_int); > static void install_dir(char *); > -static u_long numeric_id(const char *, const char *); > +static void metadata_log(const char *, const char *, struct timeval *, > + const char *, const char *, off_t); > +static int parseid(const char *, id_t *); > static void strip(const char *); > static int trymmap(int); > static void usage(void); > @@ -101,12 +148,13 @@ main(int argc, char *argv[]) > u_long fset; > int ch, no_target; > u_int iflags; > - char *flags; > - const char *group, *owner, *to_name; > + char *p; > + const char *to_name; > > iflags = 0; > group = owner = NULL; > - while ((ch = getopt(argc, argv, "B:bCcdf:g:Mm:o:pSsv")) != -1) > + while ((ch = getopt(argc, argv, "B:bCcD:df:g:h:l:M:m:N:o:pSsT:Uv")) != > + -1) > switch((char)ch) { > case 'B': > suffix = optarg; > @@ -120,29 +168,69 @@ main(int argc, char *argv[]) > case 'c': > /* For backwards compatibility. */ > break; > + case 'D': > + destdir = optarg; > + break; > case 'd': > dodir = 1; > break; > case 'f': > - flags = optarg; > - if (strtofflags(&flags, &fset, NULL)) > - errx(EX_USAGE, "%s: invalid flag", flags); > - iflags |= SETFLAGS; > + haveopt_f = 1; > + fflags = optarg; > break; > case 'g': > + haveopt_g = 1; > group = optarg; > break; > + case 'h': > + digest = optarg; > + break; > + case 'l': > + for (p = optarg; *p != '\0'; p++) > + switch (*p) { > + case 's': > + dolink &= ~(LN_HARD|LN_MIXED); > + dolink |= LN_SYMBOLIC; > + break; > + case 'h': > + dolink &= ~(LN_SYMBOLIC|LN_MIXED); > + dolink |= LN_HARD; > + break; > + case 'm': > + dolink &= ~(LN_SYMBOLIC|LN_HARD); > + dolink |= LN_MIXED; > + break; > + case 'a': > + dolink &= ~LN_RELATIVE; > + dolink |= LN_ABSOLUTE; > + break; > + case 'r': > + dolink &= ~LN_ABSOLUTE; > + dolink |= LN_RELATIVE; > + break; > + default: > + errx(1, "%c: invalid link type", *p); > + /* NOTREACHED */ > + } > + break; > case 'M': > - nommap = 1; > + metafile = optarg; > break; > case 'm': > + haveopt_m = 1; > if (!(set = setmode(optarg))) > errx(EX_USAGE, "invalid file mode: %s", > optarg); > mode = getmode(set, 0); > free(set); > break; > + case 'N': > + if (!setup_getid(optarg)) > + err(EX_OSERR, "Unable to use user and group " > + "databases in `%s'", optarg); > + break; > case 'o': > + haveopt_o = 1; > owner = optarg; > break; > case 'p': > @@ -154,6 +242,12 @@ main(int argc, char *argv[]) > case 's': > dostrip = 1; > break; > + case 'T': > + tags = optarg; > + break; > + case 'U': > + dounpriv = 1; > + break; > case 'v': > verbose = 1; > break; > @@ -179,27 +273,62 @@ main(int argc, char *argv[]) > if (argc == 0 || (argc == 1 && !dodir)) > usage(); > > + if (digest != NULL) { > + if (strcmp(digest, "none") == 0) { > + digesttype = DIGEST_NONE; > + } else if (strcmp(digest, "md5") == 0) { > + digesttype = DIGEST_MD5; > + } else if (strcmp(digest, "rmd160") == 0) { > + digesttype = DIGEST_RIPEMD160; > + } else if (strcmp(digest, "sha1") == 0) { > + digesttype = DIGEST_SHA1; > + } else if (strcmp(digest, "sha256") == 0) { > + digesttype = DIGEST_SHA256; > + } else if (strcmp(digest, "sha512") == 0) { > + digesttype = DIGEST_SHA512; > + } else { > + warnx("unknown digest `%s'", digest); > + usage(); > + } > + } > + > /* need to make a temp copy so we can compare stripped version */ > if (docompare && dostrip) > safecopy = 1; > > /* get group and owner id's */ > - if (group != NULL) { > - if ((gp = getgrnam(group)) != NULL) > - gid = gp->gr_gid; > - else > - gid = (gid_t)numeric_id(group, "group"); > + if (group != NULL && !dounpriv) { > + if (gid_from_group(group, &gid) == -1) { > + id_t id; > + if (!parseid(group, &id)) > + errx(1, "unknown group %s", group); > + gid = id; > + } > } else > gid = (gid_t)-1; > > - if (owner != NULL) { > - if ((pp = getpwnam(owner)) != NULL) > - uid = pp->pw_uid; > - else > - uid = (uid_t)numeric_id(owner, "user"); > + if (owner != NULL && !dounpriv) { > + if (uid_from_user(owner, &uid) == -1) { > + id_t id; > + if (!parseid(owner, &id)) > + errx(1, "unknown user %s", owner); > + uid = id; > + } > } else > uid = (uid_t)-1; > > + if (fflags != NULL && !dounpriv) { > + if (strtofflags(&fflags, &fset, NULL)) > + errx(EX_USAGE, "%s: invalid flag", fflags); > + iflags |= SETFLAGS; > + } > + > + if (metafile != NULL) { > + if ((metafp = fopen(metafile, "a")) == NULL) > + warn("open %s", metafile); > + } else > + digesttype = DIGEST_NONE; > + > if (dodir) { > for (; *argv != NULL; ++argv) > install_dir(*argv); > @@ -207,8 +336,21 @@ main(int argc, char *argv[]) > /* NOTREACHED */ > } > > - no_target = stat(to_name = argv[argc - 1], &to_sb); > + to_name = argv[argc - 1]; > + no_target = stat(to_name, &to_sb); > if (!no_target && S_ISDIR(to_sb.st_mode)) { > + if (dolink & LN_SYMBOLIC) { > + if (lstat(to_name, &to_sb) != 0) > + err(EX_OSERR, "%s vanished", to_name); > + if (S_ISLNK(to_sb.st_mode)) { > + if (argc != 2) { > + errno = ENOTDIR; > + err(EX_USAGE, "%s", to_name); > + } > + install(*argv, to_name, fset, iflags); > + exit(EX_OK); > + } > + } > for (; *argv != to_name; ++argv) > install(*argv, to_name, fset, iflags | DIRECTORY); > exit(EX_OK); > @@ -226,7 +368,7 @@ main(int argc, char *argv[]) > usage(); > } > > - if (!no_target) { > + if (!no_target && !dolink) { > if (stat(*argv, &from_sb)) > err(EX_OSERR, "%s", *argv); > if (!S_ISREG(to_sb.st_mode)) { > @@ -243,23 +385,327 @@ main(int argc, char *argv[]) > /* NOTREACHED */ > } > > -static u_long > -numeric_id(const char *name, const char *type) > +static char * > +digest_file(const char *name) > +{ > + > + switch (digesttype) { > + case DIGEST_MD5: > + return (MD5File(name, NULL)); > + case DIGEST_RIPEMD160: > + return (RIPEMD160_File(name, NULL)); > + case DIGEST_SHA1: > + return (SHA1_File(name, NULL)); > + case DIGEST_SHA256: > + return (SHA256_File(name, NULL)); > + case DIGEST_SHA512: > + return (SHA512_File(name, NULL)); > + default: > + return (NULL); > + } > +} > + > +static void > +digest_init(DIGEST_CTX *c) > +{ > + > + switch (digesttype) { > + case DIGEST_NONE: > + break; > + case DIGEST_MD5: > + MD5Init(&(c->MD5)); > + break; > + case DIGEST_RIPEMD160: > + RIPEMD160_Init(&(c->RIPEMD160)); > + break; > + case DIGEST_SHA1: > + SHA1_Init(&(c->SHA1)); > + break; > + case DIGEST_SHA256: > + SHA256_Init(&(c->SHA256)); > + break; > + case DIGEST_SHA512: > + SHA512_Init(&(c->SHA512)); > + break; > + } > +} > + > +static void > +digest_update(DIGEST_CTX *c, const unsigned char *data, size_t len) > +{ > + > + switch (digesttype) { > + case DIGEST_NONE: > + break; > + case DIGEST_MD5: > + MD5Update(&(c->MD5), data, len); > + break; > + case DIGEST_RIPEMD160: > + RIPEMD160_Update(&(c->RIPEMD160), data, len); > + break; > + case DIGEST_SHA1: > + SHA1_Update(&(c->SHA1), data, len); > + break; > + case DIGEST_SHA256: > + SHA256_Update(&(c->SHA256), data, len); > + break; > + case DIGEST_SHA512: > + SHA512_Update(&(c->SHA512), data, len); > + break; > + } > +} > + > +static char * > +digest_end(DIGEST_CTX *c, char *buf) > +{ > + > + switch (digesttype) { > + case DIGEST_MD5: > + return (MD5End(&(c->MD5), buf)); > + case DIGEST_RIPEMD160: > + return (RIPEMD160_End(&(c->RIPEMD160), buf)); > + case DIGEST_SHA1: > + return (SHA1_End(&(c->SHA1), buf)); > + case DIGEST_SHA256: > + return (SHA256_End(&(c->SHA256), buf)); > + case DIGEST_SHA512: > + return (SHA512_End(&(c->SHA512), buf)); > + default: > + return (NULL); > + } > +} > + > +/* > + * parseid -- > + * parse uid or gid from arg into id, returning non-zero if successful > + */ > +static int > +parseid(const char *name, id_t *id) > +{ > + char *ep; > + errno = 0; > + *id = (id_t)strtoul(name, &ep, 10); > + if (errno || *ep != '\0') > + return (0); > + return (1); > +} > + > +/* > + * quiet_mktemp -- > + * mktemp implementation used mkstemp to avoid mktemp warnings. We > + * really do need mktemp semantics here as we will be creating a link. > + */ > +static char * > +quiet_mktemp(char *template) > +{ > + int fd; > + > + if ((fd = mkstemp(template)) == -1) > + return (NULL); > + close (fd); > + if (unlink(template) == -1) > + err(EX_OSERR, "unlink %s", template); > + return (template); > +} > + > +/* > + * do_link -- > + * make a hard link, obeying dorename if set > + * return -1 on failure > + */ > +static int > +do_link(const char *from_name, const char *to_name, > + const struct stat *target_sb) > +{ > + char tmpl[MAXPATHLEN]; > + int ret; > + > + if (safecopy && target_sb != NULL) { > + (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name); > + /* This usage is safe. */ > + if (quiet_mktemp(tmpl) == NULL) > + err(EX_OSERR, "%s: mktemp", tmpl); > + ret = link(from_name, tmpl); > + if (ret == 0) { > + if (target_sb->st_mode & S_IFDIR && rmdir(to_name) == > + -1) { > + unlink(tmpl); > + err(EX_OSERR, "%s", to_name); > + } > + if (target_sb->st_flags & NOCHANGEBITS) > + (void)chflags(to_name, target_sb->st_flags & > + ~NOCHANGEBITS); > + unlink(to_name); > + ret = rename(tmpl, to_name); > + /* > + * If rename has posix semantics, then the temporary > + * file may still exist when from_name and to_name point > + * to the same file, so unlink it unconditionally. > + */ > + (void)unlink(tmpl); > + } > + return (ret); > + } else > + return (link(from_name, to_name)); > +} > + > +/* > + * do_symlink -- > + * Make a symbolic link, obeying dorename if set. Exit on failure. > + */ > +static void > +do_symlink(const char *from_name, const char *to_name, > + const struct stat *target_sb) > +{ > + char tmpl[MAXPATHLEN]; > + > + if (safecopy && target_sb != NULL) { > + (void)snprintf(tmpl, sizeof(tmpl), "%s.inst.XXXXXX", to_name); > + /* This usage is safe. */ > + if (quiet_mktemp(tmpl) == NULL) > + err(EX_OSERR, "%s: mktemp", tmpl); > + > + if (symlink(from_name, tmpl) == -1) > + err(EX_OSERR, "symlink %s -> %s", from_name, tmpl); > + > + if (target_sb->st_mode & S_IFDIR && rmdir(to_name) == -1) { > + (void)unlink(tmpl); > + err(EX_OSERR, "%s", to_name); > + } > + if (target_sb->st_flags & NOCHANGEBITS) > + (void)chflags(to_name, target_sb->st_flags & > + ~NOCHANGEBITS); > + unlink(to_name); > + > + if (rename(tmpl, to_name) == -1) { > + /* Remove temporary link before exiting. */ > + (void)unlink(tmpl); > + err(EX_OSERR, "%s: rename", to_name); > + } > + } else { > + if (symlink(from_name, to_name) == -1) > + err(EX_OSERR, "symlink %s -> %s", from_name, to_name); > + } > +} > + > +/* > + * makelink -- > + * make a link from source to destination > + */ > +static void > +makelink(const char *from_name, const char *to_name, > + const struct stat *target_sb) > { > - u_long val; > - char *ep; > + char src[MAXPATHLEN], dst[MAXPATHLEN], lnk[MAXPATHLEN]; > + struct stat to_sb; > + > + /* Try hard links first. */ > + if (dolink & (LN_HARD|LN_MIXED)) { > + if (do_link(from_name, to_name, target_sb) == -1) { > + if ((dolink & LN_HARD) || errno != EXDEV) > + err(EX_OSERR, "link %s -> %s", from_name, to_name); > + } else { > + if (stat(to_name, &to_sb)) > + err(EX_OSERR, "%s: stat", to_name); > + if (S_ISREG(to_sb.st_mode)) { > + /* > + * XXX: hard links to anything other than > + * plain files are not metalogged > + */ > + int omode; > + const char *oowner, *ogroup; > + char *offlags; > + char *dres; > + > + /* > + * XXX: use underlying perms, unless > + * overridden on command line. > + */ > + omode = mode; > + if (!haveopt_m) > + mode = (to_sb.st_mode & 0777); > + oowner = owner; > + if (!haveopt_o) > + owner = NULL; > + ogroup = group; > + if (!haveopt_g) > + group = NULL; > + offlags = fflags; > + if (!haveopt_f) > + fflags = NULL; > + dres = digest_file(from_name); > + metadata_log(to_name, "file", NULL, NULL, > + dres, to_sb.st_size); > + free(dres); > + mode = omode; > + owner = oowner; > + group = ogroup; > + fflags = offlags; > + } > + return; > + } > + } > + > + /* Symbolic links. */ > + if (dolink & LN_ABSOLUTE) { > + /* Convert source path to absolute. */ > + if (realpath(from_name, src) == NULL) > + err(EX_OSERR, "%s: realpath", from_name); > + do_symlink(src, to_name, target_sb); > + /* XXX: src may point outside of destdir */ > + metadata_log(to_name, "link", NULL, src, NULL, 0); > + return; > + } > + > + if (dolink & LN_RELATIVE) { > + char *cp, *d, *s; > + > + /* Resolve pathnames. */ > + if (realpath(from_name, src) == NULL) > + err(EX_OSERR, "%s: realpath", from_name); > + > + /* > + * The last component of to_name may be a symlink, > + * so use realpath to resolve only the directory. > + */ > + cp = dirname(to_name); > + if (realpath(cp, dst) == NULL) > + err(EX_OSERR, "%s: realpath", cp); > + /* .. and add the last component. */ > + if (strcmp(dst, "/") != 0) { > + if (strlcat(dst, "/", sizeof(dst)) > sizeof(dst)) > + errx(1, "resolved pathname too long"); > + } > + cp = basename(to_name); > + if (strlcat(dst, cp, sizeof(dst)) > sizeof(dst)) > + errx(1, "resolved pathname too long"); > + > + /* Trim common path components. */ > + for (s = src, d = dst; *s == *d; s++, d++) > + continue; > + while (*s != '/') > + s--, d--; > + > + /* Count the number of directories we need to backtrack. */ > + for (++d, lnk[0] = '\0'; *d; d++) > + if (*d == '/') > + (void)strlcat(lnk, "../", sizeof(lnk)); > + > + (void)strlcat(lnk, ++s, sizeof(lnk)); > + > + do_symlink(lnk, to_name, target_sb); > + /* XXX: Link may point outside of destdir. */ > + metadata_log(to_name, "link", NULL, lnk, NULL, 0); > + return; > + } > > /* > - * XXX > - * We know that uid_t's and gid_t's are unsigned longs. > + * If absolute or relative was not specified, try the names the > + * user provided. > */ > - errno = 0; > - val = strtoul(name, &ep, 10); > - if (errno) > - err(EX_NOUSER, "%s", name); > - if (*ep != '\0') > - errx(EX_NOUSER, "unknown %s %s", type, name); > - return (val); > + do_symlink(from_name, to_name, target_sb); > + /* XXX: from_name may point outside of destdir. */ > + metadata_log(to_name, "link", NULL, from_name, NULL, 0); > } > > /* > @@ -274,6 +720,7 @@ install(const char *from_name, const cha > int devnull, files_match, from_fd, serrno, target; > int tempcopy, temp_fd, to_fd; > char backup[MAXPATHLEN], *p, pathbuf[MAXPATHLEN], tempfile[MAXPATHLEN]; > + char *digestresult; > > files_match = 0; > from_fd = -1; > @@ -281,11 +728,13 @@ install(const char *from_name, const cha > > /* If try to install NULL file to a directory, fails. */ > if (flags & DIRECTORY || strcmp(from_name, _PATH_DEVNULL)) { > - if (stat(from_name, &from_sb)) > - err(EX_OSERR, "%s", from_name); > - if (!S_ISREG(from_sb.st_mode)) { > - errno = EFTYPE; > - err(EX_OSERR, "%s", from_name); > + if (!dolink) { > + if (stat(from_name, &from_sb)) > + err(EX_OSERR, "%s", from_name); > + if (!S_ISREG(from_sb.st_mode)) { > + errno = EFTYPE; > + err(EX_OSERR, "%s", from_name); > + } > } > /* Build the target path. */ > if (flags & DIRECTORY) { > @@ -299,7 +748,23 @@ install(const char *from_name, const cha > devnull = 1; > } > > - target = stat(to_name, &to_sb) == 0; > + if (!dolink) > + target = (stat(to_name, &to_sb) == 0); > + else > + target = (lstat(to_name, &to_sb) == 0); > + > + if (dolink) { > + if (target && !safecopy) { > + if (to_sb.st_mode & S_IFDIR && rmdir(to_name) == -1) > + err(EX_OSERR, "%s", to_name); > + if (to_sb.st_flags & NOCHANGEBITS) > + (void)chflags(to_name, > + to_sb.st_flags & ~NOCHANGEBITS); > + unlink(to_name); > + } > + makelink(from_name, to_name, target ? &to_sb : NULL); > + return; > + } > > /* Only install to regular files. */ > if (target && !S_ISREG(to_sb.st_mode)) { > @@ -323,7 +788,7 @@ install(const char *from_name, const cha > else > files_match = !(compare(from_fd, from_name, > (size_t)from_sb.st_size, to_fd, > - to_name, (size_t)to_sb.st_size)); > + to_name, (size_t)to_sb.st_size, &digestresult)); > > /* Close "to" file unless we match. */ > if (!files_match) > @@ -345,8 +810,10 @@ install(const char *from_name, const cha > from_name, to_name); > } > if (!devnull) > - copy(from_fd, from_name, to_fd, > + digestresult = copy(from_fd, from_name, to_fd, > tempcopy ? tempfile : to_name, from_sb.st_size); > + else > + digestresult = NULL; > } > > if (dostrip) { > @@ -380,7 +847,8 @@ install(const char *from_name, const cha > } > > if (compare(temp_fd, tempfile, (size_t)temp_sb.st_size, to_fd, > - to_name, (size_t)to_sb.st_size) == 0) { > + to_name, (size_t)to_sb.st_size, &digestresult) > + == 0) { > /* > * If target has more than one link we need to > * replace it in order to snap the extra links. > @@ -400,6 +868,9 @@ install(const char *from_name, const cha > } > } > > + if (dostrip && (!docompare || !target)) > + digestresult = digest_file(tempfile); > + > /* > > *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** > _______________________________________________ > svn-src-stable-9@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-stable-9 > To unsubscribe, send any mail to "svn-src-stable-9-unsubscribe@freebsd.org" From owner-svn-src-stable-9@FreeBSD.ORG Mon Mar 18 14:22:17 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5CDBE622; Mon, 18 Mar 2013 14:22:17 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 2B89FD9C; Mon, 18 Mar 2013 14:22:17 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 838F5B91A; Mon, 18 Mar 2013 10:22:16 -0400 (EDT) From: John Baldwin To: Jeremy Chadwick Subject: Re: svn commit: r248331 - in stable/9: . usr.bin/xinstall Date: Mon, 18 Mar 2013 09:45:57 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: <201303151519.r2FFJYjS060493@svn.freebsd.org> <20130318024922.GA24535@icarus.home.lan> In-Reply-To: <20130318024922.GA24535@icarus.home.lan> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201303180945.57393.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 18 Mar 2013 10:22:16 -0400 (EDT) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, Brooks Davis , src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Mar 2013 14:22:17 -0000 On Sunday, March 17, 2013 10:49:22 pm Jeremy Chadwick wrote: > Please see PR 177055. This MFC has broken mergmaster for at least a > couple people. The PR should really be rated high priority: > > http://www.freebsd.org/cgi/query-pr.cgi?pr=177055 > > http://lists.freebsd.org/pipermail/freebsd-stable/2013-March/072848.html Probably breaks etcupdate as well. Both of these tools use the host's tools and not the cross-built tools as they just run 'make distribute'. The right fix might be as simple as making those make targets use XMAKE so that if a world is built they use the cross-built tools instead of the host's tools? -- John Baldwin From owner-svn-src-stable-9@FreeBSD.ORG Mon Mar 18 14:41:53 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0EE583E2 for ; Mon, 18 Mar 2013 14:41:53 +0000 (UTC) (envelope-from jdc@koitsu.org) Received: from qmta01.emeryville.ca.mail.comcast.net (qmta01.emeryville.ca.mail.comcast.net [IPv6:2001:558:fe2d:43:76:96:30:16]) by mx1.freebsd.org (Postfix) with ESMTP id E759EEB7 for ; Mon, 18 Mar 2013 14:41:52 +0000 (UTC) Received: from omta24.emeryville.ca.mail.comcast.net ([76.96.30.92]) by qmta01.emeryville.ca.mail.comcast.net with comcast id D0g01l0031zF43QA12hsSx; Mon, 18 Mar 2013 14:41:52 +0000 Received: from koitsu.strangled.net ([67.180.84.87]) by omta24.emeryville.ca.mail.comcast.net with comcast id D2hr1l00i1t3BNj8k2hsME; Mon, 18 Mar 2013 14:41:52 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id C3B0973A1C; Mon, 18 Mar 2013 07:41:51 -0700 (PDT) Date: Mon, 18 Mar 2013 07:41:51 -0700 From: Jeremy Chadwick To: John Baldwin Subject: Re: svn commit: r248331 - in stable/9: . usr.bin/xinstall Message-ID: <20130318144151.GA35755@icarus.home.lan> References: <201303151519.r2FFJYjS060493@svn.freebsd.org> <20130318024922.GA24535@icarus.home.lan> <201303180945.57393.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201303180945.57393.jhb@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20121106; t=1363617712; bh=os6VN61lRzMy2r1uON930M6L3O8wInYTgpn+UzjlTOY=; h=Received:Received:Received:Date:From:To:Subject:Message-ID: MIME-Version:Content-Type; b=WlTgZ17uCDRmTtyqr/MtlYzPZLrhPYi3Chg/h4xxnf8/wZGBFtB/DthqjWscbJzGd 0FRAME5hXgh0XKSMTcQ5jMIYIlz8BpP8I0KQK41JZf+m3wMmKSp3GX/ZBSl4kY0Tus HdVp2xtZqObzzVutI7TFOL+J8ahAn0POLe5ypPlkHawDepp7M949wpW7oja3/+InmG ujsZSPebgj1sWFgUc2Wj7kojKdFekZqsR3OIZ4I3ZQTl0XRt1rYdOzEm87HOgf1MAm e7dH23vwhi7Vi2jTnZfJuyM/ZolSrJdtqkzVMZ/jMdwrzArAFfipspHnJiR23ZYgPg OWZ5CwedYN0uw== Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, Brooks Davis , src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Mar 2013 14:41:53 -0000 On Mon, Mar 18, 2013 at 09:45:57AM -0400, John Baldwin wrote: > On Sunday, March 17, 2013 10:49:22 pm Jeremy Chadwick wrote: > > Please see PR 177055. This MFC has broken mergmaster for at least a > > couple people. The PR should really be rated high priority: > > > > http://www.freebsd.org/cgi/query-pr.cgi?pr=177055 > > > > http://lists.freebsd.org/pipermail/freebsd-stable/2013-March/072848.html > > Probably breaks etcupdate as well. Both of these tools use the host's tools > and not the cross-built tools as they just run 'make distribute'. The right > fix might be as simple as making those make targets use XMAKE so that if a > world is built they use the cross-built tools instead of the host's tools? To me that sounds like the right approach. -- | Jeremy Chadwick jdc@koitsu.org | | UNIX Systems Administrator http://jdc.koitsu.org/ | | Mountain View, CA, US | | Making life hard for others since 1977. PGP 4BD6C0CB | From owner-svn-src-stable-9@FreeBSD.ORG Mon Mar 18 15:27:59 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id A2EA14A1; Mon, 18 Mar 2013 15:27:59 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9494F272; Mon, 18 Mar 2013 15:27:59 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2IFRxpT091824; Mon, 18 Mar 2013 15:27:59 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2IFRx2Z091822; Mon, 18 Mar 2013 15:27:59 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201303181527.r2IFRx2Z091822@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Mon, 18 Mar 2013 15:27:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248468 - stable/9/crypto/openssh X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Mar 2013 15:27:59 -0000 Author: des Date: Mon Mar 18 15:27:59 2013 New Revision: 248468 URL: http://svnweb.freebsd.org/changeset/base/248468 Log: MFH (r248465): revert upstream decommissioning of authorized_keys2 Modified: stable/9/crypto/openssh/sshd_config Directory Properties: stable/9/crypto/openssh/ (props changed) Modified: stable/9/crypto/openssh/sshd_config ============================================================================== --- stable/9/crypto/openssh/sshd_config Mon Mar 18 15:18:55 2013 (r248467) +++ stable/9/crypto/openssh/sshd_config Mon Mar 18 15:27:59 2013 (r248468) @@ -50,8 +50,7 @@ #PubkeyAuthentication yes # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 -# but this is overridden so installations will only check .ssh/authorized_keys -AuthorizedKeysFile .ssh/authorized_keys +#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2 #AuthorizedPrincipalsFile none From owner-svn-src-stable-9@FreeBSD.ORG Mon Mar 18 20:36:26 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 7CB33B11; Mon, 18 Mar 2013 20:36:26 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 568EC91F; Mon, 18 Mar 2013 20:36:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2IKaQR9086331; Mon, 18 Mar 2013 20:36:26 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2IKaQGN086329; Mon, 18 Mar 2013 20:36:26 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201303182036.r2IKaQGN086329@svn.freebsd.org> From: Xin LI Date: Mon, 18 Mar 2013 20:36:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248474 - stable/9/sbin/recoverdisk X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Mar 2013 20:36:26 -0000 Author: delphij Date: Mon Mar 18 20:36:25 2013 New Revision: 248474 URL: http://svnweb.freebsd.org/changeset/base/248474 Log: MFC r248279: Correct type for DIOCGSTRIPESIZE. Without this there would be a stack overflow which will crash the program later. PR: bin/176953 Submitted by: r4721 tormail org Modified: stable/9/sbin/recoverdisk/recoverdisk.c Directory Properties: stable/9/sbin/recoverdisk/ (props changed) Modified: stable/9/sbin/recoverdisk/recoverdisk.c ============================================================================== --- stable/9/sbin/recoverdisk/recoverdisk.c Mon Mar 18 20:22:40 2013 (r248473) +++ stable/9/sbin/recoverdisk/recoverdisk.c Mon Mar 18 20:36:25 2013 (r248474) @@ -156,7 +156,7 @@ main(int argc, char * const argv[]) int error, state; u_char *buf; u_int sectorsize; - u_int stripesize; + off_t stripesize; time_t t1, t2; struct stat sb; u_int n, snapshot = 60; From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 19 11:07:12 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B0B7CB34; Tue, 19 Mar 2013 11:07:12 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 8A8C3A33; Tue, 19 Mar 2013 11:07:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2JB7CUQ051859; Tue, 19 Mar 2013 11:07:12 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2JB7C5V051858; Tue, 19 Mar 2013 11:07:12 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201303191107.r2JB7C5V051858@svn.freebsd.org> From: Sean Bruno Date: Tue, 19 Mar 2013 11:07:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248494 - stable/9/sys/dev/ciss X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2013 11:07:12 -0000 Author: sbruno Date: Tue Mar 19 11:07:12 2013 New Revision: 248494 URL: http://svnweb.freebsd.org/changeset/base/248494 Log: MFC r247279 The 5300 series ciss(4) board does not work in performant mode with our currnet initialization sequence. Set it to simple mode only so that systems can be updated from stable/7 to newer installations. At some point, we should figure out why we cannot initialize performant mode on this board. PR: kern/153361 Reviewed by: scottl Obtained from: Yahoo! Inc. Modified: stable/9/sys/dev/ciss/ciss.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/dev/ (props changed) Modified: stable/9/sys/dev/ciss/ciss.c ============================================================================== --- stable/9/sys/dev/ciss/ciss.c Tue Mar 19 07:47:51 2013 (r248493) +++ stable/9/sys/dev/ciss/ciss.c Tue Mar 19 11:07:12 2013 (r248494) @@ -281,6 +281,7 @@ TUNABLE_INT("hw.ciss.force_interrupt", & #define CISS_BOARD_SA5 1 #define CISS_BOARD_SA5B 2 #define CISS_BOARD_NOMSI (1<<4) +#define CISS_BOARD_SIMPLE (1<<5) static struct { @@ -289,7 +290,8 @@ static struct int flags; char *desc; } ciss_vendor_data[] = { - { 0x0e11, 0x4070, CISS_BOARD_SA5|CISS_BOARD_NOMSI, "Compaq Smart Array 5300" }, + { 0x0e11, 0x4070, CISS_BOARD_SA5|CISS_BOARD_NOMSI|CISS_BOARD_SIMPLE, + "Compaq Smart Array 5300" }, { 0x0e11, 0x4080, CISS_BOARD_SA5B|CISS_BOARD_NOMSI, "Compaq Smart Array 5i" }, { 0x0e11, 0x4082, CISS_BOARD_SA5B|CISS_BOARD_NOMSI, "Compaq Smart Array 532" }, { 0x0e11, 0x4083, CISS_BOARD_SA5B|CISS_BOARD_NOMSI, "HP Smart Array 5312" }, @@ -681,8 +683,15 @@ ciss_init_pci(struct ciss_softc *sc) supported_methods = CISS_TRANSPORT_METHOD_PERF; break; default: - supported_methods = sc->ciss_cfg->supported_methods; - break; + /* + * Override the capabilities of the BOARD and specify SIMPLE + * MODE + */ + if (ciss_vendor_data[i].flags & CISS_BOARD_SIMPLE) + supported_methods = CISS_TRANSPORT_METHOD_SIMPLE; + else + supported_methods = sc->ciss_cfg->supported_methods; + break; } setup: From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 19 12:42:14 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D968A53B; Tue, 19 Mar 2013 12:42:14 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id CB321FCF; Tue, 19 Mar 2013 12:42:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2JCgEqV081438; Tue, 19 Mar 2013 12:42:14 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2JCgEWi081436; Tue, 19 Mar 2013 12:42:14 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201303191242.r2JCgEWi081436@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Tue, 19 Mar 2013 12:42:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248497 - stable/9/sys/netpfil/ipfw X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2013 12:42:14 -0000 Author: melifaro Date: Tue Mar 19 12:42:14 2013 New Revision: 248497 URL: http://svnweb.freebsd.org/changeset/base/248497 Log: MFC r247626. Fix callout expiring dynamic rules. PR: kern/175530 Submitted by: Vladimir Spiridenkov Modified: stable/9/sys/netpfil/ipfw/ip_fw_dynamic.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netpfil/ipfw/ip_fw_dynamic.c ============================================================================== --- stable/9/sys/netpfil/ipfw/ip_fw_dynamic.c Tue Mar 19 12:35:33 2013 (r248496) +++ stable/9/sys/netpfil/ipfw/ip_fw_dynamic.c Tue Mar 19 12:42:14 2013 (r248497) @@ -982,8 +982,8 @@ ipfw_dyn_tick(void * vnetx) chain = &V_layer3_chain; - /* Run keepalive checks every keepalive_interval iff ka is enabled */ - if ((V_dyn_keepalive_last + V_dyn_keepalive_interval >= time_uptime) && + /* Run keepalive checks every keepalive_period iff ka is enabled */ + if ((V_dyn_keepalive_last + V_dyn_keepalive_period <= time_uptime) && (V_dyn_keepalive != 0)) { V_dyn_keepalive_last = time_uptime; check_ka = 1; @@ -1322,7 +1322,7 @@ ipfw_dyn_init(struct ip_fw_chain *chain) V_dyn_keepalive_interval = 20; V_dyn_keepalive_period = 5; V_dyn_keepalive = 1; /* do send keepalives */ - V_dyn_keepalive = time_uptime; + V_dyn_keepalive_last = time_uptime; V_dyn_max = 4096; /* max # of dynamic rules */ From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 19 13:29:02 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 358A7197; Tue, 19 Mar 2013 13:29:02 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 25E5C619; Tue, 19 Mar 2013 13:29:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2JDT2YA098125; Tue, 19 Mar 2013 13:29:02 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2JDT1aE098122; Tue, 19 Mar 2013 13:29:01 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201303191329.r2JDT1aE098122@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Tue, 19 Mar 2013 13:29:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248505 - stable/9/sbin/ipfw X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2013 13:29:02 -0000 Author: melifaro Date: Tue Mar 19 13:29:01 2013 New Revision: 248505 URL: http://svnweb.freebsd.org/changeset/base/248505 Log: Merge r247666, r247712, r247811. Fix ipfw table argument parsing/printing. Fix style. PR: kern/175909 Submitted by: Daniel Hagerty Implement buffer size checking in ipfw(8) add cmd. PR: bin/65961 Submitted by: Eugene Grosbein Do not suddenly fail on some rulesets if -n (syntax check only) is specified and ipfw(4) module is not loaded. Modified: stable/9/sbin/ipfw/ipfw2.c stable/9/sbin/ipfw/ipfw2.h stable/9/sbin/ipfw/ipv6.c Directory Properties: stable/9/sbin/ (props changed) stable/9/sbin/ipfw/ (props changed) Modified: stable/9/sbin/ipfw/ipfw2.c ============================================================================== --- stable/9/sbin/ipfw/ipfw2.c Tue Mar 19 13:21:39 2013 (r248504) +++ stable/9/sbin/ipfw/ipfw2.c Tue Mar 19 13:29:01 2013 (r248505) @@ -64,6 +64,22 @@ int ipfw_socket = -1; #define s6_addr32 __u6_addr.__u6_addr32 #endif +#define CHECK_LENGTH(v, len) do { \ + if ((v) < (len)) \ + errx(EX_DATAERR, "Rule too long"); \ + } while (0) +/* + * Check if we have enough space in cmd buffer. Note that since + * first 8? u32 words are reserved by reserved header, full cmd + * buffer can't be used, so we need to protect from buffer overrun + * only. At the beginnig, cblen is less than actual buffer size by + * size of ipfw_insn_u32 instruction + 1 u32 work. This eliminates need + * for checking small instructions fitting in given range. + * We also (ab)use the fact that ipfw_insn is always the first field + * for any custom instruction. + */ +#define CHECK_CMDLEN CHECK_LENGTH(cblen, F_LEN((ipfw_insn *)cmd)) + #define GET_UINT_ARG(arg, min, max, tok, s_x) do { \ if (!av[0]) \ errx(EX_USAGE, "%s: missing argument", match_value(s_x, tok)); \ @@ -653,7 +669,7 @@ strtoport(char *s, char **end, int base, * Fill the body of the command with the list of port ranges. */ static int -fill_newports(ipfw_insn_u16 *cmd, char *av, int proto) +fill_newports(ipfw_insn_u16 *cmd, char *av, int proto, int cblen) { uint16_t a, b, *p = cmd->ports; int i = 0; @@ -664,6 +680,8 @@ fill_newports(ipfw_insn_u16 *cmd, char * if (s == av) /* empty or invalid argument */ return (0); + CHECK_LENGTH(cblen, i + 2); + switch (*s) { case '-': /* a range */ av = s + 1; @@ -2067,7 +2085,7 @@ lookup_host (char *host, struct in_addr * We can have multiple comma-separated address/mask entries. */ static void -fill_ip(ipfw_insn_ip *cmd, char *av) +fill_ip(ipfw_insn_ip *cmd, char *av, int cblen) { int len = 0; uint32_t *d = ((ipfw_insn_u32 *)cmd)->d; @@ -2107,6 +2125,8 @@ fill_ip(ipfw_insn_ip *cmd, char *av) int masklen; char md, nd = '\0'; + CHECK_LENGTH(cblen, F_INSN_SIZE(ipfw_insn) + 2 + len); + if (p) { md = *p; *p++ = '\0'; @@ -2365,11 +2385,13 @@ ipfw_delete(char *av[]) * patterns which match interfaces. */ static void -fill_iface(ipfw_insn_if *cmd, char *arg) +fill_iface(ipfw_insn_if *cmd, char *arg, int cblen) { cmd->name[0] = '\0'; cmd->o.len |= F_INSN_SIZE(ipfw_insn_if); + CHECK_CMDLEN; + /* Parse the interface or address */ if (strcmp(arg, "any") == 0) cmd->o.len = 0; /* effectively ignore this command */ @@ -2440,8 +2462,10 @@ get_mac_addr_mask(const char *p, uint8_t * the new command in case it has been clobbered before. */ static ipfw_insn * -next_cmd(ipfw_insn *cmd) +next_cmd(ipfw_insn *cmd, int *len) { + *len -= F_LEN(cmd); + CHECK_LENGTH(*len, 0); cmd += F_LEN(cmd); bzero(cmd, sizeof(*cmd)); return cmd; @@ -2451,7 +2475,7 @@ next_cmd(ipfw_insn *cmd) * Takes arguments and copies them into a comment */ static void -fill_comment(ipfw_insn *cmd, char **av) +fill_comment(ipfw_insn *cmd, char **av, int cblen) { int i, l; char *p = (char *)(cmd + 1); @@ -2469,6 +2493,8 @@ fill_comment(ipfw_insn *cmd, char **av) "comment too long (max 80 chars)"); l = 1 + (l+3)/4; cmd->len = (cmd->len & (F_NOT | F_OR)) | l; + CHECK_CMDLEN; + for (i = 0; av[i] != NULL; i++) { strcpy(p, av[i]); p += strlen(av[i]); @@ -2494,7 +2520,7 @@ fill_cmd(ipfw_insn *cmd, enum ipfw_opcod * two microinstructions, and returns the pointer to the last one. */ static ipfw_insn * -add_mac(ipfw_insn *cmd, char *av[]) +add_mac(ipfw_insn *cmd, char *av[], int cblen) { ipfw_insn_mac *mac; @@ -2503,6 +2529,7 @@ add_mac(ipfw_insn *cmd, char *av[]) cmd->opcode = O_MACADDR2; cmd->len = (cmd->len & (F_NOT | F_OR)) | F_INSN_SIZE(ipfw_insn_mac); + CHECK_CMDLEN; mac = (ipfw_insn_mac *)cmd; get_mac_addr_mask(av[0], mac->addr, mac->mask); /* dst */ @@ -2512,12 +2539,13 @@ add_mac(ipfw_insn *cmd, char *av[]) } static ipfw_insn * -add_mactype(ipfw_insn *cmd, char *av) +add_mactype(ipfw_insn *cmd, char *av, int cblen) { if (!av) errx(EX_DATAERR, "missing MAC type"); if (strcmp(av, "any") != 0) { /* we have a non-null type */ - fill_newports((ipfw_insn_u16 *)cmd, av, IPPROTO_ETHERTYPE); + fill_newports((ipfw_insn_u16 *)cmd, av, IPPROTO_ETHERTYPE, + cblen); cmd->opcode = O_MAC_TYPE; return cmd; } else @@ -2586,9 +2614,9 @@ add_proto_compat(ipfw_insn *cmd, char *a } static ipfw_insn * -add_srcip(ipfw_insn *cmd, char *av) +add_srcip(ipfw_insn *cmd, char *av, int cblen) { - fill_ip((ipfw_insn_ip *)cmd, av); + fill_ip((ipfw_insn_ip *)cmd, av, cblen); if (cmd->opcode == O_IP_DST_SET) /* set */ cmd->opcode = O_IP_SRC_SET; else if (cmd->opcode == O_IP_DST_LOOKUP) /* table */ @@ -2603,9 +2631,9 @@ add_srcip(ipfw_insn *cmd, char *av) } static ipfw_insn * -add_dstip(ipfw_insn *cmd, char *av) +add_dstip(ipfw_insn *cmd, char *av, int cblen) { - fill_ip((ipfw_insn_ip *)cmd, av); + fill_ip((ipfw_insn_ip *)cmd, av, cblen); if (cmd->opcode == O_IP_DST_SET) /* set */ ; else if (cmd->opcode == O_IP_DST_LOOKUP) /* table */ @@ -2620,12 +2648,12 @@ add_dstip(ipfw_insn *cmd, char *av) } static ipfw_insn * -add_ports(ipfw_insn *cmd, char *av, u_char proto, int opcode) +add_ports(ipfw_insn *cmd, char *av, u_char proto, int opcode, int cblen) { /* XXX "any" is trapped before. Perhaps "to" */ if (_substrcmp(av, "any") == 0) { return NULL; - } else if (fill_newports((ipfw_insn_u16 *)cmd, av, proto)) { + } else if (fill_newports((ipfw_insn_u16 *)cmd, av, proto, cblen)) { /* XXX todo: check that we have a protocol with ports */ cmd->opcode = opcode; return cmd; @@ -2634,7 +2662,7 @@ add_ports(ipfw_insn *cmd, char *av, u_ch } static ipfw_insn * -add_src(ipfw_insn *cmd, char *av, u_char proto) +add_src(ipfw_insn *cmd, char *av, u_char proto, int cblen) { struct in6_addr a; char *host, *ch; @@ -2647,11 +2675,11 @@ add_src(ipfw_insn *cmd, char *av, u_char if (proto == IPPROTO_IPV6 || strcmp(av, "me6") == 0 || inet_pton(AF_INET6, host, &a) == 1) - ret = add_srcip6(cmd, av); + ret = add_srcip6(cmd, av, cblen); /* XXX: should check for IPv4, not !IPv6 */ if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 || inet_pton(AF_INET6, host, &a) != 1)) - ret = add_srcip(cmd, av); + ret = add_srcip(cmd, av, cblen); if (ret == NULL && strcmp(av, "any") != 0) ret = cmd; @@ -2660,7 +2688,7 @@ add_src(ipfw_insn *cmd, char *av, u_char } static ipfw_insn * -add_dst(ipfw_insn *cmd, char *av, u_char proto) +add_dst(ipfw_insn *cmd, char *av, u_char proto, int cblen) { struct in6_addr a; char *host, *ch; @@ -2673,11 +2701,11 @@ add_dst(ipfw_insn *cmd, char *av, u_char if (proto == IPPROTO_IPV6 || strcmp(av, "me6") == 0 || inet_pton(AF_INET6, host, &a) == 1) - ret = add_dstip6(cmd, av); + ret = add_dstip6(cmd, av, cblen); /* XXX: should check for IPv4, not !IPv6 */ if (ret == NULL && (proto == IPPROTO_IP || strcmp(av, "me") == 0 || inet_pton(AF_INET6, host, &a) != 1)) - ret = add_dstip(cmd, av); + ret = add_dstip(cmd, av, cblen); if (ret == NULL && strcmp(av, "any") != 0) ret = cmd; @@ -2707,6 +2735,7 @@ ipfw_add(char *av[]) * go into actbuf[]. */ static uint32_t rulebuf[255], actbuf[255], cmdbuf[255]; + int rblen, ablen, cblen; ipfw_insn *src, *dst, *cmd, *action, *prev=NULL; ipfw_insn *first_cmd; /* first match pattern */ @@ -2737,6 +2766,15 @@ ipfw_add(char *av[]) cmd = (ipfw_insn *)cmdbuf; action = (ipfw_insn *)actbuf; + rblen = sizeof(rulebuf) / sizeof(rulebuf[0]); + rblen -= offsetof(struct ip_fw, cmd) / sizeof(rulebuf[0]); + ablen = sizeof(actbuf) / sizeof(actbuf[0]); + cblen = sizeof(cmdbuf) / sizeof(cmdbuf[0]); + cblen -= F_INSN_SIZE(ipfw_insn_u32) + 1; + +#define CHECK_RBUFLEN(len) { CHECK_LENGTH(rblen, len); rblen -= len; } +#define CHECK_ACTLEN CHECK_LENGTH(ablen, action->len) + av++; /* [rule N] -- Rule number optional */ @@ -2768,6 +2806,7 @@ ipfw_add(char *av[]) i = match_token(rule_actions, *av); av++; action->len = 1; /* default */ + CHECK_ACTLEN; switch(i) { case TOK_CHECKSTATE: have_state = action; @@ -2819,6 +2858,7 @@ ipfw_add(char *av[]) case TOK_NAT: action->opcode = O_NAT; action->len = F_INSN_SIZE(ipfw_insn_nat); + CHECK_ACTLEN; if (_substrcmp(*av, "global") == 0) { action->arg1 = 0; av++; @@ -2935,6 +2975,7 @@ chkarg: action->opcode = O_FORWARD_IP; action->len = F_INSN_SIZE(ipfw_insn_sa); + CHECK_ACTLEN; /* * In the kernel we assume AF_INET and use only @@ -2951,6 +2992,7 @@ chkarg: action->opcode = O_FORWARD_IP6; action->len = F_INSN_SIZE(ipfw_insn_sa6); + CHECK_ACTLEN; p->sa.sin6_len = sizeof(struct sockaddr_in6); p->sa.sin6_family = AF_INET6; @@ -3004,7 +3046,7 @@ chkarg: default: errx(EX_DATAERR, "invalid action %s\n", av[-1]); } - action = next_cmd(action); + action = next_cmd(action, &ablen); /* * [altq queuename] -- altq tag, optional @@ -3026,6 +3068,7 @@ chkarg: "log cannot be specified more than once"); have_log = (ipfw_insn *)c; cmd->len = F_INSN_SIZE(ipfw_insn_log); + CHECK_CMDLEN; cmd->opcode = O_LOG; if (av[0] && _substrcmp(*av, "logamount") == 0) { av++; @@ -3039,9 +3082,14 @@ chkarg: } else { len = sizeof(c->max_log); if (sysctlbyname("net.inet.ip.fw.verbose_limit", - &c->max_log, &len, NULL, 0) == -1) + &c->max_log, &len, NULL, 0) == -1) { + if (co.test_only) { + c->max_log = 0; + break; + } errx(1, "sysctlbyname(\"%s\")", "net.inet.ip.fw.verbose_limit"); + } } } break; @@ -3057,6 +3105,7 @@ chkarg: "altq cannot be specified more than once"); have_altq = (ipfw_insn *)a; cmd->len = F_INSN_SIZE(ipfw_insn_altq); + CHECK_CMDLEN; cmd->opcode = O_ALTQ; a->qid = altq_name_to_qid(*av); av++; @@ -3082,7 +3131,7 @@ chkarg: default: abort(); } - cmd = next_cmd(cmd); + cmd = next_cmd(cmd, &cblen); } if (have_state) /* must be a check-state, we are done */ @@ -3167,7 +3216,7 @@ chkarg: av++; if (F_LEN(cmd) != 0) { prev = cmd; - cmd = next_cmd(cmd); + cmd = next_cmd(cmd, &cblen); } } else if (first_cmd != cmd) { errx(EX_DATAERR, "invalid protocol ``%s''", *av); @@ -3188,11 +3237,11 @@ chkarg: OR_START(source_ip); NOT_BLOCK; /* optional "not" */ NEED1("missing source address"); - if (add_src(cmd, *av, proto)) { + if (add_src(cmd, *av, proto, cblen)) { av++; if (F_LEN(cmd) != 0) { /* ! any */ prev = cmd; - cmd = next_cmd(cmd); + cmd = next_cmd(cmd, &cblen); } } else errx(EX_USAGE, "bad source address %s", *av); @@ -3204,10 +3253,10 @@ chkarg: NOT_BLOCK; /* optional "not" */ if ( av[0] != NULL ) { if (_substrcmp(*av, "any") == 0 || - add_ports(cmd, *av, proto, O_IP_SRCPORT)) { + add_ports(cmd, *av, proto, O_IP_SRCPORT, cblen)) { av++; if (F_LEN(cmd) != 0) - cmd = next_cmd(cmd); + cmd = next_cmd(cmd, &cblen); } } @@ -3224,11 +3273,11 @@ chkarg: OR_START(dest_ip); NOT_BLOCK; /* optional "not" */ NEED1("missing dst address"); - if (add_dst(cmd, *av, proto)) { + if (add_dst(cmd, *av, proto, cblen)) { av++; if (F_LEN(cmd) != 0) { /* ! any */ prev = cmd; - cmd = next_cmd(cmd); + cmd = next_cmd(cmd, &cblen); } } else errx( EX_USAGE, "bad destination address %s", *av); @@ -3240,10 +3289,10 @@ chkarg: NOT_BLOCK; /* optional "not" */ if (av[0]) { if (_substrcmp(*av, "any") == 0 || - add_ports(cmd, *av, proto, O_IP_DSTPORT)) { + add_ports(cmd, *av, proto, O_IP_DSTPORT, cblen)) { av++; if (F_LEN(cmd) != 0) - cmd = next_cmd(cmd); + cmd = next_cmd(cmd, &cblen); } } @@ -3331,7 +3380,7 @@ read_options: case TOK_VIA: NEED1("recv, xmit, via require interface name" " or address"); - fill_iface((ipfw_insn_if *)cmd, av[0]); + fill_iface((ipfw_insn_if *)cmd, av[0], cblen); av++; if (F_LEN(cmd) == 0) /* not a valid address */ break; @@ -3351,14 +3400,14 @@ read_options: case TOK_ICMP6TYPES: NEED1("icmptypes requires list of types"); - fill_icmp6types((ipfw_insn_icmp6 *)cmd, *av); + fill_icmp6types((ipfw_insn_icmp6 *)cmd, *av, cblen); av++; break; case TOK_IPTTL: NEED1("ipttl requires TTL"); if (strpbrk(*av, "-,")) { - if (!add_ports(cmd, *av, 0, O_IPTTL)) + if (!add_ports(cmd, *av, 0, O_IPTTL, cblen)) errx(EX_DATAERR, "invalid ipttl %s", *av); } else fill_cmd(cmd, O_IPTTL, 0, strtoul(*av, NULL, 0)); @@ -3368,7 +3417,7 @@ read_options: case TOK_IPID: NEED1("ipid requires id"); if (strpbrk(*av, "-,")) { - if (!add_ports(cmd, *av, 0, O_IPID)) + if (!add_ports(cmd, *av, 0, O_IPID, cblen)) errx(EX_DATAERR, "invalid ipid %s", *av); } else fill_cmd(cmd, O_IPID, 0, strtoul(*av, NULL, 0)); @@ -3378,7 +3427,7 @@ read_options: case TOK_IPLEN: NEED1("iplen requires length"); if (strpbrk(*av, "-,")) { - if (!add_ports(cmd, *av, 0, O_IPLEN)) + if (!add_ports(cmd, *av, 0, O_IPLEN, cblen)) errx(EX_DATAERR, "invalid ip len %s", *av); } else fill_cmd(cmd, O_IPLEN, 0, strtoul(*av, NULL, 0)); @@ -3474,7 +3523,7 @@ read_options: case TOK_TCPDATALEN: NEED1("tcpdatalen requires length"); if (strpbrk(*av, "-,")) { - if (!add_ports(cmd, *av, 0, O_TCPDATALEN)) + if (!add_ports(cmd, *av, 0, O_TCPDATALEN, cblen)) errx(EX_DATAERR, "invalid tcpdata len %s", *av); } else fill_cmd(cmd, O_TCPDATALEN, 0, @@ -3500,7 +3549,7 @@ read_options: case TOK_TCPWIN: NEED1("tcpwin requires length"); if (strpbrk(*av, "-,")) { - if (!add_ports(cmd, *av, 0, O_TCPWIN)) + if (!add_ports(cmd, *av, 0, O_TCPWIN, cblen)) errx(EX_DATAERR, "invalid tcpwin len %s", *av); } else fill_cmd(cmd, O_TCPWIN, 0, @@ -3539,6 +3588,7 @@ read_options: have_state = cmd; cmd->len = F_INSN_SIZE(ipfw_insn_limit); + CHECK_CMDLEN; cmd->opcode = O_LIMIT; c->limit_mask = c->conn_limit = 0; @@ -3570,28 +3620,28 @@ read_options: case TOK_SRCIP: NEED1("missing source IP"); - if (add_srcip(cmd, *av)) { + if (add_srcip(cmd, *av, cblen)) { av++; } break; case TOK_DSTIP: NEED1("missing destination IP"); - if (add_dstip(cmd, *av)) { + if (add_dstip(cmd, *av, cblen)) { av++; } break; case TOK_SRCIP6: NEED1("missing source IP6"); - if (add_srcip6(cmd, *av)) { + if (add_srcip6(cmd, *av, cblen)) { av++; } break; case TOK_DSTIP6: NEED1("missing destination IP6"); - if (add_dstip6(cmd, *av)) { + if (add_dstip6(cmd, *av, cblen)) { av++; } break; @@ -3599,7 +3649,7 @@ read_options: case TOK_SRCPORT: NEED1("missing source port"); if (_substrcmp(*av, "any") == 0 || - add_ports(cmd, *av, proto, O_IP_SRCPORT)) { + add_ports(cmd, *av, proto, O_IP_SRCPORT, cblen)) { av++; } else errx(EX_DATAERR, "invalid source port %s", *av); @@ -3608,7 +3658,7 @@ read_options: case TOK_DSTPORT: NEED1("missing destination port"); if (_substrcmp(*av, "any") == 0 || - add_ports(cmd, *av, proto, O_IP_DSTPORT)) { + add_ports(cmd, *av, proto, O_IP_DSTPORT, cblen)) { av++; } else errx(EX_DATAERR, "invalid destination port %s", @@ -3616,13 +3666,13 @@ read_options: break; case TOK_MAC: - if (add_mac(cmd, av)) + if (add_mac(cmd, av, cblen)) av += 2; break; case TOK_MACTYPE: NEED1("missing mac type"); - if (!add_mactype(cmd, *av)) + if (!add_mactype(cmd, *av, cblen)) errx(EX_DATAERR, "invalid mac type %s", *av); av++; break; @@ -3660,18 +3710,18 @@ read_options: if (proto != IPPROTO_IPV6 ) errx( EX_USAGE, "flow-id filter is active " "only for ipv6 protocol\n"); - fill_flow6( (ipfw_insn_u32 *) cmd, *av ); + fill_flow6( (ipfw_insn_u32 *) cmd, *av, cblen); av++; break; case TOK_COMMENT: - fill_comment(cmd, av); + fill_comment(cmd, av, cblen); av[0]=NULL; break; case TOK_TAGGED: if (av[0] && strpbrk(*av, "-,")) { - if (!add_ports(cmd, *av, 0, O_TAGGED)) + if (!add_ports(cmd, *av, 0, O_TAGGED, cblen)) errx(EX_DATAERR, "tagged: invalid tag" " list: %s", *av); } @@ -3724,7 +3774,7 @@ read_options: } if (F_LEN(cmd) > 0) { /* prepare to advance */ prev = cmd; - cmd = next_cmd(cmd); + cmd = next_cmd(cmd, &cblen); } } @@ -3753,12 +3803,13 @@ done: */ if (have_state && have_state->opcode != O_CHECK_STATE) { fill_cmd(dst, O_PROBE_STATE, 0, 0); - dst = next_cmd(dst); + dst = next_cmd(dst, &rblen); } /* copy all commands but O_LOG, O_KEEP_STATE, O_LIMIT, O_ALTQ, O_TAG */ for (src = (ipfw_insn *)cmdbuf; src != cmd; src += i) { i = F_LEN(src); + CHECK_RBUFLEN(i); switch (src->opcode) { case O_LOG: @@ -3778,6 +3829,7 @@ done: */ if (have_state && have_state->opcode != O_CHECK_STATE) { i = F_LEN(have_state); + CHECK_RBUFLEN(i); bcopy(have_state, dst, i * sizeof(uint32_t)); dst += i; } @@ -3789,24 +3841,29 @@ done: /* put back O_LOG, O_ALTQ, O_TAG if necessary */ if (have_log) { i = F_LEN(have_log); + CHECK_RBUFLEN(i); bcopy(have_log, dst, i * sizeof(uint32_t)); dst += i; } if (have_altq) { i = F_LEN(have_altq); + CHECK_RBUFLEN(i); bcopy(have_altq, dst, i * sizeof(uint32_t)); dst += i; } if (have_tag) { i = F_LEN(have_tag); + CHECK_RBUFLEN(i); bcopy(have_tag, dst, i * sizeof(uint32_t)); dst += i; } + /* * copy all other actions */ for (src = (ipfw_insn *)actbuf; src != action; src += i) { i = F_LEN(src); + CHECK_RBUFLEN(i); bcopy(src, dst, i * sizeof(uint32_t)); dst += i; } @@ -3911,6 +3968,7 @@ ipfw_flush(int force) static void table_list(uint16_t num, int need_header); +static void table_fill_xentry(char *arg, ipfw_table_xentry *xent); /* * This one handles all table-related commands @@ -3926,15 +3984,18 @@ ipfw_table_handler(int ac, char *av[]) int do_add; int is_all; size_t len; - char *p; - uint32_t a, type, mask, addrlen; + uint32_t a; uint32_t tables_max; len = sizeof(tables_max); if (sysctlbyname("net.inet.ip.fw.tables_max", &tables_max, &len, - NULL, 0) == -1) - errx(1, "Can't determine maximum number of ipfw tables. " - "Perhaps you forgot to load ipfw module?"); + NULL, 0) == -1) { + if (co.test_only) + tables_max = 128; /* Old conservative default */ + else + errx(1, "Can't determine maximum number of ipfw tables." + " Perhaps you forgot to load ipfw module?"); + } memset(&xent, 0, sizeof(xent)); @@ -3963,57 +4024,8 @@ ipfw_table_handler(int ac, char *av[]) ac--; av++; if (!ac) errx(EX_USAGE, "address required"); - /* - * Let's try to guess type by agrument. - * Possible types: - * 1) IPv4[/mask] - * 2) IPv6[/mask] - * 3) interface name - * 4) port ? - */ - type = 0; - if (ishexnumber(*av[0])) { - /* Remove / if exists */ - if ((p = strchr(*av, '/')) != NULL) { - *p = '\0'; - mask = atoi(p + 1); - } - - if (inet_pton(AF_INET, *av, &xent.k.addr6) == 1) { - type = IPFW_TABLE_CIDR; - if ((p != NULL) && (mask > 32)) - errx(EX_DATAERR, "bad IPv4 mask width: %s", p + 1); - xent.masklen = p ? mask : 32; - addrlen = sizeof(struct in_addr); - } else if (inet_pton(AF_INET6, *av, &xent.k.addr6) == 1) { - type = IPFW_TABLE_CIDR; - if ((p != NULL) && (mask > 128)) - errx(EX_DATAERR, "bad IPv6 mask width: %s", p + 1); - xent.masklen = p ? mask : 128; - addrlen = sizeof(struct in6_addr); - } - } - if ((type == 0) && (strchr(*av, '.') == NULL)) { - /* Assume interface name. Copy significant data only */ - mask = MIN(strlen(*av), IF_NAMESIZE - 1); - memcpy(xent.k.iface, *av, mask); - /* Set mask to exact match */ - xent.masklen = 8 * IF_NAMESIZE; - type = IPFW_TABLE_INTERFACE; - addrlen = IF_NAMESIZE; - } - - if (type == 0) { - if (lookup_host(*av, (struct in_addr *)&xent.k.addr6) != 0) - errx(EX_NOHOST, "hostname ``%s'' unknown", *av); - xent.masklen = 32; - type = IPFW_TABLE_CIDR; - addrlen = sizeof(struct in_addr); - } - - xent.type = type; - xent.len = offsetof(ipfw_table_xentry, k) + addrlen; + table_fill_xentry(*av, &xent); ac--; av++; if (do_add && ac) { @@ -4063,6 +4075,93 @@ ipfw_table_handler(int ac, char *av[]) } static void +table_fill_xentry(char *arg, ipfw_table_xentry *xent) +{ + int addrlen, mask, masklen, type; + struct in6_addr *paddr; + uint32_t *pkey; + char *p; + uint32_t key; + + mask = 0; + type = 0; + addrlen = 0; + masklen = 0; + + /* + * Let's try to guess type by agrument. + * Possible types: + * 1) IPv4[/mask] + * 2) IPv6[/mask] + * 3) interface name + * 4) port, uid/gid or other u32 key (base 10 format) + * 5) hostname + */ + paddr = &xent->k.addr6; + if (ishexnumber(*arg) != 0 || *arg == ':') { + /* Remove / if exists */ + if ((p = strchr(arg, '/')) != NULL) { + *p = '\0'; + mask = atoi(p + 1); + } + + if (inet_pton(AF_INET, arg, paddr) == 1) { + if (p != NULL && mask > 32) + errx(EX_DATAERR, "bad IPv4 mask width: %s", + p + 1); + + type = IPFW_TABLE_CIDR; + masklen = p ? mask : 32; + addrlen = sizeof(struct in_addr); + } else if (inet_pton(AF_INET6, arg, paddr) == 1) { + if (IN6_IS_ADDR_V4COMPAT(paddr)) + errx(EX_DATAERR, + "Use IPv4 instead of v4-compatible"); + if (p != NULL && mask > 128) + errx(EX_DATAERR, "bad IPv6 mask width: %s", + p + 1); + + type = IPFW_TABLE_CIDR; + masklen = p ? mask : 128; + addrlen = sizeof(struct in6_addr); + } else { + /* Port or any other key */ + key = strtol(arg, &p, 10); + /* Skip non-base 10 entries like 'fa1' */ + if (p != arg) { + pkey = (uint32_t *)paddr; + *pkey = htonl(key); + type = IPFW_TABLE_CIDR; + addrlen = sizeof(uint32_t); + } + } + } + + if (type == 0 && strchr(arg, '.') == NULL) { + /* Assume interface name. Copy significant data only */ + mask = MIN(strlen(arg), IF_NAMESIZE - 1); + memcpy(xent->k.iface, arg, mask); + /* Set mask to exact match */ + masklen = 8 * IF_NAMESIZE; + type = IPFW_TABLE_INTERFACE; + addrlen = IF_NAMESIZE; + } + + if (type == 0) { + if (lookup_host(arg, (struct in_addr *)paddr) != 0) + errx(EX_NOHOST, "hostname ``%s'' unknown", arg); + + masklen = 32; + type = IPFW_TABLE_CIDR; + addrlen = sizeof(struct in_addr); + } + + xent->type = type; + xent->masklen = masklen; + xent->len = offsetof(ipfw_table_xentry, k) + addrlen; +} + +static void table_list(uint16_t num, int need_header) { ipfw_xtable *tbl; @@ -4105,8 +4204,8 @@ table_list(uint16_t num, int need_header tval = xent->value; addr6 = &xent->k.addr6; - if ((addr6->s6_addr32[0] == 0) && (addr6->s6_addr32[1] == 0) && - (addr6->s6_addr32[2] == 0)) { + + if (IN6_IS_ADDR_V4COMPAT(addr6)) { /* IPv4 address */ inet_ntop(AF_INET, &addr6->s6_addr32[3], tbuf, sizeof(tbuf)); } else { Modified: stable/9/sbin/ipfw/ipfw2.h ============================================================================== --- stable/9/sbin/ipfw/ipfw2.h Tue Mar 19 13:21:39 2013 (r248504) +++ stable/9/sbin/ipfw/ipfw2.h Tue Mar 19 13:29:01 2013 (r248505) @@ -283,10 +283,10 @@ void print_flow6id(struct _ipfw_insn_u32 void print_icmp6types(struct _ipfw_insn_u32 *cmd); void print_ext6hdr(struct _ipfw_insn *cmd ); -struct _ipfw_insn *add_srcip6(struct _ipfw_insn *cmd, char *av); -struct _ipfw_insn *add_dstip6(struct _ipfw_insn *cmd, char *av); +struct _ipfw_insn *add_srcip6(struct _ipfw_insn *cmd, char *av, int cblen); +struct _ipfw_insn *add_dstip6(struct _ipfw_insn *cmd, char *av, int cblen); -void fill_flow6(struct _ipfw_insn_u32 *cmd, char *av ); +void fill_flow6(struct _ipfw_insn_u32 *cmd, char *av, int cblen); void fill_unreach6_code(u_short *codep, char *str); -void fill_icmp6types(struct _ipfw_insn_icmp6 *cmd, char *av); +void fill_icmp6types(struct _ipfw_insn_icmp6 *cmd, char *av, int cblen); int fill_ext6hdr(struct _ipfw_insn *cmd, char *av); Modified: stable/9/sbin/ipfw/ipv6.c ============================================================================== --- stable/9/sbin/ipfw/ipv6.c Tue Mar 19 13:21:39 2013 (r248504) +++ stable/9/sbin/ipfw/ipv6.c Tue Mar 19 13:29:01 2013 (r248505) @@ -42,6 +42,11 @@ #include #include +#define CHECK_LENGTH(v, len) do { \ + if ((v) < (len)) \ + errx(EX_DATAERR, "Rule too long"); \ + } while (0) + static struct _s_x icmp6codes[] = { { "no-route", ICMP6_DST_UNREACH_NOROUTE }, { "admin-prohib", ICMP6_DST_UNREACH_ADMIN }, @@ -131,10 +136,12 @@ print_ip6(ipfw_insn_ip6 *cmd, char const } void -fill_icmp6types(ipfw_insn_icmp6 *cmd, char *av) +fill_icmp6types(ipfw_insn_icmp6 *cmd, char *av, int cblen) { uint8_t type; + CHECK_LENGTH(cblen, F_INSN_SIZE(ipfw_insn_icmp6)); + bzero(cmd, sizeof(*cmd)); while (*av) { if (*av == ',') @@ -327,7 +334,7 @@ lookup_host6 (char *host, struct in6_add * Return 1 on success, 0 on failure. */ static int -fill_ip6(ipfw_insn_ip6 *cmd, char *av) +fill_ip6(ipfw_insn_ip6 *cmd, char *av, int cblen) { int len = 0; struct in6_addr *d = &(cmd->addr6); @@ -379,6 +386,8 @@ fill_ip6(ipfw_insn_ip6 *cmd, char *av) int masklen; char md = '\0'; + CHECK_LENGTH(cblen, 1 + len + 2 * F_INSN_SIZE(struct in6_addr)); + if ((p = strpbrk(av, "/,")) ) { md = *p; /* save the separator */ *p = '\0'; /* terminate address string */ @@ -453,7 +462,7 @@ fill_ip6(ipfw_insn_ip6 *cmd, char *av) * additional flow-id we want to filter, the basic is 1 */ void -fill_flow6( ipfw_insn_u32 *cmd, char *av ) +fill_flow6( ipfw_insn_u32 *cmd, char *av, int cblen) { u_int32_t type; /* Current flow number */ u_int16_t nflow = 0; /* Current flow index */ @@ -461,6 +470,8 @@ fill_flow6( ipfw_insn_u32 *cmd, char *av cmd->d[0] = 0; /* Initializing the base number*/ while (s) { + CHECK_LENGTH(cblen, F_INSN_SIZE(ipfw_insn_u32) + nflow + 1); + av = strsep( &s, ",") ; type = strtoul(av, &av, 0); if (*av != ',' && *av != '\0') @@ -481,10 +492,10 @@ fill_flow6( ipfw_insn_u32 *cmd, char *av } ipfw_insn * -add_srcip6(ipfw_insn *cmd, char *av) +add_srcip6(ipfw_insn *cmd, char *av, int cblen) { - fill_ip6((ipfw_insn_ip6 *)cmd, av); + fill_ip6((ipfw_insn_ip6 *)cmd, av, cblen); if (cmd->opcode == O_IP_DST_SET) /* set */ cmd->opcode = O_IP_SRC_SET; else if (cmd->opcode == O_IP_DST_LOOKUP) /* table */ @@ -503,10 +514,10 @@ add_srcip6(ipfw_insn *cmd, char *av) } ipfw_insn * -add_dstip6(ipfw_insn *cmd, char *av) +add_dstip6(ipfw_insn *cmd, char *av, int cblen) { - fill_ip6((ipfw_insn_ip6 *)cmd, av); + fill_ip6((ipfw_insn_ip6 *)cmd, av, cblen); if (cmd->opcode == O_IP_DST_SET) /* set */ ; else if (cmd->opcode == O_IP_DST_LOOKUP) /* table */ From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 19 13:36:19 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E3FCE53F; Tue, 19 Mar 2013 13:36:19 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id D3B8B6CC; Tue, 19 Mar 2013 13:36:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2JDaJ9P001027; Tue, 19 Mar 2013 13:36:19 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2JDaJf6001026; Tue, 19 Mar 2013 13:36:19 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201303191336.r2JDaJf6001026@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Tue, 19 Mar 2013 13:36:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248506 - stable/9/usr.bin/netstat X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2013 13:36:20 -0000 Author: melifaro Date: Tue Mar 19 13:36:19 2013 New Revision: 248506 URL: http://svnweb.freebsd.org/changeset/base/248506 Log: Merge r248112. Document netstat -Q flags meaning. Modified: stable/9/usr.bin/netstat/netstat.1 Directory Properties: stable/9/usr.bin/ (props changed) stable/9/usr.bin/netstat/ (props changed) Modified: stable/9/usr.bin/netstat/netstat.1 ============================================================================== --- stable/9/usr.bin/netstat/netstat.1 Tue Mar 19 13:29:01 2013 (r248505) +++ stable/9/usr.bin/netstat/netstat.1 Tue Mar 19 13:36:19 2013 (r248506) @@ -28,7 +28,7 @@ .\" @(#)netstat.1 8.8 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd February 22, 2010 +.Dd March 10, 2013 .Dt NETSTAT 1 .Os .Sh NAME @@ -301,6 +301,11 @@ is repeated, counters with a value of ze Show .Xr netisr 9 statistics. +The flags field shows available ISR handlers: +.Bl -column ".Li W" ".Dv NETISR_SNP_FLAGS_DRAINEDCPU" +.It Li C Ta Dv NETISR_SNP_FLAGS_M2CPUID Ta "Able to map mbuf to cpu id" +.It Li D Ta Dv NETISR_SNP_FLAGS_DRAINEDCPU Ta "Has queue drain handler" +.It Li F Ta Dv NETISR_SNP_FLAGS_M2FLOW Ta "Able to map mbuf to flow id" .El .Pp Some options have the general meaning: From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 19 16:12:43 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 38138118; Tue, 19 Mar 2013 16:12:43 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (lor.one-eyed-alien.net [69.66.77.232]) by mx1.freebsd.org (Postfix) with ESMTP id 75C0523E; Tue, 19 Mar 2013 16:12:42 +0000 (UTC) Received: from lor.one-eyed-alien.net (localhost [127.0.0.1]) by lor.one-eyed-alien.net (8.14.5/8.14.5) with ESMTP id r2JGCegX092689; Tue, 19 Mar 2013 11:12:40 -0500 (CDT) (envelope-from brooks@lor.one-eyed-alien.net) Received: (from brooks@localhost) by lor.one-eyed-alien.net (8.14.5/8.14.5/Submit) id r2JGCdWc092688; Tue, 19 Mar 2013 11:12:39 -0500 (CDT) (envelope-from brooks) Date: Tue, 19 Mar 2013 11:12:39 -0500 From: Brooks Davis To: Dmitry Morozovsky Subject: Re: svn commit: r248352 - in stable/9: etc share/mk Message-ID: <20130319161239.GB80942@lor.one-eyed-alien.net> References: <201303152132.r2FLWfwx076672@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="4Ckj6UjgE2iN1+kY" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2013 16:12:43 -0000 --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Mar 17, 2013 at 06:10:58PM +0400, Dmitry Morozovsky wrote: > On Fri, 15 Mar 2013, Brooks Davis wrote: >=20 > > Author: brooks > > Date: Fri Mar 15 21:32:40 2013 > > New Revision: 248352 > > URL: http://svnweb.freebsd.org/changeset/base/248352 > >=20 > > Log: > > MFC r245752,246913,247162 > > =20 > > Replace all known uses of ln in the build process with appropriate > > install -l invocations via new INSTALL_LINK and INSTALL_SYMLINK > > variables. >=20 > It seems this merge breaks ``make distribution'' and hence mergemaster if= your=20 > base system is not updated yet (for example, while updating jail): Sorry for the delay in responding. I missed this yesterday. It works for me on a older 9.0-STABLE system where the base install doesn't support -l. Did you build world or run "make toolchain" in that source tree to build the bootstrap copy of install? -- Brooks --4Ckj6UjgE2iN1+kY Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iD8DBQFRSI53XY6L6fI4GtQRAoYwAKCQ5EzhDH6xeoFEoDU0IET5YD9D6gCdGtE4 DI3t29pWZIR043IvNuCppyc= =nZOR -----END PGP SIGNATURE----- --4Ckj6UjgE2iN1+kY-- From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 19 17:49:49 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 99204307; Tue, 19 Mar 2013 17:49:49 +0000 (UTC) (envelope-from marck@rinet.ru) Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68]) by mx1.freebsd.org (Postfix) with ESMTP id 1557D9A8; Tue, 19 Mar 2013 17:49:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by woozle.rinet.ru (8.14.5/8.14.5) with ESMTP id r2JHnljF057183; Tue, 19 Mar 2013 21:49:48 +0400 (MSK) (envelope-from marck@rinet.ru) Date: Tue, 19 Mar 2013 21:49:47 +0400 (MSK) From: Dmitry Morozovsky To: Brooks Davis Subject: Re: svn commit: r248352 - in stable/9: etc share/mk In-Reply-To: <20130319161239.GB80942@lor.one-eyed-alien.net> Message-ID: References: <201303152132.r2FLWfwx076672@svn.freebsd.org> <20130319161239.GB80942@lor.one-eyed-alien.net> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) X-NCC-RegID: ru.rinet X-OpenPGP-Key-ID: 6B691B03 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (woozle.rinet.ru [0.0.0.0]); Tue, 19 Mar 2013 21:49:48 +0400 (MSK) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2013 17:49:49 -0000 On Tue, 19 Mar 2013, Brooks Davis wrote: > > > Replace all known uses of ln in the build process with appropriate > > > install -l invocations via new INSTALL_LINK and INSTALL_SYMLINK > > > variables. > > > > It seems this merge breaks ``make distribution'' and hence mergemaster if your > > base system is not updated yet (for example, while updating jail): > > Sorry for the delay in responding. I missed this yesterday. > > It works for me on a older 9.0-STABLE system where the base install > doesn't support -l. Did you build world or run "make toolchain" in that > source tree to build the bootstrap copy of install? Yes, this is after full ``make buildworld buildkernel'' process. For me, I use an obvious quick'n'dirty hack (bad, I know, but useable for me as a workaround) marck@castor:/FreeBSD/rinet/src.9.newcarp> svn diff share/mk Index: share/mk/bsd.own.mk =================================================================== --- share/mk/bsd.own.mk (revision 248523) +++ share/mk/bsd.own.mk (working copy) @@ -187,8 +187,8 @@ HRDLINK?= -l h SYMLINK?= -l s -INSTALL_LINK?= ${INSTALL} ${HRDLINK} -INSTALL_SYMLINK?= ${INSTALL} ${SYMLINK} +INSTALL_LINK?= ln -f +INSTALL_SYMLINK?= ln -fs # Common variables .if !defined(DEBUG_FLAGS) -- Sincerely, D.Marck [DM5020, MCK-RIPE, DM3-RIPN] [ FreeBSD committer: marck@FreeBSD.org ] ------------------------------------------------------------------------ *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru *** ------------------------------------------------------------------------ From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 19 20:00:36 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id D1B6C1B5; Tue, 19 Mar 2013 20:00:36 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A8794199; Tue, 19 Mar 2013 20:00:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2JK0a0M020407; Tue, 19 Mar 2013 20:00:36 GMT (envelope-from brooks@svn.freebsd.org) Received: (from brooks@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2JK0Z5p020396; Tue, 19 Mar 2013 20:00:35 GMT (envelope-from brooks@svn.freebsd.org) Message-Id: <201303192000.r2JK0Z5p020396@svn.freebsd.org> From: Brooks Davis Date: Tue, 19 Mar 2013 20:00:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248531 - in stable/9: etc share/mk usr.sbin/mergemaster X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2013 20:00:36 -0000 Author: brooks Date: Tue Mar 19 20:00:34 2013 New Revision: 248531 URL: http://svnweb.freebsd.org/changeset/base/248531 Log: Revert r248352: > Replace all known uses of ln in the build process with appropriate > install -l invocations via new INSTALL_LINK and INSTALL_SYMLINK > variables. This breaks the assumption mergemaster and etcupdate that no new features of tools will be required to run "make distribution" or it's prerequisites. Plotting a way forward will take some time and nothing in 9-STABLE depends on INSTALL_LINK and INSTALL_SYMLINK yet so backing this out seem like the right short-term approach. PR: misc/177055 Modified: stable/9/etc/Makefile stable/9/share/mk/bsd.incs.mk stable/9/share/mk/bsd.info.mk stable/9/share/mk/bsd.lib.mk stable/9/share/mk/bsd.links.mk stable/9/share/mk/bsd.man.mk stable/9/share/mk/bsd.own.mk stable/9/usr.sbin/mergemaster/mergemaster.sh Directory Properties: stable/9/etc/ (props changed) stable/9/share/mk/ (props changed) Modified: stable/9/etc/Makefile ============================================================================== --- stable/9/etc/Makefile Tue Mar 19 19:49:06 2013 (r248530) +++ stable/9/etc/Makefile Tue Mar 19 20:00:34 2013 (r248531) @@ -321,29 +321,26 @@ distrib-dirs: -f $$m -p $$d; \ ${MTREE_CMD} -deU ${MTREE_FOLLOWS_SYMLINKS} -f $$m -p $$d; \ done; true - ${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys + ln -sfh usr/src/sys ${DESTDIR}/sys cd ${DESTDIR}/usr/share/man; \ for mandir in man*; do \ - ${INSTALL_SYMLINK} ../$$mandir \ - ${DESTDIR}/usr/share/man/en.ISO8859-1/; \ - ${INSTALL_SYMLINK} ../$$mandir \ - ${DESTDIR}/usr/share/man/en.UTF-8/; \ + ln -sfh ../$$mandir ${DESTDIR}/usr/share/man/en.ISO8859-1/; \ + ln -sfh ../$$mandir ${DESTDIR}/usr/share/man/en.UTF-8/; \ done cd ${DESTDIR}/usr/share/openssl/man; \ for mandir in man*; do \ - ${INSTALL_SYMLINK} ../$$mandir \ + ln -sfh ../$$mandir \ ${DESTDIR}/usr/share/openssl/man/en.ISO8859-1/; \ done set - `grep "^[a-zA-Z]" ${.CURDIR}/man.alias`; \ while [ $$# -gt 0 ] ; do \ - ${INSTALL_SYMLINK} "$$2" "${DESTDIR}/usr/share/man/$$1"; \ - ${INSTALL_SYMLINK} "$$2" \ - "${DESTDIR}/usr/share/openssl/man/$$1"; \ + ln -sfh "$$2" "${DESTDIR}/usr/share/man/$$1"; \ + ln -sfh "$$2" "${DESTDIR}/usr/share/openssl/man/$$1"; \ shift; shift; \ done set - `grep "^[a-zA-Z]" ${.CURDIR}/nls.alias`; \ while [ $$# -gt 0 ] ; do \ - ${INSTALL_SYMLINK} "$$2" "${DESTDIR}/usr/share/nls/$$1"; \ + ln -sfh "$$2" "${DESTDIR}/usr/share/nls/$$1"; \ shift; shift; \ done Modified: stable/9/share/mk/bsd.incs.mk ============================================================================== --- stable/9/share/mk/bsd.incs.mk Tue Mar 19 19:49:06 2013 (r248530) +++ stable/9/share/mk/bsd.incs.mk Tue Mar 19 20:00:34 2013 (r248531) @@ -73,7 +73,7 @@ installincludes: t=${DESTDIR}$$1; \ shift; \ ${ECHO} $$t -\> $$l; \ - ${INSTALL_SYMLINK} $$l $$t; \ + ln -fs $$l $$t; \ done; true .endif .endif # !target(installincludes) Modified: stable/9/share/mk/bsd.info.mk ============================================================================== --- stable/9/share/mk/bsd.info.mk Tue Mar 19 19:49:06 2013 (r248530) +++ stable/9/share/mk/bsd.info.mk Tue Mar 19 20:00:34 2013 (r248531) @@ -113,7 +113,7 @@ DVIPS2ASCII?= dvips2ascii .info.html: ${INFO2HTML} ${.IMPSRC} - ${INSTALL_LINK} ${.TARGET:R}.info.Top.html ${.TARGET} + ln -f ${.TARGET:R}.info.Top.html ${.TARGET} .PATH: ${.CURDIR} ${SRCDIR} Modified: stable/9/share/mk/bsd.lib.mk ============================================================================== --- stable/9/share/mk/bsd.lib.mk Tue Mar 19 19:49:06 2013 (r248530) +++ stable/9/share/mk/bsd.lib.mk Tue Mar 19 20:00:34 2013 (r248531) @@ -178,9 +178,9 @@ ${SHLIB_NAME}: ${SOBJS} beforelinking ${SHLIB_NAME}: ${SOBJS} .endif @${ECHO} building shared library ${SHLIB_NAME} - @rm -f ${SHLIB_NAME} ${SHLIB_LINK} + @rm -f ${.TARGET} ${SHLIB_LINK} .if defined(SHLIB_LINK) - @${INSTALL_SYMLINK} ${SHLIB_NAME} ${SHLIB_LINK} + @ln -fs ${.TARGET} ${SHLIB_LINK} .endif .if !defined(NM) @${CC} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \ @@ -291,9 +291,9 @@ _libinstall: ${_INSTALLFLAGS} lib${LIB}.ld ${DESTDIR}${LIBDIR}/${SHLIB_LINK} .else .if ${SHLIBDIR} == ${LIBDIR} - ${INSTALL_SYMLINK} ${SHLIB_NAME} ${DESTDIR}${LIBDIR}/${SHLIB_LINK} + ln -fs ${SHLIB_NAME} ${DESTDIR}${LIBDIR}/${SHLIB_LINK} .else - ${INSTALL_SYMLINK} ${_SHLIBDIRPREFIX}${SHLIBDIR}/${SHLIB_NAME} \ + ln -fs ${_SHLIBDIRPREFIX}${SHLIBDIR}/${SHLIB_NAME} \ ${DESTDIR}${LIBDIR}/${SHLIB_LINK} .if exists(${DESTDIR}${LIBDIR}/${SHLIB_NAME}) -chflags noschg ${DESTDIR}${LIBDIR}/${SHLIB_NAME} Modified: stable/9/share/mk/bsd.links.mk ============================================================================== --- stable/9/share/mk/bsd.links.mk Tue Mar 19 19:49:06 2013 (r248530) +++ stable/9/share/mk/bsd.links.mk Tue Mar 19 20:00:34 2013 (r248531) @@ -15,7 +15,7 @@ _installlinks: t=${DESTDIR}$$1; \ shift; \ ${ECHO} $$t -\> $$l; \ - ${INSTALL_LINK} $$l $$t; \ + ln -f $$l $$t; \ done; true .endif .if defined(SYMLINKS) && !empty(SYMLINKS) @@ -26,6 +26,6 @@ _installlinks: t=${DESTDIR}$$1; \ shift; \ ${ECHO} $$t -\> $$l; \ - ${INSTALL_SYMLINK} $$l $$t; \ + ln -fs $$l $$t; \ done; true .endif Modified: stable/9/share/mk/bsd.man.mk ============================================================================== --- stable/9/share/mk/bsd.man.mk Tue Mar 19 19:49:06 2013 (r248530) +++ stable/9/share/mk/bsd.man.mk Tue Mar 19 20:00:34 2013 (r248531) @@ -216,7 +216,7 @@ _maninstall: ${MAN} t=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}/$$name; \ ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \ rm -f $${t} $${t}${MCOMPRESS_EXT}; \ - ${INSTALL_LINK} $${l}${ZEXT} $${t}${ZEXT}; \ + ln $${l}${ZEXT} $${t}${ZEXT}; \ done .if defined(MANBUILDCAT) && !empty(MANBUILDCAT) @set ${MLINKS:C/\.([^.]*)$/.\1 \1/}; \ @@ -231,7 +231,7 @@ _maninstall: ${MAN} t=${DESTDIR}${CATDIR}$${sect}${MANSUBDIR}/$$name; \ ${ECHO} $${t}${ZEXT} -\> $${l}${ZEXT}; \ rm -f $${t} $${t}${MCOMPRESS_EXT}; \ - ${INSTALL_LINK} $${l}${ZEXT} $${t}${ZEXT}; \ + ln $${l}${ZEXT} $${t}${ZEXT}; \ done .endif .endif Modified: stable/9/share/mk/bsd.own.mk ============================================================================== --- stable/9/share/mk/bsd.own.mk Tue Mar 19 19:49:06 2013 (r248530) +++ stable/9/share/mk/bsd.own.mk Tue Mar 19 20:00:34 2013 (r248531) @@ -181,15 +181,6 @@ NLSMODE?= ${NOBINMODE} INCLUDEDIR?= /usr/include -# -# install(1) parameters. -# -HRDLINK?= -l h -SYMLINK?= -l s - -INSTALL_LINK?= ${INSTALL} ${HRDLINK} -INSTALL_SYMLINK?= ${INSTALL} ${SYMLINK} - # Common variables .if !defined(DEBUG_FLAGS) STRIP?= -s Modified: stable/9/usr.sbin/mergemaster/mergemaster.sh ============================================================================== --- stable/9/usr.sbin/mergemaster/mergemaster.sh Tue Mar 19 19:49:06 2013 (r248530) +++ stable/9/usr.sbin/mergemaster/mergemaster.sh Tue Mar 19 20:00:34 2013 (r248531) @@ -629,7 +629,12 @@ case "${RERUN}" in ${MM_MAKE} DESTDIR=${DESTDIR} distrib-dirs >/dev/null ;; esac - od=${TEMPROOT}/usr/obj + if [ -d `${MM_MAKE} -V .OBJDIR` ]; then + od=`${MM_MAKE} -V MAKEOBJDIRPREFIX` + else + od=${TEMPROOT}/usr/obj + fi + echo $od 1>&2 ${MM_MAKE} DESTDIR=${TEMPROOT} distrib-dirs >/dev/null && MAKEOBJDIRPREFIX=$od ${MM_MAKE} _obj SUBDIR_OVERRIDE=etc >/dev/null && MAKEOBJDIRPREFIX=$od ${MM_MAKE} everything SUBDIR_OVERRIDE=etc >/dev/null && From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 19 20:06:28 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B03864A2; Tue, 19 Mar 2013 20:06:28 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (lor.one-eyed-alien.net [69.66.77.232]) by mx1.freebsd.org (Postfix) with ESMTP id E48F41F2; Tue, 19 Mar 2013 20:06:27 +0000 (UTC) Received: from lor.one-eyed-alien.net (localhost [127.0.0.1]) by lor.one-eyed-alien.net (8.14.5/8.14.5) with ESMTP id r2JK6Vis093932; Tue, 19 Mar 2013 15:06:31 -0500 (CDT) (envelope-from brooks@lor.one-eyed-alien.net) Received: (from brooks@localhost) by lor.one-eyed-alien.net (8.14.5/8.14.5/Submit) id r2JK6V3l093931; Tue, 19 Mar 2013 15:06:31 -0500 (CDT) (envelope-from brooks) Date: Tue, 19 Mar 2013 15:06:31 -0500 From: Brooks Davis To: Dmitry Morozovsky Subject: Re: svn commit: r248352 - in stable/9: etc share/mk Message-ID: <20130319200631.GC80942@lor.one-eyed-alien.net> References: <201303152132.r2FLWfwx076672@svn.freebsd.org> <20130319161239.GB80942@lor.one-eyed-alien.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="NDin8bjvE/0mNLFQ" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2013 20:06:28 -0000 --NDin8bjvE/0mNLFQ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 19, 2013 at 09:49:47PM +0400, Dmitry Morozovsky wrote: > On Tue, 19 Mar 2013, Brooks Davis wrote: >=20 > > > > Replace all known uses of ln in the build process with appropriate > > > > install -l invocations via new INSTALL_LINK and INSTALL_SYMLINK > > > > variables. > > >=20 > > > It seems this merge breaks ``make distribution'' and hence mergemaste= r if your=20 > > > base system is not updated yet (for example, while updating jail): > >=20 > > Sorry for the delay in responding. I missed this yesterday. > >=20 > > It works for me on a older 9.0-STABLE system where the base install > > doesn't support -l. Did you build world or run "make toolchain" in that > > source tree to build the bootstrap copy of install? >=20 > Yes, this is after full ``make buildworld buildkernel'' process. I've found the problem thanks to misc/177055. It is that mergemaster (and etcupdate) set MAKEOBJDIRPREFIX to something in their temporary directory and thus deprive themselves of bootstrap tools. Unfortunately, I don't see a trivial fix so I've backed this out for now and will work on this in HEAD. -- Brooks --NDin8bjvE/0mNLFQ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iD8DBQFRSMVGXY6L6fI4GtQRApRoAKDP6Lit0aK4PRlqIUQoiCJHYjHgbACfdsiJ zp6mEmiP2sIMKAAVPj0/BjE= =zfNH -----END PGP SIGNATURE----- --NDin8bjvE/0mNLFQ-- From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 19 20:18:32 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8A172A98; Tue, 19 Mar 2013 20:18:32 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 7B6562A1; Tue, 19 Mar 2013 20:18:32 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2JKIWDP026745; Tue, 19 Mar 2013 20:18:32 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2JKIU55026730; Tue, 19 Mar 2013 20:18:30 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201303192018.r2JKIU55026730@svn.freebsd.org> From: Jung-uk Kim Date: Tue, 19 Mar 2013 20:18:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248532 - in stable/9/sys: amd64/linux32 compat/linux i386/linux kern X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2013 20:18:32 -0000 Author: jkim Date: Tue Mar 19 20:18:30 2013 New Revision: 248532 URL: http://svnweb.freebsd.org/changeset/base/248532 Log: MFC: r234352 Implement pipe2 syscall for Linuxulator. Modified: stable/9/sys/amd64/linux32/linux32_dummy.c stable/9/sys/amd64/linux32/linux32_machdep.c stable/9/sys/amd64/linux32/syscalls.master stable/9/sys/compat/linux/linux_file.c stable/9/sys/i386/linux/linux_dummy.c stable/9/sys/i386/linux/linux_machdep.c stable/9/sys/i386/linux/syscalls.master stable/9/sys/kern/sys_pipe.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/amd64/linux32/linux32_dummy.c ============================================================================== --- stable/9/sys/amd64/linux32/linux32_dummy.c Tue Mar 19 20:00:34 2013 (r248531) +++ stable/9/sys/amd64/linux32/linux32_dummy.c Tue Mar 19 20:18:30 2013 (r248532) @@ -131,7 +131,6 @@ DUMMY(signalfd4); DUMMY(eventfd2); DUMMY(epoll_create1); DUMMY(dup3); -DUMMY(pipe2); DUMMY(inotify_init1); /* linux 2.6.30: */ DUMMY(preadv); Modified: stable/9/sys/amd64/linux32/linux32_machdep.c ============================================================================== --- stable/9/sys/amd64/linux32/linux32_machdep.c Tue Mar 19 20:00:34 2013 (r248531) +++ stable/9/sys/amd64/linux32/linux32_machdep.c Tue Mar 19 20:18:30 2013 (r248532) @@ -698,25 +698,6 @@ linux_iopl(struct thread *td, struct lin } int -linux_pipe(struct thread *td, struct linux_pipe_args *args) -{ - int error; - int fildes[2]; - -#ifdef DEBUG - if (ldebug(pipe)) - printf(ARGS(pipe, "*")); -#endif - - error = kern_pipe(td, fildes); - if (error) - return (error); - - /* XXX: Close descriptors on error. */ - return (copyout(fildes, args->pipefds, sizeof fildes)); -} - -int linux_sigaction(struct thread *td, struct linux_sigaction_args *args) { l_osigaction_t osa; Modified: stable/9/sys/amd64/linux32/syscalls.master ============================================================================== --- stable/9/sys/amd64/linux32/syscalls.master Tue Mar 19 20:00:34 2013 (r248531) +++ stable/9/sys/amd64/linux32/syscalls.master Tue Mar 19 20:18:30 2013 (r248532) @@ -95,7 +95,7 @@ 39 AUE_MKDIR STD { int linux_mkdir(char *path, l_int mode); } 40 AUE_RMDIR STD { int linux_rmdir(char *path); } 41 AUE_DUP NOPROTO { int dup(u_int fd); } -42 AUE_PIPE STD { int linux_pipe(l_ulong *pipefds); } +42 AUE_PIPE STD { int linux_pipe(l_int *pipefds); } 43 AUE_NULL STD { int linux_times(struct l_times_argv *buf); } 44 AUE_NULL UNIMPL prof 45 AUE_NULL STD { int linux_brk(l_ulong dsend); } @@ -536,7 +536,7 @@ 328 AUE_NULL STD { int linux_eventfd2(void); } 329 AUE_NULL STD { int linux_epoll_create1(void); } 330 AUE_NULL STD { int linux_dup3(void); } -331 AUE_NULL STD { int linux_pipe2(void); } +331 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); } 332 AUE_NULL STD { int linux_inotify_init1(void); } ; linux 2.6.30: 333 AUE_NULL STD { int linux_preadv(void); } Modified: stable/9/sys/compat/linux/linux_file.c ============================================================================== --- stable/9/sys/compat/linux/linux_file.c Tue Mar 19 20:00:34 2013 (r248531) +++ stable/9/sys/compat/linux/linux_file.c Tue Mar 19 20:18:30 2013 (r248532) @@ -69,6 +69,9 @@ __FBSDID("$FreeBSD$"); #include #include +/* XXX */ +int do_pipe(struct thread *td, int fildes[2], int flags); + int linux_creat(struct thread *td, struct linux_creat_args *args) { @@ -1571,3 +1574,49 @@ linux_fadvise64_64(struct thread *td, st return (kern_posix_fadvise(td, args->fd, args->offset, args->len, advice)); } + +int +linux_pipe(struct thread *td, struct linux_pipe_args *args) +{ + int fildes[2]; + int error; + +#ifdef DEBUG + if (ldebug(pipe)) + printf(ARGS(pipe, "*")); +#endif + + error = do_pipe(td, fildes, 0); + if (error) + return (error); + + /* XXX: Close descriptors on error. */ + return (copyout(fildes, args->pipefds, sizeof(fildes))); +} + +int +linux_pipe2(struct thread *td, struct linux_pipe2_args *args) +{ + int fildes[2]; + int error, flags; + +#ifdef DEBUG + if (ldebug(pipe2)) + printf(ARGS(pipe2, "*, %d"), args->flags); +#endif + + if ((args->flags & ~(LINUX_O_NONBLOCK | LINUX_O_CLOEXEC)) != 0) + return (EINVAL); + + flags = 0; + if ((args->flags & LINUX_O_NONBLOCK) != 0) + flags |= O_NONBLOCK; + if ((args->flags & LINUX_O_CLOEXEC) != 0) + flags |= O_CLOEXEC; + error = do_pipe(td, fildes, flags); + if (error) + return (error); + + /* XXX: Close descriptors on error. */ + return (copyout(fildes, args->pipefds, sizeof(fildes))); +} Modified: stable/9/sys/i386/linux/linux_dummy.c ============================================================================== --- stable/9/sys/i386/linux/linux_dummy.c Tue Mar 19 20:00:34 2013 (r248531) +++ stable/9/sys/i386/linux/linux_dummy.c Tue Mar 19 20:18:30 2013 (r248532) @@ -122,7 +122,6 @@ DUMMY(signalfd4); DUMMY(eventfd2); DUMMY(epoll_create1); DUMMY(dup3); -DUMMY(pipe2); DUMMY(inotify_init1); /* linux 2.6.30: */ DUMMY(preadv); Modified: stable/9/sys/i386/linux/linux_machdep.c ============================================================================== --- stable/9/sys/i386/linux/linux_machdep.c Tue Mar 19 20:00:34 2013 (r248531) +++ stable/9/sys/i386/linux/linux_machdep.c Tue Mar 19 20:18:30 2013 (r248532) @@ -587,25 +587,6 @@ linux_mprotect(struct thread *td, struct } int -linux_pipe(struct thread *td, struct linux_pipe_args *args) -{ - int error; - int fildes[2]; - -#ifdef DEBUG - if (ldebug(pipe)) - printf(ARGS(pipe, "*")); -#endif - - error = kern_pipe(td, fildes); - if (error) - return (error); - - /* XXX: Close descriptors on error. */ - return (copyout(fildes, args->pipefds, sizeof fildes)); -} - -int linux_ioperm(struct thread *td, struct linux_ioperm_args *args) { int error; Modified: stable/9/sys/i386/linux/syscalls.master ============================================================================== --- stable/9/sys/i386/linux/syscalls.master Tue Mar 19 20:00:34 2013 (r248531) +++ stable/9/sys/i386/linux/syscalls.master Tue Mar 19 20:18:30 2013 (r248532) @@ -95,7 +95,7 @@ 39 AUE_MKDIR STD { int linux_mkdir(char *path, l_int mode); } 40 AUE_RMDIR STD { int linux_rmdir(char *path); } 41 AUE_DUP NOPROTO { int dup(u_int fd); } -42 AUE_PIPE STD { int linux_pipe(l_ulong *pipefds); } +42 AUE_PIPE STD { int linux_pipe(l_int *pipefds); } 43 AUE_NULL STD { int linux_times(struct l_times_argv *buf); } 44 AUE_NULL UNIMPL prof 45 AUE_NULL STD { int linux_brk(l_ulong dsend); } @@ -546,7 +546,7 @@ 328 AUE_NULL STD { int linux_eventfd2(void); } 329 AUE_NULL STD { int linux_epoll_create1(void); } 330 AUE_NULL STD { int linux_dup3(void); } -331 AUE_NULL STD { int linux_pipe2(void); } +331 AUE_NULL STD { int linux_pipe2(l_int *pipefds, l_int flags); } 332 AUE_NULL STD { int linux_inotify_init1(void); } ; linux 2.6.30: 333 AUE_NULL STD { int linux_preadv(void); } Modified: stable/9/sys/kern/sys_pipe.c ============================================================================== --- stable/9/sys/kern/sys_pipe.c Tue Mar 19 20:00:34 2013 (r248531) +++ stable/9/sys/kern/sys_pipe.c Tue Mar 19 20:18:30 2013 (r248532) @@ -128,6 +128,9 @@ __FBSDID("$FreeBSD$"); #include #include +/* XXX */ +int do_pipe(struct thread *td, int fildes[2], int flags); + /* * Use this define if you want to disable *fancy* VM things. Expect an * approx 30% decrease in transfer rate. This could be useful for @@ -324,11 +327,18 @@ pipe_zone_fini(void *mem, int size) int kern_pipe(struct thread *td, int fildes[2]) { + + return (do_pipe(td, fildes, 0)); +} + +int +do_pipe(struct thread *td, int fildes[2], int flags) +{ struct filedesc *fdp = td->td_proc->p_fd; struct file *rf, *wf; struct pipepair *pp; struct pipe *rpipe, *wpipe; - int fd, error; + int fd, fflags, error; pp = uma_zalloc(pipe_zone, M_WAITOK); #ifdef MAC @@ -357,7 +367,7 @@ kern_pipe(struct thread *td, int fildes[ rpipe->pipe_state |= PIPE_DIRECTOK; wpipe->pipe_state |= PIPE_DIRECTOK; - error = falloc(td, &rf, &fd, 0); + error = falloc(td, &rf, &fd, flags); if (error) { pipeclose(rpipe); pipeclose(wpipe); @@ -366,14 +376,18 @@ kern_pipe(struct thread *td, int fildes[ /* An extra reference on `rf' has been held for us by falloc(). */ fildes[0] = fd; + fflags = FREAD | FWRITE; + if ((flags & O_NONBLOCK) != 0) + fflags |= FNONBLOCK; + /* * Warning: once we've gotten past allocation of the fd for the * read-side, we can only drop the read side via fdrop() in order * to avoid races against processes which manage to dup() the read * side while we are blocked trying to allocate the write side. */ - finit(rf, FREAD | FWRITE, DTYPE_PIPE, rpipe, &pipeops); - error = falloc(td, &wf, &fd, 0); + finit(rf, fflags, DTYPE_PIPE, rpipe, &pipeops); + error = falloc(td, &wf, &fd, flags); if (error) { fdclose(fdp, rf, fildes[0], td); fdrop(rf, td); @@ -382,7 +396,7 @@ kern_pipe(struct thread *td, int fildes[ return (error); } /* An extra reference on `wf' has been held for us by falloc(). */ - finit(wf, FREAD | FWRITE, DTYPE_PIPE, wpipe, &pipeops); + finit(wf, fflags, DTYPE_PIPE, wpipe, &pipeops); fdrop(wf, td); fildes[1] = fd; fdrop(rf, td); From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 19 20:20:02 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BFF94C14; Tue, 19 Mar 2013 20:20:02 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A42CA2B2; Tue, 19 Mar 2013 20:20:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2JKK2eC027013; Tue, 19 Mar 2013 20:20:02 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2JKK0Xh026997; Tue, 19 Mar 2013 20:20:00 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201303192020.r2JKK0Xh026997@svn.freebsd.org> From: Jung-uk Kim Date: Tue, 19 Mar 2013 20:20:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248533 - in stable/9/sys: amd64/linux32 i386/linux X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2013 20:20:02 -0000 Author: jkim Date: Tue Mar 19 20:20:00 2013 New Revision: 248533 URL: http://svnweb.freebsd.org/changeset/base/248533 Log: Regen for r248532. Modified: stable/9/sys/amd64/linux32/linux32_proto.h stable/9/sys/amd64/linux32/linux32_syscall.h stable/9/sys/amd64/linux32/linux32_syscalls.c stable/9/sys/amd64/linux32/linux32_sysent.c stable/9/sys/amd64/linux32/linux32_systrace_args.c stable/9/sys/i386/linux/linux_proto.h stable/9/sys/i386/linux/linux_syscall.h stable/9/sys/i386/linux/linux_syscalls.c stable/9/sys/i386/linux/linux_sysent.c stable/9/sys/i386/linux/linux_systrace_args.c Modified: stable/9/sys/amd64/linux32/linux32_proto.h ============================================================================== --- stable/9/sys/amd64/linux32/linux32_proto.h Tue Mar 19 20:18:30 2013 (r248532) +++ stable/9/sys/amd64/linux32/linux32_proto.h Tue Mar 19 20:20:00 2013 (r248533) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/9/sys/amd64/linux32/syscalls.master 234316 2012-04-15 16:52:48Z netchild + * created from FreeBSD: stable/9/sys/amd64/linux32/syscalls.master 248532 2013-03-19 20:18:30Z jkim */ #ifndef _LINUX_SYSPROTO_H_ @@ -152,7 +152,7 @@ struct linux_rmdir_args { char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; }; struct linux_pipe_args { - char pipefds_l_[PADL_(l_ulong *)]; l_ulong * pipefds; char pipefds_r_[PADR_(l_ulong *)]; + char pipefds_l_[PADL_(l_int *)]; l_int * pipefds; char pipefds_r_[PADR_(l_int *)]; }; struct linux_times_args { char buf_l_[PADL_(struct l_times_argv *)]; struct l_times_argv * buf; char buf_r_[PADR_(struct l_times_argv *)]; @@ -1044,7 +1044,8 @@ struct linux_dup3_args { register_t dummy; }; struct linux_pipe2_args { - register_t dummy; + char pipefds_l_[PADL_(l_int *)]; l_int * pipefds; char pipefds_r_[PADR_(l_int *)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_inotify_init1_args { register_t dummy; Modified: stable/9/sys/amd64/linux32/linux32_syscall.h ============================================================================== --- stable/9/sys/amd64/linux32/linux32_syscall.h Tue Mar 19 20:18:30 2013 (r248532) +++ stable/9/sys/amd64/linux32/linux32_syscall.h Tue Mar 19 20:20:00 2013 (r248533) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/9/sys/amd64/linux32/syscalls.master 234316 2012-04-15 16:52:48Z netchild + * created from FreeBSD: stable/9/sys/amd64/linux32/syscalls.master 248532 2013-03-19 20:18:30Z jkim */ #define LINUX_SYS_exit 1 Modified: stable/9/sys/amd64/linux32/linux32_syscalls.c ============================================================================== --- stable/9/sys/amd64/linux32/linux32_syscalls.c Tue Mar 19 20:18:30 2013 (r248532) +++ stable/9/sys/amd64/linux32/linux32_syscalls.c Tue Mar 19 20:20:00 2013 (r248533) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/9/sys/amd64/linux32/syscalls.master 234316 2012-04-15 16:52:48Z netchild + * created from FreeBSD: stable/9/sys/amd64/linux32/syscalls.master 248532 2013-03-19 20:18:30Z jkim */ const char *linux_syscallnames[] = { Modified: stable/9/sys/amd64/linux32/linux32_sysent.c ============================================================================== --- stable/9/sys/amd64/linux32/linux32_sysent.c Tue Mar 19 20:18:30 2013 (r248532) +++ stable/9/sys/amd64/linux32/linux32_sysent.c Tue Mar 19 20:20:00 2013 (r248533) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/9/sys/amd64/linux32/syscalls.master 234316 2012-04-15 16:52:48Z netchild + * created from FreeBSD: stable/9/sys/amd64/linux32/syscalls.master 248532 2013-03-19 20:18:30Z jkim */ #include "opt_compat.h" @@ -350,7 +350,7 @@ struct sysent linux_sysent[] = { { 0, (sy_call_t *)linux_eventfd2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 328 = linux_eventfd2 */ { 0, (sy_call_t *)linux_epoll_create1, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 329 = linux_epoll_create1 */ { 0, (sy_call_t *)linux_dup3, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 330 = linux_dup3 */ - { 0, (sy_call_t *)linux_pipe2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 331 = linux_pipe2 */ + { AS(linux_pipe2_args), (sy_call_t *)linux_pipe2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 331 = linux_pipe2 */ { 0, (sy_call_t *)linux_inotify_init1, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 332 = linux_inotify_init1 */ { 0, (sy_call_t *)linux_preadv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 333 = linux_preadv */ { 0, (sy_call_t *)linux_pwritev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 334 = linux_pwritev */ Modified: stable/9/sys/amd64/linux32/linux32_systrace_args.c ============================================================================== --- stable/9/sys/amd64/linux32/linux32_systrace_args.c Tue Mar 19 20:18:30 2013 (r248532) +++ stable/9/sys/amd64/linux32/linux32_systrace_args.c Tue Mar 19 20:20:00 2013 (r248533) @@ -287,7 +287,7 @@ systrace_args(int sysnum, void *params, /* linux_pipe */ case 42: { struct linux_pipe_args *p = params; - uarg[0] = (intptr_t) p->pipefds; /* l_ulong * */ + uarg[0] = (intptr_t) p->pipefds; /* l_int * */ *n_args = 1; break; } @@ -2171,7 +2171,10 @@ systrace_args(int sysnum, void *params, } /* linux_pipe2 */ case 331: { - *n_args = 0; + struct linux_pipe2_args *p = params; + uarg[0] = (intptr_t) p->pipefds; /* l_int * */ + iarg[1] = p->flags; /* l_int */ + *n_args = 2; break; } /* linux_inotify_init1 */ @@ -2688,7 +2691,7 @@ systrace_setargdesc(int sysnum, int ndx, case 42: switch(ndx) { case 0: - p = "l_ulong *"; + p = "l_int *"; break; default: break; @@ -5364,6 +5367,16 @@ systrace_setargdesc(int sysnum, int ndx, break; /* linux_pipe2 */ case 331: + switch(ndx) { + case 0: + p = "l_int *"; + break; + case 1: + p = "l_int"; + break; + default: + break; + }; break; /* linux_inotify_init1 */ case 332: Modified: stable/9/sys/i386/linux/linux_proto.h ============================================================================== --- stable/9/sys/i386/linux/linux_proto.h Tue Mar 19 20:18:30 2013 (r248532) +++ stable/9/sys/i386/linux/linux_proto.h Tue Mar 19 20:20:00 2013 (r248533) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/9/sys/i386/linux/syscalls.master 234316 2012-04-15 16:52:48Z netchild + * created from FreeBSD: stable/9/sys/i386/linux/syscalls.master 248532 2013-03-19 20:18:30Z jkim */ #ifndef _LINUX_SYSPROTO_H_ @@ -156,7 +156,7 @@ struct linux_rmdir_args { char path_l_[PADL_(char *)]; char * path; char path_r_[PADR_(char *)]; }; struct linux_pipe_args { - char pipefds_l_[PADL_(l_ulong *)]; l_ulong * pipefds; char pipefds_r_[PADR_(l_ulong *)]; + char pipefds_l_[PADL_(l_int *)]; l_int * pipefds; char pipefds_r_[PADR_(l_int *)]; }; struct linux_times_args { char buf_l_[PADL_(struct l_times_argv *)]; struct l_times_argv * buf; char buf_r_[PADR_(struct l_times_argv *)]; @@ -1063,7 +1063,8 @@ struct linux_dup3_args { register_t dummy; }; struct linux_pipe2_args { - register_t dummy; + char pipefds_l_[PADL_(l_int *)]; l_int * pipefds; char pipefds_r_[PADR_(l_int *)]; + char flags_l_[PADL_(l_int)]; l_int flags; char flags_r_[PADR_(l_int)]; }; struct linux_inotify_init1_args { register_t dummy; Modified: stable/9/sys/i386/linux/linux_syscall.h ============================================================================== --- stable/9/sys/i386/linux/linux_syscall.h Tue Mar 19 20:18:30 2013 (r248532) +++ stable/9/sys/i386/linux/linux_syscall.h Tue Mar 19 20:20:00 2013 (r248533) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/9/sys/i386/linux/syscalls.master 234316 2012-04-15 16:52:48Z netchild + * created from FreeBSD: stable/9/sys/i386/linux/syscalls.master 248532 2013-03-19 20:18:30Z jkim */ #define LINUX_SYS_exit 1 Modified: stable/9/sys/i386/linux/linux_syscalls.c ============================================================================== --- stable/9/sys/i386/linux/linux_syscalls.c Tue Mar 19 20:18:30 2013 (r248532) +++ stable/9/sys/i386/linux/linux_syscalls.c Tue Mar 19 20:20:00 2013 (r248533) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/9/sys/i386/linux/syscalls.master 234316 2012-04-15 16:52:48Z netchild + * created from FreeBSD: stable/9/sys/i386/linux/syscalls.master 248532 2013-03-19 20:18:30Z jkim */ const char *linux_syscallnames[] = { Modified: stable/9/sys/i386/linux/linux_sysent.c ============================================================================== --- stable/9/sys/i386/linux/linux_sysent.c Tue Mar 19 20:18:30 2013 (r248532) +++ stable/9/sys/i386/linux/linux_sysent.c Tue Mar 19 20:20:00 2013 (r248533) @@ -3,7 +3,7 @@ * * DO NOT EDIT-- this file is automatically generated. * $FreeBSD$ - * created from FreeBSD: stable/9/sys/i386/linux/syscalls.master 234316 2012-04-15 16:52:48Z netchild + * created from FreeBSD: stable/9/sys/i386/linux/syscalls.master 248532 2013-03-19 20:18:30Z jkim */ #include @@ -349,7 +349,7 @@ struct sysent linux_sysent[] = { { 0, (sy_call_t *)linux_eventfd2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 328 = linux_eventfd2 */ { 0, (sy_call_t *)linux_epoll_create1, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 329 = linux_epoll_create1 */ { 0, (sy_call_t *)linux_dup3, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 330 = linux_dup3 */ - { 0, (sy_call_t *)linux_pipe2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 331 = linux_pipe2 */ + { AS(linux_pipe2_args), (sy_call_t *)linux_pipe2, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 331 = linux_pipe2 */ { 0, (sy_call_t *)linux_inotify_init1, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 332 = linux_inotify_init1 */ { 0, (sy_call_t *)linux_preadv, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 333 = linux_preadv */ { 0, (sy_call_t *)linux_pwritev, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 334 = linux_pwritev */ Modified: stable/9/sys/i386/linux/linux_systrace_args.c ============================================================================== --- stable/9/sys/i386/linux/linux_systrace_args.c Tue Mar 19 20:18:30 2013 (r248532) +++ stable/9/sys/i386/linux/linux_systrace_args.c Tue Mar 19 20:20:00 2013 (r248533) @@ -295,7 +295,7 @@ systrace_args(int sysnum, void *params, /* linux_pipe */ case 42: { struct linux_pipe_args *p = params; - uarg[0] = (intptr_t) p->pipefds; /* l_ulong * */ + uarg[0] = (intptr_t) p->pipefds; /* l_int * */ *n_args = 1; break; } @@ -2262,7 +2262,10 @@ systrace_args(int sysnum, void *params, } /* linux_pipe2 */ case 331: { - *n_args = 0; + struct linux_pipe2_args *p = params; + uarg[0] = (intptr_t) p->pipefds; /* l_int * */ + iarg[1] = p->flags; /* l_int */ + *n_args = 2; break; } /* linux_inotify_init1 */ @@ -2792,7 +2795,7 @@ systrace_setargdesc(int sysnum, int ndx, case 42: switch(ndx) { case 0: - p = "l_ulong *"; + p = "l_int *"; break; default: break; @@ -5660,6 +5663,16 @@ systrace_setargdesc(int sysnum, int ndx, break; /* linux_pipe2 */ case 331: + switch(ndx) { + case 0: + p = "l_int *"; + break; + case 1: + p = "l_int"; + break; + default: + break; + }; break; /* linux_inotify_init1 */ case 332: From owner-svn-src-stable-9@FreeBSD.ORG Tue Mar 19 20:46:51 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D74FFD6C; Tue, 19 Mar 2013 20:46:51 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (lor.one-eyed-alien.net [69.66.77.232]) by mx1.freebsd.org (Postfix) with ESMTP id 7CB5367F; Tue, 19 Mar 2013 20:46:49 +0000 (UTC) Received: from lor.one-eyed-alien.net (localhost [127.0.0.1]) by lor.one-eyed-alien.net (8.14.5/8.14.5) with ESMTP id r2JKksWR094240; Tue, 19 Mar 2013 15:46:54 -0500 (CDT) (envelope-from brooks@lor.one-eyed-alien.net) Received: (from brooks@localhost) by lor.one-eyed-alien.net (8.14.5/8.14.5/Submit) id r2JKkrsN094239; Tue, 19 Mar 2013 15:46:53 -0500 (CDT) (envelope-from brooks) Date: Tue, 19 Mar 2013 15:46:53 -0500 From: Brooks Davis To: John Baldwin Subject: Re: svn commit: r248331 - in stable/9: . usr.bin/xinstall Message-ID: <20130319204653.GD80942@lor.one-eyed-alien.net> References: <201303151519.r2FFJYjS060493@svn.freebsd.org> <20130318024922.GA24535@icarus.home.lan> <201303180945.57393.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Fig2xvG2VGoz8o/s" Content-Disposition: inline In-Reply-To: <201303180945.57393.jhb@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Mar 2013 20:46:51 -0000 --Fig2xvG2VGoz8o/s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 18, 2013 at 09:45:57AM -0400, John Baldwin wrote: > On Sunday, March 17, 2013 10:49:22 pm Jeremy Chadwick wrote: > > Please see PR 177055. This MFC has broken mergmaster for at least a > > couple people. The PR should really be rated high priority: Sorry I missed this earlier. I've backed out the change for now. Ironically, it only effects people who follow the instructions about mergemaster -p. If you get away with skipping that step then it just works. > > http://www.freebsd.org/cgi/query-pr.cgi?pr=3D177055 > >=20 > > http://lists.freebsd.org/pipermail/freebsd-stable/2013-March/072848.html >=20 > Probably breaks etcupdate as well. Both of these tools use the host's to= ols > and not the cross-built tools as they just run 'make distribute'. The ri= ght=20 > fix might be as simple as making those make targets use XMAKE so that if = a=20 > world is built they use the cross-built tools instead of the host's tools? I was wondering why they sets MAKEOBJDIRPREFIX at all. If they don't set it, then they would use the bootstrap tools that were already created. Regardless of the final fix in mergemaster and etcupdate, we also need to change the instructions in UPDATING. Users need to run "sh usr.sbin/mergemaster/mergemaster.sh -p" as that's the only way we can reliably survive requirement changes in the source tree. Does this seem like a generally acceptable change? -- Brooks P.S. In addition to requiring install -l, I'm planning to change HEAD to require nmtree in the not to distant future so that we can eliminate the last duplicate entries in METALOG by only listing each directly once in a .mtree file so it would be good to get this sorted out soon. --Fig2xvG2VGoz8o/s Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iD8DBQFRSM69XY6L6fI4GtQRAm+dAJ9U9fwgNPmV0N366rXrmN5Ly8kGEACeLHWK 1TeCfp4a+LMruwT5sAoRrkE= =agXo -----END PGP SIGNATURE----- --Fig2xvG2VGoz8o/s-- From owner-svn-src-stable-9@FreeBSD.ORG Wed Mar 20 00:13:49 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 230F778C; Wed, 20 Mar 2013 00:13:49 +0000 (UTC) (envelope-from marck@rinet.ru) Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68]) by mx1.freebsd.org (Postfix) with ESMTP id 79FCDE81; Wed, 20 Mar 2013 00:13:48 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by woozle.rinet.ru (8.14.5/8.14.5) with ESMTP id r2K0DkTP074703; Wed, 20 Mar 2013 04:13:46 +0400 (MSK) (envelope-from marck@rinet.ru) Date: Wed, 20 Mar 2013 04:13:46 +0400 (MSK) From: Dmitry Morozovsky To: Brooks Davis Subject: Re: svn commit: r248352 - in stable/9: etc share/mk In-Reply-To: <20130319200631.GC80942@lor.one-eyed-alien.net> Message-ID: References: <201303152132.r2FLWfwx076672@svn.freebsd.org> <20130319161239.GB80942@lor.one-eyed-alien.net> <20130319200631.GC80942@lor.one-eyed-alien.net> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) X-NCC-RegID: ru.rinet X-OpenPGP-Key-ID: 6B691B03 MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (woozle.rinet.ru [0.0.0.0]); Wed, 20 Mar 2013 04:13:47 +0400 (MSK) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2013 00:13:49 -0000 On Tue, 19 Mar 2013, Brooks Davis wrote: > > > > > Replace all known uses of ln in the build process with appropriate > > > > > install -l invocations via new INSTALL_LINK and INSTALL_SYMLINK > > > > > variables. > > > > > > > > It seems this merge breaks ``make distribution'' and hence mergemaster if your > > > > base system is not updated yet (for example, while updating jail): > > > > > > Sorry for the delay in responding. I missed this yesterday. > > > > > > It works for me on a older 9.0-STABLE system where the base install > > > doesn't support -l. Did you build world or run "make toolchain" in that > > > source tree to build the bootstrap copy of install? > > > > Yes, this is after full ``make buildworld buildkernel'' process. > > I've found the problem thanks to misc/177055. It is that mergemaster > (and etcupdate) set MAKEOBJDIRPREFIX to something in their > temporary directory and thus deprive themselves of bootstrap tools. > Unfortunately, I don't see a trivial fix so I've backed this out for > now and will work on this in HEAD. Thank you; hopefully some decent and balanced solution could be constructed for not too much effort ;) BTW: I'm really quite happy with your efforts to make build system more consistent; please do not by any means treat our cryticism as stop-point. -- Sincerely, D.Marck [DM5020, MCK-RIPE, DM3-RIPN] [ FreeBSD committer: marck@FreeBSD.org ] ------------------------------------------------------------------------ *** Dmitry Morozovsky --- D.Marck --- Wild Woozle --- marck@rinet.ru *** ------------------------------------------------------------------------ From owner-svn-src-stable-9@FreeBSD.ORG Wed Mar 20 05:49:11 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 3831E195; Wed, 20 Mar 2013 05:49:11 +0000 (UTC) (envelope-from bryanv@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1AB96D92; Wed, 20 Mar 2013 05:49:11 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2K5nABZ002374; Wed, 20 Mar 2013 05:49:10 GMT (envelope-from bryanv@svn.freebsd.org) Received: (from bryanv@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2K5nAWq002370; Wed, 20 Mar 2013 05:49:10 GMT (envelope-from bryanv@svn.freebsd.org) Message-Id: <201303200549.r2K5nAWq002370@svn.freebsd.org> From: Bryan Venteicher Date: Wed, 20 Mar 2013 05:49:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248544 - in stable/9/sys: amd64/conf conf i386/conf X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2013 05:49:11 -0000 Author: bryanv Date: Wed Mar 20 05:49:09 2013 New Revision: 248544 URL: http://svnweb.freebsd.org/changeset/base/248544 Log: MFC 247870: Remove the virtio dependency entry for the VirtIO device drivers. This will prevent the kernel from linking if the device driver are included without the virtio module. Remove pci and scbus for the same reason. Also explain the relationship and necessity of the virtio and virtio_pci modules. Currently in FreeBSD, we only support VirtIO PCI, but it could be replaced with a different interface (like MMIO) and the device (network, block, etc) will still function. Approved by: grehan (mentor) Modified: stable/9/sys/amd64/conf/NOTES stable/9/sys/conf/files.amd64 stable/9/sys/conf/files.i386 stable/9/sys/i386/conf/NOTES Directory Properties: stable/9/sys/ (props changed) stable/9/sys/conf/ (props changed) Modified: stable/9/sys/amd64/conf/NOTES ============================================================================== --- stable/9/sys/amd64/conf/NOTES Wed Mar 20 05:44:03 2013 (r248543) +++ stable/9/sys/amd64/conf/NOTES Wed Mar 20 05:49:09 2013 (r248544) @@ -442,6 +442,13 @@ options SAFE_RNDTEST # enable rndtest s # # VirtIO support +# +# The virtio entry provides a generic bus for use by the device drivers. +# It must be combined with an interface that communicates with the host. +# Multiple such interfaces defined by the VirtIO specification. FreeBSD +# only has support for PCI. Therefore, virtio_pci must be statically +# compiled in or loaded as a module for the device drivers to function. +# device virtio # Generic VirtIO bus (required) device virtio_pci # VirtIO PCI Interface device vtnet # VirtIO Ethernet device Modified: stable/9/sys/conf/files.amd64 ============================================================================== --- stable/9/sys/conf/files.amd64 Wed Mar 20 05:44:03 2013 (r248543) +++ stable/9/sys/conf/files.amd64 Wed Mar 20 05:49:09 2013 (r248544) @@ -385,11 +385,11 @@ dev/virtio/virtio.c optional virtio dev/virtio/virtqueue.c optional virtio dev/virtio/virtio_bus_if.m optional virtio dev/virtio/virtio_if.m optional virtio -dev/virtio/pci/virtio_pci.c optional virtio_pci virtio pci -dev/virtio/network/if_vtnet.c optional vtnet virtio -dev/virtio/block/virtio_blk.c optional virtio_blk virtio -dev/virtio/balloon/virtio_balloon.c optional virtio_balloon virtio -dev/virtio/scsi/virtio_scsi.c optional virtio_scsi virtio scbus +dev/virtio/pci/virtio_pci.c optional virtio_pci +dev/virtio/network/if_vtnet.c optional vtnet +dev/virtio/block/virtio_blk.c optional virtio_blk +dev/virtio/balloon/virtio_balloon.c optional virtio_balloon +dev/virtio/scsi/virtio_scsi.c optional virtio_scsi isa/syscons_isa.c optional sc isa/vga_isa.c optional vga kern/kern_clocksource.c standard Modified: stable/9/sys/conf/files.i386 ============================================================================== --- stable/9/sys/conf/files.i386 Wed Mar 20 05:44:03 2013 (r248543) +++ stable/9/sys/conf/files.i386 Wed Mar 20 05:49:09 2013 (r248544) @@ -363,11 +363,11 @@ dev/virtio/virtio.c optional virtio dev/virtio/virtqueue.c optional virtio dev/virtio/virtio_bus_if.m optional virtio dev/virtio/virtio_if.m optional virtio -dev/virtio/pci/virtio_pci.c optional virtio_pci virtio pci -dev/virtio/network/if_vtnet.c optional vtnet virtio -dev/virtio/block/virtio_blk.c optional virtio_blk virtio -dev/virtio/balloon/virtio_balloon.c optional virtio_balloon virtio -dev/virtio/scsi/virtio_scsi.c optional virtio_scsi virtio scbus +dev/virtio/pci/virtio_pci.c optional virtio_pci +dev/virtio/network/if_vtnet.c optional vtnet +dev/virtio/block/virtio_blk.c optional virtio_blk +dev/virtio/balloon/virtio_balloon.c optional virtio_balloon +dev/virtio/scsi/virtio_scsi.c optional virtio_scsi i386/acpica/acpi_machdep.c optional acpi acpi_wakecode.o optional acpi \ dependency "$S/i386/acpica/acpi_wakecode.S assym.s" \ Modified: stable/9/sys/i386/conf/NOTES ============================================================================== --- stable/9/sys/i386/conf/NOTES Wed Mar 20 05:44:03 2013 (r248543) +++ stable/9/sys/i386/conf/NOTES Wed Mar 20 05:49:09 2013 (r248544) @@ -773,6 +773,13 @@ device glxsb # AMD Geode LX Security B # # VirtIO support +# +# The virtio entry provides a generic bus for use by the device drivers. +# It must be combined with an interface that communicates with the host. +# Multiple such interfaces defined by the VirtIO specification. FreeBSD +# only has support for PCI. Therefore, virtio_pci must be statically +# compiled in or loaded as a module for the device drivers to function. +# device virtio # Generic VirtIO bus (required) device virtio_pci # VirtIO PCI Interface device vtnet # VirtIO Ethernet device From owner-svn-src-stable-9@FreeBSD.ORG Wed Mar 20 07:20:00 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AF764F3C; Wed, 20 Mar 2013 07:20:00 +0000 (UTC) (envelope-from melifaro@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9732ACC; Wed, 20 Mar 2013 07:20:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2K7K0Zq030068; Wed, 20 Mar 2013 07:20:00 GMT (envelope-from melifaro@svn.freebsd.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2K7K0mA030067; Wed, 20 Mar 2013 07:20:00 GMT (envelope-from melifaro@svn.freebsd.org) Message-Id: <201303200720.r2K7K0mA030067@svn.freebsd.org> From: "Alexander V. Chernikov" Date: Wed, 20 Mar 2013 07:20:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248546 - stable/9/sys/net X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2013 07:20:00 -0000 Author: melifaro Date: Wed Mar 20 07:20:00 2013 New Revision: 248546 URL: http://svnweb.freebsd.org/changeset/base/248546 Log: Merge r247842. Write lock is not required for find&compare operation. Modified: stable/9/sys/net/route.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/net/ (props changed) Modified: stable/9/sys/net/route.c ============================================================================== --- stable/9/sys/net/route.c Wed Mar 20 06:35:03 2013 (r248545) +++ stable/9/sys/net/route.c Wed Mar 20 07:20:00 2013 (r248546) @@ -1503,7 +1503,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int if (rnh == NULL) /* this table doesn't exist but others might */ continue; - RADIX_NODE_HEAD_LOCK(rnh); + RADIX_NODE_HEAD_RLOCK(rnh); #ifdef RADIX_MPATH if (rn_mpath_capable(rnh)) { @@ -1532,7 +1532,7 @@ rtinit1(struct ifaddr *ifa, int cmd, int (rn->rn_flags & RNF_ROOT) || RNTORT(rn)->rt_ifa != ifa || !sa_equal((struct sockaddr *)rn->rn_key, dst)); - RADIX_NODE_HEAD_UNLOCK(rnh); + RADIX_NODE_HEAD_RUNLOCK(rnh); if (error) { /* this is only an error if bad on ALL tables */ continue; From owner-svn-src-stable-9@FreeBSD.ORG Wed Mar 20 08:26:18 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 039FBB1D; Wed, 20 Mar 2013 08:26:18 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DACFB359; Wed, 20 Mar 2013 08:26:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2K8QHLE050529; Wed, 20 Mar 2013 08:26:17 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2K8QGaD050522; Wed, 20 Mar 2013 08:26:16 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201303200826.r2K8QGaD050522@svn.freebsd.org> From: Martin Matuska Date: Wed, 20 Mar 2013 08:26:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248547 - in stable/9: cddl/contrib/opensolaris/cmd/ztest sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2013 08:26:18 -0000 Author: mm Date: Wed Mar 20 08:26:16 2013 New Revision: 248547 URL: http://svnweb.freebsd.org/changeset/base/248547 Log: MFC r242845, r247592: MFC r242845 (delphij): Illumos r13840:97fd5cdf328a: 3145 single-copy arc 3212 ztest: race condition between vdev_online() and spa_vdev_remove() Illumos r13849:3468a95b27cd: 3258 ztest's use of file descriptors is unstable MFC r247592 (delphij): Import a fix tighten assertion on SPA versions from vendor (Illumos). Illumos ZFS issue: 3543 Feature flags causes assertion in spa.c to miss certain cases Approved by: delphij Modified: stable/9/cddl/contrib/opensolaris/cmd/ztest/ztest.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h Directory Properties: stable/9/cddl/contrib/opensolaris/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) Modified: stable/9/cddl/contrib/opensolaris/cmd/ztest/ztest.c ============================================================================== --- stable/9/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Mar 20 07:20:00 2013 (r248546) +++ stable/9/cddl/contrib/opensolaris/cmd/ztest/ztest.c Wed Mar 20 08:26:16 2013 (r248547) @@ -121,8 +121,8 @@ #include #include -#define ZTEST_FD_DATA 3 -#define ZTEST_FD_RAND 4 +static int ztest_fd_data = -1; +static int ztest_fd_rand = -1; typedef struct ztest_shared_hdr { uint64_t zh_hdr_size; @@ -713,14 +713,17 @@ process_options(int argc, char **argv) UINT64_MAX >> 2); if (strlen(altdir) > 0) { - char cmd[MAXNAMELEN]; - char realaltdir[MAXNAMELEN]; + char *cmd; + char *realaltdir; char *bin; char *ztest; char *isa; int isalen; - (void) realpath(getexecname(), cmd); + cmd = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); + realaltdir = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); + + VERIFY(NULL != realpath(getexecname(), cmd)); if (0 != access(altdir, F_OK)) { ztest_dump_core = B_FALSE; fatal(B_TRUE, "invalid alternate ztest path: %s", @@ -751,6 +754,9 @@ process_options(int argc, char **argv) fatal(B_TRUE, "invalid alternate lib directory %s", zo->zo_alt_libpath); } + + umem_free(cmd, MAXPATHLEN); + umem_free(realaltdir, MAXPATHLEN); } } @@ -767,10 +773,12 @@ ztest_random(uint64_t range) { uint64_t r; + ASSERT3S(ztest_fd_rand, >=, 0); + if (range == 0) return (0); - if (read(ZTEST_FD_RAND, &r, sizeof (r)) != sizeof (r)) + if (read(ztest_fd_rand, &r, sizeof (r)) != sizeof (r)) fatal(1, "short read from /dev/urandom"); return (r % range); @@ -4836,7 +4844,18 @@ ztest_fault_inject(ztest_ds_t *zd, uint6 if (islog) (void) rw_unlock(&ztest_name_lock); } else { + /* + * Ideally we would like to be able to randomly + * call vdev_[on|off]line without holding locks + * to force unpredictable failures but the side + * effects of vdev_[on|off]line prevent us from + * doing so. We grab the ztest_vdev_lock here to + * prevent a race between injection testing and + * aux_vdev removal. + */ + VERIFY(mutex_lock(&ztest_vdev_lock) == 0); (void) vdev_online(spa, guid0, 0, NULL); + VERIFY(mutex_unlock(&ztest_vdev_lock) == 0); } } @@ -5795,29 +5814,16 @@ ztest_init(ztest_shared_t *zs) } static void -setup_fds(void) +setup_data_fd(void) { - int fd; -#ifdef illumos - - char *tmp = tempnam(NULL, NULL); - fd = open(tmp, O_RDWR | O_CREAT, 0700); - ASSERT3U(fd, ==, ZTEST_FD_DATA); - (void) unlink(tmp); - free(tmp); -#else - char tmp[MAXPATHLEN]; - - strlcpy(tmp, ztest_opts.zo_dir, MAXPATHLEN); - strlcat(tmp, "/ztest.XXXXXX", MAXPATHLEN); - fd = mkstemp(tmp); - ASSERT3U(fd, ==, ZTEST_FD_DATA); -#endif + static char ztest_name_data[] = "/tmp/ztest.data.XXXXXX"; - fd = open("/dev/urandom", O_RDONLY); - ASSERT3U(fd, ==, ZTEST_FD_RAND); + ztest_fd_data = mkstemp(ztest_name_data); + ASSERT3S(ztest_fd_data, >=, 0); + (void) unlink(ztest_name_data); } + static int shared_data_size(ztest_shared_hdr_t *hdr) { @@ -5838,15 +5844,11 @@ setup_hdr(void) int size; ztest_shared_hdr_t *hdr; -#ifndef illumos - pwrite(ZTEST_FD_DATA, "", 1, 0); -#endif - hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()), - PROT_READ | PROT_WRITE, MAP_SHARED, ZTEST_FD_DATA, 0); + PROT_READ | PROT_WRITE, MAP_SHARED, ztest_fd_data, 0); ASSERT(hdr != MAP_FAILED); - VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, sizeof (ztest_shared_hdr_t))); + VERIFY3U(0, ==, ftruncate(ztest_fd_data, sizeof (ztest_shared_hdr_t))); hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t); hdr->zh_opts_size = sizeof (ztest_shared_opts_t); @@ -5857,7 +5859,7 @@ setup_hdr(void) hdr->zh_ds_count = ztest_opts.zo_datasets; size = shared_data_size(hdr); - VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, size)); + VERIFY3U(0, ==, ftruncate(ztest_fd_data, size)); (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize())); } @@ -5870,14 +5872,14 @@ setup_data(void) uint8_t *buf; hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()), - PROT_READ, MAP_SHARED, ZTEST_FD_DATA, 0); + PROT_READ, MAP_SHARED, ztest_fd_data, 0); ASSERT(hdr != MAP_FAILED); size = shared_data_size(hdr); (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize())); hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()), - PROT_READ | PROT_WRITE, MAP_SHARED, ZTEST_FD_DATA, 0); + PROT_READ | PROT_WRITE, MAP_SHARED, ztest_fd_data, 0); ASSERT(hdr != MAP_FAILED); buf = (uint8_t *)hdr; @@ -5896,12 +5898,13 @@ exec_child(char *cmd, char *libpath, boo { pid_t pid; int status; - char cmdbuf[MAXPATHLEN]; + char *cmdbuf = NULL; pid = fork(); if (cmd == NULL) { - (void) strlcpy(cmdbuf, getexecname(), sizeof (cmdbuf)); + cmdbuf = umem_alloc(MAXPATHLEN, UMEM_NOFAIL); + (void) strlcpy(cmdbuf, getexecname(), MAXPATHLEN); cmd = cmdbuf; } @@ -5910,9 +5913,16 @@ exec_child(char *cmd, char *libpath, boo if (pid == 0) { /* child */ char *emptyargv[2] = { cmd, NULL }; + char fd_data_str[12]; struct rlimit rl = { 1024, 1024 }; (void) setrlimit(RLIMIT_NOFILE, &rl); + + (void) close(ztest_fd_rand); + VERIFY3U(11, >=, + snprintf(fd_data_str, 12, "%d", ztest_fd_data)); + VERIFY0(setenv("ZTEST_FD_DATA", fd_data_str, 1)); + (void) enable_extended_FILE_stdio(-1, -1); if (libpath != NULL) VERIFY(0 == setenv("LD_LIBRARY_PATH", libpath, 1)); @@ -5925,6 +5935,11 @@ exec_child(char *cmd, char *libpath, boo fatal(B_TRUE, "exec failed: %s", cmd); } + if (cmdbuf != NULL) { + umem_free(cmdbuf, MAXPATHLEN); + cmd = NULL; + } + while (waitpid(pid, &status, 0) != pid) continue; if (statusp != NULL) @@ -5989,39 +6004,41 @@ main(int argc, char **argv) char timebuf[100]; char numbuf[6]; spa_t *spa; - char cmd[MAXNAMELEN]; + char *cmd; boolean_t hasalt; - - boolean_t ischild = (0 == lseek(ZTEST_FD_DATA, 0, SEEK_CUR)); - ASSERT(ischild || errno == EBADF); + char *fd_data_str = getenv("ZTEST_FD_DATA"); (void) setvbuf(stdout, NULL, _IOLBF, 0); dprintf_setup(&argc, argv); - if (!ischild) { + ztest_fd_rand = open("/dev/urandom", O_RDONLY); + ASSERT3S(ztest_fd_rand, >=, 0); + + if (!fd_data_str) { process_options(argc, argv); - setup_fds(); + setup_data_fd(); setup_hdr(); setup_data(); bcopy(&ztest_opts, ztest_shared_opts, sizeof (*ztest_shared_opts)); } else { + ztest_fd_data = atoi(fd_data_str); setup_data(); bcopy(ztest_shared_opts, &ztest_opts, sizeof (ztest_opts)); } ASSERT3U(ztest_opts.zo_datasets, ==, ztest_shared_hdr->zh_ds_count); /* Override location of zpool.cache */ - (void) asprintf((char **)&spa_config_path, "%s/zpool.cache", - ztest_opts.zo_dir); + VERIFY3U(asprintf((char **)&spa_config_path, "%s/zpool.cache", + ztest_opts.zo_dir), !=, -1); ztest_ds = umem_alloc(ztest_opts.zo_datasets * sizeof (ztest_ds_t), UMEM_NOFAIL); zs = ztest_shared; - if (ischild) { + if (fd_data_str) { metaslab_gang_bang = ztest_opts.zo_metaslab_gang_bang; metaslab_df_alloc_threshold = zs->zs_metaslab_df_alloc_threshold; @@ -6044,7 +6061,8 @@ main(int argc, char **argv) (u_longlong_t)ztest_opts.zo_time); } - (void) strlcpy(cmd, getexecname(), sizeof (cmd)); + cmd = umem_alloc(MAXNAMELEN, UMEM_NOFAIL); + (void) strlcpy(cmd, getexecname(), MAXNAMELEN); zs->zs_do_init = B_TRUE; if (strlen(ztest_opts.zo_alt_ztest) != 0) { @@ -6185,5 +6203,7 @@ main(int argc, char **argv) kills, iters - kills, (100.0 * kills) / MAX(1, iters)); } + umem_free(cmd, MAXNAMELEN); + return (0); } Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Wed Mar 20 07:20:00 2013 (r248546) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Wed Mar 20 08:26:16 2013 (r248547) @@ -191,6 +191,7 @@ uint64_t zfs_arc_meta_limit = 0; int zfs_arc_grow_retry = 0; int zfs_arc_shrink_shift = 0; int zfs_arc_p_min_shift = 0; +int zfs_disable_dup_eviction = 0; TUNABLE_QUAD("vfs.zfs.arc_max", &zfs_arc_max); TUNABLE_QUAD("vfs.zfs.arc_min", &zfs_arc_min); @@ -321,7 +322,6 @@ typedef struct arc_stats { kstat_named_t arcstat_l2_io_error; kstat_named_t arcstat_l2_size; kstat_named_t arcstat_l2_hdr_size; - kstat_named_t arcstat_memory_throttle_count; kstat_named_t arcstat_l2_write_trylock_fail; kstat_named_t arcstat_l2_write_passed_headroom; kstat_named_t arcstat_l2_write_spa_mismatch; @@ -334,6 +334,10 @@ typedef struct arc_stats { kstat_named_t arcstat_l2_write_buffer_bytes_scanned; kstat_named_t arcstat_l2_write_buffer_list_iter; kstat_named_t arcstat_l2_write_buffer_list_null_iter; + kstat_named_t arcstat_memory_throttle_count; + kstat_named_t arcstat_duplicate_buffers; + kstat_named_t arcstat_duplicate_buffers_size; + kstat_named_t arcstat_duplicate_reads; } arc_stats_t; static arc_stats_t arc_stats = { @@ -391,7 +395,6 @@ static arc_stats_t arc_stats = { { "l2_io_error", KSTAT_DATA_UINT64 }, { "l2_size", KSTAT_DATA_UINT64 }, { "l2_hdr_size", KSTAT_DATA_UINT64 }, - { "memory_throttle_count", KSTAT_DATA_UINT64 }, { "l2_write_trylock_fail", KSTAT_DATA_UINT64 }, { "l2_write_passed_headroom", KSTAT_DATA_UINT64 }, { "l2_write_spa_mismatch", KSTAT_DATA_UINT64 }, @@ -403,7 +406,11 @@ static arc_stats_t arc_stats = { { "l2_write_pios", KSTAT_DATA_UINT64 }, { "l2_write_buffer_bytes_scanned", KSTAT_DATA_UINT64 }, { "l2_write_buffer_list_iter", KSTAT_DATA_UINT64 }, - { "l2_write_buffer_list_null_iter", KSTAT_DATA_UINT64 } + { "l2_write_buffer_list_null_iter", KSTAT_DATA_UINT64 }, + { "memory_throttle_count", KSTAT_DATA_UINT64 }, + { "duplicate_buffers", KSTAT_DATA_UINT64 }, + { "duplicate_buffers_size", KSTAT_DATA_UINT64 }, + { "duplicate_reads", KSTAT_DATA_UINT64 } }; #define ARCSTAT(stat) (arc_stats.stat.value.ui64) @@ -1516,6 +1523,17 @@ arc_buf_clone(arc_buf_t *from) hdr->b_buf = buf; arc_get_data_buf(buf); bcopy(from->b_data, buf->b_data, size); + + /* + * This buffer already exists in the arc so create a duplicate + * copy for the caller. If the buffer is associated with user data + * then track the size and number of duplicates. These stats will be + * updated as duplicate buffers are created and destroyed. + */ + if (hdr->b_type == ARC_BUFC_DATA) { + ARCSTAT_BUMP(arcstat_duplicate_buffers); + ARCSTAT_INCR(arcstat_duplicate_buffers_size, size); + } hdr->b_datacnt += 1; return (buf); } @@ -1616,6 +1634,16 @@ arc_buf_destroy(arc_buf_t *buf, boolean_ ASSERT3U(state->arcs_size, >=, size); atomic_add_64(&state->arcs_size, -size); buf->b_data = NULL; + + /* + * If we're destroying a duplicate buffer make sure + * that the appropriate statistics are updated. + */ + if (buf->b_hdr->b_datacnt > 1 && + buf->b_hdr->b_type == ARC_BUFC_DATA) { + ARCSTAT_BUMPDOWN(arcstat_duplicate_buffers); + ARCSTAT_INCR(arcstat_duplicate_buffers_size, -size); + } ASSERT(buf->b_hdr->b_datacnt > 0); buf->b_hdr->b_datacnt -= 1; } @@ -1800,6 +1828,48 @@ arc_buf_size(arc_buf_t *buf) } /* + * Called from the DMU to determine if the current buffer should be + * evicted. In order to ensure proper locking, the eviction must be initiated + * from the DMU. Return true if the buffer is associated with user data and + * duplicate buffers still exist. + */ +boolean_t +arc_buf_eviction_needed(arc_buf_t *buf) +{ + arc_buf_hdr_t *hdr; + boolean_t evict_needed = B_FALSE; + + if (zfs_disable_dup_eviction) + return (B_FALSE); + + mutex_enter(&buf->b_evict_lock); + hdr = buf->b_hdr; + if (hdr == NULL) { + /* + * We are in arc_do_user_evicts(); let that function + * perform the eviction. + */ + ASSERT(buf->b_data == NULL); + mutex_exit(&buf->b_evict_lock); + return (B_FALSE); + } else if (buf->b_data == NULL) { + /* + * We have already been added to the arc eviction list; + * recommend eviction. + */ + ASSERT3P(hdr, ==, &arc_eviction_hdr); + mutex_exit(&buf->b_evict_lock); + return (B_TRUE); + } + + if (hdr->b_datacnt > 1 && hdr->b_type == ARC_BUFC_DATA) + evict_needed = B_TRUE; + + mutex_exit(&buf->b_evict_lock); + return (evict_needed); +} + +/* * Evict buffers from list until we've removed the specified number of * bytes. Move the removed buffers to the appropriate evict state. * If the recycle flag is set, then attempt to "recycle" a buffer: @@ -2885,8 +2955,10 @@ arc_read_done(zio_t *zio) abuf = buf; for (acb = callback_list; acb; acb = acb->acb_next) { if (acb->acb_done) { - if (abuf == NULL) + if (abuf == NULL) { + ARCSTAT_BUMP(arcstat_duplicate_reads); abuf = arc_buf_clone(buf); + } acb->acb_buf = abuf; abuf = NULL; } @@ -3405,6 +3477,16 @@ arc_release(arc_buf_t *buf, void *tag) ASSERT3U(*size, >=, hdr->b_size); atomic_add_64(size, -hdr->b_size); } + + /* + * We're releasing a duplicate user data buffer, update + * our statistics accordingly. + */ + if (hdr->b_type == ARC_BUFC_DATA) { + ARCSTAT_BUMPDOWN(arcstat_duplicate_buffers); + ARCSTAT_INCR(arcstat_duplicate_buffers_size, + -hdr->b_size); + } hdr->b_datacnt -= 1; arc_cksum_verify(buf); #ifdef illumos Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Wed Mar 20 07:20:00 2013 (r248546) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Wed Mar 20 08:26:16 2013 (r248547) @@ -2071,7 +2071,24 @@ dbuf_rele_and_unlock(dmu_buf_impl_t *db, dbuf_evict(db); } else { VERIFY(arc_buf_remove_ref(db->db_buf, db) == 0); - if (!DBUF_IS_CACHEABLE(db)) + + /* + * A dbuf will be eligible for eviction if either the + * 'primarycache' property is set or a duplicate + * copy of this buffer is already cached in the arc. + * + * In the case of the 'primarycache' a buffer + * is considered for eviction if it matches the + * criteria set in the property. + * + * To decide if our buffer is considered a + * duplicate, we must call into the arc to determine + * if multiple buffers are referencing the same + * block on-disk. If so, then we simply evict + * ourselves. + */ + if (!DBUF_IS_CACHEABLE(db) || + arc_buf_eviction_needed(db->db_buf)) dbuf_clear(db); else mutex_exit(&db->db_mtx); Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Wed Mar 20 07:20:00 2013 (r248546) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Wed Mar 20 08:26:16 2013 (r248547) @@ -6001,7 +6001,7 @@ spa_sync_version(void *arg1, void *arg2, */ ASSERT(tx->tx_txg != TXG_INITIAL); - ASSERT(version <= SPA_VERSION); + ASSERT(SPA_VERSION_IS_SUPPORTED(version)); ASSERT(version >= spa_version(spa)); spa->spa_uberblock.ub_version = version; @@ -6542,7 +6542,7 @@ spa_upgrade(spa_t *spa, uint64_t version * future version would result in an unopenable pool, this shouldn't be * possible. */ - ASSERT(spa->spa_uberblock.ub_version <= SPA_VERSION); + ASSERT(SPA_VERSION_IS_SUPPORTED(spa->spa_uberblock.ub_version)); ASSERT(version >= spa->spa_uberblock.ub_version); spa->spa_uberblock.ub_version = version; Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h Wed Mar 20 07:20:00 2013 (r248546) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/arc.h Wed Mar 20 08:26:16 2013 (r248547) @@ -96,6 +96,7 @@ int arc_released(arc_buf_t *buf); int arc_has_callback(arc_buf_t *buf); void arc_buf_freeze(arc_buf_t *buf); void arc_buf_thaw(arc_buf_t *buf); +boolean_t arc_buf_eviction_needed(arc_buf_t *buf); #ifdef ZFS_DEBUG int arc_referenced(arc_buf_t *buf); #endif From owner-svn-src-stable-9@FreeBSD.ORG Wed Mar 20 09:12:29 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 180629BF; Wed, 20 Mar 2013 09:12:29 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0A04183E; Wed, 20 Mar 2013 09:12:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2K9CS6U065458; Wed, 20 Mar 2013 09:12:28 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2K9CSKB065457; Wed, 20 Mar 2013 09:12:28 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201303200912.r2K9CSKB065457@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Wed, 20 Mar 2013 09:12:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248549 - stable/9/sys/netinet6 X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2013 09:12:29 -0000 Author: ae Date: Wed Mar 20 09:12:28 2013 New Revision: 248549 URL: http://svnweb.freebsd.org/changeset/base/248549 Log: MFC r248180: Take the inpcb rlock before calculating checksum, it was accidentally moved in r191672. Modified: stable/9/sys/netinet6/raw_ip6.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/netinet6/raw_ip6.c ============================================================================== --- stable/9/sys/netinet6/raw_ip6.c Wed Mar 20 08:34:30 2013 (r248548) +++ stable/9/sys/netinet6/raw_ip6.c Wed Mar 20 09:12:28 2013 (r248549) @@ -197,6 +197,7 @@ rip6_input(struct mbuf **mp, int *offp, &ip6->ip6_dst) != 0) continue; } + INP_RLOCK(in6p); if (in6p->in6p_cksum != -1) { V_rip6stat.rip6s_isum++; if (in6_cksum(m, proto, *offp, @@ -206,7 +207,6 @@ rip6_input(struct mbuf **mp, int *offp, continue; } } - INP_RLOCK(in6p); /* * If this raw socket has multicast state, and we * have received a multicast, check if this socket From owner-svn-src-stable-9@FreeBSD.ORG Wed Mar 20 18:43:53 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id BE223AC2; Wed, 20 Mar 2013 18:43:53 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 93475D28; Wed, 20 Mar 2013 18:43:53 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 025D2B917; Wed, 20 Mar 2013 14:43:53 -0400 (EDT) From: John Baldwin To: Brooks Davis Subject: Re: svn commit: r248352 - in stable/9: etc share/mk Date: Wed, 20 Mar 2013 09:18:08 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: <201303152132.r2FLWfwx076672@svn.freebsd.org> <20130319200631.GC80942@lor.one-eyed-alien.net> In-Reply-To: <20130319200631.GC80942@lor.one-eyed-alien.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201303200918.08803.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 20 Mar 2013 14:43:53 -0400 (EDT) Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Dmitry Morozovsky , svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2013 18:43:53 -0000 On Tuesday, March 19, 2013 4:06:31 pm Brooks Davis wrote: > On Tue, Mar 19, 2013 at 09:49:47PM +0400, Dmitry Morozovsky wrote: > > On Tue, 19 Mar 2013, Brooks Davis wrote: > > > > > > > Replace all known uses of ln in the build process with appropriate > > > > > install -l invocations via new INSTALL_LINK and INSTALL_SYMLINK > > > > > variables. > > > > > > > > It seems this merge breaks ``make distribution'' and hence mergemaster if your > > > > base system is not updated yet (for example, while updating jail): > > > > > > Sorry for the delay in responding. I missed this yesterday. > > > > > > It works for me on a older 9.0-STABLE system where the base install > > > doesn't support -l. Did you build world or run "make toolchain" in that > > > source tree to build the bootstrap copy of install? > > > > Yes, this is after full ``make buildworld buildkernel'' process. > > I've found the problem thanks to misc/177055. It is that mergemaster > (and etcupdate) set MAKEOBJDIRPREFIX to something in their > temporary directory and thus deprive themselves of bootstrap tools. > Unfortunately, I don't see a trivial fix so I've backed this out for > now and will work on this in HEAD. Hummmm. In the case of etcupdate you can use 'etcupdate -B'. That is actually safe to do in the common case where you've just updated /usr/src and built the corresponding world in /usr/obj. It should possibly even by the default for etcupdate if a DESTDIR is not specified. -- John Baldwin From owner-svn-src-stable-9@FreeBSD.ORG Thu Mar 21 16:15:35 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 7F0F95B6; Thu, 21 Mar 2013 16:15:35 +0000 (UTC) (envelope-from tijl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 588AB74A; Thu, 21 Mar 2013 16:15:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2LGFZa7038245; Thu, 21 Mar 2013 16:15:35 GMT (envelope-from tijl@svn.freebsd.org) Received: (from tijl@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2LGFZOj038244; Thu, 21 Mar 2013 16:15:35 GMT (envelope-from tijl@svn.freebsd.org) Message-Id: <201303211615.r2LGFZOj038244@svn.freebsd.org> From: Tijl Coosemans Date: Thu, 21 Mar 2013 16:15:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248587 - stable/9/sys/kern X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Mar 2013 16:15:35 -0000 Author: tijl Date: Thu Mar 21 16:15:34 2013 New Revision: 248587 URL: http://svnweb.freebsd.org/changeset/base/248587 Log: - Fix two possible overflows when testing if ELF program headers are on the first page: 1. Cast uint16_t operands in a multiplication to unsigned int because otherwise the implicit promotion to int results in a signed multiplication that can overflow and the behaviour on integer overflow is undefined. 2. Replace (offset + size > PAGE_SIZE) with (size > PAGE_SIZE - offset) because the sum may overflow. - Use the same tests to see if the path to the interpreter is on the first page. There's no overflow here because size is already limited by MAXPATHLEN, but the compiler optimises the new tests better. Also fix an off-by-one error. - Simplify tests to see if an ELF note program header is on the first page. This also fixes an off-by-one error. Reviewed by: kib Modified: stable/9/sys/kern/imgact_elf.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/kern/imgact_elf.c ============================================================================== --- stable/9/sys/kern/imgact_elf.c Thu Mar 21 16:04:34 2013 (r248586) +++ stable/9/sys/kern/imgact_elf.c Thu Mar 21 16:15:34 2013 (r248587) @@ -663,9 +663,8 @@ __elfN(load_file)(struct proc *p, const } /* Only support headers that fit within first page for now */ - /* (multiplication of two Elf_Half fields will not overflow) */ if ((hdr->e_phoff > PAGE_SIZE) || - (hdr->e_phentsize * hdr->e_phnum) > PAGE_SIZE - hdr->e_phoff) { + (u_int)hdr->e_phentsize * hdr->e_phnum > PAGE_SIZE - hdr->e_phoff) { error = ENOEXEC; goto fail; } @@ -747,7 +746,7 @@ __CONCAT(exec_, __elfN(imgact))(struct i */ if ((hdr->e_phoff > PAGE_SIZE) || - (hdr->e_phoff + hdr->e_phentsize * hdr->e_phnum) > PAGE_SIZE) { + (u_int)hdr->e_phentsize * hdr->e_phnum > PAGE_SIZE - hdr->e_phoff) { /* Only support headers in first page for now */ return (ENOEXEC); } @@ -766,8 +765,8 @@ __CONCAT(exec_, __elfN(imgact))(struct i case PT_INTERP: /* Path to interpreter */ if (phdr[i].p_filesz > MAXPATHLEN || - phdr[i].p_offset >= PAGE_SIZE || - phdr[i].p_offset + phdr[i].p_filesz >= PAGE_SIZE) + phdr[i].p_offset > PAGE_SIZE || + phdr[i].p_filesz > PAGE_SIZE - phdr[i].p_offset) return (ENOEXEC); interp = imgp->image_header + phdr[i].p_offset; interp_name_len = phdr[i].p_filesz; @@ -1555,9 +1554,8 @@ __elfN(parse_notes)(struct image_params const char *note_name; int i; - if (pnote == NULL || pnote->p_offset >= PAGE_SIZE || - pnote->p_filesz > PAGE_SIZE || - pnote->p_offset + pnote->p_filesz >= PAGE_SIZE) + if (pnote == NULL || pnote->p_offset > PAGE_SIZE || + pnote->p_filesz > PAGE_SIZE - pnote->p_offset) return (FALSE); note = note0 = (const Elf_Note *)(imgp->image_header + pnote->p_offset); From owner-svn-src-stable-9@FreeBSD.ORG Thu Mar 21 16:18:10 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5731A756; Thu, 21 Mar 2013 16:18:10 +0000 (UTC) (envelope-from tijl@coosemans.org) Received: from mailrelay020.isp.belgacom.be (Mailrelay020.isp.belgacom.be [195.238.6.95]) by mx1.freebsd.org (Postfix) with ESMTP id 4CF41772; Thu, 21 Mar 2013 16:18:08 +0000 (UTC) X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgIFAMYwS1Fbs6OL/2dsb2JhbABDiCG9F4FZF3SCJAEBBSMzIgEQCxQEAgIFFgsCAgkDAgECASceBg0BBwEBiBQIsDaSQYEjjDiBNgeCLYETA5gDj2ODCzuBLg Received: from 139.163-179-91.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([91.179.163.139]) by relay.skynet.be with ESMTP; 21 Mar 2013 17:16:58 +0100 Received: from kalimero.tijl.coosemans.org (kalimero.tijl.coosemans.org [127.0.0.1]) by kalimero.tijl.coosemans.org (8.14.6/8.14.6) with ESMTP id r2LGGvaR014337; Thu, 21 Mar 2013 17:16:57 +0100 (CET) (envelope-from tijl@coosemans.org) Message-ID: <514B3279.7010404@coosemans.org> Date: Thu, 21 Mar 2013 17:16:57 +0100 From: Tijl Coosemans User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:17.0) Gecko/20130315 Thunderbird/17.0.4 MIME-Version: 1.0 To: Tijl Coosemans Subject: Re: svn commit: r248587 - stable/9/sys/kern References: <201303211615.r2LGFZOj038244@svn.freebsd.org> In-Reply-To: <201303211615.r2LGFZOj038244@svn.freebsd.org> X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: svn-src-stable@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, svn-src-stable-9@freebsd.org X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Mar 2013 16:18:10 -0000 On 2013-03-21 17:15, Tijl Coosemans wrote: > Author: tijl > Date: Thu Mar 21 16:15:34 2013 > New Revision: 248587 > URL: http://svnweb.freebsd.org/changeset/base/248587 > > Log: > - Fix two possible overflows when testing if ELF program headers are on > the first page: > 1. Cast uint16_t operands in a multiplication to unsigned int because > otherwise the implicit promotion to int results in a signed > multiplication that can overflow and the behaviour on integer > overflow is undefined. > 2. Replace (offset + size > PAGE_SIZE) with (size > PAGE_SIZE - offset) > because the sum may overflow. > - Use the same tests to see if the path to the interpreter is on the first > page. There's no overflow here because size is already limited by > MAXPATHLEN, but the compiler optimises the new tests better. Also fix an > off-by-one error. > - Simplify tests to see if an ELF note program header is on the first page. > This also fixes an off-by-one error. > > Reviewed by: kib Forgot to mention: MFC r248256 From owner-svn-src-stable-9@FreeBSD.ORG Thu Mar 21 23:37:37 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 07B5EBD9; Thu, 21 Mar 2013 23:37:37 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id DFAE71C5; Thu, 21 Mar 2013 23:37:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2LNbaM2074138; Thu, 21 Mar 2013 23:37:36 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2LNbZ2p074128; Thu, 21 Mar 2013 23:37:35 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201303212337.r2LNbZ2p074128@svn.freebsd.org> From: Xin LI Date: Thu, 21 Mar 2013 23:37:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248604 - stable/9/crypto/openssl/ssl X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Mar 2013 23:37:37 -0000 Author: delphij Date: Thu Mar 21 23:37:35 2013 New Revision: 248604 URL: http://svnweb.freebsd.org/changeset/base/248604 Log: MFV r248595: - Integrate OpenSSL revisions fb092ef4fca897344daf7189526f5f26be6487ce, a93cc7c57333f4538cbcdedd2e961a5a38caa52d, and 76c61a5d1adb92388f39e585e4af860a20feb9bb. This removes the newly added orig_len field of SSL3_RECORD and restored ABI. Approved by: benl Modified: stable/9/crypto/openssl/ssl/d1_pkt.c stable/9/crypto/openssl/ssl/s3_cbc.c stable/9/crypto/openssl/ssl/s3_enc.c stable/9/crypto/openssl/ssl/s3_pkt.c stable/9/crypto/openssl/ssl/ssl3.h stable/9/crypto/openssl/ssl/ssl_locl.h stable/9/crypto/openssl/ssl/t1_enc.c Directory Properties: stable/9/crypto/openssl/ (props changed) Modified: stable/9/crypto/openssl/ssl/d1_pkt.c ============================================================================== --- stable/9/crypto/openssl/ssl/d1_pkt.c Thu Mar 21 23:07:04 2013 (r248603) +++ stable/9/crypto/openssl/ssl/d1_pkt.c Thu Mar 21 23:37:35 2013 (r248604) @@ -330,8 +330,8 @@ dtls1_process_record(SSL *s) int i,al; int enc_err; SSL_SESSION *sess; - SSL3_RECORD *rr; - unsigned int mac_size; + SSL3_RECORD *rr; + unsigned int mac_size, orig_len; unsigned char md[EVP_MAX_MD_SIZE]; rr= &(s->s3->rrec); @@ -362,7 +362,7 @@ dtls1_process_record(SSL *s) /* decrypt in place in 'rr->input' */ rr->data=rr->input; - rr->orig_len=rr->length; + orig_len=rr->length; enc_err = s->method->ssl3_enc->enc(s,0); /* enc_err is: @@ -399,10 +399,10 @@ printf("\n"); * therefore we can safely process the record in a different * amount of time if it's too short to possibly contain a MAC. */ - if (rr->orig_len < mac_size || + if (orig_len < mac_size || /* CBC records must have a padding length byte too. */ (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE && - rr->orig_len < mac_size+1)) + orig_len < mac_size+1)) { al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_DTLS1_PROCESS_RECORD,SSL_R_LENGTH_TOO_SHORT); @@ -417,12 +417,12 @@ printf("\n"); * without leaking the contents of the padding bytes. * */ mac = mac_tmp; - ssl3_cbc_copy_mac(mac_tmp, rr, mac_size); + ssl3_cbc_copy_mac(mac_tmp, rr, mac_size, orig_len); rr->length -= mac_size; } else { - /* In this case there's no padding, so |rec->orig_len| + /* In this case there's no padding, so |orig_len| * equals |rec->length| and we checked that there's * enough bytes for |mac_size| above. */ rr->length -= mac_size; Modified: stable/9/crypto/openssl/ssl/s3_cbc.c ============================================================================== --- stable/9/crypto/openssl/ssl/s3_cbc.c Thu Mar 21 23:07:04 2013 (r248603) +++ stable/9/crypto/openssl/ssl/s3_cbc.c Thu Mar 21 23:37:35 2013 (r248604) @@ -116,7 +116,9 @@ int ssl3_cbc_remove_padding(const SSL* s good = constant_time_ge(rec->length, padding_length+overhead); /* SSLv3 requires that the padding is minimal. */ good &= constant_time_ge(block_size, padding_length+1); - rec->length -= good & (padding_length+1); + padding_length = good & (padding_length+1); + rec->length -= padding_length; + rec->type |= padding_length<<8; /* kludge: pass padding length */ return (int)((good & 1) | (~good & -1)); } @@ -202,7 +204,9 @@ int tls1_cbc_remove_padding(const SSL* s good <<= sizeof(good)*8-1; good = DUPLICATE_MSB_TO_ALL(good); - rec->length -= good & (padding_length+1); + padding_length = good & (padding_length+1); + rec->length -= padding_length; + rec->type |= padding_length<<8; /* kludge: pass padding length */ /* We can always safely skip the explicit IV. We check at the beginning * of this function that the record has at least enough space for the @@ -217,7 +221,6 @@ int tls1_cbc_remove_padding(const SSL* s rec->data += block_size; rec->input += block_size; rec->length -= block_size; - rec->orig_len -= block_size; } return (int)((good & 1) | (~good & -1)); @@ -245,7 +248,7 @@ int tls1_cbc_remove_padding(const SSL* s */ void ssl3_cbc_copy_mac(unsigned char* out, const SSL3_RECORD *rec, - unsigned md_size) + unsigned md_size,unsigned orig_len) { #if defined(CBC_MAC_ROTATE_IN_PLACE) unsigned char rotated_mac_buf[EVP_MAX_MD_SIZE*2]; @@ -264,7 +267,7 @@ void ssl3_cbc_copy_mac(unsigned char* ou unsigned div_spoiler; unsigned rotate_offset; - OPENSSL_assert(rec->orig_len >= md_size); + OPENSSL_assert(orig_len >= md_size); OPENSSL_assert(md_size <= EVP_MAX_MD_SIZE); #if defined(CBC_MAC_ROTATE_IN_PLACE) @@ -272,8 +275,8 @@ void ssl3_cbc_copy_mac(unsigned char* ou #endif /* This information is public so it's safe to branch based on it. */ - if (rec->orig_len > md_size + 255 + 1) - scan_start = rec->orig_len - (md_size + 255 + 1); + if (orig_len > md_size + 255 + 1) + scan_start = orig_len - (md_size + 255 + 1); /* div_spoiler contains a multiple of md_size that is used to cause the * modulo operation to be constant time. Without this, the time varies * based on the amount of padding when running on Intel chips at least. @@ -286,9 +289,9 @@ void ssl3_cbc_copy_mac(unsigned char* ou rotate_offset = (div_spoiler + mac_start - scan_start) % md_size; memset(rotated_mac, 0, md_size); - for (i = scan_start; i < rec->orig_len;) + for (i = scan_start; i < orig_len;) { - for (j = 0; j < md_size && i < rec->orig_len; i++, j++) + for (j = 0; j < md_size && i < orig_len; i++, j++) { unsigned char mac_started = constant_time_ge(i, mac_start); unsigned char mac_ended = constant_time_ge(i, mac_end); Modified: stable/9/crypto/openssl/ssl/s3_enc.c ============================================================================== --- stable/9/crypto/openssl/ssl/s3_enc.c Thu Mar 21 23:07:04 2013 (r248603) +++ stable/9/crypto/openssl/ssl/s3_enc.c Thu Mar 21 23:37:35 2013 (r248604) @@ -504,8 +504,6 @@ int ssl3_enc(SSL *s, int send) EVP_Cipher(ds,rec->data,rec->input,l); - rec->orig_len = rec->length; - if (s->read_hash != NULL) mac_size = EVP_MD_size(s->read_hash); @@ -587,7 +585,7 @@ int ssl3_mac(SSL *ssl, unsigned char *md EVP_MD_CTX md_ctx; const EVP_MD *hash; unsigned char *p,rec_char; - size_t md_size; + size_t md_size, orig_len; int npad; if (send) @@ -608,6 +606,10 @@ int ssl3_mac(SSL *ssl, unsigned char *md md_size=EVP_MD_size(hash); npad=(48/md_size)*md_size; + /* kludge: ssl3_cbc_remove_padding passes padding length in rec->type */ + orig_len = rec->length+md_size+((unsigned int)rec->type>>8); + rec->type &= 0xff; + if (!send && EVP_CIPHER_CTX_mode(ssl->enc_read_ctx) == EVP_CIPH_CBC_MODE && ssl3_cbc_record_digest_supported(hash)) @@ -639,7 +641,7 @@ int ssl3_mac(SSL *ssl, unsigned char *md hash, md, &md_size, header, rec->input, - rec->length + md_size, rec->orig_len, + rec->length + md_size, orig_len, mac_sec, md_size, 1 /* is SSLv3 */); } Modified: stable/9/crypto/openssl/ssl/s3_pkt.c ============================================================================== --- stable/9/crypto/openssl/ssl/s3_pkt.c Thu Mar 21 23:07:04 2013 (r248603) +++ stable/9/crypto/openssl/ssl/s3_pkt.c Thu Mar 21 23:37:35 2013 (r248604) @@ -246,7 +246,7 @@ static int ssl3_get_record(SSL *s) unsigned char *p; unsigned char md[EVP_MAX_MD_SIZE]; short version; - unsigned mac_size; + unsigned mac_size, orig_len; size_t extra; rr= &(s->s3->rrec); @@ -351,7 +351,7 @@ again: /* decrypt in place in 'rr->input' */ rr->data=rr->input; - rr->orig_len=rr->length; + orig_len=rr->length; enc_err = s->method->ssl3_enc->enc(s,0); /* enc_err is: @@ -387,10 +387,10 @@ printf("\n"); * therefore we can safely process the record in a different * amount of time if it's too short to possibly contain a MAC. */ - if (rr->orig_len < mac_size || + if (orig_len < mac_size || /* CBC records must have a padding length byte too. */ (EVP_CIPHER_CTX_mode(s->enc_read_ctx) == EVP_CIPH_CBC_MODE && - rr->orig_len < mac_size+1)) + orig_len < mac_size+1)) { al=SSL_AD_DECODE_ERROR; SSLerr(SSL_F_SSL3_GET_RECORD,SSL_R_LENGTH_TOO_SHORT); @@ -405,12 +405,12 @@ printf("\n"); * without leaking the contents of the padding bytes. * */ mac = mac_tmp; - ssl3_cbc_copy_mac(mac_tmp, rr, mac_size); + ssl3_cbc_copy_mac(mac_tmp, rr, mac_size, orig_len); rr->length -= mac_size; } else { - /* In this case there's no padding, so |rec->orig_len| + /* In this case there's no padding, so |orig_len| * equals |rec->length| and we checked that there's * enough bytes for |mac_size| above. */ rr->length -= mac_size; Modified: stable/9/crypto/openssl/ssl/ssl3.h ============================================================================== --- stable/9/crypto/openssl/ssl/ssl3.h Thu Mar 21 23:07:04 2013 (r248603) +++ stable/9/crypto/openssl/ssl/ssl3.h Thu Mar 21 23:37:35 2013 (r248604) @@ -304,10 +304,6 @@ typedef struct ssl3_record_st /*r */ unsigned char *comp; /* only used with decompression - malloc()ed */ /*r */ unsigned long epoch; /* epoch number, needed by DTLS1 */ /*r */ PQ_64BIT seq_num; /* sequence number, needed by DTLS1 */ -/*rw*/ unsigned int orig_len; /* How many bytes were available before padding - was removed? This is used to implement the - MAC check in constant time for CBC records. - */ } SSL3_RECORD; typedef struct ssl3_buffer_st Modified: stable/9/crypto/openssl/ssl/ssl_locl.h ============================================================================== --- stable/9/crypto/openssl/ssl/ssl_locl.h Thu Mar 21 23:07:04 2013 (r248603) +++ stable/9/crypto/openssl/ssl/ssl_locl.h Thu Mar 21 23:37:35 2013 (r248604) @@ -1015,7 +1015,7 @@ int ssl_parse_clienthello_renegotiate_ex /* s3_cbc.c */ void ssl3_cbc_copy_mac(unsigned char* out, const SSL3_RECORD *rec, - unsigned md_size); + unsigned md_size,unsigned orig_len); int ssl3_cbc_remove_padding(const SSL* s, SSL3_RECORD *rec, unsigned block_size, Modified: stable/9/crypto/openssl/ssl/t1_enc.c ============================================================================== --- stable/9/crypto/openssl/ssl/t1_enc.c Thu Mar 21 23:07:04 2013 (r248603) +++ stable/9/crypto/openssl/ssl/t1_enc.c Thu Mar 21 23:37:35 2013 (r248604) @@ -689,7 +689,7 @@ int tls1_mac(SSL *ssl, unsigned char *md SSL3_RECORD *rec; unsigned char *mac_sec,*seq; const EVP_MD *hash; - size_t md_size; + size_t md_size, orig_len; int i; HMAC_CTX hmac; unsigned char header[13]; @@ -727,6 +727,10 @@ int tls1_mac(SSL *ssl, unsigned char *md else memcpy(header, seq, 8); + /* kludge: tls1_cbc_remove_padding passes padding length in rec->type */ + orig_len = rec->length+md_size+((unsigned int)rec->type>>8); + rec->type &= 0xff; + header[8]=rec->type; header[9]=(unsigned char)(ssl->version>>8); header[10]=(unsigned char)(ssl->version); @@ -745,7 +749,7 @@ int tls1_mac(SSL *ssl, unsigned char *md hash, md, &md_size, header, rec->input, - rec->length + md_size, rec->orig_len, + rec->length + md_size, orig_len, ssl->s3->read_mac_secret, EVP_MD_size(ssl->read_hash), 0 /* not SSLv3 */); @@ -764,7 +768,7 @@ int tls1_mac(SSL *ssl, unsigned char *md ssl->enc_read_ctx, hash, &hmac, rec->input, - rec->length, rec->orig_len); + rec->length, orig_len); #endif } From owner-svn-src-stable-9@FreeBSD.ORG Fri Mar 22 07:30:37 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id F16A8767; Fri, 22 Mar 2013 07:30:36 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E1CDE8BB; Fri, 22 Mar 2013 07:30:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2M7Uak7019413; Fri, 22 Mar 2013 07:30:36 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2M7UaV1019411; Fri, 22 Mar 2013 07:30:36 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201303220730.r2M7UaV1019411@svn.freebsd.org> From: Martin Matuska Date: Fri, 22 Mar 2013 07:30:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248609 - stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Mar 2013 07:30:37 -0000 Author: mm Date: Fri Mar 22 07:30:36 2013 New Revision: 248609 URL: http://svnweb.freebsd.org/changeset/base/248609 Log: MFC r248493: Plug memory leak in dsl_check_snap_cb() This was unnoticed because the function is very rarely used. Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Mar 22 01:45:54 2013 (r248608) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Mar 22 07:30:36 2013 (r248609) @@ -919,7 +919,8 @@ dsl_check_snap_cb(const char *name, void char *dsname; dsname = kmem_asprintf("%s@%s", name, da->snapname); - VERIFY(nvlist_add_boolean(da->nvl, dsname) == 0); + fnvlist_add_boolean(da->nvl, dsname); + kmem_free(dsname, strlen(dsname) + 1); return (0); } From owner-svn-src-stable-9@FreeBSD.ORG Fri Mar 22 07:57:30 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 6970677B; Fri, 22 Mar 2013 07:57:30 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4D21AA08; Fri, 22 Mar 2013 07:57:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2M7vTmP029365; Fri, 22 Mar 2013 07:57:29 GMT (envelope-from mm@svn.freebsd.org) Received: (from mm@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2M7vSZj029359; Fri, 22 Mar 2013 07:57:28 GMT (envelope-from mm@svn.freebsd.org) Message-Id: <201303220757.r2M7vSZj029359@svn.freebsd.org> From: Martin Matuska Date: Fri, 22 Mar 2013 07:57:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248611 - in stable/9: cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Mar 2013 07:57:30 -0000 Author: mm Date: Fri Mar 22 07:57:28 2013 New Revision: 248611 URL: http://svnweb.freebsd.org/changeset/base/248611 Log: MFC r240870 (pjd): It is possible to recursively destroy snapshots even if the snapshot doesn't exist on a dataset we are starting from. For example if we have the following configuration: tank tank/foo tank/foo@snap tank/bar tank/bar@snap We can execute: # zfs destroy -t tank@snap eventhough tank@snap doesn't exit. Unfortunately it is not possible to do the same with recursive rename: # zfs rename -r tank@snap tank@pans cannot open 'tank@snap': dataset does not exist ...until now. This change allows to recursively rename snapshots even if snapshot doesn't exist on the starting dataset. Sponsored by: rsync.net Modified: stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Directory Properties: stable/9/cddl/contrib/opensolaris/ (props changed) stable/9/cddl/contrib/opensolaris/cmd/zfs/ (props changed) stable/9/cddl/contrib/opensolaris/lib/libzfs/ (props changed) stable/9/sys/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) Modified: stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c ============================================================================== --- stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Fri Mar 22 07:40:34 2013 (r248610) +++ stable/9/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c Fri Mar 22 07:57:28 2013 (r248611) @@ -3070,6 +3070,7 @@ zfs_do_rename(int argc, char **argv) int ret = 0; int types; boolean_t parents = B_FALSE; + char *snapshot = NULL; /* check options */ while ((c = getopt(argc, argv, "fpru")) != -1) { @@ -3138,6 +3139,19 @@ zfs_do_rename(int argc, char **argv) else types = ZFS_TYPE_DATASET; + if (flags.recurse) { + /* + * When we do recursive rename we are fine when the given + * snapshot for the given dataset doesn't exist - it can + * still exists below. + */ + + snapshot = strchr(argv[0], '@'); + assert(snapshot != NULL); + *snapshot = '\0'; + snapshot++; + } + if ((zhp = zfs_open(g_zfs, argv[0], types)) == NULL) return (1); @@ -3148,7 +3162,7 @@ zfs_do_rename(int argc, char **argv) return (1); } - ret = (zfs_rename(zhp, argv[1], flags) != 0); + ret = (zfs_rename(zhp, snapshot, argv[1], flags) != 0); zfs_close(zhp); return (ret); Modified: stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h ============================================================================== --- stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Fri Mar 22 07:40:34 2013 (r248610) +++ stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h Fri Mar 22 07:57:28 2013 (r248611) @@ -571,7 +571,8 @@ typedef struct renameflags { int forceunmount : 1; } renameflags_t; -extern int zfs_rename(zfs_handle_t *, const char *, renameflags_t flags); +extern int zfs_rename(zfs_handle_t *, const char *, const char *, + renameflags_t flags); typedef struct sendflags { /* print informational messages (ie, -v was specified) */ Modified: stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c ============================================================================== --- stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Fri Mar 22 07:40:34 2013 (r248610) +++ stable/9/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c Fri Mar 22 07:57:28 2013 (r248611) @@ -611,6 +611,22 @@ zfs_open(libzfs_handle_t *hdl, const cha return (NULL); } + if (zhp == NULL) { + char *at = strchr(path, '@'); + + if (at != NULL) + *at = '\0'; + errno = 0; + if ((zhp = make_dataset_handle(hdl, path)) == NULL) { + (void) zfs_standard_error(hdl, errno, errbuf); + return (NULL); + } + if (at != NULL) + *at = '@'; + (void) strlcpy(zhp->zfs_name, path, sizeof (zhp->zfs_name)); + zhp->zfs_type = ZFS_TYPE_SNAPSHOT; + } + if (!(types & zhp->zfs_type)) { (void) zfs_error(hdl, EZFS_BADTYPE, errbuf); zfs_close(zhp); @@ -3614,7 +3630,8 @@ zfs_rollback(zfs_handle_t *zhp, zfs_hand * Renames the given dataset. */ int -zfs_rename(zfs_handle_t *zhp, const char *target, renameflags_t flags) +zfs_rename(zfs_handle_t *zhp, const char *source, const char *target, + renameflags_t flags) { int ret; zfs_cmd_t zc = { 0 }; @@ -3634,6 +3651,18 @@ zfs_rename(zfs_handle_t *zhp, const char (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot rename to '%s'"), target); + if (source != NULL) { + /* + * This is recursive snapshots rename, put snapshot name + * (that might not exist) into zfs_name. + */ + assert(flags.recurse); + + (void) strlcat(zhp->zfs_name, "@", sizeof(zhp->zfs_name)); + (void) strlcat(zhp->zfs_name, source, sizeof(zhp->zfs_name)); + zhp->zfs_type = ZFS_TYPE_SNAPSHOT; + } + /* * Make sure the target name is valid */ Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Mar 22 07:40:34 2013 (r248610) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_dataset.c Fri Mar 22 07:57:28 2013 (r248611) @@ -2520,6 +2520,7 @@ struct renamesnaparg { char failed[MAXPATHLEN]; char *oldsnap; char *newsnap; + int error; }; static int @@ -2557,6 +2558,9 @@ dsl_snapshot_rename_one(const char *name dsl_sync_task_create(ra->dstg, dsl_dataset_snapshot_rename_check, dsl_dataset_snapshot_rename_sync, ds, ra->newsnap, 0); + /* First successful rename clears the error. */ + ra->error = 0; + return (0); } @@ -2585,14 +2589,16 @@ dsl_recursive_rename(char *oldname, cons ra->oldsnap = strchr(oldname, '@') + 1; ra->newsnap = strchr(newname, '@') + 1; *ra->failed = '\0'; + ra->error = ENOENT; err = dmu_objset_find(fsname, dsl_snapshot_rename_one, ra, DS_FIND_CHILDREN); kmem_free(fsname, len); + if (err == 0) + err = ra->error; - if (err == 0) { + if (err == 0) err = dsl_sync_task_group_wait(ra->dstg); - } for (dst = list_head(&ra->dstg->dstg_tasks); dst; dst = list_next(&ra->dstg->dstg_tasks, dst)) { Modified: stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c ============================================================================== --- stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Fri Mar 22 07:40:34 2013 (r248610) +++ stable/9/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Fri Mar 22 07:57:28 2013 (r248611) @@ -780,7 +780,26 @@ zfs_secpolicy_rename_perms(const char *f static int zfs_secpolicy_rename(zfs_cmd_t *zc, cred_t *cr) { - return (zfs_secpolicy_rename_perms(zc->zc_name, zc->zc_value, cr)); + char *at = NULL; + int error; + + if ((zc->zc_cookie & 1) != 0) { + /* + * This is recursive rename, so the starting snapshot might + * not exist. Check file system or volume permission instead. + */ + at = strchr(zc->zc_name, '@'); + if (at == NULL) + return (EINVAL); + *at = '\0'; + } + + error = zfs_secpolicy_rename_perms(zc->zc_name, zc->zc_value, cr); + + if (at != NULL) + *at = '@'; + + return (error); } static int From owner-svn-src-stable-9@FreeBSD.ORG Fri Mar 22 22:40:17 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4E295A19; Fri, 22 Mar 2013 22:40:17 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 27CC621E; Fri, 22 Mar 2013 22:40:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2MMeHiI064462; Fri, 22 Mar 2013 22:40:17 GMT (envelope-from mckusick@svn.freebsd.org) Received: (from mckusick@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2MMeHAV064461; Fri, 22 Mar 2013 22:40:17 GMT (envelope-from mckusick@svn.freebsd.org) Message-Id: <201303222240.r2MMeHAV064461@svn.freebsd.org> From: Kirk McKusick Date: Fri, 22 Mar 2013 22:40:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248626 - stable/9/sys/ufs/ffs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Mar 2013 22:40:17 -0000 Author: mckusick Date: Fri Mar 22 22:40:16 2013 New Revision: 248626 URL: http://svnweb.freebsd.org/changeset/base/248626 Log: MFS of 246289: For UFS2 i_blocks is unsigned. The current "sanity" check that it has gone below zero after the blocks in its inode are freed is a no-op which the compiler fails to warn about because of the use of the DIP macro. Change the sanity check to compare the number of blocks being freed against the value i_blocks. If the number of blocks being freed exceeds i_blocks, just set i_blocks to zero. Reported by: Pedro Giffuni (pfg@) Modified: stable/9/sys/ufs/ffs/ffs_inode.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/dev/puc/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) stable/9/sys/net/ (props changed) stable/9/sys/sys/ (props changed) Modified: stable/9/sys/ufs/ffs/ffs_inode.c ============================================================================== --- stable/9/sys/ufs/ffs/ffs_inode.c Fri Mar 22 21:50:43 2013 (r248625) +++ stable/9/sys/ufs/ffs/ffs_inode.c Fri Mar 22 22:40:16 2013 (r248626) @@ -547,9 +547,9 @@ done: */ ip->i_size = length; DIP_SET(ip, i_size, length); - DIP_SET(ip, i_blocks, DIP(ip, i_blocks) - blocksreleased); - - if (DIP(ip, i_blocks) < 0) /* sanity */ + if (DIP(ip, i_blocks) >= blocksreleased) + DIP_SET(ip, i_blocks, DIP(ip, i_blocks) - blocksreleased); + else /* sanity */ DIP_SET(ip, i_blocks, 0); ip->i_flag |= IN_CHANGE; #ifdef QUOTA From owner-svn-src-stable-9@FreeBSD.ORG Fri Mar 22 22:50:49 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 0A7C5F46; Fri, 22 Mar 2013 22:50:49 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id E1F1A308; Fri, 22 Mar 2013 22:50:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2MMomnG067532; Fri, 22 Mar 2013 22:50:48 GMT (envelope-from mckusick@svn.freebsd.org) Received: (from mckusick@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2MMomvZ067530; Fri, 22 Mar 2013 22:50:48 GMT (envelope-from mckusick@svn.freebsd.org) Message-Id: <201303222250.r2MMomvZ067530@svn.freebsd.org> From: Kirk McKusick Date: Fri, 22 Mar 2013 22:50:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248628 - stable/9/sbin/fsck_ffs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Mar 2013 22:50:49 -0000 Author: mckusick Date: Fri Mar 22 22:50:48 2013 New Revision: 248628 URL: http://svnweb.freebsd.org/changeset/base/248628 Log: MFS of 246812: Update fsck_ffs buffer cache manager to use TAILQ macros. No functional changes. Modified: stable/9/sbin/fsck_ffs/fsck.h stable/9/sbin/fsck_ffs/fsutil.c Directory Properties: stable/9/sbin/fsck_ffs/ (props changed) Modified: stable/9/sbin/fsck_ffs/fsck.h ============================================================================== --- stable/9/sbin/fsck_ffs/fsck.h Fri Mar 22 22:46:19 2013 (r248627) +++ stable/9/sbin/fsck_ffs/fsck.h Fri Mar 22 22:50:48 2013 (r248628) @@ -67,10 +67,13 @@ #include #include +#include + #define MAXDUP 10 /* limit on dup blks (per inode) */ #define MAXBAD 10 /* limit on bad blks (per inode) */ -#define MAXBUFSPACE 40*1024 /* maximum space to allocate to buffers */ -#define INOBUFSIZE 56*1024 /* size of buffer to read inodes in pass1 */ +#define MINBUFS 10 /* minimum number of buffers required */ +#define MAXBUFS 40 /* maximum space to allocate to buffers */ +#define INOBUFSIZE 64*1024 /* size of buffer to read inodes in pass1 */ union dinode { struct ufs1_dinode dp1; @@ -130,8 +133,7 @@ struct inostatlist { * buffer cache structure. */ struct bufarea { - struct bufarea *b_next; /* free list queue */ - struct bufarea *b_prev; /* free list queue */ + TAILQ_ENTRY(bufarea) b_list; /* buffer list */ ufs2_daddr_t b_bno; int b_size; int b_errs; @@ -159,10 +161,11 @@ struct bufarea { (bp)->b_un.b_indir2[i] = (val); \ } while (0) -#define B_INUSE 1 +/* + * Buffer flags + */ +#define B_INUSE 0x00000001 /* Buffer is in use */ -#define MINBUFS 5 /* minimum number of buffers required */ -struct bufarea bufhead; /* head of list of other blks in filesys */ struct bufarea sblk; /* file system superblock */ struct bufarea cgblk; /* cylinder group blocks */ struct bufarea *pdirbp; /* current directory contents */ Modified: stable/9/sbin/fsck_ffs/fsutil.c ============================================================================== --- stable/9/sbin/fsck_ffs/fsutil.c Fri Mar 22 22:46:19 2013 (r248627) +++ stable/9/sbin/fsck_ffs/fsutil.c Fri Mar 22 22:50:48 2013 (r248628) @@ -67,6 +67,8 @@ long diskreads, totalreads; /* Disk cach struct timeval slowio_starttime; int slowio_delay_usec = 10000; /* Initial IO delay for background fsck */ int slowio_pollcnt; +static TAILQ_HEAD(buflist, bufarea) bufhead; /* head of buffer cache list */ +static int numbufs; /* size of buffer cache */ int ftypeok(union dinode *dp) @@ -161,8 +163,8 @@ bufinit(void) errx(EEXIT, "cannot allocate buffer pool"); cgblk.b_un.b_buf = bufp; initbarea(&cgblk); - bufhead.b_next = bufhead.b_prev = &bufhead; - bufcnt = MAXBUFSPACE / sblock.fs_bsize; + TAILQ_INIT(&bufhead); + bufcnt = MAXBUFS; if (bufcnt < MINBUFS) bufcnt = MINBUFS; for (i = 0; i < bufcnt; i++) { @@ -174,13 +176,10 @@ bufinit(void) errx(EEXIT, "cannot allocate buffer pool"); } bp->b_un.b_buf = bufp; - bp->b_prev = &bufhead; - bp->b_next = bufhead.b_next; - bufhead.b_next->b_prev = bp; - bufhead.b_next = bp; + TAILQ_INSERT_HEAD(&bufhead, bp, b_list); initbarea(bp); } - bufhead.b_size = i; /* save number of buffers */ + numbufs = i; /* save number of buffers */ } /* @@ -191,23 +190,19 @@ getdatablk(ufs2_daddr_t blkno, long size { struct bufarea *bp; - for (bp = bufhead.b_next; bp != &bufhead; bp = bp->b_next) + TAILQ_FOREACH(bp, &bufhead, b_list) if (bp->b_bno == fsbtodb(&sblock, blkno)) goto foundit; - for (bp = bufhead.b_prev; bp != &bufhead; bp = bp->b_prev) + TAILQ_FOREACH_REVERSE(bp, &bufhead, buflist, b_list) if ((bp->b_flags & B_INUSE) == 0) break; - if (bp == &bufhead) + if (bp == NULL) errx(EEXIT, "deadlocked buffer pool"); getblk(bp, blkno, size); /* fall through */ foundit: - bp->b_prev->b_next = bp->b_next; - bp->b_next->b_prev = bp->b_prev; - bp->b_prev = &bufhead; - bp->b_next = bufhead.b_next; - bufhead.b_next->b_prev = bp; - bufhead.b_next = bp; + TAILQ_REMOVE(&bufhead, bp, b_list); + TAILQ_INSERT_HEAD(&bufhead, bp, b_list); bp->b_flags |= B_INUSE; return (bp); } @@ -273,7 +268,7 @@ void ckfini(int markclean) { struct bufarea *bp, *nbp; - int ofsmodified, cnt = 0; + int ofsmodified, cnt; if (bkgrdflag) { unlink(snapname); @@ -294,6 +289,10 @@ ckfini(int markclean) rerun = 1; } } + if (debug && totalreads > 0) + printf("cache with %d buffers missed %ld of %ld (%d%%)\n", + numbufs, diskreads, totalreads, + (int)(diskreads * 100 / totalreads)); if (fswritefd < 0) { (void)close(fsreadfd); return; @@ -308,15 +307,16 @@ ckfini(int markclean) } flush(fswritefd, &cgblk); free(cgblk.b_un.b_buf); - for (bp = bufhead.b_prev; bp && bp != &bufhead; bp = nbp) { + cnt = 0; + TAILQ_FOREACH_REVERSE_SAFE(bp, &bufhead, buflist, b_list, nbp) { + TAILQ_REMOVE(&bufhead, bp, b_list); cnt++; flush(fswritefd, bp); - nbp = bp->b_prev; free(bp->b_un.b_buf); free((char *)bp); } - if (bufhead.b_size != cnt) - errx(EEXIT, "panic: lost %d buffers", bufhead.b_size - cnt); + if (numbufs != cnt) + errx(EEXIT, "panic: lost %d buffers", numbufs - cnt); pbp = pdirbp = (struct bufarea *)0; if (cursnapshot == 0 && sblock.fs_clean != markclean) { if ((sblock.fs_clean = markclean) != 0) { @@ -342,9 +342,6 @@ ckfini(int markclean) rerun = 1; } } - if (debug && totalreads > 0) - printf("cache missed %ld of %ld (%d%%)\n", diskreads, - totalreads, (int)(diskreads * 100 / totalreads)); (void)close(fsreadfd); (void)close(fswritefd); } From owner-svn-src-stable-9@FreeBSD.ORG Sat Mar 23 03:28:20 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B0C254DE; Sat, 23 Mar 2013 03:28:20 +0000 (UTC) (envelope-from pluknet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A31D1D9B; Sat, 23 Mar 2013 03:28:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2N3SKli054259; Sat, 23 Mar 2013 03:28:20 GMT (envelope-from pluknet@svn.freebsd.org) Received: (from pluknet@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2N3SKud054258; Sat, 23 Mar 2013 03:28:20 GMT (envelope-from pluknet@svn.freebsd.org) Message-Id: <201303230328.r2N3SKud054258@svn.freebsd.org> From: Sergey Kandaurov Date: Sat, 23 Mar 2013 03:28:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248633 - stable/9/sbin/fsdb X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Mar 2013 03:28:20 -0000 Author: pluknet Date: Sat Mar 23 03:28:20 2013 New Revision: 248633 URL: http://svnweb.freebsd.org/changeset/base/248633 Log: MFC r246823: Remove write only assignments and thus fix the build after struct bufarea TAILQ conversion (r246812). Modified: stable/9/sbin/fsdb/fsdbutil.c Directory Properties: stable/9/sbin/fsdb/ (props changed) Modified: stable/9/sbin/fsdb/fsdbutil.c ============================================================================== --- stable/9/sbin/fsdb/fsdbutil.c Sat Mar 23 01:25:11 2013 (r248632) +++ stable/9/sbin/fsdb/fsdbutil.c Sat Mar 23 03:28:20 2013 (r248633) @@ -241,7 +241,6 @@ printindir(ufs2_daddr_t blk, int level, /* for the final indirect level, don't use the cache */ bp = &buf; bp->b_un.b_buf = bufp; - bp->b_prev = bp->b_next = bp; initbarea(bp); getblk(bp, blk, sblock.fs_bsize); From owner-svn-src-stable-9@FreeBSD.ORG Sat Mar 23 15:50:35 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 25686884; Sat, 23 Mar 2013 15:50:35 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 17488A2E; Sat, 23 Mar 2013 15:50:35 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2NFoYCJ086060; Sat, 23 Mar 2013 15:50:34 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2NFoYC9086059; Sat, 23 Mar 2013 15:50:34 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201303231550.r2NFoYC9086059@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 23 Mar 2013 15:50:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248650 - stable/9/lib/libc/gen X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Mar 2013 15:50:35 -0000 Author: jilles Date: Sat Mar 23 15:50:34 2013 New Revision: 248650 URL: http://svnweb.freebsd.org/changeset/base/248650 Log: MFC r246641: fts: Use O_DIRECTORY when opening name that might be changed by attacker. There are uncommon cases where fts_safe_changedir() may be called with a non-NULL name that is not "..". Do not block or worse if an attacker put (a symlink to) a fifo or device where a directory used to be. Modified: stable/9/lib/libc/gen/fts.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/gen/fts.c ============================================================================== --- stable/9/lib/libc/gen/fts.c Sat Mar 23 15:11:53 2013 (r248649) +++ stable/9/lib/libc/gen/fts.c Sat Mar 23 15:50:34 2013 (r248650) @@ -1147,7 +1147,8 @@ fts_safe_changedir(sp, p, fd, path) newfd = fd; if (ISSET(FTS_NOCHDIR)) return (0); - if (fd < 0 && (newfd = _open(path, O_RDONLY | O_CLOEXEC, 0)) < 0) + if (fd < 0 && (newfd = _open(path, O_RDONLY | O_DIRECTORY | + O_CLOEXEC, 0)) < 0) return (-1); if (_fstat(newfd, &sb)) { ret = -1; From owner-svn-src-stable-9@FreeBSD.ORG Sat Mar 23 16:02:50 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0FE58F12; Sat, 23 Mar 2013 16:02:50 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 0222EACC; Sat, 23 Mar 2013 16:02:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2NG2nbs089758; Sat, 23 Mar 2013 16:02:49 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2NG2ne6089757; Sat, 23 Mar 2013 16:02:49 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201303231602.r2NG2ne6089757@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 23 Mar 2013 16:02:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248651 - stable/9/lib/libc/net X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Mar 2013 16:02:50 -0000 Author: jilles Date: Sat Mar 23 16:02:49 2013 New Revision: 248651 URL: http://svnweb.freebsd.org/changeset/base/248651 Log: MFC r248252: libc: Avoid SIGPIPE when nscd closes the connection unexpectedly. It is almost always a bug if nscd closes the connection unexpectedly but programs should not be killed with SIGPIPE for it. Modified: stable/9/lib/libc/net/nscachedcli.c Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/net/nscachedcli.c ============================================================================== --- stable/9/lib/libc/net/nscachedcli.c Sat Mar 23 15:50:34 2013 (r248650) +++ stable/9/lib/libc/net/nscachedcli.c Sat Mar 23 16:02:49 2013 (r248651) @@ -75,9 +75,10 @@ safe_write(struct cached_connection_ *co nevents = _kevent(connection->write_queue, NULL, 0, &eventlist, 1, &timeout); if ((nevents == 1) && (eventlist.filter == EVFILT_WRITE)) { - s_result = _write(connection->sockfd, data + result, + s_result = _sendto(connection->sockfd, data + result, eventlist.data < data_size - result ? - eventlist.data : data_size - result); + eventlist.data : data_size - result, MSG_NOSIGNAL, + NULL, 0); if (s_result == -1) return (-1); else @@ -175,8 +176,8 @@ send_credentials(struct cached_connectio nevents = _kevent(connection->write_queue, NULL, 0, &eventlist, 1, NULL); if (nevents == 1 && eventlist.filter == EVFILT_WRITE) { - result = (_sendmsg(connection->sockfd, &cred_hdr, 0) == -1) ? - -1 : 0; + result = (_sendmsg(connection->sockfd, &cred_hdr, + MSG_NOSIGNAL) == -1) ? -1 : 0; EV_SET(&eventlist, connection->sockfd, EVFILT_WRITE, EV_ADD, 0, 0, NULL); _kevent(connection->write_queue, &eventlist, 1, NULL, 0, NULL); From owner-svn-src-stable-9@FreeBSD.ORG Sat Mar 23 16:06:21 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 14DFC22F; Sat, 23 Mar 2013 16:06:21 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 06853AF3; Sat, 23 Mar 2013 16:06:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2NG6KPm090505; Sat, 23 Mar 2013 16:06:20 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2NG6KLU090504; Sat, 23 Mar 2013 16:06:20 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201303231606.r2NG6KLU090504@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 23 Mar 2013 16:06:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248652 - stable/9/lib/libc/stdio X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Mar 2013 16:06:21 -0000 Author: jilles Date: Sat Mar 23 16:06:20 2013 New Revision: 248652 URL: http://svnweb.freebsd.org/changeset/base/248652 Log: MFC r246824,r246952: setbuf(3): Bring BUGS section up to date. Modified: stable/9/lib/libc/stdio/setbuf.3 Directory Properties: stable/9/lib/libc/ (props changed) Modified: stable/9/lib/libc/stdio/setbuf.3 ============================================================================== --- stable/9/lib/libc/stdio/setbuf.3 Sat Mar 23 16:02:49 2013 (r248651) +++ stable/9/lib/libc/stdio/setbuf.3 Sat Mar 23 16:06:20 2013 (r248652) @@ -32,7 +32,7 @@ .\" @(#)setbuf.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd February 18, 2013 .Dt SETBUF 3 .Os .Sh NAME @@ -196,18 +196,5 @@ functions conform to .St -isoC . .Sh BUGS -The -.Fn setbuffer -and -.Fn setlinebuf -functions are not portable to versions of -.Bx -before -.Bx 4.2 . -On -.Bx 4.2 -and -.Bx 4.3 -systems, .Fn setbuf -always uses a suboptimal buffer size and should be avoided. +usually uses a suboptimal buffer size and should be avoided. From owner-svn-src-stable-9@FreeBSD.ORG Sat Mar 23 21:56:21 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 0F3554A1; Sat, 23 Mar 2013 21:56:21 +0000 (UTC) (envelope-from mckusick@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id F407AC11; Sat, 23 Mar 2013 21:56:20 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2NLuKIE098973; Sat, 23 Mar 2013 21:56:20 GMT (envelope-from mckusick@svn.freebsd.org) Received: (from mckusick@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2NLuK8o098966; Sat, 23 Mar 2013 21:56:20 GMT (envelope-from mckusick@svn.freebsd.org) Message-Id: <201303232156.r2NLuK8o098966@svn.freebsd.org> From: Kirk McKusick Date: Sat, 23 Mar 2013 21:56:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248665 - in stable/9/sys: geom kern sys ufs/ffs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Mar 2013 21:56:21 -0000 Author: mckusick Date: Sat Mar 23 21:56:19 2013 New Revision: 248665 URL: http://svnweb.freebsd.org/changeset/base/248665 Log: MFC of 246876 and 246877 MFC: 246876: Add barrier write capability to the VFS buffer interface. A barrier write is a disk write request that tells the disk that the buffer being written must be committed to the media along with any writes that preceeded it before any future blocks may be written to the drive. Barrier writes are provided by adding the functions bbarrierwrite (bwrite with barrier) and babarrierwrite (bawrite with barrier). Following a bbarrierwrite the client knows that the requested buffer is on the media. It does not ensure that buffers written before that buffer are on the media. It only ensure that buffers written before that buffer will get to the media before any buffers written after that buffer. A flush command must be sent to the disk to ensure that all earlier written buffers are on the media. Reviewed by: kib Tested by: Peter Holm MFC 246877: The UFS2 filesystem allocates new blocks of inodes as they are needed. When a cylinder group runs short of inodes, a new block for inodes is allocated, zero'ed, and written to the disk. The zero'ed inodes must be on the disk before the cylinder group can be updated to claim them. If the cylinder group claiming the new inodes were written before the zero'ed block of inodes, the system could crash with the filesystem in an unrecoverable state. Rather than adding a soft updates dependency to ensure that the new inode block is written before it is claimed by the cylinder group map, we just do a barrier write of the zero'ed inode block to ensure that it will get written before the updated cylinder group map can be written. This change should only slow down bulk loading of newly created filesystems since that is the primary time that new inode blocks need to be created. Reported by: Robert Watson Reviewed by: kib Tested by: Peter Holm Modified: stable/9/sys/geom/geom_vfs.c stable/9/sys/kern/vfs_bio.c stable/9/sys/kern/vfs_cluster.c stable/9/sys/sys/buf.h stable/9/sys/ufs/ffs/ffs_alloc.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/dev/puc/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) stable/9/sys/net/ (props changed) stable/9/sys/sys/ (props changed) Modified: stable/9/sys/geom/geom_vfs.c ============================================================================== --- stable/9/sys/geom/geom_vfs.c Sat Mar 23 21:34:10 2013 (r248664) +++ stable/9/sys/geom/geom_vfs.c Sat Mar 23 21:56:19 2013 (r248665) @@ -168,6 +168,10 @@ g_vfs_strategy(struct bufobj *bo, struct bip->bio_done = g_vfs_done; bip->bio_caller2 = bp; bip->bio_length = bp->b_bcount; + if (bp->b_flags & B_BARRIER) { + bip->bio_flags |= BIO_ORDERED; + bp->b_flags &= ~B_BARRIER; + } g_io_request(bip, cp); } Modified: stable/9/sys/kern/vfs_bio.c ============================================================================== --- stable/9/sys/kern/vfs_bio.c Sat Mar 23 21:34:10 2013 (r248664) +++ stable/9/sys/kern/vfs_bio.c Sat Mar 23 21:56:19 2013 (r248665) @@ -206,6 +206,9 @@ SYSCTL_INT(_vfs, OID_AUTO, flushbufqtarg static long notbufdflashes; SYSCTL_LONG(_vfs, OID_AUTO, notbufdflashes, CTLFLAG_RD, ¬bufdflashes, 0, "Number of dirty buffer flushes done by the bufdaemon helpers"); +static long barrierwrites; +SYSCTL_LONG(_vfs, OID_AUTO, barrierwrites, CTLFLAG_RW, &barrierwrites, 0, + "Number of barrier writes"); /* * Wakeup point for bufdaemon, as well as indicator of whether it is already @@ -914,6 +917,9 @@ bufwrite(struct buf *bp) return (0); } + if (bp->b_flags & B_BARRIER) + barrierwrites++; + oldflags = bp->b_flags; BUF_ASSERT_HELD(bp); @@ -1033,6 +1039,8 @@ bdwrite(struct buf *bp) CTR3(KTR_BUF, "bdwrite(%p) vp %p flags %X", bp, bp->b_vp, bp->b_flags); KASSERT(bp->b_bufobj != NULL, ("No b_bufobj %p", bp)); + KASSERT((bp->b_flags & B_BARRIER) == 0, + ("Barrier request in delayed write %p", bp)); BUF_ASSERT_HELD(bp); if (bp->b_flags & B_INVAL) { @@ -1193,6 +1201,40 @@ bawrite(struct buf *bp) } /* + * babarrierwrite: + * + * Asynchronous barrier write. Start output on a buffer, but do not + * wait for it to complete. Place a write barrier after this write so + * that this buffer and all buffers written before it are committed to + * the disk before any buffers written after this write are committed + * to the disk. The buffer is released when the output completes. + */ +void +babarrierwrite(struct buf *bp) +{ + + bp->b_flags |= B_ASYNC | B_BARRIER; + (void) bwrite(bp); +} + +/* + * bbarrierwrite: + * + * Synchronous barrier write. Start output on a buffer and wait for + * it to complete. Place a write barrier after this write so that + * this buffer and all buffers written before it are committed to + * the disk before any buffers written after this write are committed + * to the disk. The buffer is released when the output completes. + */ +int +bbarrierwrite(struct buf *bp) +{ + + bp->b_flags |= B_BARRIER; + return (bwrite(bp)); +} + +/* * bwillwrite: * * Called prior to the locking of any vnodes when we are expecting to Modified: stable/9/sys/kern/vfs_cluster.c ============================================================================== --- stable/9/sys/kern/vfs_cluster.c Sat Mar 23 21:34:10 2013 (r248664) +++ stable/9/sys/kern/vfs_cluster.c Sat Mar 23 21:56:19 2013 (r248665) @@ -944,11 +944,17 @@ cluster_wbuild(vp, size, start_lbn, len) } bp->b_bcount += size; bp->b_bufsize += size; - bundirty(tbp); - tbp->b_flags &= ~B_DONE; - tbp->b_ioflags &= ~BIO_ERROR; + /* + * If any of the clustered buffers have their + * B_BARRIER flag set, transfer that request to + * the cluster. + */ + bp->b_flags |= (tbp->b_flags & B_BARRIER); + tbp->b_flags &= ~(B_DONE | B_BARRIER); tbp->b_flags |= B_ASYNC; + tbp->b_ioflags &= ~BIO_ERROR; tbp->b_iocmd = BIO_WRITE; + bundirty(tbp); reassignbuf(tbp); /* put on clean list */ bufobj_wref(tbp->b_bufobj); BUF_KERNPROC(tbp); Modified: stable/9/sys/sys/buf.h ============================================================================== --- stable/9/sys/sys/buf.h Sat Mar 23 21:34:10 2013 (r248664) +++ stable/9/sys/sys/buf.h Sat Mar 23 21:56:19 2013 (r248665) @@ -205,7 +205,7 @@ struct buf { #define B_00000800 0x00000800 /* Available flag. */ #define B_00001000 0x00001000 /* Available flag. */ #define B_INVAL 0x00002000 /* Does not contain valid info. */ -#define B_00004000 0x00004000 /* Available flag. */ +#define B_BARRIER 0x00004000 /* Write this and all preceeding first. */ #define B_NOCACHE 0x00008000 /* Do not cache block after use. */ #define B_MALLOC 0x00010000 /* malloced b_data */ #define B_CLUSTEROK 0x00020000 /* Pagein op, so swap() can count it. */ @@ -491,6 +491,8 @@ int breadn_flags(struct vnode *, daddr_t struct ucred *, int, struct buf **); void bdwrite(struct buf *); void bawrite(struct buf *); +void babarrierwrite(struct buf *); +int bbarrierwrite(struct buf *); void bdirty(struct buf *); void bundirty(struct buf *); void bufstrategy(struct bufobj *, struct buf *); Modified: stable/9/sys/ufs/ffs/ffs_alloc.c ============================================================================== --- stable/9/sys/ufs/ffs/ffs_alloc.c Sat Mar 23 21:34:10 2013 (r248664) +++ stable/9/sys/ufs/ffs/ffs_alloc.c Sat Mar 23 21:56:19 2013 (r248665) @@ -1801,7 +1801,6 @@ gotit: /* * Check to see if we need to initialize more inodes. */ - ibp = NULL; if (fs->fs_magic == FS_UFS2_MAGIC && ipref + INOPB(fs) > cgp->cg_initediblk && cgp->cg_initediblk < cgp->cg_niblk) { @@ -1814,6 +1813,16 @@ gotit: dp2->di_gen = arc4random() / 2 + 1; dp2++; } + /* + * Rather than adding a soft updates dependency to ensure + * that the new inode block is written before it is claimed + * by the cylinder group map, we just do a barrier write + * here. The barrier write will ensure that the inode block + * gets written before the updated cylinder group map can be + * written. The barrier write should only slow down bulk + * loading of newly created filesystems. + */ + babarrierwrite(ibp); cgp->cg_initediblk += INOPB(fs); } UFS_LOCK(ump); @@ -1832,8 +1841,6 @@ gotit: if (DOINGSOFTDEP(ITOV(ip))) softdep_setup_inomapdep(bp, ip, cg * fs->fs_ipg + ipref, mode); bdwrite(bp); - if (ibp != NULL) - bawrite(ibp); return ((ino_t)(cg * fs->fs_ipg + ipref)); } From owner-svn-src-stable-9@FreeBSD.ORG Sat Mar 23 22:41:48 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9E8A8DEA; Sat, 23 Mar 2013 22:41:48 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 901FCE77; Sat, 23 Mar 2013 22:41:48 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r2NMfm9a013790; Sat, 23 Mar 2013 22:41:48 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r2NMfmOI013789; Sat, 23 Mar 2013 22:41:48 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201303232241.r2NMfmOI013789@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 23 Mar 2013 22:41:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r248667 - stable/9/sys/ufs/ffs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Mar 2013 22:41:48 -0000 Author: kib Date: Sat Mar 23 22:41:48 2013 New Revision: 248667 URL: http://svnweb.freebsd.org/changeset/base/248667 Log: MFC r247387: Inode block must not be read or written while cg block buffer is owned. Modified: stable/9/sys/ufs/ffs/ffs_alloc.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/ufs/ffs/ffs_alloc.c ============================================================================== --- stable/9/sys/ufs/ffs/ffs_alloc.c Sat Mar 23 22:23:15 2013 (r248666) +++ stable/9/sys/ufs/ffs/ffs_alloc.c Sat Mar 23 22:41:48 2013 (r248667) @@ -1724,6 +1724,17 @@ fail: return (0); } +static inline struct buf * +getinobuf(struct inode *ip, u_int cg, u_int32_t cginoblk, int gbflags) +{ + struct fs *fs; + + fs = ip->i_fs; + return (getblk(ip->i_devvp, fsbtodb(fs, ino_to_fsba(fs, + cg * fs->fs_ipg + cginoblk)), (int)fs->fs_bsize, 0, 0, + gbflags)); +} + /* * Determine whether an inode can be allocated. * @@ -1748,9 +1759,11 @@ ffs_nodealloccg(ip, cg, ipref, mode, unu u_int8_t *inosused; struct ufs2_dinode *dp2; int error, start, len, loc, map, i; + u_int32_t old_initediblk; fs = ip->i_fs; ump = ip->i_ump; +check_nifree: if (fs->fs_cs(fs, cg).cs_nifree == 0) return (0); UFS_UNLOCK(ump); @@ -1762,13 +1775,13 @@ ffs_nodealloccg(ip, cg, ipref, mode, unu return (0); } cgp = (struct cg *)bp->b_data; +restart: if (!cg_chkmagic(cgp) || cgp->cg_cs.cs_nifree == 0) { brelse(bp); UFS_LOCK(ump); return (0); } bp->b_xflags |= BX_BKGRDWRITE; - cgp->cg_old_time = cgp->cg_time = time_second; inosused = cg_inosused(cgp); if (ipref) { ipref %= fs->fs_ipg; @@ -1796,7 +1809,6 @@ ffs_nodealloccg(ip, cg, ipref, mode, unu panic("ffs_nodealloccg: block not in map"); } ipref = i * NBBY + ffs(map) - 1; - cgp->cg_irotor = ipref; gotit: /* * Check to see if we need to initialize more inodes. @@ -1804,9 +1816,37 @@ gotit: if (fs->fs_magic == FS_UFS2_MAGIC && ipref + INOPB(fs) > cgp->cg_initediblk && cgp->cg_initediblk < cgp->cg_niblk) { - ibp = getblk(ip->i_devvp, fsbtodb(fs, - ino_to_fsba(fs, cg * fs->fs_ipg + cgp->cg_initediblk)), - (int)fs->fs_bsize, 0, 0, 0); + old_initediblk = cgp->cg_initediblk; + + /* + * Free the cylinder group lock before writing the + * initialized inode block. Entering the + * babarrierwrite() with the cylinder group lock + * causes lock order violation between the lock and + * snaplk. + * + * Another thread can decide to initialize the same + * inode block, but whichever thread first gets the + * cylinder group lock after writing the newly + * allocated inode block will update it and the other + * will realize that it has lost and leave the + * cylinder group unchanged. + */ + ibp = getinobuf(ip, cg, old_initediblk, GB_LOCK_NOWAIT); + brelse(bp); + if (ibp == NULL) { + /* + * The inode block buffer is already owned by + * another thread, which must initialize it. + * Wait on the buffer to allow another thread + * to finish the updates, with dropped cg + * buffer lock, then retry. + */ + ibp = getinobuf(ip, cg, old_initediblk, 0); + brelse(ibp); + UFS_LOCK(ump); + goto check_nifree; + } bzero(ibp->b_data, (int)fs->fs_bsize); dp2 = (struct ufs2_dinode *)(ibp->b_data); for (i = 0; i < INOPB(fs); i++) { @@ -1823,8 +1863,29 @@ gotit: * loading of newly created filesystems. */ babarrierwrite(ibp); - cgp->cg_initediblk += INOPB(fs); + + /* + * After the inode block is written, try to update the + * cg initediblk pointer. If another thread beat us + * to it, then leave it unchanged as the other thread + * has already set it correctly. + */ + error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NOCRED, &bp); + UFS_LOCK(ump); + ACTIVECLEAR(fs, cg); + UFS_UNLOCK(ump); + if (error != 0) { + brelse(bp); + return (error); + } + cgp = (struct cg *)bp->b_data; + if (cgp->cg_initediblk == old_initediblk) + cgp->cg_initediblk += INOPB(fs); + goto restart; } + cgp->cg_old_time = cgp->cg_time = time_second; + cgp->cg_irotor = ipref; UFS_LOCK(ump); ACTIVECLEAR(fs, cg); setbit(inosused, ipref);