• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 _BLKDEV_H
19 #define _BLKDEV_H
20 
21 #include <sys/types.h>
22 
23 struct media;
24 
25 enum blk_type { blkdev_unknown, blkdev_disk, blkdev_partition };
26 
27 struct 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 };
45 
46 struct blkdev_list {
47     struct blkdev      *dev;
48     struct blkdev_list *next;
49 };
50 
51 typedef struct blkdev blkdev_t;
52 typedef struct blkdev_list blkdev_list_t;
53 
54 blkdev_t *blkdev_create(blkdev_t *disk, char *devpath, int major, int minor, struct media *media, char *type);
55 blkdev_t *blkdev_create_pending_partition(blkdev_t *disk, char *dev_fspath, int major, int minor, struct media *media);
56 blkdev_t *blkdev_lookup_by_path(char *devpath);
57 blkdev_t *blkdev_lookup_by_devno(int maj, int min);
58 char *blkdev_get_devpath(blkdev_t *blk);
59 
60 void blkdev_destroy(blkdev_t *blk);
61 
62 int blkdev_get_num_pending_partitions(blkdev_t *blk);
63 int blkdev_refresh(blkdev_t *blk);
64 #endif
65