From: Lubomir Rintel on
On Mon, 2010-07-19 at 16:58 +0200, Christoph Hellwig wrote:
> On Mon, Jul 19, 2010 at 07:16:42PM +0200, Lubomir Rintel wrote:
> > A mount-time option was added that makes it possible to override the
> > endianness and an attempt is made to autodetect it (which seems easy,
> > given the disk addresses are 3-byte.
> >
> > No attempt is made to detect big-endian filesystems -- were there any?
> > Tested with PDP-11 v7 filesystems and PC-IX maintenance floppy.
>
> Do you actually need the mount option? We get away just fine with
> it for sysv filesystems. And if not I'd be consistent and accept the
> options for both sysv and v7 filesystems.

Well, there's no reliable way to detect endiannes of a v7 filesystem
unless we do a deep check as fsck would do (there are cases where we can
be sure that a filesystem is not of a certain bytesex, which is what the
current sanity check does and what's abused for the lousy
autodetection).

In super.c it looks like xenix and sysv use a magic number which the
byte order can be determined from, thus the option would be useless
there.

Coherent seems to always use PDP-11 bytesex. I can not check at the
time, but I'm almost sure it never run on such machines (was PC and 68k
only?), so I suspect the coherent kernel might have always done the
translation to native byte order. I think I have some coherent (for PC)
floppies at home, so I can check tomorrow.

> > + /* plausibility check on root inode: it is a directory,
> > + with a nonzero size that is a multiple of 16 */
> > + if ((bh2 = sb_bread(sb, 2)) == NULL) {
> > + return 0;
> > + }
>
> A little style nitpick, this should be:
>
> bh2 = sb_bread(sb, 2);
> if (!bh)
> return 0;
>

I actually did not write this myself, but merely moved from
v7_fill_super(). It would probably a good idea to keep it as it is (not
to obfuscate the changes) and fix it up in a separate commit if is
worth.

Take care,
Lubo

--
Flash is the Web2.0 version of blink and animated gifs.
-- Stephen Smoogen

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Lubomir Rintel on
On Tue, 2010-07-20 at 12:41 +0200, Lubomir Rintel wrote:
> On Mon, 2010-07-19 at 16:58 +0200, Christoph Hellwig wrote:
....
> > Do you actually need the mount option? We get away just fine with
> > it for sysv filesystems. And if not I'd be consistent and accept the
> > options for both sysv and v7 filesystems.
....
> Coherent seems to always use PDP-11 bytesex. I can not check at the
> time, but I'm almost sure it never run on such machines (was PC and 68k
> only?), so I suspect the coherent kernel might have always done the
> translation to native byte order. I think I have some coherent (for PC)
> floppies at home, so I can check tomorrow.

This was just partly correct. Coherent indeed run on PDP-11 (and not on
68k), but the PC version uses the very same bytesex as PDP-11 one,
translating the byte order on the fly (_canl() routine defined in
i386/as.inc file of Coherent 4.2.10 for i386 kernel is used).

Thus the mount option is really only useful with v7 filesystem and none
of those handled with sysv filesystem.

--
Flash is the Web2.0 version of blink and animated gifs.
-- Stephen Smoogen

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Al Viro on
On Mon, Jul 19, 2010 at 04:58:51PM +0200, Christoph Hellwig wrote:
> On Mon, Jul 19, 2010 at 07:16:42PM +0200, Lubomir Rintel wrote:
> > A mount-time option was added that makes it possible to override the
> > endianness and an attempt is made to autodetect it (which seems easy,
> > given the disk addresses are 3-byte.
> >
> > No attempt is made to detect big-endian filesystems -- were there any?
> > Tested with PDP-11 v7 filesystems and PC-IX maintenance floppy.
>
> Do you actually need the mount option? We get away just fine with
> it for sysv filesystems. And if not I'd be consistent and accept the
> options for both sysv and v7 filesystems.

Actually, it shouldn't be too hard to detect the damn thing even without magic.
Look - we always have the inode table starting at block 2, so on-disk root
inode is guaranteed to be found correctly. Now, suppose we'd mistaken
l-e for pdp or vice versa; the half-words of i_size would get swapped.
What could pass both tests? Suppose the right size is a * 65536 + b;
then we have: a and b are both multiples of 16 and at least one is non-zero.
So all we need is to reject root directories bigger than 1Mb. And posted
patches do reject that (and lower than that, actually).

So I'd rather see a variant without that option. Simply get both bh, then
try the same sanity checks with LE and PDP used for s_bytesex. And use
one that works - we _know_ that it's impossible to have both pass at the
same time.

I'm fine with the rest of patch series as is; Lubomir, could you redo the
last one that way and resend?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/