Page MenuHomeFreeBSD

D27161.1775624350.diff
No OneTemporary

Size
4 KB
Referenced Files
None
Subscribers
None

D27161.1775624350.diff

Index: sbin/growfs/growfs.c
===================================================================
--- sbin/growfs/growfs.c
+++ sbin/growfs/growfs.c
@@ -67,6 +67,7 @@
#include <ctype.h>
#include <err.h>
#include <errno.h>
+#include <sysexits.h>
#include <fcntl.h>
#include <fstab.h>
#include <inttypes.h>
@@ -150,7 +151,7 @@
*/
fscs = (struct csum *)calloc((size_t)1, (size_t)sblock.fs_cssize);
if (fscs == NULL)
- errx(1, "calloc failed");
+ errx(EX_OSERR, "calloc failed");
memcpy(fscs, osblock.fs_csp, osblock.fs_cssize);
free(osblock.fs_csp);
osblock.fs_csp = NULL;
@@ -262,7 +263,7 @@
* and all the alternates back to disk.
*/
if (!Nflag && sbput(fso, &sblock, sblock.fs_ncg) != 0)
- errc(2, EIO, "could not write updated superblock");
+ errc(EX_IOERR, EIO, "could not write updated superblock");
DBG_PRINT0("fscs written\n");
#ifdef FS_DEBUG
@@ -1405,7 +1406,7 @@
size <<= 30;
size <<= 10;
} else
- errx(1, "unknown suffix on -s argument");
+ errx(EX_DATAERR, "unknown suffix on -s argument");
break;
case 'v': /* for compatibility to newfs */
break;
@@ -1429,25 +1430,25 @@
*/
device = getdev(*argv);
if (device == NULL)
- errx(1, "cannot find special device for %s", *argv);
+ errx(EX_UNAVAILABLE, "cannot find special device for %s", *argv);
statfsp = dev_to_statfs(device);
fsi = open(device, O_RDONLY);
if (fsi < 0)
- err(1, "%s", device);
+ err(EX_OSERR, "%s", device);
/*
* Try to guess the slice size if not specified.
*/
if (ioctl(fsi, DIOCGMEDIASIZE, &mediasize) == -1)
- err(1,"DIOCGMEDIASIZE");
+ err(EX_OSERR,"DIOCGMEDIASIZE");
/*
* Check if that partition is suitable for growing a file system.
*/
if (mediasize < 1)
- errx(1, "partition is unavailable");
+ errx(EX_UNAVAILABLE, "partition is unavailable");
/*
* Read the current superblock, and take a backup.
@@ -1455,9 +1456,9 @@
if ((ret = sbget(fsi, &fs, STDSB)) != 0) {
switch (ret) {
case ENOENT:
- errx(1, "superblock not recognized");
+ errx(EX_DATAERR, "superblock not recognized");
default:
- errc(1, ret, "unable to read superblock");
+ errc(EX_OSERR, ret, "unable to read superblock");
}
}
/*
@@ -1465,7 +1466,7 @@
*/
if (fs->fs_clean == 0 ||
(fs->fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) != 0)
- errx(1, "%s is not clean - run fsck.\n", *argv);
+ errx(EX_CONFIG, "%s is not clean - run fsck.\n", *argv);
memcpy(&osblock, fs, fs->fs_sbsize);
free(fs);
memcpy((void *)&fsun1, (void *)&fsun2, osblock.fs_sbsize);
@@ -1486,7 +1487,7 @@
mediasize,
"B", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
- errx(1, "requested size %s is larger "
+ errx(EX_DATAERR, "requested size %s is larger "
"than the available %s", oldsizebuf, newsizebuf);
}
}
@@ -1515,7 +1516,7 @@
* Are we really growing?
*/
if (osblock.fs_size >= sblock.fs_size) {
- errx(1, "we are not growing (%jd->%jd)",
+ errx(EX_UNAVAILABLE, "we are not growing (%jd->%jd)",
(intmax_t)osblock.fs_size, (intmax_t)sblock.fs_size);
}
@@ -1525,7 +1526,7 @@
if (yflag == 0) {
for (j = 0; j < FSMAXSNAP; j++) {
if (sblock.fs_snapinum[j]) {
- errx(1, "active snapshot found in file system; "
+ errx(EX_UNAVAILABLE, "active snapshot found in file system; "
"please remove all snapshots before "
"using growfs");
}
@@ -1570,14 +1571,14 @@
if (statfsp != NULL && (statfsp->f_flags & MNT_RDONLY) == 0) {
fso = open(_PATH_UFSSUSPEND, O_RDWR);
if (fso == -1)
- err(1, "unable to open %s", _PATH_UFSSUSPEND);
+ err(EX_OSERR, "unable to open %s", _PATH_UFSSUSPEND);
error = ioctl(fso, UFSSUSPEND, &statfsp->f_fsid);
if (error != 0)
- err(1, "UFSSUSPEND");
+ err(EX_OSERR, "UFSSUSPEND");
} else {
fso = open(device, O_WRONLY);
if (fso < 0)
- err(1, "%s", device);
+ err(EX_OSERR, "%s", device);
}
}
@@ -1586,7 +1587,7 @@
*/
testbuf = malloc(sblock.fs_fsize);
if (testbuf == NULL)
- err(1, "malloc");
+ err(EX_OSERR, "malloc");
rdfs((ufs2_daddr_t)((size - sblock.fs_fsize) / DEV_BSIZE),
sblock.fs_fsize, testbuf, fsi);
wtfs((ufs2_daddr_t)((size - sblock.fs_fsize) / DEV_BSIZE),
@@ -1640,7 +1641,7 @@
fragroundup(&sblock, sblock.fs_ncg * sizeof(struct csum));
if (osblock.fs_size >= sblock.fs_size)
- errx(1, "not enough new space");
+ errx(EX_IOERR, "not enough new space");
DBG_PRINT0("sblock calculated\n");
@@ -1654,11 +1655,11 @@
if (statfsp != NULL && (statfsp->f_flags & MNT_RDONLY) == 0) {
error = ioctl(fso, UFSRESUME);
if (error != 0)
- err(1, "UFSRESUME");
+ err(EX_OSERR, "UFSRESUME");
}
error = close(fso);
if (error != 0)
- err(1, "close");
+ err(EX_OSERR, "close");
if (statfsp != NULL && (statfsp->f_flags & MNT_RDONLY) != 0)
mount_reload(statfsp);
}

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 8, 4:59 AM (2 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28297845
Default Alt Text
D27161.1775624350.diff (4 KB)

Event Timeline