blob: 7818419d11e23ca86053c025743cbd25928d288a [file] [log] [blame]
The Android Open Source Project8ac3a132009-01-20 14:04:01 -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 _BLKDEV_H
19#define _BLKDEV_H
20
21#include <sys/types.h>
22
23struct media;
24
25enum blk_type { blkdev_unknown, blkdev_disk, blkdev_partition };
26
27struct blkdev {
28 char *devpath;
29 enum blk_type type;
30 struct media *media;
31
32 // If type == blkdev_disk then nr_parts = number of partitions
33 int nr_parts;
34
35 // If type == blkdev_partition then part_type = partition type
36 uint8_t part_type;
37 // If type == blkdev_partition
38 struct blkdev *disk;
39
40 unsigned int nr_sec;
41
42 int major;
43 int minor;
44 char *dev_fspath;
45};
46
47struct blkdev_list {
48 struct blkdev *dev;
49 struct blkdev_list *next;
50};
51
52typedef struct blkdev blkdev_t;
53typedef struct blkdev_list blkdev_list_t;
54
55blkdev_t *blkdev_create(blkdev_t *disk, char *devpath, int major, int minor, struct media *media, char *type);
56blkdev_t *blkdev_create_pending_partition(blkdev_t *disk, char *dev_fspath, int major, int minor, struct media *media);
57blkdev_t *blkdev_lookup_by_path(char *devpath);
58blkdev_t *blkdev_lookup_by_devno(int maj, int min);
59blkdev_t *blkdev_lookup_by_dev_fspath(char *dev_fspath);
60void blkdev_destroy(blkdev_t *blk);
61
62int blkdev_handle_devicefile_created(blkdev_t *blk, char *dev_fspath);
63int blkdev_handle_devicefile_removed(blkdev_t *blk, char *dev_fspath);
64int blkdev_get_num_pending_partitions(blkdev_t *blk);
65void blkdev_devpath_set(blkdev_t *blk, char *dev_fspath);
66#endif