Skip to content

Commit

Permalink
Merge from @xiaolu: Add exfat for modules or static mode
Browse files Browse the repository at this point in the history
If you cannot write to partitions, it could be you miss SE permissions

Change-Id: I82f8e72a836d9469412e88e25e9cc2067efcb0ab
  • Loading branch information
PhilZ-cwm6 authored and kumajaya committed Mar 21, 2014
1 parent b246446 commit 5e70bb7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Android.mk
Expand Up @@ -16,6 +16,10 @@ ifneq ($(TARGET_USE_CUSTOM_LUN_FILE_PATH),)
common_cflags += -DCUSTOM_LUN_FILE=\"$(TARGET_USE_CUSTOM_LUN_FILE_PATH)\"
endif

ifneq ($(KERNEL_EXFAT_MODULE_NAME),)
common_cflags += -DEXFAT_MODULE_NAME=\"$(KERNEL_EXFAT_MODULE_NAME)\"
endif

common_cflags += -Werror

common_src_files := \
Expand Down
22 changes: 22 additions & 0 deletions Exfat.cpp
Expand Up @@ -45,6 +45,9 @@
static char EXFAT_FSCK[] = HELPER_PATH "fsck.exfat";
static char EXFAT_MKFS[] = HELPER_PATH "mkfs.exfat";
static char EXFAT_MOUNT[] = HELPER_PATH "mount.exfat";
#ifdef EXFAT_MODULE_NAME
extern "C" int mount(const char *, const char *, const char *, unsigned long, const void *);
#endif

int Exfat::doMount(const char *fsPath, const char *mountPoint,
bool ro, bool remount, bool executable,
Expand All @@ -60,6 +63,7 @@ int Exfat::doMount(const char *fsPath, const char *mountPoint,
return rc;
}

#ifndef EXFAT_MODULE_NAME
sprintf(mountData,
"noatime,nodev,nosuid,dirsync,uid=%d,gid=%d,fmask=%o,dmask=%o,%s,%s",
ownerUid, ownerGid, permMask, permMask,
Expand All @@ -77,12 +81,30 @@ int Exfat::doMount(const char *fsPath, const char *mountPoint,

rc = android_fork_execvp(ARRAY_SIZE(args), (char **)args, &status, false,
true);
#else
unsigned long flags;

flags = MS_NOATIME | MS_NODEV | MS_NOSUID | MS_DIRSYNC;

flags |= (executable ? 0 : MS_NOEXEC);
flags |= (ro ? MS_RDONLY : 0);
flags |= (remount ? MS_REMOUNT : 0);

sprintf(mountData,
"uid=%d,gid=%d,fmask=%o,dmask=%o",
ownerUid, ownerGid, permMask, permMask);
rc = mount(fsPath, mountPoint, EXFAT_MODULE_NAME, flags, mountData);
#endif
if (rc && errno == EROFS) {
SLOGE("%s appears to be a read only filesystem - retrying mount RO", fsPath);
#ifndef EXFAT_MODULE_NAME
strcat(mountData, ",ro");
rc = android_fork_execvp(ARRAY_SIZE(args), (char **)args, &status, false,
true);
#else
flags |= MS_RDONLY;
rc = mount(fsPath, mountPoint, EXFAT_MODULE_NAME, flags, mountData);
#endif
}

return rc;
Expand Down

0 comments on commit 5e70bb7

Please sign in to comment.