blob: 6fd8b8432c009c927f23cef5dffee8c92d33b3cd [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001
2/*
3 * Copyright (C) 2008 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef _MEDIA_H
19#define _MEDIA_H
20
21#include <sys/types.h>
22
23#include "blkdev.h"
24
25typedef enum media_type {
26 media_unknown,
27 media_mmc,
28 media_devmapper,
29} media_type_t;
30
Ethan.Du3afe20b2009-09-02 14:04:26 +080031/*
32 * max 8 partitions per card
33 */
34#define MMC_PARTS_PER_CARD (1<<3)
35#define ALIGN_MMC_MINOR(min) (min / MMC_PARTS_PER_CARD * MMC_PARTS_PER_CARD)
36
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -080037typedef struct media {
38 char *devpath;
39 char *name;
40 uint32_t serial;
41 media_type_t media_type;
42
43 blkdev_list_t *devs;
44} media_t;
45
46typedef struct media_list {
47 media_t *media;
48 struct media_list *next;
49} media_list_t;
50
51media_t *media_create(char *devpath, char *name, char *serial, enum media_type);
52media_t *media_lookup_by_path(char *devpath, boolean fuzzy_match);
53media_t *media_lookup_by_dev(blkdev_t *dev);
54void media_destroy(media_t *media);
55int media_add_blkdev(media_t *media, blkdev_t *dev);
56void media_remove_blkdev(media_t *media, blkdev_t *dev);
57#endif