2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <sys/statvfs.h>
24 #include <tzplatform_config.h>
30 #define COMPAT_DIR "/opt/usr/media"
32 #ifndef __USE_FILE_OFFSET64
33 int __WEAK__ storage_get_internal_memory_size(struct statvfs *buf);
35 int __WEAK__ storage_get_internal_memory_size64(struct statvfs *buf);
38 static int internal_get_state(void)
40 return STORAGE_STATE_MOUNTED;
43 static int internal_get_space(unsigned long long *total, unsigned long long *available)
48 #ifndef __USE_FILE_OFFSET64
49 ret = storage_get_internal_memory_size(&s);
51 ret = storage_get_internal_memory_size64(&s);
57 *total = (unsigned long long)s.f_frsize*s.f_blocks;
59 *available = (unsigned long long)s.f_bsize*s.f_bavail;
63 static const char *internal_get_root(void)
65 struct libmnt_table *t = NULL;
70 ret = tzplatform_getenv(TZ_USER_CONTENT);
76 r = mnt_table_parse_mtab(t, NULL);
82 fs = mnt_table_find_target(t,COMPAT_DIR,MNT_ITER_BACKWARD);
84 // TODO : mnt_fs_get_root(fs) should be matched to tzplatform_getenv(TZ_USER_CONTENT).
93 const struct storage_ops internal = {
94 .type = STORAGE_TYPE_INTERNAL,
95 .root = internal_get_root,
96 .get_state = internal_get_state,
97 .get_space = internal_get_space,
101 STORAGE_OPS_REGISTER(&internal)