info-mtools
[Top][All Lists]
Advanced

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

Re: [Info-mtools] Inconsistent results between kernel vfat and mtools; u


From: Alexander Huemer
Subject: Re: [Info-mtools] Inconsistent results between kernel vfat and mtools; user error indeed
Date: Tue, 21 Nov 2023 20:36:50 +0100

On Tue, Nov 21, 2023 at 11:41:19PM +0700, Nutchanon Wetchasit wrote:
> On Tue, 21 Nov 2023, Alexander Huemer wrote:
> 
> > mcopy -a ~/image.img -a :: .
> [...]
> > Does the image file have some unusual properties that push mtools to 
> > undesired behavior?
> 
> Not "unusual" property at all, because:
> 
> > User error?
> 
> First, I suspect you are having at least some typos in the question,
> for example: it shouldn't be `-a image.img` [1] but rather `-i ~/image.img`.
> 
> In any case, if you are really using `-a` switch with `mcopy`, then yes,
> it is user error: because *you* are instructing it to attempt
> translating CR-LF sequences into LF when copying the files;
> which usually ruin the data in case of binary files.
> 
> This is an excerpt from Mtools manual, section "4.8 Mcopy" [2]:
> 
> > `a'
> >      Text (ASCII) file transfer.  `ASCII' translates incoming carriage
> >      return/line feeds to line feeds.
> 
> Of course, when you are mounting the same image using kernel Linux's
> VFAT driver, it would be correct because it does none of such
> file content translation by default. (And for what it's worth,
> `mcopy` doesn't do such thing by default as well)
> 
> A reason you should NOT use `-a` switch with `mcopy` is more or less
> the same reason you are NOT supposed use `conv=text` VFAT mount option [3]
> which `man mount` already warned you about.
> 
> The minimally-correct `mcopy` command line for your use would rather be:
> 
> > $ mcopy -i ~/image.img -s :: .
> 
> (`-s` is for recursive copying)
> 
> You are free to add `-m` and/or `-p` switch to the command line
> if you like of course too; which would not affect the resulting
> files content's correctness. (They just improve metadata correctness)
> 
> And this is a demonstration of the minimally-correct invocation
> using your example disk image (note that my temporary mount point path
> at `/mnt/tmp` is a bit unconventional):
> 
> > # cd /tmp
> > # ln -s IBM_3174_DSL_FC9021_N52.0.img image.img
> > # mkdir /tmp/unpack
> > # cd /tmp/unpack
> > # /opt/mtools/bin/mcopy -i ../image.img -s :: .
> > # mount -t vfat -o ro,loop /tmp/image.img /mnt/tmp
> > # diff -u <(md5sum -b *) <(cd /mnt/tmp && md5sum -b *)
> > # echo $?
> > 0
> > # 
> 
> You would see here that there is no difference whatsoever
> in the files' content.

Perfect!
Thanks much. Case closed.

-Alex



reply via email to

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