Add FBSDID. Start errx(3) messages with lowercase. Remove a ')' with no '('.
In usage(), use fprintf(3) instead of errx(3), to make the printed string really start with `usage: ...'. Reviewed by: marcel
This commit is contained in:
parent
efb426e6dd
commit
23938bc9aa
@ -31,10 +31,11 @@
|
|||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
|
||||||
* $FreeBSD$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/disk.h>
|
#include <sys/disk.h>
|
||||||
#include <sys/kerneldump.h>
|
#include <sys/kerneldump.h>
|
||||||
@ -103,7 +104,7 @@ DoFile(const char *device)
|
|||||||
if (!error)
|
if (!error)
|
||||||
error = ioctl(fd, DIOCGSECTORSIZE, §orsize);
|
error = ioctl(fd, DIOCGSECTORSIZE, §orsize);
|
||||||
if (error) {
|
if (error) {
|
||||||
warn("Couldn't find media and/or sector size of %s)", device);
|
warn("couldn't find media and/or sector size of %s", device);
|
||||||
goto closefd;
|
goto closefd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,18 +117,18 @@ DoFile(const char *device)
|
|||||||
lseek(fd, lasthd, SEEK_SET);
|
lseek(fd, lasthd, SEEK_SET);
|
||||||
error = read(fd, &kdhl, sizeof kdhl);
|
error = read(fd, &kdhl, sizeof kdhl);
|
||||||
if (error != sizeof kdhl) {
|
if (error != sizeof kdhl) {
|
||||||
warn("Error reading last dump header at offset %lld in %s",
|
warn("error reading last dump header at offset %lld in %s",
|
||||||
(long long)lasthd, device);
|
(long long)lasthd, device);
|
||||||
goto closefd;
|
goto closefd;
|
||||||
}
|
}
|
||||||
if (memcmp(kdhl.magic, KERNELDUMPMAGIC, sizeof kdhl.magic)) {
|
if (memcmp(kdhl.magic, KERNELDUMPMAGIC, sizeof kdhl.magic)) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
warnx("Magic mismatch on last dump header on %s",
|
warnx("magic mismatch on last dump header on %s",
|
||||||
device);
|
device);
|
||||||
goto closefd;
|
goto closefd;
|
||||||
}
|
}
|
||||||
if (dtoh32(kdhl.version) != KERNELDUMPVERSION) {
|
if (dtoh32(kdhl.version) != KERNELDUMPVERSION) {
|
||||||
warnx("Unknown version (%d) in last dump header on %s",
|
warnx("unknown version (%d) in last dump header on %s",
|
||||||
dtoh32(kdhl.version), device);
|
dtoh32(kdhl.version), device);
|
||||||
goto closefd;
|
goto closefd;
|
||||||
}
|
}
|
||||||
@ -137,7 +138,7 @@ DoFile(const char *device)
|
|||||||
goto nuke;
|
goto nuke;
|
||||||
|
|
||||||
if (kerneldump_parity(&kdhl)) {
|
if (kerneldump_parity(&kdhl)) {
|
||||||
warnx("Parity error on last dump header on %s", device);
|
warnx("parity error on last dump header on %s", device);
|
||||||
goto closefd;
|
goto closefd;
|
||||||
}
|
}
|
||||||
dumpsize = dtoh64(kdhl.dumplength);
|
dumpsize = dtoh64(kdhl.dumplength);
|
||||||
@ -145,12 +146,12 @@ DoFile(const char *device)
|
|||||||
lseek(fd, firsthd, SEEK_SET);
|
lseek(fd, firsthd, SEEK_SET);
|
||||||
error = read(fd, &kdhf, sizeof kdhf);
|
error = read(fd, &kdhf, sizeof kdhf);
|
||||||
if (error != sizeof kdhf) {
|
if (error != sizeof kdhf) {
|
||||||
warn("Error reading first dump header at offset %lld in %s",
|
warn("error reading first dump header at offset %lld in %s",
|
||||||
(long long)firsthd, device);
|
(long long)firsthd, device);
|
||||||
goto closefd;
|
goto closefd;
|
||||||
}
|
}
|
||||||
if (memcmp(&kdhl, &kdhf, sizeof kdhl)) {
|
if (memcmp(&kdhl, &kdhf, sizeof kdhl)) {
|
||||||
warn("First and last dump headers disagree on %s", device);
|
warn("first and last dump headers disagree on %s", device);
|
||||||
goto closefd;
|
goto closefd;
|
||||||
}
|
}
|
||||||
md5 = MD5Data((unsigned char *)&kdhl, sizeof kdhl, NULL);
|
md5 = MD5Data((unsigned char *)&kdhl, sizeof kdhl, NULL);
|
||||||
@ -168,7 +169,7 @@ DoFile(const char *device)
|
|||||||
goto closefd;
|
goto closefd;
|
||||||
}
|
}
|
||||||
} else if (errno != ENOENT) {
|
} else if (errno != ENOENT) {
|
||||||
warn("Error while checking for pre-saved core file");
|
warn("error while checking for pre-saved core file");
|
||||||
goto closefd;
|
goto closefd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,12 +204,12 @@ DoFile(const char *device)
|
|||||||
wl = dumpsize;
|
wl = dumpsize;
|
||||||
error = read(fd, buf, wl);
|
error = read(fd, buf, wl);
|
||||||
if (error != wl) {
|
if (error != wl) {
|
||||||
warn("Read error on %s", device);
|
warn("read error on %s", device);
|
||||||
goto closeall;
|
goto closeall;
|
||||||
}
|
}
|
||||||
error = write(fdcore, buf, wl);
|
error = write(fdcore, buf, wl);
|
||||||
if (error != wl) {
|
if (error != wl) {
|
||||||
warn("Write error on %s.core file", md5);
|
warn("write error on %s.core file", md5);
|
||||||
goto closeall;
|
goto closeall;
|
||||||
}
|
}
|
||||||
dumpsize -= wl;
|
dumpsize -= wl;
|
||||||
@ -227,7 +228,7 @@ DoFile(const char *device)
|
|||||||
lseek(fd, lasthd, SEEK_SET);
|
lseek(fd, lasthd, SEEK_SET);
|
||||||
error = write(fd, &kdhl, sizeof kdhl);
|
error = write(fd, &kdhl, sizeof kdhl);
|
||||||
if (error != sizeof kdhl)
|
if (error != sizeof kdhl)
|
||||||
warn("Error while clearing the dump header");
|
warn("error while clearing the dump header");
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
@ -243,7 +244,7 @@ DoFile(const char *device)
|
|||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
errx(1, "usage: savecore [-cfkv] [directory [device...]]");
|
fprintf(stderr, "usage: savecore [-cfkv] [directory [device...]]\n");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user