mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
Fix a couple of minor issues with newfs_msdos:
- Do not unnecessarily strdup(). - Check return value of getdiskinfo(), if it failed, bail out. Reviewed by: imp MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D22729
This commit is contained in:
parent
c3cccf95bf
commit
2780a26b6a
2 changed files with 4 additions and 7 deletions
|
|
@ -318,7 +318,8 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
|
|||
bpb.bpbHiddenSecs = o.hidden_sectors;
|
||||
if (!(o.floppy || (o.drive_heads && o.sectors_per_track &&
|
||||
o.bytes_per_sector && o.size && o.hidden_sectors_set))) {
|
||||
getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb);
|
||||
if (getdiskinfo(fd, fname, dtype, o.hidden_sectors_set, &bpb) == -1)
|
||||
goto done;
|
||||
bpb.bpbHugeSectors -= (o.offset / bpb.bpbBytesPerSec);
|
||||
if (bpb.bpbSecPerClust == 0) { /* set defaults */
|
||||
if (bpb.bpbHugeSectors <= 6000) /* about 3MB -> 512 bytes */
|
||||
|
|
@ -423,10 +424,7 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
|
|||
bname = o.bootstrap;
|
||||
if (!strchr(bname, '/')) {
|
||||
snprintf(buf, sizeof(buf), "/boot/%s", bname);
|
||||
if (!(bname = strdup(buf))) {
|
||||
warn(NULL);
|
||||
goto done;
|
||||
}
|
||||
bname = buf;
|
||||
}
|
||||
if ((fd1 = open(bname, O_RDONLY)) == -1 || fstat(fd1, &sb)) {
|
||||
warn("%s", bname);
|
||||
|
|
|
|||
|
|
@ -185,8 +185,7 @@ main(int argc, char *argv[])
|
|||
fname = *argv++;
|
||||
if (!o.create_size && !strchr(fname, '/')) {
|
||||
snprintf(buf, sizeof(buf), "%s%s", _PATH_DEV, fname);
|
||||
if (!(fname = strdup(buf)))
|
||||
err(1, NULL);
|
||||
fname = buf;
|
||||
}
|
||||
dtype = *argv;
|
||||
exit(!!mkfs_msdos(fname, dtype, &o));
|
||||
|
|
|
|||
Loading…
Reference in a new issue