Add to mount lib directory for rpk
[platform/core/appfw/launchpad.git] / src / lib / launchpad-glib / util.hh
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef LIB_LAUNCHPAD_GLIB_UTIL_HH_
18 #define LIB_LAUNCHPAD_GLIB_UTIL_HH_
19
20 #include <bundle.h>
21 #include <sys/types.h>
22 #include <tzplatform_config.h>
23
24 #include <string>
25 #include <vector>
26
27 #include <app_info.hh>
28 #include <types.hh>
29
30 #undef EXPORT_API
31 #define EXPORT_API __attribute__((visibility("default")))
32
33 #undef GLOBAL_USER
34 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
35
36 namespace launchpad {
37
38 class EXPORT_API Util {
39  public:
40   static void SetEnvironments(const AppInfo* app_info);
41   static void DeleteSocketPath(pid_t pid, uid_t uid);
42   static int EnableExternalPackage(const AppInfo* app_info);
43   static int MountResourceDirectories(const AppInfo* app_info);
44   [[nodiscard]] static int MountGadgetDirectories(const tizen_base::Bundle& b);
45   static int WaitTepMount(const AppInfo* app_info);
46   static std::string GetLibDirectory(const std::string& app_path);
47   static void CloseAllFds(const std::vector<int>& except_fds = {});
48   static int PrepareAppSocket();
49   static int PrepareAppIdFile(const AppInfo* app_info);
50   static int SendCmdToAmd(enum AmdCmd cmd);
51   static int SendCmdToAmd(enum AmdCmd cmd, bundle* request, int opt);
52   static int MountLibraryDirectories(const tizen_base::Bundle& b);
53 };
54
55 }  // namespace launchpad
56
57 #endif  // LIB_LAUNCHPAD_GLIB_UTIL_HH_