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.
23 #include <sys/mount.h>
25 #include "core/common.h"
28 #define EXFAT_MOUNT_OPT "uid=5000,gid=5000,dmask=0002,fmask=0002"
29 #define SMACK_MOUNT_OPT "smackfsroot=*,smackfsdef=*"
31 static const char *exfat_check_arg[] = {
33 "-f", "-R", NULL, NULL,
36 static const char *exfat_arg[] = {
38 "-t", "exfat", "-s", "9", "-c", "8", "-b", "11", "-f", "1", "-l", "tizen", NULL, NULL,
41 static int exfat_check(const char *devname)
44 argc = ARRAY_SIZE(exfat_check_arg);
45 exfat_check_arg[argc - 2] = devname;
46 return run_child(argc, exfat_check_arg);
49 static void get_mount_options(bool smack, char *options, int len)
52 snprintf(options, len, "%s,%s", EXFAT_MOUNT_OPT, SMACK_MOUNT_OPT);
54 snprintf(options, len, "%s", EXFAT_MOUNT_OPT);
57 static int exfat_mount(bool smack, const char *devpath, const char *mount_point)
59 char options[NAME_MAX];
60 get_mount_options(smack, options, sizeof(options));
61 return mount(devpath, mount_point, "exfat", 0, options);
64 static int exfat_mount_rdonly(bool smack, const char *devpath, const char *mount_point)
66 char options[NAME_MAX];
67 get_mount_options(smack, options, sizeof(options));
68 return mount(devpath, mount_point, "exfat", MS_RDONLY, options);
71 static int exfat_format(const char *path)
74 argc = ARRAY_SIZE(exfat_arg);
75 exfat_arg[argc - 2] = path;
76 return run_child(argc, exfat_arg);
79 static const struct storage_fs_ops exfat_ops = {
83 .mount_rdonly = exfat_mount_rdonly,
84 .format = exfat_format,
87 static void __CONSTRUCTOR__ exfat_init(void)
89 register_fs(&exfat_ops);