2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <sys/types.h>
26 #define LOG_TAG "Vold"
28 #include <cutils/log.h>
31 const char *Xwarp::XWARP_BACKINGFILE = "/mnt/secure/asec/xwarp.img";
32 const char *Xwarp::XWARP_CFG = "/sys/fs/yaffs/mtd3/xwarp-backing-store";
33 const char *Xwarp::XWARP_READY = "/sys/fs/yaffs/mtd3/xwarp-ready";
34 const char *Xwarp::XWARP_MIRROR_STATUS = "/sys/fs/yaffs/mtd3/xwarp-mirror";
37 return doEnableDisable(true);
40 int Xwarp::disable() {
41 return doEnableDisable(false);
44 int Xwarp::status(bool *ready, unsigned *mirrorPos, unsigned *maxSize) {
50 if (!(fp = fopen(XWARP_READY, "r"))) {
54 fscanf(fp, "%d", (int *) ready);
57 if (!(fp = fopen(XWARP_MIRROR_STATUS, "r"))) {
61 fscanf(fp, "%u %u", mirrorPos, maxSize);
66 int Xwarp::doEnableDisable(bool enable) {
68 int fd = open(XWARP_CFG, O_WRONLY);
73 tmp = (enable ? XWARP_BACKINGFILE : "");
75 if (write(fd, tmp, strlen(tmp)+1) < 0) {
76 SLOGE("Failed to write xwarp cfg (%s)", strerror(errno));