🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #85793

Re: INN2 - 32bit - Wheezy

#85793
From: Julien ÉLIE
Date: Sat, 27 Jul 2013 14:28
109 lines
5585 bytes
Hi Russ,

> 1. Write the piece of code that no one has had a chance to write yet to
>     convert a CAF file from 32-bit to 64-bit.
> 
> The problem is that INN uses binary off_t and similar data types directly
> in the on-disk structures without any ability to detect incorrect sizes or
> convert from old formats.  (This is, obviously, a bug, but it's a bug in
> the on-disk data format and therefore rather difficult to fix.)

I am still puzzled about what should be done.

Let's consider the CAF file named <patharticles>/timecaf-02/0c/5129.CF
on my 32-bit system without LFS support.

Its header is:

00000000  43 52 4d 54 01 00 00 00  00 00 04 00 03 00 00 00  |CRMT............|
00000010  00 00 00 00 00 c2 4c 00  00 02 00 00 cc c1 1c 00  |......L.........|
00000020  cc 01 00 00 0c 08 7d b7  00 00 00 00 00 00 00 00  |......}.........|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

corresponding to:

typedef struct _CAFHEADER {
    char         Magic[4];          /* Magic Number "CRMT" */
    ARTNUM       Low;               /* lowest article in the file */
    ARTNUM       NumSlots;          /* number of articles there are room for in the TOC */
    ARTNUM       High;              /* last article actually present in the file */
    size_t       Free;              /* amount of space currently unused (freed by cancels/expires) */
    off_t        StartDataBlock;    /* offset of first article data block. */
    unsigned int BlockSize;         /* unit of allocation for CAF files. */
    size_t       FreeZoneTabSize;   /* amount of space taken up by the free zone table. */
    size_t       FreeZoneIndexSize; /* size taken up by the "index" part of the free zone table. */
    time_t       LastCleaned;       /* note time of last cleaning. */
    int          spare[3];
} CAFHEADER;

that is to say:

Magic[4] - 43 52 4d 54
Low - 01 00 00 00 (=1)
NumSlots - 00 00 04 00 (=262144)
High - 03 00 00 00 (=3)
Free - 00 00 00 00 (=0)
StartDataBlock - 00 c2 4c 00 (=5030400)
BlockSize - 00 02 00 00 (=512)
FreeZoneTabSize - cc c1 1c 00 (=1884620)
FreeZoneIndexSize - cc 01 00 00 (=460)
LastCleaned - 0c 08 7d b7 (seems broken:  =3078424588, which is Tue Jan 19 04:14:07 2038)
spare[3] - 00 00 00 00 00 00 00 00 00 00 00 00

then we have the table of free blocks.  (We'll see it later.)


Then we have TOC entries:

001cc200  00 00 00 00 00 00 00 00  00 00 00 00 00 c4 4c 00  |..............L.|
001cc210  2c 08 00 00 2a 29 0c 51  00 ce 4c 00 0a 0a 00 00  |,...*).Q..L.....|
001cc220  6c 29 0c 51 00 00 00 00  00 00 00 00 00 00 00 00  |l).Q............|
001cc230  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

corresponding to:

typedef struct _CAFTOCENT {
    off_t  Offset;
    size_t Size;
    time_t ModTime;
} CAFTOCENT;

that is to say we have here two articles.  The first one is:

Offset - 00 c4 4c 00
Size - 2c 08 00 00 (=2092)
ModTime - 2a 29 0c 51 (Fri Feb  1 21:44:26 2013)

and we properly see it at this offset:

004cc400  58 2d 52 65 63 65 69 76  65 64 3a 20 62 79 20 31  |X-Received: by 1|
[...]




We can check that:
  sizeof(CAFHEADER) + FreeZoneTabSize + NumSlots*sizeof(CAFTOCENT) = StartDataBlock
  52 + 1884620 + 262144*12 = 5030400

  sizeof(CAFHEADER) + FreeZoneTabSize => start of TOC entries (offset 001cc200)





My questions are related to how the CAF file is supposed to be converted for LFS.
- should ARTNUM (unsigned long) be written on 8 bytes?
- should size_t be written on 8 bytes?
- should off_t be written on 8 bytes?
- should int and be written on 8 bytes?
- should time_t be written on 8 bytes?
- my example above is from a 32-bit system where an off_t is 4 byte-long; maybe it is already 8 byte-long on other systems; in that case, should something be done for them with regards to LFS?
- should something else than a mere conversion of the CAF file be done?  (change in the source code?)

-- 
Julien ÉLIE

« – Je t'ai préparé une bonne soupe dont tu me diras des
    nouvelles, mon garçon !
  – Pour moi, ça, ce n'est pas des bonnes nouvelles ! » (Astérix)
Technical Details
Message-ID: <kt0lf9$psp$1@news.trigofacile.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams3.giganews.com!border2.nntp.ams3.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!rt.uk.eu.org!weretis.net!feeder4.news.weretis.net!news.trigofacile.com!.POSTED.aaubervilliers-652-1-82-26.w83-114.abo.wanadoo.fr!not-for-mail
References: <ko7pdg$ccs$1@matrix.darkstorm.co.uk> <877gig1i2k.fsf@windlord.stanford.edu>

Show Full Headers
Complete Article Headers
Message-ID: <kt0lf9$psp$1@news.trigofacile.com>
Subject: Re: INN2 - 32bit - Wheezy
Date: Sat, 27 Jul 2013 16:28:57 +0200
From: Julien ÉLIE <iulius@nom-de-mon-site.com.invalid>
References: <ko7pdg$ccs$1@matrix.darkstorm.co.uk> <877gig1i2k.fsf@windlord.stanford.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20141118.mbox.gz!border1.nntp.ams3.giganews.com!border2.nntp.ams3.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!rt.uk.eu.org!weretis.net!feeder4.news.weretis.net!news.trigofacile.com!.POSTED.aaubervilliers-652-1-82-26.w83-114.abo.wanadoo.fr!not-for-mail
Newsgroups: news.software.nntp
Organization: TrigoFACILE -- http://www.trigofacile.com/
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 27 Jul 2013 14:28:57 +0000 (UTC)
Injection-Info: news.trigofacile.com;
 posting-host="aaubervilliers-652-1-82-26.w83-114.abo.wanadoo.fr:83.114.57.26";
 logging-data="26521"; mail-complaints-to="abuse@trigofacile.com"
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8;
In-Reply-To: <877gig1i2k.fsf@windlord.stanford.edu>
Lines: 108
X-Original-Bytes: 5406