Project

General

Profile

0007-disklabel64-8-Add-various-static-keyword-Fix-compila.patch

liweitianux, 11/08/2017 07:07 AM

Download (7.81 KB)

View differences:

sbin/disklabel64/disklabel64.c
98 98

  
99 99
extern uint32_t crc32(const void *buf, size_t size);
100 100

  
101
void	makelabel(const char *, const char *, struct disklabel64 *);
102
int	writelabel(int, struct disklabel64 *);
103
void	l_perror(const char *);
104
struct disklabel64 *readlabel(int);
105
struct disklabel64 *makebootarea(int);
106
void	display(FILE *, const struct disklabel64 *);
107
int	edit(struct disklabel64 *, int);
108
int	editit(void);
109
char	*skip(char *);
110
char	*word(char *);
111
int	getasciilabel(FILE *, struct disklabel64 *);
112
int	getasciipartspec(char *, struct disklabel64 *, int, int, uint32_t);
113
int	getasciipartuuid(char *, struct disklabel64 *, int, int, uint32_t);
114
int	checklabel(struct disklabel64 *);
115
void	Warning(const char *, ...) __printflike(1, 2);
116
void	usage(void);
117
struct disklabel64 *getvirginlabel(void);
101
static void	makelabel(const char *, const char *, struct disklabel64 *);
102
static int	writelabel(int, struct disklabel64 *);
103
static void	l_perror(const char *);
104
static void	display(FILE *, const struct disklabel64 *);
105
static int	edit(struct disklabel64 *, int);
106
static int	editit(void);
107
static char	*skip(char *);
108
static char	*word(char *);
109
static int	parse_field_val(char **, char **, u_int64_t *, int);
110
static int	getasciilabel(FILE *, struct disklabel64 *);
111
static int	getasciipartspec(char *, struct disklabel64 *, int, int, uint32_t);
112
static int	getasciipartuuid(char *, struct disklabel64 *, int, int, uint32_t);
113
static int	checklabel(struct disklabel64 *);
114
static void	Warning(const char *, ...) __printflike(1, 2);
115
static void	usage(void);
116
static struct disklabel64 *getvirginlabel(void);
117
static struct disklabel64 *readlabel(int);
118
static struct disklabel64 *makebootarea(int);
118 119

  
119 120
#define	DEFEDITOR	_PATH_VI
120 121
#define	streq(a,b)	(strcmp(a,b) == 0)
121 122

  
122
char	*dkname;
123
char	*specname;
124
char	tmpfil[] = PATH_TMPFILE;
123
static char	*dkname;
124
static char	*specname;
125
static char	tmpfil[] = PATH_TMPFILE;
125 126

  
126
struct	disklabel64 lab;
127
static struct	disklabel64 lab;
127 128

  
128 129
#define MAX_PART ('z')
129 130
#define MAX_NUM_PARTS (1 + MAX_PART - 'a')
130
char    part_size_type[MAX_NUM_PARTS];
131
char    part_offset_type[MAX_NUM_PARTS];
132
int     part_set[MAX_NUM_PARTS];
133

  
134
int	installboot;	/* non-zero if we should install a boot program */
135
int	boot1size;
136
int	boot1lsize;
137
int	boot2size;
138
char	*boot1buf;
139
char	*boot2buf;
140
char	*boot1path;
141
char	*boot2path;
142

  
143
enum	{
131
static char	part_size_type[MAX_NUM_PARTS];
132
static char	part_offset_type[MAX_NUM_PARTS];
133
static int	part_set[MAX_NUM_PARTS];
134

  
135
static int	installboot;	/* non-zero if we should install a boot program */
136
static int	boot1size;
137
static int	boot1lsize;
138
static int	boot2size;
139
static char	*boot1buf;
140
static char	*boot2buf;
141
static char	*boot1path;
142
static char	*boot2path;
143

  
144
static enum {
144 145
	UNSPEC, EDIT, NOWRITE, READ, RESTORE, WRITE, WRITEABLE, WRITEBOOT
145 146
} op = UNSPEC;
146 147

  
147
int	rflag;
148
int	Vflag;
149
int	disable_write;   /* set to disable writing to disk label */
148
static int	rflag;
149
static int	Vflag;
150
static int	disable_write;   /* set to disable writing to disk label */
150 151

  
151 152
#ifdef DEBUG
152
int	debug;
153
static int	debug;
153 154
#define OPTIONS	"BNRWb:denrs:Vw"
154 155
#else
155 156
#define OPTIONS	"BNRWb:enrs:Vw"
......
161 162
	struct disklabel64 *lp;
162 163
	FILE *t;
163 164
	int ch, f = 0, flag, error = 0;
164
	char *name = NULL;
165
	const char *name = NULL;
165 166
	const char *dtype = NULL;
166 167

  
167 168
	while ((ch = getopt(argc, argv, OPTIONS)) != -1)
......
340 341
 * effect, set the names of the primary and secondary boot files
341 342
 * if specified.
342 343
 */
343
void
344
static void
344 345
makelabel(const char *type, const char *name, struct disklabel64 *lp)
345 346
{
346 347
	struct disklabel64 *dp;
......
355 356
	 * NOTE: boot control files may no longer be specified in disktab.
356 357
	 */
357 358
	if (name)
358
		strncpy(lp->d_packname, name, sizeof(lp->d_packname));
359
		strncpy((char *)lp->d_packname, name, sizeof(lp->d_packname));
359 360
}
360 361

  
361
int
362
static int
362 363
writelabel(int f, struct disklabel64 *lp)
363 364
{
364 365
	struct disklabel64 *blp;
......
456 457
	return (0);
457 458
}
458 459

  
459
void
460
static void
460 461
l_perror(const char *s)
461 462
{
462 463
	switch (errno) {
......
491 492
 * Fetch disklabel for disk.
492 493
 * Use ioctl to get label unless -r flag is given.
493 494
 */
494
struct disklabel64 *
495
static struct disklabel64 *
495 496
readlabel(int f)
496 497
{
497 498
	struct disklabel64 *lp;
......
545 546
 * the label within the area.  The caller will overwrite the label so
546 547
 * we don't actually have to read it.
547 548
 */
548
struct disklabel64 *
549
static struct disklabel64 *
549 550
makebootarea(int f)
550 551
{
551 552
	struct disklabel64 *lp;
......
619 620
	return (lp);
620 621
}
621 622

  
622
void
623
static void
623 624
display(FILE *f, const struct disklabel64 *lp)
624 625
{
625 626
	const struct partition64 *pp;
......
728 729
	fflush(f);
729 730
}
730 731

  
731
int
732
static int
732 733
edit(struct disklabel64 *lp, int f)
733 734
{
734 735
	int c, fd;
......
772 773
	return (1);
773 774
}
774 775

  
775
int
776
static int
776 777
editit(void)
777 778
{
778 779
	int pid, xpid;
......
807 808
	return(!status);
808 809
}
809 810

  
810
char *
811
static char *
811 812
skip(char *cp)
812 813
{
813 814

  
......
818 819
	return (cp);
819 820
}
820 821

  
821
char *
822
static char *
822 823
word(char *cp)
823 824
{
824 825
	char c;
......
838 839
 * in the same format as that put out by display(),
839 840
 * and fill in lp.
840 841
 */
841
int
842
static int
842 843
getasciilabel(FILE *f, struct disklabel64 *lp)
843 844
{
844 845
	char *cp;
......
892 893
			continue;
893 894
		}
894 895
		if (streq(cp, "label")) {
895
			strncpy(lp->d_packname, tp, sizeof (lp->d_packname));
896
			strncpy((char *)lp->d_packname, tp, sizeof(lp->d_packname));
896 897
			continue;
897 898
		}
898 899

  
......
1028 1029
	return (errors == 0);
1029 1030
}
1030 1031

  
1031
static
1032
int
1032
static int
1033 1033
parse_field_val(char **tp, char **cp, u_int64_t *vv, int lineno)
1034 1034
{
1035 1035
	char *tmp;
......
1055 1055
 * Read a partition line into partition `part' in the specified disklabel.
1056 1056
 * Return 0 on success, 1 on failure.
1057 1057
 */
1058
int
1058
static int
1059 1059
getasciipartspec(char *tp, struct disklabel64 *lp, int part,
1060 1060
		 int lineno, uint32_t blksize)
1061 1061
{
......
1178 1178
	return(0);
1179 1179
}
1180 1180

  
1181
int
1181
static int
1182 1182
getasciipartuuid(char *tp, struct disklabel64 *lp, int part,
1183 1183
		 int lineno, uint32_t blksize __unused)
1184 1184
{
......
1203 1203
 * Check disklabel for errors and fill in
1204 1204
 * derived fields according to supplied values.
1205 1205
 */
1206
int
1206
static int
1207 1207
checklabel(struct disklabel64 *lp)
1208 1208
{
1209 1209
	struct partition64 *pp;
......
1460 1460
 */
1461 1461
static struct disklabel64 dlab;
1462 1462

  
1463
struct disklabel64 *
1463
static struct disklabel64 *
1464 1464
getvirginlabel(void)
1465 1465
{
1466 1466
	struct disklabel64 *dl = &dlab;
......
1484 1484
}
1485 1485

  
1486 1486
/*VARARGS1*/
1487
void
1487
static void
1488 1488
Warning(const char *fmt, ...)
1489 1489
{
1490 1490
	va_list ap;
......
1496 1496
	va_end(ap);
1497 1497
}
1498 1498

  
1499
void
1499
static void
1500 1500
usage(void)
1501 1501
{
1502 1502
	fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
1503
-