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);
30d9a4e358614a0c5f60cc76c0636ee4bb02004a32San Mehat    static int create(const char *id, const char *loopFile, char *loopDeviceBuffer, size_t len);
31a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat    static int destroyByDevice(const char *loopDevice);
32a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat    static int destroyByFile(const char *loopFile);
338b8f71b1d760411279f3b07a5c97709f052c689eSan Mehat    static int createImageFile(const char *file, unsigned int numSectors);
34d9a4e358614a0c5f60cc76c0636ee4bb02004a32San Mehat
35d9a4e358614a0c5f60cc76c0636ee4bb02004a32San Mehat    static int dumpState(SocketClient *c);
36a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat};
37a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat
38a19b250bd273455933ca3502cf2c2e0a803aff77San Mehat#endif
39