From patchwork Sat Mar 12 19:04:58 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Fritz X-Patchwork-Id: 11805 Received: from mout0.freenet.de ([194.97.50.131]) by www.linuxtv.org with esmtp (Exim 4.34) id 1DABwi-0007xb-3g for vdr@linuxtv.org; Sat, 12 Mar 2005 20:06:44 +0100 Received: from [194.97.55.192] (helo=mx8.freenet.de) by mout0.freenet.de with esmtpa (Exim 4.51) id 1DABwJ-0002Fv-KC for vdr@linuxtv.org; Sat, 12 Mar 2005 20:06:19 +0100 Received: from pd95732eb.dip0.t-ipconnect.de ([217.87.50.235] helo=gurke.wofritz.de) by mx8.freenet.de with esmtpa (ID wofritz@freenet.de) (Exim 4.43 #13) id 1DABwJ-0007sP-Af for vdr@linuxtv.org; Sat, 12 Mar 2005 20:06:19 +0100 Received: from localhost (localhost [127.0.0.1]) by gurke.wofritz.de (Postfix) with ESMTP id 5EC3E27394 for ; Sat, 12 Mar 2005 20:06:19 +0100 (CET) Received: by gurke.wofritz.de (Postfix, from userid 500) id BD89629264; Sat, 12 Mar 2005 20:05:19 +0100 (CET) To: vdr@linuxtv.org X-Original-To: moderator@gurke.wofritz.de Delivered-To: moderator@gurke.wofritz.de by gurke.wofritz.de (Postfix) with ESMTP id 52F6F27394 for ; Sat, 12 Mar 2005 20:05:19 +0100 (CET) id 1A59E29264; Sat, 12 Mar 2005 20:04:48 +0100 (CET) From: Wolfgang Fritz Date: Sat, 12 Mar 2005 20:04:58 +0100 Organization: None Lines: 55 Message-ID: NNTP-Posting-Host: eddie.wofritz.de Mime-Version: 1.0 User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en X-AntiVirus: checked by AntiVir MailGate (version: 2.0.2-8; AVE: 6.30.0.5; VDF: 6.30.0.26; host: gurke) Subject: [vdr] [PATCH] vdr-1.3.22: do not create zero-sized vdr.nnn files X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Wolfgang Fritz , Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Mar 2005 19:06:44 -0000 Status: O X-Status: X-Keywords: X-UID: 659 The following patch avoids the creation of zero sized vdr.nnn files if a recording is disturbed (loss of signal etc.). Without this patch it is possible to fill up a recording directory with 0-sized files up to the maximum vdr.255 quite fast. Testers and feedback welcome. Wolfgang Index: recording.c =================================================================== --- recording.c (Revision 231) +++ recording.c (Arbeitskopie) @@ -1124,8 +1124,25 @@ fileNumber = Number; sprintf(pFileNumber, RECORDFILESUFFIX, fileNumber); if (record) { - if (access(fileName, F_OK) == 0) // file exists, let's try next suffix - return SetOffset(Number + 1); + if (access(fileName, F_OK) == 0) { + // files exists, check if it has non-zero size + struct stat buf; + if (stat(fileName, &buf) == 0) { + if (buf.st_size != 0) { + // file exists and has non zero size, let's try next suffix + return SetOffset(Number + 1); + } + else { + // Zero size file. Remove it. + dsyslog ("cFileName::SetOffset: Removing zero-sized file %s\n", fileName); + unlink (fileName); + } + } + else { + // error with fstat. Should not happen, just to be on the safe side + return SetOffset(Number + 1); + } + } else if (errno != ENOENT) { // something serious has happened LOG_ERROR_STR(fileName); return -1;