return OK;
}
-void Disk::createPublicVolume(dev_t device) {
- auto vol = std::shared_ptr<VolumeBase>(new PublicVolume(device));
+void Disk::createPublicVolume(dev_t device,
+ const std::string& fstype /* = "" */,
+ const std::string& mntopts /* = "" */) {
+ auto vol = std::shared_ptr<VolumeBase>(new PublicVolume(device, fstype, mntopts));
if (mJustPartitioned) {
LOG(DEBUG) << "Device just partitioned; silently formatting";
vol->setSilent(true);
/* Flag that we just partitioned and should format all volumes */
bool mJustPartitioned;
- void createPublicVolume(dev_t device);
+ void createPublicVolume(dev_t device,
+ const std::string& fstype = "",
+ const std::string& mntopts = "");
void createPrivateVolume(dev_t device, const std::string& partGuid);
void destroyAllVolumes();
namespace vold {
DiskPartition::DiskPartition(const std::string& eventPath, dev_t device,
- const std::string& nickname, int flags, int partnum) :
+ const std::string& nickname, int flags, int partnum,
+ const std::string& fstype /* = "" */, const std::string& mntopts /* = "" */) :
Disk(eventPath, device, nickname, flags),
- mPartNum(partnum) {
+ mPartNum(partnum),
+ mFsType(fstype),
+ mMntOpts(mntopts) {
// Empty
}
mCreated = true;
notifyEvent(ResponseCode::DiskCreated, StringPrintf("%d", mFlags));
dev_t partDevice = makedev(major(mDevice), minor(mDevice) + mPartNum);
- createPublicVolume(partDevice);
+ createPublicVolume(partDevice, mFsType, mMntOpts);
return OK;
}
public:
DiskPartition(const std::string& eventPath, dev_t device,
const std::string& nickname,
- int flags, int partnum);
+ int flags, int partnum,
+ const std::string& fstype = "", const std::string& mntopts = "");
virtual ~DiskPartition();
virtual status_t create();
private:
/* Partition number */
int mPartNum;
+ /* Filesystem type */
+ std::string mFsType;
+ /* Mount options */
+ std::string mMntOpts;
};
} // namespace vold
static const char* kAsecPath = "/mnt/secure/asec";
-PublicVolume::PublicVolume(dev_t device) :
- VolumeBase(Type::kPublic), mDevice(device), mFusePid(0) {
+PublicVolume::PublicVolume(dev_t device, const std::string& fstype /* = "" */,
+ const std::string& mntopts /* = "" */) :
+ VolumeBase(Type::kPublic), mDevice(device), mFusePid(0),
+ mFsType(fstype), mMntOpts(mntopts) {
setId(StringPrintf("public:%u,%u", major(device), minor(device)));
mDevPath = StringPrintf("/dev/block/vold/%s", getId().c_str());
}
ret = exfat::Mount(mDevPath, mRawPath, false, false, false,
AID_MEDIA_RW, AID_MEDIA_RW, 0007);
} else if (mFsType == "ext4") {
- ret = ext4::Mount(mDevPath, mRawPath, false, false, true);
+ ret = ext4::Mount(mDevPath, mRawPath, false, false, true, mMntOpts);
} else if (mFsType == "f2fs") {
ret = f2fs::Mount(mDevPath, mRawPath);
} else if (mFsType == "ntfs") {
*/
class PublicVolume : public VolumeBase {
public:
- explicit PublicVolume(dev_t device);
+ PublicVolume(dev_t device, const std::string& mntopts = "",
+ const std::string& fstype = "");
virtual ~PublicVolume();
protected:
std::string mFsUuid;
/* User-visible filesystem label */
std::string mFsLabel;
+ /* Mount options */
+ std::string mMntOpts;
DISALLOW_COPY_AND_ASSIGN(PublicVolume);
};
source->getNickname(), flags) :
new android::vold::DiskPartition(eventPath, device,
source->getNickname(), flags,
- source->getPartNum());
+ source->getPartNum(),
+ source->getFsType(), source->getMntOpts());
disk->create();
mDisks.push_back(std::shared_ptr<android::vold::Disk>(disk));
break;
class DiskSource {
public:
- DiskSource(const std::string& sysPattern, const std::string& nickname, int partnum, int flags) :
- mSysPattern(sysPattern), mNickname(nickname), mPartNum(partnum), mFlags(flags) {
+ DiskSource(const std::string& sysPattern, const std::string& nickname,
+ int partnum, int flags,
+ const std::string& fstype, const std::string mntopts) :
+ mSysPattern(sysPattern), mNickname(nickname),
+ mPartNum(partnum), mFlags(flags),
+ mFsType(fstype), mMntOpts(mntopts) {
}
bool matches(const std::string& sysPath) {
const std::string& getNickname() { return mNickname; }
int getPartNum() { return mPartNum; }
int getFlags() { return mFlags; }
+ const std::string& getFsType() { return mFsType; }
+ const std::string& getMntOpts() { return mMntOpts; }
private:
std::string mSysPattern;
std::string mNickname;
int mPartNum;
int mFlags;
+ std::string mFsType;
+ std::string mMntOpts;
};
void addDiskSource(const std::shared_ptr<DiskSource>& diskSource);
}
status_t Mount(const std::string& source, const std::string& target, bool ro,
- bool remount, bool executable) {
+ bool remount, bool executable, const std::string& opts /* = "" */) {
int rc;
unsigned long flags;
const char* c_source = source.c_str();
const char* c_target = target.c_str();
+ const char* c_opts = opts.c_str();
flags = MS_NOATIME | MS_NODEV | MS_NOSUID | MS_DIRSYNC;
flags |= (ro ? MS_RDONLY : 0);
flags |= (remount ? MS_REMOUNT : 0);
- rc = mount(c_source, c_target, "ext4", flags, NULL);
+ rc = mount(c_source, c_target, "ext4", flags, c_opts);
if (rc && errno == EROFS) {
SLOGE("%s appears to be a read only filesystem - retrying mount RO", c_source);
status_t Check(const std::string& source, const std::string& target, bool trusted);
status_t Mount(const std::string& source, const std::string& target, bool ro,
- bool remount, bool executable);
+ bool remount, bool executable, const std::string& opts = "");
status_t Format(const std::string& source, unsigned long numSectors,
const std::string& target);
status_t Resize(const std::string& source, unsigned long numSectors);
for (int i = 0; i < fstab->num_entries; i++) {
if (fs_mgr_is_voldmanaged(&fstab->recs[i])) {
std::string sysPattern(fstab->recs[i].blk_device);
+ std::string fstype;
+ if (fstab->recs[i].fs_type) {
+ fstype = fstab->recs[i].fs_type;
+ }
+ std::string mntopts;
+ if (fstab->recs[i].fs_options) {
+ mntopts = fstab->recs[i].fs_options;
+ }
std::string nickname(fstab->recs[i].label);
int partnum = fstab->recs[i].partnum;
int flags = 0;
}
vm->addDiskSource(std::shared_ptr<VolumeManager::DiskSource>(
- new VolumeManager::DiskSource(sysPattern, nickname, partnum, flags)));
+ new VolumeManager::DiskSource(sysPattern, nickname, partnum, flags,
+ fstype, mntopts)));
}
}
return 0;