Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Bug in backup/restore dsl2.0< Next Oldest | Next Newest >
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Dec. 10 2005,09:22 QUOTE

Line 104 in dsl-2.0's filetool.sh needs inverted commas in the -f test, or restore can fail leading to an invalid device message ie:

Code Sample
if [ ! -f "$MOUNTPOINT/$TARGETFILE" ]; then
    if [ $MOUNTED == "no" ]; then
     sudo umount $MOUNTPOINT
    fi
 fi


Someone else might have already found this, I haven't checked.
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Dec. 10 2005,11:04 QUOTE

Also:  

1. For some reason it's possible in dsl-2.0 for /etc/mtab to contain
multiple duplicate entries eg the same line twice, perhaps after attempting to mount twice.

In which case get_mountpoint in /etc/init.d/dsl-functions returns the mountpoint twice, which makes backup very FUBAR.

I replaced the call to get_mountpoint in filetool.sh with:

Code Sample

MOUNTPOINT="$(grep "^/dev/$DEVICE" /etc/mtab|awk '{print $2}'| head -n 1)"

ensuring there's only one word in MOUNTPOINT.

Or could do all in awk:
Code Sample

MOUNTPOINT="$(awk '{$1 == "^/dev/$ENVIRON["DEVICE"]"} END {if (++cnt==1){print $2}} ' /etc/mtab)"


EDIT: /proc/mounts does not contain multiple entries, so could grep that instead.

Obviously this is a bigger problem if get_mountpoint is also called by something else in dsl-2.0, or if multiple entries in /etc/mtab interferes with other stuff.

If this function is called by my-dsl scripts then it might explain a *serious* problem I had recently with those.

2. I don't know if the bash version has changed, but dsl-2.0 complains about the syntax ~ lines 38 and 53 of filetool.sh - I suggest change:

Code Sample
if [ $MOUNTED == "no" ]; then


to

Code Sample
if [ "$MOUNTED" = no ]; then


and similarly elsewhere.
Back to top
Profile PM 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: Dec. 10 2005,23:53 QUOTE

First off, I have to smile when I see such a dramatic title.
The backup/restore has been in place for a very long time and it used everyday by many. That is not to say it is perfect.
But lets proceed with the analysis.

The mount point functions were contributed by a forum member to DSL in 9/12/04 which would make this in place since v0.8.2. These functions replaced inline code that I wrote dating back to dsl v0.5

Again, leading to the fact this is a rather subtle error and not one to be so alarmed about. And in fact is not a bug specific to dsl v2.0.

Multiple mounting. This is possible and in fact allowed with no use of any DSL code. It is perfectly permissible to mount the same device to multiple mount points. This can easily be achieved using the mount command. Why one would do this, especially for the chosen backup device is beyond me, but more on that later. Again this has nothing to do with DSL code or any version of DSL.

But in fact if one does  do this very thing, then, yes, the backup will fail with a broken pipe message. Why, because the find_mountpoint() which is called by the get_mountpoint() which is called from filetool.sh will return the multiple mount points caused only if such multiple mounting was done. Normally this would not occur.

Applying the head -n 1 to the find_mount() MOUNTPOINT variable will indeed as WDef suggests will correct this and return only one. Afterall, it is the device that this code is after.

Inlining the code and not calling functions is dangerous in the world of bash code. Global variables which may be set in functions might then not be set from excluding such function calls. I would rather see a more generic description of the problem that a recommendation to bypass existing functions.

I suspect the percipitation of this subtle bug is because of the popularity of the frugal installs. For example a typical frugal install will be at hda2 and /dev/hda2 is mounted on /cdrom. Because it is frugal /cdrom is indeed writeable by user root. But most users would think that it would not be possible to write to /cdrom. Then with that convenient mount.app gui sitting there, allowing easy access to mount hda2 (/dev/hda2 on /mnt/hda2). Thereby we now have the dreaded multiple mount. This multiple mount will show up in both /etc/mtab and /proc/mounts.

Anyway, an interesting post to squash a subtle bug.
I have corrected this in the next cut to be available soon.

It is not a crisis, just beware of multiple mounts especially while using a frugal install.

Thanks WDef for bring this to my attention.
Back to top
Profile PM WEB 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Dec. 14 2005,15:37 QUOTE

Thanks Robert for working this through.  Quite right it's not just dsl-2.0 - got the same thing on dsl-1.5 not long after posting ie undesired multiple mounts and resulting fubarred backup.

Quite right also about bypassing your functions - I can see it reads that way but I only intended to document what I did to show that it was the problem - I assumed you'd want to edit the function of course!

While I know linux allows multiple mounts, I'm unable (normally) to multiple-mount - just get

Code Sample
mount: /dev/hdb11 already mounted or /mnt/hdb11 busy
mount: according to mtab, /dev/hdb11 is already mounted on /mnt/hdb11


Hence I'm wondering where the multiple mounting is coming from (when it comes), which I'm seeing as the more fundamental issue.   I don't have a frugal install - just toram livecd.

Subject title wasn't meant to be dramatic - just businesslike - perhaps I should adopt a lighter tone :=).  A bug is a bug.

You'll note I started with a bash issue but then ran straight into the multiple mounts so posted again - these should really have been separate threads, sorry - shouldn't mix up issues.

Bug is not so subtle when it manifests of course. Also, when I tried to umount, just got a (paraphrasing) "/dev/hdb11 appears to be mounted more than once" message.  It stubornly remained mounted.  /proc/mounts did not show multiple mounts for me -  only mtab.

Of course this hasn't been a problem before or since, which I thought made it all the more worth posting  - Murphy's law etc.

I think it was The Man Linus T who said something typically portentous like "All bugs are shallow given enough eyes".
Back to top
Profile PM 
3 replies since Dec. 10 2005,09:22 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: Bug in backup/restore dsl2.0

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code