INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.tizen.app2sd.conf DESTINATION
${SYSCONF_INSTALL_DIR}/dbus-1/system.d/)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/app2sd-server.service DESTINATION ${UNITDIR})
+
+# build app2sd-mount-helper binary
+SET(APP2SD_MOUNT_HELPER "app2sd-mount-helper")
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/mount_helper APP2SD_MOUNT_HELPER_SRCS)
+ADD_EXECUTABLE(${APP2SD_MOUNT_HELPER} ${APP2SD_MOUNT_HELPER_SRCS})
+SET_TARGET_PROPERTIES(${APP2SD_MOUNT_HELPER} PROPERTIES COMPILE_FLAGS ${CFLAGS} "-fPIE -fstack-protector-strong")
+SET_TARGET_PROPERTIES(${APP2SD_MOUNT_HELPER} PROPERTIES LINK_FLAGS "-pie -Wl,--as-needed,-z,relro")
+INSTALL(TARGETS ${APP2SD_MOUNT_HELPER} DESTINATION bin)
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/mount.h>
+
+int main(int argc, char *argv[])
+{
+ char *source;
+ char *target;
+ char *filesystemtype;
+ unsigned long mountflags;
+
+ if (argc < 5)
+ return -EINVAL;
+
+ source = argv[1];
+ target = argv[2];
+ filesystemtype = argv[3];
+ mountflags = strtoul(argv[4], NULL, 0);
+
+ return mount(source, target, filesystemtype, mountflags, NULL);
+}
.tv_sec = 0,
.tv_nsec = 1000 * 1000 * 200
};
+ char mountflags_str[BUF_SIZE];
+ const char *argv_mount[] = { "/bin/app2sd-mount-helper", dev,
+ app_mmc_path, FS_TYPE, mountflags_str, NULL };
if (dev == NULL) {
_E("input param is NULL (%s)", dev);
switch (mount_type) {
case MOUNT_TYPE_RD:
- ret = mount(dev, app_mmc_path, FS_TYPE,
- MS_MGC_VAL | MS_RDONLY | MS_NOSUID, NULL);
+ snprintf(mountflags_str, sizeof(mountflags_str), "%u",
+ MS_MGC_VAL | MS_RDONLY | MS_NOSUID);
+ ret = _xsystem(argv_mount);
if (ret < 0) {
_E("read only mount failed, errono is (%d), "
"dev is (%s) path is (%s)",
}
break;
case MOUNT_TYPE_RW:
- ret = mount(dev, app_mmc_path, FS_TYPE, MS_MGC_VAL | MS_NOSUID,
- NULL);
+ snprintf(mountflags_str, sizeof(mountflags_str), "%u",
+ MS_MGC_VAL | MS_NOSUID);
+ ret = _xsystem(argv_mount);
if (ret < 0) {
_E("read write mount failed, errono is (%d)", errno);
ret = APP2EXT_ERROR_MOUNT;
}
break;
case MOUNT_TYPE_RW_NOEXEC:
- ret = mount(dev, app_mmc_path, FS_TYPE,
- MS_MGC_VAL | MS_NOEXEC | MS_NOSUID, NULL);
+ snprintf(mountflags_str, sizeof(mountflags_str), "%u",
+ MS_MGC_VAL | MS_NOEXEC | MS_NOSUID);
+ ret = _xsystem(argv_mount);
if (ret < 0) {
_E("rwnx mount failed errono is (%d)", errno);
ret = APP2EXT_ERROR_MOUNT;
}
break;
case MOUNT_TYPE_RD_REMOUNT:
- ret = mount(dev, app_mmc_path, FS_TYPE,
- MS_MGC_VAL | MS_RDONLY | MS_REMOUNT | MS_NOSUID,
- NULL);
+ snprintf(mountflags_str, sizeof(mountflags_str), "%u",
+ MS_MGC_VAL | MS_RDONLY | MS_REMOUNT |
+ MS_NOSUID);
+ ret = _xsystem(argv_mount);
if (ret < 0) {
_E("read remount failed errono is (%d)", errno);
ret = APP2EXT_ERROR_MOUNT;
}
break;
case MOUNT_TYPE_RW_REMOUNT:
- ret = mount(dev, app_mmc_path, FS_TYPE,
- MS_MGC_VAL | MS_REMOUNT | MS_NOSUID, NULL);
+ snprintf(mountflags_str, sizeof(mountflags_str), "%u",
+ MS_MGC_VAL | MS_REMOUNT | MS_NOSUID);
+ ret = _xsystem(argv_mount);
strerror_r(errno, err_buf, sizeof(err_buf));
if (ret < 0) {
_E("read write remount failed errono(%d), errstr(%s)",