blob: 45c97001fb3980d56b6807ef8f64f3d3248a69b4 [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
5import logging, os, utils, time
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
Sourav Poddar574bd622010-05-26 14:22:26 +05309def __get_mount_parts(expected_mountpt = chromeos_constants.CRYPTOHOME_MOUNT_PT,
10 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
17def is_mounted(device = chromeos_constants.CRYPTOHOME_DEVICE,
18 expected_mountpt = chromeos_constants.CRYPTOHOME_MOUNT_PT,
19 allow_fail = False):
20 mount_parts = _get_mount_parts(device, allow_fail)
Bryan Yeung99ee6a52010-03-24 16:39:25 -040021 return len(mount_parts) > 0 and device == mount_parts[0]
Sourav Poddar574bd622010-05-26 14:22:26 +053022
23
24def is_mounted_on_tmpfs(device = chromeos_constants.CRYPTOHOME_DEVICE,
25 expected_mountpt =
26 chromeos_constants.CRYPTOHOME_MOUNT_PT,
27 allow_fail = False):
28 mount_parts = __get_mount_parts(device, allow_fail)
29 return (len(mount_parts) > 2 and device == mount_parts[0] and
30 'tmpfs' == mount_parts[2])