1// Copyright 2014 The Android Open Source Project
2//
3// This software is licensed under the terms of the GNU General Public
4// License version 2, as published by the Free Software Foundation, and
5// may be copied, distributed, and modified under those terms.
6//
7// This program is distributed in the hope that it will be useful,
8// but WITHOUT ANY WARRANTY; without even the implied warranty of
9// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10// GNU General Public License for more details.
11
12#ifndef ANDROID_FILESYSTEMS_PARTITION_TYPES_H
13#define ANDROID_FILESYSTEMS_PARTITION_TYPES_H
14
15#include "android/utils/compiler.h"
16
17#include <inttypes.h>
18
19ANDROID_BEGIN_HEADER
20
21// List of supported Android partition image types.
22typedef enum {
23    ANDROID_PARTITION_TYPE_UNKNOWN = 0,
24    ANDROID_PARTITION_TYPE_YAFFS2 = 1,
25    ANDROID_PARTITION_TYPE_EXT4 = 2,
26} AndroidPartitionType;
27
28// Return a string describing the partition type to the caller.
29// Note: this will panic if |part_type| is an invalid value.
30const char* androidPartitionType_toString(AndroidPartitionType part_type);
31
32// Return an AndroidPartitionType from a string description.
33AndroidPartitionType androidPartitionType_fromString(const char* part_type);
34
35// Probe a given image file and return its partition image type.
36// Note: this returns ANDROID_PARTITION_TYPE_UNKNOWN if the file does
37// not exist or cannot be read.
38AndroidPartitionType androidPartitionType_probeFile(const char* image_file);
39
40// Create or reset the file at |image_file| to be an empty partition of type
41// |part_type| and size |part_size|. Returns 0 on success, or -errno on
42// failure.
43int androidPartitionType_makeEmptyFile(AndroidPartitionType part_type,
44                                       uint64_t part_size,
45                                       const char* image_file);
46
47ANDROID_END_HEADER
48
49#endif  // ANDROID_FILESYSTEMS_PARTITION_TYPES_H
50