From owner-p4-projects@FreeBSD.ORG Tue Apr 13 05:49:54 2010 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 88E081065674; Tue, 13 Apr 2010 05:49:54 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4CC24106564A; Tue, 13 Apr 2010 05:49:54 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-yw0-f193.google.com (mail-yw0-f193.google.com [209.85.211.193]) by mx1.freebsd.org (Postfix) with ESMTP id E4A3E8FC0C; Tue, 13 Apr 2010 05:49:53 +0000 (UTC) Received: by ywh31 with SMTP id 31so1801261ywh.3 for ; Mon, 12 Apr 2010 22:49:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:received:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=hTAQ2+x9bm3eMM3kFIuPC+rOCXmCp5s1DGsvTBKasBM=; b=aL2R7L+q9Go7V0Y6UubmfRfRDHXDEmsby5JoSNuRZoKRfTzhxcj/3qYayAfYjJ0EKU O4SQL+qwIEz+EkaUmm97oV/2SHe/pdZd/YOEmocqAsx2wYi5uJg3q0cpsZ6T+v7DS3Bx TpDPDL0PQvwdxbe6WxKMVrTKPSox5XmDOjqK8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=WTwP1cR1mZvv/Z/p8zIG82za0A2Adczb9D27MojyeHZ4+5Tq7z8CknxRnFcq9cRcw2 VIAs9yp/Wy3EiTf8G4m93oMnFU3c2TxBoaGK8MkkrMarmCM+6ktaLf6Hrs+Rolaicbmr CwLVR4FSd/VOweXHWuMQB8ivMqIAUezauUPv8= MIME-Version: 1.0 Sender: yanegomi@gmail.com Received: by 10.231.183.17 with HTTP; Mon, 12 Apr 2010 22:49:52 -0700 (PDT) In-Reply-To: <4BC3EB5B.5070801@freebsd.org> References: <201004121230.o3CCUsIX029146@repoman.freebsd.org> <4BC3EB5B.5070801@freebsd.org> Date: Mon, 12 Apr 2010 22:49:52 -0700 X-Google-Sender-Auth: 12f8679d5ba78e1c Received: by 10.101.152.22 with SMTP id e22mr8944675ano.89.1271137792805; Mon, 12 Apr 2010 22:49:52 -0700 (PDT) Message-ID: From: Garrett Cooper To: Tim Kientzle Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Perforce Change Reviews Subject: Re: PERFORCE change 176831 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Apr 2010 05:49:55 -0000 On Mon, Apr 12, 2010 at 8:56 PM, Tim Kientzle wrote: > Garrett Cooper wrote: >> >> +FILE* >> +unpack_file_to_fd(const char *pkg, const char *file) >> +{ > > .... >> >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 r =3D arch= ive_read_extract(archive, >> archive_entry, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 EX= TRACT_ARCHIVE_FLAGS); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (r =3D= =3D ARCHIVE_OK) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 if (Verbose) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 printf("X - %s\n", >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 entry_pathname); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 fd =3D fopen(entry_pathname, "r"); > > This is potentially race-prone. =A0I would suggest instead that > you: > > =A0 int fd =3D open(entry_pathname, O_RDWR | O_CREAT, ...) > =A0 archive_read_data_into_fd(a, fd); > > Then rewind the fd and return it. =A0archive_read_extract() > is handy but it's way overkill for this kind of simple > operation. =A0I would also put in a simple verification > that the entry you found is a regular entry: > =A0 archive_entry_filetype(entry) =3D=3D AE_IFREG Ok. What does a regular entry correspond to (I assume not a regular file)? >> + * NOTE: the exit code is 0 / 1 so that this can be fed directly into >> exit >> + * when doing piped tar commands for copying hierarchies *hint*, *hint*=