iter_files() should not descend into "lost+found" on ext4/ext3/ext2

Bug #863716 reported by Jason Gerard DeRose on 2011-09-30
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Jason Gerard DeRose

Bug Description

A lot of work as been put into making sure our import process will either import every single file on a card, or fail loudly if any problem occurs. We don't want any gray area because we ultimately want to automatically format the cards upon completing the import (assuming the files were stored on 2 different hard drives as they were imported).

Turns out the `os.walk()` function is a dangerous little beast in this setting... never use it for dmedia or filestore!

On the other hand, our `iter_files()` function is very strict and explicit because we never want a permission error to be interpreted as there being no files inside a directory.

But one problem is that if you want to import files from an ext4/ext3/ext2 partition, `iter_files()` currently bombs out when it tries to descend into the "lost+found" directory.

So when we have a "lost+found" directory, we wont descend into it assuming all these conditions are met:

  1. path.ismount(basedir) is True

  2. "lost+found" is owned by the root user

  3. "lost+found" has 0700 permissions (is this always the case for ext2/ext3/ext4?)

Otherwise we descend into it, even if named "lost+found", even if it causes an exception to be raised.

Note that we want this to *always* raise an exception:


But we don't want this to raise an exception when "MyFiles" is an ext2/ext3/ext4 partition:


Subtle but important difference.

Related branches

Changed in filestore:
status: Triaged → In Progress
assignee: nobody → Jason Gerard DeRose (jderose)
Changed in filestore:
status: In Progress → Fix Committed
Changed in filestore:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers