From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 13 13:54:18 2007 Return-Path: X-Original-To: hackers@freebsd.org Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B66B516A46D for ; Wed, 13 Jun 2007 13:54:18 +0000 (UTC) (envelope-from mwm-keyword-freebsdhackers2.e313df@mired.org) Received: from mired.org (vpn.mired.org [66.92.153.74]) by mx1.freebsd.org (Postfix) with SMTP id 5E8DE13C469 for ; Wed, 13 Jun 2007 13:54:18 +0000 (UTC) (envelope-from mwm-keyword-freebsdhackers2.e313df@mired.org) Received: (qmail 13183 invoked by uid 1001); 13 Jun 2007 13:52:14 -0000 Received: by bhuda.mired.org (tmda-sendmail, from uid 1001); Wed, 13 Jun 2007 09:52:13 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <18031.63117.423936.99266@bhuda.mired.org> Date: Wed, 13 Jun 2007 09:52:13 -0400 To: Garrett Cooper In-Reply-To: <466F9020.9050306@u.washington.edu> References: <466F86C6.7010006@u.washington.edu> <20070613083046.atl5dyq3s488s0o8@webmail.leidinger.net> <466F9020.9050306@u.washington.edu> X-Mailer: VM 7.19 under Emacs 21.3.1 X-Primary-Address: mwm@mired.org X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`; h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ X-Delivery-Agent: TMDA/1.1.11 (Ladyburn) From: Mike Meyer Cc: Alexander Leidinger , hackers@freebsd.org Subject: Re: Using shell commands versus C equivalents X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2007 13:54:18 -0000 In <466F9020.9050306@u.washington.edu>, Garrett Cooper typed: > Alexander Leidinger wrote: > > Quoting Garrett Cooper (from Tue, 12 Jun > > 2007 22:55:18 -0700): > > > >> Another simple question (I hope): > >> Is there any reason why shell commands should be used in place of a > >> C command (in this case chmod via vsystem instead of the chmod(2) > >> function)? It seems like the fork / exec would be more expensive with > >> the shell command, but any area where code could be optimized is more > >> than welcome I would think. > > > > If it is just one file, I don't see the reason to use the shell > > command, but if you need to reinvent "chmod -R", I don't see a reason > > to forbid the use of the shell command (pragmatic programming). > > > > Bye, > > Alexander. > > > Exactly my thinking (ch{own,mod} for one file, not reinventing the > -R 'wheel'). After looking over style(7) I don't see anything about not > doing that. While I agree in principal - if chmod already implements some hard-to-implement functionality, then using it only makes sense - I don't think -R qualifies. It's implemented via the fts library, which makes recursing through a directory tree about as difficult as scanning a directory. In fact, fts has features that dir* doesn't, so there are instances where fts is preferable to the dir* routines for scanning a directory. http://www.mired.org/consulting.html Independent Network/Unix/Perforce consultant, email for more information.