-/* $OpenBSD: cmd.c,v 1.125 2021/07/12 18:31:53 krw Exp $ */
+/* $OpenBSD: cmd.c,v 1.126 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
#include "user.h"
#include "cmd.h"
-int gedit(int);
-int edit(int, struct mbr *);
-int gsetpid(int);
-int setpid(int, struct mbr *);
-int parsepn(char *);
+int gedit(const int);
+int edit(const int, struct mbr *);
+int gsetpid(const int);
+int setpid(const int, struct mbr *);
+int parsepn(const char *);
int ask_num(const char *, int, int, int);
-int ask_pid(int, struct uuid *);
+int ask_pid(const int, struct uuid *);
char *ask_string(const char *, const char *);
extern const unsigned char manpage[];
}
int
-gedit(int pn)
+gedit(const int pn)
{
struct gpt_partition oldgg;
struct gpt_partition *gg;
}
int
-parsepn(char *pnstr)
+parsepn(const char *pnstr)
{
const char *errstr;
int maxpn, pn;
}
int
-edit(int pn, struct mbr *mbr)
+edit(const int pn, struct mbr *mbr)
{
struct prt oldpp;
struct prt *pp;
}
int
-ask_pid(int dflt, struct uuid *guid)
+ask_pid(const int dflt, struct uuid *guid)
{
char lbuf[100], *cp;
int num = -1, status;
-/* $OpenBSD: cmd.h,v 1.22 2021/07/12 18:31:53 krw Exp $ */
+/* $OpenBSD: cmd.h,v 1.23 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
int (*cmd_fcn)(char *, struct mbr *);
char *cmd_help;
};
-extern struct cmd cmd_table[];
+extern const struct cmd cmd_table[];
int Xreinit(char *, struct mbr *);
int Xdisk(char *, struct mbr *);
-/* $OpenBSD: disk.c,v 1.61 2021/07/12 18:31:53 krw Exp $ */
+/* $OpenBSD: disk.c,v 1.62 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
struct disklabel dl;
void
-DISK_open(int rw)
+DISK_open(const int rw)
{
struct stat st;
uint64_t sz, spc;
* to indicate the units that should be used for display.
*/
int
-DISK_printgeometry(char *units)
+DISK_printgeometry(const char *units)
{
const int secsize = unit_types[SECTORS].ut_conversion;
double size;
* errno if the write fails.
*/
int
-DISK_writesector(char *secbuf, off_t where)
+DISK_writesector(const char *secbuf, off_t where)
{
int secsize;
ssize_t len;
-/* $OpenBSD: disk.h,v 1.25 2021/07/12 14:06:19 krw Exp $ */
+/* $OpenBSD: disk.h,v 1.26 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
/* Align partition starts/sizes on 32K-byte boundaries. */
#define BLOCKALIGNMENT 64
-void DISK_open(int);
-int DISK_printgeometry(char *);
+void DISK_open(const int);
+int DISK_printgeometry(const char *);
char *DISK_readsector(off_t);
-int DISK_writesector(char *, off_t);
+int DISK_writesector(const char *, off_t);
extern struct disk disk;
extern struct disklabel dl;
-/* $OpenBSD: gpt.c,v 1.39 2021/07/12 18:31:53 krw Exp $ */
+/* $OpenBSD: gpt.c,v 1.40 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
int lba_start_cmp(const void *e1, const void *e2);
int lba_free(uint64_t *, uint64_t *);
int add_partition(const uint8_t *, const char *, uint64_t);
-int get_header(off_t);
+int get_header(const off_t);
int get_partition_table(void);
int init_gh(void);
-int init_gp(int, uint32_t);
+int init_gp(const int, const uint32_t);
uint32_t crc32(const u_char *, const uint32_t);
int
-get_header(off_t where)
+get_header(const off_t where)
{
char *secbuf;
uint64_t partlastlba, partslen, lba_end;
}
void
-GPT_read(int which)
+GPT_read(const int which)
{
int valid;
}
void
-GPT_print(char *units, int verbosity)
+GPT_print(const char *units, const int verbosity)
{
const int secsize = unit_types[SECTORS].ut_conversion;
struct uuid guid;
}
void
-GPT_print_parthdr(int verbosity)
+GPT_print_parthdr(const int verbosity)
{
printf(" #: type "
" [ start: size ]\n");
}
void
-GPT_print_part(int n, char *units, int verbosity)
+GPT_print_part(const int n, const char *units, const int verbosity)
{
struct uuid guid;
struct gpt_partition *partn = &gp[n];
}
int
-init_gp(int how, uint32_t bootsectors)
+init_gp(const int how, const uint32_t bootsectors)
{
struct gpt_partition oldgp[NGPTPARTITIONS];
const uint8_t gpt_uuid_efi_system[] = GPT_UUID_EFI_SYSTEM;
}
int
-GPT_init(int how, uint32_t bootsectors)
+GPT_init(const int how, const uint32_t bootsectors)
{
int rslt = 0;
}
int
-GPT_get_lba_start(unsigned int pn)
+GPT_get_lba_start(const unsigned int pn)
{
uint64_t bs;
unsigned int i;
}
int
-GPT_get_lba_end(unsigned int pn)
+GPT_get_lba_end(const unsigned int pn)
{
struct gpt_partition **sgp;
uint64_t bs, nextbs, ns;
-/* $OpenBSD: gpt.h,v 1.14 2021/07/11 13:23:18 krw Exp $ */
+/* $OpenBSD: gpt.h,v 1.15 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 2015 Markus Muller <mmu@grummel.net>
* Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-void GPT_read(int);
-int GPT_get_lba_start(unsigned int);
-int GPT_get_lba_end(unsigned int);
+void GPT_read(const int);
+int GPT_get_lba_start(const unsigned int);
+int GPT_get_lba_end(const unsigned int);
-int GPT_init(int, uint32_t);
+int GPT_init(const int, const uint32_t);
int GPT_write(void);
void GPT_zap_headers(void);
-void GPT_print(char *, int);
-void GPT_print_part(int, char *, int);
-void GPT_print_parthdr(int);
+void GPT_print(const char *, const int);
+void GPT_print_part(const int, const char *, const int);
+void GPT_print_parthdr(const int);
extern struct gpt_header gh;
extern struct gpt_partition gp[NGPTPARTITIONS];
-/* $OpenBSD: mbr.c,v 1.83 2021/07/12 14:06:19 krw Exp $ */
+/* $OpenBSD: mbr.c,v 1.84 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
}
void
-MBR_parse(struct dos_mbr *dos_mbr, off_t lba_self, off_t lba_firstembr,
- struct mbr *mbr)
+MBR_parse(const struct dos_mbr *dos_mbr, const off_t lba_self,
+ const off_t lba_firstembr, struct mbr *mbr)
{
struct dos_partition dos_parts[NDOSPART];
int i;
}
void
-MBR_print(struct mbr *mbr, char *units)
+MBR_print(const struct mbr *mbr, const char *units)
{
int i;
}
int
-MBR_read(off_t where, struct dos_mbr *dos_mbr)
+MBR_read(const off_t where, struct dos_mbr *dos_mbr)
{
char *secbuf;
}
int
-MBR_write(off_t where, struct dos_mbr *dos_mbr)
+MBR_write(const off_t where, const struct dos_mbr *dos_mbr)
{
char *secbuf;
-/* $OpenBSD: mbr.h,v 1.33 2021/07/11 19:43:19 krw Exp $ */
+/* $OpenBSD: mbr.h,v 1.34 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
extern struct mbr initial_mbr;
-void MBR_print(struct mbr *, char *);
-void MBR_parse(struct dos_mbr *, off_t, off_t, struct mbr *);
+void MBR_print(const struct mbr *, const char *);
+void MBR_parse(const struct dos_mbr *, const off_t, const off_t,
+ struct mbr *);
void MBR_make(struct mbr *, struct dos_mbr *);
void MBR_init(struct mbr *);
void MBR_init_GPT(struct mbr *);
-int MBR_read(off_t, struct dos_mbr *);
-int MBR_write(off_t, struct dos_mbr *);
+int MBR_read(const off_t, struct dos_mbr *);
+int MBR_write(const off_t, const struct dos_mbr *);
int MBR_protective_mbr(struct mbr *);
#endif /* _MBR_H */
-/* $OpenBSD: misc.c,v 1.74 2021/07/12 18:31:53 krw Exp $ */
+/* $OpenBSD: misc.c,v 1.75 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
};
int
-unit_lookup(char *units)
+unit_lookup(const char *units)
{
int i = 0;
}
int
-string_from_line(char *buf, size_t buflen)
+string_from_line(char *buf, const size_t buflen)
{
static char *line;
static size_t sz;
* adapted from sbin/disklabel/editor.c
*/
uint64_t
-getuint64(char *prompt, uint64_t oval, uint64_t minval, uint64_t maxval)
+getuint64(const char *prompt, uint64_t oval, const uint64_t minval,
+ const uint64_t maxval)
{
char buf[BUFSIZ], *endptr, *p, operator = '\0';
const int secsize = unit_types[SECTORS].ut_conversion;
-/* $OpenBSD: misc.h,v 1.38 2021/07/11 13:51:42 krw Exp $ */
+/* $OpenBSD: misc.h,v 1.39 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
#define _MISC_H
struct unit_type {
- char *abbr;
- int64_t conversion;
- char *lname;
+ char *ut_abbr;
+ int64_t ut_conversion;
+ char *ut_lname;
};
extern struct unit_type unit_types[];
#define SECTORS 1
/* Prototypes */
-int unit_lookup(char *);
-int string_from_line(char *, size_t);
+int unit_lookup(const char *);
+int string_from_line(char *, const size_t);
int ask_yn(const char *);
-uint64_t getuint64(char *, uint64_t, uint64_t, uint64_t);
+uint64_t getuint64(const char *, uint64_t, const uint64_t, const uint64_t);
char *utf16le_to_string(const uint16_t *);
uint16_t *string_to_utf16le(const char *);
-/* $OpenBSD: part.c,v 1.93 2021/07/12 18:31:53 krw Exp $ */
+/* $OpenBSD: part.c,v 1.94 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
#include "misc.h"
#include "part.h"
-int check_chs(struct prt *);
-const char *ascii_id(int);
+int check_chs(const struct prt *);
+const char *ascii_id(const int);
static const struct part_type {
int pt_type;
#endif
int
-PRT_protected_guid(struct uuid *leuuid)
+PRT_protected_guid(const struct uuid *leuuid)
{
struct uuid uuid;
char *str = NULL;
}
const char *
-ascii_id(int id)
+ascii_id(const int id)
{
static char unknown[] = "<Unknown ID>";
int i;
}
void
-PRT_parse(struct dos_partition *dp, off_t lba_self, off_t lba_firstembr,
- struct prt *prt)
+PRT_parse(const struct dos_partition *dp, const off_t lba_self,
+ const off_t lba_firstembr, struct prt *prt)
{
off_t off;
uint32_t t;
}
int
-check_chs(struct prt *prt)
+check_chs(const struct prt *prt)
{
if ( (prt->prt_shead > 255) ||
(prt->prt_ssect >63) ||
}
void
-PRT_make(struct prt *prt, off_t lba_self, off_t lba_firstembr,
+PRT_make(struct prt *prt, const off_t lba_self, const off_t lba_firstembr,
struct dos_partition *dp)
{
off_t off;
}
void
-PRT_print(int num, struct prt *prt, char *units)
+PRT_print(const int num, const struct prt *prt, const char *units)
{
const int secsize = unit_types[SECTORS].ut_conversion;
double size;
}
void
-PRT_fix_BN(struct prt *prt, int pn)
+PRT_fix_BN(struct prt *prt, const int pn)
{
uint32_t spt, tpc, spc;
uint32_t start = 0;
}
char *
-PRT_uuid_to_typename(struct uuid *uuid)
+PRT_uuid_to_typename(const struct uuid *uuid)
{
static char partition_type[UUID_STR_LEN + 1];
char *uuidstr = NULL;
}
int
-PRT_uuid_to_type(struct uuid *uuid)
+PRT_uuid_to_type(const struct uuid *uuid)
{
char *uuidstr;
int entries, i, status, type;
}
struct uuid *
-PRT_type_to_uuid(int type)
+PRT_type_to_uuid(const int type)
{
static struct uuid guid;
int i, entries, status = uuid_s_ok;
-/* $OpenBSD: part.h,v 1.26 2021/07/11 20:51:50 krw Exp $ */
+/* $OpenBSD: part.h,v 1.27 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
};
void PRT_printall(void);
-void PRT_parse(struct dos_partition *, off_t, off_t,
+void PRT_parse(const struct dos_partition *, const off_t, const off_t,
struct prt *);
-void PRT_make(struct prt *, off_t, off_t, struct dos_partition *);
-void PRT_print(int, struct prt *, char *);
-char *PRT_uuid_to_typename(struct uuid *);
-int PRT_uuid_to_type(struct uuid *);
-struct uuid *PRT_type_to_uuid(int);
-int PRT_protected_guid(struct uuid *);
+void PRT_make(struct prt *,const off_t, const off_t, struct dos_partition *);
+void PRT_print(const int, const struct prt *, const char *);
+char *PRT_uuid_to_typename(const struct uuid *);
+int PRT_uuid_to_type(const struct uuid *);
+struct uuid *PRT_type_to_uuid(const int);
+int PRT_protected_guid(const struct uuid *);
/* This does CHS -> bs/ns */
-void PRT_fix_BN(struct prt *, int);
+void PRT_fix_BN(struct prt *, const int);
/* This does bs/ns -> CHS */
void PRT_fix_CHS(struct prt *);
-/* $OpenBSD: user.c,v 1.61 2021/07/12 18:31:53 krw Exp $ */
+/* $OpenBSD: user.c,v 1.62 2021/07/12 22:18:54 krw Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
#include "disk.h"
/* Our command table */
-struct cmd cmd_table[] = {
+const struct cmd cmd_table[] = {
{"help", 1, Xhelp, "Command help list"},
{"manual", 1, Xmanual, "Show entire OpenBSD man page for fdisk"},
{"reinit", 1, Xreinit, "Re-initialize loaded MBR (to defaults)"},
void ask_cmd(char **, char **);
void
-USER_edit(off_t offset, off_t reloff)
+USER_edit(const off_t offset, const off_t reloff)
{
struct dos_mbr dos_mbr;
struct mbr mbr;
}
void
-USER_print_disk(int verbosity)
+USER_print_disk(const int verbosity)
{
struct dos_mbr dos_mbr;
struct mbr mbr;