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 VFAT_MOUNT_OPT "uid=5000,gid=5000,dmask=0002,fmask=0002,iocharset=iso8859-1,utf8,shortname=mixed"
29 #define SMACK_MOUNT_OPT "smackfsroot=*,smackfsdef=*"
31 static const char *vfat_check_arg[] = {
32 "/usr/bin/fsck_msdosfs",
36 static const char *vfat_arg[] = {
37 "/usr/bin/newfs_msdos",
38 "-F", "32", "-O", "tizen", "-c", "8", NULL, NULL,
41 static int vfat_check(const char *devname)
44 argc = ARRAY_SIZE(vfat_check_arg);
45 vfat_check_arg[argc - 2] = devname;
46 return run_child(argc, vfat_check_arg);
49 static void get_mount_options(bool smack, char *options, int len)
52 snprintf(options, len, "%s,%s", VFAT_MOUNT_OPT, SMACK_MOUNT_OPT);
54 snprintf(options, len, "%s", VFAT_MOUNT_OPT);
57 static int vfat_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, "vfat", 0, options);
64 static int vfat_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, "vfat", MS_RDONLY, options);
71 static int vfat_format(const char *path)
74 argc = ARRAY_SIZE(vfat_arg);
75 vfat_arg[argc - 2] = path;
76 return run_child(argc, vfat_arg);
79 static const struct storage_fs_ops vfat_ops = {
83 .mount_rdonly = vfat_mount_rdonly,
84 .format = vfat_format,
87 static void __CONSTRUCTOR__ vfat_init(void)
89 register_fs(&vfat_ops);