#define EXTENDEDSD_MOUNT_PATH "/opt/extendedsd"
#define VFAT_NAME "vfat"
+#define EXFAT_NAME "exfat"
#define EXT4_NAME "ext4"
#define LUKS_NAME "crypto_LUKS"
-#define EXTENDEDSD_NAME "extendedsd"
+#define EXTENDEDSD_NAME "extendedsd"
/* Minimum value of block id */
#define BLOCK_ID_MIN 10
} else
fstype = fs_type;
}
+ if (!strcmp(fstype, EXFAT_NAME))
+ fstype = VFAT_NAME;
fs = NULL;
len = strlen(fstype);
break;
}
- if (!fs) {
+ if (!fs || !fs->format) {
BLOCK_FLAG_SET(data, FS_NOT_SUPPORTED);
_E("Not supported file system(%s).", fstype);
return -ENOTSUP;
}
_I("Format path=%s", data->devnode);
- fs->check(data->devnode);
r = fs->format(data->devnode);
if (r < 0) {
_E("Failed to format block data for %s.", data->devnode);
--- /dev/null
+/*
+ * storaged
+ *
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include <stdio.h>
+#include <sys/mount.h>
+#include <limits.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+
+#include "log.h"
+#include "block.h"
+
+/* guid 10001 - group priv_externalstorage */
+#define FS_EXFAT_MOUNT_OPT "uid=0,gid=10001,dmask=0000,fmask=0111"
+
+static int exfat_mount(bool smack, const char *devpath, const char *mount_point)
+{
+ char options[NAME_MAX];
+ int r, err, retry = RETRY_COUNT;
+ struct timespec time = {0,};
+ unsigned long mountflags = MS_NOSUID | MS_NOEXEC | MS_NODEV | MS_DIRSYNC;
+
+ if (smack)
+ snprintf(options, sizeof(options), "%s,%s", FS_EXFAT_MOUNT_OPT, SMACKFS_MOUNT_OPT);
+ else
+ snprintf(options, sizeof(options), "%s", FS_EXFAT_MOUNT_OPT);
+
+ do {
+ r = mount(devpath, mount_point, "exfat", mountflags, options);
+ if (!r) {
+ _I("Storage Mounted exfat.");
+ return 0;
+ }
+
+ err = errno;
+ _I("Failed to mount return=%d: %d", r, err);
+ time.tv_nsec = 100 * NANO_SECOND_MULTIPLIER;
+ nanosleep(&time, NULL);
+ if (r < 0 && err == EROFS)
+ mountflags |= MS_RDONLY;
+ } while (r < 0 && (err == ENOENT || err == EROFS) && retry-- > 0);
+
+ return -err;
+}
+
+static const struct block_fs_ops exfat_ops = {
+ .type = FS_TYPE_EXFAT,
+ .name = "exfat",
+ .match = NULL,
+ .check = NULL,
+ .mount = exfat_mount,
+ .format = NULL,
+};
+
+static void __CONSTRUCTOR__ module_init(void)
+{
+ add_fs(&exfat_ops);
+}
+/*
+static void __DESTRUCTOR__ module_exit(void)
+{
+ _I("module exit");
+ remove_fs(&exfat_ops);
+}
+*/