Upload Tizen:Base source
[framework/base/util-linux-ng.git] / include / blkdev.h
1 #ifndef BLKDEV_H
2 #define BLKDEV_H
3
4 #include <sys/types.h>
5 #include <sys/ioctl.h>
6 #include <fcntl.h>
7 #include <unistd.h>
8
9 #define DEFAULT_SECTOR_SIZE       512
10
11 /* open() retries when errno is ENOMEDIUM */
12 #define CRDOM_NOMEDIUM_RETRIES    5
13
14 #if !defined(BLKROSET) && defined(__linux__)
15
16 #define BLKROSET   _IO(0x12,93) /* set device read-only (0 = read-write) */
17 #define BLKROGET   _IO(0x12,94) /* get read-only status (0 = read_write) */
18 #define BLKRRPART  _IO(0x12,95) /* re-read partition table */
19 #define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
20 #define BLKFLSBUF  _IO(0x12,97) /* flush buffer cache */
21 #define BLKRASET   _IO(0x12,98) /* set read ahead for block device */
22 #define BLKRAGET   _IO(0x12,99) /* get current read ahead setting */
23 #define BLKFRASET  _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
24 #define BLKFRAGET  _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
25 #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
26 #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
27 #define BLKSSZGET  _IO(0x12,104)/* get block device sector size */
28
29 /* ioctls introduced in 2.2.16, removed in 2.5.58 */
30 #define BLKELVGET  _IOR(0x12,106,size_t) /* elevator get */
31 #define BLKELVSET  _IOW(0x12,107,size_t) /* elevator set */
32
33 #define BLKBSZGET  _IOR(0x12,112,size_t)
34 #define BLKBSZSET  _IOW(0x12,113,size_t)
35 #define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size in bytes (u64 *arg) */
36
37 #endif /* BLKROSET */
38
39 #ifndef HDIO_GETGEO
40 # ifdef __linux__
41 #  define HDIO_GETGEO 0x0301
42 # endif
43 struct hd_geometry {
44         unsigned char heads;
45         unsigned char sectors;
46         unsigned short cylinders;       /* truncated */
47         unsigned long start;
48 };
49 #endif
50
51 /* Determine size in bytes */
52 off_t blkdev_find_size (int fd);
53
54 /* get size in bytes */
55 int blkdev_get_size(int fd, unsigned long long *bytes);
56
57 /* get 512-byte sector count */
58 int blkdev_get_sectors(int fd, unsigned long long *sectors);
59
60 /* get hardware sector size */
61 int blkdev_get_sector_size(int fd, int *sector_size);
62
63 #endif /* BLKDEV_H */