~ubuntu-branches/ubuntu/trusty/landscape-client/trusty-proposed

« back to all changes in this revision

Viewing changes to landscape/lib/disk.py

  • Committer: Bazaar Package Importer
  • Author(s): Free Ekanayaka
  • Date: 2010-04-07 16:27:45 UTC
  • mfrom: (1.1.14 upstream) (24.1.1 karmic-proposed)
  • Revision ID: james.westby@ubuntu.com-20100407162745-oeyoppvl0qyvii55
Tags: 1.5.0-0ubuntu0.10.04.0
* New upstream version (LP: #557244)
  - Fix package-changer running before smart-update has completed (LP: #542215)
  - Report the version of Eucalyptus used to generate topology data (LP: #554007)
  - Enable the Eucalyptus plugin by default, if supported (LP: #546531)
  - Use a whitelist of allowed filesystem types to instead of a blacklist (LP: #351927)
  - Report the update-manager logs to the server (LP: #503384)
  - Turn off Curl's DNS caching for requests. (LP: #522688)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import statvfs
5
5
 
6
6
 
7
 
def get_mount_info(mounts_file, statvfs_):
 
7
def get_mount_info(mounts_file, statvfs_, filesystems_whitelist=None):
8
8
    """
9
9
    Given a mounts file (e.g., /proc/mounts), generate dicts with the following
10
10
    keys:
11
11
 
 
12
    @param filesystems_whitelist: if provided, the list of file systems which
 
13
        we're allowed to stat.
 
14
 
12
15
     - device: The device file which is mounted.
13
16
     - mount-point: The path at which the filesystem is mounted.
14
17
     - filesystem: The filesystem type.
21
24
            mount_point = mount_point.decode("string-escape")
22
25
        except ValueError:
23
26
            continue
 
27
        if (filesystems_whitelist is not None and
 
28
            filesystem not in filesystems_whitelist):
 
29
            continue
24
30
        megabytes = 1024 * 1024
25
31
        stats = statvfs_(mount_point)
26
32
        block_size = stats[statvfs.F_BSIZE]
31
37
               "free-space": free_space}
32
38
 
33
39
 
34
 
def get_filesystem_for_path(path, mounts_file, statvfs_):
 
40
def get_filesystem_for_path(path, mounts_file, statvfs_,
 
41
                            filesystems_whitelist=None):
35
42
    candidate = None
36
43
    path = os.path.realpath(path)
37
44
    path_segments = path.split("/")
38
 
    for info in get_mount_info(mounts_file, statvfs_):
 
45
    for info in get_mount_info(mounts_file, statvfs_, filesystems_whitelist):
39
46
        mount_segments = info["mount-point"].split("/")
40
47
        if path.startswith(info["mount-point"]):
41
48
            if ((not candidate)