-/* $OpenBSD: disklabel.c,v 1.246 2022/12/04 23:50:46 cheloha Exp $ */
+/* $OpenBSD: disklabel.c,v 1.247 2023/01/04 21:08:08 krw Exp $ */
/*
* Copyright (c) 1987, 1993
}
double
-scale(u_int64_t sz, char unit, struct disklabel *lp)
+scale(u_int64_t sz, char unit, const struct disklabel *lp)
{
double fsz;
* Display a particular partition.
*/
void
-display_partition(FILE *f, struct disklabel *lp, int i, char unit)
+display_partition(FILE *f, const struct disklabel *lp, int i, char unit)
{
- struct partition *pp = &lp->d_partitions[i];
+ const struct partition *pp = &lp->d_partitions[i];
double p_size;
p_size = scale(DL_GETPSIZE(pp), unit, lp);
}
char
-canonical_unit(struct disklabel *lp, char unit)
+canonical_unit(const struct disklabel *lp, char unit)
{
- struct partition *pp;
+ const struct partition *pp;
u_int64_t small;
int i;
}
void
-display(FILE *f, struct disklabel *lp, char unit, int all)
+display(FILE *f, const struct disklabel *lp, char unit, int all)
{
int i;
double d;
-/* $OpenBSD: editor.c,v 1.384 2023/01/04 18:41:25 krw Exp $ */
+/* $OpenBSD: editor.c,v 1.385 2023/01/04 21:08:08 krw Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <millert@openbsd.org>
void editor_resize(struct disklabel *, char *);
void editor_add(struct disklabel *, char *);
void editor_change(struct disklabel *, char *);
-u_int64_t editor_countfree(struct disklabel *);
+u_int64_t editor_countfree(const struct disklabel *);
void editor_delete(struct disklabel *, char *);
void editor_help(void);
void editor_modify(struct disklabel *, char *);
void editor_name(struct disklabel *, char *);
char *getstring(const char *, const char *, const char *);
-u_int64_t getuint64(struct disklabel *, char *, char *, u_int64_t,
+u_int64_t getuint64(const struct disklabel *, char *, char *, u_int64_t,
u_int64_t, int *);
u_int64_t getnumber(char *, char *, u_int32_t, u_int32_t);
int has_overlap(struct disklabel *);
int partition_cmp(const void *, const void *);
-struct partition **sort_partitions(struct disklabel *, int);
+const struct partition **sort_partitions(const struct disklabel *, int);
void getdisktype(struct disklabel *, char *, char *);
-void find_bounds(struct disklabel *);
+void find_bounds(const struct disklabel *);
void set_bounds(struct disklabel *);
void set_duid(struct disklabel *);
-struct diskchunk *free_chunks(struct disklabel *, int);
+struct diskchunk *free_chunks(const struct disklabel *, int);
int micmp(const void *, const void *);
int mpequal(char **, char **);
int get_bsize(struct disklabel *, int);
int get_offset(struct disklabel *, int);
int get_size(struct disklabel *, int);
void zero_partitions(struct disklabel *);
-u_int64_t max_partition_size(struct disklabel *, int);
-void display_edit(struct disklabel *, char);
-void psize(u_int64_t sz, char unit, struct disklabel *lp);
+u_int64_t max_partition_size(const struct disklabel *, int);
+void display_edit(const struct disklabel *, char);
+void psize(u_int64_t sz, char unit, const struct disklabel *lp);
char *get_token(char **);
int apply_unit(double, u_char, u_int64_t *);
int parse_sizespec(const char *, double *, char **);
* CMD_ABORTED ==> ^D on input
*/
u_int64_t
-getuint64(struct disklabel *lp, char *prompt, char *helpstring,
+getuint64(const struct disklabel *lp, char *prompt, char *helpstring,
u_int64_t oval, u_int64_t maxval, int *flags)
{
char buf[21], *p, operator = '\0';
int
has_overlap(struct disklabel *lp)
{
- struct partition **spp;
+ const struct partition **spp;
int i, p1, p2;
char *line = NULL;
size_t linesize = 0;
strncpy(lp->d_packname, p, sizeof(lp->d_packname)); /* checked */
}
-struct partition **
-sort_partitions(struct disklabel *lp, int ignore)
+const struct partition **
+sort_partitions(const struct disklabel *lp, int ignore)
{
- static struct partition *spp[MAXPARTITIONS+2];
+ const static struct partition *spp[MAXPARTITIONS+2];
int i, npartitions;
memset(spp, 0, sizeof(spp));
* Return a list of the "chunks" of free space available
*/
struct diskchunk *
-free_chunks(struct disklabel *lp, int partno)
+free_chunks(const struct disklabel *lp, int partno)
{
- struct partition **spp;
+ const struct partition **spp;
static struct diskchunk chunks[MAXPARTITIONS + 2];
u_int64_t start, stop;
int i, numchunks;
}
void
-find_bounds(struct disklabel *lp)
+find_bounds(const struct disklabel *lp)
{
starting_sector = DL_GETBSTART(lp);
ending_sector = DL_GETBEND(lp);
* Calculate free space.
*/
u_int64_t
-editor_countfree(struct disklabel *lp)
+editor_countfree(const struct disklabel *lp)
{
- struct diskchunk *chunk;
+ const struct diskchunk *chunk;
u_int64_t freesectors = 0;
chunk = free_chunks(lp, -1);
}
void
-mpsave(struct disklabel *lp)
+mpsave(const struct disklabel *lp)
{
int i, j;
char bdev[PATH_MAX], *p;
}
u_int64_t
-max_partition_size(struct disklabel *lp, int partno)
+max_partition_size(const struct disklabel *lp, int partno)
{
struct diskchunk *chunk;
u_int64_t maxsize = 0, offset;
}
void
-psize(u_int64_t sz, char unit, struct disklabel *lp)
+psize(u_int64_t sz, char unit, const struct disklabel *lp)
{
double d = scale(sz, unit, lp);
if (d < 0)
}
void
-display_edit(struct disklabel *lp, char unit)
+display_edit(const struct disklabel *lp, char unit)
{
u_int64_t fr;
int i;
-/* $OpenBSD: extern.h,v 1.34 2022/02/18 17:45:43 krw Exp $ */
+/* $OpenBSD: extern.h,v 1.35 2023/01/04 21:08:08 krw Exp $ */
/*
* Copyright (c) 2003 Theo de Raadt <deraadt@openbsd.org>
#define MEG(x) ((x) * 1024LL * (1024 / DEV_BSIZE))
#define GIG(x) (MEG(x) * 1024LL)
-u_short dkcksum(struct disklabel *);
-char canonical_unit(struct disklabel *, char);
-double scale(u_int64_t, char, struct disklabel *);
-void display(FILE *, struct disklabel *, char, int);
-void display_partition(FILE *, struct disklabel *, int, char);
+u_short dkcksum(const struct disklabel *);
+char canonical_unit(const struct disklabel *, char);
+double scale(u_int64_t, char, const struct disklabel *);
+void display(FILE *, const struct disklabel *, char, int);
+void display_partition(FILE *, const struct disklabel *, int, char);
int duid_parse(struct disklabel *, char *);
int editor(int);
int editor_allocspace(struct disklabel *);
-void mpsave(struct disklabel *);
+void mpsave(const struct disklabel *);
void mpcopy(char **, char **);
void mpfree(char **);
void parse_autotable(char *);