From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Truncating Direct IO files Date: Tue, 21 Apr 2015 09:47:24 +0200 Organization: cbb software GmbH Message-ID: <1tufk7ruhyejt.1tyb01i9kotm1.dlg@40tude.net> References: <8323246f-eb13-49e8-9e0c-5c5ec1002060@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: enOx0b+nfqkc2k+TNpOejg.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:25562 Date: 2015-04-21T09:47:24+02:00 List-Id: On Tue, 21 Apr 2015 00:30:37 -0700 (PDT), tonyg wrote: > I am recording records to disk. Sometimes I replace thes records with a > smaller set of records. Do you rewrite all file then? In that case you could simply work with a copy and delete the original, in a sort of double-buffering manner. > I could delete the file each time but would prefer to truncate the file. I > can't see a way of doing this, can you? There seems no way doing that without OS. In my implementation of a persistent storage pool I simply maintain the list of free elements and reuse them later. BTW, I don't overwrite any file elements within single transaction. I don't know what you are doing, but consider a scenario when the application or the whole system crashes in the middle of file updating. Would that corrupt the data? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de