4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
26 #include "core/common.h"
28 #include "mmc-handler.h"
30 #define FS_EXFAT_NAME "EXFAT"
32 #define FS_EXFAT_MOUNT_OPT "uid=5000,gid=5000,dmask=0002,fmask=0002"
34 static const char *exfat_arg[] = {
36 "-t", "exfat", "-s", "9", "-c", "8", "-b", "11", "-f", "1", "-l", "tizen", NULL, NULL,
39 static const char *exfat_check_arg[] = {
41 "-f", "-R", NULL, NULL,
44 static struct fs_check exfat_info = {
49 static bool exfat_match(const char *devpath)
56 argc = ARRAY_SIZE(exfat_check_arg);
57 exfat_check_arg[argc - 2] = devpath;
59 fd = open(devpath, O_RDONLY);
61 _E("failed to open fd(%s) : %s", devpath, strerror(errno));
65 /* check file system name */
68 while (len != 0 && (r = read(fd, tmpbuf, len)) != 0) {
78 if (strncmp((buf + 3), FS_EXFAT_NAME, strlen(FS_EXFAT_NAME)))
82 _I("MMC type : %s", exfat_info.name);
87 _E("failed to match with exfat(%s %s)", devpath, buf);
91 static int exfat_check(const char *devpath)
94 argc = ARRAY_SIZE(exfat_check_arg);
95 exfat_check_arg[argc - 2] = devpath;
96 return run_child(argc, exfat_check_arg);
99 static int exfat_mount(bool smack, const char *devpath, const char *mount_point)
101 char options[NAME_MAX];
102 int r, retry = RETRY_COUNT;
105 snprintf(options, sizeof(options), "%s,%s", FS_EXFAT_MOUNT_OPT, SMACKFS_MOUNT_OPT);
107 snprintf(options, sizeof(options), "%s", FS_EXFAT_MOUNT_OPT);
110 r = mount(devpath, mount_point, "exfat", 0, options);
112 _I("Mounted mmc card [exfat]");
116 } while (r < 0 && errno == ENOENT && retry-- > 0);
121 static int exfat_format(const char *devpath)
124 argc = ARRAY_SIZE(exfat_arg);
125 exfat_arg[argc - 2] = devpath;
126 return run_child(argc, exfat_arg);
129 static const struct mmc_fs_ops exfat_ops = {
130 .type = FS_TYPE_EXFAT,
132 .match = exfat_match,
133 .check = exfat_check,
134 .mount = exfat_mount,
135 .format = exfat_format,
138 static void __CONSTRUCTOR__ module_init(void)
143 static void __DESTRUCTOR__ module_exit(void)
145 remove_fs(&exfat_ops);