Imported Upstream version 24.2
[rrq/maintain_lilo.git] / src / partition.h
1 /* partition.h  -  Partition table handling
2  * 
3  * Copyright 1992-1998 Werner Almesberger
4  * Copyright 1999-2004 John Coffman
5  * Copyright 2009-2015 Joachim Wiedorn
6  * All rights reserved.
7  * 
8  * Licensed under the terms contained in the file 'COPYING'
9  * in the source directory.
10  */
11
12 #ifndef PARTITION_H
13 #define PARTITION_H
14
15 #include <unistd.h>
16 #include <linux/unistd.h>
17
18 typedef struct _change_rule {
19     const char *type;
20     unsigned char normal;
21     unsigned char hidden;
22     struct _change_rule *next;
23 } CHANGE_RULE;
24
25 enum {PTW_OKAY=0, PTW_DOS=1, PTW_OS2=2, PTW_SWAP, PTW_XFS,
26                 PTW_mask=7, PTW_NTFS=8};
27
28
29 #define LLSECTORSIZE ((int64_t)SECTOR_SIZE)
30
31 #if __GLIBC__ < 2 || __GLIBC_MINOR__ < 1
32 typedef int64_t lloff_t;
33
34 #ifdef _syscall5
35        lloff_t lseek64(unsigned int fd, lloff_t offs, unsigned int whence);
36 #endif
37 #endif
38
39 struct partition {
40         unsigned char boot_ind;         /* 0x80 - active */
41         unsigned char head;             /* starting head */
42         unsigned char sector;           /* starting sector */
43         unsigned char cyl;              /* starting cylinder */
44         unsigned char sys_ind;          /* What partition type */
45         unsigned char end_head;         /* end head */
46         unsigned char end_sector;       /* end sector */
47         unsigned char end_cyl;          /* end cylinder */
48         unsigned int start_sect;        /* starting sector counting from 0 */
49         unsigned int nr_sects;          /* nr of sectors in partition */
50 };
51
52
53 int part_nowrite(char* device);
54 /* identify partitions which would be destroyed if the boot block
55    is overwritten:
56    
57    known problems occur for:
58         XFS
59         NTFS
60         DOS FAT (relocation will fix)
61 */
62
63 #define is_extd_part(x) ((x)==PART_DOS_EXTD||(x)==PART_WIN_EXTD_LBA||(x)==PART_LINUX_EXTD)
64
65 void part_verify(int dev_nr,int type);
66 /* Verify the partition table of the disk of which dev_nr is a partition. May
67    also try to "fix" a partition table. Fail on non-Linux partitions if the
68    TYPE flag is non-zero (unless IGNORE-TABLE is set too). */
69
70 void do_cr_auto(void);
71 /* do automatic change-rules */
72
73 void preload_types(void);
74 /* Preload some partition types for convenience */
75
76 void do_activate(char *where, char *which);
77 /* Activate the specified partition */
78
79 void do_install_mbr(char *where, char *what);
80 /* Install a new MBR (Master Boot Record) */
81
82 int read_partitions(char *part, int max, int *volid,
83                 struct partition *p, int64_t *where);
84 /* read all partitions & partition tables */
85
86 #endif