Add RFS format support
Change-Id: Ifd1e5ce9875c3eaacc1cec1759b67e672894e279
This commit is contained in:
parent
890b951a3d
commit
a8f265dd6f
@ -171,3 +171,37 @@ int cmd_bml_get_partition_device(const char *partition, char *device)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int run_exec_process ( char **argv);
|
||||
|
||||
int format_rfs_device (const char *device, const char *path) {
|
||||
const char *fatsize = "32";
|
||||
const char *sectorsize = "1";
|
||||
|
||||
if (strcmp(path, "/datadata") == 0 || strcmp(path, "/cache") == 0) {
|
||||
fatsize = "16";
|
||||
}
|
||||
|
||||
// Just in case /data sector size needs to be altered
|
||||
else if (strcmp(path, "/data") == 0 ) {
|
||||
sectorsize = "1";
|
||||
}
|
||||
|
||||
// dump 10KB of zeros to partition before format due to fat.format bug
|
||||
char ofdevice[PATH_MAX];
|
||||
snprintf(ofdevice, sizeof(ofdevice), "of=%s", device);
|
||||
const char *rfszerodump[] = {"/sbin/dd", "if=/dev/zero", ofdevice, "bs=4096", "count=10", NULL};
|
||||
if(run_exec_process((char **)rfszerodump)) {
|
||||
printf("failure while running rfszerodump\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Run fat.format
|
||||
const char *fatformat[] = {"/sbin/fat.format", "-F", fatsize, "-S", "4096", "-s", sectorsize, device, NULL};
|
||||
if(run_exec_process((char **)fatformat)) {
|
||||
printf("failure while running fat.format\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
6
bmlutils/bmlutils.h
Normal file
6
bmlutils/bmlutils.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef BMLUTILS_H_
|
||||
#define BMLUTILS_H_
|
||||
|
||||
int format_rfs_device (const char *device, const char *path);
|
||||
|
||||
#endif // BMLUTILS_H_
|
@ -41,6 +41,7 @@
|
||||
#include "edify/expr.h"
|
||||
#include <libgen.h>
|
||||
#include "mtdutils/mtdutils.h"
|
||||
#include "bmlutils/bmlutils.h"
|
||||
|
||||
|
||||
int signature_check_enabled = 1;
|
||||
@ -450,6 +451,18 @@ int format_device(const char *device, const char *path, const char *fs_type) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(fs_type, "rfs") == 0) {
|
||||
if (ensure_path_unmounted(path) != 0) {
|
||||
LOGE("format_volume failed to unmount \"%s\"\n", v->mount_point);
|
||||
return -1;
|
||||
}
|
||||
if (0 != format_rfs_device(device, path)) {
|
||||
LOGE("format_volume: format_rfs_device failed on %s\n", device);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strcmp(v->mount_point, path) != 0) {
|
||||
return format_unknown_device(v->device, path, NULL);
|
||||
}
|
||||
|
@ -61,3 +61,16 @@ include $(BUILD_PREBUILT)
|
||||
|
||||
|
||||
endif
|
||||
|
||||
ifdef BOARD_HAS_RFS_FILESYSTEM
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := fat.format
|
||||
LOCAL_MODULE_TAGS := eng
|
||||
LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES
|
||||
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
endif
|
||||
|
||||
|
BIN
utilities/fat.format
Executable file
BIN
utilities/fat.format
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user