From owner-svn-src-stable-7@FreeBSD.ORG Sun May 20 01:40:35 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id EFEE5106566B; Sun, 20 May 2012 01:40:35 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D8EF08FC14; Sun, 20 May 2012 01:40:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4K1eZUm058560; Sun, 20 May 2012 01:40:35 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4K1eZTd058558; Sun, 20 May 2012 01:40:35 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201205200140.q4K1eZTd058558@svn.freebsd.org> From: Glen Barber Date: Sun, 20 May 2012 01:40:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235675 - stable/7/share/man/man4 X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 May 2012 01:40:36 -0000 Author: gjb (doc committer) Date: Sun May 20 01:40:35 2012 New Revision: 235675 URL: http://svn.freebsd.org/changeset/base/235675 Log: MFC r235567: mdoc(7) style/formatting fixes. While here, fix a few nits igor(1) does not like. Modified: stable/7/share/man/man4/siftr.4 Directory Properties: stable/7/share/man/man4/ (props changed) Modified: stable/7/share/man/man4/siftr.4 ============================================================================== --- stable/7/share/man/man4/siftr.4 Sun May 20 01:40:24 2012 (r235674) +++ stable/7/share/man/man4/siftr.4 Sun May 20 01:40:35 2012 (r235675) @@ -91,7 +91,7 @@ utilises the .Xr sysctl 8 interface to export its configuration variables to user-space. The following variables are available: -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va net.inet.siftr.enabled controls whether the module performs its measurements or not. @@ -104,7 +104,7 @@ packet filtering hooks are only inserted .Va net.inet.siftr.enabled is set to 1. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va net.inet.siftr.ppl controls how many inbound/outbound packets for a given TCP connection will cause a log message to be generated for the connection. @@ -113,13 +113,13 @@ every packet of every TCP connection. The value can be set to any integer in the range [1,2^32], and can be changed at any time, even while the module is enabled. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va net.inet.siftr.logfile controls the path to the file that the module writes its log messages to. By default, the file /var/log/siftr.log is used. The path can be changed at any time, even while the module is enabled. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va net.inet.siftr.genhashes controls whether a hash is generated for each TCP packet seen by .Nm . @@ -150,36 +150,36 @@ sysname=FreeBSD sysver=604000 ipmo .Ed .Pp Field descriptions are as follows: -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va enable_time_secs time at which the module was enabled, in seconds since the UNIX epoch. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va enable_time_usecs time at which the module was enabled, in microseconds since enable_time_secs. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va siftrver version of .Nm . .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va hz tick rate of the kernel in ticks per second. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va tcp_rtt_scale smoothed RTT estimate scaling factor .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va sysname operating system name .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va sysver operating system version .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va ipmode IP mode as defined at compile time. An ipmode of "4" means IPv6 is not supported and IP addresses are logged in @@ -202,7 +202,7 @@ o,0xbec491a5,1238556193.463551,172.16.7. .Ed .Pp Field descriptions are as follows: -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 1 Direction of packet that triggered the log message. Either @@ -211,77 +211,77 @@ for in, or .Qq o for out. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 2 Hash of the packet that triggered the log message. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 3 Time at which the packet that triggered the log message was processed by the .Xr pfil 9 hook function, in seconds and microseconds since the UNIX epoch. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 4 The IPv4 or IPv6 address of the local host, in dotted quad (IPv4 packet) or colon-separated hex (IPv6 packet) notation. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 5 The TCP port that the local host is communicating via. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 6 The IPv4 or IPv6 address of the foreign host, in dotted quad (IPv4 packet) or colon-separated hex (IPv6 packet) notation. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 7 The TCP port that the foreign host is communicating via. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 8 The slow start threshold for the flow, in bytes. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 9 The current congestion window for the flow, in bytes. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 10 The current bandwidth-controlled window for the flow, in bytes. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 11 The current sending window for the flow, in bytes. The post scaled value is reported, except during the initial handshake (first few packets), during which time the unscaled value is reported. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 12 The current receive window for the flow, in bytes. The post scaled value is always reported. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 13 The current window scaling factor for the sending window. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 14 The current window scaling factor for the receiving window. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 15 The current state of the TCP finite state machine, as defined in .Aq Pa netinet/tcp_fsm.h . .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 16 The maximum segment size for the flow, in bytes. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 17 The current smoothed RTT estimate for the flow, in units of TCP_RTT_SCALE * HZ, where TCP_RTT_SCALE is a define found in tcp_var.h, and HZ is the kernel's tick @@ -289,46 +289,46 @@ timer. Divide by TCP_RTT_SCALE * HZ to get the RTT in secs. TCP_RTT_SCALE and HZ are reported in the enable log message. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 18 SACK enabled indicator. 1 if SACK enabled, 0 otherwise. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 19 The current state of the TCP flags for the flow. See .Aq Pa netinet/tcp_var.h for information about the various flags. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 20 The current retransmission timeout length for the flow, in units of HZ, where HZ is the kernel's tick timer. Divide by HZ to get the timeout length in seconds. HZ is reported in the enable log message. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 21 The current size of the socket send buffer in bytes. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 22 The current number of bytes in the socket send buffer. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 23 The current size of the socket receive buffer in bytes. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 24 The current number of bytes in the socket receive buffer. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 25 The current number of unacknowledged bytes in-flight. Bytes acknowledged via SACK are not excluded from this count. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va 26 The current number of segments in the reassembly queue. .El @@ -350,82 +350,82 @@ flow_list=172.16.7.28;22-172.16.2.5;5593 .Ed .Pp Field descriptions are as follows: -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va disable_time_secs Time at which the module was disabled, in seconds since the UNIX epoch. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va disable_time_usecs Time at which the module was disabled, in microseconds since disable_time_secs. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va num_inbound_tcp_pkts Number of TCP packets that traversed up the network stack. This only includes inbound TCP packets during the periods when .Nm was enabled. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va num_outbound_tcp_pkts Number of TCP packets that traversed down the network stack. This only includes outbound TCP packets during the periods when .Nm was enabled. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va total_tcp_pkts The summation of num_inbound_tcp_pkts and num_outbound_tcp_pkts. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va num_inbound_skipped_pkts_malloc Number of inbound packets that were not processed because of failed malloc() calls. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va num_outbound_skipped_pkts_malloc Number of outbound packets that were not processed because of failed malloc() calls. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va num_inbound_skipped_pkts_mtx Number of inbound packets that were not processed because of failure to add the packet to the packet processing queue. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va num_outbound_skipped_pkts_mtx Number of outbound packets that were not processed because of failure to add the packet to the packet processing queue. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va num_inbound_skipped_pkts_tcb Number of inbound packets that were not processed because of failure to find the TCP control block associated with the packet. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va num_outbound_skipped_pkts_tcb Number of outbound packets that were not processed because of failure to find the TCP control block associated with the packet. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va num_inbound_skipped_pkts_icb Number of inbound packets that were not processed because of failure to find the IP control block associated with the packet. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va num_outbound_skipped_pkts_icb Number of outbound packets that were not processed because of failure to find the IP control block associated with the packet. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va total_skipped_tcp_pkts The summation of all skipped packet counters. .El -.Bl -tag -offset indent +.Bl -tag -offset indent -width Va .It Va flow_list A CSV list of TCP flows that triggered data log messages to be generated since the module was loaded. Each flow entry in the CSV list is formatted as .Qq local_ip;local_port-foreign_ip;foreign_port . -If there are no entries in the list (i.e. no data log messages were generated), +If there are no entries in the list (i.e., no data log messages were generated), the value will be blank. If there is at least one entry in the list, a trailing comma will always be present. @@ -498,10 +498,10 @@ the system to trigger a dump of the stat flow. With the PPL set to 1, we are in effect sampling each TCP flow's control block state as frequently as flow packets enter/leave the system. -For example, setting PPL to 2 halves the sampling rate i.e. every second flow +For example, setting PPL to 2 halves the sampling rate i.e., every second flow packet (inbound OR outbound) causes a dump of the control block state. .Pp -The distinction between interrogating individual packets vs interrogating the +The distinction between interrogating individual packets versus interrogating the control block is important, because .Nm does not remove the need for packet capturing tools like @@ -543,7 +543,7 @@ If one thread holds the lock, the other This does introduce some additional bounded delay into the kernel's packet processing code path. .Pp -In some cases (e.g. low memory, connection termination), TCP packets that enter +In some cases (e.g., low memory, connection termination), TCP packets that enter the .Nm .Xr pfil 9 From owner-svn-src-stable-7@FreeBSD.ORG Mon May 21 00:15:59 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8EDE410656D1; Mon, 21 May 2012 00:15:59 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3122E8FC12; Mon, 21 May 2012 00:15:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4L0Fxx9025780; Mon, 21 May 2012 00:15:59 GMT (envelope-from gjb@svn.freebsd.org) Received: (from gjb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4L0FwKq025778; Mon, 21 May 2012 00:15:58 GMT (envelope-from gjb@svn.freebsd.org) Message-Id: <201205210015.q4L0FwKq025778@svn.freebsd.org> From: Glen Barber Date: Mon, 21 May 2012 00:15:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235709 - stable/7/usr.bin/join X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2012 00:15:59 -0000 Author: gjb (doc committer) Date: Mon May 21 00:15:58 2012 New Revision: 235709 URL: http://svn.freebsd.org/changeset/base/235709 Log: MFC r235597: Fix a typo that crept in. Modified: stable/7/usr.bin/join/join.1 Directory Properties: stable/7/usr.bin/join/ (props changed) Modified: stable/7/usr.bin/join/join.1 ============================================================================== --- stable/7/usr.bin/join/join.1 Mon May 21 00:15:47 2012 (r235708) +++ stable/7/usr.bin/join/join.1 Mon May 21 00:15:58 2012 (r235709) @@ -113,7 +113,7 @@ representing the join field. The elements of list must be either comma .Pq Ql \&, or whitespace separated. -(The letter requires quoting to protect it from the shell, or, a simpler +(The latter requires quoting to protect it from the shell, or, a simpler approach is to use multiple .Fl o options.) From owner-svn-src-stable-7@FreeBSD.ORG Mon May 21 13:07:13 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id CA745106566B; Mon, 21 May 2012 13:07:13 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B26018FC0C; Mon, 21 May 2012 13:07:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4LD7DWD059314; Mon, 21 May 2012 13:07:13 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4LD7Dnh059298; Mon, 21 May 2012 13:07:13 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201205211307.q4LD7Dnh059298@svn.freebsd.org> From: Baptiste Daroussin Date: Mon, 21 May 2012 13:07:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235722 - in stable/7/usr.sbin/pkg_install: add delete info lib updating version X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2012 13:07:13 -0000 Author: bapt Date: Mon May 21 13:07:12 2012 New Revision: 235722 URL: http://svn.freebsd.org/changeset/base/235722 Log: MFC: r201226, r202844, r206043, r206132, r206133, r212029, r225610, r226708, r228670 - Add support for UPDATING remote fetching. - Reorganize EXAMPLES section in pkg_updating(1). - Style fixes. - Replace hardcoded INDEX version. [1] - Fix a buffer overlap. [2] - Remove empty package when fetching fails and -K is used. [3] - Remove useless chmod2() after mkdtemp(3). [4] - Replace mkdir(1) call with mkdir(2). [5] - Get rid of some vsystem() calls. - Switch from lstat(2) to open(2) in fexists(). - Try rename(2) in move_file() first. - Fix pkg_delete, check if the file we're trying to delete is a symlink before complaining that it doesn't exist. Typical case would be a leftover library symlink that's left over after the actual library has been removed. - Print the package name on deletion errors. - Staticify elide_root() - In usr.sbin/pkg_install/updating/main.c, use the size of the destination buffer as size argument to strlcpy(), not the length of the source PR: bin/145101 [1], bin/139492 [2], bin/144919 [3] bin/144920 [4], bin/144921 [5] Submitted by: gcooper [1,2,3,4,5] Approved by: des (mentor) Modified: stable/7/usr.sbin/pkg_install/add/futil.c stable/7/usr.sbin/pkg_install/add/main.c stable/7/usr.sbin/pkg_install/add/perform.c stable/7/usr.sbin/pkg_install/delete/perform.c stable/7/usr.sbin/pkg_install/info/show.c stable/7/usr.sbin/pkg_install/lib/file.c stable/7/usr.sbin/pkg_install/lib/lib.h stable/7/usr.sbin/pkg_install/lib/match.c stable/7/usr.sbin/pkg_install/lib/pen.c stable/7/usr.sbin/pkg_install/lib/plist.c stable/7/usr.sbin/pkg_install/lib/url.c stable/7/usr.sbin/pkg_install/updating/main.c stable/7/usr.sbin/pkg_install/updating/pkg_updating.1 stable/7/usr.sbin/pkg_install/version/perform.c Directory Properties: stable/7/usr.sbin/ (props changed) stable/7/usr.sbin/pkg_install/ (props changed) Modified: stable/7/usr.sbin/pkg_install/add/futil.c ============================================================================== --- stable/7/usr.sbin/pkg_install/add/futil.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/add/futil.c Mon May 21 13:07:12 2012 (r235722) @@ -50,7 +50,7 @@ make_hierarchy(char *dir) } } else { - if (vsystem("/bin/mkdir %s", dir)) { + if (mkdir(dir, 0777) < 0) { if (cp2) *cp2 = '/'; return FAIL; Modified: stable/7/usr.sbin/pkg_install/add/main.c ============================================================================== --- stable/7/usr.sbin/pkg_install/add/main.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/add/main.c Mon May 21 13:07:12 2012 (r235722) @@ -22,7 +22,7 @@ __FBSDID("$FreeBSD$"); #include -#include +#include #include #include @@ -303,7 +303,9 @@ getpackagesite(void) { int reldate, i; static char sitepath[MAXPATHLEN]; - struct utsname u; + int archmib[] = { CTL_HW, HW_MACHINE_ARCH }; + char arch[64]; + size_t archlen = sizeof(arch); if (getenv("PACKAGESITE")) { if (strlcpy(sitepath, getenv("PACKAGESITE"), sizeof(sitepath)) @@ -326,8 +328,10 @@ getpackagesite(void) >= sizeof(sitepath)) return NULL; - uname(&u); - if (strlcat(sitepath, u.machine, sizeof(sitepath)) >= sizeof(sitepath)) + if (sysctl(archmib, 2, arch, &archlen, NULL, 0) == -1) + return NULL; + arch[archlen-1] = 0; + if (strlcat(sitepath, arch, sizeof(sitepath)) >= sizeof(sitepath)) return NULL; reldate = getosreldate(); Modified: stable/7/usr.sbin/pkg_install/add/perform.c ============================================================================== --- stable/7/usr.sbin/pkg_install/add/perform.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/add/perform.c Mon May 21 13:07:12 2012 (r235722) @@ -78,6 +78,7 @@ pkg_do(char *pkg) char pre_arg[FILENAME_MAX], post_arg[FILENAME_MAX]; char *conflict[2]; char **matched; + int fd; conflictsfound = 0; code = 0; @@ -408,8 +409,10 @@ pkg_do(char *pkg) goto bomb; /* Look for the requirements file */ - if (fexists(REQUIRE_FNAME)) { - vsystem("/bin/chmod +x %s", REQUIRE_FNAME); /* be sure */ + if ((fd = open(REQUIRE_FNAME, O_RDWR)) != -1) { + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (Verbose) printf("Running requirements file first for %s..\n", Plist.name); if (!Fake && vsystem("./%s %s INSTALL", REQUIRE_FNAME, Plist.name)) { @@ -441,8 +444,10 @@ pkg_do(char *pkg) } /* If we're really installing, and have an installation file, run it */ - if (!NoInstall && fexists(pre_script)) { - vsystem("/bin/chmod +x %s", pre_script); /* make sure */ + if (!NoInstall && (fd = open(pre_script, O_RDWR)) != -1) { + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (Verbose) printf("Running pre-install for %s..\n", Plist.name); if (!Fake && vsystem("./%s %s %s", pre_script, Plist.name, pre_arg)) { @@ -470,8 +475,10 @@ pkg_do(char *pkg) } /* Run the installation script one last time? */ - if (!NoInstall && fexists(post_script)) { - vsystem("/bin/chmod +x %s", post_script); /* make sure */ + if (!NoInstall && (fd = open(post_script, O_RDWR)) != -1) { + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (Verbose) printf("Running post-install for %s..\n", Plist.name); if (!Fake && vsystem("./%s %s %s", post_script, Plist.name, post_arg)) { @@ -503,7 +510,10 @@ pkg_do(char *pkg) goto success; /* close enough for government work */ } /* Make sure pkg_info can read the entry */ - vsystem("/bin/chmod a+rx %s", LogDir); + fd = open(LogDir, O_RDWR); + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IRALL | S_IXALL); /* be sure, chmod a+rx */ + close(fd); move_file(".", DESC_FNAME, LogDir); move_file(".", COMMENT_FNAME, LogDir); if (fexists(INSTALL_FNAME)) Modified: stable/7/usr.sbin/pkg_install/delete/perform.c ============================================================================== --- stable/7/usr.sbin/pkg_install/delete/perform.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/delete/perform.c Mon May 21 13:07:12 2012 (r235722) @@ -132,6 +132,8 @@ pkg_do(char *pkg) const char *post_script, *pre_arg, *post_arg; struct reqr_by_entry *rb_entry; struct reqr_by_head *rb_list; + int fd; + struct stat sb; if (!pkg || !(len = strlen(pkg))) return 1; @@ -221,10 +223,12 @@ pkg_do(char *pkg) setenv(PKG_PREFIX_VNAME, p->name, 1); - if (fexists(REQUIRE_FNAME)) { + if ((fd = open(REQUIRE_FNAME, O_RDWR)) != -1) { + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (Verbose) printf("Executing 'require' script.\n"); - vsystem("/bin/chmod +x %s", REQUIRE_FNAME); /* be sure */ if (vsystem("./%s %s DEINSTALL", REQUIRE_FNAME, pkg)) { warnx("package %s fails requirements %s", pkg, Force ? "" : "- not deleted"); @@ -250,11 +254,13 @@ pkg_do(char *pkg) post_script = pre_arg = post_arg = NULL; } - if (!NoDeInstall && pre_script != NULL && fexists(pre_script)) { + if (!NoDeInstall && pre_script != NULL && (fd = open(pre_script, O_RDWR)) != -1) { if (Fake) printf("Would execute de-install script at this point.\n"); else { - vsystem("/bin/chmod +x %s", pre_script); /* make sure */ + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (vsystem("./%s %s %s", pre_script, pkg, pre_arg)) { warnx("deinstall script returned error status"); if (!Force) @@ -318,19 +324,21 @@ pkg_do(char *pkg) */ if (delete_package(FALSE, CleanDirs, &Plist) == FAIL) warnx( - "couldn't entirely delete package (perhaps the packing list is\n" - "incorrectly specified?)"); + "couldn't entirely delete package `%s'\n" + "(perhaps the packing list is incorrectly specified?)", pkg); if (chdir(LogDir) == FAIL) { warnx("unable to change directory to %s! deinstall failed", LogDir); return 1; } - if (!NoDeInstall && post_script != NULL && fexists(post_script)) { + if (!NoDeInstall && post_script != NULL && (fd = open(post_script, O_RDWR)) != -1) { if (Fake) printf("Would execute post-deinstall script at this point.\n"); else { - vsystem("/bin/chmod +x %s", post_script); /* make sure */ + fstat(fd, &sb); + fchmod(fd, sb.st_mode | S_IXALL); /* be sure, chmod a+x */ + close(fd); if (vsystem("./%s %s %s", post_script, pkg, post_arg)) { warnx("post-deinstall script returned error status"); if (!Force) Modified: stable/7/usr.sbin/pkg_install/info/show.c ============================================================================== --- stable/7/usr.sbin/pkg_install/info/show.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/info/show.c Mon May 21 13:07:12 2012 (r235722) @@ -207,6 +207,14 @@ show_plist(const char *title, Package *p } } +static const char * +elide_root(const char *dir) +{ + if (strcmp(dir, "/") == 0) + return ""; + return dir; +} + /* Show all files in the packing list (except ignored ones) */ void show_files(const char *title, Package *plist) @@ -223,7 +231,7 @@ show_files(const char *title, Package *p switch(p->type) { case PLIST_FILE: if (!ign) - printf("%s/%s\n", dir, p->name); + printf("%s/%s\n", elide_root(dir), p->name); ign = FALSE; break; @@ -270,7 +278,7 @@ show_size(const char *title, Package *pl switch (p->type) { case PLIST_FILE: if (!ign) { - snprintf(tmp, FILENAME_MAX, "%s/%s", dir, p->name); + snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name); if (!lstat(tmp, &sb)) { size += sb.st_size; if (Verbose) @@ -328,7 +336,7 @@ show_cksum(const char *title, Package *p else dir = p->name; } else if (p->type == PLIST_FILE) { - snprintf(tmp, FILENAME_MAX, "%s/%s", dir, p->name); + snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name); if (!fexists(tmp)) warnx("%s doesn't exist", tmp); else if (p->next && p->next->type == PLIST_COMMENT && Modified: stable/7/usr.sbin/pkg_install/lib/file.c ============================================================================== --- stable/7/usr.sbin/pkg_install/lib/file.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/lib/file.c Mon May 21 13:07:12 2012 (r235722) @@ -31,10 +31,13 @@ __FBSDID("$FreeBSD$"); Boolean fexists(const char *fname) { - struct stat dummy; - if (!lstat(fname, &dummy)) - return TRUE; - return FALSE; + int fd; + + if ((fd = open(fname, O_RDONLY)) == -1) + return FALSE; + + close(fd); + return TRUE; } /* Quick check to see if something is a directory or symlink to a directory */ @@ -279,17 +282,23 @@ copy_file(const char *dir, const char *f } void -move_file(const char *dir, const char *fname, const char *to) +move_file(const char *dir, const char *fname, const char *tdir) { - char cmd[FILENAME_MAX]; + char from[FILENAME_MAX]; + char to[FILENAME_MAX]; if (fname[0] == '/') - snprintf(cmd, FILENAME_MAX, "/bin/mv %s %s", fname, to); + strncpy(from, fname, FILENAME_MAX); else - snprintf(cmd, FILENAME_MAX, "/bin/mv %s/%s %s", dir, fname, to); - if (vsystem(cmd)) { - cleanup(0); - errx(2, "%s: could not perform '%s'", __func__, cmd); + snprintf(from, FILENAME_MAX, "%s/%s", dir, fname); + + snprintf(to, FILENAME_MAX, "%s/%s", tdir, fname); + + if (rename(from, to) == -1) { + if (vsystem("/bin/mv %s %s", from, to)) { + cleanup(0); + errx(2, "%s: could not move '%s' to '%s'", __func__, from, to); + } } } Modified: stable/7/usr.sbin/pkg_install/lib/lib.h ============================================================================== --- stable/7/usr.sbin/pkg_install/lib/lib.h Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/lib/lib.h Mon May 21 13:07:12 2012 (r235722) @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,11 @@ #define YES 2 #define NO 1 +/* Some more stat macros. */ +#define S_IRALL 0000444 +#define S_IWALL 0000222 +#define S_IXALL 0000111 + /* Usually "rm", but often "echo" during debugging! */ #define REMOVE_CMD "/bin/rm" @@ -84,18 +90,6 @@ #define DISPLAY_FNAME "+DISPLAY" #define MTREE_FNAME "+MTREE_DIRS" -#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000 -#define INDEX_FNAME "INDEX-9" -#elif defined(__FreeBSD_version) && __FreeBSD_version >= 800000 -#define INDEX_FNAME "INDEX-8" -#elif defined(__FreeBSD_version) && __FreeBSD_version >= 700000 -#define INDEX_FNAME "INDEX-7" -#elif defined(__FreeBSD_version) && __FreeBSD_version >= 600000 -#define INDEX_FNAME "INDEX-6" -#else -#define INDEX_FNAME "INDEX" -#endif - #define CMD_CHAR '@' /* prefix for extended PLIST cmd */ /* The name of the "prefix" environment variable given to scripts */ @@ -105,7 +99,7 @@ * Version of the package tools - increase whenever you make a change * in the code that is not cosmetic only. */ -#define PKG_INSTALL_VERSION 20090902 +#define PKG_INSTALL_VERSION 20100403 #define PKG_WRAPCONF_FNAME "/var/db/pkg_install.conf" #define main(argc, argv) real_main(argc, argv) Modified: stable/7/usr.sbin/pkg_install/lib/match.c ============================================================================== --- stable/7/usr.sbin/pkg_install/lib/match.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/lib/match.c Mon May 21 13:07:12 2012 (r235722) @@ -267,7 +267,7 @@ matchallbyorigin(const char **origins, i */ if (isemptydir(tmp)) continue; - snprintf(tmp, PATH_MAX, "%s/%s", tmp, CONTENTS_FNAME); + strncat(tmp, "/" CONTENTS_FNAME, PATH_MAX); fp = fopen(tmp, "r"); if (fp == NULL) { warnx("the package info for package '%s' is corrupt", installed[i]); Modified: stable/7/usr.sbin/pkg_install/lib/pen.c ============================================================================== --- stable/7/usr.sbin/pkg_install/lib/pen.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/lib/pen.c Mon May 21 13:07:12 2012 (r235722) @@ -113,10 +113,6 @@ make_playpen(char *pen, off_t sz) cleanup(0); errx(2, "%s: can't mktemp '%s'", __func__, pen); } - if (chmod(pen, 0700) == FAIL) { - cleanup(0); - errx(2, "%s: can't mkdir '%s'", __func__, pen); - } if (Verbose) { if (sz) { Modified: stable/7/usr.sbin/pkg_install/lib/plist.c ============================================================================== --- stable/7/usr.sbin/pkg_install/lib/plist.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/lib/plist.c Mon May 21 13:07:12 2012 (r235722) @@ -551,7 +551,7 @@ delete_hierarchy(const char *dir, Boolea char *cp1, *cp2; cp1 = cp2 = strdup(dir); - if (!fexists(dir)) { + if (!fexists(dir) && !issymlink(dir)) { if (!ign_err) warnx("%s '%s' doesn't exist", isdir(dir) ? "directory" : "file", dir); Modified: stable/7/usr.sbin/pkg_install/lib/url.c ============================================================================== --- stable/7/usr.sbin/pkg_install/lib/url.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/lib/url.c Mon May 21 13:07:12 2012 (r235722) @@ -108,6 +108,10 @@ fileGetURL(const char *base, const char if ((ftp = fetchGetURL(fname, Verbose ? "v" : NULL)) == NULL) { printf("Error: Unable to get %s: %s\n", fname, fetchLastErrString); + /* If the fetch fails, yank the package. */ + if (keep_package && unlink(pkg) < 0 && Verbose) { + warnx("failed to remove partially fetched package: %s", pkg); + } return NULL; } Modified: stable/7/usr.sbin/pkg_install/updating/main.c ============================================================================== --- stable/7/usr.sbin/pkg_install/updating/main.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/updating/main.c Mon May 21 13:07:12 2012 (r235722) @@ -10,7 +10,11 @@ #include __FBSDID("$FreeBSD$"); + +#include +#include #include +#include #include #include #include @@ -115,10 +119,10 @@ main(int argc, char *argv[]) if (argc != 0) { pflag = 1; while (*argv) { - if((curr = (INSTALLEDPORT *) + if ((curr = (INSTALLEDPORT *) malloc(sizeof(INSTALLEDPORT))) == NULL) (void)exit(EXIT_FAILURE); - strlcpy (curr->name, *argv, strlen(*argv) + 1); + strlcpy(curr->name, *argv, strlen(*argv) + 1); curr->next = head; head = curr; (void)*argv++; @@ -131,22 +135,22 @@ main(int argc, char *argv[]) */ if (pflag == 0) { /* Open /var/db/pkg and search for all installed ports. */ - if((dir = opendir(pkgdbpath)) != NULL) { + if ((dir = opendir(pkgdbpath)) != NULL) { while ((pkgdbdir = readdir(dir)) != NULL) { if (strcmp(pkgdbdir->d_name, ".") != 0 && - strcmp(pkgdbdir->d_name, "..") !=0) { + strcmp(pkgdbdir->d_name, "..") != 0) { /* Create path to +CONTENTS file for each installed port */ - n = strlcpy(tmp_file, pkgdbpath, strlen(pkgdbpath)+1); + n = strlcpy(tmp_file, pkgdbpath, sizeof(tmp_file)); n = strlcpy(tmp_file + n, "/", sizeof(tmp_file) - n); n = strlcat(tmp_file + n, pkgdbdir->d_name, sizeof(tmp_file) - n); - if(stat(tmp_file, &attribute) == -1) { + if (stat(tmp_file, &attribute) == -1) { fprintf(stderr, "can't open %s: %s\n", tmp_file, strerror(errno)); return EXIT_FAILURE; } - if(attribute.st_mode & S_IFREG) + if (attribute.st_mode & S_IFREG) continue; (void)strlcat(tmp_file + n, "/", sizeof(tmp_file) - n); @@ -155,7 +159,7 @@ main(int argc, char *argv[]) /* Open +CONTENT file */ fd = fopen(tmp_file, "r"); - if(fd == NULL) { + if (fd == NULL) { fprintf(stderr, "warning: can't open %s: %s\n", tmp_file, strerror(errno)); continue; @@ -165,25 +169,25 @@ main(int argc, char *argv[]) * Parses +CONTENT for ORIGIN line and * put element into linked list. */ - while(fgets(originline, maxcharperline, fd) != NULL) { + while (fgets(originline, maxcharperline, fd) != NULL) { tmpline1 = strstr(originline, origin); - if( tmpline1 != NULL ) { + if (tmpline1 != NULL) { /* Tmp variable to store port name. */ char *pname; pname = strrchr(originline, (int)':'); pname++; - if((curr = (INSTALLEDPORT *) + if ((curr = (INSTALLEDPORT *) malloc(sizeof(INSTALLEDPORT))) == NULL) (void)exit(EXIT_FAILURE); if (pname[strlen(pname) - 1] == '\n') pname[strlen(pname) - 1] = '\0'; - strlcpy (curr->name, pname, strlen(pname)+1); + strlcpy (curr->name, pname, sizeof(curr->name)); curr->next = head; head = curr; } } - if(ferror(fd)) { + if (ferror(fd)) { fprintf(stderr, "error reading input\n"); exit(EX_IOERR); } @@ -195,32 +199,41 @@ main(int argc, char *argv[]) } } - /* Open UPDATING file */ - fd = fopen(updatingfile, "r"); - if(fd == NULL) { + /* Fetch UPDATING file if needed and open file */ + if (isURL(updatingfile)) { + if ((fd = fetchGetURL(updatingfile, "")) == NULL) { + fprintf(stderr, "Error: Unable to get %s: %s\n", + updatingfile, fetchLastErrString); + exit(EX_UNAVAILABLE); + } + } + else { + fd = fopen(updatingfile, "r"); + } + if (fd == NULL) { fprintf(stderr, "can't open %s: %s\n", - updatingfile, strerror(errno)); + updatingfile, strerror(errno)); exit(EX_UNAVAILABLE); } /* Parse opened UPDATING file. */ - while(fgets(updatingline, maxcharperline, fd) != NULL) { + while (fgets(updatingline, maxcharperline, fd) != NULL) { /* No entry is found so far */ if (found == 0) { /* Search for AFFECTS line to parse the portname. */ tmpline1 = strstr(updatingline, affects); - if( tmpline1 != NULL ) { + if (tmpline1 != NULL) { curr = head; - while(curr != NULL) { + while (curr != NULL) { tmpline2 = strstr(updatingline, curr->name); - if( tmpline2 != NULL ) + if (tmpline2 != NULL) break; curr = curr->next; } - if( tmpline2 != NULL ) { + if (tmpline2 != NULL) { /* If -d is set, check if entry is newer than the date. */ - if ( (dflag == 1) && (strncmp(dateline, date, 8) < 0)) + if ((dflag == 1) && (strncmp(dateline, date, 8) < 0)) continue; printf("%s", dateline); printf("%s", updatingline); @@ -231,7 +244,7 @@ main(int argc, char *argv[]) /* Search for the end of an entry, if not found print the line. */ else { tmpline1 = strstr(updatingline, end); - if( tmpline1 == NULL ) + if (tmpline1 == NULL) printf("%s", updatingline); else { linelength = strlen(updatingline); @@ -245,7 +258,7 @@ main(int argc, char *argv[]) dateline = strdup(updatingline); } - if(ferror(fd)) { + if (ferror(fd)) { fprintf(stderr, "error reading input\n"); exit(EX_IOERR); } Modified: stable/7/usr.sbin/pkg_install/updating/pkg_updating.1 ============================================================================== --- stable/7/usr.sbin/pkg_install/updating/pkg_updating.1 Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/updating/pkg_updating.1 Mon May 21 13:07:12 2012 (r235722) @@ -45,26 +45,31 @@ Print help message. .El .Sh EXAMPLES .Bl -tag -width indent -.Dl pkg_updating +Shows all entries of all installed ports: .Pp -Shows all entries of all installed ports. +.Dl % pkg_updating .Pp -.Dl pkg_updating -d 20070101 +Shows all entries of all installed ports since 2007-01-01: .Pp -Shows all entries of all installed ports since 2007-01-01. +.Dl % pkg_updating -d 20070101 .Pp -.Dl pkg_updating apache mysql +Shows all entries for all apache and mysql ports: .Pp -Shows all entries for all apache and mysql ports. +.Dl % pkg_updating apache mysql .Pp -.Dl pkg_updating -d 20060101 apache +Shows all apache entries since 2006-01-01: .Pp -Shows all apache entries since 2006-01-01. -.Pp -.Dl pkg_updating -f /tmp/UPDATING +.Dl % pkg_updating -d 20060101 apache .Pp Defines that the UPDATING file is in /tmp and shows all entries of all -installed ports +installed ports: +.Pp +.Dl % pkg_updating -f /tmp/UPDATING +.Pp +Fetch UPDATING file from ftp mirror and show all entries of all +installed ports: +.Pp +.Dl % pkg_updating -f ftp://ftp.freebsd.org/pub/FreeBSD/ports/packages/UPDATING .Pp .El .Sh ENVIRONMENT Modified: stable/7/usr.sbin/pkg_install/version/perform.c ============================================================================== --- stable/7/usr.sbin/pkg_install/version/perform.c Mon May 21 13:05:41 2012 (r235721) +++ stable/7/usr.sbin/pkg_install/version/perform.c Mon May 21 13:07:12 2012 (r235722) @@ -35,28 +35,41 @@ static int pkg_do(char *); static void show_version(Package, const char *, const char *); /* - * This is the traditional pkg_perform, except that the argument is _not_ - * a list of packages. It is the index file from the command line. + * This is the traditional pkg_perform, except that the argument is _not_ a + * list of packages. It is the index file from the command line. * - * We loop over the installed packages, matching them with the -s flag - * if needed and calling pkg_do(). Before hand we set up a few things, - * and after we tear them down... + * We loop over the installed packages, matching them with the -s flag if + * needed and calling pkg_do(). Beforehand we set up a few things, and after + * we tear them down... + * + * Returns 0 on success, non-zero on failure, corresponding to the number of + * failed attempts to access the INDEX. */ int pkg_perform(char **indexarg) { char **pkgs, *pat[2], **patterns; struct index_entry *ie; - int i, err_cnt = 0; + int i, err_cnt = 0, rel_major_ver; int MatchType; + struct utsname u; + + if (uname(&u) == -1) { + warn("%s(): failed to determine uname information", __func__); + return 1; + } else if ((rel_major_ver = (int) strtol(u.release, NULL, 10)) <= 0) { + + } + /* * Try to find and open the INDEX. We only check IndexFile != NULL * later, if we actually need the INDEX. */ - if (*indexarg == NULL) - snprintf(IndexPath, sizeof(IndexPath), "%s/%s", PORTS_DIR, INDEX_FNAME); - else + if (*indexarg == NULL) { + snprintf(IndexPath, sizeof(IndexPath), "%s/INDEX-%d", PORTS_DIR, + rel_major_ver); + } else strlcpy(IndexPath, *indexarg, sizeof(IndexPath)); if (isURL(IndexPath)) IndexFile = fetchGetURL(IndexPath, ""); From owner-svn-src-stable-7@FreeBSD.ORG Tue May 22 13:14:21 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E44FD106566B; Tue, 22 May 2012 13:14:21 +0000 (UTC) (envelope-from sbruno@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B42B38FC08; Tue, 22 May 2012 13:14:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4MDELhu003738; Tue, 22 May 2012 13:14:21 GMT (envelope-from sbruno@svn.freebsd.org) Received: (from sbruno@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4MDELMT003737; Tue, 22 May 2012 13:14:21 GMT (envelope-from sbruno@svn.freebsd.org) Message-Id: <201205221314.q4MDELMT003737@svn.freebsd.org> From: Sean Bruno Date: Tue, 22 May 2012 13:14:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235784 - stable/7/sys X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 May 2012 13:14:22 -0000 Author: sbruno Date: Tue May 22 13:14:21 2012 New Revision: 235784 URL: http://svn.freebsd.org/changeset/base/235784 Log: Update mergeinfo to reflect MFC r235634 Fix and update battery status bits according to linux driver Actual merge occured at r235636 Modified: Directory Properties: stable/7/sys/ (props changed) From owner-svn-src-stable-7@FreeBSD.ORG Fri May 25 04:27:09 2012 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0854A1065746; Fri, 25 May 2012 04:27:09 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E6E2A8FC0A; Fri, 25 May 2012 04:27:08 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4P4R8Tc080168; Fri, 25 May 2012 04:27:08 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4P4R8dU080164; Fri, 25 May 2012 04:27:08 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201205250427.q4P4R8dU080164@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Fri, 25 May 2012 04:27:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235970 - stable/7/sys/geom/mirror X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 May 2012 04:27:09 -0000 Author: ae Date: Fri May 25 04:27:08 2012 New Revision: 235970 URL: http://svn.freebsd.org/changeset/base/235970 Log: MFC r235599: Introduce new device flag G_MIRROR_DEVICE_FLAG_TASTING. It should protect geom from destroying while it is tasting. MFC r235600: Prevent removing of the last active component from a mirror. PR: kern/154860 Reviewed by: pjd Tested by: Eugene Grosbein Modified: stable/7/sys/geom/mirror/g_mirror.c stable/7/sys/geom/mirror/g_mirror.h stable/7/sys/geom/mirror/g_mirror_ctl.c Directory Properties: stable/7/sys/ (props changed) Modified: stable/7/sys/geom/mirror/g_mirror.c ============================================================================== --- stable/7/sys/geom/mirror/g_mirror.c Fri May 25 04:26:44 2012 (r235969) +++ stable/7/sys/geom/mirror/g_mirror.c Fri May 25 04:27:08 2012 (r235970) @@ -1690,6 +1690,8 @@ g_mirror_can_destroy(struct g_mirror_sof gp = sc->sc_geom; if (gp->softc == NULL) return (1); + if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_TASTING) != 0) + return (0); LIST_FOREACH(cp, &gp->consumer, consumer) { if (g_mirror_is_busy(sc, cp)) return (0); @@ -3041,6 +3043,7 @@ g_mirror_taste(struct g_class *mp, struc G_MIRROR_DEBUG(1, "Adding disk %s to %s.", pp->name, gp->name); g_topology_unlock(); sx_xlock(&sc->sc_lock); + sc->sc_flags |= G_MIRROR_DEVICE_FLAG_TASTING; error = g_mirror_add_disk(sc, pp, &md); if (error != 0) { G_MIRROR_DEBUG(0, "Cannot add disk %s to %s (error=%d).", @@ -3053,6 +3056,12 @@ g_mirror_taste(struct g_class *mp, struc } gp = NULL; } + sc->sc_flags &= ~G_MIRROR_DEVICE_FLAG_TASTING; + if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROY) != 0) { + g_mirror_destroy(sc, G_MIRROR_DESTROY_HARD); + g_topology_lock(); + return (NULL); + } sx_xunlock(&sc->sc_lock); g_topology_lock(); return (gp); Modified: stable/7/sys/geom/mirror/g_mirror.h ============================================================================== --- stable/7/sys/geom/mirror/g_mirror.h Fri May 25 04:26:44 2012 (r235969) +++ stable/7/sys/geom/mirror/g_mirror.h Fri May 25 04:27:08 2012 (r235970) @@ -157,6 +157,7 @@ struct g_mirror_event { #define G_MIRROR_DEVICE_FLAG_DESTROY 0x0100000000000000ULL #define G_MIRROR_DEVICE_FLAG_WAIT 0x0200000000000000ULL #define G_MIRROR_DEVICE_FLAG_DESTROYING 0x0400000000000000ULL +#define G_MIRROR_DEVICE_FLAG_TASTING 0x0800000000000000ULL #define G_MIRROR_DEVICE_STATE_STARTING 0 #define G_MIRROR_DEVICE_STATE_RUNNING 1 Modified: stable/7/sys/geom/mirror/g_mirror_ctl.c ============================================================================== --- stable/7/sys/geom/mirror/g_mirror_ctl.c Fri May 25 04:26:44 2012 (r235969) +++ stable/7/sys/geom/mirror/g_mirror_ctl.c Fri May 25 04:27:08 2012 (r235970) @@ -560,7 +560,7 @@ g_mirror_ctl_remove(struct gctl_req *req const char *name; char param[16]; int *nargs; - u_int i; + u_int i, active; nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs)); if (nargs == NULL) { @@ -587,6 +587,7 @@ g_mirror_ctl_remove(struct gctl_req *req "first."); return; } + active = g_mirror_ndisks(sc, G_MIRROR_DISK_STATE_ACTIVE); for (i = 1; i < (u_int)*nargs; i++) { snprintf(param, sizeof(param), "arg%u", i); name = gctl_get_asciiparam(req, param); @@ -599,6 +600,16 @@ g_mirror_ctl_remove(struct gctl_req *req gctl_error(req, "No such provider: %s.", name); continue; } + if (disk->d_state == G_MIRROR_DISK_STATE_ACTIVE) { + if (active > 1) + active--; + else { + gctl_error(req, "%s: Can't remove the last " + "ACTIVE component %s.", sc->sc_geom->name, + name); + continue; + } + } g_mirror_event_send(disk, G_MIRROR_DISK_STATE_DESTROY, G_MIRROR_EVENT_DONTWAIT); }