From owner-cvs-all Tue Sep 25 11:19:43 2001 Delivered-To: cvs-all@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id AFE9337B409; Tue, 25 Sep 2001 11:16:43 -0700 (PDT) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.2/8.11.2) id f8PIGe164016; Tue, 25 Sep 2001 21:16:40 +0300 (EEST) (envelope-from ru) Date: Tue, 25 Sep 2001 21:16:39 +0300 From: Ruslan Ermilov To: Matt Dillon Cc: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/bin/cat cat.1 cat.c Message-ID: <20010925211639.C57333@sunbay.com> References: <200109150039.f8F0dFZ41705@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200109150039.f8F0dFZ41705@freefall.freebsd.org>; from dillon@FreeBSD.org on Fri, Sep 14, 2001 at 05:39:14PM -0700 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG How about testing with stat(2) that an argument is a socket thus eliminating the need to open(2) sockets and connect(2) to non-sockets? Index: cat.c =================================================================== RCS file: /home/ncvs/src/bin/cat/cat.c,v retrieving revision 1.17 diff -u -p -r1.17 cat.c --- cat.c 2001/09/15 00:39:14 1.17 +++ cat.c 2001/09/25 18:17:30 @@ -135,6 +135,9 @@ scanfiles(argv, cooked) { int i = 0; char *path; +#ifndef NO_UDOM_SUPPORT + struct stat sb; +#endif while ((path = argv[i]) != NULL || i == 0) { int fd; @@ -144,10 +147,15 @@ scanfiles(argv, cooked) fd = 0; } else { filename = path; - fd = open(path, O_RDONLY); +#ifndef NO_UDOM_SUPPORT + if ((fd = stat(path, &sb)) == 0) { + if (S_ISSOCK(sb.st_mode)) + fd = udom_open(path, O_RDONLY, 0); + else +#endif + fd = open(path, O_RDONLY); #ifndef NO_UDOM_SUPPORT - if (fd < 0 && errno == EOPNOTSUPP) - fd = udom_open(path, O_RDONLY, 0); + } #endif } if (fd < 0) { On Fri, Sep 14, 2001 at 05:39:14PM -0700, Matt Dillon wrote: > dillon 2001/09/14 17:39:14 PDT > > Modified files: > bin/cat cat.1 cat.c > Log: > Give /bin/cat the ability to connect to and read unix-domain sockets > > MFC after: 1 week > > Revision Changes Path > 1.18 +7 -2 src/bin/cat/cat.1 > 1.17 +103 -56 src/bin/cat/cat.c -- Ruslan Ermilov Oracle Developer/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 cvs-all" in the body of the message