From owner-freebsd-standards Sun Mar 17 23:23:37 2002 Delivered-To: freebsd-standards@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id 8484537B400 for ; Sun, 17 Mar 2002 23:23:34 -0800 (PST) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g2I7HSW43513; Mon, 18 Mar 2002 02:17:28 -0500 (EST) (envelope-from mike) Date: Mon, 18 Mar 2002 02:17:28 -0500 From: Mike Barcroft To: Bruce Evans Cc: "M. Warner Losh" , standards@FreeBSD.ORG Subject: Re: Garrett's POSIX versions patch for review Message-ID: <20020318021728.D56122@espresso.q9media.com> References: <20020226.224449.28794535.imp@village.org> <20020227184645.K47808-100000@gamplex.bde.org> <20020227144359.R31007@espresso.q9media.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020227144359.R31007@espresso.q9media.com>; from mike@FreeBSD.ORG on Wed, Feb 27, 2002 at 02:43:59PM -0500 Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Mike Barcroft writes: [...] > +#if __POSIX_VISIBLE > +#define _POSIX_VERSION 200112 > +#define _KPOSIX_VERSION 200112 > +#endif > + > #endif /* !_SYS_CDEFS_H_ */ I ran into a little bit of trouble when testing this. Specifically, NOTES/LINT includes _KPOSIX_VERSION as an option. This conflicts with the ability to define _KPOSIX_VERSION in . Does _KPOSIX_VERSION have any use as a kernel option? It would seem to me that, in order to run a FreeBSD system at a different POSIX version than the one the system was designed to run at would require more than just a kernel configuration change. So, this define as a kernel option doesn't really buy us anything. Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Mar 18 11:26:16 2002 Delivered-To: freebsd-standards@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 2CE8937B404; Mon, 18 Mar 2002 11:26:15 -0800 (PST) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.11.4/8.11.6) id g2IJQEo33811; Mon, 18 Mar 2002 14:26:14 -0500 (EST) (envelope-from wollman) Date: Mon, 18 Mar 2002 14:26:14 -0500 (EST) From: Garrett Wollman Message-Id: <200203181926.g2IJQEo33811@khavrinen.lcs.mit.edu> To: Mike Barcroft Cc: standards@FreeBSD.ORG Subject: Re: Garrett's POSIX versions patch for review In-Reply-To: <20020318021728.D56122@espresso.q9media.com> References: <20020226.224449.28794535.imp@village.org> <20020227184645.K47808-100000@gamplex.bde.org> <20020227144359.R31007@espresso.q9media.com> <20020318021728.D56122@espresso.q9media.com> Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG < said: > Does _KPOSIX_VERSION have any use as a kernel option? I think it's bogus. Ask Peter Dufault what the intent was. -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Mar 18 13:43:56 2002 Delivered-To: freebsd-standards@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id CCE3E37B400; Mon, 18 Mar 2002 13:43:53 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id IAA27069; Tue, 19 Mar 2002 08:43:51 +1100 Date: Tue, 19 Mar 2002 08:43:54 +1100 (EST) From: Bruce Evans X-X-Sender: To: Mike Barcroft Cc: "M. Warner Losh" , Subject: Re: Garrett's POSIX versions patch for review In-Reply-To: <20020318021728.D56122@espresso.q9media.com> Message-ID: <20020319083700.B2957-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 18 Mar 2002, Mike Barcroft wrote: > I ran into a little bit of trouble when testing this. Specifically, > NOTES/LINT includes _KPOSIX_VERSION as an option. This conflicts with > the ability to define _KPOSIX_VERSION in . > > Does _KPOSIX_VERSION have any use as a kernel option? It would seem > to me that, in order to run a FreeBSD system at a different POSIX > version than the one the system was designed to run at would require > more than just a kernel configuration change. So, this define as a > kernel option doesn't really buy us anything. I agree with removing it. Only a similar compile-time option for the whole system would make sense. Too many options gives you namespace problems just for detemirmining the relevant options. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Mar 18 18:40:15 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id D21D537B405 for ; Mon, 18 Mar 2002 18:40:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2J2e1G74639; Mon, 18 Mar 2002 18:40:01 -0800 (PST) (envelope-from gnats) Received: from mx1.thinksec.com (time.thinksec.com [193.212.248.2]) by hub.freebsd.org (Postfix) with ESMTP id 691DE37B402 for ; Mon, 18 Mar 2002 18:30:01 -0800 (PST) Received: from des.thinksec.com (213-145-188-14.dd.nextgentel.com [213.145.188.14]) by mx1.thinksec.com (Postfix) with ESMTP id 6EA5D47DD1 for ; Tue, 19 Mar 2002 03:29:59 +0100 (CET) Received: by des.thinksec.com (Postfix, from userid 2602) id 6F19E55DD; Tue, 19 Mar 2002 03:29:44 +0100 (CET) Message-Id: <20020319022944.6F19E55DD@des.thinksec.com> Date: Tue, 19 Mar 2002 03:29:44 +0100 (CET) From: Dag-Erling Smorgrav Reply-To: Dag-Erling Smorgrav To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36070: Test PR Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36070 >Category: standards >Synopsis: Test PR >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 18 18:40:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Dag-Erling Smorgrav >Release: FreeBSD 5.0-CURRENT i386 >Organization: >Environment: System: FreeBSD des.thinksec.com 5.0-CURRENT FreeBSD 5.0-CURRENT #158: Sat Mar 16 02:35:13 CET 2002 des@des.thinksec.com:/usr/src/sys/i386/compile/DES i386 >Description: Testing new Gnats category. >How-To-Repeat: N/A >Fix: N/A >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Mar 18 18:40:33 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id D9FD137B41A for ; Mon, 18 Mar 2002 18:40:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2J2e2574659; Mon, 18 Mar 2002 18:40:02 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (044.a.006.mel.iprimus.net.au [210.50.44.44]) by hub.freebsd.org (Postfix) with ESMTP id B8DD937B405 for ; Mon, 18 Mar 2002 18:38:30 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2J2ahn00531; Tue, 19 Mar 2002 13:36:43 +1100 (EST) (envelope-from tim) Message-Id: <200203190236.g2J2ahn00531@descent.robbins.dropbear.id.au> Date: Tue, 19 Mar 2002 13:36:43 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36072: P1003.1-2001 join(1) -o 0 option Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36072 >Category: standards >Synopsis: P1003.1-2001 join(1) -o 0 option >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Mar 18 18:40:02 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #8: Tue Mar 19 08:46:39 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: -o 0 cannot be used with FreeBSD join(1) to specify that the join field be output. NOTE: This patch does not bring join(1) up to conformance; see the note I added to the STANDARDS section. As the example below shows, join is supposed to accept eg. -a 2 and -a2, whereas our join only accepts the latter. >How-To-Repeat: From the standard: The -o 0 field essentially selects the union of the join fields. For example, given file phone: !Name Phone Number Don +1 123-456-7890 Hal +1 234-567-8901 Yasushi +2 345-678-9012 and file fax: !Name Fax Number Don +1 123-456-7899 Keith +1 456-789-0122 Yasushi +2 345-678-9011 (where the large expanses of white space are meant to each represent a single ), the command: join -t "" -a 1 -a 2 -e '(unknown)' -o 0,1.2,2.2 phone fax would produce: !Name Phone Number Fax Number Don +1 123-456-7890 +1 123-456-7899 Hal +1 234-567-8901 (unknown) Keith (unknown) +1 456-789-0122 Yasushi +2 345-678-9012 +2 345-678-9011 >Fix: Index: join.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/join/join.1,v retrieving revision 1.7 diff -u -r1.7 join.1 --- join.1 2001/08/15 09:09:41 1.7 +++ join.1 2002/03/19 02:31:38 @@ -106,13 +106,16 @@ each line with matching join fields. Each element of .Ar list -has the form +has the either the form .Ql file_number.field , where .Ar file_number is a file number and .Ar field -is a field number. +is a field number, or the form +.Ql 0 +.Pq zero , +representing the join field. The elements of list must be either comma .Pf ( Dq , Ns ) or whitespace separated. @@ -216,9 +219,11 @@ .Sh STANDARDS The .Nm -command is expected to be -.St -p1003.2 -compatible. +command conforms to +.St -p1003.1-2001 +except for the requirement that there be no space between the +.Fl a +option and its argument. .Sh SEE ALSO .Xr awk 1 , .Xr comm 1 , Index: join.c =================================================================== RCS file: /home/ncvs/src/usr.bin/join/join.c,v retrieving revision 1.10 diff -u -r1.10 join.c --- join.c 1999/08/28 01:02:19 1.10 +++ join.c 2002/03/19 02:31:41 @@ -405,6 +405,8 @@ for (cnt = 0; cnt < olistcnt; ++cnt) { if (olist[cnt].filenum == F->number) outfield(lp, olist[cnt].fieldno, 0); + else if (olist[cnt].filenum == 0) + outfield(lp, F->joinf, 0); else outfield(lp, 0, 1); } @@ -427,7 +429,12 @@ /* Output a pair of lines according to the join list (if any). */ if (olist) for (cnt = 0; cnt < olistcnt; ++cnt) - if (olist[cnt].filenum == 1) + if (olist[cnt].filenum == 0) { + if (lp1->fieldcnt >= F1->joinf) + outfield(lp1, F1->joinf, 0); + else + outfield(lp2, F2->joinf, 0); + } else if (olist[cnt].filenum == 1) outfield(lp1, olist[cnt].fieldno, 0); else /* if (olist[cnt].filenum == 2) */ outfield(lp2, olist[cnt].fieldno, 0); @@ -480,27 +487,33 @@ fieldarg(option) char *option; { - u_long fieldno; + u_long fieldno, filenum; char *end, *token; while ((token = strsep(&option, ", \t")) != NULL) { if (*token == '\0') continue; - if (token[0] != '1' && token[0] != '2' || token[1] != '.') - errx(1, "malformed -o option field"); - fieldno = strtol(token + 2, &end, 10); - if (*end) + if (token[0] == '0') + filenum = fieldno = 0; + else if ((token[0] == '1' || token[0] == '2') && + token[1] == '.') { + filenum = token[0] - '0'; + fieldno = strtol(token + 2, &end, 10); + if (*end) + errx(1, "malformed -o option field"); + if (fieldno == 0) + errx(1, "field numbers are 1 based"); + --fieldno; + } else errx(1, "malformed -o option field"); - if (fieldno == 0) - errx(1, "field numbers are 1 based"); if (olistcnt == olistalloc) { olistalloc += 50; if ((olist = realloc(olist, olistalloc * sizeof(OLIST))) == NULL) err(1, NULL); } - olist[olistcnt].filenum = token[0] - '0'; - olist[olistcnt].fieldno = fieldno - 1; + olist[olistcnt].filenum = filenum; + olist[olistcnt].fieldno = fieldno; ++olistcnt; } } @@ -567,6 +580,8 @@ if (ap[2] != '\0') break; for (p = argv + 2; *p; ++p) { + if (p[0][0] == '0') + break; if (p[0][0] != '1' && p[0][0] != '2' || p[0][1] != '.') break; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Mar 18 18:46: 1 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 0ED6537B42F; Mon, 18 Mar 2002 18:45:52 -0800 (PST) Received: (from des@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2J2jpQ81183; Mon, 18 Mar 2002 18:45:51 -0800 (PST) (envelope-from des) Date: Mon, 18 Mar 2002 18:45:51 -0800 (PST) From: Message-Id: <200203190245.g2J2jpQ81183@freefall.freebsd.org> To: des@ofug.org, des@FreeBSD.org, freebsd-standards@FreeBSD.org Subject: Re: standards/36070: Test PR Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Synopsis: Test PR State-Changed-From-To: open->closed State-Changed-By: des State-Changed-When: Mon Mar 18 18:45:49 PST 2002 State-Changed-Why: Seems to work fine. http://www.freebsd.org/cgi/query-pr.cgi?pr=36070 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Mar 18 18:50:42 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 00C0937B435 for ; Mon, 18 Mar 2002 18:50:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2J2o1M85996; Mon, 18 Mar 2002 18:50:01 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (044.a.006.mel.iprimus.net.au [210.50.44.44]) by hub.freebsd.org (Postfix) with ESMTP id 1A8C537B402 for ; Mon, 18 Mar 2002 18:44:35 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2J2ghC00736; Tue, 19 Mar 2002 13:42:43 +1100 (EST) (envelope-from tim) Message-Id: <200203190242.g2J2ghC00736@descent.robbins.dropbear.id.au> Date: Tue, 19 Mar 2002 13:42:43 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36074: paste(1) should not accept no arguments Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36074 >Category: standards >Synopsis: paste(1) should not accept no arguments >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 18 18:50:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #8: Tue Mar 19 08:46:39 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: When invoked with no arguments, paste(1) does nothing instead of giving a usage error message, like its usage and SYNOPSIS would indicate, as well as the standard. >How-To-Repeat: paste >Fix: Index: paste/paste.c =================================================================== RCS file: /home/ncvs/src/usr.bin/paste/paste.c,v retrieving revision 1.6 diff -u -r1.6 paste.c --- paste/paste.c 1999/08/28 01:04:53 1.6 +++ paste/paste.c 2002/03/02 17:40:30 @@ -88,6 +88,9 @@ argc -= optind; argv += optind; + if (*argv == NULL) + usage(); + if (!delim) { delimcnt = 1; delim = "\t"; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Mar 18 19: 0:43 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 8B5C837B41A for ; Mon, 18 Mar 2002 19:00:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2J303496654; Mon, 18 Mar 2002 19:00:03 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (044.a.006.mel.iprimus.net.au [210.50.44.44]) by hub.freebsd.org (Postfix) with ESMTP id 845D037B400 for ; Mon, 18 Mar 2002 18:59:41 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2J2vM401093; Tue, 19 Mar 2002 13:57:22 +1100 (EST) (envelope-from tim) Message-Id: <200203190257.g2J2vM401093@descent.robbins.dropbear.id.au> Date: Tue, 19 Mar 2002 13:57:22 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36076: Implementation of POSIX fuser command Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36076 >Category: standards >Synopsis: Implementation of POSIX fuser command >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Mar 18 19:00:02 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #8: Tue Mar 19 08:46:39 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: FreeBSD is missing the P1003.1-2001 fuser command. >How-To-Repeat: N/A >Fix: A shell script wrapper around the more powerful fstat utility that modifies its inputs and outputs to act like fuser. Script was tested with FreeBSD /bin/sh and AT&T ksh93 from ports. # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # fuser.1 # fuser.sh # echo x - fuser.1 sed 's/^X//' >fuser.1 << 'END-of-fuser.1' X.\" Copyright (c) 2002 Tim J. Robbins. X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X.\" SUCH DAMAGE. X.\" X.\" $FreeBSD$ X.\" $Id: fuser.1,v 1.2 2002/02/17 23:14:44 tim Exp $ X.\" X.Dd February 9, 2002 X.Dt FUSER 1 X.Os X.Sh NAME X.Nm fuser X.Nd list process IDs of all processes that have one or more files open X.Sh SYNOPSIS X.Nm X.Op Fl c | f X.Op Fl mu X.Op Fl M Ar core X.Op Fl N Ar system X.Ar X.Sh DESCRIPTION XThe X.Nm Xutility writes to standard output the process IDs of processes that Xhave one or more of the specified X.Ar file Xarguments open. X.Pp XIf a X.Ar file Xargument is a block special device, all processes using any file on that Xdevice are listed. X.Pp XAdditional information about the open files is written to standard error. X.Pp XThe options are as follows: X.Bl -tag -width indent X.It Fl M Ar core XExtract values associated with the name list from X.Ar core Xinstead of X.Pa /dev/kmem . X.It Fl N Ar system XExtract the name list from X.Ar system Xinstead of X.Pa /kernel . X.It Fl c XTreat the X.Ar file Xarguments as mount points and list all files open on these file systems. X.It Fl f XDisable special processing for block special devices. X.It Fl m XInclude information about memory mapped files. X.It Fl u XInclude the user who owns each process in the output. X.El X.Pp XThe format of the output is: X.Bl -bullet -offset indent X.It XFile or mount point name, followed by a colon X.Pq Ql \&: ; X.It XProcess ID; X.It XZero or more of the following flags, indicating how the file is being used: X.Bl -tag -width z X.It Cm c XProcess's working directory X.It Cm r XProcess's root directory X.It Cm x XExecutable text X.It Cm t XKernel trace file X.It Cm m XMemory mapped file X.El X.It XIf the X.Fl u Xoption is given, the user name of the process's owner, in parentheses. X.El X.Sh EXAMPLES XKill all processes with X.Pa foo.c Xopen: X.D1 kill `fuser foo.c` X.Sh DIAGNOSTICS X.Ex -std X.Sh SEE ALSO X.Xr fstat 1 , X.Xr ktrace 1 X.Sh STANDARDS XThe X.Nm Xutility is designed to comply with the X.St -p1003.1-2001 Xspecification. X.Sh BUGS XThe user name associated with the process's effective user ID is written Xinstead of that of the real user ID. END-of-fuser.1 echo x - fuser.sh sed 's/^X//' >fuser.sh << 'END-of-fuser.sh' X#!/bin/sh X# X# Copyright (c) 2002 Tim J. Robbins. X# All rights reserved. X# X# Redistribution and use in source and binary forms, with or without X# modification, are permitted provided that the following conditions X# are met: X# 1. Redistributions of source code must retain the above copyright X# notice, this list of conditions and the following disclaimer. X# 2. Redistributions in binary form must reproduce the above copyright X# notice, this list of conditions and the following disclaimer in the X# documentation and/or other materials provided with the distribution. X# X# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X# SUCH DAMAGE. X# X X# X# fuser - list process IDs of all processes that have one or more files open X# This is a wrapper script around fstat(1). X# X# $FreeBSD$ X# $Id: fuser.sh,v 1.2 2002/02/17 23:14:56 tim Exp $ X# X Xcflag=0 Xfflag=0 Xuflag=0 Xfstatopts="" Xwhile getopts M:N:cfmu ch; do X case $ch in X M) # Choose memory file X fstatopts="$fstatopts -M $OPTARG" X ;; X N) # Choose kernel file X fstatopts="$fstatopts -N $OPTARG" X ;; X c) # Treat as mount point X cflag=1 X ;; X f) # Show open block devices X fflag=1 X ;; X m) # Show memory mapped files X fstatopts="$fstatopts -m" X ;; X u) # Print user names X uflag=1 X ;; X esac Xdone X Xshift $(($OPTIND - 1)) Xif [ $# -eq 0 -o \( $cflag -eq 1 -a $fflag -eq 1 \) ]; then X echo "usage: fuser [-c|-f] [-mu] [-M core] [-N system] file..." >&2 X exit 64 Xfi X Xfor f in $*; do X if [ $cflag -eq 1 ]; then X fstat -f $fstatopts -- "$f" X else X mtpt=`mount | grep -we "^$f" | cut -d" " -f3` X if [ "$mtpt" != "" -a $fflag -ne 1 ]; then X fstat $fstatopts -f -- "$mtpt" X else X fstat $fstatopts -- "$f" X fi X fi | tail -n +2 | while read user cmd pid fd junk; do X echo -n "$f: " >&2 X echo -n "$pid " X case $fd in X wd) X echo -n c >&2 X ;; X root) X echo -n r >&2 X ;; X text) X echo -n x >&2 X ;; X tr) X echo -n t >&2 X ;; X mmap) X echo -n m >&2 X ;; X esac X if [ $uflag -eq 1 ]; then X echo -n "($user)" >&2 X fi X echo >&2 X done Xdone END-of-fuser.sh exit >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Mar 18 19: 0:47 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 5FC1437B419 for ; Mon, 18 Mar 2002 19:00:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2J302j96645; Mon, 18 Mar 2002 19:00:02 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (044.a.006.mel.iprimus.net.au [210.50.44.44]) by hub.freebsd.org (Postfix) with ESMTP id 0A55B37B402 for ; Mon, 18 Mar 2002 18:54:24 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2J2qBC00914; Tue, 19 Mar 2002 13:52:11 +1100 (EST) (envelope-from tim) Message-Id: <200203190252.g2J2qBC00914@descent.robbins.dropbear.id.au> Date: Tue, 19 Mar 2002 13:52:11 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36075: P1003.1-2001 m4(1) -s option Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36075 >Category: standards >Synopsis: P1003.1-2001 m4(1) -s option >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Mar 18 19:00:02 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #8: Tue Mar 19 08:46:39 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: FreeBSD m4 is missing the P1003.1-2001 -s option. This patch adds it. It also adds an EXIT STATUS section to the manual page. -s Enable line synchronization output for the c99 preprocessor phase (that is, #line directives). >How-To-Repeat: N/A >Fix: Index: eval.c =================================================================== RCS file: /home/ncvs/src/usr.bin/m4/eval.c,v retrieving revision 1.14 diff -u -r1.14 eval.c --- eval.c 2001/07/24 14:09:47 1.14 +++ eval.c 2002/03/19 02:49:44 @@ -584,7 +584,11 @@ errx(1, "too many include files"); if ((infile[ilevel + 1] = fopen(ifile, "r")) != NULL) { ilevel++; + if ((inname[ilevel] = strdup(ifile)) == NULL) + err(1, NULL); + inlineno[ilevel] = 1; bbase[ilevel] = bufbase = bp; + emitline(); return (1); } else @@ -604,9 +608,11 @@ register int c; if ((pf = fopen(pfile, "r")) != NULL) { + fprintf(active, "#line 1 \"%s\"\n", pfile); while ((c = getc(pf)) != EOF) putc(c, active); (void) fclose(pf); + emitline(); return (1); } else Index: extern.h =================================================================== RCS file: /home/ncvs/src/usr.bin/m4/extern.h,v retrieving revision 1.5 diff -u -r1.5 extern.h --- extern.h 2001/07/24 14:09:47 1.5 +++ extern.h 2002/03/19 02:49:44 @@ -53,6 +53,7 @@ void dopushdef __P((char *, char *)); void dosub __P((char *[], int)); void doundiv __P((char *[], int)); +void emitline __P((void)); void eval __P((char *[], int, int)); void expand __P((char *[], int)); void getdiv __P((int)); @@ -72,6 +73,8 @@ extern stae mstack[]; /* stack of m4 machine */ extern FILE *active; /* active output file pointer */ extern FILE *infile[]; /* input file stack (0=stdin) */ +extern char *inname[]; /* names of these input files */ +extern int inlineno[]; /* current number in each input*/ extern FILE *outfile[]; /* diversion array(0=bitbucket) */ extern int fp; /* m4 call frame pointer */ extern int ilevel; /* input file stack pointer */ @@ -92,3 +95,5 @@ extern char *null; /* as it says.. just a null. */ extern char rquote; /* right quote character (') */ extern char scommt; /* start character for comment */ +extern int synccpp; /* Line synchronisation for C preprocessor */ +extern int chscratch; /* Scratch space for gpbc() macro */ Index: m4.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/m4/m4.1,v retrieving revision 1.12 diff -u -r1.12 m4.1 --- m4.1 2001/07/15 08:01:24 1.12 +++ m4.1 2002/03/19 02:49:45 @@ -10,9 +10,9 @@ .Sh SYNOPSIS .Nm .Oo -.Fl D Ns Ar name Ns Op Ar =value +.Fl D Ar name Ns Op Ar =value .Oc -.Op Fl U Ns Ar name +.Op Fl U Ar name .Op Ar filename \|.\|.\|. .Sh DESCRIPTION @@ -41,13 +41,18 @@ .Pp The options are as follows: .Bl -tag -width "-Dname[=value]xxx" -.It Fl D Ns Ar name Ns Oo +.It Fl s +Emit +.Em #line +directives for +.Xr cpp 1 . +.It Fl D Ar name Ns Oo .Ar =value .Oc Define the symbol .Ar name to have some value (or NULL). -.It Fl "U" Ns Ar "name" +.It Fl "U" Ar "name" Undefine the symbol .Ar name . .El @@ -177,7 +182,34 @@ .It unix A pre-defined macro for testing the OS platform. .El +.Sh DIAGNOSTICS +.Ex -std +.Pp +The exit status can be specified by the input file using the +.Em m4exit +macro. +.Sh STANDARDS +The +.Nm +utility is compatible with the +.St -p1003.1-2001 +specification with the exception of the +.Em traceon +and +.Em traceoff +built-in macros, which are not implemented. +.Pp +The +.Em expr , +.Em paste , +.Em spaste +and +.Em unix +built-in macros are extensions to the standard. +.Sh "SEE ALSO" +.Xr cpp 1 .Sh AUTHORS .An Ozan Yigit Aq oz@sis.yorku.ca -and .An Richard A. O'Keefe Aq ok@goanna.cs.rmit.OZ.AU +.Sh BUGS +The tracing macros are not implemented. Index: main.c =================================================================== RCS file: /home/ncvs/src/usr.bin/m4/main.c,v retrieving revision 1.11 diff -u -r1.11 main.c --- main.c 2001/07/24 14:09:47 1.11 +++ main.c 2002/03/19 02:49:46 @@ -80,6 +80,8 @@ int sp; /* current m4 stack pointer */ int fp; /* m4 call frame pointer */ FILE *infile[MAXINP]; /* input file stack (0=stdin) */ +char *inname[MAXINP]; /* names of these input files */ +int inlineno[MAXINP]; /* current number in each input*/ FILE *outfile[MAXOUT]; /* diversion array(0=bitbucket)*/ FILE *active; /* active output file pointer */ char *m4temp; /* filename for diversions */ @@ -92,6 +94,8 @@ char rquote = RQUOTE; /* right quote character (') */ char scommt = SCOMMT; /* start character for comment */ char ecommt = ECOMMT; /* end character for comment */ +int synccpp = 0; /* Line synchronisation for C preprocessor */ +int chscratch = 0; /* Scratch space for gpbc() macro */ struct keyblk keywrds[] = { /* m4 keywords to be installed */ "include", INCLTYPE, @@ -159,7 +163,7 @@ initkwds(); - while ((c = getopt(argc, argv, "tD:U:o:")) != -1) + while ((c = getopt(argc, argv, "D:U:s")) != -1) switch(c) { case 'D': /* define something..*/ @@ -173,7 +177,9 @@ case 'U': /* undefine... */ remhash(optarg, TOP); break; - case 'o': /* specific output */ + case 's': + synccpp = 1; + break; case '?': usage(); } @@ -195,6 +201,10 @@ sp = -1; /* stack pointer initialized */ fp = 0; /* frame pointer initialized */ infile[0] = stdin; /* default input (naturally) */ + if ((inname[0] = strdup("-")) == NULL) + err(1, NULL); + inlineno[0] = 1; + emitline(); macro(); } else for (; argc--; ++argv) { @@ -206,6 +216,10 @@ sp = -1; fp = 0; infile[0] = ifp; + if ((inname[0] = strdup(p)) == NULL) + err(1, NULL); + inlineno[0] = 1; + emitline(); macro(); if (ifp != stdin) (void)fclose(ifp); @@ -282,7 +296,9 @@ break; /* all done thanks.. */ --ilevel; (void) fclose(infile[ilevel+1]); + free(inname[ilevel+1]); bufbase = bbase[ilevel]; + emitline(); continue; } /* @@ -418,4 +434,13 @@ p->defn = null; p->type = keywrds[i].ktyp | STATIC; } +} + +/* Emit preprocessor #line directive if -s option used. */ +void +emitline() +{ + if (synccpp) + fprintf(active, "#line %d \"%s\"\n", inlineno[ilevel], + inname[ilevel]); } Index: mdef.h =================================================================== RCS file: /home/ncvs/src/usr.bin/m4/mdef.h,v retrieving revision 1.3 diff -u -r1.3 mdef.h --- mdef.h 1995/05/30 06:31:35 1.3 +++ mdef.h 2002/03/19 02:49:47 @@ -142,7 +142,9 @@ * pushf() - push a call frame entry onto stack * pushs() - push a string pointer onto stack */ -#define gpbc() (bp > bufbase) ? (*--bp ? *bp : EOF) : getc(infile[ilevel]) +#define gpbc() (bp > bufbase) ? (*--bp ? *bp : EOF) : \ + ((chscratch = getc(infile[ilevel])) == '\n' && ++inlineno[ilevel], \ + chscratch) #define pushf(x) if (sp < STACKMAX) mstack[++sp].sfra = (x) #define pushs(x) if (sp < STACKMAX) mstack[++sp].sstr = (x) Index: misc.c =================================================================== RCS file: /home/ncvs/src/usr.bin/m4/misc.c,v retrieving revision 1.8 diff -u -r1.8 misc.c --- misc.c 2001/07/24 14:09:47 1.8 +++ misc.c 2002/03/19 02:49:47 @@ -219,6 +219,7 @@ void usage() { - fprintf(stderr, "usage: m4 [-Dname[=val]] [-Uname]\n"); + fprintf(stderr, +"usage: m4 [-s] [-D name[=val]]... [-U name]... file...\n"); exit(1); } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Mar 18 19:20: 8 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 5DC1037B417 for ; Mon, 18 Mar 2002 19:20:06 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2J3K6U23297; Mon, 18 Mar 2002 19:20:06 -0800 (PST) (envelope-from gnats) Date: Mon, 18 Mar 2002 19:20:06 -0800 (PST) Message-Id: <200203190320.g2J3K6U23297@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: "Tim J. Robbins" Subject: Re: standards/36076: Implementation of POSIX fuser command Reply-To: "Tim J. Robbins" Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The following reply was made to PR standards/36076; it has been noted by GNATS. From: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.ORG Cc: Subject: Re: standards/36076: Implementation of POSIX fuser command Date: Tue, 19 Mar 2002 14:12:42 +1100 On Tue, Mar 19, 2002 at 01:57:22PM +1100, Tim J. Robbins wrote: > > # This archive contains: > # > # fuser.1 > # fuser.sh Here is the Makefile. Oops. # $FreeBSD$ # $Id: Makefile,v 1.2 2002/02/17 23:15:08 tim Exp $ SCRIPTS=fuser.sh MAN= fuser.1 .include To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Mar 19 0:10: 8 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3A7C537B404 for ; Tue, 19 Mar 2002 00:10:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2J8A3761846; Tue, 19 Mar 2002 00:10:03 -0800 (PST) (envelope-from gnats) Date: Tue, 19 Mar 2002 00:10:03 -0800 (PST) Message-Id: <200203190810.g2J8A3761846@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: "Tim J. Robbins" Subject: Re: standards/36076: Implementation of POSIX fuser command Reply-To: "Tim J. Robbins" Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The following reply was made to PR standards/36076; it has been noted by GNATS. From: "Tim J. Robbins" To: Garrett Wollman Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: standards/36076: Implementation of POSIX fuser command Date: Tue, 19 Mar 2002 19:02:54 +1100 On Mon, Mar 18, 2002 at 10:38:42PM -0500, Garrett Wollman wrote: > This script breaks when the argument to -M contains shell field > separators. Thanks for the info; here is an updated version of the script that fixes this problem, as well as a problem in the output format caused by my misreading of the standard (the output is the same as Solaris now, except that it seems to use tabs where I use spaces). #!/bin/sh # # Copyright (c) 2002 Tim J. Robbins. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # # fuser - list process IDs of all processes that have one or more files open # This is a wrapper script around fstat(1). # # $FreeBSD$ # $Id: fuser.sh,v 1.4 2002/03/19 07:58:05 tim Exp $ # cflag=0 fflag=0 uflag=0 opt_M="" opt_N="" opt_m="" while getopts M:N:cfmu ch; do case $ch in M) # Choose memory file opt_M="$OPTARG" ;; N) # Choose kernel file opt_N="$OPTARG" ;; c) # Treat as mount point cflag=1 ;; f) # Show open block devices fflag=1 ;; m) # Show memory mapped files opt_m="-m" ;; u) # Print user names uflag=1 ;; esac done shift $(($OPTIND - 1)) if [ $# -eq 0 -o \( $cflag -eq 1 -a $fflag -eq 1 \) ]; then echo "usage: fuser [-c|-f] [-mu] [-M core] [-N system] file..." >&2 exit 64 fi for f in $*; do echo -n "$f: " >&2 if [ $cflag -eq 1 ]; then fstat ${opt_M:+"-M${opt_M}"} ${opt_N:+"-N${opt_N}"} \ $opt_m -f -- "$f" else mtpt=`mount | awk '$1 == "'"$f"'" { print $3; }'` if [ "$mtpt" != "" -a $fflag -ne 1 ]; then fstat ${opt_M:+"-M${opt_M}"} ${opt_N:+"-N${opt_N}"} \ $opt_m -f -- "$mtpt" else fstat ${opt_M:+"-M${opt_M}"} ${opt_N:+"-N${opt_N}"} \ $opt_m -- "$f" fi fi | tail -n +2 | while read user cmd pid fd junk; do echo -n "$pid" case $fd in wd) echo -n c >&2 ;; root) echo -n r >&2 ;; text) echo -n x >&2 ;; tr) echo -n t >&2 ;; mmap) echo -n m >&2 ;; esac if [ $uflag -eq 1 ]; then echo -n "($user)" >&2 fi echo -n " " done echo >&2 done To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Mar 19 1:41:39 2002 Delivered-To: freebsd-standards@freebsd.org Received: from straylight.ringlet.net (discworld.nanolink.com [217.75.135.248]) by hub.freebsd.org (Postfix) with SMTP id EC54837B400 for ; Tue, 19 Mar 2002 01:41:33 -0800 (PST) Received: (qmail 11134 invoked by uid 1000); 19 Mar 2002 09:06:34 -0000 Date: Tue, 19 Mar 2002 11:06:34 +0200 From: Peter Pentchev To: "Tim J. Robbins" Cc: freebsd-standards@FreeBSD.org Subject: Re: standards/36076: Implementation of POSIX fuser command Message-ID: <20020319110634.H9136@straylight.oblivion.bg> References: <200203190810.g2J8A3761846@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="dMyqICaxQaaUjrCL" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <200203190810.g2J8A3761846@freefall.freebsd.org>; from tim@robbins.dropbear.id.au on Tue, Mar 19, 2002 at 12:10:03AM -0800 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --dMyqICaxQaaUjrCL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 19, 2002 at 12:10:03AM -0800, Tim J. Robbins wrote: > On Mon, Mar 18, 2002 at 10:38:42PM -0500, Garrett Wollman wrote: > =20 > > This script breaks when the argument to -M contains shell field > > separators. > =20 > Thanks for the info; here is an updated version of the script that > fixes this problem, as well as a problem in the output format caused > by my misreading of the standard (the output is the same as Solaris now, > except that it seems to use tabs where I use spaces). I must admit that I am a bit wary of having a shell script wrapper; there are many ways a shell command could go wrong - field separators, backticks, variable expansions... IMVHO, a Perl script might make things a bit more secure. What do others think? G'luck, Peter --=20 Peter Pentchev roam@ringlet.net roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 "yields falsehood, when appended to its quotation." yields falsehood, when = appended to its quotation. --dMyqICaxQaaUjrCL Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjyW/5oACgkQ7Ri2jRYZRVPu7gCePMbQxv6J92neMSRBEqXHdG1T qgEAni9ZhCKjHhVC1qgo9YX8GqzbpdgG =DPE9 -----END PGP SIGNATURE----- --dMyqICaxQaaUjrCL-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Mar 19 1:56:37 2002 Delivered-To: freebsd-standards@freebsd.org Received: from mailhub.fokus.gmd.de (mailhub.fokus.gmd.de [193.174.154.14]) by hub.freebsd.org (Postfix) with ESMTP id AD12037B400 for ; Tue, 19 Mar 2002 01:56:34 -0800 (PST) Received: from beagle (beagle [193.175.132.100]) by mailhub.fokus.gmd.de (8.11.6/8.11.6) with ESMTP id g2J9u8t23208; Tue, 19 Mar 2002 10:56:08 +0100 (MET) Date: Tue, 19 Mar 2002 10:56:08 +0100 (CET) From: Harti Brandt To: Peter Pentchev Cc: "Tim J. Robbins" , Subject: Re: standards/36076: Implementation of POSIX fuser command In-Reply-To: <20020319110634.H9136@straylight.oblivion.bg> Message-ID: <20020319105215.O62790-100000@beagle.fokus.gmd.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, 19 Mar 2002, Peter Pentchev wrote: PP>On Tue, Mar 19, 2002 at 12:10:03AM -0800, Tim J. Robbins wrote: PP>> On Mon, Mar 18, 2002 at 10:38:42PM -0500, Garrett Wollman wrote: PP>> PP>> > This script breaks when the argument to -M contains shell field PP>> > separators. PP>> PP>> Thanks for the info; here is an updated version of the script that PP>> fixes this problem, as well as a problem in the output format caused PP>> by my misreading of the standard (the output is the same as Solaris now, PP>> except that it seems to use tabs where I use spaces). PP> PP>I must admit that I am a bit wary of having a shell script wrapper; PP>there are many ways a shell command could go wrong - field separators, PP>backticks, variable expansions... IMVHO, a Perl script might make PP>things a bit more secure. What do others think? Nice move to start a bikeshed... Any script in any language can go wrong if badly written. If correctly written shell scripts are by no means more insecure than perl scripts. And they don't depend on perl beeing installed :-) It would be helpful if you'd name your concrete concerns with Tim's script. Regards, harti -- harti brandt, http://www.fokus.gmd.de/research/cc/cats/employees/hartmut.brandt/private brandt@fokus.fhg.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Mar 19 2: 7: 1 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (211.c.004.mel.iprimus.net.au [210.50.38.211]) by hub.freebsd.org (Postfix) with ESMTP id 2564A37B404 for ; Tue, 19 Mar 2002 02:06:56 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2JA5pc02696; Tue, 19 Mar 2002 21:05:51 +1100 (EST) (envelope-from tim) Date: Tue, 19 Mar 2002 21:05:50 +1100 From: "Tim J. Robbins" To: Peter Pentchev Cc: freebsd-standards@FreeBSD.ORG Subject: Re: standards/36076: Implementation of POSIX fuser command Message-ID: <20020319210550.A2621@descent.robbins.dropbear.id.au> References: <200203190810.g2J8A3761846@freefall.freebsd.org> <20020319110634.H9136@straylight.oblivion.bg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020319110634.H9136@straylight.oblivion.bg>; from roam@ringlet.net on Tue, Mar 19, 2002 at 11:06:34AM +0200 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, Mar 19, 2002 at 11:06:34AM +0200, Peter Pentchev wrote: > I must admit that I am a bit wary of having a shell script wrapper; > there are many ways a shell command could go wrong - field separators, > backticks, variable expansions... IMVHO, a Perl script might make > things a bit more secure. What do others think? I was under the impression that FreeBSD was slowly moving away from having perl in the base system but I'll write a perl version if necessary, but even that won't remove some limitations (eg. spaces in command names). AFAIK, the only problem with the current fuser script is that it chokes on filenames with quotes in them (due to the |awk). The only safe way to do it is to write it in C using similar techniques to those fstat uses, but that requires more effort and introduces yet another sgid kmem binary. Although not an excuse for introducing new 'bad' code into the tree, it's worth pointing out that rcp/scp can't copy files with shell meta- characters in their names, and nobody seems to have complained. Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Mar 19 2:27:18 2002 Delivered-To: freebsd-standards@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id 5378337B400 for ; Tue, 19 Mar 2002 02:27:15 -0800 (PST) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g2JAKvP92304; Tue, 19 Mar 2002 05:20:57 -0500 (EST) (envelope-from mike) Date: Tue, 19 Mar 2002 05:20:57 -0500 From: Mike Barcroft To: Peter Pentchev Cc: "Tim J. Robbins" , freebsd-standards@FreeBSD.org Subject: Re: standards/36076: Implementation of POSIX fuser command Message-ID: <20020319052057.O56122@espresso.q9media.com> References: <200203190810.g2J8A3761846@freefall.freebsd.org> <20020319110634.H9136@straylight.oblivion.bg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020319110634.H9136@straylight.oblivion.bg>; from roam@ringlet.net on Tue, Mar 19, 2002 at 11:06:34AM +0200 Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Peter Pentchev writes: > On Tue, Mar 19, 2002 at 12:10:03AM -0800, Tim J. Robbins wrote: > > On Mon, Mar 18, 2002 at 10:38:42PM -0500, Garrett Wollman wrote: > > > > > This script breaks when the argument to -M contains shell field > > > separators. > > > > Thanks for the info; here is an updated version of the script that > > fixes this problem, as well as a problem in the output format caused > > by my misreading of the standard (the output is the same as Solaris now, > > except that it seems to use tabs where I use spaces). > > I must admit that I am a bit wary of having a shell script wrapper; > there are many ways a shell command could go wrong - field separators, > backticks, variable expansions... IMVHO, a Perl script might make > things a bit more secure. What do others think? I think Perl has even more language features that could result in things going wrong. Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Mar 19 2:51:34 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id E839937B416 for ; Tue, 19 Mar 2002 02:50:00 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2JAo0s39300; Tue, 19 Mar 2002 02:50:00 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (211.c.004.mel.iprimus.net.au [210.50.38.211]) by hub.freebsd.org (Postfix) with ESMTP id E0A0437B404 for ; Tue, 19 Mar 2002 02:42:36 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2JAfO702880; Tue, 19 Mar 2002 21:41:24 +1100 (EST) (envelope-from tim) Message-Id: <200203191041.g2JAfO702880@descent.robbins.dropbear.id.au> Date: Tue, 19 Mar 2002 21:41:24 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36087: P1003.1-2001 c99 utility Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36087 >Category: standards >Synopsis: P1003.1-2001 c99 utility >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Mar 19 02:50:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #8: Tue Mar 19 08:46:39 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: FreeBSD is missing the P1003.1-2001 c99 utility. >How-To-Repeat: c99 foo.c >Fix: Here is an implementation of the c99 utility. The manual page is based on Joerg Wunsch's page for c89. It's pretty much trivial, the only interesting thing it does is in addlib(), where it maps -lpthread to the -pthread gcc option, and removes -lxnet and -lrt because they are not available on FreeBSD, their functionality is in libc. # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # Makefile # c99.c # c99.1 # echo x - Makefile sed 's/^X//' >Makefile << 'END-of-Makefile' X# $FreeBSD$ X# $Id: Makefile,v 1.1 2002/02/20 05:27:51 tim Exp $ X XPROG= c99 X X.include END-of-Makefile echo x - c99.c sed 's/^X//' >c99.c << 'END-of-c99.c' X/*- X * Copyright (c) 2002 Tim J. Robbins. X * All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X */ X X/* X * c99 -- compile standard C programs X * X * This is essentially a wrapper around the system C compiler that forces X * the compiler into C99 mode and modifies the libraries used. X */ X X#include X__FBSDID("$FreeBSD$"); X__RCSID("$Id: c99.c,v 1.3 2002/03/19 03:21:43 tim Exp $"); X X#include X X#include X#include X#include X#include X#include X Xchar **args; Xu_int cargs, nargs; X Xvoid addlib(const char *lib); Xvoid addarg(const char *item); Xvoid usage(void); X Xint Xmain(int argc, char *argv[]) X{ X int ch, i; X X args = NULL; X cargs = nargs = 0; X X /* Validate the options and find where they end */ X while ((ch = getopt(argc, argv, "cD:EgI:L:o:O:sU:l:")) != -1) { X if (ch == 'l') { X /* Gone too far. Back up and get out. */ X if (argv[optind - 1][0] == '-') X optind -= 1; X else X optind -= 2; X break; X } else if (ch == '?') X usage(); X } X if (optind == argc) X usage(); X X addarg("cc"); X addarg("-std=iso9899:199x"); X addarg("-pedantic"); X X /* Add the options */ X for (i = 1; i < optind; i++) X addarg(argv[i]); X /* Add the operands, with special processing for libraries */ X while (i < argc) { X if (strncmp(argv[i], "-l", 2) == 0) { X if (argv[i][2] != '\0') X addlib(argv[i++] + 2); X else { X /* -l foo */ X if (argv[++i] == NULL) X usage(); X addlib(argv[i++]); X } X } else X addarg(argv[i++]); X } X X execv("/usr/bin/cc", args); X err(1, "/usr/bin/cc"); X} X Xvoid Xaddlib(const char *lib) X{ X if (strcmp(lib, "pthread") == 0) X addarg("-pthread"); X else if (strcmp(lib, "rt") == 0) X ; X else if (strcmp(lib, "xnet") == 0) X ; X else { X addarg("-l"); X addarg(lib); X } X} X Xvoid Xaddarg(const char *item) X{ X if (nargs + 1 > cargs) { X cargs += 16; X if ((args = realloc(args, sizeof(*args) * cargs)) == NULL) X err(1, "malloc"); X } X if ((args[nargs++] = strdup(item)) == NULL) X err(1, "strdup"); X args[nargs] = NULL; X} X Xvoid Xusage(void) X{ X fprintf(stderr, X"usage: c99 [-cEgs] [-D name[=value]] [-I directory] ... [-L directory] ...\n"); X fprintf(stderr, X" [-o outfile] [-O optlevel] [-U name]... operand ...\n"); X exit(1); X} END-of-c99.c echo x - c99.1 sed 's/^X//' >c99.1 << 'END-of-c99.1' X.\" X.\" Copyright (c) 1997 Joerg Wunsch X.\" X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR X.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT, X.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X.\" X.\" $FreeBSD: src/usr.bin/c89/c89.1,v 1.4.2.4 2001/08/02 01:11:13 obrien Exp $ X.\" $Id: c99.1,v 1.2 2002/03/19 03:05:28 tim Exp $ X.\" " X.Dd February 20, 2002 X.Os X.Dt C99 1 X.Sh NAME X.Nm c99 X.Nd standard C language compiler X.Sh SYNOPSIS X.Nm X.Op Fl cEgs X.Op Fl D Ar name Ns Op = Ns Ar value X.Ar ... X.Op Fl I Ar directory ... X.Op Fl L Ar directory ... X.Op Fl o Ar outfile X.Op Fl O Ar optlevel X.Op Fl U Ar name ... X.Ar operand ... X.Sh DESCRIPTION XThis is the name of the C language compiler as required by the X.St -p1003.1-2001 Xstandard. X.Pp XThe X.Nm Xcompiler accepts the following options: X.Bl -tag -width indent X.It Fl c XSuppress the link-edit phase of the compilation, and do not remove any Xobject files that are produced. X.It Fl D Ar name Ns Op = Ns Ar value XDefine name as if by a C-language X.Ic #define Xdirective. If Xno X.Dq = Ns Ar value Xis given, a value of 1 will be used. XThe X.Fl D Xoption has lower precedence than the X.Fl U Xoption. That is, if X.Ar name Xis used in both a X.Fl U Xand a X.Fl D Xoption, X.Ar name Xwill be undefined regardless of the order of the options. The X.Fl D Xoption may be specified more than once. X.It Fl E XCopy C-language source files to the standard output, expanding all Xpreprocessor directives; no compilation will be performed. X.It Fl g XProduce symbolic information in the object or executable files. X.It Fl I Ar directory XChange the algorithm for searching for headers whose names are not Xabsolute pathnames to look in the directory named by the X.Ar directory Xpathname before looking in the usual places. Thus, headers whose Xnames are enclosed in double-quotes ("") will be searched for first Xin the directory of the file with the X.Ic #include Xline, then in Xdirectories named in X.Fl I Xoptions, and last in the usual places. For Xheaders whose names are enclosed in angle brackets (<>), the header Xwill be searched for only in directories named in X.Fl I Xoptions and then in the usual places. Directories named in X.Fl I Xoptions shall be searched in the order specified. The X.Fl I Xoption may be specified more than once. X.It Fl L Ar directory XChange the algorithm of searching for the libraries named in the X.Fl l Xobjects to look in the directory named by the X.Ar directory Xpathname before looking in the usual places. Directories named in X.Fl L Xoptions will be searched in the order specified. The X.Fl L Xoption may be specified more than once. X.It Fl o Ar outfile XUse the pathname X.Ar outfile , Xinstead of the default X.Pa a.out , Xfor the executable file produced. X.It Fl O Ar optlevel XIf X.Ar optlevel Xis zero, disable all optimizations. Otherwise, enable optimizations at Xthe specified level. X.It Fl s XProduce object and/or executable files from which symbolic and other Xinformation not required for proper execution has been removed X(stripped). X.It Fl U Ar name XRemove any initial definition of X.Ar name . XThe X.Fl U Xoption may be specified more than once. X.El X.Pp XAn operand is either in the form of a pathname or the form X.Fl l Xlibrary. At least one operand of the pathname form needs to be Xspecified. Supported operands are of the form: X.Bl -tag -offset indent -width "-l library" X.It Ar file Ns Pa .c XA C-language source file to be compiled and optionally linked. The Xoperand must be of this form if the X.Fl c Xoption is used. X.It Ar file Ns Pa .a XA library of object files, as produced by X.Xr ar 1 , Xpassed directly to the link editor. X.It Ar file Ns Pa .o XAn object file produced by X.Nm Fl c , Xand passed directly to the link editor. X.It Fl l Ar library XSearch the library named X.Pa lib Ns Ar library Ns Pa .a . XA library will be searched when its name is encountered, so the Xplacement of a X.Fl l Xoperand is significant. X.El X.Sh SEE ALSO X.Xr ar 1 , X.Xr c89 1 , X.Xr cc 1 X.Sh STANDARDS XThe X.Nm Xcommand is believed to comply with X.St -p1003.1-2001 . X.Sh BUGS XThe standard X.Pa trace Xlibrary does not exist in X.Fx Xso X.Fl l Pa trace Xdoes not work. END-of-c99.1 exit >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Mar 19 10: 4:45 2002 Delivered-To: freebsd-standards@freebsd.org Received: from bremen.shuttle.de (bremen.shuttle.de [194.95.249.251]) by hub.freebsd.org (Postfix) with ESMTP id 8027C37B42A for ; Tue, 19 Mar 2002 10:04:01 -0800 (PST) Received: from bremen.shuttle.de (localhost [127.0.0.1]) by bremen.shuttle.de (Postfix) with ESMTP id 8CFC517D29; Tue, 19 Mar 2002 19:03:57 +0100 (CET) Received: (from uucp@localhost) by bremen.shuttle.de (8.12.1/8.12.1/Debian -5) with UUCP id g2JI3v8O016221; Tue, 19 Mar 2002 19:03:57 +0100 Received: (from schweikh@localhost) by hal9000.schweikhardt.net (8.12.2/8.11.6) id g2JHt9QO001676; Tue, 19 Mar 2002 18:55:09 +0100 (CET) (envelope-from schweikh) Date: Tue, 19 Mar 2002 18:55:09 +0100 From: Jens Schweikhardt To: "Tim J. Robbins" Cc: Peter Pentchev , freebsd-standards@FreeBSD.ORG Subject: Re: standards/36076: Implementation of POSIX fuser command Message-ID: <20020319185509.B1316@schweikhardt.net> References: <200203190810.g2J8A3761846@freefall.freebsd.org> <20020319110634.H9136@straylight.oblivion.bg> <20020319210550.A2621@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020319210550.A2621@descent.robbins.dropbear.id.au>; from tim@robbins.dropbear.id.au on Tue, Mar 19, 2002 at 09:05:50PM +1100 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG hello, world\n # The only safe way to do it is to write it in C using similar techniques # to those fstat uses, but that requires more effort and introduces yet # another sgid kmem binary. # # Although not an excuse for introducing new 'bad' code into the tree, # it's worth pointing out that rcp/scp can't copy files with shell meta- # characters in their names, and nobody seems to have complained. Then I'd consider rcp/scp broken as designed. I think choking on funny filenames is a POLA violation. If C is the only way to DTRT, so be it. Additional work to get something right instead of kludged up (and also violating the Standard!) was never a valid argument. That's why I once rewrote c89(1) in C which has been a shell script. And didn't you just today write a c99(1) in C which is nothing more than an arglist tweaker? You're on the right track :-) Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Mar 19 12: 0:32 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 1AB2337B405 for ; Tue, 19 Mar 2002 12:00:13 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2JK0DW95265; Tue, 19 Mar 2002 12:00:13 -0800 (PST) (envelope-from gnats) Date: Tue, 19 Mar 2002 12:00:13 -0800 (PST) Message-Id: <200203192000.g2JK0DW95265@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: Garrett Wollman Subject: Re: standards/36076: Implementation of POSIX fuser command Reply-To: Garrett Wollman Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The following reply was made to PR standards/36076; it has been noted by GNATS. From: Garrett Wollman To: "Tim J. Robbins" Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: standards/36076: Implementation of POSIX fuser command Date: Tue, 19 Mar 2002 14:54:49 -0500 (EST) < said: > echo -n "$f: " >&2 If we really want to be POSIXly correct, this should use the `printf' command and not `echo -n' (which is non-standard). -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Mar 19 23: 3:51 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (226.e.010.mel.iprimus.net.au [210.50.204.226]) by hub.freebsd.org (Postfix) with ESMTP id 25BCE37B417 for ; Tue, 19 Mar 2002 23:03:33 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2K6x7804117; Wed, 20 Mar 2002 17:59:07 +1100 (EST) (envelope-from tim) Date: Wed, 20 Mar 2002 17:59:02 +1100 From: "Tim J. Robbins" To: Jens Schweikhardt Cc: freebsd-standards@FreeBSD.ORG Subject: Re: standards/36076: Implementation of POSIX fuser command Message-ID: <20020320175902.A3989@descent.robbins.dropbear.id.au> References: <200203190810.g2J8A3761846@freefall.freebsd.org> <20020319110634.H9136@straylight.oblivion.bg> <20020319210550.A2621@descent.robbins.dropbear.id.au> <20020319185509.B1316@schweikhardt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020319185509.B1316@schweikhardt.net>; from schweikh@schweikhardt.net on Tue, Mar 19, 2002 at 06:55:09PM +0100 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, Mar 19, 2002 at 06:55:09PM +0100, Jens Schweikhardt wrote: > Then I'd consider rcp/scp broken as designed. I think choking on funny > filenames is a POLA violation. Fix it then. While you are at it, here are some more for you to fix: mkdep shar yyfix lp zcmp nroff whatis cvsbug sendbug send-pr rcsfreeze and when you're done with those, I will find some more for you. > If C is the only way to DTRT, so be it. Additional work to get something > right instead of kludged up (and also violating the Standard!) was never a > valid argument. There is way too much overlap with fstat for them to be separate programs, but the structure of fstat does not present an easy way to make it act as fuser. My script does not violate the standard; double quote (char. 34) is not in the portable pathname character set. Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Mar 19 23:42:23 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id EF86F37B417 for ; Tue, 19 Mar 2002 23:40:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2K7e2Q33928; Tue, 19 Mar 2002 23:40:02 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (226.e.010.mel.iprimus.net.au [210.50.204.226]) by hub.freebsd.org (Postfix) with ESMTP id B82F537B4D1 for ; Tue, 19 Mar 2002 23:28:07 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2K7NOa04690; Wed, 20 Mar 2002 18:23:24 +1100 (EST) (envelope-from tim) Message-Id: <200203200723.g2K7NOa04690@descent.robbins.dropbear.id.au> Date: Wed, 20 Mar 2002 18:23:24 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36126: P1003.1-2001 tabs utility Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36126 >Category: standards >Synopsis: P1003.1-2001 tabs utility >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Tue Mar 19 23:40:02 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #8: Tue Mar 19 08:46:39 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: FreeBSD is missing the P1003.1-2001 tabs utility, which sets/clears terminal tab stops and margins. >How-To-Repeat: tabs >Fix: Here is an implementation of the tabs utility. It works on all the VT100 emulators I've tried, but does not work on ANSI terminals or FreeBSD console. GNU termutils shares this limitation. Although it's not very useful, the standard still requires it. # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # Makefile # tabs.c # tabs.1 # echo x - Makefile sed 's/^X//' >Makefile << 'END-of-Makefile' X# $FreeBSD$ X# $Id: Makefile,v 1.2 2002/02/17 23:08:53 tim Exp $ X XPROG= tabs XDPADD= ${LIBTERMCAP} XLDADD= -ltermcap X X.include END-of-Makefile echo x - tabs.c sed 's/^X//' >tabs.c << 'END-of-tabs.c' X/*- X * Copyright (c) 2002 Tim J. Robbins. X * All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X */ X X/* X * tabs -- set terminal tabs X * X * This utility displays a series of characters that reinitialises the X * terminal hardware tab settings. X * X * NOTE: Warnings emitted by gcc such as "passing arg 1 of `tparm' discards X * qualifiers from pointer target type" are caused by a flaw in X * that causes the "const" to be omitted from the prototypes. X */ X X#include X__FBSDID("$FreeBSD$"); X__RCSID("$Id: tabs.c,v 1.9 2002/03/19 10:52:02 tim Exp $"); X X#include X#include X#include X#include X#include X#include X#include X#include X X X/* Maximum number of tab stops allowed in table */ X#define NSTOPS 20 X Xvoid usage(void); X X/* X * Predefined formats, taken from IEEE P1003.1 Draft 7, June 2001. We rely X * on the fact that the uninitialised elements of the `stops' array will X * be zeroed. X */ Xstruct { X const char *name; /* Format name used on cmd. line */ X int stops[NSTOPS]; /* Column positions */ X} formats[] = { X { "a", { 1, 10, 16, 36, 72 } }, X { "a2", { 1, 10, 16, 40, 72 } }, X { "c", { 1, 8, 12, 16, 20, 55 } }, X { "c2", { 1, 6, 10, 14, 49 } }, X { "c3", { 1, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, X 62, 67 } }, X { "f", { 1, 7, 11, 15, 19, 23 } }, X { "p", { 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, X 61 } }, X { "s", { 1, 10, 55 } }, X { "u", { 1, 12, 20, 44 } } X}; X X#define NELEMS(a) (sizeof(a) / sizeof(a[0])) X Xint Xmain(int argc, char *argv[]) X{ X char area[1024]; X int stops[NSTOPS]; X long inc, nstops, margin; X char *arg, *end, *ap; X const char *ct, *st, *cr, *ML; X X inc = 0; X margin = 0; X nstops = -1; X while ((arg = *++argv) != NULL && (*arg == '-' || *arg == '+')) { X if (*arg == '+') { X /* X * +m[n] and +n X */ X if (*++arg == 'm') X arg++; X if (*arg != '\0') { X errno = 0; X margin = strtol(arg + 2, &end, 10); X if (errno != 0 || *end != '\0') X errx(1, "invalid number"); X } else X margin = 10; X continue; X } X if (isdigit(arg[1])) { X /* X * -n X */ X errno = 0; X inc = strtol(arg + 1, &end, 10); X if (errno != 0 || *end != '\0') X errx(1, "invalid number"); X } else if (arg[1] == 'T') { X /* X * -Ttype or -T type X */ X if (arg[2] != '\0') X setenv("TERM", arg + 2, 1); X else { X if ((arg = *++argv) == NULL) X usage(); X setenv("TERM", arg, 1); X } X } else { X /* X * The only thing left to try is one of the X * predefined formats. X */ X int i, j; X X for (i = 0; i < (int)NELEMS(formats); i++) X if (strcmp(formats[i].name, arg + 1) == 0) X break; X if (i == NELEMS(formats)) X usage(); X for (j = nstops = 0; j < NSTOPS && X formats[i].stops[j] != 0; j++) X stops[nstops++] = formats[i].stops[j]; X } X } X X if (arg != NULL) { X char *tok; X long last = 0, stop; X X /* List of tab stops */ X if (nstops != -1 || inc != 0 || argv[1] != NULL) X usage(); X X for (nstops = 0, tok = strtok(arg, ","); tok != NULL; X tok = strtok(NULL, ",")) { X if (nstops >= NSTOPS) { X warnx("too many tab stops given"); X break; X } X if (*tok == '+' && tok != arg) { X errno = 0; X stop = strtol(tok + 1, &end, 10); X if (errno != 0 || *end != '\0') X errx(1, "invalid number"); X stop += last; X if (last > stop) X errx(1, "can't go backwards"); X last = stops[nstops++] = stop; X } else { X errno = 0; X stop = strtol(tok, &end, 10); X if (errno != 0 || *end != '\0') X errx(1, "invalid number"); X if (last > stop) X errx(1, "can't go backwards"); X last = stops[nstops++] = stop; X } X } X } X X /* Initialise terminal, get the strings we need */ X setupterm(NULL, 1, NULL); X ap = area; X if ((ct = tgetstr("ct", &ap)) == NULL) X errx(1, "can't clear tabs"); X if ((st = tgetstr("st", &ap)) == NULL) X errx(1, "can't set tabs"); X if ((cr = tgetstr("cr", &ap)) == NULL) X cr = "\r"; X ML = tgetstr("ML", &ap); X X /* Clear all tabs */ X putp(cr); X putp(ct); X X if (ML != NULL) X putp(tparm(ML, margin)); X else if (margin != 0) X warnx("can't set soft margin"); X X if (nstops >= 0) { X long i, j; X X /* Optionally output the new ones */ X if (nstops > 0) { X putp(cr); X for (j = 1; j < stops[0]; j++) X putchar(' '); X putp(st); X for (i = 1; i < nstops; i++) { X for (j = 0; j < stops[i] - stops[i - 1]; j++) X putchar(' '); X putp(st); X } X putp(cr); X } X } else if (inc > 0) { X long cols, i, j; X X cols = tgetnum("co"); X if (cols == 0) X cols = atoi(getenv("COLUMNS")); X if (cols == 0) { X cols = 80; X warnx("defaulted to %ld columns", cols); X } X X putp(cr); X /* Set tab stops every `inc' characters */ X for (i = 0; i < cols / inc; i++) { X putp(st); X for (j = 0; j < inc; j++) X putchar(' '); X } X putp(st); X putp(cr); X } X X return (0); X} X Xvoid Xusage(void) X{ X fprintf(stderr, X"usage: tabs [-n|-a|-a2|-c|-c2|-c3|-f|-p|-s|-u] [+m[n]] [+n] [-T type]\n"); X fprintf(stderr, X" tabs [+m[n]] [+n] [-T type] n1,[n2,...]\n"); X exit(1); X} END-of-tabs.c echo x - tabs.1 sed 's/^X//' >tabs.1 << 'END-of-tabs.1' X.\" Copyright (c) 2002 Tim J. Robbins. X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X.\" SUCH DAMAGE. X.\" X.\" $FreeBSD$ X.\" $Id: tabs.1,v 1.5 2002/03/19 11:01:21 tim Exp $ X.\" X.Dd January 24, 2002 X.Dt TABS 1 X.Os X.Sh NAME X.Nm tabs X.Nd set terminal tabs X.Sh SYNOPSIS X.Nm X.Op Cm +m Ns Op Ar n X.Op Cm + Ns Ar n X.Op Fl T Ar type X.Ar n1 , Ns Op Ar n2 , Ns ... X.Nm X.Op Fl Ar n | Fl a | a2 | c | c2 | c3 | f | p | s | u X.Op Cm +m Ns Op Ar n X.Op Cm + Ns Ar n X.Op Fl T Ar type X.Sh DESCRIPTION XThe X.Nm Xutility displays a series of characters that clear the hardware terminal Xtab settings then optionally initialise tab stops at specified positions. X.Pp XIn the first synopsis form, tab stops are set at positions X.Ar n1 , Ar n2 , Xetc. XIf a position is preceded by a X.Ql + , Xit is relative to the previous position set. X.Pp XIn the second synopsis form, the tab stops set depend on the command line Xoptions used, and may be one of the predefined formats or at regular Xintervals. X.Pp XThe options are as follows: X.Bl -tag -width indent X.It Fl Ar n XSet a tab stop every X.Ar n Xcolumns. X.It Fl a XAssembler format (columns 1, 10, 16, 36, 72). X.It Fl a2 XAssembler format (columns 1, 10, 16, 40, 72). X.It Fl c XCOBOL normal format (columns 1, 8, 12, 16, 20, 55) X.It Fl c2 XCOBOL compact format (columns 1, 6, 10, 14, 49) X.It Fl c3 XCOBOL compact format (columns 1, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, X50, 54, 58, 62, 67). X.It Fl f XFORTRAN format (columns 1, 7, 11, 15, 19, 23). X.It Fl p XPL/1 format (columns 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, X57, 61). X.It Fl s XSNOBOL format (columns 1, 10, 55). X.It Fl u XAssembler format (columns 1, 12, 20, 44). X.It Cm + Ns Ar n XSet an X.Ar n Xcharacter margin. X.It Cm +m Ns Op Ar n XSet an X.Ar n Xcharacter margin, or 10 if X.Ar n Xis omitted. X.It Fl T Ar type XOutput escape sequence for the terminal type X.Ar type . X.El X.Sh ENVIRONMENT X.Bl -tag -width indent X.It Ev TERM XTerminal type unless overridden by the X.Fl T Xoption. X.Sh DIAGNOSTICS X.Ex -std X.Sh SEE ALSO X.Xr expand 1 , X.Xr stty 1 , X.Xr tput 1 , X.Xr unexpand 1 , X.Xr termcap 5 X.Sh STANDARDS XThe X.Nm Xutility is designed to comply with the X.St -p1003.1-2001 Xspecification. END-of-tabs.1 exit >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Mar 19 23:42:36 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id A00F137B41E for ; Tue, 19 Mar 2002 23:40:05 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2K7e5H33954; Tue, 19 Mar 2002 23:40:05 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (226.e.010.mel.iprimus.net.au [210.50.204.226]) by hub.freebsd.org (Postfix) with ESMTP id 2E4F537B41A for ; Tue, 19 Mar 2002 23:37:08 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2K7WBZ04802; Wed, 20 Mar 2002 18:32:11 +1100 (EST) (envelope-from tim) Message-Id: <200203200732.g2K7WBZ04802@descent.robbins.dropbear.id.au> Date: Wed, 20 Mar 2002 18:32:11 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36128: Reimplementation of who utility Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36128 >Category: standards >Synopsis: Reimplementation of who utility >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Mar 19 23:40:05 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #8: Tue Mar 19 08:46:39 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: FreeBSD's who(1) utility does not comply with P1003.1-2001. It is missing every single command line option specified by the standard. >How-To-Repeat: who -H >Fix: This implementation is as close to conformance as I could get it; concepts like "runlevels" don't exist on BSD. # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # Makefile # who.c # who.1 # echo x - Makefile sed 's/^X//' >Makefile << 'END-of-Makefile' X# $FreeBSD$ X# $Id: Makefile,v 1.1 2002/02/17 23:12:22 tim Exp $ X XPROG= who X X.include END-of-Makefile echo x - who.c sed 's/^X//' >who.c << 'END-of-who.c' X/*- X * Copyright (c) 2002 Tim J. Robbins. X * All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X */ X X#include X__FBSDID("$FreeBSD$"); X__RCSID("$Id: who.c,v 1.5 2002/03/19 11:17:35 tim Exp $"); X X#include X#include X X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X Xvoid heading(void); Xvoid usage(void); Xvoid process_utmp(const char *fn); Xvoid process_wtmp(const char *fn); Xvoid quick(const char *fn); Xvoid row(const char *name, char state, const char *line, time_t utime, X time_t idle); Xvoid wtmp(void); X Xint Hflag, Tflag, aflag, bflag, dflag, lflag, mflag, pflag, qflag, rflag; Xint sflag, tflag, uflag; X Xint Xmain(int argc, char *argv[]) X{ X int ch; X X setlocale(LC_TIME, ""); X X Hflag = Tflag = aflag = bflag = dflag = lflag = mflag = 0; X pflag = qflag = rflag = sflag = tflag = uflag = 0; X while ((ch = getopt(argc, argv, "HTabdlmpqrstu")) != -1) { X switch (ch) { X case 'H': /* Write column headings */ X Hflag = 1; X break; X case 'T': /* Show terminal state */ X Tflag = 1; X break; X case 'a': /* Show all info */ X aflag = bflag = dflag = lflag = tflag = Tflag = 1; X pflag = rflag = uflag = 1; X break; X case 'b': /* Write time&date of last reboot */ X bflag = 1; X break; X case 'd': /* Show dead processes */ X warnx("cannot show dead processes"); X dflag = 1; X break; X case 'l': /* Show only lines waiting for login */ X lflag = 1; X break; X case 'm': /* Show info about current terminal */ X mflag = 1; X break; X case 'q': /* "Quick" mode */ X qflag = 1; X break; X case 'r': /* Show run-level of init process */ X warnx("cannot show runlevel"); X rflag = 1; X break; X case 'p': /* Show other procs spawned by init */ X warnx("cannot show `other' processes"); X pflag = 1; X break; X case 's': /* Show name, line, time */ X sflag = 1; X break; X case 't': /* Show last change to system clock */ X tflag = 1; X break; X case 'u': /* Show idle time */ X uflag = 1; X break; X default: X usage(); X /*NOTREACHED*/ X } X } X argc -= optind; X argv += optind; X X if (argc > 2 && strcmp(argv[0], "am") == 0 && X (strcmp(argv[1], "i") == 0 || strcmp(argv[1], "I") == 0)) { X /* "who am i" or "who am I", equivalent to -m */ X mflag = 1; X argc -= 2; X argv += 2; X } X if (argc > 1) X usage(); X X if (sflag) X Tflag = uflag = 0; X if (Hflag) X heading(); X if (qflag) X quick(*argv != NULL ? *argv : _PATH_UTMP); X else { X if (aflag || (!bflag && !dflag && !pflag && !rflag && !tflag)) X process_utmp(*argv != NULL ? *argv : _PATH_UTMP); X if (bflag || tflag) X process_wtmp(_PATH_WTMP); X } X X return (0); X} X Xvoid Xusage(void) X{ X fprintf(stderr, "usage: who [-HTabdlmpqrstu] [am I] [file]\n"); X exit(1); X} X Xvoid Xheading(void) X{ X printf("%-*s ", UT_NAMESIZE, "NAME"); X if (Tflag) X printf("S "); X printf("%-*s ", UT_LINESIZE, "LINE"); X printf("%-*s ", 12, "TIME"); X if (uflag) X printf("IDLE "); X printf("\n"); X} X Xvoid Xrow(const char *name, char state, const char *line, time_t utime, time_t idle) X{ X char buf[80]; X struct tm *tm; X X printf("%-*.*s ", UT_NAMESIZE, UT_NAMESIZE, name); X if (Tflag) X printf("%c ", state); X printf("%-*.*s ", UT_LINESIZE, UT_LINESIZE, line); X tm = localtime(&utime); X strftime(buf, sizeof(buf), "%b %e %H:%M", tm); X printf("%-*s ", 12, buf); X if (uflag) { X if (idle < 60) X printf(" . "); X else if (idle < 24 * 60 * 60) X printf("%02d:%02d ", idle / 60 / 60, idle / 60 % 60); X else X printf(" old "); X } X printf("\n"); X} X Xvoid Xprocess_utmp(const char *fn) X{ X FILE *fp; X struct utmp ut; X struct stat sb; X char tty[PATH_MAX], *ttyn; X time_t idle, now; X char state; X X now = time(NULL); X if (mflag && (ttyn = ttyname(0)) == NULL) X return; X X if ((fp = fopen(fn, "r")) == NULL) X err(1, "%s", fn); X X while (fread(&ut, sizeof(ut), 1, fp) == 1) { X strcpy(tty, _PATH_DEV); X strncat(tty, ut.ut_line, sizeof(ut.ut_line)); X tty[strlen(_PATH_DEV) + UT_LINESIZE] = '\0'; X state = '?'; X idle = 0; X if (Tflag || uflag) { X if (stat(tty, &sb) == 0) { X state = sb.st_mode & (S_IWOTH|S_IWGRP) ? X '+' : '-'; X idle = now - sb.st_mtime; X } X } X if ((!lflag || aflag) && *ut.ut_name != '\0' && X (!mflag || strcmp(ttyn, tty) == 0)) X row(ut.ut_name, state, ut.ut_line, ut.ut_time, idle); X else if (lflag && *ut.ut_name == '\0' && *ut.ut_line != '\0') X row("LOGIN", ' ', ut.ut_line, ut.ut_time, idle); X } X X fclose(fp); X} X Xvoid Xprocess_wtmp(const char *fn) X{ X FILE *fp; X struct utmp ut; X time_t lastboot, lasttime; X X if ((fp = fopen(fn, "r")) == NULL) X err(1, "%s", fn); X X lastboot = lasttime = (time_t)-1; X while (fread(&ut, sizeof(ut), 1, fp) == 1) { X if (bflag && *ut.ut_line == '~') X lastboot = ut.ut_time; X if (tflag && *ut.ut_line == '{') X lasttime = ut.ut_time; X } X X if (bflag) { X if (lastboot != (time_t)-1) X row("reboot", ' ', "-", lastboot, 0); X else X warnx("couldn't find time of last reboot"); X X } X if (tflag) { X if (lasttime != (time_t)-1) X row("date", ' ', "-", lasttime, 0); X else X warnx("couldn't find time of last date change"); X X } X} X Xvoid Xquick(const char *fn) X{ X FILE *fp; X struct utmp ut; X int n; X X if ((fp = fopen(fn, "r")) == NULL) X err(1, "%s", fn); X X n = 0; X while (fread(&ut, sizeof(ut), 1, fp) == 1) { X if (*ut.ut_name == '\0') X continue; X printf("%-.*s\n", UT_NAMESIZE, ut.ut_name); X n++; X } X printf("# users = %d\n", n); X} END-of-who.c echo x - who.1 sed 's/^X//' >who.1 << 'END-of-who.1' X.\" Copyright (c) 2002 Tim J. Robbins. X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X.\" SUCH DAMAGE. X.\" X.\" $FreeBSD$ X.\" $Id: who.1,v 1.3 2002/03/19 10:55:50 tim Exp $ X.\" X.Dd January 24, 2002 X.Dt WHO 1 X.Os X.Sh NAME X.Nm who X.Nd display who is on the system X.Sh SYNOPSIS X.Nm X.Op Fl HTabdlmpqrstu X.Op Cm am I X.Op Ar file X.Sh DESCRIPTION XThe X.Nm Xutility displays information about currently logged in users. X.Pp XA X.Xr utmp 5 Xformat X.Ar file Xargument may be specified instead of the default X.Pa utmp Xfile. X.Pp XThe options are as follows: X.Bl -tag -width indent X.It Fl H XWrite column headings. X.It Fl T XIndicate whether each user is accepting messages. XOne of the following characters is written: X.Bl -tag -width x -compact X.It + XUser is accepting messages. X.It \&- XUser is not accepting messages. X.It ? XAn error occurred. X.El X.It Fl a XEquivalent to X.Fl Tbdlprtu . X.It Fl b XWrite the time and date of the last reboot. X.It Fl l XList only lines that are waiting for a user to log in. X.It Fl m XWrite information about the current terminal only. X.It Fl q XList the names and number of logged in users. XAll command line options are ignored. X.It Fl s XWrite the name, line and time fields only. X.It Fl t XShow the time the system clock was last changed. X.It Fl u XShow idle time for each user in hours and minutes as X.Ql hh:mm , X.Ql \&. Xif the user has been idle less that a minute and X.Ql old Xif the user has been idle more than 24 hours. X.It Cm am I XEquivalent to X.Fl m . X.El X.Pp XThe X.Fl d , X.Fl r Xand X.Fl p Xoptions are accepted but ignored for compatibility with X.At V.4 Xsystems. X.Sh FILES X.Pa /var/run/utmp X.Sh DIAGNOSTICS X.Ex -std X.Sh SEE ALSO X.Xr last 1 , X.Xr users 1 , X.Xr w 1 , X.Xr utmp 5 , X.Xr init 8 X.Sh STANDARDS XThe X.Nm Xutility is designed to comply with the X.St -p1003.1-2001 Xspecification. X.Pp XThe X.Fl r Xoption is ignored because X.Bx Ns 's X.Xr init 8 Xdoes not use runlevels, nor does it keep track of the relevant information Xto implement the X.Fl d Xand X.Fl p Xoptions. END-of-who.1 exit >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Mar 20 1: 1:38 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 9191137B47B for ; Wed, 20 Mar 2002 01:00:04 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2K902A52342; Wed, 20 Mar 2002 01:00:02 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (226.e.010.mel.iprimus.net.au [210.50.204.226]) by hub.freebsd.org (Postfix) with ESMTP id 3991137B420 for ; Wed, 20 Mar 2002 00:57:06 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2K89W605096; Wed, 20 Mar 2002 19:09:32 +1100 (EST) (envelope-from tim) Message-Id: <200203200809.g2K89W605096@descent.robbins.dropbear.id.au> Date: Wed, 20 Mar 2002 19:09:32 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36130: P1003.2 asa utility is missing Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36130 >Category: standards >Synopsis: P1003.2 asa utility is missing >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Mar 20 01:00:02 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #8: Tue Mar 19 08:46:39 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: FreeBSD is missing the POSIX.2 (1992) asa utility. >How-To-Repeat: a.out | asa >Fix: This is a modified version of NetBSD's asa(1) utility. I've made the following changes: * $FreeBSD$, __FBSDID etc. * Remove prototype for main() * Remove __P * Use getopt so "asa -- foo" works, and add usage() function * Correct exit status * style(9) fixes. Most notably, space between function name and parenthesis. (if you're interested: http://www.wiretapped.net/~fyre/freebsd/asa.diff) # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # Makefile # asa.c # asa.1 # echo x - Makefile sed 's/^X//' >Makefile << 'END-of-Makefile' X# $NetBSD: Makefile,v 1.2 1995/03/25 18:04:51 glass Exp $ X# $FreeBSD$ X XPROG= asa X X.include END-of-Makefile echo x - asa.c sed 's/^X//' >asa.c << 'END-of-asa.c' X/* X * Copyright (c) 1993,94 Winning Strategies, Inc. X * All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * 3. All advertising materials mentioning features or use of this software X * must display the following acknowledgement: X * This product includes software developed by Winning Strategies, Inc. X * 4. The name of the author may not be used to endorse or promote products X * derived from this software without specific prior written permission X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X */ X X#include X__FBSDID("$FreeBSD$"); X__RCSID("$NetBSD: asa.c,v 1.11 1997/09/20 14:55:00 lukem Exp $"); X X#include X#include X#include X#include X Xstatic void asa(FILE *); Xstatic void usage(void); X Xint Xmain(int argc, char *argv[]) X{ X FILE *fp; X const char *fn; X int ch, exval; X X while ((ch = getopt(argc, argv, "")) != -1) { X switch (ch) { X case '?': X default: X usage(); X /*NOTREACHED*/ X } X } X argc -= optind; X argv += optind; X X exval = 0; X if (argc == 0) X asa(stdin); X else { X while ((fn = *argv++) != NULL) { X if ((fp = fopen(fn, "r")) == NULL) { X warn("%s", fn); X exval = 1; X continue; X } X asa(fp); X fclose(fp); X } X } X X return (exval); X} X Xstatic void Xusage(void) X{ X fprintf(stderr, "usage: asa [file...]\n"); X exit(1); X} X Xstatic void Xasa(FILE *f) X{ X char *buf; X size_t len; X X if ((buf = fgetln(f, &len)) != NULL) { X if (buf[len - 1] == '\n') X buf[--len] = '\0'; X /* special case the first line */ X switch (buf[0]) { X case '0': X putchar('\n'); X break; X case '1': X putchar('\f'); X break; X } X X if (len > 1 && buf[0] && buf[1]) X printf("%.*s", (int)(len - 1), buf + 1); X X while ((buf = fgetln(f, &len)) != NULL) { X if (buf[len - 1] == '\n') X buf[--len] = '\0'; X switch (buf[0]) { X default: X case ' ': X putchar('\n'); X break; X case '0': X putchar('\n'); X putchar('\n'); X break; X case '1': X putchar('\f'); X break; X case '+': X putchar('\r'); X break; X } X X if (len > 1 && buf[0] && buf[1]) X printf("%.*s", (int)(len - 1), buf + 1); X } X X putchar('\n'); X } X} END-of-asa.c echo x - asa.1 sed 's/^X//' >asa.1 << 'END-of-asa.1' X.\" Copyright (c) 1993 Winning Strategies, Inc. X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" 3. All advertising materials mentioning features or use of this software X.\" must display the following acknowledgement: X.\" This product includes software developed by Winning Strategies, Inc. X.\" 4. The name of the author may not be used to endorse or promote products X.\" derived from this software without specific prior written permission X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR X.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES X.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. X.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, X.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT X.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, X.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY X.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT X.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF X.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. X.\" X.\" $NetBSD: asa.1,v 1.11 2002/02/08 01:36:18 ross Exp $ X.\" $FreeBSD$ X.\" X.Dd September 23, 1993 X.Dt ASA 1 X.Os X.Sh NAME X.Nm asa X.Nd interpret carriage-control characters X.Sh SYNOPSIS X.Nm X.Op Ar X.Sh DESCRIPTION XThe X.Nm Xutility reads files sequentially, mapping X.Tn FORTRAN Xcarriage-control characters to line-printer control sequences, Xand writes them to the standard output. X.Pp XThe first character of each line is interpreted as a carriage-control Xcharacter. The following characters are interpreted as follows: X.Bl -tag -width "\*[Lt]space\*[Gt]" X.It \*[Lt]space\*[Gt] XOutput the rest of the line without change. X.It 0 XOutput a \*[Lt]newline\*[Gt] character before printing the rest of the line. X.It 1 XOutput a \*[Lt]formfeed\*[Gt] character before printing the rest of the line. X.It + XThe trailing \*[Lt]newline\*[Gt] of the previous line is replaced by a \*[Lt]carriage-return\*[Gt] Xbefore printing the rest of the line. X.El X.Pp XLines beginning with characters other than the above are treated as if they Xbegin with \*[Lt]space\*[Gt]. X.Sh EXIT STATUS XThe X.Nm Xutility exit 0 on success, and \*[Gt]0 if an error occurs. X.Sh EXAMPLES XTo view a file containing the output of a X.Tn FORTRAN Xprogram: X.Dl asa file X.Pp XTo format the output of a X.Tn FORTRAN Xprogram and redirect it to a line-printer: X.Dl a.out | asa | lpr X.Sh SEE ALSO X.Xr f77 1 X.Sh STANDARDS XThe X.Nm Xutility conforms to X.St -p1003.1-2001 . X.Sh AUTHORS XJ.T. Conklin, Winning Strategies, Inc. END-of-asa.1 exit >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Mar 20 1: 2:46 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 529AE37B404; Wed, 20 Mar 2002 01:02:40 -0800 (PST) Received: (from mike@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2K92e452996; Wed, 20 Mar 2002 01:02:40 -0800 (PST) (envelope-from mike) Date: Wed, 20 Mar 2002 01:02:40 -0800 (PST) From: Message-Id: <200203200902.g2K92e452996@freefall.freebsd.org> To: tim@robbins.dropbear.id.au, mike@FreeBSD.org, freebsd-standards@FreeBSD.org, mike@FreeBSD.org Subject: Re: standards/36074: paste(1) should not accept no arguments Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Synopsis: paste(1) should not accept no arguments State-Changed-From-To: open->analyzed State-Changed-By: mike State-Changed-When: Wed Mar 20 01:01:02 PST 2002 State-Changed-Why: Fixed in -current; awaiting MFC. Responsible-Changed-From-To: freebsd-standards->mike Responsible-Changed-By: mike Responsible-Changed-When: Wed Mar 20 01:01:02 PST 2002 Responsible-Changed-Why: http://www.freebsd.org/cgi/query-pr.cgi?pr=36074 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Mar 20 13:15:29 2002 Delivered-To: freebsd-standards@freebsd.org Received: from hda.hda.com (host65.hda.com [63.104.68.65]) by hub.freebsd.org (Postfix) with ESMTP id 5FD9537B422; Wed, 20 Mar 2002 13:15:25 -0800 (PST) Received: (from dufault@localhost) by hda.hda.com (8.11.6/8.11.6) id g2KLGQB05421; Wed, 20 Mar 2002 16:16:26 -0500 (EST) (envelope-from dufault) Date: Wed, 20 Mar 2002 16:16:25 -0500 From: Peter Dufault To: Garrett Wollman Cc: Mike Barcroft , standards@FreeBSD.ORG Subject: Re: Garrett's POSIX versions patch for review Message-ID: <20020320161625.A5344@hda.hda.com> References: <20020226.224449.28794535.imp@village.org> <20020227184645.K47808-100000@gamplex.bde.org> <20020227144359.R31007@espresso.q9media.com> <20020318021728.D56122@espresso.q9media.com> <200203181926.g2IJQEo33811@khavrinen.lcs.mit.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200203181926.g2IJQEo33811@khavrinen.lcs.mit.edu>; from wollman@lcs.mit.edu on Mon, Mar 18, 2002 at 02:26:14PM -0500 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Mar 18, 2002 at 02:26:14PM -0500, Garrett Wollman wrote: > < said: > > > Does _KPOSIX_VERSION have any use as a kernel option? > > I think it's bogus. Ask Peter Dufault what the intent was. It was to build the kernel with newer interfaces and test them by occasionally setting user-space _POSIX_VERSION into the "future", leaving _POSIX_VERSION at the release. It seemed like a good idea at the time, as bumping _POSIX_VERSION in general seemed likely to autoconf in things you don't expect. Peter -- Peter Dufault (dufault@hda.com) Realtime development, Machine control, HD Associates, Inc. Fail-Safe systems, Agency approval To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Mar 21 10:46:55 2002 Delivered-To: freebsd-standards@freebsd.org Received: from bremen.shuttle.de (bremen.shuttle.de [194.95.249.251]) by hub.freebsd.org (Postfix) with ESMTP id 71B8D37B400 for ; Thu, 21 Mar 2002 10:46:43 -0800 (PST) Received: from bremen.shuttle.de (localhost [127.0.0.1]) by bremen.shuttle.de (Postfix) with ESMTP id 0C5DC17D70; Thu, 21 Mar 2002 19:46:40 +0100 (CET) Received: (from uucp@localhost) by bremen.shuttle.de (8.12.1/8.12.1/Debian -5) with UUCP id g2LIkdIp015327; Thu, 21 Mar 2002 19:46:39 +0100 Received: (from schweikh@localhost) by hal9000.schweikhardt.net (8.12.2/8.11.6) id g2LIJRJa001683; Thu, 21 Mar 2002 19:19:27 +0100 (CET) (envelope-from schweikh) Date: Thu, 21 Mar 2002 19:19:27 +0100 From: Jens Schweikhardt To: "Tim J. Robbins" Cc: freebsd-standards@FreeBSD.ORG Subject: Re: standards/36076: Implementation of POSIX fuser command Message-ID: <20020321191927.A1215@schweikhardt.net> References: <200203190810.g2J8A3761846@freefall.freebsd.org> <20020319110634.H9136@straylight.oblivion.bg> <20020319210550.A2621@descent.robbins.dropbear.id.au> <20020319185509.B1316@schweikhardt.net> <20020320175902.A3989@descent.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020320175902.A3989@descent.robbins.dropbear.id.au>; from tim@robbins.dropbear.id.au on Wed, Mar 20, 2002 at 05:59:02PM +1100 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Tim, On Wed, Mar 20, 2002 at 05:59:02PM +1100, Tim J. Robbins wrote: # On Tue, Mar 19, 2002 at 06:55:09PM +0100, Jens Schweikhardt wrote: # # > Then I'd consider rcp/scp broken as designed. I think choking on funny # > filenames is a POLA violation. # # Fix it then. While you are at it, here are some more for you to fix: [zap list] I already started with c89(1). # and when you're done with those, I will find some more for you. I know, but is this a reason to introduce more utilities that behave this way? I think not. # > If C is the only way to DTRT, so be it. Additional work to get something # > right instead of kludged up (and also violating the Standard!) was never a # > valid argument. # # There is way too much overlap with fstat for them to be separate programs, # but the structure of fstat does not present an easy way to make it act # as fuser. # # My script does not violate the standard; double quote (char. 34) is not # in the portable pathname character set. The POSIX 2001 portable pathname character set is [-._A-Za-z0-9] and we generally assume much more than that to be "portable", think foo,v. Yes, you handle foo,v in your script, but I *do* encounter more and more filenames with spaces or tabs in them (admitted, not in the base OS) and this is where almost all scripts are notoriously failing. Does it handle those too? I understand that sometimes it's hard to make bullet-proof software, but still I think it's a worthwhile goal -- and a value-add compared to other competing open source operating systems that shall remain nameless :-) Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Mar 21 12:42: 2 2002 Delivered-To: freebsd-standards@freebsd.org Received: from rover.village.org (rover.bsdimp.com [204.144.255.66]) by hub.freebsd.org (Postfix) with ESMTP id A87F737B400 for ; Thu, 21 Mar 2002 12:41:59 -0800 (PST) Received: from harmony.village.org (harmony.village.org [10.0.0.6]) by rover.village.org (8.11.3/8.11.3) with ESMTP id g2LKfwi83352 for ; Thu, 21 Mar 2002 13:41:58 -0700 (MST) (envelope-from imp@village.org) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.11.6/8.11.6) with ESMTP id g2LKftL19437 for ; Thu, 21 Mar 2002 13:41:55 -0700 (MST) (envelope-from imp@village.org) Date: Thu, 21 Mar 2002 13:41:51 -0700 (MST) Message-Id: <20020321.134151.58406849.imp@village.org> To: standards@freebsd.org Subject: Comments on this patch from pendants From: "M. Warner Losh" X-Mailer: Mew version 2.1 on Emacs 21.1 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Looks like this is the only place in our whole tree that we use or depend on _REENTRANT being defined. I don't see why we need it. Can the standards czars on this list comment about the pros and cons of this patch? Thanks much Warner Index: src/math.h =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/lib/msun/src/math.h,v retrieving revision 1.11 diff -u -r1.11 math.h --- src/math.h 13 Dec 2001 17:22:17 -0000 1.11 +++ src/math.h 21 Mar 2002 20:37:07 -0000 @@ -182,10 +182,8 @@ * Reentrant version of gamma & lgamma; passes signgam back by reference * as the second argument; user must allocate space for signgam. */ -#ifdef _REENTRANT double gamma_r __P((double, int *)); double lgamma_r __P((double, int *)); -#endif /* _REENTRANT */ /* float versions of ANSI/POSIX functions */ float acosf __P((float)); @@ -264,10 +262,8 @@ * signgam back by reference as the second argument; user must * allocate space for signgam. */ -#ifdef _REENTRANT float gammaf_r __P((float, int *)); float lgammaf_r __P((float, int *)); -#endif /* _REENTRANT */ #endif /* !_XOPEN_SOURCE */ #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Mar 21 16:10:44 2002 Delivered-To: freebsd-standards@freebsd.org Received: from quic.net (romulus.quic.net [216.23.27.8]) by hub.freebsd.org (Postfix) with SMTP id 5003F37B41A for ; Thu, 21 Mar 2002 16:10:29 -0800 (PST) Received: (qmail 22796 invoked by uid 1032); 22 Mar 2002 00:10:31 -0000 From: utsl@quic.net Date: Thu, 21 Mar 2002 19:10:31 -0500 To: freebsd-standards@freebsd.org Subject: utmpx implementation Message-ID: <20020322001031.GA21735@quic.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Dxnq1zWXvFF0Q93v" Content-Disposition: inline User-Agent: Mutt/1.3.27i Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --Dxnq1zWXvFF0Q93v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I have written a utmpx implementation. It is written from scratch from the SUSv2 spec (also in POSIX, I believe), and is under BSD license. I have also examined other systems, and included what made sense to me. I have partially implemented reentrant functions, but haven't finished yet. Suggestions and patches are welcome. --Dxnq1zWXvFF0Q93v Content-Type: text/x-csrc; charset=us-ascii Content-Disposition: attachment; filename="utmpx.c" /* * Copyright (c) 2002 * Nathan Hawkins. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #include #include #include #include "utmpx.h" static int utx_fd=-1; static off_t utx_offset=-1; static struct utmpx utx_last; static char default_utmpxfile[]=_PATH_UTMPX; static char *utmpxfile=&default_utmpxfile[0]; static int utx_ro=0; static int openutxfile (void) { if(utx_fd == -1) { utx_fd = open(utmpxfile, O_RDWR); if(utx_fd == -1) { utx_fd = open(utmpxfile, O_RDONLY); utx_ro = 1; /* set read-only flag */ if(utx_fd == -1) return (1); } else utx_ro=0; /* clear read-only flag */ } utx_offset = 0; return (0); } /* * setutxent rewinds the utmpx file. If the file isn't open, it does nothing. */ void setutxent (void) { if (utx_fd == -1) return; utx_offset = lseek(utx_fd, 0, SEEK_SET); } /* * endutxent closes the utmpx file, and restores the filename to the default. */ void endutxent (void) { if (utx_fd != -1) { close (utx_fd); utx_fd = -1; } utmpxfile = default_utmpxfile; } /* * utmpxname is a nonstandard function used to select an alternate utmpx file. * The string passed here isn't used until one of the other functions opens the * file. endutxent resets the filename to default. */ void utmpxname (const char *utmpx) { if (utmpx != NULL) utmpxfile = (char *)utmpx; } static struct utmpx * getutxent_internal (struct utmpx *ut) { /* either read a full struct utmpx from the file or return NULL */ if (read(utx_fd, ut, sizeof (struct utmpx)) != sizeof (struct utmpx)) return (NULL); utx_offset += sizeof (struct utmpx); return (ut); } struct utmpx * getutxent_r (struct utmpx *buffer) { struct utmpx *ut; int flag; /* open the file if it isn't already */ if (utx_fd == -1 && openutxfile()) return (NULL); /* lock the file for reading */ flag=flock(utx_fd,LOCK_SH); if (flag == -1) return (NULL); /* failed to get the lock */ ut=getutxent_internal(buffer); flag=flock(utx_fd,LOCK_UN); if (flag == -1) return (NULL); /* failed to unlock for some reason */ return (ut); } /* * According to SUSv2: * * The getutxid() function searches forward from the current point in the * database. If the ut_type value of the utmpx structure pointed to by id is * BOOT_TIME, OLD_TIME or NEW_TIME, then it stops when it finds an entry with a * matching ut_type value. If the ut_type value is INIT_PROCESS, LOGIN_PROCESS, * USER_PROCESS, or DEAD_PROCESS, then it stops when it finds an entry whose * type is one of these four and whose ut_id member matches the ut_id member of * the utmpx structure pointed to by id. If the end of the database is reached * without a match, getutxid() fails. */ struct utmpx * getutxid_r (const struct utmpx *ut, struct utmpx *buffer) { int finished; struct utmpx *last; int flag; /* open the file if it isn't already */ if (utx_fd == -1 && openutxfile()) return (NULL); /* lock the file for reading */ flag=flock(utx_fd,LOCK_SH); if (flag == -1) return (NULL); /* failed to get the lock */ for (;;) { if ((last=getutxent_internal(buffer)) == NULL) break; switch (ut->ut_type) { case BOOT_TIME: case OLD_TIME: case NEW_TIME: if (ut->ut_type == last->ut_type) finished = 1; break; case INIT_PROCESS: case LOGIN_PROCESS: case USER_PROCESS: case DEAD_PROCESS: if (ut->ut_type == last->ut_type && strncmp(ut->ut_id,last->ut_id,4) == 0) finished = 1; break; /* evidently this function ignores other types */ default: break; } if (finished) break; } flag=flock(utx_fd,LOCK_UN); if (flag == -1) return (NULL); /* failed to unlock for some reason */ return (last); } /* * According to SUSv2: * * The getutxline() function searches forward from the current point in the * database until it finds an entry of the type LOGIN_PROCESS or USER_PROCESS * which also has a ut_line value matching that in the utmpx structure pointed * to by line. If the end of the database is reached without a match, * getutxline() fails. */ struct utmpx * getutxline_r (const struct utmpx *ut, struct utmpx *buffer) { int finished; struct utmpx *last; int flag; /* open the file if it isn't already */ if (utx_fd == -1 && openutxfile()) return (NULL); /* lock the file for reading */ flag=flock(utx_fd,LOCK_SH); if (flag == -1) return (NULL); /* failed to get the lock */ for (;;) { if ((last=getutxent_internal(buffer)) == NULL) break; switch (last->ut_type) { case LOGIN_PROCESS: case USER_PROCESS: if (strncmp(ut->ut_line,last->ut_line,UT_LINESIZE) == 0) finished = 1; break; /* evidently this function ignores other types */ default: break; } if (finished) break; } flag=flock(utx_fd,LOCK_UN); if (flag == -1) return (NULL); /* failed to unlock for some reason */ return (last); } /* * According to SUSv2: * * If the process has appropriate privileges, the pututxline() function writes * out the structure into the user accounting database. It uses getutxid() to * search for a record that satisfies the request. If this search succeeds, * then the entry is replaced. Otherwise, a new entry is made at the end of the * user accounting database. * * The implicit read done by pututxline() (if it finds that it is not already * at the correct place in the user accounting database) will not modify the * static structure returned by getutxent(), getutxid() or getutxline(), if the * application has just modified this structure and passed the pointer back to * pututxline(). */ struct utmpx * pututxline (const struct utmpx *ut) { struct utmpx findbuf; struct utmpx *found; int flag; if (utx_ro) return (NULL); /* don't have write access to utmpx */ if ((found=getutxid_r(ut,&findbuf))!=NULL) { /* try to rewind the file by exactly one record */ utx_offset = lseek(utx_fd, utx_offset - sizeof (struct utmpx), SEEK_CUR); } else { /* seek to the end of the file */ utx_offset = lseek(utx_fd, 0, SEEK_END); } /* lock the file for writing */ flag=flock(utx_fd,LOCK_EX); if (flag == -1) return (NULL); /* failed to get the lock */ if (write(utx_fd, ut, sizeof (struct utmpx)) != sizeof (struct utmpx)) { /* * In case of failed write to the end of the file, truncate the * record. This keeps the file format from getting corrupted. */ if (found != NULL) { ftruncate(utx_fd, utx_offset); return (NULL); } else { return (NULL); } } utx_offset += sizeof (struct utmpx); flag=flock(utx_fd,LOCK_UN); if (flag == -1) return (NULL); /* failed to unlock for some reason */ return ((struct utmpx *)ut); } struct utmpx * getutxent(void) { getutxent_r(&utx_last); } struct utmpx * getutxid (const struct utmpx *ut) { getutxid_r(ut,&utx_last); } struct utmpx * getutxline (const struct utmpx *ut) { getutxid_r(ut,&utx_last); } --Dxnq1zWXvFF0Q93v Content-Type: text/x-chdr; charset=us-ascii Content-Disposition: attachment; filename="utmpx.h" /* * Copyright (c) 2002 * Nathan Hawkins. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * */ #ifndef _UTMPX_H_ #define _UTMPX_H_ #include #include #define _PATH_UTMPX "/var/run/utmpx" #define UTMPX_FILE _PATH_UTMPX /* features in utmpx */ #define _HAVE_UT_PID 1 #define _HAVE_UT_ID 1 #define _HAVE_UT_TV 1 #define _HAVE_UT_TYPE 1 #define _HAVE_UT_HOST 1 /* size of character arrays in struct utmpx */ #define UT_LINESIZE 32 #define UT_NAMESIZE 32 #define UT_HOSTSIZE 256 struct exit_status { short int e_termination; /* Process termination status. */ short int e_exit; /* Process exit status. */ }; struct utmpx { pid_t ut_pid; char ut_id[4]; /* reserve space for IPv6 addresses */ u_int32_t ut_addr6[4]; long int ut_session; /* used by X? */ struct timeval ut_tv; struct exit_status ut_exit; short int ut_type; char ut_line[UT_LINESIZE]; char ut_user[UT_NAMESIZE]; char ut_host[UT_HOSTSIZE]; char _unused[20]; }; /* values for ut_type */ #define EMPTY 0 /* Empty struct */ #define RUN_LVL 1 /* SysV runlevel */ #define BOOT_TIME 2 /* System boot */ #define NEW_TIME 3 /* Mark new time at time change */ #define OLD_TIME 4 /* Mark old time at time change */ #define INIT_PROCESS 5 /* Process started by init */ #define LOGIN_PROCESS 6 /* User login */ #define USER_PROCESS 7 /* Normal process. */ #define DEAD_PROCESS 8 /* Terminated process. */ #define ACCOUNTING 9 __BEGIN_DECLS void endutxent(void); void setutxent(void); struct utmpx *getutxent(void); struct utmpx *getutxid(const struct utmpx *); struct utmpx *getutxline(const struct utmpx *); struct utmpx *pututxline(const struct utmpx *); void utmpxname(const char *); __END_DECLS #endif /* !_UTMPX_H_ */ --Dxnq1zWXvFF0Q93v-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Mar 21 16:56:48 2002 Delivered-To: freebsd-standards@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 0A9DA37B404; Thu, 21 Mar 2002 16:56:21 -0800 (PST) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.11.4/8.11.6) id g2M0uKU77186; Thu, 21 Mar 2002 19:56:20 -0500 (EST) (envelope-from wollman) Date: Thu, 21 Mar 2002 19:56:20 -0500 (EST) From: Garrett Wollman Message-Id: <200203220056.g2M0uKU77186@khavrinen.lcs.mit.edu> To: standards@FreeBSD.org Cc: audit@FreeBSD.org Subject: Expr fixes Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG [Followups to -standards, please.] I've fixed expr to be able to deal correctly with arguments and results consisting of a single '-'. At the same time, I also changed the data type used internally by expr to intmax_t, away from (deprecated) quad_t. The whole ``pre-parse to see if it might be an integer'' thing is silly, and should probably be removed entirely -- function calls are *not* that expensive. There are many style bugs in this utility. I have a couple of defect reports in to the Austin Group about the lack of specificity in 1003.1-2001 as regards how expr's integer math actually works, and whether expr should be prepared to accept an initial argument of "--" to indicate that there are no options. This change was created and tested on FreeBSD/sparc64, while tracking down a test-suite failure in autoconf 2.52. -GAWollman Index: expr.y =================================================================== RCS file: /home/cvs/src/bin/expr/expr.y,v retrieving revision 1.18 diff -u -r1.18 expr.y --- expr.y 2002/02/02 06:36:49 1.18 +++ expr.y 2002/03/22 00:47:57 @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -26,20 +27,20 @@ enum valtype type; union { char *s; - quad_t i; + intmax_t i; } u; } ; struct val *result; -int chk_div(quad_t, quad_t); -int chk_minus(quad_t, quad_t, quad_t); -int chk_plus(quad_t, quad_t, quad_t); -int chk_times(quad_t, quad_t, quad_t); +int chk_div(intmax_t, intmax_t); +int chk_minus(intmax_t, intmax_t, intmax_t); +int chk_plus(intmax_t, intmax_t, intmax_t); +int chk_times(intmax_t, intmax_t, intmax_t); void free_value(struct val *); int is_zero_or_null(struct val *); int isstring(struct val *); -struct val *make_integer(quad_t); +struct val *make_integer(intmax_t); struct val *make_str(const char *); struct val *op_and(struct val *, struct val *); struct val *op_colon(struct val *, struct val *); @@ -55,7 +56,7 @@ struct val *op_plus(struct val *, struct val *); struct val *op_rem(struct val *, struct val *); struct val *op_times(struct val *, struct val *); -quad_t to_integer(struct val *); +intmax_t to_integer(struct val *); void to_string(struct val *); int yyerror(const char *); int yylex(void); @@ -105,7 +106,7 @@ %% struct val * -make_integer(quad_t i) +make_integer(intmax_t i) { struct val *vp; @@ -123,26 +124,34 @@ make_str(const char *s) { struct val *vp; - size_t i; - int isint; + char *ep; vp = (struct val *) malloc (sizeof (*vp)); if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) { errx (2, "malloc() failed"); } - for(i = 1, isint = isdigit(s[0]) || s[0] == '-'; - isint && i < strlen(s); - i++) - { - if(!isdigit(s[i])) - isint = 0; - } + /* + * Previously we tried to scan the string to see if it ``looked like'' + * an integer (erroneously, as it happened). Let strtoimax() do the + * dirty work. We could cache the value, except that we are using + * a union and need to preserve the original string form until we + * are certain that it is not needed. + * + * IEEE Std.1003.1-2001 says: + * /integer/ An argument consisting only of an (optional) unary minus + * followed by digits. + * + * This means that arguments which consist of digits followed by + * non-digits MUST NOT be considered integers. strtoimax() will + * figure this out for us. + */ + (void)strtoimax(s, &ep, 10); - if (isint) - vp->type = numeric_string; - else + if (*ep != '\0') vp->type = string; + else + vp->type = numeric_string; return vp; } @@ -156,10 +165,10 @@ } -quad_t +intmax_t to_integer(struct val *vp) { - quad_t i; + intmax_t i; if (vp->type == integer) return 1; @@ -169,10 +178,10 @@ /* vp->type == numeric_string, make it numeric */ errno = 0; - i = strtoq(vp->u.s, (char**)NULL, 10); - if (errno != 0) { - errx (2, "overflow"); - } + i = strtoimax(vp->u.s, (char **)NULL, 10); + if (errno == ERANGE) + err(2, NULL); + free (vp->u.s); vp->u.i = i; vp->type = integer; @@ -187,12 +196,18 @@ if (vp->type == string || vp->type == numeric_string) return; - tmp = malloc ((size_t)25); + /* + * log_10(x) ~= 0.3 * log_2(x). Rounding up gives the number + * of digits; add one each for the sign and terminating null + * character, respectively. + */ +#define NDIGITS(x) (3 * (sizeof(x) * CHAR_BIT) / 10 + 1 + 1 + 1) + tmp = malloc (NDIGITS(vp->u.i)); if (tmp == NULL) { errx (2, "malloc() failed"); } - sprintf (tmp, "%lld", (long long)vp->u.i); + sprintf (tmp, "%jd", vp->u.i); vp->type = string; vp->u.s = tmp; } @@ -252,7 +267,7 @@ yyparse (); if (result->type == integer) - printf ("%lld\n", (long long)result->u.i); + printf ("%jd\n", result->u.i); else printf ("%s\n", result->u.s); @@ -284,7 +299,7 @@ if (is_zero_or_null (a) || is_zero_or_null (b)) { free_value (a); free_value (b); - return (make_integer ((quad_t)0)); + return (make_integer ((intmax_t)0)); } else { free_value (b); return (a); @@ -299,11 +314,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) == 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) == 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i == b->u.i)); + r = make_integer ((intmax_t)(a->u.i == b->u.i)); } free_value (a); @@ -319,11 +334,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) > 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) > 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i > b->u.i)); + r = make_integer ((intmax_t)(a->u.i > b->u.i)); } free_value (a); @@ -339,11 +354,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) < 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) < 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i < b->u.i)); + r = make_integer ((intmax_t)(a->u.i < b->u.i)); } free_value (a); @@ -359,11 +374,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) >= 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) >= 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i >= b->u.i)); + r = make_integer ((intmax_t)(a->u.i >= b->u.i)); } free_value (a); @@ -379,11 +394,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) <= 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) <= 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i <= b->u.i)); + r = make_integer ((intmax_t)(a->u.i <= b->u.i)); } free_value (a); @@ -399,11 +414,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) != 0)); + r = make_integer ((intmax_t)(strcoll (a->u.s, b->u.s) != 0)); } else { (void)to_integer(a); (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i != b->u.i)); + r = make_integer ((intmax_t)(a->u.i != b->u.i)); } free_value (a); @@ -412,7 +427,7 @@ } int -chk_plus(quad_t a, quad_t b, quad_t r) +chk_plus(intmax_t a, intmax_t b, intmax_t r) { /* sum of two positive numbers must be positive */ if (a > 0 && b > 0 && r <= 0) @@ -433,7 +448,7 @@ errx (2, "non-numeric argument"); } - r = make_integer (/*(quad_t)*/(a->u.i + b->u.i)); + r = make_integer (/*(intmax_t)*/(a->u.i + b->u.i)); if (chk_plus (a->u.i, b->u.i, r->u.i)) { errx (2, "overflow"); } @@ -443,16 +458,16 @@ } int -chk_minus(quad_t a, quad_t b, quad_t r) +chk_minus(intmax_t a, intmax_t b, intmax_t r) { - /* special case subtraction of QUAD_MIN */ - if (b == QUAD_MIN) { + /* special case subtraction of INTMAX_MIN */ + if (b == INTMAX_MIN) { if (a >= 0) return 1; else return 0; } - /* this is allowed for b != QUAD_MIN */ + /* this is allowed for b != INTMAX_MIN */ return chk_plus (a, -b, r); } @@ -465,7 +480,7 @@ errx (2, "non-numeric argument"); } - r = make_integer (/*(quad_t)*/(a->u.i - b->u.i)); + r = make_integer (/*(intmax_t)*/(a->u.i - b->u.i)); if (chk_minus (a->u.i, b->u.i, r->u.i)) { errx (2, "overflow"); } @@ -475,7 +490,7 @@ } int -chk_times(quad_t a, quad_t b, quad_t r) +chk_times(intmax_t a, intmax_t b, intmax_t r) { /* special case: first operand is 0, no overflow possible */ if (a == 0) @@ -495,7 +510,7 @@ errx (2, "non-numeric argument"); } - r = make_integer (/*(quad_t)*/(a->u.i * b->u.i)); + r = make_integer (/*(intmax_t)*/(a->u.i * b->u.i)); if (chk_times (a->u.i, b->u.i, r->u.i)) { errx (2, "overflow"); } @@ -505,11 +520,11 @@ } int -chk_div(quad_t a, quad_t b) +chk_div(intmax_t a, intmax_t b) { /* div by zero has been taken care of before */ - /* only QUAD_MIN / -1 causes overflow */ - if (a == QUAD_MIN && b == -1) + /* only INTMAX_MIN / -1 causes overflow */ + if (a == INTMAX_MIN && b == -1) return 1; /* everything else is OK */ return 0; @@ -528,7 +543,7 @@ errx (2, "division by zero"); } - r = make_integer (/*(quad_t)*/(a->u.i / b->u.i)); + r = make_integer (/*(intmax_t)*/(a->u.i / b->u.i)); if (chk_div (a->u.i, b->u.i)) { errx (2, "overflow"); } @@ -550,7 +565,7 @@ errx (2, "division by zero"); } - r = make_integer (/*(quad_t)*/(a->u.i % b->u.i)); + r = make_integer (/*(intmax_t)*/(a->u.i % b->u.i)); /* chk_rem necessary ??? */ free_value (a); free_value (b); @@ -584,11 +599,11 @@ v = make_str (a->u.s + rm[1].rm_so); } else { - v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); + v = make_integer ((intmax_t)(rm[0].rm_eo - rm[0].rm_so)); } } else { if (rp.re_nsub == 0) { - v = make_integer ((quad_t)0); + v = make_integer ((intmax_t)0); } else { v = make_str (""); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Mar 21 19:21:36 2002 Delivered-To: freebsd-standards@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id 5136A37B41B for ; Thu, 21 Mar 2002 19:21:34 -0800 (PST) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g2M3FXW19188; Thu, 21 Mar 2002 22:15:33 -0500 (EST) (envelope-from mike) Date: Thu, 21 Mar 2002 22:15:33 -0500 From: Mike Barcroft To: Peter Dufault Cc: Garrett Wollman , standards@FreeBSD.ORG Subject: Re: Garrett's POSIX versions patch for review Message-ID: <20020321221533.B80338@espresso.q9media.com> References: <20020226.224449.28794535.imp@village.org> <20020227184645.K47808-100000@gamplex.bde.org> <20020227144359.R31007@espresso.q9media.com> <20020318021728.D56122@espresso.q9media.com> <200203181926.g2IJQEo33811@khavrinen.lcs.mit.edu> <20020320161625.A5344@hda.hda.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020320161625.A5344@hda.hda.com>; from dufault@hda.hda.com on Wed, Mar 20, 2002 at 04:16:25PM -0500 Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Peter Dufault writes: > It was to build the kernel with newer interfaces and test them > by occasionally setting user-space _POSIX_VERSION into the "future", > leaving _POSIX_VERSION at the release. It seemed like a good idea > at the time, as bumping _POSIX_VERSION in general seemed > likely to autoconf in things you don't expect. Why don't we make the sysctl that it controls writable? This will allow developers the ability to test new POSIX features without recompiling their kernels. Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Mar 21 23:40:50 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 2776937B41B for ; Thu, 21 Mar 2002 23:40:04 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2M7e4W67209; Thu, 21 Mar 2002 23:40:04 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (095.b.003.mel.iprimus.net.au [210.50.32.95]) by hub.freebsd.org (Postfix) with ESMTP id 1629C37B404 for ; Thu, 21 Mar 2002 23:38:47 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2M7b5x01824; Fri, 22 Mar 2002 18:37:05 +1100 (EST) (envelope-from tim) Message-Id: <200203220737.g2M7b5x01824@descent.robbins.dropbear.id.au> Date: Fri, 22 Mar 2002 18:37:05 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36190: P1003.1-2001 newgrp command Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36190 >Category: standards >Synopsis: P1003.1-2001 newgrp command >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Mar 21 23:40:03 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #17: Thu Mar 21 19:48:18 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: FreeBSD is missing the P1003.1-2001 newgrp command. Many people believe 4.2BSD's group system makes this command unnecessary, but the standard still requires it. >How-To-Repeat: newgrp >Fix: This is an implementation of the newgrp utility. It obviously needs to be suid root to work, which is a security risk, and a risk I don't believe is worth taking in most cases. I suggest making newgrp suid a compile-time option like with ssh because most people won't use it. # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # Makefile # newgrp.c # newgrp.1 # echo x - Makefile sed 's/^X//' >Makefile << 'END-of-Makefile' X# $FreeBSD$ X# $Id: Makefile,v 1.1 2002/02/17 22:59:24 tim Exp $ X XPROG= newgrp XDPADD= ${LIBCRYPT} XLDADD= -lcrypt -lutil X XBINMODE=4555 XINSTALLFLAGS=-fschg X X.include END-of-Makefile echo x - newgrp.c sed 's/^X//' >newgrp.c << 'END-of-newgrp.c' X/*- X * Copyright (c) 2002 Tim J. Robbins. X * All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X */ X X/* X * newgrp -- change to a new group X */ X X#include X__FBSDID("$FreeBSD$"); X__RCSID("$Id: newgrp.c,v 1.5 2002/03/19 10:53:30 tim Exp $"); X X#include X X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X#include X Xvoid addgroup(const char *grpname); Xvoid restoregrps(void); Xvoid usage(void); X Xstruct passwd *pwd; X X/* Change groups back to those from the password/group databases */ Xvoid Xrestoregrps(void) X{ X X if (initgroups(pwd->pw_name, pwd->pw_gid)) { X warn("initgroups"); X return; X } X X if (setgid(pwd->pw_gid)) X warn("setgid"); X} X X/* Change gid and egid to specified group */ Xvoid Xaddgroup(const char *grpname) X{ X gid_t grps[NGROUPS_MAX]; X struct group *grp; X char *ep; X char **p; X long lgid; X gid_t egid; X int dbmember, i, newegmem, egmem, ngrps; X X /* X * Get group database entry for the specified group. First try it X * as a name, then a group ID. X */ X if ((grp = getgrnam(grpname)) == NULL) X if ((lgid = strtol(grpname, &ep, 10)) <= 0 || *ep != '\0' || X (grp = getgrgid((gid_t)lgid)) == NULL ) { X warnx("%s: bad group name", grpname); X return; X } X X /* Check whether user is a member of the requested group */ X dbmember = 0; X if (pwd->pw_gid == grp->gr_gid) X dbmember = 1; X for (p = grp->gr_mem; *p != NULL; p++) X if (strcmp(*p, pwd->pw_name) == 0) { X dbmember = 1; X break; X } X X /* Non-members need a password if one exists (except superuser). */ X if (!dbmember && *grp->gr_passwd != '\0' && getuid() != 0) { X char *pass; X X pass = getpass("Password:"); X if (pass == NULL || X strcmp(grp->gr_passwd, crypt(pass, grp->gr_passwd)) != 0) { X (void)fprintf(stderr, "Sorry\n"); X return; X } X } X X if ((ngrps = getgroups(NGROUPS_MAX, (gid_t *)grps)) < 0) { X warn("getgroups"); X return; X } X /* Determine whether current egid is in supp. group list */ X egid = getegid(); X egmem = 0; X for (i = 0; i < ngrps; i++) X if (grps[i] == egid) { X egmem = 1; X break; X } X /* Determine whether new egid is in supp. group list */ X newegmem = 0; X for (i = 0; i < ngrps; i++) X if (grps[i] == grp->gr_gid) { X newegmem = 1; X break; X } X X if (!egmem) { X /* X * "If the new effective group ID is not in the supplementary X * group list, newgrp will add the new effective group ID to X * the list, if there is room to add it." X */ X if (ngrps == NGROUPS_MAX) X warnx("too many groups"); X else { X grps[ngrps++] = grp->gr_gid; X if (setgroups(ngrps, (const gid_t *)grps)) X warn("setgroups"); X } X } X X if (newegmem) { X /* X * "If the new effective group ID is in the supplementary X * group list, newgrp will delete it." X */ X for (i = 0; i < ngrps; i++) X if (grps[i] == grp->gr_gid) X break; X ngrps--; X memmove(&grps[i], &grps[i + 1], (ngrps - i) * X sizeof(gid_t)); X if (setgroups(ngrps, (const gid_t *)grps)) X warn("setgroups"); X } X X /* Finally set grop id. */ X if (setgid(grp->gr_gid)) X warn("setgid"); X} X Xint Xmain(int argc, char *argv[]) X{ X const char *shell; X int ch, login; X X login = 0; X while ((ch = getopt(argc, argv, "-l")) > 0) { X switch (ch) { X case '-': X case 'l': X login = 1; X break; X default: X usage(); X /*NOTREACHED*/ X } X } X X argc -= optind; X argv += optind; X X if ((pwd = getpwuid(getuid())) == NULL) X errx(1, "who are you?"); X X if (*argv == NULL) X restoregrps(); X else X addgroup(*argv); X X if (setuid(getuid()) != 0) X err(1, "setuid"); X X if (!login) { X /* X * Not setting up login environment, keep all the old X * exported variables and current directory. X */ X if ((shell = getenv("SHELL")) == NULL) X shell = _PATH_BSHELL; X execl(shell, basename(shell), NULL); X err(1, "%s", shell); X } else { X /* X * Setting up login environment. Clean the environment, X * HOME, SHELL and USER environment variables from password X * database, default PATH, retain old TERM. X */ X char *args[2], *envs[6]; X char **ep = envs; X char *term; X login_cap_t *lc; X X shell = pwd->pw_shell; X if (*shell == '\0') X shell = _PATH_BSHELL; X if (chdir(pwd->pw_dir)) { X warn("%s", pwd->pw_dir); X chdir("/"); X } X X asprintf(ep++, "USER=%s", pwd->pw_name); X asprintf(ep++, "SHELL=%s", shell); X asprintf(ep++, "HOME=%s", pwd->pw_dir); X asprintf(ep++, "PATH=%s", _PATH_DEFPATH); X if ((term = getenv("TERM")) != NULL) X asprintf(ep++, "TERM=%s", term); X *ep = NULL; X X lc = login_getpwclass(pwd); X setclassenvironment(lc, pwd, 1); X X asprintf(&args[0], "-%s", basename(shell)); X args[1] = NULL; X X execve(shell, args, envs); X err(1, "%s", shell); X } X X /*NOTREACHED*/ X return (1); X} X Xvoid Xusage(void) X{ X X fprintf(stderr, "usage: newgrp [-] [-l] [group]\n"); X exit(1); X} END-of-newgrp.c echo x - newgrp.1 sed 's/^X//' >newgrp.1 << 'END-of-newgrp.1' X.\" Copyright (c) 2002 Tim J. Robbins. X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X.\" SUCH DAMAGE. X.\" X.\" $FreeBSD$ X.\" $Id: newgrp.1,v 1.4 2002/03/20 08:16:47 tim Exp $ X.\" X.Dd January 29, 2002 X.Dt NEWGRP 1 X.Os X.Sh NAME X.Nm newgrp X.Nd change to a new group X.Sh SYNOPSIS X.Nm X.Op Fl X.Op Fl l X.Op Ar group X.Sh DESCRIPTION XThe X.Nm Xutility creates a new shell execution environment with modified Xreal and effective group IDs. X.Pp XThe options are as follows: X.Bl -tag -width indent X.It Fl l Fl XSimulate a full login. The X.Ev HOME , X.Ev SHELL , X.Ev USER Xenvironment variables are set to the values from the current user's password Xdatabase entry. X.Ev PATH Xis set to the system default. XAll other environment variables are discarded except for X.Ev TERM . X.El X.Pp XIf the X.Ar group Xoperand is present, a new shell is started with the specified effective Xand real group IDs. XThe user will be prompted for a password if they are not a member of the Xspecified group. X.Pp XOtherwise, the real, effective and supplementary group IDs are restored to Xthose from the current user's password database Xentry. X.Sh ENVIRONMENT XNot modified except as described for the X.Fl l Xoption. X.Pp XThe X.Ev SHELL Xvariable is used to determine the shell to execute. X.Sh SEE ALSO X.Xr login 1 , X.Xr su 1 , X.Xr group 5 , X.Xr passwd 5 , X.Xr environ 7 X.Sh DIAGNOSTICS XWarning messages will be emitted if the requested group IDs cannot be set X(invalid group, bad password, ...) and if the shell cannot be executed. X.Sh STANDARDS XThe X.Nm Xutility is expected to comply with the X.St -p1003.1-2001 Xspecification. X.Sh BUGS XGroup passwords are inherently insecure as there is no way to stop Xusers obtaining the crypted passwords from the group database. XTheir use is discouraged. END-of-newgrp.1 exit >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Mar 21 23:50:34 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id AE27C37B417 for ; Thu, 21 Mar 2002 23:50:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2M7o1U74257; Thu, 21 Mar 2002 23:50:01 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (095.b.003.mel.iprimus.net.au [210.50.32.95]) by hub.freebsd.org (Postfix) with ESMTP id EA5F437B421 for ; Thu, 21 Mar 2002 23:44:03 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2M7gPw01928; Fri, 22 Mar 2002 18:42:25 +1100 (EST) (envelope-from tim) Message-Id: <200203220742.g2M7gPw01928@descent.robbins.dropbear.id.au> Date: Fri, 22 Mar 2002 18:42:25 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36191: P1003.1-2001 csplit utility Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36191 >Category: standards >Synopsis: P1003.1-2001 csplit utility >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Mar 21 23:50:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #17: Thu Mar 21 19:48:18 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: FreeBSD is missing the P1003.1-2001 csplit utililty. >How-To-Repeat: csplit >Fix: Here's an implementation of csplit. # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # Makefile # csplit.c # csplit.1 # echo x - Makefile sed 's/^X//' >Makefile << 'END-of-Makefile' X# $FreeBSD$ X# $Id: Makefile,v 1.1 2002/02/15 06:40:51 tim Exp $ X XPROG= csplit X X.include END-of-Makefile echo x - csplit.c sed 's/^X//' >csplit.c << 'END-of-csplit.c' X/*- X * Copyright (c) 2002 Tim J. Robbins. X * All rights reserved. X * X * Redistribution and use in source and binary forms, with or without X * modification, are permitted provided that the following conditions X * are met: X * 1. Redistributions of source code must retain the above copyright X * notice, this list of conditions and the following disclaimer. X * 2. Redistributions in binary form must reproduce the above copyright X * notice, this list of conditions and the following disclaimer in the X * documentation and/or other materials provided with the distribution. X * X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X * SUCH DAMAGE. X */ X X/* X * csplit -- split files based on context X * X * This utility splits its input into numbered output files by line number X * or by a regular expression. Regular expression matches have an optional X * offset with them, allowing the split to occur a specified number of X * lines before or after the match. X * X * To handle negative offsets, we stop reading when the match occurs and X * store the offset that the file should have been split at, then use X * this output file as input until all the "overflowed" lines have been read. X * The file is then closed and truncated to the correct length. X * X * We assume that the output files can be seeked upon (ie. they cannot be X * symlinks to named pipes or character devices), but make no such X * assumption about the input. X */ X X#include X__FBSDID("$FreeBSD$"); X__RCSID("$Id: csplit.c,v 1.17 2002/03/22 07:39:55 tim Exp $"); X X#include X X#include X#include X#include X#include X#include X#include X#include X#include X#include X Xvoid cleanup(void); Xvoid do_lineno(const char *expr); Xvoid do_rexp(const char *expr); Xchar *getline(void); XFILE *newfile(void); Xvoid toomuch(FILE *ofp, long n); Xvoid usage(void); X X/* X * Command line options X */ Xconst char *prefix; /* File name prefix */ Xlong sufflen; /* Number of decimal digits for suffix */ Xint sflag; /* Suppress output of file names */ Xint kflag; /* Keep output if error occurs */ X X/* X * Other miscellaneous globals (XXX too many) X */ Xlong lineno; /* Current line number in input file */ Xlong reps; /* Number of repetitions for this pattern */ Xlong nfiles; /* Number of files output so far */ Xchar currfile[PATH_MAX]; /* Current output file */ Xconst char *infn; /* Name of the input file */ XFILE *infile; /* Input file handle */ XFILE *overfile; /* Overflow file for toomuch() */ Xoff_t truncofs; /* Offset this file should be truncated at */ Xint doclean; /* Should cleanup() remove output? */ X X/* Create a new output file */ XFILE * Xnewfile(void) X{ X char fmt[20]; X FILE *fp; X X sprintf(fmt, "%%s%%0%ldld", sufflen); X sprintf(currfile, fmt, prefix, nfiles); X if ((fp = fopen(currfile, "w+")) == NULL) X err(1, "%s", currfile); X nfiles++; X X return (fp); X} X X/* Remove partial output, called before exiting. */ Xvoid Xcleanup(void) X{ X char fmt[20], fnbuf[PATH_MAX]; X long i; X X if (!doclean) X return; X X for (i = 0; i < nfiles; i++) { X sprintf(fmt, "%%s%%0%ldld", sufflen); X sprintf(fnbuf, fmt, prefix, i); X unlink(fnbuf); X } X} X X/* Read a line from the input */ Xchar * Xgetline(void) X{ X static char lbuf[LINE_MAX]; X FILE *src; X X src = overfile != NULL ? overfile : infile; X Xagain: if (fgets(lbuf, sizeof(lbuf), src) == NULL) { X if (src == overfile) { X src = infile; X goto again; X } X return (NULL); X } X lineno++; X if (strchr(lbuf, '\n') == NULL) X errx(1, "%s:%ld: line too long", infn, lineno); X if (ferror(src)) X err(1, "%s", infn); X X return (lbuf); X} X X/* Conceptually rewind the input (as obtained by getline()) back `n' lines */ Xvoid Xtoomuch(FILE *ofp, long n) X{ X char buf[BUFSIZ]; X size_t nread, i; X X if (overfile != NULL) { X /* X * Truncate the previous file we overflowed into back to X * the correct length, close it. X */ X if (fflush(overfile) != 0) X err(1, "overflow"); X if (ftruncate(fileno(overfile), truncofs) != 0) X err(1, "overflow"); X if (fclose(overfile) != 0) X err(1, "overflow"); X overfile = NULL; X } X X if (n == 0) X /* Just tidying up */ X return; X X lineno -= n; X X /* X * Wind the overflow file backwards to `n' lines before the X * current one. X */ X do { X /* Back a chunk */ X if (ftello(ofp) < (off_t)sizeof(buf)) X rewind(ofp); X else X fseek(ofp, -(long)sizeof(buf), SEEK_CUR); X if (ferror(ofp)) X errx(1, "%s: can't seek", currfile); X if ((nread = fread(buf, 1, sizeof(buf), ofp)) == 0) X errx(1, "can't read overflowed output"); X if (fseek(ofp, -(long)nread, SEEK_CUR) != 0) X err(1, "%s", currfile); X for (i = 0; i < nread; i++) X if (buf[nread - i] == '\n' && n-- == 0) X break; X } while (n > 0); X if (fseek(ofp, nread - i + 1, SEEK_CUR) != 0) X err(1, "%s", currfile); X X /* X * getline() will read from here. Next call will truncate to X * truncofs in this file. X */ X overfile = ofp; X truncofs = ftello(overfile); X} X X/* Handle splits for /regexp/ and %regexp% patterns */ Xvoid Xdo_rexp(const char *expr) X{ X regex_t cre; X long long nwritten; X long ofs; X char *ecopy, *ep, *p, *pofs, *re; X FILE *ofp; X int first; X X if ((ecopy = strdup(expr)) == NULL) X err(1, NULL); X X re = ecopy + 1; /* point to first char of regexp */ X if ((pofs = strrchr(ecopy, *expr)) == NULL || pofs[-1] == '\\') X errx(1, "%s: missing trailing %c", expr, *expr); X *pofs++ = '\0'; /* point to offset from regexp, zap trailing char */ X X if (*pofs != '\0') { X if (*pofs != '+' && *pofs != '-') X errx(1, "%s: bad offset", pofs); X errno = 0; X ofs = strtol(pofs, &ep, 10); X if (ofs < 0 || *ep != '\0' || errno != 0) X errx(1, "%s: bad offset", pofs); X } else X ofs = 0; X X if (regcomp(&cre, re, REG_BASIC|REG_NOSUB) != 0) X errx(1, "%s: bad regular expression", re); X X if (*expr == '/') X /* /regexp/: Save results to a file */ X ofp = newfile(); X else X /* %regexp%: Make a temporary file for overflow */ X ofp = tmpfile(); X X /* Read and output lines until we get a match */ X first = 1; X while ((p = getline()) != NULL) { X if (fputs(p, ofp) != 0) X break; X if (!first && regexec(&cre, p, 0, NULL, 0) == 0) X break; X first = 0; X } X X if (ofs <= 0) { X /* X * Negative (or zero) offset: throw back any lines we should X * not have read yet. X */ X if (p != NULL) { X toomuch(ofp, -ofs + 1); X nwritten = (long long)truncofs; X } else X nwritten = (long long)ftello(ofp); X } else { X /* X * Positive offset: copy the requested number of lines X * after the match. X */ X while (--ofs > 0 && (p = getline()) != NULL) X fputs(p, ofp); X toomuch(NULL, 0); X nwritten = (long long)ftello(ofp); X if (fclose(ofp) != 0) X err(1, "%s", currfile); X } X X if (!sflag && *expr == '/') X printf("%lld\n", (long long)nwritten); X X regfree(&cre); X free(ecopy); X} X X/* Handle splits based on line number */ Xvoid Xdo_lineno(const char *expr) X{ X long tgtline, lastline; X char *p, *ep; X FILE *ofp; X X errno = 0; X tgtline = strtol(expr, &ep, 10); X if (tgtline <= 0 || errno != 0 || *ep != '\0') X errx(1, "%s: bad line number", expr); X lastline = tgtline; X if (lastline <= lineno) X errx(1, "%s: can't go backwards", expr); X X for (;;) { X ofp = newfile(); X while (lineno + 1 != lastline) X if ((p = getline()) == NULL || fputs(p, ofp) != 0) X break; X if (!sflag) X printf("%lld\n", (long long)ftello(ofp)); X if (fclose(ofp) != 0) X err(1, "%s", currfile); X if (reps-- == 0) X break; X lastline += tgtline; X } X} X Xint Xmain(int argc, char *argv[]) X{ X const char *expr; X char *ep, *p; X FILE *ofp; X int ch; X X kflag = sflag = 0; X prefix = "xx"; X sufflen = 2; X while ((ch = getopt(argc, argv, "ksf:n:")) > 0) { X switch (ch) { X case 'f': X prefix = optarg; X break; X case 'k': X kflag = 1; X break; X case 'n': X errno = 0; X sufflen = strtol(optarg, &ep, 10); X if (sufflen <= 0 || *ep != '\0' || errno != 0) X errx(1, "%s: bad suffix length", optarg); X break; X case 's': X sflag = 1; X break; X default: X usage(); X /*NOTREACHED*/ X } X } X X if (sufflen + strlen(prefix) >= PATH_MAX) X errx(1, "name too long"); X X argc -= optind; X argv += optind; X X if ((infn = *argv++) == NULL) X usage(); X if (strcmp(infn, "-") == 0) { X infile = stdin; X infn = "stdin"; X } else if ((infile = fopen(infn, "r")) == NULL) X err(1, "%s", infn); X X if (!kflag) { X doclean = 1; X atexit(cleanup); X } X X lineno = 0; X nfiles = 0; X truncofs = 0; X overfile = NULL; X X while ((expr = *argv++) != NULL) { X /* Look ahead & see if this pattern has any repetitions */ X if (*argv != NULL && **argv == '{') { X errno = 0; X reps = strtol(*argv + 1, &ep, 10); X if (reps < 0 || *ep != '}' || errno != 0) X errx(1, "%s: bad repetitions", expr); X argv++; X } else X reps = 0; X X if (*expr == '/' || *expr == '%') { X /* Regular expression copy or ignore */ X do X do_rexp(expr); X while (reps-- != 0); X } else if (isdigit(*expr)) X do_lineno(expr); X else X errx(1, "bad expression %s", expr); X } X X /* Copy the rest into a new file */ X if (!feof(infile)) { X ofp = newfile(); X while ((p = getline()) != NULL && fputs(p, ofp) == 0) X ; X if (!sflag) X printf("%lld\n", (long long)ftell(ofp)); X if (fclose(ofp) != 0) X err(1, "%s", currfile); X } X X toomuch(NULL, 0); X doclean = 0; X X return (0); X} X Xvoid Xusage(void) X{ X fprintf(stderr, X"usage: csplit [-ks] [-f prefix] [-n number] file [args ...]\n"); X exit(1); X} END-of-csplit.c echo x - csplit.1 sed 's/^X//' >csplit.1 << 'END-of-csplit.1' X.\" Copyright (c) 2002 Tim J. Robbins. X.\" All rights reserved. X.\" X.\" Redistribution and use in source and binary forms, with or without X.\" modification, are permitted provided that the following conditions X.\" are met: X.\" 1. Redistributions of source code must retain the above copyright X.\" notice, this list of conditions and the following disclaimer. X.\" 2. Redistributions in binary form must reproduce the above copyright X.\" notice, this list of conditions and the following disclaimer in the X.\" documentation and/or other materials provided with the distribution. X.\" X.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE X.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF X.\" SUCH DAMAGE. X.\" X.\" $FreeBSD$ X.\" $Id: csplit.1,v 1.8 2002/02/20 12:52:11 tim Exp $ X.\" X.Dd February 20, 2002 X.Dt CSPLIT 1 X.Os X.Sh NAME X.Nm csplit X.Nd split files based on context X.Sh SYNOPSIS X.Nm X.Op Fl ks X.Op Fl f Ar prefix X.Op Fl n Ar number X.Ar file X.Bk X.Op Ar args ... X.Ek X.Sh DESCRIPTION XThe X.Nm Xutility splits X.Ar file Xinto pieces using the patterns X.Ar args... . XIf X.Ar file Xis Xa dash X.Pq Sq \&- , X.Nm Xreads from standard input. X.Pp XThe options are as follows: X.Bl -tag -width indent X.It Fl f Ar prefix XName the created files beginning with X.Ar prefix . XThe default is X.Dq Pa xx . X.It Fl k XDo not remove output files if an error occurs. X.It Fl n Ar number XUse X.Ar number Xof decimal digits after the X.Ar prefix Xto form the file name. The default is 2. X.It Fl s XDo not write the size of each output file. X.El X.Pp XThe X.Ar args... Xoperands may be a combination of the following: X.Bl -tag -width "line_no" X.It Em /regexp/[[+|-]offset] XCreate a file containing the input from the current line to (but not including) Xthe next line matching the given basic regular expression. X.It Em %regexp%[[+|-]offset] XSame as above but a file is not created for the output. X.It Em line_no XCreate containing the input from the current line to (but not including) Xthe specified line number. X.It Em {num} XRepeat the previous pattern the specified number of times. XIf it follows a line number pattern, a new file will be created for each X.Em line_no Xlines, X.Em num Xtimes. XThe first line of the file is line number 1 for historic reasons. X.El X.Pp XAfter all the patterns have been processed, the remaining input data X(if there is any) will be written to a new file. X.Pp XRequesting to split at a line before the current line number will result Xin an error. X.Sh EXAMPLES XSplit the X.Xr mdoc 7 Xfile X.Pa foo.1 Xinto one file for each section (up to 20): X.Pp X.D1 Ic csplit foo.1 %^\\.Sh% /^\\.Sh/ {20} X.Pp XSplit standard input into 66 line pages. X.Pp X.D1 Ic csplit - 67 66 {19} X.Sh DIAGNOSTICS X.Ex -std X.Sh COMPATIBILITY XSome implementations of X.Nm Xcannot work with input files that are not regular files. This implementation Xdoes not share this problem. X.Sh SEE ALSO X.Xr sed 1 , X.Xr split 1 , X.Xr re_format 7 X.Sh STANDARDS XThe X.Nm Xutility is expected to comply with the X.St -p1003.1-2001 Xspecification. X.Pp XThe ability to specify a file argument of X.Sq \&- Xto read from standard input is a X.Fx Xextension. END-of-csplit.1 exit >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Mar 22 0:10: 7 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id B5F5337B419 for ; Fri, 22 Mar 2002 00:10:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2M8A3681181; Fri, 22 Mar 2002 00:10:03 -0800 (PST) (envelope-from gnats) Date: Fri, 22 Mar 2002 00:10:03 -0800 (PST) Message-Id: <200203220810.g2M8A3681181@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: "Tim J. Robbins" Subject: Re: standards/36190: P1003.1-2001 newgrp command Reply-To: "Tim J. Robbins" Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The following reply was made to PR standards/36190; it has been noted by GNATS. From: "Tim J. Robbins" To: Jos Backus Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: standards/36190: P1003.1-2001 newgrp command Date: Fri, 22 Mar 2002 19:03:33 +1100 On Thu, Mar 21, 2002 at 11:45:49PM -0801, Jos Backus wrote: > On Fri, Mar 22, 2002 at 06:37:05PM +1100, Tim J. Robbins wrote: > > X /* Finally set grop id. */ > > Typo? Fixed. tim@descent$ rcsdiff -u -r1.5 -r1.6 newgrp.c =================================================================== RCS file: RCS/newgrp.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- newgrp.c 2002/03/19 10:53:30 1.5 +++ newgrp.c 2002/03/22 08:01:36 1.6 @@ -30,7 +30,7 @@ #include __FBSDID("$FreeBSD$"); -__RCSID("$Id: newgrp.c,v 1.5 2002/03/19 10:53:30 tim Exp $"); +__RCSID("$Id: newgrp.c,v 1.6 2002/03/22 08:01:36 tim Exp $"); #include @@ -162,7 +162,7 @@ warn("setgroups"); } - /* Finally set grop id. */ + /* Finally set group id. */ if (setgid(grp->gr_gid)) warn("setgid"); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Mar 22 4: 1:39 2002 Delivered-To: freebsd-standards@freebsd.org Received: from hda.hda.com (host65.hda.com [63.104.68.65]) by hub.freebsd.org (Postfix) with ESMTP id E421B37B419; Fri, 22 Mar 2002 04:01:34 -0800 (PST) Received: (from dufault@localhost) by hda.hda.com (8.11.6/8.11.6) id g2MC2fv03440; Fri, 22 Mar 2002 07:02:41 -0500 (EST) (envelope-from dufault) Date: Fri, 22 Mar 2002 07:02:41 -0500 From: Peter Dufault To: Mike Barcroft Cc: Garrett Wollman , standards@FreeBSD.ORG Subject: Re: Garrett's POSIX versions patch for review Message-ID: <20020322070241.A3411@hda.hda.com> References: <20020226.224449.28794535.imp@village.org> <20020227184645.K47808-100000@gamplex.bde.org> <20020227144359.R31007@espresso.q9media.com> <20020318021728.D56122@espresso.q9media.com> <200203181926.g2IJQEo33811@khavrinen.lcs.mit.edu> <20020320161625.A5344@hda.hda.com> <20020321221533.B80338@espresso.q9media.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020321221533.B80338@espresso.q9media.com>; from mike@FreeBSD.ORG on Thu, Mar 21, 2002 at 10:15:33PM -0500 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Mar 21, 2002 at 10:15:33PM -0500, Mike Barcroft wrote: > Peter Dufault writes: > > It was to build the kernel with newer interfaces and test them > > by occasionally setting user-space _POSIX_VERSION into the "future", > > leaving _POSIX_VERSION at the release. It seemed like a good idea > > at the time, as bumping _POSIX_VERSION in general seemed > > likely to autoconf in things you don't expect. > > Why don't we make the sysctl that it controls writable? This will > allow developers the ability to test new POSIX features without > recompiling their kernels. I don't see that as needed. The user _POSIX_VERSION should cleanly select new features, what the kernel supports shouldn't need to be modified. I think anything with _KPOSIX_VERSION <= _POSIX_VERSION is tested, in regular use, and can be unconditional (at least by that feature test), while _KPOSIX_VERSION > _POSIX_VERSION features are not ready for universal use and can be enabled by advancing _POSIX_VERSION. Is this obviated by the notion of a -current? Maybe, I like the notion of a _KPOSIX_VERSION as what should be there is well defined, but I'm inactive. Peter -- Peter Dufault (dufault@hda.com) Realtime development, Machine control, HD Associates, Inc. Fail-Safe systems, Agency approval To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Mar 22 5:20: 9 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 68F4A37B400 for ; Fri, 22 Mar 2002 05:20:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2MDK3653346; Fri, 22 Mar 2002 05:20:03 -0800 (PST) (envelope-from gnats) Date: Fri, 22 Mar 2002 05:20:03 -0800 (PST) Message-Id: <200203221320.g2MDK3653346@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: Ruslan Ermilov Subject: Re: standards/36190: P1003.1-2001 newgrp command Reply-To: Ruslan Ermilov Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The following reply was made to PR standards/36190; it has been noted by GNATS. From: Ruslan Ermilov To: "Tim J. Robbins" Cc: bug-followup@FreeBSD.org Subject: Re: standards/36190: P1003.1-2001 newgrp command Date: Fri, 22 Mar 2002 15:09:45 +0200 On Fri, Mar 22, 2002 at 06:37:05PM +1100, Tim J. Robbins wrote: > > # $Id: Makefile,v 1.1 2002/02/17 22:59:24 tim Exp $ > > PROG= newgrp > DPADD= ${LIBCRYPT} > LDADD= -lcrypt -lutil > > BINMODE=4555 > INSTALLFLAGS=-fschg > > .include You need to fix DPADD -- consult with ``make checkdpadd''. Cheers, -- Ruslan Ermilov Sysadmin and DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Mar 22 6:50: 6 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id E324037B400 for ; Fri, 22 Mar 2002 06:50:02 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2MEo2586444; Fri, 22 Mar 2002 06:50:02 -0800 (PST) (envelope-from gnats) Date: Fri, 22 Mar 2002 06:50:02 -0800 (PST) Message-Id: <200203221450.g2MEo2586444@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: "Brian F. Feldman" Subject: Re: standards/36191: P1003.1-2001 csplit utility Reply-To: "Brian F. Feldman" Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The following reply was made to PR standards/36191; it has been noted by GNATS. From: "Brian F. Feldman" To: "Tim J. Robbins" Cc: FreeBSD-gnats-submit@FreeBSD.org Subject: Re: standards/36191: P1003.1-2001 csplit utility Date: Fri, 22 Mar 2002 09:49:36 -0500 "Tim J. Robbins" wrote: > X sprintf(fmt, "%%s%%0%ldld", sufflen); > X sprintf(currfile, fmt, prefix, nfiles); This is a bit of a strange construct. You should probably be using something like: snprintf(currfile, sizeof(currfile), "%s%*ld", prefix, sufflen, nfiles); -- Brian Fundakowski Feldman \'[ FreeBSD ]''''''''''\ <> green@FreeBSD.org <> bfeldman@tislabs.com \ The Power to Serve! \ Opinions expressed are my own. \,,,,,,,,,,,,,,,,,,,,,,\ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Mar 22 8:33:40 2002 Delivered-To: freebsd-standards@freebsd.org Received: from sunny.newgold.net (Durham-ar1-4-64-252-018.dsl.genuity.net [4.64.252.18]) by hub.freebsd.org (Postfix) with ESMTP id 8DB7237B427; Fri, 22 Mar 2002 08:33:23 -0800 (PST) Received: from sunny.newgold.net (freebsd@localhost [IPv6:::1]) by sunny.newgold.net (8.12.1/8.12.1) with ESMTP id g2MG85II012588; Fri, 22 Mar 2002 16:12:10 GMT Received: (from freebsd@localhost) by sunny.newgold.net (8.12.1/8.12.1/Submit) id g2MG7svv006089; Fri, 22 Mar 2002 16:07:54 GMT Date: Fri, 22 Mar 2002 16:06:32 +0000 From: "J. Mallett" To: "J. Mallett" Cc: "Tim J. Robbins" , freebsd-audit@FreeBSD.ORG, freebsd-standards@FreeBSD.ORG Subject: Re: patch for review: xargs standards compliance Message-ID: <20020322160631.A31375@FreeBSD.ORG> References: <20020315231100.A20942@FreeBSD.ORG> <20020316192629.A5254@descent.robbins.dropbear.id.au> <20020316090004.A26394@FreeBSD.ORG> <20020316093507.B26394@FreeBSD.ORG> <20020316101434.A2192@FreeBSD.ORG> <20020322035231.A23277@FreeBSD.ORG> <20020322160802.B1338@descent.robbins.dropbear.id.au> <20020322151214.A26549@FreeBSD.ORG> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020322151214.A26549@FreeBSD.ORG> User-Agent: Mutt/1.3.21i Organisation: FreeBSD Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Mar 22, 2002 at 03:12:15PM +0000, J. Mallett wrote: > > Well, given all the input thus far, I'd like to commit > http://people.freebsd.org/~jmallett/xargs.patch4 > However I just pulled up the SUS spec online and found I was misremembering how exactly things were worded, and realised that strnsubst needs run with a n of 5 for each argument, not for the entire arguments list. One thing I am now unsure of that I'd forgotten all about is: "Constructed arguments cannot grow larger than 255 bytes. " Should I errx() if strlen(*tmp) is >255, or should I augment strnsubst() to take a size argument and not allow more than that amount to be allocated, and furthermore, do I strlcat replstr for each match, or do I do checks along the way to see if it is time to give up on replacing, and just concatenate the rest of the string. I *think* given the language relating to umber of replacements in the argument list, that I should TRY to replace as many times as possible, up to five... Thoughts? Anyway, here's with strnsubst() taking yet another size_t argument, and it being used to set the maximum size, and checks as I think the standard permits it. The way I've done it is to ensure we either get as much of the input string as possible, or we continue concatenating. This sometimes results in arguments less than 255 bytes, but will never result in a higher amount. The standard is not clear enough on this point in my opinion, and so it is up to the implementation what to do to ensure it never grows beyond 255 bytes per argument, I suppose, in whatever way is seen fit. http://people.freebsd.org/~jmallett/xargs.patch5 This is being copied to -standards, as now I am getting into the grounds of interpereting SUS, and I'd rather not do that without review in principle as well as in code. Thank you, /j. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Mar 22 17: 0:10 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3E2D137B400 for ; Fri, 22 Mar 2002 17:00:07 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2N107478747; Fri, 22 Mar 2002 17:00:07 -0800 (PST) (envelope-from gnats) Date: Fri, 22 Mar 2002 17:00:07 -0800 (PST) Message-Id: <200203230100.g2N107478747@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: "Tim J. Robbins" Subject: Re: standards/36190: P1003.1-2001 newgrp command Reply-To: "Tim J. Robbins" Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The following reply was made to PR standards/36190; it has been noted by GNATS. From: "Tim J. Robbins" To: Ruslan Ermilov Cc: bug-followup@FreeBSD.org Subject: Re: standards/36190: P1003.1-2001 newgrp command Date: Sat, 23 Mar 2002 11:56:37 +1100 On Fri, Mar 22, 2002 at 03:09:45PM +0200, Ruslan Ermilov wrote: > You need to fix DPADD -- consult with ``make checkdpadd''. Thanks. I believe this patch makes it correct, then: --- Makefile 2002/02/17 22:59:24 1.1 +++ Makefile 2002/03/23 00:30:09 1.2 @@ -1,8 +1,8 @@ # $FreeBSD$ -# $Id: Makefile,v 1.1 2002/02/17 22:59:24 tim Exp $ +# $Id: Makefile,v 1.2 2002/03/23 00:30:09 tim Exp $ PROG= newgrp -DPADD= ${LIBCRYPT} +DPADD= ${LIBCRYPT} ${LIBUTIL} LDADD= -lcrypt -lutil BINMODE=4555 Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Mar 22 19:50:22 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id DC58037B404 for ; Fri, 22 Mar 2002 19:50:07 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2N3o7933719; Fri, 22 Mar 2002 19:50:07 -0800 (PST) (envelope-from gnats) Date: Fri, 22 Mar 2002 19:50:07 -0800 (PST) Message-Id: <200203230350.g2N3o7933719@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: "Tim J. Robbins" Subject: Re: standards/36191: P1003.1-2001 csplit utility Reply-To: "Tim J. Robbins" Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The following reply was made to PR standards/36191; it has been noted by GNATS. From: "Tim J. Robbins" To: "Brian F. Feldman" Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: standards/36191: P1003.1-2001 csplit utility Date: Sat, 23 Mar 2002 14:41:04 +1100 On Fri, Mar 22, 2002 at 09:49:36AM -0500, Brian F. Feldman wrote: > "Tim J. Robbins" wrote: > > X sprintf(fmt, "%%s%%0%ldld", sufflen); > > X sprintf(currfile, fmt, prefix, nfiles); > > This is a bit of a strange construct. You should probably be using > something like: > snprintf(currfile, sizeof(currfile), "%s%*ld", prefix, sufflen, nfiles); Thanks for your suggestion - that way is indeed much cleaner. --- csplit.c 2002/03/22 07:39:55 1.17 +++ csplit.c 2002/03/23 03:36:26 1.18 @@ -44,7 +44,7 @@ #include __FBSDID("$FreeBSD$"); -__RCSID("$Id: csplit.c,v 1.17 2002/03/22 07:39:55 tim Exp $"); +__RCSID("$Id: csplit.c,v 1.18 2002/03/23 03:36:26 tim Exp $"); #include @@ -91,11 +91,10 @@ FILE * newfile(void) { - char fmt[20]; FILE *fp; - sprintf(fmt, "%%s%%0%ldld", sufflen); - sprintf(currfile, fmt, prefix, nfiles); + snprintf(currfile, sizeof(currfile), "%s%0*ld", prefix, sufflen, + nfiles); if ((fp = fopen(currfile, "w+")) == NULL) err(1, "%s", currfile); nfiles++; @@ -107,15 +106,14 @@ void cleanup(void) { - char fmt[20], fnbuf[PATH_MAX]; + char fnbuf[PATH_MAX]; long i; if (!doclean) return; for (i = 0; i < nfiles; i++) { - sprintf(fmt, "%%s%%0%ldld", sufflen); - sprintf(fnbuf, fmt, prefix, i); + snprintf(fnbuf, sizeof(fnbuf), "%s%0*ld", prefix, sufflen, i); unlink(fnbuf); } } Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Mar 22 20: 2:21 2002 Delivered-To: freebsd-standards@freebsd.org Received: from descent.robbins.dropbear.id.au (254.d.010.mel.iprimus.net.au [210.50.203.254]) by hub.freebsd.org (Postfix) with ESMTP id D858337B419; Fri, 22 Mar 2002 20:02:13 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2N415a03833; Sat, 23 Mar 2002 15:01:05 +1100 (EST) (envelope-from tim) Date: Sat, 23 Mar 2002 15:01:05 +1100 From: "Tim J. Robbins" To: "J. Mallett" Cc: freebsd-audit@FreeBSD.ORG, freebsd-standards@FreeBSD.ORG Subject: Re: patch for review: xargs standards compliance Message-ID: <20020323150105.A3813@descent.robbins.dropbear.id.au> References: <20020316192629.A5254@descent.robbins.dropbear.id.au> <20020316090004.A26394@FreeBSD.ORG> <20020316093507.B26394@FreeBSD.ORG> <20020316101434.A2192@FreeBSD.ORG> <20020322035231.A23277@FreeBSD.ORG> <20020322160802.B1338@descent.robbins.dropbear.id.au> <20020322151214.A26549@FreeBSD.ORG> <20020322160631.A31375@FreeBSD.ORG> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020322160631.A31375@FreeBSD.ORG>; from jmallett@FreeBSD.ORG on Fri, Mar 22, 2002 at 04:06:32PM +0000 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Mar 22, 2002 at 04:06:32PM +0000, J. Mallett wrote: > One thing I am now unsure of that I'd forgotten all about is: > "Constructed arguments cannot grow larger than 255 bytes. " > > Should I errx() if strlen(*tmp) is >255, or should I augment strnsubst() > to take a size argument and not allow more than that amount to be > allocated, and furthermore, do I strlcat replstr for each match, or do I > do checks along the way to see if it is time to give up on replacing, and > just concatenate the rest of the string. I *think* given the language > relating to umber of replacements in the argument list, that I should TRY > to replace as many times as possible, up to five... $ echo hello | xargs -I xxx echo `perl -e 'print "A"x255;'`xxx xargs: Maximum argument size with insertion via xxx's exceeded Segmentation Fault $ uname -sr SunOS 5.8 Since SUS is biased towards SysV, you should probably print an error message and exit like Solaris tries to; no need for you to segfault like they do though ;) Also: $ echo hello | xargs -Ixxx a xxx b xxx c xxx d xxx e xxx f xxx xargs: too many args with xxx So it seems you should quit with an error when either of these limits are reached. This seems to be a flaw in the standard because these limits are (a) artifically low and (b) cannot be raised by implementors. Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sat Mar 23 18:10:16 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 8D31B37B419 for ; Sat, 23 Mar 2002 18:10:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2O2A1F52593; Sat, 23 Mar 2002 18:10:01 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (126.b.008.mel.iprimus.net.au [210.50.87.126]) by hub.freebsd.org (Postfix) with ESMTP id 6E47B37B404 for ; Sat, 23 Mar 2002 18:08:40 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2O21RG14101; Sun, 24 Mar 2002 13:01:27 +1100 (EST) (envelope-from tim) Message-Id: <200203240201.g2O21RG14101@descent.robbins.dropbear.id.au> Date: Sun, 24 Mar 2002 13:01:27 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36243: pr is missing P1003.1-2001 -f and -p options Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36243 >Category: standards >Synopsis: pr is missing P1003.1-2001 -f and -p options >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Mar 23 18:10:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #17: Thu Mar 21 19:48:18 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: P1003.1-2001 specifies the -f and -p options, which are not present in FreeBSD's pr utility. >How-To-Repeat: pr -f >Fix: Note: I use ++fooflag instead of fooflag = 1 in the getopt() loop and cast return value of fclose() and putc() to void for consistency, not because I think they're correct. This is a slightly modified version of the patch I posted to freebsd-standards a few months ago. Index: pr.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/pr/pr.1,v retrieving revision 1.17 diff -u -r1.17 pr.1 --- pr.1 2001/09/21 02:57:56 1.17 +++ pr.1 2002/03/24 02:05:07 @@ -50,7 +50,7 @@ .Bk -words .Op Fl Ar column .Ek -.Op Fl adFmrt +.Op Fl adFfmprt .Bk -words .Oo .Op Fl e @@ -197,6 +197,10 @@ sequence of .Em characters. +.It Fl f +Same as +.Fl F +but pause before beginning the first page if standard output is a terminal. .It Fl h Ar header Use the string .Ar header @@ -293,6 +297,11 @@ .Fl o option is not specified, the default is zero. The space taken is in addition to the output line width. +.It Fl p +Pause before each page if the standard output is a terminal. +.Nm +will write an alert character to standard error and wait for a carriage +return to be read on the terminal. .It Fl r Write no diagnostic reports on failure to open a file. .It Fl s Ar char @@ -373,7 +382,7 @@ The .Nm utility is -.St -p1003.2 +.St -p1003.1-2001 compatible. .Sh HISTORY A Index: pr.c =================================================================== RCS file: /home/ncvs/src/usr.bin/pr/pr.c,v retrieving revision 1.12 diff -u -r1.12 pr.c --- pr.c 2002/02/17 20:53:56 1.12 +++ pr.c 2002/03/24 02:05:10 @@ -84,6 +84,8 @@ int dspace; /* double space flag */ char inchar; /* expand input char */ int ingap; /* expand input gap */ +int pausefst; /* Pause before first page */ +int pauseall; /* Pause before each page */ int formfeed; /* use formfeed as trailer */ char *header; /* header name instead of file name */ char ochar; /* contract output char */ @@ -139,6 +141,23 @@ } /* + * Write an alert character and wait for a carriage return on /dev/tty. + */ +void +ttypause(void) +{ + int pch; + FILE *ttyfp; + + if ((ttyfp = fopen("/dev/tty", "r")) != NULL) { + (void)putc('\a', stderr); + while ((pch = getc(ttyfp)) != '\n' && pch != EOF) + ; + (void)fclose(ttyfp); + } +} + +/* * onecol: print files with only one column of output. * Line length is unlimited. */ @@ -222,6 +241,10 @@ ips = 0; cps = 0; + if ((pauseall || (pausefst && pagecnt == 1)) && + isatty(STDOUT_FILENO)) + ttypause(); + /* * loop by line */ @@ -410,6 +433,9 @@ * loop by page */ for(;;) { + if ((pauseall || (pausefst && pagecnt == 1)) && + isatty(STDOUT_FILENO)) + ttypause(); /* * loop by column */ @@ -666,6 +692,10 @@ * loop by page */ for(;;) { + if ((pauseall || (pausefst && pagecnt == 1)) && + isatty(STDOUT_FILENO)) + ttypause(); + /* * loop by line */ @@ -856,6 +886,10 @@ * continue to loop while any file still has data */ while (actf > 0) { + if ((pauseall || (pausefst && pagecnt == 1)) && + isatty(STDOUT_FILENO)) + ttypause(); + /* * loop by line */ @@ -1561,7 +1595,8 @@ usage() { (void)fputs( - "usage: pr [+page] [-col] [-adFmrt] [-e[ch][gap]] [-h header]\n",err); + "usage: pr [+page] [-col] [-adFfmprt] [-e[ch][gap]] [-h header]\n", + err); (void)fputs( " [-i[ch][gap]] [-l line] [-n[ch][width]] [-o offset]\n",err); (void)fputs( @@ -1596,7 +1631,7 @@ } } else err = stderr; - while ((c = egetopt(argc, argv, "#adFmrte?h:i?L:l:n?o:s?w:")) != -1) { + while ((c = egetopt(argc, argv, "#adFfmrte?h:i?L:l:n?o:ps?w:")) != -1) { switch (c) { case '+': if ((pgnm = atoi(eoptarg)) < 1) { @@ -1640,6 +1675,9 @@ } else ingap = INGAP; break; + case 'f': + ++pausefst; + /*FALLTHROUGH*/ case 'F': ++formfeed; break; @@ -1704,6 +1742,9 @@ err); return(1); } + break; + case 'p': + ++pauseall; break; case 'r': ++nodiag; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sat Mar 23 18:40:19 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 0376637B419 for ; Sat, 23 Mar 2002 18:40:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2O2e0w70144; Sat, 23 Mar 2002 18:40:00 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (126.b.008.mel.iprimus.net.au [210.50.87.126]) by hub.freebsd.org (Postfix) with ESMTP id 8330837B439 for ; Sat, 23 Mar 2002 18:33:26 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2O2Pn114298; Sun, 24 Mar 2002 13:25:49 +1100 (EST) (envelope-from tim) Message-Id: <200203240225.g2O2Pn114298@descent.robbins.dropbear.id.au> Date: Sun, 24 Mar 2002 13:25:49 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: standards/36245: Missing P1003.1-2001 fold -b and -s options Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 36245 >Category: standards >Synopsis: Missing P1003.1-2001 fold -b and -s options >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Mar 23 18:40:00 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #17: Thu Mar 21 19:48:18 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: FreeBSD's fold(1) utility is missing the -b and -s options mandated by P1003.1-2001. >How-To-Repeat: fold -s >Fix: This patch is based on NetBSD's fold utility, with some style changes. Index: fold.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/fold/fold.1,v retrieving revision 1.7 diff -u -r1.7 fold.1 --- fold.1 2001/12/12 18:25:53 1.7 +++ fold.1 2002/03/24 02:31:02 @@ -40,6 +40,7 @@ .Nd "fold long lines for finite width output device" .Sh SYNOPSIS .Nm +.Op Fl bs .Op Fl w Ar width .Op Ar .Sh DESCRIPTION @@ -50,6 +51,14 @@ .Pp The following option is available: .Bl -tag -width indent +.It Fl b +Count +.Ar width +in bytes rather than column positions. +.It Fl s +Fold line after the last blank character within the first +.Ar width +column positions (or bytes). .It Fl w Ar width Specify a line width to use instead of the default 80 characters. .Ar Width Index: fold.c =================================================================== RCS file: /home/ncvs/src/usr.bin/fold/fold.c,v retrieving revision 1.7 diff -u -r1.7 fold.c --- fold.c 2002/03/22 01:22:35 1.7 +++ fold.c 2002/03/24 02:31:03 @@ -52,13 +52,18 @@ #include #include #include +#include #include #define DEFLINEWIDTH 80 void fold(int); +static int new_column_position(int, int); static void usage(void); +int count_bytes = 0; +int split_words = 0; + int main(argc, argv) int argc; @@ -69,8 +74,14 @@ char *p; width = -1; - while ((ch = getopt(argc, argv, "0123456789w:")) != -1) + while ((ch = getopt(argc, argv, "0123456789bsw:")) != -1) switch (ch) { + case 'b': + count_bytes = 1; + break; + case 's': + split_words = 1; + break; case 'w': if ((width = atoi(optarg)) <= 0) { errx(1, "illegal width value"); @@ -107,57 +118,110 @@ static void usage() { - (void)fprintf(stderr, "usage: fold [-w width] [file ...]\n"); + (void)fprintf(stderr, "usage: fold [-bs] [-w width] [file ...]\n"); exit(1); } +/* + * Fold the contents of standard input to fit within WIDTH columns + * (or bytes) and write to standard output. + * + * If split_words is set, split the line at the last space character + * on the line. This flag necessitates storing the line in a buffer + * until the current column > width, or a newline or EOF is read. + * + * The buffer can grow larger than WIDTH due to backspaces and carriage + * returns embedded in the input stream. + */ void fold(width) register int width; { - register int ch, col, new; - - for (col = 0;;) { - switch (ch = getchar()) { - case EOF: - return; - case '\b': - new = col ? col - 1 : 0; - break; - case '\n': - case '\r': - new = 0; - break; - case '\t': - new = (col + 8) & ~7; - break; - default: - new = col + 1; - break; + static char *buf = NULL; + static int buf_max = 0; + register int ch, col; + int indx; + + col = indx = 0; + while ((ch = getchar()) != EOF) { + if (ch == '\n') { + if (indx != 0) + fwrite(buf, 1, indx, stdout); + putchar('\n'); + col = indx = 0; + continue; } - if (new > width) { + col = new_column_position(col, ch); + if (col > width) { + int i, last_space; + + if (split_words) + for (i = 0, last_space = -1; i < indx; i++) + if (buf[i] == ' ') + last_space = i; + + if (split_words && last_space != -1) { + last_space++; + + fwrite(buf, 1, last_space, stdout); + memmove(buf, buf+last_space, indx-last_space); + + indx -= last_space; + col = 0; + for (i = 0; i < indx; i++) + col = new_column_position(col, buf[i]); + } else { + fwrite (buf, 1, indx, stdout); + col = indx = 0; + } putchar('\n'); - col = 0; + + /* calculate the column position for the next line. */ + col = new_column_position(col, ch); } - putchar(ch); + if (indx + 1 > buf_max) { + /* Allocate buffer in LINE_MAX increments */ + buf_max += 2048; + if((buf = realloc(buf, buf_max)) == NULL) { + err(1, "realloc"); + /* NOTREACHED */ + } + } + buf[indx++] = ch; + } + + if (indx != 0) + fwrite(buf, 1, indx, stdout); +} + +/* + * calculate the column position + */ +static int +new_column_position (col, ch) + int col, ch; +{ + + if (!count_bytes) { switch (ch) { case '\b': if (col > 0) --col; break; - case '\n': case '\r': col = 0; break; case '\t': - col += 8; - col &= ~7; + col = (col + 8) & ~7; break; default: ++col; break; } - } + } else + ++col; + + return col; } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message