File: autopartkit.h

package info (click to toggle)
autopartkit 1.07
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,060 kB
  • ctags: 198
  • sloc: ansic: 2,489; sh: 843; makefile: 103
file content (118 lines) | stat: -rw-r--r-- 3,589 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef AUTOPARTKIT_H
#define AUTOPARTKIT_H

#include <parted/device.h>  /* for PedSector */
#include <parted/disk.h>    /* for PedGeometry */

struct disk_info_t;

struct diskspace_req_s {
  char *mountpoint;
  char *fstype;
  int minsize; /* In MB */
  int maxsize; /* In MB */

  int ondisk; /* flag if the file system should get a disk partition */

  /* Used by the allocation algorithm in distribute.c */
  PedSector min_blk;
  PedSector max_blk;
  PedSector blocks;
  struct disk_info_t *curdisk;
};

typedef struct diskspace_req_s diskspace_req_t;

struct device_mntpoint_map_s {
  diskspace_req_t *mountpoint;
  char *devpath;
};

typedef struct device_mntpoint_map_s device_mntpoint_map_t;

struct disk_info_t {
    /* Ref to the disk/partition where there is free space */
    const char *path; /* Path to device */
    PedGeometry geom; /* Location of free space */

    PedSector capacity;
    PedSector freespace;
};

/* from distribute.c */
int distribute_partitions(struct disk_info_t diskinfo[],
			  struct diskspace_req_s reqs[]);
struct disk_info_t *get_free_space_list(void);
void print_list(struct disk_info_t diskinfo[], struct diskspace_req_s reqs[]);

/* from loadpartitions.c */
diskspace_req_t * load_partitions(const char *filename);
void free_partition_list(diskspace_req_t *list);
void list_dump(diskspace_req_t *list);
double get_ram_size(void);

/* From choosetable.c */
const char *choose_profile_table(const char *profiles);

void autopartkit_log(const int level, const char * format, ...);
void autopartkit_error (int isfatal, const char * format, ...);

#define MEGABYTE (1024 * 1024)
/* Assumes 2048 byte sector_size */
#define MiB_TO_BLOCKS(mb) ((mb) * 2048l)
#define BLOCKS_TO_MiB(b)  ((b)  / 2048l)

/* from mapdevfs.c */
char *normalize_devfs(const char* path);

/* from lvm.c */
int lvm_init(void);
int lvm_init_dev(const char *devpath);
int lvm_volumegroup_add_dev(const char *vgname, const char *devpath);
char *lvm_create_logicalvolume(const char *vgname, const char *lvname,
			       unsigned int mbsize);
int lvm_split_fstype(const char *str, int separator, int elemcount,
		     char *elements[]);
char *lvm_lv_add(void *stack, const char *fstype, unsigned int mbminsize,
		 unsigned int mbmaxsize);

void *lvm_pv_stack_new(void);
int lvm_pv_stack_isempty(void *stack);
int lvm_pv_stack_push(void *stack, const char *vgname, const char *devpath);
int lvm_pv_stack_pop(void *stack, char **vgname, char **devpath);
int lvm_pv_stack_delete(void *);

void *lvm_lv_stack_new(void);
int lvm_lv_stack_isempty(void *stack);
int lvm_lv_stack_push(void *stack, const char *vgname, const char *lvname,
		      const char *fstype, unsigned int mbminsize,
		      unsigned int mbmaxsize);
int lvm_lv_stack_pop(void *stack, char **vgname, char **lvname,
		     char **fstype, unsigned int *mbminsize,
		     unsigned int *mbmaxsize);
int lvm_lv_stack_delete(void *);

/* andread@linpro.no */
int lvm_get_free_space_list(char*, struct disk_info_t*);
void *reduce_disk_usage_size(struct disk_info_t*,
			     struct diskspace_req_s[],
			     double);
void *lvm_vg_stack_new(void);
int lvm_vg_stack_isempty(void *stack);
int lvm_vg_stack_push(void *stack, const char *vgname);
int lvm_vg_stack_pop(void *stack, char **vgname);
int lvm_vg_stack_delete(void *);


/* from makepath.c */
#include <sys/stat.h>
#include <sys/types.h>
int make_path(const char *pathname, mode_t mode);

/* ext3 is not supported by libparted v1.4, nor v1.6. */
#define DEFAULT_FS "ext2"

/* from evaluator.c */
double evaluate(const char *expression);

#endif /* AUTOPARTKIT_H */