ok,再往上就是volume manager了,这篇不关心。这个问题format失败的原因是No such device,来看下vol->create():
status_tPrivateVolume::doCreate(){ if (CreateDeviceNode(mRawDevPath, mRawDevice)) { return -EIO; } if (mKeyRaw.size() != cryptfs_get_keysize()) { PLOG(ERROR) << getId() << " Raw keysize " << mKeyRaw.size() << " does not match crypt keysize " << cryptfs_get_keysize(); return -EIO; }
// Recover from stale vold by tearing down any old mappings cryptfs_revert_ext_volume(getId().c_str());
// TODO: figure out better SELinux labels for private volumes
unsignedchar* key = (unsignedchar*) mKeyRaw.data(); char crypto_blkdev[MAXPATHLEN]; int res = cryptfs_setup_ext_volume(getId().c_str(), mRawDevPath.c_str(), key, crypto_blkdev); mDmDevPath = crypto_blkdev; if (res != 0) { PLOG(ERROR) << getId() << " failed to setup cryptfs"; return -EIO; }
return OK; }
vold先删掉这个外部设备(private:179,66):
/* * Called by vold when it's asked to unmount an encrypted external * storage volume. */ intcryptfs_revert_ext_volume(constchar* label){ returndelete_crypto_blk_dev((char*) label); }
/* * Called by vold when it's asked to mount an encrypted external * storage volume. The incoming partition has no crypto header/footer, * as any metadata is been stored in a separate, small partition. We * assume it must be using our same crypt type and keysize. * * out_crypto_blkdev must be MAXPATHLEN. */ intcryptfs_setup_ext_volume(constchar* label, constchar* real_blkdev, constunsignedchar* key, char* out_crypto_blkdev){ ... returncreate_crypto_blk_dev(&ext_crypt_ftr, key, real_blkdev, out_crypto_blkdev, label, flags); }
11-03 15:48:22.629 485 488 I Cryptfs : real_blk_name = /dev/block/vold/private:179,66, extra_params = 11-03 15:48:22.657 485 488 E vold : private:179,66 failed to format: No such device or address //tj: here
It can sometimes take a moment for the dm-device to appear after creation, causing operations on it such as formatting to fail. Ensure the device exists before create_crypto_blk_dev returns.
Test: adb sm set-virtual-disk true and format as adoptable. Bug: 117586466 Change-Id: Id8f571b551f50fc759e78d917e4ac3080e926722 Merged-In: Id8f571b551f50fc759e78d917e4ac3080e926722
ok,合入后还是看不到SD卡,不过format正常了:
I make_f2fs: Info: format successful
你说是不是坑。继续看log,发现有如下错误:
11-26 04:13:35.941 510 1686 E cutils : Failed to chown(/mnt/expand/0f64cdaf-640b-4a01-9432-03a80985bcdf, 0, 0): I/O error 11-26 04:13:35.926 0 0 E goodix_fp soc: fpsensor: Selected 'fpsensor_reset_active' 11-26 04:13:35.931 0 0 W gf : gf_ioctl, exit 11-26 04:13:35.948 0 0 E : Quota error (device dm-1): qtree_read_dquot: Can't read quota structure for id 0 11-26 04:13:35.941 510 1686 E vold : private:179,66 failed to create mount point /mnt/expand/0f64cdaf-640b-4a01-9432-03a80985bcdf: I/O error