}
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);
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;
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;
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;