[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: an ext2 partition saw like a swap partition

From: Andrew Clausen
Subject: Re: an ext2 partition saw like a swap partition
Date: Mon, 01 Jan 2001 16:10:42 -0200

Olivier Gondouin wrote:
> Andrew Clausen wrote:
> >
> > What might have happened is the format program (mkfs) or whatever
> > didn't overwrite the swap signature.  However, in this case, there
> > should be both linux-swap and ext2 signatures.
> Aaargh!!
> > So, Parted has found that it was unambiguously linux-swap.  So,
> > either you have a really broken ext2 file system, or Parted is
> > broken - I suspect the later :/
> >
> > Could you send me the first 100k of the partition?
> >
> >         # dd if=/dev/sda6 bs=100k count=1 | gzip > ext2-broken-probe.gz
> see attachement


OK, I understand the problem now:

(1) Linux-swap requires very little to be valid.  Hence, if it is
detected, it will always be "open-able".

(2) The ext2 file system wasn't cleanly unmounted.  When libparted
attempts to open it from within probe, it silently fails rather
than attempting to resolve the error.  (This behaviour is "right",
because probe can throw exceptions saying why it didn't probe a
file system... but usually we're not interested)

I can't think of any good ways out of this problem.  (Any ideas?)
The fundamental flaw is that we're using open() as a heuristic
for probe()... perhaps probe() should return a confidence value?


So, probe would accept an extra argument, saying what the maximum
level of detection it is looking for is.  (Doing a thorough
probe may require lots of work, which we don't want to do, when
we're just printing out a partition table... unless there is
some ambiguouity)

So, ped_file_system_probe() would become something like:

        int                     ambiguous;
        PedFileSystemType*      fs_type;
        PedFileSystemConfidence conf;

        for (conf=1; conf < 3; conf++) {
                ambiguous = 0;
                fs_type = NULL;
                for (fs-types) {
                        if (!probe-works)
                        if (fs_type) {
                                amibiuous = 1;
                        } else {
                                fs_type = this-fs;
                if (!ambiguous)
                        return fs_type;
        return NULL;

To work around, you can destroy the linux-swap signature.  This
can be done with a hex editor, or with:

        # dd if=/dev/zero of=/dev/sda6 bs=1k count=1

(The first 1k is never used by ext2, but is used by the old
linux-swap format)

Andrew Clausen

reply via email to

[Prev in Thread] Current Thread [Next in Thread]