2012-01-07 03:09:42 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2012 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-03-31 14:32:09 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <libgen.h>
|
2012-01-07 03:09:42 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2016-07-22 03:48:14 +00:00
|
|
|
#include <sys/ioctl.h>
|
2012-01-07 03:09:42 +00:00
|
|
|
#include <sys/mount.h>
|
|
|
|
#include <sys/stat.h>
|
2016-03-31 14:32:09 +00:00
|
|
|
#include <sys/swap.h>
|
2012-01-07 03:09:42 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <time.h>
|
2016-03-31 14:32:09 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
|
2017-03-02 22:33:04 +00:00
|
|
|
#include <android-base/file.h>
|
|
|
|
#include <android-base/stringprintf.h>
|
2017-01-16 13:49:49 +00:00
|
|
|
#include <android-base/unique_fd.h>
|
2014-06-20 05:12:20 +00:00
|
|
|
#include <cutils/android_reboot.h>
|
2012-01-07 03:09:42 +00:00
|
|
|
#include <cutils/partition_utils.h>
|
|
|
|
#include <cutils/properties.h>
|
2016-10-06 00:53:30 +00:00
|
|
|
#include <ext4_utils/ext4.h>
|
|
|
|
#include <ext4_utils/ext4_crypt_init_extensions.h>
|
|
|
|
#include <ext4_utils/ext4_sb.h>
|
|
|
|
#include <ext4_utils/ext4_utils.h>
|
|
|
|
#include <ext4_utils/wipe.h>
|
2016-07-22 03:48:14 +00:00
|
|
|
#include <linux/fs.h>
|
2016-03-31 14:32:09 +00:00
|
|
|
#include <linux/loop.h>
|
fs_mgr: Capture the output of e2fsck and add to the kernel log
Currently, the output of e2fsck is not saved, and we have no insight
into how many errors e2fsck is finding and fixing. Using the new
abbreviated logging feature in liblogwrap, up to the first 100 lines,
and last 4K bytes of the output of e2fsck is captured by fs_mgr, and
added to the kernel log.
Usually, the filesystem will be clean, and this will only add a few
lines to the kernel log on boot, but when things go wrong, it should
save enough to indicate what the problem is, without potentially
filling the kernel log with only e2fsck output if the filesystem is
really corrupted.
Change-Id: I9c264798e6fe721c8f818b5ce15d0975027ddbdd
2013-03-20 02:38:44 +00:00
|
|
|
#include <logwrap/logwrap.h>
|
2017-03-20 21:29:00 +00:00
|
|
|
#include <private/android_logger.h> // for __android_log_is_debuggable()
|
2013-02-23 02:11:41 +00:00
|
|
|
|
2012-01-07 03:09:42 +00:00
|
|
|
#include "fs_mgr_priv.h"
|
2017-01-11 14:21:38 +00:00
|
|
|
#include "fs_mgr_priv_avb.h"
|
2012-01-07 03:09:42 +00:00
|
|
|
|
|
|
|
#define KEY_LOC_PROP "ro.crypto.keyfile.userdata"
|
|
|
|
#define KEY_IN_FOOTER "footer"
|
|
|
|
|
|
|
|
#define E2FSCK_BIN "/system/bin/e2fsck"
|
2016-07-22 03:48:14 +00:00
|
|
|
#define F2FS_FSCK_BIN "/system/bin/fsck.f2fs"
|
2013-07-09 02:11:55 +00:00
|
|
|
#define MKSWAP_BIN "/system/bin/mkswap"
|
2016-07-22 03:48:14 +00:00
|
|
|
#define TUNE2FS_BIN "/system/bin/tune2fs"
|
2013-07-09 02:11:55 +00:00
|
|
|
|
2013-09-19 00:49:21 +00:00
|
|
|
#define FSCK_LOG_FILE "/dev/fscklogs/log"
|
|
|
|
|
2013-07-09 02:11:55 +00:00
|
|
|
#define ZRAM_CONF_DEV "/sys/block/zram0/disksize"
|
2016-08-26 13:09:35 +00:00
|
|
|
#define ZRAM_CONF_MCS "/sys/block/zram0/max_comp_streams"
|
2012-01-07 03:09:42 +00:00
|
|
|
|
fs_mgr: Capture the output of e2fsck and add to the kernel log
Currently, the output of e2fsck is not saved, and we have no insight
into how many errors e2fsck is finding and fixing. Using the new
abbreviated logging feature in liblogwrap, up to the first 100 lines,
and last 4K bytes of the output of e2fsck is captured by fs_mgr, and
added to the kernel log.
Usually, the filesystem will be clean, and this will only add a few
lines to the kernel log on boot, but when things go wrong, it should
save enough to indicate what the problem is, without potentially
filling the kernel log with only e2fsck output if the filesystem is
really corrupted.
Change-Id: I9c264798e6fe721c8f818b5ce15d0975027ddbdd
2013-03-20 02:38:44 +00:00
|
|
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
|
|
|
|
|
2017-03-02 22:33:04 +00:00
|
|
|
// record fs stat
|
|
|
|
enum FsStatFlags {
|
|
|
|
FS_STAT_IS_EXT4 = 0x0001,
|
|
|
|
FS_STAT_NEW_IMAGE_VERSION = 0x0002,
|
|
|
|
FS_STAT_E2FSCK_F_ALWAYS = 0x0004,
|
|
|
|
FS_STAT_UNCLEAN_SHUTDOWN = 0x0008,
|
|
|
|
FS_STAT_QUOTA_ENABLED = 0x0010,
|
|
|
|
FS_STAT_TUNE2FS_FAILED = 0x0020,
|
|
|
|
FS_STAT_RO_MOUNT_FAILED = 0x0040,
|
|
|
|
FS_STAT_RO_UNMOUNT_FAILED = 0x0080,
|
|
|
|
FS_STAT_FULL_MOUNT_FAILED = 0x0100,
|
|
|
|
FS_STAT_E2FSCK_FAILED = 0x0200,
|
|
|
|
FS_STAT_E2FSCK_FS_FIXED = 0x0400,
|
|
|
|
};
|
|
|
|
|
2012-01-07 03:09:42 +00:00
|
|
|
/*
|
|
|
|
* gettime() - returns the time in seconds of the system's monotonic clock or
|
|
|
|
* zero on error.
|
|
|
|
*/
|
|
|
|
static time_t gettime(void)
|
|
|
|
{
|
|
|
|
struct timespec ts;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
|
|
if (ret < 0) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PERROR << "clock_gettime(CLOCK_MONOTONIC) failed";
|
2012-01-07 03:09:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ts.tv_sec;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int wait_for_file(const char *filename, int timeout)
|
|
|
|
{
|
|
|
|
struct stat info;
|
|
|
|
time_t timeout_time = gettime() + timeout;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
while (gettime() < timeout_time && ((ret = stat(filename, &info)) < 0))
|
|
|
|
usleep(10000);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-03-02 22:33:04 +00:00
|
|
|
static void log_fs_stat(const char* blk_device, int fs_stat)
|
|
|
|
{
|
|
|
|
if ((fs_stat & FS_STAT_IS_EXT4) == 0) return; // only log ext4
|
|
|
|
std::string msg = android::base::StringPrintf("\nfs_stat,%s,0x%x\n", blk_device, fs_stat);
|
|
|
|
android::base::unique_fd fd(TEMP_FAILURE_RETRY(open(FSCK_LOG_FILE, O_WRONLY | O_CLOEXEC |
|
|
|
|
O_APPEND | O_CREAT, 0664)));
|
|
|
|
if (fd == -1 || !android::base::WriteStringToFd(msg, fd)) {
|
|
|
|
LWARNING << __FUNCTION__ << "() cannot log " << msg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void check_fs(const char *blk_device, char *fs_type, char *target, int *fs_stat)
|
2012-01-07 03:09:42 +00:00
|
|
|
{
|
|
|
|
int status;
|
2012-07-24 02:34:00 +00:00
|
|
|
int ret;
|
|
|
|
long tmpmnt_flags = MS_NOATIME | MS_NOEXEC | MS_NOSUID;
|
2015-05-20 17:01:39 +00:00
|
|
|
char tmpmnt_opts[64] = "errors=remount-ro";
|
2017-01-16 13:49:49 +00:00
|
|
|
const char *e2fsck_argv[] = {
|
fs_mgr: Capture the output of e2fsck and add to the kernel log
Currently, the output of e2fsck is not saved, and we have no insight
into how many errors e2fsck is finding and fixing. Using the new
abbreviated logging feature in liblogwrap, up to the first 100 lines,
and last 4K bytes of the output of e2fsck is captured by fs_mgr, and
added to the kernel log.
Usually, the filesystem will be clean, and this will only add a few
lines to the kernel log on boot, but when things go wrong, it should
save enough to indicate what the problem is, without potentially
filling the kernel log with only e2fsck output if the filesystem is
really corrupted.
Change-Id: I9c264798e6fe721c8f818b5ce15d0975027ddbdd
2013-03-20 02:38:44 +00:00
|
|
|
E2FSCK_BIN,
|
2016-04-05 18:43:37 +00:00
|
|
|
"-f",
|
fs_mgr: Capture the output of e2fsck and add to the kernel log
Currently, the output of e2fsck is not saved, and we have no insight
into how many errors e2fsck is finding and fixing. Using the new
abbreviated logging feature in liblogwrap, up to the first 100 lines,
and last 4K bytes of the output of e2fsck is captured by fs_mgr, and
added to the kernel log.
Usually, the filesystem will be clean, and this will only add a few
lines to the kernel log on boot, but when things go wrong, it should
save enough to indicate what the problem is, without potentially
filling the kernel log with only e2fsck output if the filesystem is
really corrupted.
Change-Id: I9c264798e6fe721c8f818b5ce15d0975027ddbdd
2013-03-20 02:38:44 +00:00
|
|
|
"-y",
|
|
|
|
blk_device
|
|
|
|
};
|
2012-01-07 03:09:42 +00:00
|
|
|
|
|
|
|
/* Check for the types of filesystems we know how to check */
|
2013-02-13 20:58:40 +00:00
|
|
|
if (!strcmp(fs_type, "ext2") || !strcmp(fs_type, "ext3") || !strcmp(fs_type, "ext4")) {
|
2012-07-24 02:34:00 +00:00
|
|
|
/*
|
|
|
|
* First try to mount and unmount the filesystem. We do this because
|
|
|
|
* the kernel is more efficient than e2fsck in running the journal and
|
|
|
|
* processing orphaned inodes, and on at least one device with a
|
|
|
|
* performance issue in the emmc firmware, it can take e2fsck 2.5 minutes
|
|
|
|
* to do what the kernel does in about a second.
|
|
|
|
*
|
|
|
|
* After mounting and unmounting the filesystem, run e2fsck, and if an
|
|
|
|
* error is recorded in the filesystem superblock, e2fsck will do a full
|
|
|
|
* check. Otherwise, it does nothing. If the kernel cannot mount the
|
|
|
|
* filesytsem due to an error, e2fsck is still run to do a full check
|
|
|
|
* fix the filesystem.
|
|
|
|
*/
|
2015-04-24 18:05:48 +00:00
|
|
|
errno = 0;
|
2015-05-20 17:01:39 +00:00
|
|
|
if (!strcmp(fs_type, "ext4")) {
|
|
|
|
// This option is only valid with ext4
|
|
|
|
strlcat(tmpmnt_opts, ",nomblk_io_submit", sizeof(tmpmnt_opts));
|
|
|
|
}
|
2013-02-13 20:58:40 +00:00
|
|
|
ret = mount(blk_device, target, fs_type, tmpmnt_flags, tmpmnt_opts);
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PINFO << __FUNCTION__ << "(): mount(" << blk_device << "," << target
|
|
|
|
<< "," << fs_type << ")=" << ret;
|
2013-02-13 20:58:40 +00:00
|
|
|
if (!ret) {
|
2015-02-06 00:02:42 +00:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < 5; i++) {
|
|
|
|
// Try to umount 5 times before continuing on.
|
|
|
|
// Should we try rebooting if all attempts fail?
|
|
|
|
int result = umount(target);
|
|
|
|
if (result == 0) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << __FUNCTION__ << "(): unmount(" << target
|
|
|
|
<< ") succeeded";
|
2015-02-06 00:02:42 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-03-02 22:33:04 +00:00
|
|
|
*fs_stat |= FS_STAT_RO_UNMOUNT_FAILED;
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PERROR << __FUNCTION__ << "(): umount(" << target << ")="
|
|
|
|
<< result;
|
2015-02-06 00:02:42 +00:00
|
|
|
sleep(1);
|
|
|
|
}
|
2017-03-02 22:33:04 +00:00
|
|
|
} else {
|
|
|
|
*fs_stat |= FS_STAT_RO_MOUNT_FAILED;
|
2012-07-24 02:34:00 +00:00
|
|
|
}
|
|
|
|
|
2014-02-17 10:14:44 +00:00
|
|
|
/*
|
|
|
|
* Some system images do not have e2fsck for licensing reasons
|
|
|
|
* (e.g. recent SDK system images). Detect these and skip the check.
|
|
|
|
*/
|
|
|
|
if (access(E2FSCK_BIN, X_OK)) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "Not running " << E2FSCK_BIN << " on " << blk_device
|
|
|
|
<< " (executable not in system image)";
|
2014-02-17 10:14:44 +00:00
|
|
|
} else {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "Running " << E2FSCK_BIN << " on " << blk_device;
|
2014-02-17 10:14:44 +00:00
|
|
|
|
2017-03-02 22:33:04 +00:00
|
|
|
*fs_stat |= FS_STAT_E2FSCK_F_ALWAYS;
|
2017-01-16 13:49:49 +00:00
|
|
|
ret = android_fork_execvp_ext(ARRAY_SIZE(e2fsck_argv),
|
|
|
|
const_cast<char **>(e2fsck_argv),
|
2015-08-14 08:22:53 +00:00
|
|
|
&status, true, LOG_KLOG | LOG_FILE,
|
2017-01-16 13:49:49 +00:00
|
|
|
true,
|
|
|
|
const_cast<char *>(FSCK_LOG_FILE),
|
|
|
|
NULL, 0);
|
2014-02-17 10:14:44 +00:00
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
/* No need to check for error in fork, we can't really handle it now */
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Failed trying to run " << E2FSCK_BIN;
|
2017-03-02 22:33:04 +00:00
|
|
|
*fs_stat |= FS_STAT_E2FSCK_FAILED;
|
|
|
|
} else if (status != 0) {
|
|
|
|
LINFO << "e2fsck returned status 0x" << std::hex << status;
|
|
|
|
*fs_stat |= FS_STAT_E2FSCK_FS_FIXED;
|
2014-02-17 10:14:44 +00:00
|
|
|
}
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
2014-06-18 00:01:14 +00:00
|
|
|
} else if (!strcmp(fs_type, "f2fs")) {
|
2017-01-16 13:49:49 +00:00
|
|
|
const char *f2fs_fsck_argv[] = {
|
2014-06-18 00:01:14 +00:00
|
|
|
F2FS_FSCK_BIN,
|
2015-07-08 21:57:07 +00:00
|
|
|
"-a",
|
2014-06-18 00:01:14 +00:00
|
|
|
blk_device
|
|
|
|
};
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "Running " << F2FS_FSCK_BIN << " -a " << blk_device;
|
2014-06-18 00:01:14 +00:00
|
|
|
|
2017-01-16 13:49:49 +00:00
|
|
|
ret = android_fork_execvp_ext(ARRAY_SIZE(f2fs_fsck_argv),
|
|
|
|
const_cast<char **>(f2fs_fsck_argv),
|
2014-06-18 00:01:14 +00:00
|
|
|
&status, true, LOG_KLOG | LOG_FILE,
|
2017-01-16 13:49:49 +00:00
|
|
|
true, const_cast<char *>(FSCK_LOG_FILE),
|
|
|
|
NULL, 0);
|
2014-06-18 00:01:14 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
/* No need to check for error in fork, we can't really handle it now */
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Failed trying to run " << F2FS_FSCK_BIN;
|
2014-06-18 00:01:14 +00:00
|
|
|
}
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-22 03:48:14 +00:00
|
|
|
/* Function to read the primary superblock */
|
|
|
|
static int read_super_block(int fd, struct ext4_super_block *sb)
|
|
|
|
{
|
|
|
|
off64_t ret;
|
|
|
|
|
|
|
|
ret = lseek64(fd, 1024, SEEK_SET);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = read(fd, sb, sizeof(*sb));
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
if (ret != sizeof(*sb))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ext4_fsblk_t ext4_blocks_count(struct ext4_super_block *es)
|
|
|
|
{
|
|
|
|
return ((ext4_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
|
|
|
|
le32_to_cpu(es->s_blocks_count_lo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ext4_fsblk_t ext4_r_blocks_count(struct ext4_super_block *es)
|
|
|
|
{
|
|
|
|
return ((ext4_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) |
|
|
|
|
le32_to_cpu(es->s_r_blocks_count_lo);
|
|
|
|
}
|
|
|
|
|
2017-03-02 22:33:04 +00:00
|
|
|
static int do_quota_with_shutdown_check(char *blk_device, char *fs_type,
|
|
|
|
struct fstab_rec *rec, int *fs_stat)
|
2016-12-14 19:00:51 +00:00
|
|
|
{
|
|
|
|
int force_check = 0;
|
|
|
|
if (!strcmp(fs_type, "ext4")) {
|
|
|
|
/*
|
|
|
|
* Some system images do not have tune2fs for licensing reasons
|
|
|
|
* Detect these and skip reserve blocks.
|
|
|
|
*/
|
|
|
|
if (access(TUNE2FS_BIN, X_OK)) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Not running " << TUNE2FS_BIN << " on "
|
|
|
|
<< blk_device << " (executable not in system image)";
|
2016-12-14 19:00:51 +00:00
|
|
|
} else {
|
2017-01-16 13:49:49 +00:00
|
|
|
const char* arg1 = nullptr;
|
|
|
|
const char* arg2 = nullptr;
|
2016-12-14 19:00:51 +00:00
|
|
|
int status = 0;
|
|
|
|
int ret = 0;
|
2017-01-16 13:49:49 +00:00
|
|
|
android::base::unique_fd fd(
|
|
|
|
TEMP_FAILURE_RETRY(open(blk_device, O_RDONLY | O_CLOEXEC)));
|
2016-12-14 19:00:51 +00:00
|
|
|
if (fd >= 0) {
|
|
|
|
struct ext4_super_block sb;
|
|
|
|
ret = read_super_block(fd, &sb);
|
|
|
|
if (ret < 0) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PERROR << "Can't read '" << blk_device << "' super block";
|
2017-01-16 13:49:49 +00:00
|
|
|
return force_check;
|
2016-12-14 19:00:51 +00:00
|
|
|
}
|
2017-03-02 22:33:04 +00:00
|
|
|
*fs_stat |= FS_STAT_IS_EXT4;
|
2017-04-07 21:16:42 +00:00
|
|
|
LINFO << "superblock s_max_mnt_count:" << sb.s_max_mnt_count << "," << blk_device;
|
|
|
|
if (sb.s_max_mnt_count == 0xffff) { // -1 (int16) in ext2, but uint16 in ext4
|
|
|
|
*fs_stat |= FS_STAT_NEW_IMAGE_VERSION;
|
|
|
|
}
|
2017-03-02 22:33:04 +00:00
|
|
|
if ((sb.s_feature_incompat & EXT4_FEATURE_INCOMPAT_RECOVER) != 0 ||
|
|
|
|
(sb.s_state & EXT4_VALID_FS) == 0) {
|
|
|
|
LINFO << __FUNCTION__ << "(): was not clealy shutdown, state flag:"
|
|
|
|
<< std::hex << sb.s_state
|
|
|
|
<< "incompat flag:" << std::hex << sb.s_feature_incompat;
|
|
|
|
force_check = 1;
|
|
|
|
*fs_stat |= FS_STAT_UNCLEAN_SHUTDOWN;
|
|
|
|
}
|
2016-12-14 19:00:51 +00:00
|
|
|
int has_quota = (sb.s_feature_ro_compat
|
|
|
|
& cpu_to_le32(EXT4_FEATURE_RO_COMPAT_QUOTA)) != 0;
|
|
|
|
int want_quota = fs_mgr_is_quota(rec) != 0;
|
|
|
|
|
|
|
|
if (has_quota == want_quota) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "Requested quota status is match on " << blk_device;
|
2017-01-16 13:49:49 +00:00
|
|
|
return force_check;
|
2016-12-14 19:00:51 +00:00
|
|
|
} else if (want_quota) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "Enabling quota on " << blk_device;
|
2016-12-14 19:00:51 +00:00
|
|
|
arg1 = "-Oquota";
|
|
|
|
arg2 = "-Qusrquota,grpquota";
|
|
|
|
force_check = 1;
|
2017-03-02 22:33:04 +00:00
|
|
|
*fs_stat |= FS_STAT_QUOTA_ENABLED;
|
2016-12-14 19:00:51 +00:00
|
|
|
} else {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "Disabling quota on " << blk_device;
|
2016-12-14 19:00:51 +00:00
|
|
|
arg1 = "-Q^usrquota,^grpquota";
|
|
|
|
arg2 = "-O^quota";
|
|
|
|
}
|
|
|
|
} else {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PERROR << "Failed to open '" << blk_device << "'";
|
2016-12-14 19:00:51 +00:00
|
|
|
return force_check;
|
|
|
|
}
|
|
|
|
|
2017-01-16 13:49:49 +00:00
|
|
|
const char *tune2fs_argv[] = {
|
2016-12-14 19:00:51 +00:00
|
|
|
TUNE2FS_BIN,
|
|
|
|
arg1,
|
|
|
|
arg2,
|
|
|
|
blk_device,
|
|
|
|
};
|
2017-01-16 13:49:49 +00:00
|
|
|
ret = android_fork_execvp_ext(ARRAY_SIZE(tune2fs_argv),
|
|
|
|
const_cast<char **>(tune2fs_argv),
|
2016-12-14 19:00:51 +00:00
|
|
|
&status, true, LOG_KLOG | LOG_FILE,
|
|
|
|
true, NULL, NULL, 0);
|
|
|
|
if (ret < 0) {
|
|
|
|
/* No need to check for error in fork, we can't really handle it now */
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Failed trying to run " << TUNE2FS_BIN;
|
2017-03-02 22:33:04 +00:00
|
|
|
*fs_stat |= FS_STAT_TUNE2FS_FAILED;
|
2016-12-14 19:00:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return force_check;
|
|
|
|
}
|
|
|
|
|
2017-03-02 22:33:04 +00:00
|
|
|
static void do_reserved_size(char *blk_device, char *fs_type, struct fstab_rec *rec, int *fs_stat)
|
2016-07-22 03:48:14 +00:00
|
|
|
{
|
|
|
|
/* Check for the types of filesystems we know how to check */
|
|
|
|
if (!strcmp(fs_type, "ext2") || !strcmp(fs_type, "ext3") || !strcmp(fs_type, "ext4")) {
|
|
|
|
/*
|
|
|
|
* Some system images do not have tune2fs for licensing reasons
|
|
|
|
* Detect these and skip reserve blocks.
|
|
|
|
*/
|
|
|
|
if (access(TUNE2FS_BIN, X_OK)) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Not running " << TUNE2FS_BIN << " on "
|
|
|
|
<< blk_device << " (executable not in system image)";
|
2016-07-22 03:48:14 +00:00
|
|
|
} else {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "Running " << TUNE2FS_BIN << " on " << blk_device;
|
2016-07-22 03:48:14 +00:00
|
|
|
|
|
|
|
int status = 0;
|
|
|
|
int ret = 0;
|
|
|
|
unsigned long reserved_blocks = 0;
|
2017-01-16 13:49:49 +00:00
|
|
|
android::base::unique_fd fd(
|
|
|
|
TEMP_FAILURE_RETRY(open(blk_device, O_RDONLY | O_CLOEXEC)));
|
2016-07-22 03:48:14 +00:00
|
|
|
if (fd >= 0) {
|
|
|
|
struct ext4_super_block sb;
|
|
|
|
ret = read_super_block(fd, &sb);
|
|
|
|
if (ret < 0) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PERROR << "Can't read '" << blk_device << "' super block";
|
2017-01-16 13:49:49 +00:00
|
|
|
return;
|
2016-07-22 03:48:14 +00:00
|
|
|
}
|
|
|
|
reserved_blocks = rec->reserved_size / EXT4_BLOCK_SIZE(&sb);
|
|
|
|
unsigned long reserved_threshold = ext4_blocks_count(&sb) * 0.02;
|
|
|
|
if (reserved_threshold < reserved_blocks) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LWARNING << "Reserved blocks " << reserved_blocks
|
|
|
|
<< " is too large";
|
2016-07-22 03:48:14 +00:00
|
|
|
reserved_blocks = reserved_threshold;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ext4_r_blocks_count(&sb) == reserved_blocks) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "Have reserved same blocks";
|
2017-01-16 13:49:49 +00:00
|
|
|
return;
|
2016-07-22 03:48:14 +00:00
|
|
|
}
|
|
|
|
} else {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PERROR << "Failed to open '" << blk_device << "'";
|
2016-07-22 03:48:14 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
char buf[16] = {0};
|
|
|
|
snprintf(buf, sizeof (buf), "-r %lu", reserved_blocks);
|
2017-01-16 13:49:49 +00:00
|
|
|
const char *tune2fs_argv[] = {
|
2016-07-22 03:48:14 +00:00
|
|
|
TUNE2FS_BIN,
|
|
|
|
buf,
|
|
|
|
blk_device,
|
|
|
|
};
|
|
|
|
|
2017-01-16 13:49:49 +00:00
|
|
|
ret = android_fork_execvp_ext(ARRAY_SIZE(tune2fs_argv),
|
|
|
|
const_cast<char **>(tune2fs_argv),
|
2016-07-22 03:48:14 +00:00
|
|
|
&status, true, LOG_KLOG | LOG_FILE,
|
|
|
|
true, NULL, NULL, 0);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
/* No need to check for error in fork, we can't really handle it now */
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Failed trying to run " << TUNE2FS_BIN;
|
2017-03-02 22:33:04 +00:00
|
|
|
*fs_stat |= FS_STAT_TUNE2FS_FAILED;
|
2016-07-22 03:48:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-07 03:09:42 +00:00
|
|
|
static void remove_trailing_slashes(char *n)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
|
|
|
len = strlen(n) - 1;
|
|
|
|
while ((*(n + len) == '/') && len) {
|
|
|
|
*(n + len) = '\0';
|
|
|
|
len--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-16 23:41:32 +00:00
|
|
|
/*
|
|
|
|
* Mark the given block device as read-only, using the BLKROSET ioctl.
|
|
|
|
* Return 0 on success, and -1 on error.
|
|
|
|
*/
|
2014-12-18 16:15:30 +00:00
|
|
|
int fs_mgr_set_blk_ro(const char *blockdev)
|
2013-04-16 23:41:32 +00:00
|
|
|
{
|
|
|
|
int fd;
|
2014-12-18 16:15:30 +00:00
|
|
|
int rc = -1;
|
2013-04-16 23:41:32 +00:00
|
|
|
int ON = 1;
|
|
|
|
|
2014-12-18 16:15:30 +00:00
|
|
|
fd = TEMP_FAILURE_RETRY(open(blockdev, O_RDONLY | O_CLOEXEC));
|
2013-04-16 23:41:32 +00:00
|
|
|
if (fd < 0) {
|
|
|
|
// should never happen
|
2014-12-18 16:15:30 +00:00
|
|
|
return rc;
|
2013-04-16 23:41:32 +00:00
|
|
|
}
|
|
|
|
|
2014-12-18 16:15:30 +00:00
|
|
|
rc = ioctl(fd, BLKROSET, &ON);
|
2015-05-16 02:16:40 +00:00
|
|
|
close(fd);
|
2014-12-18 16:15:30 +00:00
|
|
|
|
|
|
|
return rc;
|
2013-04-16 23:41:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* __mount(): wrapper around the mount() system call which also
|
|
|
|
* sets the underlying block device to read-only if the mount is read-only.
|
|
|
|
* See "man 2 mount" for return values.
|
|
|
|
*/
|
2014-06-18 21:54:37 +00:00
|
|
|
static int __mount(const char *source, const char *target, const struct fstab_rec *rec)
|
2013-04-16 23:41:32 +00:00
|
|
|
{
|
2014-06-18 21:54:37 +00:00
|
|
|
unsigned long mountflags = rec->flags;
|
|
|
|
int ret;
|
|
|
|
int save_errno;
|
2014-06-26 21:55:04 +00:00
|
|
|
|
|
|
|
/* We need this because sometimes we have legacy symlinks
|
|
|
|
* that are lingering around and need cleaning up.
|
|
|
|
*/
|
|
|
|
struct stat info;
|
|
|
|
if (!lstat(target, &info))
|
|
|
|
if ((info.st_mode & S_IFMT) == S_IFLNK)
|
|
|
|
unlink(target);
|
2014-05-28 21:10:01 +00:00
|
|
|
mkdir(target, 0755);
|
2014-06-18 21:54:37 +00:00
|
|
|
ret = mount(source, target, rec->fs_type, mountflags, rec->fs_options);
|
|
|
|
save_errno = errno;
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << __FUNCTION__ << "(source=" << source << ",target="
|
|
|
|
<< target << ",type=" << rec->fs_type << ")=" << ret;
|
2013-04-16 23:41:32 +00:00
|
|
|
if ((ret == 0) && (mountflags & MS_RDONLY) != 0) {
|
2014-12-18 16:15:30 +00:00
|
|
|
fs_mgr_set_blk_ro(source);
|
2013-04-16 23:41:32 +00:00
|
|
|
}
|
2014-06-18 21:54:37 +00:00
|
|
|
errno = save_errno;
|
2013-04-16 23:41:32 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-11-03 20:36:35 +00:00
|
|
|
static int fs_match(const char *in1, const char *in2)
|
2012-01-07 03:09:42 +00:00
|
|
|
{
|
|
|
|
char *n1;
|
|
|
|
char *n2;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
n1 = strdup(in1);
|
|
|
|
n2 = strdup(in2);
|
|
|
|
|
|
|
|
remove_trailing_slashes(n1);
|
|
|
|
remove_trailing_slashes(n2);
|
|
|
|
|
|
|
|
ret = !strcmp(n1, n2);
|
|
|
|
|
|
|
|
free(n1);
|
|
|
|
free(n2);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-01-07 19:44:51 +00:00
|
|
|
static int device_is_force_encrypted() {
|
|
|
|
int ret = -1;
|
|
|
|
char value[PROP_VALUE_MAX];
|
|
|
|
ret = __system_property_get("ro.vold.forceencryption", value);
|
|
|
|
if (ret < 0)
|
|
|
|
return 0;
|
|
|
|
return strcmp(value, "1") ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
2014-07-02 20:16:04 +00:00
|
|
|
/*
|
|
|
|
* Tries to mount any of the consecutive fstab entries that match
|
|
|
|
* the mountpoint of the one given by fstab->recs[start_idx].
|
|
|
|
*
|
|
|
|
* end_idx: On return, will be the last rec that was looked at.
|
|
|
|
* attempted_idx: On return, will indicate which fstab rec
|
|
|
|
* succeeded. In case of failure, it will be the start_idx.
|
|
|
|
* Returns
|
|
|
|
* -1 on failure with errno set to match the 1st mount failure.
|
|
|
|
* 0 on success.
|
|
|
|
*/
|
|
|
|
static int mount_with_alternatives(struct fstab *fstab, int start_idx, int *end_idx, int *attempted_idx)
|
2014-06-20 05:12:20 +00:00
|
|
|
{
|
2014-07-02 20:16:04 +00:00
|
|
|
int i;
|
|
|
|
int mount_errno = 0;
|
|
|
|
int mounted = 0;
|
|
|
|
|
|
|
|
if (!end_idx || !attempted_idx || start_idx >= fstab->num_entries) {
|
|
|
|
errno = EINVAL;
|
|
|
|
if (end_idx) *end_idx = start_idx;
|
2016-12-14 14:47:33 +00:00
|
|
|
if (attempted_idx) *attempted_idx = start_idx;
|
2014-07-02 20:16:04 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hunt down an fstab entry for the same mount point that might succeed */
|
|
|
|
for (i = start_idx;
|
|
|
|
/* We required that fstab entries for the same mountpoint be consecutive */
|
|
|
|
i < fstab->num_entries && !strcmp(fstab->recs[start_idx].mount_point, fstab->recs[i].mount_point);
|
|
|
|
i++) {
|
|
|
|
/*
|
|
|
|
* Don't try to mount/encrypt the same mount point again.
|
|
|
|
* Deal with alternate entries for the same point which are required to be all following
|
|
|
|
* each other.
|
|
|
|
*/
|
|
|
|
if (mounted) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << __FUNCTION__ << "(): skipping fstab dup mountpoint="
|
|
|
|
<< fstab->recs[i].mount_point << " rec[" << i
|
|
|
|
<< "].fs_type=" << fstab->recs[i].fs_type
|
|
|
|
<< " already mounted as "
|
|
|
|
<< fstab->recs[*attempted_idx].fs_type;
|
2014-07-02 20:16:04 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-03-02 22:33:04 +00:00
|
|
|
int fs_stat = 0;
|
|
|
|
int force_check = do_quota_with_shutdown_check(fstab->recs[i].blk_device,
|
|
|
|
fstab->recs[i].fs_type,
|
|
|
|
&fstab->recs[i], &fs_stat);
|
2016-12-14 19:00:51 +00:00
|
|
|
|
|
|
|
if ((fstab->recs[i].fs_mgr_flags & MF_CHECK) || force_check) {
|
2014-07-02 20:16:04 +00:00
|
|
|
check_fs(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
|
2017-03-02 22:33:04 +00:00
|
|
|
fstab->recs[i].mount_point, &fs_stat);
|
2014-07-02 20:16:04 +00:00
|
|
|
}
|
2016-07-22 03:48:14 +00:00
|
|
|
|
|
|
|
if (fstab->recs[i].fs_mgr_flags & MF_RESERVEDSIZE) {
|
|
|
|
do_reserved_size(fstab->recs[i].blk_device, fstab->recs[i].fs_type,
|
2017-03-02 22:33:04 +00:00
|
|
|
&fstab->recs[i], &fs_stat);
|
2016-07-22 03:48:14 +00:00
|
|
|
}
|
|
|
|
|
2014-07-02 20:16:04 +00:00
|
|
|
if (!__mount(fstab->recs[i].blk_device, fstab->recs[i].mount_point, &fstab->recs[i])) {
|
|
|
|
*attempted_idx = i;
|
|
|
|
mounted = 1;
|
|
|
|
if (i != start_idx) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << __FUNCTION__ << "(): Mounted "
|
|
|
|
<< fstab->recs[i].blk_device << " on "
|
|
|
|
<< fstab->recs[i].mount_point << " with fs_type="
|
|
|
|
<< fstab->recs[i].fs_type << " instead of "
|
|
|
|
<< fstab->recs[start_idx].fs_type;
|
2014-07-02 20:16:04 +00:00
|
|
|
}
|
|
|
|
} else {
|
2017-03-02 22:33:04 +00:00
|
|
|
fs_stat |= FS_STAT_FULL_MOUNT_FAILED;
|
2017-03-09 04:19:08 +00:00
|
|
|
/* back up the first errno for crypto decisions */
|
|
|
|
if (mount_errno == 0) {
|
|
|
|
mount_errno = errno;
|
|
|
|
}
|
2014-07-02 20:16:04 +00:00
|
|
|
}
|
2017-03-02 22:33:04 +00:00
|
|
|
log_fs_stat(fstab->recs[i].blk_device, fs_stat);
|
2014-06-20 05:12:20 +00:00
|
|
|
}
|
2014-07-02 20:16:04 +00:00
|
|
|
|
|
|
|
/* Adjust i for the case where it was still withing the recs[] */
|
|
|
|
if (i < fstab->num_entries) --i;
|
|
|
|
|
|
|
|
*end_idx = i;
|
|
|
|
if (!mounted) {
|
|
|
|
*attempted_idx = start_idx;
|
|
|
|
errno = mount_errno;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
2014-06-20 05:12:20 +00:00
|
|
|
}
|
|
|
|
|
2014-12-17 20:26:54 +00:00
|
|
|
static int translate_ext_labels(struct fstab_rec *rec)
|
|
|
|
{
|
|
|
|
DIR *blockdir = NULL;
|
|
|
|
struct dirent *ent;
|
|
|
|
char *label;
|
|
|
|
size_t label_len;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (strncmp(rec->blk_device, "LABEL=", 6))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
label = rec->blk_device + 6;
|
|
|
|
label_len = strlen(label);
|
|
|
|
|
|
|
|
if (label_len > 16) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "FS label is longer than allowed by filesystem";
|
2014-12-17 20:26:54 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
blockdir = opendir("/dev/block");
|
|
|
|
if (!blockdir) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "couldn't open /dev/block";
|
2014-12-17 20:26:54 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((ent = readdir(blockdir))) {
|
|
|
|
int fd;
|
|
|
|
char super_buf[1024];
|
|
|
|
struct ext4_super_block *sb;
|
|
|
|
|
|
|
|
if (ent->d_type != DT_BLK)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
fd = openat(dirfd(blockdir), ent->d_name, O_RDONLY);
|
|
|
|
if (fd < 0) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Cannot open block device /dev/block/" << ent->d_name;
|
2014-12-17 20:26:54 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TEMP_FAILURE_RETRY(lseek(fd, 1024, SEEK_SET)) < 0 ||
|
|
|
|
TEMP_FAILURE_RETRY(read(fd, super_buf, 1024)) != 1024) {
|
|
|
|
/* Probably a loopback device or something else without a readable
|
|
|
|
* superblock.
|
|
|
|
*/
|
|
|
|
close(fd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
sb = (struct ext4_super_block *)super_buf;
|
|
|
|
if (sb->s_magic != EXT4_SUPER_MAGIC) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "/dev/block/" << ent->d_name << " not ext{234}";
|
2014-12-17 20:26:54 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strncmp(label, sb->s_volume_name, label_len)) {
|
|
|
|
char *new_blk_device;
|
|
|
|
|
|
|
|
if (asprintf(&new_blk_device, "/dev/block/%s", ent->d_name) < 0) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Could not allocate block device string";
|
2014-12-17 20:26:54 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "resolved label " << rec->blk_device << " to "
|
|
|
|
<< new_blk_device;
|
2014-12-17 20:26:54 +00:00
|
|
|
|
|
|
|
free(rec->blk_device);
|
|
|
|
rec->blk_device = new_blk_device;
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
closedir(blockdir);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-02-09 21:05:01 +00:00
|
|
|
static bool needs_block_encryption(const struct fstab_rec* rec)
|
|
|
|
{
|
|
|
|
if (device_is_force_encrypted() && fs_mgr_is_encryptable(rec)) return true;
|
|
|
|
if (rec->fs_mgr_flags & MF_FORCECRYPT) return true;
|
|
|
|
if (rec->fs_mgr_flags & MF_CRYPT) {
|
|
|
|
/* Check for existence of convert_fde breadcrumb file */
|
|
|
|
char convert_fde_name[PATH_MAX];
|
|
|
|
snprintf(convert_fde_name, sizeof(convert_fde_name),
|
|
|
|
"%s/misc/vold/convert_fde", rec->mount_point);
|
|
|
|
if (access(convert_fde_name, F_OK) == 0) return true;
|
|
|
|
}
|
|
|
|
if (rec->fs_mgr_flags & MF_FORCEFDEORFBE) {
|
|
|
|
/* Check for absence of convert_fbe breadcrumb file */
|
|
|
|
char convert_fbe_name[PATH_MAX];
|
|
|
|
snprintf(convert_fbe_name, sizeof(convert_fbe_name),
|
|
|
|
"%s/convert_fbe", rec->mount_point);
|
|
|
|
if (access(convert_fbe_name, F_OK) != 0) return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-26 15:49:42 +00:00
|
|
|
// Check to see if a mountable volume has encryption requirements
|
2016-02-02 18:31:30 +00:00
|
|
|
static int handle_encryptable(const struct fstab_rec* rec)
|
2015-03-26 15:49:42 +00:00
|
|
|
{
|
|
|
|
/* If this is block encryptable, need to trigger encryption */
|
2016-02-09 21:05:01 +00:00
|
|
|
if (needs_block_encryption(rec)) {
|
2015-03-26 15:49:42 +00:00
|
|
|
if (umount(rec->mount_point) == 0) {
|
|
|
|
return FS_MGR_MNTALL_DEV_NEEDS_ENCRYPTION;
|
|
|
|
} else {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PWARNING << "Could not umount " << rec->mount_point
|
|
|
|
<< " - allow continue unencrypted";
|
2015-03-26 15:49:42 +00:00
|
|
|
return FS_MGR_MNTALL_DEV_NOT_ENCRYPTED;
|
|
|
|
}
|
2016-02-09 21:05:01 +00:00
|
|
|
} else if (rec->fs_mgr_flags & (MF_FILEENCRYPTION | MF_FORCEFDEORFBE)) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
// Deal with file level encryption
|
|
|
|
LINFO << rec->mount_point << " is file encrypted";
|
2016-02-02 18:31:30 +00:00
|
|
|
return FS_MGR_MNTALL_DEV_FILE_ENCRYPTED;
|
2016-03-04 23:52:33 +00:00
|
|
|
} else if (fs_mgr_is_encryptable(rec)) {
|
2016-02-09 21:05:01 +00:00
|
|
|
return FS_MGR_MNTALL_DEV_NOT_ENCRYPTED;
|
2016-03-04 23:52:33 +00:00
|
|
|
} else {
|
|
|
|
return FS_MGR_MNTALL_DEV_NOT_ENCRYPTABLE;
|
2015-03-26 15:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-30 10:42:54 +00:00
|
|
|
static std::string extract_by_name_prefix(struct fstab* fstab) {
|
|
|
|
// We assume that there's an entry for the /misc mount point in the
|
|
|
|
// fstab file and use that to get the device file by-name prefix.
|
|
|
|
// The device needs not to have an actual /misc partition.
|
|
|
|
// e.g.,
|
|
|
|
// - /dev/block/platform/soc.0/7824900.sdhci/by-name/misc ->
|
|
|
|
// - /dev/block/platform/soc.0/7824900.sdhci/by-name/
|
|
|
|
struct fstab_rec* fstab_entry = fs_mgr_get_entry_for_mount_point(fstab, "/misc");
|
|
|
|
if (fstab_entry == nullptr) {
|
|
|
|
LERROR << "/misc mount point not found in fstab";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
std::string full_path(fstab_entry->blk_device);
|
|
|
|
size_t end_slash = full_path.find_last_of("/");
|
|
|
|
return full_path.substr(0, end_slash + 1);
|
|
|
|
}
|
|
|
|
|
2017-02-15 22:24:39 +00:00
|
|
|
// TODO: add ueventd notifiers if they don't exist.
|
|
|
|
// This is just doing a wait_for_device for maximum of 1s
|
2016-11-11 13:05:44 +00:00
|
|
|
int fs_mgr_test_access(const char *device) {
|
|
|
|
int tries = 25;
|
|
|
|
while (tries--) {
|
|
|
|
if (!access(device, F_OK) || errno != ENOENT) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
usleep(40 * 1000);
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-02-27 19:33:46 +00:00
|
|
|
bool is_device_secure() {
|
|
|
|
int ret = -1;
|
|
|
|
char value[PROP_VALUE_MAX];
|
|
|
|
ret = __system_property_get("ro.secure", value);
|
|
|
|
if (ret == 0) {
|
|
|
|
#ifdef ALLOW_SKIP_SECURE_CHECK
|
|
|
|
// Allow eng builds to skip this check if the property
|
|
|
|
// is not readable (happens during early mount)
|
|
|
|
return false;
|
|
|
|
#else
|
|
|
|
// If error and not an 'eng' build, we want to fail secure.
|
|
|
|
return true;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return strcmp(value, "0") ? true : false;
|
|
|
|
}
|
|
|
|
|
2014-06-18 21:54:37 +00:00
|
|
|
/* When multiple fstab records share the same mount_point, it will
|
|
|
|
* try to mount each one in turn, and ignore any duplicates after a
|
|
|
|
* first successful mount.
|
2014-07-02 20:16:04 +00:00
|
|
|
* Returns -1 on error, and FS_MGR_MNTALL_* otherwise.
|
2014-06-18 21:54:37 +00:00
|
|
|
*/
|
2016-08-23 18:58:09 +00:00
|
|
|
int fs_mgr_mount_all(struct fstab *fstab, int mount_mode)
|
2012-01-07 03:09:42 +00:00
|
|
|
{
|
2014-07-02 20:16:04 +00:00
|
|
|
int i = 0;
|
2016-03-04 23:52:33 +00:00
|
|
|
int encryptable = FS_MGR_MNTALL_DEV_NOT_ENCRYPTABLE;
|
2014-03-10 22:40:29 +00:00
|
|
|
int error_count = 0;
|
2014-06-18 21:54:37 +00:00
|
|
|
int mret = -1;
|
|
|
|
int mount_errno = 0;
|
2014-07-02 20:16:04 +00:00
|
|
|
int attempted_idx = -1;
|
2017-03-30 10:42:54 +00:00
|
|
|
FsManagerAvbUniquePtr avb_handle(nullptr);
|
2012-01-07 03:09:42 +00:00
|
|
|
|
2013-02-13 20:58:40 +00:00
|
|
|
if (!fstab) {
|
2014-03-10 22:40:29 +00:00
|
|
|
return -1;
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
|
|
|
|
2013-02-13 20:58:40 +00:00
|
|
|
for (i = 0; i < fstab->num_entries; i++) {
|
2016-08-23 18:58:09 +00:00
|
|
|
/* Don't mount entries that are managed by vold or not for the mount mode*/
|
|
|
|
if ((fstab->recs[i].fs_mgr_flags & (MF_VOLDMANAGED | MF_RECOVERYONLY)) ||
|
|
|
|
((mount_mode == MOUNT_MODE_LATE) && !fs_mgr_is_latemount(&fstab->recs[i])) ||
|
|
|
|
((mount_mode == MOUNT_MODE_EARLY) && fs_mgr_is_latemount(&fstab->recs[i]))) {
|
2013-02-13 20:58:40 +00:00
|
|
|
continue;
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 02:11:55 +00:00
|
|
|
/* Skip swap and raw partition entries such as boot, recovery, etc */
|
|
|
|
if (!strcmp(fstab->recs[i].fs_type, "swap") ||
|
|
|
|
!strcmp(fstab->recs[i].fs_type, "emmc") ||
|
2013-02-13 20:58:40 +00:00
|
|
|
!strcmp(fstab->recs[i].fs_type, "mtd")) {
|
|
|
|
continue;
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
|
|
|
|
2015-06-30 00:33:05 +00:00
|
|
|
/* Skip mounting the root partition, as it will already have been mounted */
|
|
|
|
if (!strcmp(fstab->recs[i].mount_point, "/")) {
|
|
|
|
if ((fstab->recs[i].fs_mgr_flags & MS_RDONLY) != 0) {
|
|
|
|
fs_mgr_set_blk_ro(fstab->recs[i].blk_device);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-12-17 20:26:54 +00:00
|
|
|
/* Translate LABEL= file system labels into block devices */
|
|
|
|
if (!strcmp(fstab->recs[i].fs_type, "ext2") ||
|
|
|
|
!strcmp(fstab->recs[i].fs_type, "ext3") ||
|
|
|
|
!strcmp(fstab->recs[i].fs_type, "ext4")) {
|
|
|
|
int tret = translate_ext_labels(&fstab->recs[i]);
|
|
|
|
if (tret < 0) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Could not translate label to block device";
|
2014-12-17 20:26:54 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-13 20:58:40 +00:00
|
|
|
if (fstab->recs[i].fs_mgr_flags & MF_WAIT) {
|
|
|
|
wait_for_file(fstab->recs[i].blk_device, WAIT_TIMEOUT);
|
|
|
|
}
|
|
|
|
|
2017-03-30 10:42:54 +00:00
|
|
|
if (fstab->recs[i].fs_mgr_flags & MF_AVB) {
|
|
|
|
if (!avb_handle) {
|
|
|
|
avb_handle = FsManagerAvbHandle::Open(extract_by_name_prefix(fstab));
|
|
|
|
if (!avb_handle) {
|
|
|
|
LERROR << "Failed to open FsManagerAvbHandle";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!avb_handle->SetUpAvb(&fstab->recs[i])) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Failed to set up AVB on partition: "
|
|
|
|
<< fstab->recs[i].mount_point << ", skipping!";
|
2017-01-11 14:21:38 +00:00
|
|
|
/* Skips mounting the device. */
|
|
|
|
continue;
|
|
|
|
}
|
2017-02-27 19:33:46 +00:00
|
|
|
} else if ((fstab->recs[i].fs_mgr_flags & MF_VERIFY) && is_device_secure()) {
|
2016-12-16 07:00:05 +00:00
|
|
|
int rc = fs_mgr_setup_verity(&fstab->recs[i], true);
|
2016-03-29 21:25:11 +00:00
|
|
|
if (__android_log_is_debuggable() && rc == FS_MGR_SETUP_VERITY_DISABLED) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "Verity disabled";
|
2014-10-09 14:22:49 +00:00
|
|
|
} else if (rc != FS_MGR_SETUP_VERITY_SUCCESS) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Could not set up verified partition, skipping!";
|
2013-02-23 02:11:41 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2017-01-11 14:21:38 +00:00
|
|
|
|
2014-07-02 20:16:04 +00:00
|
|
|
int last_idx_inspected;
|
2013-09-05 18:19:21 +00:00
|
|
|
int top_idx = i;
|
|
|
|
|
2014-07-02 20:16:04 +00:00
|
|
|
mret = mount_with_alternatives(fstab, i, &last_idx_inspected, &attempted_idx);
|
|
|
|
i = last_idx_inspected;
|
|
|
|
mount_errno = errno;
|
2014-06-18 07:28:14 +00:00
|
|
|
|
2014-06-18 21:54:37 +00:00
|
|
|
/* Deal with encryptability. */
|
2012-01-07 03:09:42 +00:00
|
|
|
if (!mret) {
|
2016-02-02 18:31:30 +00:00
|
|
|
int status = handle_encryptable(&fstab->recs[attempted_idx]);
|
2015-03-26 15:49:42 +00:00
|
|
|
|
|
|
|
if (status == FS_MGR_MNTALL_FAIL) {
|
|
|
|
/* Fatal error - no point continuing */
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:52:33 +00:00
|
|
|
if (status != FS_MGR_MNTALL_DEV_NOT_ENCRYPTABLE) {
|
|
|
|
if (encryptable != FS_MGR_MNTALL_DEV_NOT_ENCRYPTABLE) {
|
2015-03-26 15:49:42 +00:00
|
|
|
// Log and continue
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Only one encryptable/encrypted partition supported";
|
2014-02-03 21:27:49 +00:00
|
|
|
}
|
2015-03-26 15:49:42 +00:00
|
|
|
encryptable = status;
|
2014-02-03 21:27:49 +00:00
|
|
|
}
|
2015-03-26 15:49:42 +00:00
|
|
|
|
2012-01-07 03:09:42 +00:00
|
|
|
/* Success! Go get the next one */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-09-05 18:19:21 +00:00
|
|
|
/* mount(2) returned an error, handle the encryptable/formattable case */
|
|
|
|
bool wiped = partition_wiped(fstab->recs[top_idx].blk_device);
|
2016-03-08 14:54:55 +00:00
|
|
|
bool crypt_footer = false;
|
2013-09-05 18:19:21 +00:00
|
|
|
if (mret && mount_errno != EBUSY && mount_errno != EACCES &&
|
|
|
|
fs_mgr_is_formattable(&fstab->recs[top_idx]) && wiped) {
|
|
|
|
/* top_idx and attempted_idx point at the same partition, but sometimes
|
|
|
|
* at two different lines in the fstab. Use the top one for formatting
|
|
|
|
* as that is the preferred one.
|
|
|
|
*/
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << __FUNCTION__ << "(): " << fstab->recs[top_idx].blk_device
|
|
|
|
<< " is wiped and " << fstab->recs[top_idx].mount_point
|
|
|
|
<< " " << fstab->recs[top_idx].fs_type
|
|
|
|
<< " is formattable. Format it.";
|
2013-09-05 18:19:21 +00:00
|
|
|
if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) &&
|
|
|
|
strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) {
|
2016-03-02 22:02:55 +00:00
|
|
|
int fd = open(fstab->recs[top_idx].key_loc, O_WRONLY);
|
2013-09-05 18:19:21 +00:00
|
|
|
if (fd >= 0) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << __FUNCTION__ << "(): also wipe "
|
|
|
|
<< fstab->recs[top_idx].key_loc;
|
2013-09-05 18:19:21 +00:00
|
|
|
wipe_block_device(fd, get_file_size(fd));
|
|
|
|
close(fd);
|
|
|
|
} else {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PERROR << __FUNCTION__ << "(): "
|
|
|
|
<< fstab->recs[top_idx].key_loc << " wouldn't open";
|
2013-09-05 18:19:21 +00:00
|
|
|
}
|
2016-03-08 14:54:55 +00:00
|
|
|
} else if (fs_mgr_is_encryptable(&fstab->recs[top_idx]) &&
|
|
|
|
!strcmp(fstab->recs[top_idx].key_loc, KEY_IN_FOOTER)) {
|
|
|
|
crypt_footer = true;
|
2013-09-05 18:19:21 +00:00
|
|
|
}
|
2016-03-08 14:54:55 +00:00
|
|
|
if (fs_mgr_do_format(&fstab->recs[top_idx], crypt_footer) == 0) {
|
2013-09-05 18:19:21 +00:00
|
|
|
/* Let's replay the mount actions. */
|
|
|
|
i = top_idx - 1;
|
|
|
|
continue;
|
2016-05-02 22:55:30 +00:00
|
|
|
} else {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << __FUNCTION__ << "(): Format failed. "
|
|
|
|
<< "Suggest recovery...";
|
2016-05-02 22:55:30 +00:00
|
|
|
encryptable = FS_MGR_MNTALL_DEV_NEEDS_RECOVERY;
|
|
|
|
continue;
|
2013-09-05 18:19:21 +00:00
|
|
|
}
|
|
|
|
}
|
2014-06-18 21:54:37 +00:00
|
|
|
if (mret && mount_errno != EBUSY && mount_errno != EACCES &&
|
2014-07-02 21:26:54 +00:00
|
|
|
fs_mgr_is_encryptable(&fstab->recs[attempted_idx])) {
|
2013-09-05 18:19:21 +00:00
|
|
|
if (wiped) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << __FUNCTION__ << "(): "
|
|
|
|
<< fstab->recs[attempted_idx].blk_device
|
|
|
|
<< " is wiped and "
|
|
|
|
<< fstab->recs[attempted_idx].mount_point << " "
|
|
|
|
<< fstab->recs[attempted_idx].fs_type
|
|
|
|
<< " is encryptable. Suggest recovery...";
|
2014-07-02 21:26:54 +00:00
|
|
|
encryptable = FS_MGR_MNTALL_DEV_NEEDS_RECOVERY;
|
2014-03-10 22:40:29 +00:00
|
|
|
continue;
|
2014-06-20 05:12:20 +00:00
|
|
|
} else {
|
|
|
|
/* Need to mount a tmpfs at this mountpoint for now, and set
|
|
|
|
* properties that vold will query later for decrypting
|
|
|
|
*/
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << __FUNCTION__ << "(): possibly an encryptable blkdev "
|
|
|
|
<< fstab->recs[attempted_idx].blk_device
|
|
|
|
<< " for mount " << fstab->recs[attempted_idx].mount_point
|
|
|
|
<< " type " << fstab->recs[attempted_idx].fs_type;
|
2014-07-02 20:16:04 +00:00
|
|
|
if (fs_mgr_do_tmpfs_mount(fstab->recs[attempted_idx].mount_point) < 0) {
|
2014-06-20 05:12:20 +00:00
|
|
|
++error_count;
|
|
|
|
continue;
|
|
|
|
}
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
2014-07-02 20:16:04 +00:00
|
|
|
encryptable = FS_MGR_MNTALL_DEV_MIGHT_BE_ENCRYPTED;
|
2012-01-07 03:09:42 +00:00
|
|
|
} else {
|
2016-04-08 03:10:25 +00:00
|
|
|
if (fs_mgr_is_nofail(&fstab->recs[attempted_idx])) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PERROR << "Ignoring failure to mount an un-encryptable or wiped partition on"
|
|
|
|
<< fstab->recs[attempted_idx].blk_device << " at "
|
|
|
|
<< fstab->recs[attempted_idx].mount_point << " options: "
|
|
|
|
<< fstab->recs[attempted_idx].fs_options;
|
2016-04-08 03:10:25 +00:00
|
|
|
} else {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PERROR << "Failed to mount an un-encryptable or wiped partition on"
|
|
|
|
<< fstab->recs[attempted_idx].blk_device << " at "
|
|
|
|
<< fstab->recs[attempted_idx].mount_point << " options: "
|
|
|
|
<< fstab->recs[attempted_idx].fs_options;
|
2016-04-08 03:10:25 +00:00
|
|
|
++error_count;
|
|
|
|
}
|
2014-03-10 22:40:29 +00:00
|
|
|
continue;
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-10 22:40:29 +00:00
|
|
|
if (error_count) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
2014-02-03 21:27:49 +00:00
|
|
|
return encryptable;
|
2014-03-10 22:40:29 +00:00
|
|
|
}
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
|
|
|
|
2017-02-14 22:00:14 +00:00
|
|
|
/* wrapper to __mount() and expects a fully prepared fstab_rec,
|
|
|
|
* unlike fs_mgr_do_mount which does more things with avb / verity
|
|
|
|
* etc.
|
|
|
|
*/
|
|
|
|
int fs_mgr_do_mount_one(struct fstab_rec *rec)
|
|
|
|
{
|
|
|
|
if (!rec) {
|
|
|
|
return FS_MGR_DOMNT_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ret = __mount(rec->blk_device, rec->mount_point, rec);
|
|
|
|
if (ret) {
|
|
|
|
ret = (errno == EBUSY) ? FS_MGR_DOMNT_BUSY : FS_MGR_DOMNT_FAILED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-02-13 20:58:40 +00:00
|
|
|
/* If tmp_mount_point is non-null, mount the filesystem there. This is for the
|
2012-01-07 03:09:42 +00:00
|
|
|
* tmp mount we do to check the user password
|
2014-06-18 21:54:37 +00:00
|
|
|
* If multiple fstab entries are to be mounted on "n_name", it will try to mount each one
|
|
|
|
* in turn, and stop on 1st success, or no more match.
|
2012-01-07 03:09:42 +00:00
|
|
|
*/
|
2016-11-03 20:36:35 +00:00
|
|
|
int fs_mgr_do_mount(struct fstab *fstab, const char *n_name, char *n_blk_device,
|
2013-02-13 20:58:40 +00:00
|
|
|
char *tmp_mount_point)
|
2012-01-07 03:09:42 +00:00
|
|
|
{
|
|
|
|
int i = 0;
|
2014-09-09 17:44:51 +00:00
|
|
|
int ret = FS_MGR_DOMNT_FAILED;
|
2014-06-18 21:54:37 +00:00
|
|
|
int mount_errors = 0;
|
|
|
|
int first_mount_errno = 0;
|
2012-01-07 03:09:42 +00:00
|
|
|
char *m;
|
2017-03-30 10:42:54 +00:00
|
|
|
FsManagerAvbUniquePtr avb_handle(nullptr);
|
2012-01-07 03:09:42 +00:00
|
|
|
|
2013-02-13 20:58:40 +00:00
|
|
|
if (!fstab) {
|
2012-01-07 03:09:42 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-02-13 20:58:40 +00:00
|
|
|
for (i = 0; i < fstab->num_entries; i++) {
|
|
|
|
if (!fs_match(fstab->recs[i].mount_point, n_name)) {
|
2012-01-07 03:09:42 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We found our match */
|
2013-07-09 02:11:55 +00:00
|
|
|
/* If this swap or a raw partition, report an error */
|
|
|
|
if (!strcmp(fstab->recs[i].fs_type, "swap") ||
|
|
|
|
!strcmp(fstab->recs[i].fs_type, "emmc") ||
|
2013-02-13 20:58:40 +00:00
|
|
|
!strcmp(fstab->recs[i].fs_type, "mtd")) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Cannot mount filesystem of type "
|
|
|
|
<< fstab->recs[i].fs_type << " on " << n_blk_device;
|
2013-02-13 20:58:40 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2012-01-07 03:09:42 +00:00
|
|
|
/* First check the filesystem if requested */
|
2013-02-13 20:58:40 +00:00
|
|
|
if (fstab->recs[i].fs_mgr_flags & MF_WAIT) {
|
|
|
|
wait_for_file(n_blk_device, WAIT_TIMEOUT);
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
|
|
|
|
2017-03-02 22:33:04 +00:00
|
|
|
int fs_stat = 0;
|
|
|
|
int force_check = do_quota_with_shutdown_check(fstab->recs[i].blk_device,
|
|
|
|
fstab->recs[i].fs_type,
|
|
|
|
&fstab->recs[i], &fs_stat);
|
2016-12-14 19:00:51 +00:00
|
|
|
|
|
|
|
if ((fstab->recs[i].fs_mgr_flags & MF_CHECK) || force_check) {
|
2013-02-13 20:58:40 +00:00
|
|
|
check_fs(n_blk_device, fstab->recs[i].fs_type,
|
2017-03-02 22:33:04 +00:00
|
|
|
fstab->recs[i].mount_point, &fs_stat);
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
|
|
|
|
2016-07-22 03:48:14 +00:00
|
|
|
if (fstab->recs[i].fs_mgr_flags & MF_RESERVEDSIZE) {
|
2017-03-02 22:33:04 +00:00
|
|
|
do_reserved_size(n_blk_device, fstab->recs[i].fs_type, &fstab->recs[i], &fs_stat);
|
2016-07-22 03:48:14 +00:00
|
|
|
}
|
|
|
|
|
2017-03-30 10:42:54 +00:00
|
|
|
if (fstab->recs[i].fs_mgr_flags & MF_AVB) {
|
|
|
|
if (!avb_handle) {
|
|
|
|
avb_handle = FsManagerAvbHandle::Open(extract_by_name_prefix(fstab));
|
|
|
|
if (!avb_handle) {
|
|
|
|
LERROR << "Failed to open FsManagerAvbHandle";
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!avb_handle->SetUpAvb(&fstab->recs[i])) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Failed to set up AVB on partition: "
|
|
|
|
<< fstab->recs[i].mount_point << ", skipping!";
|
2017-01-11 14:21:38 +00:00
|
|
|
/* Skips mounting the device. */
|
|
|
|
continue;
|
|
|
|
}
|
2017-02-27 19:33:46 +00:00
|
|
|
} else if ((fstab->recs[i].fs_mgr_flags & MF_VERIFY) && is_device_secure()) {
|
2016-12-16 07:00:05 +00:00
|
|
|
int rc = fs_mgr_setup_verity(&fstab->recs[i], true);
|
2016-03-29 21:25:11 +00:00
|
|
|
if (__android_log_is_debuggable() && rc == FS_MGR_SETUP_VERITY_DISABLED) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LINFO << "Verity disabled";
|
2014-10-09 14:22:49 +00:00
|
|
|
} else if (rc != FS_MGR_SETUP_VERITY_SUCCESS) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Could not set up verified partition, skipping!";
|
2013-02-23 02:11:41 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-07 03:09:42 +00:00
|
|
|
/* Now mount it where requested */
|
2013-02-13 20:58:40 +00:00
|
|
|
if (tmp_mount_point) {
|
|
|
|
m = tmp_mount_point;
|
2012-01-07 03:09:42 +00:00
|
|
|
} else {
|
2013-02-13 20:58:40 +00:00
|
|
|
m = fstab->recs[i].mount_point;
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
2014-06-18 21:54:37 +00:00
|
|
|
if (__mount(n_blk_device, m, &fstab->recs[i])) {
|
|
|
|
if (!first_mount_errno) first_mount_errno = errno;
|
|
|
|
mount_errors++;
|
2017-03-02 22:33:04 +00:00
|
|
|
fs_stat |= FS_STAT_FULL_MOUNT_FAILED;
|
|
|
|
log_fs_stat(fstab->recs[i].blk_device, fs_stat);
|
2014-06-18 21:54:37 +00:00
|
|
|
continue;
|
2012-01-07 03:09:42 +00:00
|
|
|
} else {
|
|
|
|
ret = 0;
|
2017-03-02 22:33:04 +00:00
|
|
|
log_fs_stat(fstab->recs[i].blk_device, fs_stat);
|
2012-01-07 03:09:42 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
2014-06-18 21:54:37 +00:00
|
|
|
if (mount_errors) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
PERROR << "Cannot mount filesystem on " << n_blk_device
|
|
|
|
<< " at " << m;
|
2014-09-09 17:44:51 +00:00
|
|
|
if (first_mount_errno == EBUSY) {
|
|
|
|
ret = FS_MGR_DOMNT_BUSY;
|
|
|
|
} else {
|
|
|
|
ret = FS_MGR_DOMNT_FAILED;
|
|
|
|
}
|
2014-06-18 21:54:37 +00:00
|
|
|
} else {
|
|
|
|
/* We didn't find a match, say so and return an error */
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Cannot find mount point " << fstab->recs[i].mount_point
|
|
|
|
<< " in fstab";
|
2014-06-18 21:54:37 +00:00
|
|
|
}
|
2012-01-07 03:09:42 +00:00
|
|
|
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* mount a tmpfs filesystem at the given point.
|
|
|
|
* return 0 on success, non-zero on failure.
|
|
|
|
*/
|
2017-02-25 01:41:38 +00:00
|
|
|
int fs_mgr_do_tmpfs_mount(const char *n_name)
|
2012-01-07 03:09:42 +00:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = mount("tmpfs", n_name, "tmpfs",
|
|
|
|
MS_NOATIME | MS_NOSUID | MS_NODEV, CRYPTO_TMPFS_OPTIONS);
|
|
|
|
if (ret < 0) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Cannot mount tmpfs filesystem at " << n_name;
|
2012-01-07 03:09:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Success */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-13 20:58:40 +00:00
|
|
|
int fs_mgr_unmount_all(struct fstab *fstab)
|
2012-01-07 03:09:42 +00:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
int ret = 0;
|
|
|
|
|
2013-02-13 20:58:40 +00:00
|
|
|
if (!fstab) {
|
2012-01-07 03:09:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-02-13 20:58:40 +00:00
|
|
|
while (fstab->recs[i].blk_device) {
|
|
|
|
if (umount(fstab->recs[i].mount_point)) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Cannot unmount filesystem at "
|
|
|
|
<< fstab->recs[i].mount_point;
|
2012-01-07 03:09:42 +00:00
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2013-07-09 02:11:55 +00:00
|
|
|
|
|
|
|
/* This must be called after mount_all, because the mkswap command needs to be
|
|
|
|
* available.
|
|
|
|
*/
|
|
|
|
int fs_mgr_swapon_all(struct fstab *fstab)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
int flags = 0;
|
|
|
|
int err = 0;
|
|
|
|
int ret = 0;
|
|
|
|
int status;
|
2017-01-16 13:49:49 +00:00
|
|
|
const char *mkswap_argv[2] = {
|
2013-07-09 02:11:55 +00:00
|
|
|
MKSWAP_BIN,
|
2017-01-16 13:49:49 +00:00
|
|
|
nullptr
|
2013-07-09 02:11:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (!fstab) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < fstab->num_entries; i++) {
|
|
|
|
/* Skip non-swap entries */
|
|
|
|
if (strcmp(fstab->recs[i].fs_type, "swap")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fstab->recs[i].zram_size > 0) {
|
|
|
|
/* A zram_size was specified, so we need to configure the
|
|
|
|
* device. There is no point in having multiple zram devices
|
|
|
|
* on a system (all the memory comes from the same pool) so
|
|
|
|
* we can assume the device number is 0.
|
|
|
|
*/
|
|
|
|
FILE *zram_fp;
|
2016-08-26 13:09:35 +00:00
|
|
|
FILE *zram_mcs_fp;
|
|
|
|
|
|
|
|
if (fstab->recs[i].max_comp_streams >= 0) {
|
|
|
|
zram_mcs_fp = fopen(ZRAM_CONF_MCS, "r+");
|
|
|
|
if (zram_mcs_fp == NULL) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Unable to open zram conf comp device "
|
|
|
|
<< ZRAM_CONF_MCS;
|
2016-08-26 13:09:35 +00:00
|
|
|
ret = -1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
fprintf(zram_mcs_fp, "%d\n", fstab->recs[i].max_comp_streams);
|
|
|
|
fclose(zram_mcs_fp);
|
|
|
|
}
|
2013-07-09 02:11:55 +00:00
|
|
|
|
|
|
|
zram_fp = fopen(ZRAM_CONF_DEV, "r+");
|
|
|
|
if (zram_fp == NULL) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "Unable to open zram conf device " << ZRAM_CONF_DEV;
|
2013-07-09 02:11:55 +00:00
|
|
|
ret = -1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
fprintf(zram_fp, "%d\n", fstab->recs[i].zram_size);
|
|
|
|
fclose(zram_fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fstab->recs[i].fs_mgr_flags & MF_WAIT) {
|
|
|
|
wait_for_file(fstab->recs[i].blk_device, WAIT_TIMEOUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the swap area */
|
|
|
|
mkswap_argv[1] = fstab->recs[i].blk_device;
|
2017-01-16 13:49:49 +00:00
|
|
|
err = android_fork_execvp_ext(ARRAY_SIZE(mkswap_argv),
|
|
|
|
const_cast<char **>(mkswap_argv),
|
2015-08-14 08:22:53 +00:00
|
|
|
&status, true, LOG_KLOG, false, NULL,
|
|
|
|
NULL, 0);
|
2013-07-09 02:11:55 +00:00
|
|
|
if (err) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "mkswap failed for " << fstab->recs[i].blk_device;
|
2013-07-09 02:11:55 +00:00
|
|
|
ret = -1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If -1, then no priority was specified in fstab, so don't set
|
|
|
|
* SWAP_FLAG_PREFER or encode the priority */
|
|
|
|
if (fstab->recs[i].swap_prio >= 0) {
|
|
|
|
flags = (fstab->recs[i].swap_prio << SWAP_FLAG_PRIO_SHIFT) &
|
|
|
|
SWAP_FLAG_PRIO_MASK;
|
|
|
|
flags |= SWAP_FLAG_PREFER;
|
|
|
|
} else {
|
|
|
|
flags = 0;
|
|
|
|
}
|
|
|
|
err = swapon(fstab->recs[i].blk_device, flags);
|
|
|
|
if (err) {
|
fs_mgr: Switch to LOG()/PLOG() defined in <android-base/logging.h>
This is the minimal change just to replace KLOG_{INFO, WARNING, ERROR}
defined in <cutils/klog.h> to LOG()/PLOG() defined in
<android-base/logging.h>.
The logging.h uses program invocation name as the tag when logging.
e.g., init logs will have "init: ..." at the beginning in each line.
To facilitate debugging, this commit adds [libfs_mgr] after the tag,
and the resulting output will like this:
[ 11.278002] init: [libfs_mgr]Enabling dm-verity for system (mode 2)
[ 11.283309] init: [libfs_mgr]loading verity table: '1 /dev/block/platform/soc.0/f9824900.sdhci/by-name/system ...'
[ 11.337884] init: [libfs_mgr]Not running /system/bin/tune2fs on /dev/block/dm-0 (executable not in system image)
[ 11.362281] init: [libfs_mgr]__mount(source=/dev/block/dm-0,target=/system,type=ext4)=0
[ 11.376331] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor
[ 11.398237] init: [libfs_mgr]__mount(source=/dev/block/platform/soc.0/f9824900.sdhci/by-name/vendor,target=/vendor,type=ext4)=0
[ 11.410735] init: [libfs_mgr]Requested quota status is match on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
[ 11.426783] init: [libfs_mgr]check_fs(): mount(/dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata,/data,ext4)=-1: Invalid argument
[ 11.439154] init: [libfs_mgr]Running /system/bin/e2fsck on /dev/block/platform/soc.0/f9824900.sdhci/by-name/userdata
Bug: 34336098
Test: check device can boot
Change-Id: Idcbaca1050e2d8eabe1e4510a0af03aa0312d03a
2017-01-23 06:04:34 +00:00
|
|
|
LERROR << "swapon failed for " << fstab->recs[i].blk_device;
|
2013-07-09 02:11:55 +00:00
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-01-07 03:09:42 +00:00
|
|
|
/*
|
|
|
|
* key_loc must be at least PROPERTY_VALUE_MAX bytes long
|
|
|
|
*
|
2013-02-13 20:58:40 +00:00
|
|
|
* real_blk_device must be at least PROPERTY_VALUE_MAX bytes long
|
2012-01-07 03:09:42 +00:00
|
|
|
*/
|
2013-02-13 20:58:40 +00:00
|
|
|
int fs_mgr_get_crypt_info(struct fstab *fstab, char *key_loc, char *real_blk_device, int size)
|
2012-01-07 03:09:42 +00:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
2013-02-13 20:58:40 +00:00
|
|
|
if (!fstab) {
|
2012-01-07 03:09:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Initialize return values to null strings */
|
|
|
|
if (key_loc) {
|
|
|
|
*key_loc = '\0';
|
|
|
|
}
|
2013-02-13 20:58:40 +00:00
|
|
|
if (real_blk_device) {
|
|
|
|
*real_blk_device = '\0';
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Look for the encryptable partition to find the data */
|
2013-02-13 20:58:40 +00:00
|
|
|
for (i = 0; i < fstab->num_entries; i++) {
|
|
|
|
/* Don't deal with vold managed enryptable partitions here */
|
|
|
|
if (fstab->recs[i].fs_mgr_flags & MF_VOLDMANAGED) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-10-29 17:31:02 +00:00
|
|
|
if (!(fstab->recs[i].fs_mgr_flags
|
|
|
|
& (MF_CRYPT | MF_FORCECRYPT | MF_FORCEFDEORFBE))) {
|
2012-01-07 03:09:42 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We found a match */
|
|
|
|
if (key_loc) {
|
2013-02-13 20:58:40 +00:00
|
|
|
strlcpy(key_loc, fstab->recs[i].key_loc, size);
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
2013-02-13 20:58:40 +00:00
|
|
|
if (real_blk_device) {
|
|
|
|
strlcpy(real_blk_device, fstab->recs[i].blk_device, size);
|
2012-01-07 03:09:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|