Re: fsck segfaults on rpi3 running 13-stable (and on 14-CURRENT analyzing the same file system that resulted from the 13-STABLE crash)

From: Mark Millard <marklmi_at_yahoo.com>
Date: Wed, 15 Feb 2023 19:39:13 UTC
On Feb 15, 2023, at 11:08, bob prohaska <fbsd@www.zefox.net> wrote:

> On Wed, Feb 15, 2023 at 09:40:51AM -0800, Mark Millard wrote:
>> 
>> Looking in my /usr/main-src/sbin/fsck_ffs/inode.c
>> I see that the original file has a leading tab
>> instead of spaces.
>> 
>> The following mostly ignores the 1st column that
>> should have a space, -, or + in the diff output for
>> the file-content lines. It is mostly about the text
>> after the first column.
>> 
>> So, if you have spaces instead after the first column
>> for the lines that start with a space, those lines
>> will not match, leading to a rejection for the
>> context matching done by patch.
> 
> Replacing spaces with tabs allowed patch to find the 
> location, but it still fails with 
> patch: **** malformed patch at line 5: printf("SIZE=%ju ", (uintmax_t)DIP(dp, di_size));

My guess is that when you made the adjustment to have
the tabs, the leading space was also removed on this
line. The first column is not part of the original
text but is instead a directive to the tool. The
missing space would be that directive and it needs to
be there. So:

<space><tab>printf("SIZE=%ju ", (uintmax_t)DIP(dp, di_size));

The space indicates to use the reset of the line just
for context identification.

Of course, since I've no access the file to check my
hypothesis, it is just a guess.

> Editing by hand looks like a good way to drive myself crazy 8-)
> 
> I take it the goal is to find the lines
>        printf("SIZE=%ju ", (uintmax_t)DIP(dp, di_size));
>        t = DIP(dp, di_mtime);
>        p = ctime(&t);
> delete the line 
> printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);

Yes. (I ignored whitespace details here: not preserved
in the E-mail result as I see it.)

> and add the four lines
> if (p == NULL)
>               printf("MTIME=invalid ");
>       else
>       printf("MTIME=%12.12s %4.4s ", &p[4], &p[20]);       

Yes. (I ignored whitespace details here too.)

> Do I at least correctly understand the intent of the patch?
> 

Yes.


===
Mark Millard
marklmi at yahoo.com