1a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat/* 2a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * Copyright (C) 2008 The Android Open Source Project 3a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * 4a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * Licensed under the Apache License, Version 2.0 (the "License"); 5a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * you may not use this file except in compliance with the License. 6a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * You may obtain a copy of the License at 7a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * 8a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * http://www.apache.org/licenses/LICENSE-2.0 9a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * 10a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * Unless required by applicable law or agreed to in writing, software 11a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * distributed under the License is distributed on an "AS IS" BASIS, 12a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * See the License for the specific language governing permissions and 14a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat * limitations under the License. 15a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat */ 16a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat 17a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat#ifndef _LOOP_H 18a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat#define _LOOP_H 19a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat 20a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat#include <unistd.h> 21a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat#include <linux/loop.h> 22a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat 23d9a4e358614a0c5f60cc76c0636ee4bb02004a32San Mehatclass SocketClient; 24d9a4e358614a0c5f60cc76c0636ee4bb02004a32San Mehat 25a19b250bd273455933ca3502cf2c2e0a803aff77San Mehatclass Loop { 26a19b250bd273455933ca3502cf2c2e0a803aff77San Mehatpublic: 27b78a32c1d5eeb243bdac0eaf18effb1897f1ee67San Mehat static const int LOOP_MAX = 4096; 28a19b250bd273455933ca3502cf2c2e0a803aff77San Mehatpublic: 29d9a4e358614a0c5f60cc76c0636ee4bb02004a32San Mehat static int lookupActive(const char *id, char *buffer, size_t len); 3014eab550e8a4f28889cc9ffbb92ddff8f18c4f03Hiroaki Miyazawa static int lookupInfo(const char *loopDevice, struct asec_superblock *sb, unsigned long *nr_sec); 31d9a4e358614a0c5f60cc76c0636ee4bb02004a32San Mehat static int create(const char *id, const char *loopFile, char *loopDeviceBuffer, size_t len); 32a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat static int destroyByDevice(const char *loopDevice); 33a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat static int destroyByFile(const char *loopFile); 34a4f48d0f44d09b6a9a3b16f6c0121ffd5123eef3Mateusz Nowak static int createImageFile(const char *file, unsigned long numSectors); 35a4f48d0f44d09b6a9a3b16f6c0121ffd5123eef3Mateusz Nowak static int resizeImageFile(const char *file, unsigned long numSectors); 36d9a4e358614a0c5f60cc76c0636ee4bb02004a32San Mehat 37d9a4e358614a0c5f60cc76c0636ee4bb02004a32San Mehat static int dumpState(SocketClient *c); 38a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat}; 39a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat 40a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat#endif 41