incorporate Fedora patch for sector sizes > 512 bytes
[debian/efibootmgr] / src / include / disk.h
1 /*
2   disk.[ch]
3  
4   Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch@dell.com>
5  
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef _DISK_H
22 #define _DISK_H
23
24 #include <sys/ioctl.h>
25
26 /* Snagged from linux/include/asm-ia64/ioctl.h */
27 #define _IOC_NRBITS     8
28 #define _IOC_TYPEBITS   8
29 #define _IOC_SIZEBITS   14
30 #define _IOC_DIRBITS    2
31
32 #define _IOC_NRMASK     ((1 << _IOC_NRBITS)-1)
33 #define _IOC_TYPEMASK   ((1 << _IOC_TYPEBITS)-1)
34 #define _IOC_SIZEMASK   ((1 << _IOC_SIZEBITS)-1)
35 #define _IOC_DIRMASK    ((1 << _IOC_DIRBITS)-1)
36
37 #define _IOC_NRSHIFT    0
38 #define _IOC_TYPESHIFT  (_IOC_NRSHIFT+_IOC_NRBITS)
39 #define _IOC_SIZESHIFT  (_IOC_TYPESHIFT+_IOC_TYPEBITS)
40 #define _IOC_DIRSHIFT   (_IOC_SIZESHIFT+_IOC_SIZEBITS)
41
42 /*
43  * Direction bits.
44  */
45 #define _IOC_NONE       0U
46 #define _IOC_WRITE      1U
47 #define _IOC_READ       2U
48
49 #define _IOC(dir,type,nr,size) \
50         (((dir)  << _IOC_DIRSHIFT) | \
51          ((type) << _IOC_TYPESHIFT) | \
52          ((nr)   << _IOC_NRSHIFT) | \
53          ((size) << _IOC_SIZESHIFT))
54
55 /* used to create numbers */
56 #define _IO(type,nr)            _IOC(_IOC_NONE,(type),(nr),0)
57
58
59 /* Snagged from linux/include/linux/fs.h */
60 #define BLKGETSIZE _IO(0x12,96)      /* return device size */
61
62
63 enum _bus_type {bus_type_unknown, isa, pci};
64 enum _interface_type {interface_type_unknown,
65                       ata, atapi, scsi, usb,
66                       i1394, fibre, i2o, md};
67
68
69 unsigned int lcm(unsigned int x, unsigned int y);
70
71 int disk_get_pci(int fd,
72                  unsigned char *bus,
73                  unsigned char *device,
74                  unsigned char *function);
75
76 int disk_info_from_fd(int fd, 
77                       int *interface_type,
78                       unsigned int *controllernum, 
79                       unsigned int *disknum,
80                       unsigned char *part);
81
82 int disk_get_partition_info (int fd, 
83                              uint32_t num,
84                              uint64_t *start, uint64_t *size,
85                              char *signature,
86                              uint8_t *mbr_type, uint8_t *signature_type);
87
88
89 int disk_get_size(int fd, long *size);
90 int get_sector_size(int fd);
91
92
93 #endif