int Volume::formatVol() { if (getState() == Volume::State_NoMedia) { errno = ENODEV; return -1; } else if (getState() != Volume::State_Idle) { errno = EBUSY; return -1; } if (isMountpointMounted(getMountpoint())) { SLOGW("Volume is idle but appears to be mounted - fixing"); setState(Volume::State_Mounted); // mCurrentlyMountedKdev = XXX errno = EBUSY; return -1; } bool formatEntireDevice = (mPartIdx == -1); char devicePath[255]; dev_t diskNode = getDiskDevice(); dev_t partNode = MKDEV(MAJOR(diskNode), (formatEntireDevice ? 1 : mPartIdx)); setState(Volume::State_Formatting); int ret = -1; // Only initialize the MBR if we are formatting the entire device if (formatEntireDevice) { sprintf(devicePath, "/dev/block/vold/%d:%d", MAJOR(diskNode), MINOR(diskNode)); if (initializeMbr(devicePath)) { SLOGE("Failed to initialize MBR (%s)", strerror(errno)); goto err; } } sprintf(devicePath, "/dev/block/vold/%d:%d", MAJOR(partNode), MINOR(partNode)); if (mDebug) { SLOGI("Formatting volume %s (%s)", getLabel(), devicePath); } if (Fat::format(devicePath, 0)) { SLOGE("Failed to format (%s)", strerror(errno)); goto err; } ret = 0; err: setState(Volume::State_Idle); return ret; }
int Volume::formatVol() { if (getState() == Volume::State_NoMedia) { errno = ENODEV; return -1; } else if (getState() != Volume::State_Idle) { errno = EBUSY; return -1; } if (isMountpointMounted(getMountpoint())) { SLOGW("Volume is idle but appears to be mounted - fixing"); setState(Volume::State_Mounted); // mCurrentlyMountedKdev = XXX errno = EBUSY; return -1; } char devicePath[255]; dev_t diskNode = getDiskDevice(); dev_t partNode = MKDEV(MAJOR(diskNode), 1); // XXX: Hmmm sprintf(devicePath, "/dev/block/vold/%d:%d", MAJOR(diskNode), MINOR(diskNode)); if (mDebug) { SLOGI("Formatting volume %s (%s)", getLabel(), devicePath); } setState(Volume::State_Formatting); if (initializeMbr(devicePath)) { SLOGE("Failed to initialize MBR (%s)", strerror(errno)); goto err; } sprintf(devicePath, "/dev/block/vold/%d:%d", MAJOR(partNode), MINOR(partNode)); if (Fat::format(devicePath, 0)) { SLOGE("Failed to format (%s)", strerror(errno)); goto err; } setState(Volume::State_Idle); return 0; err: return -1; }
int Volume::formatVol() { if (getState() == Volume::State_NoMedia) { errno = ENODEV; return -1; } else if (getState() != Volume::State_Idle) { errno = EBUSY; return -1; } if (isMountpointMounted(getMountpoint())) { SLOGW("Volume is idle but appears to be mounted - fixing"); setState(Volume::State_Mounted); // mCurrentlyMountedKdev = XXX errno = EBUSY; return -1; } bool formatEntireDevice = (mPartIdx == -1); char devicePath[255]; dev_t diskNode = getDiskDevice(); dev_t partNode = MKDEV(MAJOR(diskNode), (formatEntireDevice ? 1 : mPartIdx)); setState(Volume::State_Formatting); int ret = -1; // Only initialize the MBR if we are formatting the entire device if (formatEntireDevice) { sprintf(devicePath, "/dev/block/vold/%d:%d", MAJOR(diskNode), MINOR(diskNode)); if (initializeMbr(devicePath)) { SLOGE("Failed to initialize MBR (%s)", strerror(errno)); goto err; } } sprintf(devicePath, "/dev/block/vold/%d:%d", MAJOR(partNode), MINOR(partNode)); #ifdef VOLD_EMMC_SHARES_DEV_MAJOR // If emmc and sdcard share dev major number, vold may pick // incorrectly based on partition nodes alone, formatting // the wrong device. Use device nodes instead. dev_t deviceNodes; getDeviceNodes((dev_t *) &deviceNodes, 1); sprintf(devicePath, "/dev/block/vold/%d:%d", MAJOR(deviceNodes), MINOR(deviceNodes)); #endif if (mDebug) { SLOGI("Formatting volume %s (%s)", getLabel(), devicePath); } if (Fat::format(devicePath, 0)) { SLOGE("Failed to format (%s)", strerror(errno)); goto err; } ret = 0; err: setState(Volume::State_Idle); return ret; }
dev_t Volume::getShareDevice() { return getDiskDevice(); }
int Volume::formatVol() { dev_t deviceNodes[MAX_SUP_PART]; int part_num; if (getState() == Volume::State_NoMedia) { errno = ENODEV; return -1; } else if (getState() != Volume::State_Idle) { errno = EBUSY; return -1; } if (isMountpointMounted(getMountpoint())) { SLOGW("Volume is idle but appears to be mounted - fixing"); setState(Volume::State_Mounted); // mCurrentlyMountedKdev = XXX errno = EBUSY; return -1; } bool formatEntireDevice = ((mPartIdx == -1) && (0 != getDeviceNumParts())); char devicePath[255]; dev_t diskNode = getDiskDevice(); //dev_t partNode = MKDEV(MAJOR(diskNode), (formatEntireDevice ? 1 : mPartIdx)); //part_num reserved for mutiple partition support // getDeviceNodes((dev_t *) &deviceNodes, MAX_SUP_PART); part_num = 1; dev_t partNode = deviceNodes[part_num - 1]; setState(Volume::State_Formatting); int ret = -1; // Only initialize the MBR if we are formatting the entire device if (formatEntireDevice) { sprintf(devicePath, "/dev/block/vold/%d:%d", MAJOR(diskNode), MINOR(diskNode)); SLOGI("mDiskNumParts = %d\n", getDeviceNumParts()); if (initializeMbr(devicePath)) { SLOGE("Failed to initialize MBR (%s)", strerror(errno)); goto err; } } sprintf(devicePath, "/dev/block/vold/%d:%d", MAJOR(partNode), MINOR(partNode)); SLOGI("mDiskNumParts = %d\n", getDeviceNumParts()); if (mDebug) { SLOGI("Formatting volume %s (%s)", getLabel(), devicePath); } if (Fat::format(devicePath, 0)) { SLOGE("Failed to format (%s)", strerror(errno)); goto err; } ret = 0; err: setState(Volume::State_Idle); return ret; }
int Volume::formatVol(bool wipe) { dev_t deviceNodes[DirectVolume::MAX_PARTITIONS]; bool isForceFat32 = false; if (getState() == Volume::State_NoMedia) { errno = ENODEV; return -1; } else if (getState() != Volume::State_Idle) { errno = EBUSY; return -1; } #ifdef MTK_SHARED_SDCARD if(IsEmmcStorage()){ SLOGE("It is not allowed to format internal SDCARD with MTK_SHARED_SDCARD enabled"); errno = -EPERM; return errno; } #endif if (isMountpointMounted(getMountpoint())) { SLOGW("Volume is idle but appears to be mounted - fixing"); setState(Volume::State_Mounted); // mCurrentlyMountedKdev = XXX errno = EBUSY; return -1; } SLOGI("mDiskNumParts = %d\n", getDeviceNumParts()); bool formatEntireDevice = (mPartIdx == -1); char devicePath[255]; dev_t diskNode = getDiskDevice(); dev_t partNode = MKDEV(MAJOR(diskNode), MINOR(diskNode) + (formatEntireDevice ? 1 : mPartIdx)); setState(Volume::State_Formatting); int ret = -1; #ifdef MTK_MULTI_PARTITION_MOUNT_ONLY_SUPPORT char *otgNodePath = getOtgNodePath(); if (0 == strcmp(getLabel(), "usbotg")) { if (NULL == otgNodePath) { SLOGE("usbotg: Volume formatVol otgNodePath is NULL"); goto err; } SLOGD("usbotg: Volume formatVol otgNodePath = %s", otgNodePath); // Only initialize the MBR if we are formatting the entire device if (formatEntireDevice) { SLOGI("usbotg: Volume formatVol call initializeMbr().\n"); if (initializeMbr(otgNodePath)) { SLOGE("usbotg: Volume formatVol failed to initialize MBR (%s)", strerror(errno)); goto err; } SLOGI("usbotg: Volume formatVol exit initializeMbr().\n"); } if (Fat::format(otgNodePath, 0, wipe, isForceFat32)) { SLOGE("usbotg: Volume formatVol Failed to format (%s)", strerror(errno)); goto err; } } else { // Only initialize the MBR if we are formatting the entire device if (formatEntireDevice) { sprintf(devicePath, "/dev/block/vold/%d:%d", major(diskNode), minor(diskNode)); SLOGI("Call initializeMbr().\n"); if (initializeMbr(devicePath)) { SLOGE("Failed to initialize MBR (%s)", strerror(errno)); goto err; } SLOGI("Exit initializeMbr().\n"); } sprintf(devicePath, "/dev/block/vold/%d:%d", major(partNode), minor(partNode)); if (mDebug) { SLOGI("Formatting volume %s (%s)", getLabel(), devicePath); } #ifdef MTK_ICUSB_SUPPORT if(!strcmp(getLabel(), "icusb1") || !strcmp(getLabel(), "icusb2")){ isForceFat32 = true; } #endif if (Fat::format(devicePath, 0, wipe, isForceFat32)) { SLOGE("Failed to format (%s)", strerror(errno)); goto err; } } #else { // Only initialize the MBR if we are formatting the entire device if (formatEntireDevice) { sprintf(devicePath, "/dev/block/vold/%d:%d", major(diskNode), minor(diskNode)); SLOGI("Call initializeMbr().\n"); if (initializeMbr(devicePath)) { SLOGE("Failed to initialize MBR (%s)", strerror(errno)); goto err; } } sprintf(devicePath, "/dev/block/vold/%d:%d", major(partNode), minor(partNode)); if (mDebug) { SLOGI("Formatting volume %s (%s)", getLabel(), devicePath); } #ifdef MTK_ICUSB_SUPPORT if(!strcmp(getLabel(), "icusb1") || !strcmp(getLabel(), "icusb2")){ isForceFat32 = true; } #endif if (Fat::format(devicePath, 0, wipe, isForceFat32)) { SLOGE("Failed to format (%s)", strerror(errno)); goto err; } } #endif ret = 0; err: setState(Volume::State_Idle); return ret; }