4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Garima Shrivastava<garima.s@samsung.com>
7 * Jyotsna Dhumale <jyotsna.a@samsung.com>
8 * Venkatesha Sarpangala <sarpangala.v@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 #ifndef _APP2SD_INTERNAL_H
25 #define _APP2SD_INTERNAL_H
31 #ifndef _DEFAULT_SOURCE
32 #define _DEFAULT_SOURCE
46 #include <sys/types.h>
48 #include <sys/mount.h>
49 #include <app2sd_interface.h>
52 #define DIR_PERMS (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
55 #define MEM_BUF_SIZE 5 /*Memory buffer size in MB*/
56 #define PKG_BUF_SIZE 2 /*Memory buffer size in MB*/
58 /*Device entry defines*/
61 #define FS_TYPE "ext4"
62 #define INTERNAL_STORAGE_PATH "/opt"
64 typedef enum mount_type_t {
68 MOUNT_TYPE_RD_REMOUNT,
72 typedef enum app2sd_cmd_t {
73 APP2SD_PRE_INSTALL = 1,
76 APP2SD_POST_UNINSTALL,
81 APP2SD_MOVE_APP_TO_MMC,
82 APP2SD_MOVE_APP_TO_PHONE
85 /*This will store password in DB*/
86 int _app2sd_set_passwod_in_db(const char *pkgid, const char *password);
88 /*This will remove password from db*/
89 int _app2sd_remove_password_from_db(const char *pkgid);
91 /*This will fetch password from db*/
92 char *_app2sd_get_passowrd_from_db(const char *pkgid);
94 /*Checks whether mmc is present or not*/
95 int _app2sd_check_mmc_status(void);
97 /*this function is similar to system()*/
98 int _xsystem(const char *argv[]);
100 /*this function will return the free available memory on the SD Card*/
101 int _app2sd_get_available_free_memory(const char *sd_path, int *free_mem);
103 /*Function to move the application from/to SD Card*/
104 int _app2sd_usr_move_app(const char *pkgid, app2ext_move_type move_cmd,
105 GList* dir_list, uid_t uid);
107 /*utility to delete the directory*/
108 int _app2sd_delete_directory(const char *dirname);
110 /*utility to delete symbolic link*/
111 void _app2sd_delete_symlink(const char *dirname);
113 /*utility to calculate the size of a directory in MB*/
114 unsigned long long _app2sd_calculate_dir_size(char *dirname);
116 /*utility to calculate the size of a file in MB*/
117 unsigned long long _app2sd_calculate_file_size(const char *filename);
119 /*Utility to copy a directory*/
120 int _app2sd_copy_dir(const char *src, const char *dest);
122 /*Utility to rename a directory*/
123 int _app2sd_rename_dir(const char *old_name, const char *new_name);
125 /* Utility to create symlinks */
126 int _app2sd_create_symlink(char *pkgid);
128 /*This function finds the associated device node for the app*/
129 char *_app2sd_find_associated_device_node(const char *loopback_device);
131 /*This function does the loopback encryption for app*/
132 char *_app2sd_do_loopback_encryption_setup(const char *pkgid,
133 const char *loopback_device);
135 /*This function detaches the loopback device*/
136 char *_app2sd_detach_loop_device(const char *device);
138 /*This function finds loopback device associated with the app*/
139 char *_app2sd_find_associated_device(const char *mmc_app_path);
141 /*This function creates loopback device*/
142 int _app2sd_create_loopback_device(const char *pkgid,
143 const char *loopback_device, int size);
145 /*This function deletes loopback device associated with the app*/
146 int _app2sd_delete_loopback_device(const char *loopback_device);
148 /*This function creates ext4 FS on the device path*/
149 int _app2sd_create_file_system(const char *device_path);
151 /*This function mounts the app content on the device node*/
152 int _app2sd_mount_app_content(const char *application_path, const char *pkgid,
153 const char *dev, int mount_type, GList* dir_list,
154 app2sd_cmd cmd, uid_t uid);
156 /*This function unmounts the app content */
157 int _app2sd_unmount_app_content(const char *application_path);
159 /*This function removes the loopbck encryption setup for the app*/
160 int _app2sd_remove_loopback_encryption_setup(const char *loopback_device);
162 /*This function removes all of loopbck encryption setup for the app*/
163 int _app2sd_remove_all_loopback_encryption_setups(const char *loopback_device);
165 /*This function updates loopback device size*/
166 int _app2sd_update_loopback_device_size(const char *pkgid,
167 const char *loopback_device, const char *application_path,
168 const char *temp_pkgid, const char *temp_loopback_device,
169 const char *temp_application_path, int size, GList* dir_list,
172 /* This generates password */
173 char *_app2sd_generate_password(const char *pkgid);
175 /*This function encrypts device*/
176 char *_app2sd_encrypt_device(const char *device, const char *loopback_device,
179 /*This function finds free device*/
180 char *_app2sd_find_free_device(void);
182 /*This function initializes app2sd DB*/
183 int _app2sd_initialize_db();
185 /*This function is used to get password from db*/
186 char *_app2sd_get_password_from_db(const char *pkgid);
188 /*This function removes password from db */
189 int _app2sd_remove_password_from_db(const char *pkgid);
191 /* This functions saved password in db */
192 int _app2sd_set_password_in_db(const char *pkgid, const char *passwd);
194 /* This functions make result file */
195 void _app2sd_make_result_info_file(char *pkgid, int size, uid_t uid);
197 int _is_global(uid_t uid);