Slashdot Mirror


Data Loss Bug In OS X 10.5 Leopard

An anonymous reader writes "Leopard's Finder has a glaring bug in its directory-moving code, leading to horrendous data loss if a destination volume disappears while a move operation is in progress. This author first came across it when Samba crashed while he was moving a directory from his desktop over to a Samba mount on his FreeBSD server."

13 of 603 comments (clear)

  1. Tiger has this problem as well!!! by itsybitsy · · Score: 5, Informative

    I lost a huge amount of data being MOVED (not copied) from one volume into a virtual volume DMG file. Lost and gone forever, lots of important files. What happened? I simply bumped the laptop Mac Book Pro during the move... zap... gone forever. The DMG file was blank! Yes, complely zero bytes except for a bit of header non-file data. It sucks bad.

  2. Par for the course? by GoRK · · Score: 5, Informative

    No offense meant here, but normal move/copy operations are traditionally highly destructive events on MacOS anyway. For instance there is absolutely no simple way to merge two folders contents together on the mac. If you drag a folder called "Documents" into your home directory and click on "OK", the Mac OS will happily delete your entire documents folder. I was reminded of this enormous frustration while recovering from some multi-volume backups recently, having to resort to an obscure OS X commandline tool 'pax' and Leopard's newfound support of hardlinks to make some simple file copies play nice and not unnecessarily consume 3 times the disk space they should have.

    For all of the flack the Windows file copy interface gets, it is both safer and more flexible than trying to use the Finder: an interface that makes file management so stupefying it becomes impossible.

    1. Re:Par for the course? by TheNetAvenger · · Score: 4, Informative

      I haven't noticed different behavior in any version of Windows. How do you merge similarly named folders during a copy/move in Windows? In my experience you get the same "Do you want to replace this?" type prompt you get in OS X.


      Serious answer...

      XP offers a basic, do you want to replace folder and a basic do you want to replace files. (Very generic, but more than OS X does)

      Vista on the other hand, asks if you want to replace/merge folder and then if conflicting files are found in the folders it asks you if you want to overwrite the files, don't overwrite them, or create a second copy of the file in the same folder. File by File and Folder by Folder if you want, or you can hit a check box to mimic your response for all file and folders if you are moving a lot of files/folders.

      It also will show you the two versions of the file or folder so you can make a decision based on which files/folders are newer, and you even get a thumbnail of the file for documents and pictures to be sure you are keeping the one you want.

      (Very simple interface, but more has the functionality of the power geek that was always left to using tools like XCopy in the past.)

      This is one of the 'little' Vista features that doesn't get any press, but is a lifesaver for people that move around a lot of data, as you can merge and update folders and files much easier.

      Stuff like this is the reason I said if MS did a 'new features' list like the pety list Apple did with their 300 new features, Vista would have several thousand new features to list.

      (Again MS's marketing sucks, since most people don't even know stuff like this exists in Vista, and it is both powerful, easy, and just works.)

  3. Re:That's silly. by Hatta · · Score: 5, Informative

    Why don't you just use rsync?

    --
    Give me Classic Slashdot or give me death!
  4. Re:That's silly. by Frothy+Walrus · · Score: 5, Informative

    Oh yeah, rsync. Is that one still broken on 10.5? Apple's build of rsync on 10.4 consistently choked on a few files when my dad started using it on his Mac Pro.

  5. Re:That's silly. by ackthpt · · Score: 5, Informative

    So what happens if you're moving a 120GB folder one directory level on a 150GB disk?

    Typically if you are moving within the same logical device the file pointer is moved and no copying need take place.

    When moving to another device your code reads and writes, within a loop and traps exceptions (such as the device suddenly vanished, where the OS should raise an exception and your application traps it.) A wide variety of errors could occur while moving and in the event any of them happen the user should be notified in an appropriate manner and the original data not deleted.

    I've written a number of applications which moved files or data between databases and it's fundamental your application is on the watch for any problems. Not to have an exception raised or to trap any and all, well, that's simply an inexcusable lapse.

    This sort of thing is extremely critical if you happend to be defragmenting a disk drive. Long before Macs and PCs we had to defrag our mainframe drives and the applications which did the work were quite careful. Often the best practice, if you had the resource of a second drive, was to simply defrag to a new drive then re-assign the new dist as the original.

    --

    A feeling of having made the same mistake before: Deja Foobar
  6. Re:I don't understand by t35t0r · · Score: 5, Informative

    NFS write failure on Linux 2.4, check your data is gone.

    Uhh no. In linux mv's always make sure the data moved then delete the original file (as far back as 2.4). You can test this by dd'ing a large file (use if=/dev/urandom), then run a md5sum on it, then do a mv within the same drive, over nfs, over samba/cifs, to floppy (not sure what happens here because linux caches writes to floppies until umount), to usb drive, whatever. While the mv is in operation just pull the plug on the system (target or source system). Your old file will still be there!

  7. Re:No it isn't by tf23 · · Score: 4, Informative

    You have to pay to be able to participate in the program

    Wrong-o!! You absolutely do not have to pay anything to involved in the Appleseed program.

  8. Re:Ah, the "outsourcing" coding model.. by beav007 · · Score: 5, Informative

    Um... no. REALLY no. Please don't do that.

    The syntax for "||" is:
    If command 1 fails, do command 2 - otherwise exit (where you used "command1 || command2").

    In this case, your command will either copy all the files from $from to $to or delete all files at $from.

    What you probably meant is cp $from $to && rm -r $from, which only performs the second command if the first succeeded. This solution is far from perfect for reasons mentioned by other posters, but it's still significantly safer and more useful than yours...

  9. I had this happening to me with WinXP aswell by Lisandro · · Score: 4, Informative

    That's it, moving a file, network failure and poof, moved files deleted from the source. Most probably a bizarre coincidence, but after it happened a few times i now copy and then delete when working on a SMB network.

    (Or maybe Samba has something to do with it?)

  10. Re:Or [possibly], go fix it. by andreyw · · Score: 4, Informative

    Finder, and any GUI parts of OS X in general, are not part of Darwin.

  11. Re:That's silly. by Matt+Perry · · Score: 4, Informative

    I think you misunderstand something.
    No, I understand perfectly.

    I know for a fact that I've successfully canceled FTP-moves on Windows (brand); I also know for a fact that I've successfully canceled FTP-moves on all modern instances of the Windows OS with various FTP clients (programs).
    I'm not talking about other clients. I'm talking about using Windows XP as the client.

    What program were you using that fragged your FTP server directory exactly?
    Windows XP, service pack 1.

    I suspect you're a fud-fucking idiot
    You need to work on your social skills.

    although at the moment, I'm interested to hear if there's more than fabrication here. Pray tell: how can I reproduce this bug?
    You might need to use WinXP service pack 1. I'm unable to reproduce it now on my home machine which has SP2 installed. At work we've just upgraded to service pack 2 within the last six months. Anyway, about a year ago I was trying to move nearly 40 gigs of data from a Solaris server at another site to my local machine. The Solaris server was an FTP server and that's the only access I had to it. I opened Internet Explorer and typed in ftp://servername and was prompted for a username and password which I entered. Then I saw the files in the explorer view just like I see files on my local machine. Since I was moving so much data I decided to do it one top-level directory at a time. To move the files I selected the folder, dragged it to a folder on my local machine, and held down shift when I let go of the mouse pointer so it would move instead of copy. I noticed that Windows went through three steps when it moved from the FTP site:
    1. A dialog appears with the title Moving... and it says it's calculating how much time it'll take. This took a while itself.
    2. Then the dialog says it's moving the files and the progress meter shows the progress
    3. After the progress meter fills up, it goes to empty again and then says it's deleting the files it moved
    I did this with most of the folders until I reached one that had about 18GB of data in it. I performed the same procedure as above to start the move and after it was copying files for about a minute or two I realized that I was moving them to the wrong location (my desktop instead of a directory on my C drive). At work our desktops are retargeted to a file server and not our local hard drives. I knew that by copying to the desktop I would hit my quota limit on the server whereas if I had copied to the C drive like I did with the other folders I had no limit aside from the free hard drive space. Not copying there in the first place was just a mistake. I clicked cancel to stop the transfer. When I did that, the dialog that had the progress bar changed to the empty progress bar and said it was now deleting. By the time I realized what was going on, it had deleted that folder and all of its content from the FTP site.

    Now this could have been some weird bug or interaction between the fact that I was using a machine with SP1 instead of SP2, that my desktop and profile were retargeted to another machine, or that I was moving so much data. It wasn't a lot of files as these were data files for desktop publish programs for some brochures and catalogs, along with large print-ready images. I don't know what items worked together to cause the problem. I do know that it did happen and that I had to deal with the IT group at our other site (that had the Solaris server), open the helpdesk ticket to get them to restore the files from backup, wait for them to get around to it, etc. It was a huge pain and delayed what I was working on, causing grief for myself and my internal customer. One thing's for sure; I'll never use the built-in Windows FTP client again.
    --
    Slashdot: Failed Car Analogies. Amateur Lawyering. Anecdote Battles.
  12. Re:That's silly. by kisielk · · Score: 5, Informative

    There have been resource fork patches for some time, but somewhat unreliable. Version 3.0 is going to support resource forks (and other types of extended attributes) out of the box. The setup we have been using extracts resource forks to a separate file on the mac and then backs them up alongside the original files. The restore process just performs the reverse. It will be nice once we can switch to rsync 3.0 and get rid of that step.