-/* $OpenBSD: disklabel.c,v 1.251 2023/06/21 12:50:09 krw Exp $ */
+/* $OpenBSD: disklabel.c,v 1.252 2023/07/03 06:07:40 krw Exp $ */
/*
* Copyright (c) 1987, 1993
/* Write new label to disk. */
if (ioctl(f, DIOCWDINFO, lp) == -1) {
warn("DIOCWDINFO");
- return (1);
+ return 1;
}
/* Refresh our copy of the on-disk current label to get UID. */
mpsave(lp);
}
- return (0);
+ return 0;
}
/*
}
unit = toupper((unsigned char)unit);
- return (unit);
+ return unit;
}
void
warn("%s", tmpfil);
if (fd != -1)
close(fd);
- return (1);
+ return 1;
}
display(fp, lp, 0, 1);
fprintf(fp, "\n# Notes:\n");
puts("No changes.");
fclose(fp);
(void) unlink(tmpfil);
- return (0);
+ return 0;
}
*lp = label;
if (writelabel(f, lp) == 0) {
fclose(fp);
(void) unlink(tmpfil);
- return (0);
+ return 0;
}
}
fclose(fp);
break;
}
(void)unlink(tmpfil);
- return (1);
+ return 1;
}
/*
if (ed == NULL || ed[0] == '\0')
ed = _PATH_VI;
if (asprintf(&p, "%s %s", ed, pathname) == -1)
- return (-1);
+ return -1;
argp[2] = p;
sighup = signal(SIGHUP, SIG_IGN);
(void)signal(SIGCHLD, sigchld);
free(p);
errno = saved_errno;
- return (ret);
+ return ret;
}
char *
cp += strspn(cp, " \t");
if (*cp == '\0')
- return (NULL);
- return (cp);
+ return NULL;
+ return cp;
}
char *
cp += strcspn(cp, " \t");
if (*cp == '\0')
- return (NULL);
+ return NULL;
*cp++ = '\0';
cp += strspn(cp, " \t");
if (*cp == '\0')
- return (NULL);
- return (cp);
+ return NULL;
+ return cp;
}
/* Base the max value on the sizeof of the value we are reading */
*p = '\0';
ret = strtonum(nptr, min, max, errstr);
*p = c;
- return (ret);
+ return ret;
}
int
mpcopy(mountpoints, omountpoints);
mpfree(omountpoints, DISCARD);
- return (errors > 0);
+ return errors > 0;
}
/*
if (lp->d_secsize == 0) {
warnx("sector size 0");
- return (1);
+ return 1;
}
if (lp->d_nsectors == 0) {
warnx("sectors/track 0");
- return (1);
+ return 1;
}
if (lp->d_ntracks == 0) {
warnx("tracks/cylinder 0");
- return (1);
+ return 1;
}
if (lp->d_ncylinders == 0) {
warnx("cylinders/unit 0");
"offset %llu", part, DL_GETPSIZE(pp),
DL_GETPOFFSET(pp));
}
- return (errors > 0);
+ return errors > 0;
}
int
lab1.d_bend = lab2.d_bend;
lab1.d_bendh = lab2.d_bendh;
- return (memcmp(&lab1, &lab2, sizeof(struct disklabel)));
+ return memcmp(&lab1, &lab2, sizeof(struct disklabel));
}
void
-/* $OpenBSD: editor.c,v 1.413 2023/06/29 20:10:11 krw Exp $ */
+/* $OpenBSD: editor.c,v 1.414 2023/07/03 06:07:40 krw Exp $ */
/*
* Copyright (c) 1997-2000 Todd C. Miller <millert@openbsd.org>
mpfree(omountpoints, DISCARD);
mpfree(origmountpoints, DISCARD);
mpfree(tmpmountpoints, DISCARD);
- return (error);
+ return error;
}
/*
clearerr(stdin);
putchar('\n');
fputs("Command aborted\n", stderr);
- return (NULL);
+ return NULL;
}
}
n = strlen(buf);
strlcpy(buf, oval, sizeof(buf));
} while (buf[0] == '?');
- return (&buf[0]);
+ return &buf[0];
}
int
}
if (delete && strlen(p) == 1 && *p == '*')
- return (lp->d_npartitions);
+ return lp->d_npartitions;
if (strlen(p) > 1 || *p < 'a' || *p > maxpart || *p == 'c') {
fprintf(stderr, helpfmt, maxpart, delete ? ", or '*'" : "");
pp->p_fstype != FS_UNUSED;
if ((add && !inuse) || (!add && inuse))
- return (partno);
+ return partno;
fprintf(stderr, "Partition '%c' is %sin use.\n", *p,
inuse ? "" : "not ");
done:
- return (-1);
+ return -1;
}
/*
rslt = snprintf(buf, sizeof(buf), "%u", oval);
if (rslt < 0 || (unsigned int)rslt >= sizeof(buf))
- return (CMD_BADVALUE);
+ return CMD_BADVALUE;
p = getstring(prompt, helpstring, buf);
if (p == NULL)
- return (CMD_ABORTED);
+ return CMD_ABORTED;
if (strlen(p) == 0)
- return (oval);
+ return oval;
rval = strtonum(p, 0, maxval, &errstr);
if (errstr != NULL) {
printf("%s must be between 0 and %u\n", prompt, maxval);
- return (CMD_BADVALUE);
+ return CMD_BADVALUE;
}
- return (rval);
+ return rval;
}
/*
p = getstring(prompt, helpstring, buf);
if (p == NULL)
- return (CMD_ABORTED);
+ return CMD_ABORTED;
else if (p[0] == '\0')
rval = oval;
else if (p[0] == '*' && p[1] == '\0')
*flags |= DO_ROUNDING;
#endif
}
- return (rval);
+ return rval;
invalid:
fputs("Invalid entry\n", stderr);
- return (CMD_BADVALUE);
+ return CMD_BADVALUE;
}
/*
}
if (spp[i+1] == NULL) {
free(line);
- return (0);
+ return 0;
}
p1 = 'a' + (spp[i] - lp->d_partitions);
done:
putchar('\n');
free(line);
- return (1);
+ return 1;
}
void
partition_cmp))
err(4, "failed to sort partition table");
- return (spp);
+ return spp;
}
/*
chunks[0].start = starting_sector;
chunks[0].stop = ending_sector;
chunks[1].start = chunks[1].stop = 0;
- return (chunks);
+ return chunks;
}
/* Find chunks of free space */
/* Terminate and return */
chunks[numchunks].start = chunks[numchunks].stop = 0;
- return (chunks);
+ return chunks;
}
void
for (; chunk->start != 0 || chunk->stop != 0; chunk++)
freesectors += CHUNKSZ(chunk);
- return (freesectors);
+ return freesectors;
}
void
if ((mp1[i] != NULL && mp2[i] == NULL) ||
(mp1[i] == NULL && mp2[i] != NULL) ||
(strcmp(mp1[i], mp2[i]) != 0))
- return (0);
+ return 0;
}
- return (1);
+ return 1;
}
void
DL_GETPOFFSET(pp), &flags);
if (ui == CMD_ABORTED || ui == CMD_BADVALUE)
- return (1);
+ return 1;
#ifdef SUN_AAT0
if (partno == 0 && ui != 0) {
fprintf(stderr, "This architecture requires that "
"partition 'a' start at sector 0.\n");
- return (1);
+ return 1;
}
#endif
opp = *pp;
if (alignpartition(lp, partno, offsetalign, 1, ROUND_OFFSET_UP) == 1) {
*pp = opp;
- return (1);
+ return 1;
}
- return (0);
+ return 0;
}
int
DL_GETPSIZE(pp), maxsize, &flags);
if (ui == CMD_ABORTED || ui == CMD_BADVALUE)
- return (1);
+ return 1;
opp = *pp;
DL_SETPSIZE(pp, ui);
if (alignpartition(lp, partno, 1, sizealign, ROUND_SIZE_UP) == 1) {
*pp = opp;
- return (1);
+ return 1;
}
- return (0);
+ return 0;
}
int
u_int32_t frag, fsize;
if (pp->p_fstype != FS_BSDFFS)
- return (0);
+ return 0;
if (pp->p_cpg == 0)
pp->p_cpg = 1;
pp->p_fragblock = DISKLABELV1_FFS_FRAGBLOCK(fsize, frag);
}
#ifdef SUN_CYLCHECK
- return (0);
+ return 0;
#endif
opp = *pp;
sizealign = (DISKLABELV1_FFS_FRAG(pp->p_fragblock) *
if (alignpartition(lp, partno, offsetalign, sizealign, ROUND_OFFSET_UP |
ROUND_SIZE_DOWN | ROUND_SIZE_OVERLAP) == 1) {
*pp = opp;
- return (1);
+ return 1;
}
- return (0);
+ return 0;
}
int
"Filesystem type (usually 4.2BSD or swap)",
fstypenames[pp->p_fstype]);
if (p == NULL) {
- return (1);
+ return 1;
}
for (ui = 0; ui < FSMAXTYPES; ui++) {
if (!strcasecmp(p, fstypenames[ui])) {
"(4.2BSD) or 1 (swap).",
pp->p_fstype, UINT8_MAX);
if (ui == CMD_ABORTED)
- return (1);
+ return 1;
else if (ui == CMD_BADVALUE)
; /* Try again. */
else
}
pp->p_fstype = ui;
}
- return (0);
+ return 0;
}
int
"Where to mount this filesystem (ie: / /var /usr)",
mountpoints[partno] ? mountpoints[partno] : "none");
if (p == NULL)
- return (1);
+ return 1;
if (strcasecmp(p, "none") == 0) {
free(mountpoints[partno]);
mountpoints[partno] = NULL;
fputs("Mount points must start with '/'\n", stderr);
}
- return (0);
+ return 0;
}
int
/* We want all the NULLs at the end... */
if (mi1->mountpoint == NULL && mi2->mountpoint == NULL)
- return (0);
+ return 0;
else if (mi1->mountpoint == NULL)
- return (1);
+ return 1;
else if (mi2->mountpoint == NULL)
- return (-1);
+ return -1;
else
- return (strcmp(mi1->mountpoint, mi2->mountpoint));
+ return strcmp(mi1->mountpoint, mi2->mountpoint);
}
void
maxsize = chunk->stop - offset;
break;
}
- return (maxsize);
+ return maxsize;
}
void
tlen++;
}
if (tlen == 0)
- return (NULL);
+ return NULL;
/* eat whitespace */
while (isspace((u_char)**s))
if ((r = strndup(p, tlen)) == NULL)
err(1, NULL);
- return (r);
+ return r;
}
int
factor *= 1024;
break;
default:
- return (-1);
+ return -1;
}
val *= factor / DEV_BSIZE;
if (val > ULLONG_MAX)
- return (-1);
+ return -1;
*n = val;
- return (0);
+ return 0;
}
int
errno = 0;
*val = strtod(buf, unit);
if (errno == ERANGE || *val < 0 || *val > ULLONG_MAX)
- return (-1); /* too big/small */
+ return -1; /* too big/small */
if (*val == 0 && *unit == buf)
- return (-1); /* No conversion performed. */
+ return -1; /* No conversion performed. */
if (*unit != NULL && *unit[0] == '\0')
*unit = NULL;
- return (0);
+ return 0;
}
int
}
*max = 0;
if (parse_sizespec(buf, &val1, &unit1) == -1)
- return (-1);
+ return -1;
if (p != NULL && p[0] != '\0') {
if (p[0] == '*')
*max = UINT64_MAX;
else
if (parse_sizespec(p, &val2, &unit2) == -1)
- return (-1);
+ return -1;
}
if (unit1 == NULL && (unit1 = unit2) == NULL)
- return (-1);
+ return -1;
if (apply_unit(val1, unit1[0], min) == -1)
- return (-1);
+ return -1;
if (val2 > 0) {
if (apply_unit(val2, unit2[0], max) == -1)
- return (-1);
+ return -1;
} else
if (*max == 0)
*max = *min;
done:
free(buf);
- return (0);
+ return 0;
}
int
*n = strtonum(buf, 0, 100, &errstr);
if (errstr) {
warnx("parse percent %s: %s", buf, errstr);
- return (-1);
+ return -1;
}
free(buf);
- return (0);
+ return 0;
}
int
fprintf(stderr, "'%c' aligned offset %llu lies outside "
"the OpenBSD bounds or inside another partition\n",
'a' + partno, start);
- return (1);
+ return 1;
}
/* Calculate the new 'stop' sector, the sector after the partition. */
if (stop <= start) {
fprintf(stderr, "not enough space\n");
- return (1);
+ return 1;
}
if (start != DL_GETPOFFSET(pp))
if (stop != DL_GETPOFFSET(pp) + DL_GETPSIZE(pp))
DL_SETPSIZE(pp, stop - start);
- return (0);
+ return 0;
}