The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | |
| 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 | |
| 25 | typedef enum media_type { |
| 26 | media_unknown, |
| 27 | media_mmc, |
| 28 | media_devmapper, |
| 29 | } media_type_t; |
| 30 | |
Ethan.Du | 3afe20b | 2009-09-02 14:04:26 +0800 | [diff] [blame] | 31 | /* |
| 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 Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 37 | typedef 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 | |
| 46 | typedef struct media_list { |
| 47 | media_t *media; |
| 48 | struct media_list *next; |
| 49 | } media_list_t; |
| 50 | |
| 51 | media_t *media_create(char *devpath, char *name, char *serial, enum media_type); |
| 52 | media_t *media_lookup_by_path(char *devpath, boolean fuzzy_match); |
| 53 | media_t *media_lookup_by_dev(blkdev_t *dev); |
| 54 | void media_destroy(media_t *media); |
| 55 | int media_add_blkdev(media_t *media, blkdev_t *dev); |
| 56 | void media_remove_blkdev(media_t *media, blkdev_t *dev); |
| 57 | #endif |