summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am267
-rwxr-xr-xautogen.sh21
-rw-r--r--configure.ac147
-rw-r--r--packaging/liblazymount.manifest5
-rw-r--r--packaging/system-plugin.spec73
-rw-r--r--src/liblazymount/lazy_mount.h75
-rw-r--r--src/liblazymount/lazy_mount_interface.c155
-rw-r--r--src/liblazymount/liblazymount.pc.in17
-rw-r--r--src/liblazymount/test_lazymount.c70
-rw-r--r--units/lazy_mount.path5
-rw-r--r--units/lazy_mount.service11
11 files changed, 843 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..0b09619
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,267 @@
+ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
+
+SUBDIRS = .
+
+# legacy rc script dir
+rcdir=$(sysconfdir)/rc.d
+
+# Inherit from systemd
+systemdsysconfdir=$(sysconfdir)/systemd
+systemconfigunitdir=$(systemdsysconfdir)/system
+userconfigunitdir=$(systemdsysconfdir)/user
+systemdignoreunitdir=$(systemdsysconfdir)/default-extra-dependencies
+systemunitdir=$(rootprefix)/lib/systemd/system
+userunitdir=$(prefix)/lib/systemd/user
+udevlibexecdir=$(rootprefix)/lib/udev
+udevhomedir=$(udevlibexecdir)
+udevrulesdir=$(udevlibexecdir)/rules.d
+sysctldir=$(prefix)/lib/sysctl.d
+tmpfilesdir=$(prefix)/lib/tmpfiles.d
+
+# DBus
+dbussystemservicedir=$(prefix)/share/dbus-1/system-services
+
+pkgconfiglibdir=$(libdir)/pkgconfig
+
+# And these are the special ones for /
+rootprefix=@rootprefix@
+rootbindir=$(rootprefix)/bin
+rootlibexecdir=$(rootprefix)/lib/system
+
+CLEANFILES =
+EXTRA_DIST =
+
+lib_LTLIBRARIES =
+noinst_LTLIBRARIES =
+noinst_DATA =
+pkgconfiglib_DATA =
+
+bin_SCRIPTS =
+rc_SCRIPTS =
+SCRIPT_IN_FILES =
+sysconf_DATA =
+sysctl_DATA =
+systemdsysconf_DATA =
+systemdignoreunit_DATA =
+systemconfigunit_DATA =
+systemunit_DATA =
+udevrules_DATA =
+tmpfiles_DATA =
+dbussystemservice_DATA =
+
+DEFAULT_CFLAGS = \
+ $(OUR_CFLAGS)
+
+DEFAULT_LDFLAGS = \
+ $(OUR_LDFLAGS)
+
+AM_CPPFLAGS = \
+ -include $(top_builddir)/config.h \
+ -I $(top_srcdir)/src \
+ -I $(top_srcdir)/src/shared \
+ $(DEFAULT_CFLAGS)
+
+AM_CFLAGS = $(DEFAULT_CFLAGS)
+AM_LDFLAGS = $(DEFAULT_LDFLAGS)
+
+INSTALL_EXEC_HOOKS =
+UNINSTALL_EXEC_HOOKS =
+
+SHUTDOWN_TARGET_WANTS =
+LOCAL_FS_TARGET_WANTS =
+BASIC_TARGET_WANTS =
+SYSINIT_TARGET_WANTS =
+SOCKETS_TARGET_WANTS =
+TIMERS_TARGET_WANTS =
+TIZEN_INIT_TARGET_WANTS =
+TIZEN_BOOT_TARGET_WANTS =
+TIZEN_SYSTEM_TARGET_WANTS =
+TIZEN_RUNTIME_TARGET_WANTS =
+MULTI_USER_TARGET_WANTS =
+GRAPHICAL_TARGET_WANTS =
+DEFAULT_TARGET_WANTS =
+SYSCONF_LOCAL_FS_TARGET_WANTS =
+
+install-target-wants-hook:
+ where=$(systemunitdir) && what="$(SHUTDOWN_TARGET_WANTS)" && wants=shutdown.target && $(add-wants)
+ where=$(systemunitdir) && what="$(LOCAL_FS_TARGET_WANTS)" && wants=local-fs.target && $(add-wants)
+ where=$(systemunitdir) && what="$(BASIC_TARGET_WANTS)" && wants=basic.target && $(add-wants)
+ where=$(systemunitdir) && what="$(MULTI_USER_TARGET_WANTS)" && wants=multi-user.target && $(add-wants)
+ where=$(systemunitdir) && what="$(SYSINIT_TARGET_WANTS)" && wants=sysinit.target && $(add-wants)
+ where=$(systemunitdir) && what="$(SOCKETS_TARGET_WANTS)" && wants=sockets.target && $(add-wants)
+ where=$(systemunitdir) && what="$(TIMERS_TARGET_WANTS)" && wants=timers.target && $(add-wants)
+ where=$(systemunitdir) && what="$(SLICES_TARGET_WANTS)" && wants=slices.target && $(add-wants)
+ where=$(systemunitdir) && what="$(TIZEN_INIT_TARGET_WANTS)" && wants=tizen-init.target && $(add-wants)
+ where=$(systemunitdir) && what="$(TIZEN_BOOT_TARGET_WANTS)" && wants=tizen-boot.target && $(add-wants)
+ where=$(systemunitdir) && what="$(TIZEN_SYSTEM_TARGET_WANTS)" && wants=tizen-system.target && $(add-wants)
+ where=$(systemunitdir) && what="$(TIZEN_RUNTIME_TARGET_WANTS)" && wants=tizen-runtime.target && $(add-wants)
+ where=$(systemunitdir) && what="$(TIZEN_RUNTIME_TARGET_WANTS)" && wants=tizen-runtime.target && $(add-wants)
+ where=$(systemunitdir) && what="$(GRAPHICAL_TARGET_WANTS)" && wants=graphical.target && $(add-wants)
+ where=$(systemunitdir) && what="$(DEFAULT_TARGET_WANTS)" && wants=default.target && $(add-wants)
+ where=$(systemunitdir) && what="$(CHARGING_MODE_TARGET_WANTS)" && wants=charging-mode.target && $(add-wants)
+ where=$(systemconfigunitdir) && what="$(SYSCONF_LOCAL_FS_TARGET_WANTS)" && wants=local-fs.target && $(add-wants)
+
+define add-wants
+[ -z "$$what" -o -z "$$where" ] || ( \
+ dir=$(DESTDIR)$$where/$$wants.wants && \
+ $(MKDIR_P) -m 0755 $$dir && \
+ cd $$dir && \
+ rm -f $$what && \
+ for i in $$what; do $(LN_S) ../$$i . || exit $$? ; done )
+endef
+
+INSTALL_EXEC_HOOKS += \
+ install-target-wants-hook
+
+# ------------------------------------------------------------------------------
+pkgconfiglib_DATA += \
+ src/liblazymount/liblazymount.pc
+
+EXTRA_DIST += \
+ src/liblazymount/liblazymount.pc.in
+
+CLEANFILES += \
+ src/liblazymount/liblazymount.pc
+
+liblazymount_pkgincludedir=$(includedir)/lazymount
+liblazymount_pkginclude_HEADERS =
+
+liblazymount_pkginclude_HEADERS += src/liblazymount/lazy_mount.h
+
+lib_LTLIBRARIES += \
+ liblazymount.la
+
+liblazymount_la_SOURCES = \
+ src/liblazymount/lazy_mount.h \
+ src/liblazymount/lazy_mount_interface.c
+
+liblazymount_la_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(LIBLAZYMOUNT_PC_CFLAGS)
+
+liblazymount_la_LIBADD = \
+ $(LIBLAZYMOUNT_PC_LIBS)
+
+noinst_liblazymount_la_SOURCES = \
+ src/liblazymount/lazy_mount.h \
+ src/liblazymount/lazy_mount_interface.c
+
+# ------------------------------------------------------------------------------
+bin_PROGRAMS = \
+ test_lazymount
+
+test_lazymount_SOURCES = \
+ src/liblazymount/test_lazymount.c
+
+test_lazymount_CFLAGS = \
+ $(AM_CFLAGS) \
+ -I. -Isrc/liblazymount \
+ $(LIBLAZYMOUNT_PC_CFLAGS)
+
+test_lazymount_LDADD = \
+ -lvconf \
+ liblazymount.la
+
+systemunit_DATA += \
+ units/lazy_mount.path \
+ units/lazy_mount.service
+
+BASIC_TARGET_WANTS += \
+ lazy_mount.path
+
+# ------------------------------------------------------------------------------
+substitutions = \
+ '|rootlibexecdir=$(rootlibexecdir)|' \
+ '|rootbindir=$(rootbindir)|' \
+ '|bindir=$(bindir)|' \
+ '|SYSTEMCTL=$(rootbindir)/systemctl|' \
+ '|SYSTEMD_NOTIFY=$(rootbindir)/systemd-notify|' \
+ '|systemdsysconfdir=$(systemdsysconfdir)|' \
+ '|SYSTEM_CONFIG_UNIT_PATH=$(systemdsysconfdir)/system|' \
+ '|USER_CONFIG_UNIT_PATH=$(systemdsysconfdir)/user|' \
+ '|pkgdatadir=$(pkgdatadir)|' \
+ '|systemunitdir=$(systemunitdir)|' \
+ '|userunitdir=$(userunitdir)|' \
+ '|systempresetdir=$(systempresetdir)|' \
+ '|userpresetdir=$(userpresetdir)|' \
+ '|udevhwdbdir=$(udevhwdbdir)|' \
+ '|udevrulesdir=$(udevrulesdir)|' \
+ '|catalogdir=$(catalogdir)|' \
+ '|tmpfilesdir=$(tmpfilesdir)|' \
+ '|sysctldir=$(sysctldir)|' \
+ '|PACKAGE_VERSION=$(PACKAGE_VERSION)|' \
+ '|PACKAGE_NAME=$(PACKAGE_NAME)|' \
+ '|PACKAGE_URL=$(PACKAGE_URL)|' \
+ '|LIBLAZYMOUNT_PC_REQUIRES=$(LIBLAZYMOUNT_PC_REQUIRES)|' \
+ '|LIBLAZYMOUNT_PC_CFLAGS=$(LIBLAZYMOUNT_PC_CFLAGS)|' \
+ '|LIBLAZYMOUNT_PC_LIBS=$(LIBLAZYMOUNT_PC_LIBS)|' \
+ '|RANDOM_SEED=$(localstatedir)/lib/random-seed|' \
+ '|prefix=$(prefix)|' \
+ '|exec_prefix=$(exec_prefix)|' \
+ '|libdir=$(libdir)|' \
+ '|includedir=$(includedir)|' \
+ '|VERSION=$(VERSION)|' \
+ '|rootprefix=$(rootprefix)|' \
+ '|udevlibexecdir=$(udevlibexecdir)|' \
+ '|SUSHELL=$(SUSHELL)|' \
+ '|DEBUGTTY=$(DEBUGTTY)|' \
+ '|KILL=$(KILL)|' \
+ '|KMOD=$(KMOD)|' \
+ '|MKDIR_P=$(MKDIR_P)|' \
+ '|QUOTAON=$(QUOTAON)|' \
+ '|QUOTACHECK=$(QUOTACHECK)|' \
+ '|SYSTEM_SYSVINIT_PATH=$(sysvinitdir)|' \
+ '|VARLOGDIR=$(varlogdir)|' \
+ '|RC_LOCAL_SCRIPT_PATH_START=$(RC_LOCAL_SCRIPT_PATH_START)|' \
+ '|RC_LOCAL_SCRIPT_PATH_STOP=$(RC_LOCAL_SCRIPT_PATH_STOP)|' \
+ '|PYTHON=$(PYTHON)|' \
+ '|PYTHON_BINARY=$(PYTHON_BINARY)|' \
+ '|INITAILBOOT_DONE=$(INITAILBOOT_DONE)|' \
+ '|INITIALIZE_DONE=$(INITIALIZE_DONE)|' \
+ '|READAHEAD_DIR=$(READAHEAD_DIR)|' \
+ '|DIRTY_WRITEBACK_CENTISECS=$(DIRTY_WRITEBACK_CENTISECS)|'
+
+SED_PROCESS = \
+ $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
+ $(SED) $(subst '|,-e 's|@,$(subst =,\@|,$(subst |',|g',$(substitutions)))) \
+ < $< > $@
+
+units/%: units/%.in Makefile
+ $(SED_PROCESS)
+
+%.rules: %.rules.in Makefile
+ $(SED_PROCESS)
+
+%.sh: %.sh.in Makefile
+ $(SED_PROCESS)
+ $(AM_V_GEN)chmod +x $@
+
+src/%: src/%.m4
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
+ $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
+
+%.pc: %.pc.in
+ $(SED_PROCESS)
+
+units/%: units/%.m4 Makefile
+ $(AM_V_M4)$(MKDIR_P) $(dir $@)
+ $(AM_V_M4)$(M4) -P $(M4_DEFINES) -DFOR_SYSTEM=1 < $< > $@
+
+sysctl.d/%: sysctl.d/%.in Makefile
+ $(SED_PROCESS)
+
+conf/%: conf/%.in
+ $(SED_PROCESS)
+
+conf/%: conf/%.m4
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
+ $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
+
+scripts/%: scripts/%.in
+ $(SED_PROCESS)
+
+scripts/%: scripts/%.m4
+ $(AM_V_at)$(MKDIR_P) $(dir $@)
+ $(AM_V_M4)$(M4) -P $(M4_DEFINES) < $< > $@
+
+install-exec-hook: $(INSTALL_EXEC_HOOKS)
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..968bc8e
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+set -e
+
+if [ -f .git/hooks/pre-commit.sample ] && [ ! -f .git/hooks/pre-commit ]; then
+ # This part is allowed to fail
+ cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit && \
+ chmod +x .git/hooks/pre-commit && \
+ echo "Activated pre-commit hook." || :
+fi
+
+# README and INSTALL are required by automake, but may be deleted by
+# clean up rules. to get automake to work, simply touch these here,
+# they will be regenerated from their corresponding *.in files by
+# ./configure anyway.
+touch README INSTALL
+
+# Make sure m4 directory exist
+mkdir -p m4
+
+autoreconf --force --install --verbose || exit $?
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..4fd5105
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,147 @@
+# -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ([2.68])
+AC_INIT(liblazymount, 0.1, [BUG-REPORT-ADDRESS])
+
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_HEADERS([config.h])
+
+AC_USE_SYSTEM_EXTENSIONS
+AC_SYS_LARGEFILE
+AC_PREFIX_DEFAULT([/usr])
+AM_INIT_AUTOMAKE([foreign])
+
+LT_PREREQ(2.2)
+LT_INIT([disable-static])
+
+# Checks for programs.
+AC_PROG_MKDIR_P
+AC_PROG_LN_S
+AC_PROG_SED
+AC_PROG_GREP
+AC_PROG_AWK
+#AC_PROG_INSTALL
+
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PATH_PROG([M4], [m4])
+M4_DEFINES=
+
+# ------------------------------------------------------------------------------
+our_cflags=" \
+ -g -O2 \
+ -Werror \
+ -fpie"
+
+our_ldflags=" \
+ -Wl,--as-needed \
+ -Wl,--no-undefined \
+ -Wl,--gc-sections \
+ -Wl,-z,relro \
+ -Wl,-z,now \
+ -pie"
+# -Wl,-fuse-ld=gold"
+
+AC_SUBST([OUR_CFLAGS], "$our_cflags")
+dnl AC_SUBST([OUR_CPPFLAGS], "$OUR_CFLAGS -Wp,-D_FORTIFY_SOURCE=2")
+AC_SUBST([OUR_LDFLAGS], "$our_ldflags")
+
+# ------------------------------------------------------------------------------
+AC_ARG_WITH([rootprefix],
+ AS_HELP_STRING([--with-rootprefix=DIR],
+ [rootfs directory prefix for config files and kernel modules]),
+ [], [with_rootprefix=${ac_default_prefix}])
+AC_SUBST([rootprefix], [$with_rootprefix])
+
+# ------------------------------------------------------------------------------
+AC_ARG_WITH([rootlibdir],
+ AS_HELP_STRING([--with-rootlibdir=DIR], [Root directory for libraries necessary for boot]),
+ [],
+ [with_rootlibdir=${libdir}])
+AC_SUBST([rootlibdir], [$with_rootlibdir])
+
+# ------------------------------------------------------------------------------
+AC_ARG_ENABLE([debug-mode],
+ AS_HELP_STRING([--disable-debug-mode], [disable debug mode]),
+ [case "${enableval}" in
+ yes) enable_debug_mode=yes ;;
+ no) enable_debug_mode=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-debug-mode) ;;
+ esac],
+ enable_debug_mode=yes)
+if test "x$enable_debug_mode" == "xyes"; then
+ M4_DEFINES="$M4_DEFINES -DDEBUG_MODE"
+ AC_SUBST([OUR_CFLAGS], "$OUR_CFLAGS -DDEBUG_MODE -DTIZEN_DEBUG_ENABLE")
+fi
+
+AC_SUBST(DEBUG_MODE)
+AM_CONDITIONAL([DEBUG_MODE], [test "x$enable_debug_mode" == "xyes"])
+
+# ------------------------------------------------------------------------------
+AC_ARG_ENABLE([eng-mode],
+ AS_HELP_STRING([--disable-eng-mode], [disable engineer mode]),
+ [case "${enableval}" in
+ yes) enable_eng_mode=yes ;;
+ no) enable_eng_mode=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-eng-mode) ;;
+ esac],
+ enable_eng_mode=yes)
+if test "x$enable_eng_mode" == "xyes"; then
+ M4_DEFINES="$M4_DEFINES -DENG_MODE"
+ AC_SUBST([OUR_CFLAGS], "$OUR_CFLAGS -DENG_MODE")
+fi
+
+AC_SUBST(ENG_MODE)
+AM_CONDITIONAL([ENG_MODE], [test "x$enable_eng_mode" != "xno"])
+
+# ------------------------------------------------------------------------------
+AC_ARG_ENABLE([release-mode],
+ AS_HELP_STRING([--enable-release-mode], [enable release mode]),
+ [case "${enableval}" in
+ yes) enable_release_mode=yes ;;
+ no) enable_release_mode=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-release-mode) ;;
+ esac],
+ enable_release_mode=no)
+if test "x$enable_release_mode" == "xyes"; then
+ M4_DEFINES="$M4_DEFINES -DRELEASE_MODE"
+ AC_SUBST([OUR_CFLAGS], "$OUR_CFLAGS -DRELEASE_MODE")
+fi
+
+AC_SUBST(RELEASE_MODE)
+AM_CONDITIONAL([RELEASE_MODE], [test "x$enable_release_mode" != "xno"])
+
+# ------------------------------------------------------------------------------
+AC_SUBST(M4_DEFINES)
+
+# ------------------------------------------------------------------------------
+PKG_CHECK_MODULES(VCONF, vconf)
+
+# ------------------------------------------------------------------------------
+AC_SUBST([LIBLAZYMOUNT_PC_REQUIRES], "")
+AC_SUBST([LIBLAZYMOUNT_PC_CFLAGS], "-D_GNU_SOURCE")
+AC_SUBST([LIBLAZYMOUNT_PC_LIBS], "-L${libdir}")
+
+AC_SUBST([LIBLAZYMOUNT_PC_REQUIRES], "${LIBLAZYMOUNT_PC_REQUIRES} ${VCONF_REQUIRES}")
+AC_SUBST([LIBLAZYMOUNT_PC_CFLAGS], "${LIBLAZYMOUNT_PC_CFLAGS} ${VCONF_CFLAGS}")
+AC_SUBST([LIBLAZYMOUNT_PC_LIBS], "${LIBLAZYMOUNT_PC_LIBS} ${VCONF_LIBS}")
+
+# ------------------------------------------------------------------------------
+AC_CONFIG_FILES([Makefile])
+
+AC_OUTPUT
+AC_MSG_RESULT([
+ $PACKAGE_NAME $VERSION
+
+ prefix: ${prefix}
+ rootprefix: ${with_rootprefix}
+ sysconf dir: ${sysconfdir}
+ datarootdir: ${datarootdir}
+ lib dir: ${libdir}
+ rootlib dir: ${with_rootlibdir}
+ debug mode: ${enable_debug_mode}
+ engineer mode: ${enable_eng_mode}
+
+ OUR CFLAGS: ${OUR_CFLAGS} ${CFLAGS}
+])
diff --git a/packaging/liblazymount.manifest b/packaging/liblazymount.manifest
new file mode 100644
index 0000000..2a0cec5
--- /dev/null
+++ b/packaging/liblazymount.manifest
@@ -0,0 +1,5 @@
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
diff --git a/packaging/system-plugin.spec b/packaging/system-plugin.spec
index a25d544..819c023 100644
--- a/packaging/system-plugin.spec
+++ b/packaging/system-plugin.spec
@@ -1,16 +1,19 @@
-%define debug_package %{nil}
+#%define _unpackaged_files_terminate_build 0
+#%define debug_package %{nil}
Name: system-plugin
Summary: Target specific system configuration files
Version: 0.1
Release: 1
-Group: System/Configuration
-BuildArch: noarch
+Group: Base/Startup
License: Apache-2.0
Source0: %{name}-%{version}.tar.bz2
Source1: %{name}.manifest
+Source2: liblazymount.manifest
Requires(post): /usr/bin/systemctl
+Requires(post): /usr/bin/vconftool
+BuildRequires: pkgconfig(vconf)
%description
This package provides target specific system configuration files.
@@ -19,6 +22,7 @@ This package provides target specific system configuration files.
Summary: U3/XU3 specific system configuration files
Requires: %{name} = %{version}-%{release}
Requires: %{name}-exynos = %{version}-%{release}
+BuildArch: noarch
%description u3
This package provides U3/XU3 specific system configuration files.
@@ -27,6 +31,7 @@ This package provides U3/XU3 specific system configuration files.
Summary: Note4 specific system configuration files
Requires: %{name} = %{version}-%{release}
Requires: %{name}-exynos = %{version}-%{release}
+BuildArch: noarch
%description n4
This package provides Note4 specific system configuration files.
@@ -34,6 +39,7 @@ This package provides Note4 specific system configuration files.
%package exynos
Summary: Exynos specific system configuration files
Requires: %{name} = %{version}-%{release}
+BuildArch: noarch
%description exynos
This package provides Exynos specific system configuration files.
@@ -41,6 +47,7 @@ This package provides Exynos specific system configuration files.
%package spreadtrum
Summary: Spreadtrum specific system configuration files
Requires: %{name} = %{version}-%{release}
+BuildArch: noarch
%description spreadtrum
This package provides Spreadtrum specific system configuration files.
@@ -48,17 +55,50 @@ This package provides Spreadtrum specific system configuration files.
%package circle
Summary: Circle specific system configuration files
Requires: %{name} = %{version}-%{release}
+BuildArch: noarch
%description circle
This package provides Circle specific system configuration files.
+%package -n liblazymount
+Summary: Library for lazy mount feature
+License: Apache-2.0
+Requires: vconf
+Requires: liblazymount = %{version}
+
+
+%description -n liblazymount
+Library for lazy mount feature. It supports some interface functions.
+
+%package -n liblazymount-devel
+Summary: Development library for lazy mount feature
+License: Apache-2.0
+Requires: vconf
+Requires: liblazymount = %{version}
+
+%description -n liblazymount-devel
+Development library for lazy mount feature.It supports some interface functions.
+
%prep
%setup -q
%build
cp %{SOURCE1} .
+cp %{SOURCE2} .
+
+./autogen.sh
+%reconfigure \
+ --disable-static \
+ --prefix=%{_prefix} \
+ --disable-debug-mode \
+ --disable-eng-mode
+
+%__make %{?jobs:-j%jobs}
%install
+rm -rf %{buildroot}
+%make_install
+
mkdir -p %{buildroot}%{_unitdir}
mkdir -p %{buildroot}/csa
mkdir -p %{buildroot}/initrd
@@ -103,9 +143,19 @@ install -m 644 units/tizen-fstrim-user.service %{buildroot}%{_unitdir}
mkdir -p %{buildroot}%{_bindir}
install -m 755 scripts/tizen-fstrim-on-charge.sh %{buildroot}%{_bindir}
+%clean
+rm -rf %{buildroot}
+
%post
systemctl daemon-reload
+%post -n liblazymount
+/sbin/ldconfig
+/usr/bin/vconftool set -f -t int db/system/lazy_mount_show_ui 1
+systemctl daemon-reload
+
+%postun -n liblazymount -p /sbin/ldconfig
+
%files
%manifest %{name}.manifest
%license LICENSE.Apache-2.0
@@ -173,3 +223,20 @@ mv %{_sysconfdir}/fstab_initrd %{_sysconfdir}/fstab
%{_unitdir}/tizen-fstrim-user.timer
%{_unitdir}/tizen-fstrim-user.service
%{_bindir}/tizen-fstrim-on-charge.sh
+
+%files -n liblazymount
+%defattr(-,root,root,-)
+%{_libdir}/liblazymount.so.*
+%manifest liblazymount.manifest
+%{_unitdir}/basic.target.wants/lazy_mount.path
+%{_unitdir}/lazy_mount.path
+%{_unitdir}/lazy_mount.service
+
+%files -n liblazymount-devel
+%defattr(-,root,root,-)
+%manifest liblazymount.manifest
+%{_libdir}/liblazymount.so
+%{_includedir}/lazymount/lazy_mount.h
+%{_libdir}/pkgconfig/liblazymount.pc
+%{_bindir}/test_lazymount
+
diff --git a/src/liblazymount/lazy_mount.h b/src/liblazymount/lazy_mount.h
new file mode 100644
index 0000000..c534b6c
--- /dev/null
+++ b/src/liblazymount/lazy_mount.h
@@ -0,0 +1,75 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/*
+ * liblazymount
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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.
+ */
+
+#ifndef _LAZY_MOUNT_H_
+#define _LAZY_MOUNT_H_ 1
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief Get the check value wheter system need the ui for lazy mount feature.
+ * @return 1 if system should show the ui for lazy mount feature, otherwise 0.
+ * @par Example
+ @code
+ #include <lazy_mount.h>
+
+ int show_ui;
+
+ show_ui = get_need_ui_for_lazy_mount();
+
+ @endcode
+ */
+int get_need_ui_for_lazy_mount();
+
+/**
+ * @brief Create /tmp/.lazy_mount file to mount user partion to /opt/usr.
+ * @return 0 if success to create /tmp/.lazy_mount, otherwise -errno.
+ * @par Example
+ @code
+ #include <lazy_mount.h>
+
+ int result;
+
+ result = do_mount_user();
+
+ @endcode
+ */
+int do_mount_user();
+
+/**
+ * @brief Wait for complete to mount user partion to /opt/usr.
+ * @return 0 if success to mount it, otherwise -errno.
+ * @par Example
+ @code
+ #include <lazy_mount.h>
+
+ int result;
+
+ result = wait_mount_user();
+
+ @endcode
+ */
+int wait_mount_user();
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#endif // _LAZY_MOUNT_H_
diff --git a/src/liblazymount/lazy_mount_interface.c b/src/liblazymount/lazy_mount_interface.c
new file mode 100644
index 0000000..ec35fa6
--- /dev/null
+++ b/src/liblazymount/lazy_mount_interface.c
@@ -0,0 +1,155 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/*
+ * liblazymount
+ *
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * 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 <poll.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/inotify.h>
+#include <vconf.h>
+
+#ifndef VCONFKEY_SYSTEM_LAZY_MOUNT_SHOW_UI
+#define VCONFKEY_SYSTEM_LAZY_MOUNT_SHOW_UI "db/system/lazy_mount_show_ui"
+#endif
+#define DEFAULT_VALUE_LAZY_MOUNT_SHOW_UI 1
+
+#define LAZY_MOUNT_FILE "/tmp/.lazy_mount"
+#define LAZY_MOUNT_CHECK_DIR "/run"
+#define UNLOCK_MNT_STR ".unlock_mnt"
+#define LAZY_MOUNT_CHECK_FILE LAZY_MOUNT_CHECK_DIR "/" UNLOCK_MNT_STR
+
+#define EVENT_NAME_MAX 256
+#define EVENT_SIZE ( sizeof (struct inotify_event) )
+#define EVENT_BUF_LEN ( 512 * ( EVENT_SIZE + EVENT_NAME_MAX ) )
+
+/* Enumerate list of FDs to poll */
+enum {
+ FD_POLL_INOTIFY=0,
+ FD_POLL_MAX
+};
+
+int get_need_ui_for_lazy_mount()
+{
+ int sl_result = 0;
+ /* get touchkey light duration setting */
+ if (vconf_get_int(VCONFKEY_SYSTEM_LAZY_MOUNT_SHOW_UI, &sl_result) < 0)
+ {
+ return DEFAULT_VALUE_LAZY_MOUNT_SHOW_UI;
+ }
+
+ if(sl_result != 1 && sl_result != 0)
+ {
+ return DEFAULT_VALUE_LAZY_MOUNT_SHOW_UI;
+ }
+
+ return sl_result;
+}
+
+int do_mount_user()
+{
+ FILE *f = NULL;
+
+ f = fopen(LAZY_MOUNT_FILE, "w");
+ if (!f)
+ {
+ return -errno;
+ }
+
+ fclose(f);
+ return 0;
+}
+
+int wait_mount_user()
+{
+ int fd, wd;
+ char buffer[EVENT_BUF_LEN];
+ int length;
+ struct pollfd fds[FD_POLL_MAX];
+ int i;
+
+ fd = access(LAZY_MOUNT_CHECK_FILE, F_OK);
+
+ if(fd == 0)
+ {
+ return 0;
+ }
+
+ fd = inotify_init();
+
+ if(fd < 0)
+ {
+ return -errno;
+ }
+
+ wd = inotify_add_watch(fd, LAZY_MOUNT_CHECK_DIR, IN_CREATE|IN_MODIFY|IN_ATTRIB);
+
+ fds[FD_POLL_INOTIFY].fd = fd;
+ fds[FD_POLL_INOTIFY].events = POLLIN;
+
+ while(1)
+ {
+ if(poll(fds, FD_POLL_MAX, -1) < 0)
+ {
+ inotify_rm_watch(fd, wd);
+ close(fd);
+ return -errno;
+ }
+ if(fds[FD_POLL_INOTIFY].revents & POLLIN)
+ {
+ length = read(fds[FD_POLL_INOTIFY].fd, buffer, EVENT_BUF_LEN);
+
+ if( length < 0 )
+ {
+ inotify_rm_watch(fd, wd);
+ close(fd);
+ return -errno;
+ }
+
+ i = 0;
+ while ( i < length ) {
+ struct inotify_event *event = ( struct inotify_event * ) &buffer[ i ];
+ if ( event->len > 0 && event->len < EVENT_NAME_MAX)
+ {
+ if ( event->mask & (IN_CREATE|IN_MODIFY|IN_ATTRIB) )
+ {
+ if (!(event->mask & IN_ISDIR))
+ {
+ if(!strncmp(event->name, UNLOCK_MNT_STR, sizeof(UNLOCK_MNT_STR)))
+ {
+ inotify_rm_watch(fd, wd);
+ close(fd);
+ return 0;
+ }
+ }
+ }
+ }
+ i += EVENT_SIZE + event->len;
+ }
+ }
+ }
+
+ inotify_rm_watch(fd, wd);
+ close(fd);
+
+ return -1;
+}
diff --git a/src/liblazymount/liblazymount.pc.in b/src/liblazymount/liblazymount.pc.in
new file mode 100644
index 0000000..cf9c9cc
--- /dev/null
+++ b/src/liblazymount/liblazymount.pc.in
@@ -0,0 +1,17 @@
+# Package Information for pkg-config
+#
+# Copyright (c) 2016 Samsung Electronics Co., Ltd.
+# All rights reserved.
+#
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: liblazymount
+Description: system utility libraries for lazy-mount
+Version: @PACKAGE_VERSION@
+Requires.private: @LIBLAZYMOUNT_PC_REQUIRES@
+Cflags: @LIBLAZYMOUNT_PC_CFLAGS@
+Libs: @LIBLAZYMOUNT_PC_LIBS@
diff --git a/src/liblazymount/test_lazymount.c b/src/liblazymount/test_lazymount.c
new file mode 100644
index 0000000..41c74b2
--- /dev/null
+++ b/src/liblazymount/test_lazymount.c
@@ -0,0 +1,70 @@
+#include <lazy_mount.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int get_input()
+{
+ int data;
+ int i = 0;
+ char c_data[2];
+ while(1)
+ {
+ data = getchar();
+ if( i < 2 )
+ {
+ c_data[i] = (char)data;
+ }
+ i++;
+ if(data == 10 || data == 13)
+ {
+ break;
+ }
+ }
+ if( i > 2 )
+ {
+ return -1;
+ }
+ c_data[1] = 0;
+ return atoi(c_data);
+}
+
+int main(int argc, char **argv)
+{
+ int data;
+ int sl_ret;
+ while(1)
+ {
+ printf("Test\n");
+ printf("1. get_need_ui_for_lazy_mount()\n");
+ printf("2. do_mount_user()\n");
+ printf("3. wait_mount_user()\n");
+ printf("4. Exit to test.\n");
+ printf("Select test : ");
+ data = get_input();
+
+ switch(data)
+ {
+ case 1:
+ sl_ret = get_need_ui_for_lazy_mount();
+ printf("get_need_ui_for_lazy_mount() returns %d\n", sl_ret);
+ break;
+ case 2:
+ printf("Doing mount user data....\n");
+ sl_ret = do_mount_user();
+ printf("do_mount_user() returns %d\n", sl_ret);
+ break;
+ case 3:
+ printf("Waiting mount user data....\n");
+ sl_ret = wait_mount_user();
+ printf("wait_mount_user() returns %d\n", sl_ret);
+ break;
+ case 4:
+ printf("exit\n");
+ return 0;
+ default:
+ printf("Unknown : %d\n", data);
+ break;
+ }
+ }
+ return 0;
+}
diff --git a/units/lazy_mount.path b/units/lazy_mount.path
new file mode 100644
index 0000000..b27079f
--- /dev/null
+++ b/units/lazy_mount.path
@@ -0,0 +1,5 @@
+[Unit]
+Description=Path activator of lazy mount service
+
+[Path]
+PathExists=/tmp/.lazy_mount
diff --git a/units/lazy_mount.service b/units/lazy_mount.service
new file mode 100644
index 0000000..91b3308
--- /dev/null
+++ b/units/lazy_mount.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Mount /opt/usr
+ConditionPathIsMountPoint = !/opt/usr
+
+[Service]
+Type=oneshot
+SmackProcessLabel=System
+ExecStartPre=/usr/bin/rm -f /run/.unlock_mnt /tmp/.lazy_mount
+ExecStart=/usr/bin/mount -L user /opt/usr
+ExecStartPost=/usr/bin/touch /run/.unlock_mnt
+SuccessExitStatus=0