Chris Masone | 5e06f18 | 2010-03-23 08:29:52 -0700 | [diff] [blame] | 1 | # 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 | |
| 5 | import logging, os, utils, time |
Chris Masone | e7dd016 | 2010-03-23 13:50:58 -0700 | [diff] [blame] | 6 | from autotest_lib.client.bin import chromeos_constants, test |
Chris Masone | 5e06f18 | 2010-03-23 08:29:52 -0700 | [diff] [blame] | 7 | from autotest_lib.client.common_lib import error |
| 8 | |
Sourav Poddar | 574bd62 | 2010-05-26 14:22:26 +0530 | [diff] [blame^] | 9 | def __get_mount_parts(expected_mountpt = chromeos_constants.CRYPTOHOME_MOUNT_PT, |
| 10 | allow_fail = False): |
Will Drewry | 81ad616 | 2010-04-01 10:26:07 -0500 | [diff] [blame] | 11 | mount_line = utils.system_output( |
| 12 | 'grep %s /proc/$(pgrep cryptohomed)/mounts' % expected_mountpt, |
Sourav Poddar | 574bd62 | 2010-05-26 14:22:26 +0530 | [diff] [blame^] | 13 | ignore_status = allow_fail) |
| 14 | return mount_line.split() |
| 15 | |
| 16 | |
| 17 | def 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 Yeung | 99ee6a5 | 2010-03-24 16:39:25 -0400 | [diff] [blame] | 21 | return len(mount_parts) > 0 and device == mount_parts[0] |
Sourav Poddar | 574bd62 | 2010-05-26 14:22:26 +0530 | [diff] [blame^] | 22 | |
| 23 | |
| 24 | def 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]) |