blob: 303b4d637708f23eaf321f717fcec43653ca1261 [file] [log] [blame]
Chris Masone5e06f182010-03-23 08:29:52 -07001# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
Eric Libe760a12010-09-29 16:49:05 -07005import logging, os, re, time, utils
Chris Masonee7dd0162010-03-23 13:50:58 -07006from autotest_lib.client.bin import chromeos_constants, test
Chris Masone5e06f182010-03-23 08:29:52 -07007from autotest_lib.client.common_lib import error
8
Eric Libe760a12010-09-29 16:49:05 -07009def __get_mount_parts(expected_mountpt = chromeos_constants.CRYPTOHOME_MOUNT_PT,
Sourav Poddar574bd622010-05-26 14:22:26 +053010 allow_fail = False):
Will Drewry81ad6162010-04-01 10:26:07 -050011 mount_line = utils.system_output(
12 'grep %s /proc/$(pgrep cryptohomed)/mounts' % expected_mountpt,
Sourav Poddar574bd622010-05-26 14:22:26 +053013 ignore_status = allow_fail)
14 return mount_line.split()
15
16
Eric Libe760a12010-09-29 16:49:05 -070017
Frank Swiderski52653c32010-05-26 17:40:47 -070018def is_mounted(device=chromeos_constants.CRYPTOHOME_DEVICE_REGEX,
19 expected_mountpt=chromeos_constants.CRYPTOHOME_MOUNT_PT,
20 allow_fail=False):
21 mount_line = utils.system_output(
22 'grep %s /proc/$(pgrep cryptohomed)/mounts' % expected_mountpt,
23 ignore_status=allow_fail)
24 mount_parts = mount_line.split()
25 return len(mount_parts) > 0 and re.match(device, mount_parts[0])
Sourav Poddar574bd622010-05-26 14:22:26 +053026
27
Frank Swiderski52653c32010-05-26 17:40:47 -070028def is_mounted_on_tmpfs(device = chromeos_constants.CRYPTOHOME_INCOGNITO,
Sourav Poddar574bd622010-05-26 14:22:26 +053029 expected_mountpt =
30 chromeos_constants.CRYPTOHOME_MOUNT_PT,
31 allow_fail = False):
32 mount_parts = __get_mount_parts(device, allow_fail)
33 return (len(mount_parts) > 2 and device == mount_parts[0] and
34 'tmpfs' == mount_parts[2])