Fix mount res dir 85/259685/2
authorSangyoon Jang <jeremy.jang@samsung.com>
Fri, 11 Jun 2021 05:07:02 +0000 (14:07 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Fri, 11 Jun 2021 06:57:05 +0000 (15:57 +0900)
upperdir, workdir is not necessary for read-only mount.

Change-Id: I8849b7601541d415e65ffce025f0a7f2a505792e
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/lib/common/src/launchpad_common.c

index 7c4ab6f..61cb98c 100644 (file)
@@ -1494,27 +1494,23 @@ void _print_hwc_log(const char *format, ...)
 }
 
 static int __get_mount_opt(const char *srcs[], size_t srcs_len,
-       const char *dest, const char *workdir, char *opt, size_t opt_len)
+       const char *dest, char *opt, size_t opt_len)
 {
        int i;
        char buf[PATH_MAX];
        int ret;
 
-       snprintf(buf, sizeof(buf), "%s", "lowerdir=");
-       snprintf(opt, opt_len, "%s", buf);
+       /* read-only mount (without upperdir,workdir) needs at least 2 lowerdir,
+        * so we set dest itself as lowerdir.
+        */
+       snprintf(opt, opt_len, "lowerdir=%s", dest);
        for (i = 0; i < srcs_len; i++) {
-               snprintf(buf, sizeof(buf), "%s%s", opt, srcs[i]);
-               ret = snprintf(opt, opt_len, "%s:", buf);
+               ret = snprintf(buf, sizeof(buf), "%s:%s", opt, srcs[i]);
                if (ret < 0) {
                        _E("source directory string size is too large");
                        return -1;
                }
-       }
-       ret = snprintf(opt, opt_len, "%s,upperdir=%s,workdir=%s", buf, dest,
-                       workdir);
-       if (ret < 0) {
-               _E("source directory string size is too large");
-               return -1;
+               snprintf(opt, opt_len, "%s", buf);
        }
 
        _D("mount opt: %s", opt);
@@ -1522,13 +1518,12 @@ static int __get_mount_opt(const char *srcs[], size_t srcs_len,
        return 0;
 }
 
-static int __mount_dir(const char *srcs[], size_t srcs_len, const char *dest,
-               const char *workdir)
+static int __mount_dir(const char *srcs[], size_t srcs_len, const char *dest)
 {
        int ret;
        char opt[PATH_MAX];
 
-       ret = __get_mount_opt(srcs, srcs_len, dest, workdir, opt, sizeof(opt));
+       ret = __get_mount_opt(srcs, srcs_len, dest, opt, sizeof(opt));
        if (ret < 0) {
                _E("Failed to get mount option");
                return -1;
@@ -1548,14 +1543,11 @@ int _mount_res_dir(const char *root_path, bundle *kb)
        const char **val;
        int len;
        char dest[PATH_MAX];
-       char workdir[PATH_MAX];
 
        val = bundle_get_str_array(kb, AUL_K_MOUNT_GLOBAL_RES_DIR, &len);
        if (val) {
                snprintf(dest, sizeof(dest), "%s/res/mount/global", root_path);
-               snprintf(workdir, sizeof(workdir), "%s/res/mount/work",
-                               root_path);
-               __mount_dir(val, len, dest, workdir);
+               __mount_dir(val, len, dest);
        } else if (get_last_result() != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
                _E("invalid mount info");
                return -1;
@@ -1564,9 +1556,7 @@ int _mount_res_dir(const char *root_path, bundle *kb)
        val = bundle_get_str_array(kb, AUL_K_MOUNT_ALLOWED_RES_DIR, &len);
        if (val) {
                snprintf(dest, sizeof(dest), "%s/res/mount/allowed", root_path);
-               snprintf(workdir, sizeof(workdir), "%s/res/mount/work",
-                               root_path);
-               __mount_dir(val, len, dest, workdir);
+               __mount_dir(val, len, dest);
        } else if (get_last_result() != BUNDLE_ERROR_KEY_NOT_AVAILABLE) {
                _E("invalid mount info");
                return -1;