err(3)/warn(3) cleanup
This commit is contained in:
parent
af9d87e0d8
commit
8ffd59e28b
|
@ -42,7 +42,7 @@ static char copyright[] =
|
|||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)clri.c 8.2 (Berkeley) 9/23/93";*/
|
||||
static char *rcsid = "$Id: clri.c,v 1.6 1994/06/08 18:55:13 mycroft Exp $";
|
||||
static char *rcsid = "$Id: clri.c,v 1.7 1994/09/23 02:18:30 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -85,29 +85,20 @@ main(argc, argv)
|
|||
err(1, "%s", fs);
|
||||
if (lseek(fd, (off_t)(SBLOCK * DEV_BSIZE), SEEK_SET) < 0)
|
||||
err(1, "%s", fs);
|
||||
if (read(fd, sblock, sizeof(sblock)) != sizeof(sblock)) {
|
||||
(void)fprintf(stderr,
|
||||
"clri: %s: can't read the superblock.\n", fs);
|
||||
exit(1);
|
||||
}
|
||||
if (read(fd, sblock, sizeof(sblock)) != sizeof(sblock))
|
||||
errx(1, "%s: can't read superblock", fs);
|
||||
|
||||
sbp = (struct fs *)sblock;
|
||||
if (sbp->fs_magic != FS_MAGIC) {
|
||||
(void)fprintf(stderr,
|
||||
"clri: %s: superblock magic number 0x%x, not 0x%x.\n",
|
||||
if (sbp->fs_magic != FS_MAGIC)
|
||||
errx(1, "%s: superblock magic number 0x%x, not 0x%x",
|
||||
fs, sbp->fs_magic, FS_MAGIC);
|
||||
exit(1);
|
||||
}
|
||||
bsize = sbp->fs_bsize;
|
||||
|
||||
/* remaining arguments are inode numbers. */
|
||||
while (*++argv) {
|
||||
/* get the inode number. */
|
||||
if ((inonum = atoi(*argv)) <= 0) {
|
||||
(void)fprintf(stderr,
|
||||
"clri: %s is not a valid inode number.\n", *argv);
|
||||
exit(1);
|
||||
}
|
||||
if ((inonum = atoi(*argv)) <= 0)
|
||||
errx(1, "%s is not a valid inode number", *argv);
|
||||
(void)printf("clearing %d\n", inonum);
|
||||
|
||||
/* read in the appropriate block. */
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)dumprmt.c 8.1 (Berkeley) 6/5/93";*/
|
||||
static char *rcsid = "$Id: dumprmt.c,v 1.6 1994/06/08 18:57:34 mycroft Exp $";
|
||||
static char *rcsid = "$Id: dumprmt.c,v 1.7 1994/09/23 02:18:33 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -55,6 +55,7 @@ static char *rcsid = "$Id: dumprmt.c,v 1.6 1994/06/08 18:57:34 mycroft Exp $";
|
|||
#include <protocols/dumprestore.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <netdb.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
|
@ -106,8 +107,7 @@ static void
|
|||
rmtconnaborted()
|
||||
{
|
||||
|
||||
(void) fprintf(stderr, "rdump: Lost connection to remote host.\n");
|
||||
exit(1);
|
||||
errx(1, "Lost connection to remote host.");
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -125,16 +125,11 @@ rmtgetconn()
|
|||
|
||||
if (sp == NULL) {
|
||||
sp = getservbyname("shell", "tcp");
|
||||
if (sp == NULL) {
|
||||
(void) fprintf(stderr,
|
||||
"rdump: shell/tcp: unknown service\n");
|
||||
exit(1);
|
||||
}
|
||||
if (sp == NULL)
|
||||
errx(1, "shell/tcp: unknown service");
|
||||
pwd = getpwuid(getuid());
|
||||
if (pwd == NULL) {
|
||||
(void) fprintf(stderr, "rdump: who are you?\n");
|
||||
exit(1);
|
||||
}
|
||||
if (pwd == NULL)
|
||||
errx(1, "who are you?");
|
||||
}
|
||||
if ((cp = index(rmtpeer, '@')) != NULL) {
|
||||
tuser = rmtpeer;
|
||||
|
@ -176,8 +171,7 @@ okname(cp0)
|
|||
for (cp = cp0; *cp; cp++) {
|
||||
c = *cp;
|
||||
if (!isascii(c) || !(isalnum(c) || c == '_' || c == '-')) {
|
||||
(void) fprintf(stderr, "rdump: invalid user name %s\n",
|
||||
cp0);
|
||||
warnx("invalid user name: %s", cp0);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ static char copyright[] =
|
|||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)dumpfs.c 8.2 (Berkeley) 2/2/94";*/
|
||||
static char *rcsid = "$Id: dumpfs.c,v 1.6 1994/06/08 18:58:23 mycroft Exp $";
|
||||
static char *rcsid = "$Id: dumpfs.c,v 1.7 1994/09/23 02:18:35 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -48,13 +48,14 @@ static char *rcsid = "$Id: dumpfs.c,v 1.6 1994/06/08 18:58:23 mycroft Exp $";
|
|||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstab.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
union {
|
||||
struct fs fs;
|
||||
|
@ -83,7 +84,7 @@ main(argc, argv)
|
|||
register struct fstab *fs;
|
||||
int ch, eval;
|
||||
|
||||
while ((ch = getopt(argc, argv, "")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "")) != -1)
|
||||
switch(ch) {
|
||||
case '?':
|
||||
default:
|
||||
|
@ -213,7 +214,7 @@ dumpfs(name)
|
|||
|
||||
err: if (fd != -1)
|
||||
(void)close(fd);
|
||||
(void)fprintf(stderr, "dumpfs: %s: %s\n", name, strerror(errno));
|
||||
warn("%s", name);
|
||||
return (1);
|
||||
};
|
||||
|
||||
|
@ -230,7 +231,7 @@ dumpcg(name, fd, c)
|
|||
SEEK_SET)) == (off_t)-1)
|
||||
return (1);
|
||||
if (read(fd, &acg, afs.fs_bsize) != afs.fs_bsize) {
|
||||
(void)fprintf(stderr, "dumpfs: %s: error reading cg\n", name);
|
||||
warnx("%s: error reading cg", name);
|
||||
return (1);
|
||||
}
|
||||
printf("magic\t%x\ttell\t%qx\ttime\t%s",
|
||||
|
@ -311,6 +312,7 @@ pbits(vp, max)
|
|||
void
|
||||
usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "usage: dumpfs filesys | device\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ static char copyright[] =
|
|||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)dumplfs.c 8.1 (Berkeley) 6/5/93";
|
||||
/*static char sccsid[] = "from: @(#)dumplfs.c 8.1 (Berkeley) 6/5/93";*/
|
||||
static char *rcsid = "$Id: dumplfs.c,v 1.2 1994/09/23 02:18:37 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -49,13 +50,14 @@ static char sccsid[] = "@(#)dumplfs.c 8.1 (Berkeley) 6/5/93";
|
|||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/lfs/lfs.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstab.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "extern.h"
|
||||
|
||||
static void addseg __P((char *));
|
||||
|
@ -112,7 +114,7 @@ main(argc, argv)
|
|||
|
||||
do_allsb = 0;
|
||||
do_ientries = 0;
|
||||
while ((ch = getopt(argc, argv, "ais:")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "ais:")) != -1)
|
||||
switch(ch) {
|
||||
case 'a': /* Dump all superblocks */
|
||||
do_allsb = 1;
|
||||
|
@ -134,7 +136,7 @@ main(argc, argv)
|
|||
|
||||
special = argv[0];
|
||||
if ((fd = open(special, O_RDONLY, 0)) < 0)
|
||||
err("%s: %s", special, strerror(errno));
|
||||
err(1, "%s", special);
|
||||
|
||||
/* Read the first superblock */
|
||||
get(fd, LFS_LABELPAD, &lfs_sb1, sizeof(struct lfs));
|
||||
|
@ -194,7 +196,7 @@ dump_ifile(fd, lfsp, do_ientries)
|
|||
addr = lfsp->lfs_idaddr;
|
||||
|
||||
if (!(dpage = malloc(psize)))
|
||||
err("%s", strerror(errno));
|
||||
err(1, "malloc");
|
||||
get(fd, addr << daddr_shift, dpage, psize);
|
||||
|
||||
for (dip = dpage + INOPB(lfsp) - 1; dip >= dpage; --dip)
|
||||
|
@ -202,7 +204,7 @@ dump_ifile(fd, lfsp, do_ientries)
|
|||
break;
|
||||
|
||||
if (dip < dpage)
|
||||
err("unable to locate ifile inode");
|
||||
errx(1, "unable to locate ifile inode");
|
||||
|
||||
(void)printf("\nIFILE inode\n");
|
||||
dump_dinode(dip);
|
||||
|
@ -213,7 +215,7 @@ dump_ifile(fd, lfsp, do_ientries)
|
|||
|
||||
/* Get the direct block */
|
||||
if ((ipage = malloc(psize)) == NULL)
|
||||
err("%s", strerror(errno));
|
||||
err(1, "malloc");
|
||||
for (inum = 0, addrp = dip->di_db, i = 0; i < block_limit;
|
||||
i++, addrp++) {
|
||||
get(fd, *addrp << daddr_shift, ipage, psize);
|
||||
|
@ -241,7 +243,7 @@ dump_ifile(fd, lfsp, do_ientries)
|
|||
|
||||
/* Dump out blocks off of single indirect block */
|
||||
if (!(indir = malloc(psize)))
|
||||
err("%s", strerror(errno));
|
||||
err(1, "malloc");
|
||||
get(fd, dip->di_ib[0] << daddr_shift, indir, psize);
|
||||
block_limit = MIN(i + lfsp->lfs_nindir, nblocks);
|
||||
for (addrp = indir; i < block_limit; i++, addrp++) {
|
||||
|
@ -271,7 +273,7 @@ dump_ifile(fd, lfsp, do_ientries)
|
|||
|
||||
/* Get the double indirect block */
|
||||
if (!(dindir = malloc(psize)))
|
||||
err("%s", strerror(errno));
|
||||
err(1, "malloc");
|
||||
get(fd, dip->di_ib[1] << daddr_shift, dindir, psize);
|
||||
for (iaddrp = dindir, j = 0; j < lfsp->lfs_nindir; j++, iaddrp++) {
|
||||
if (*iaddrp == LFS_UNUSED_DADDR)
|
||||
|
@ -586,7 +588,7 @@ addseg(arg)
|
|||
SEGLIST *p;
|
||||
|
||||
if ((p = malloc(sizeof(SEGLIST))) == NULL)
|
||||
err("%s", strerror(errno));
|
||||
err(1, "malloc");
|
||||
p->next = seglist;
|
||||
p->num = atoi(arg);
|
||||
seglist = p;
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)extern.h 8.1 (Berkeley) 6/5/93
|
||||
* from: @(#)extern.h 8.1 (Berkeley) 6/5/93
|
||||
* $Id: extern.h,v 1.2 1994/09/23 02:18:40 mycroft Exp $
|
||||
*/
|
||||
|
||||
void err __P((const char *, ...));
|
||||
void get __P((int, off_t, void *, size_t));
|
||||
|
||||
extern char *special;
|
||||
|
|
|
@ -32,15 +32,18 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/5/93";
|
||||
/*static char sccsid[] = "from: @(#)misc.c 8.1 (Berkeley) 6/5/93";*/
|
||||
static char *rcsid = "$Id: misc.c,v 1.2 1994/09/23 02:18:42 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "extern.h"
|
||||
|
||||
void
|
||||
|
@ -53,38 +56,9 @@ get(fd, off, p, len)
|
|||
int rbytes;
|
||||
|
||||
if (lseek(fd, off, SEEK_SET) < 0)
|
||||
err("%s: %s", special, strerror(errno));
|
||||
err(1, "%s", special);
|
||||
if ((rbytes = read(fd, p, len)) < 0)
|
||||
err("%s: %s", special, strerror(errno));
|
||||
err(1, "%s", special);
|
||||
if (rbytes != len)
|
||||
err("%s: short read (%d, not %d)", special, rbytes, len);
|
||||
}
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
err(const char *fmt, ...)
|
||||
#else
|
||||
err(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "dumplfs: ");
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
exit(1);
|
||||
/* NOTREACHED */
|
||||
errx(1, "%s: short read (%d, not %d)", special, rbytes, len);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ static char copyright[] =
|
|||
|
||||
#ifndef lint
|
||||
/*static char sccsid[] = "from: @(#)dumpfs.c 8.2 (Berkeley) 2/2/94";*/
|
||||
static char *rcsid = "$Id: dumpfs.c,v 1.6 1994/06/08 18:58:23 mycroft Exp $";
|
||||
static char *rcsid = "$Id: dumpfs.c,v 1.7 1994/09/23 02:18:35 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -48,13 +48,14 @@ static char *rcsid = "$Id: dumpfs.c,v 1.6 1994/06/08 18:58:23 mycroft Exp $";
|
|||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/ffs/fs.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstab.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
union {
|
||||
struct fs fs;
|
||||
|
@ -83,7 +84,7 @@ main(argc, argv)
|
|||
register struct fstab *fs;
|
||||
int ch, eval;
|
||||
|
||||
while ((ch = getopt(argc, argv, "")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "")) != -1)
|
||||
switch(ch) {
|
||||
case '?':
|
||||
default:
|
||||
|
@ -213,7 +214,7 @@ dumpfs(name)
|
|||
|
||||
err: if (fd != -1)
|
||||
(void)close(fd);
|
||||
(void)fprintf(stderr, "dumpfs: %s: %s\n", name, strerror(errno));
|
||||
warn("%s", name);
|
||||
return (1);
|
||||
};
|
||||
|
||||
|
@ -230,7 +231,7 @@ dumpcg(name, fd, c)
|
|||
SEEK_SET)) == (off_t)-1)
|
||||
return (1);
|
||||
if (read(fd, &acg, afs.fs_bsize) != afs.fs_bsize) {
|
||||
(void)fprintf(stderr, "dumpfs: %s: error reading cg\n", name);
|
||||
warnx("%s: error reading cg", name);
|
||||
return (1);
|
||||
}
|
||||
printf("magic\t%x\ttell\t%qx\ttime\t%s",
|
||||
|
@ -311,6 +312,7 @@ pbits(vp, max)
|
|||
void
|
||||
usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr, "usage: dumpfs filesys | device\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ static char copyright[] =
|
|||
#endif /* not lint */
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)dumplfs.c 8.1 (Berkeley) 6/5/93";
|
||||
/*static char sccsid[] = "from: @(#)dumplfs.c 8.1 (Berkeley) 6/5/93";*/
|
||||
static char *rcsid = "$Id: dumplfs.c,v 1.2 1994/09/23 02:18:37 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
|
@ -49,13 +50,14 @@ static char sccsid[] = "@(#)dumplfs.c 8.1 (Berkeley) 6/5/93";
|
|||
#include <ufs/ufs/dinode.h>
|
||||
#include <ufs/lfs/lfs.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstab.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "extern.h"
|
||||
|
||||
static void addseg __P((char *));
|
||||
|
@ -112,7 +114,7 @@ main(argc, argv)
|
|||
|
||||
do_allsb = 0;
|
||||
do_ientries = 0;
|
||||
while ((ch = getopt(argc, argv, "ais:")) != EOF)
|
||||
while ((ch = getopt(argc, argv, "ais:")) != -1)
|
||||
switch(ch) {
|
||||
case 'a': /* Dump all superblocks */
|
||||
do_allsb = 1;
|
||||
|
@ -134,7 +136,7 @@ main(argc, argv)
|
|||
|
||||
special = argv[0];
|
||||
if ((fd = open(special, O_RDONLY, 0)) < 0)
|
||||
err("%s: %s", special, strerror(errno));
|
||||
err(1, "%s", special);
|
||||
|
||||
/* Read the first superblock */
|
||||
get(fd, LFS_LABELPAD, &lfs_sb1, sizeof(struct lfs));
|
||||
|
@ -194,7 +196,7 @@ dump_ifile(fd, lfsp, do_ientries)
|
|||
addr = lfsp->lfs_idaddr;
|
||||
|
||||
if (!(dpage = malloc(psize)))
|
||||
err("%s", strerror(errno));
|
||||
err(1, "malloc");
|
||||
get(fd, addr << daddr_shift, dpage, psize);
|
||||
|
||||
for (dip = dpage + INOPB(lfsp) - 1; dip >= dpage; --dip)
|
||||
|
@ -202,7 +204,7 @@ dump_ifile(fd, lfsp, do_ientries)
|
|||
break;
|
||||
|
||||
if (dip < dpage)
|
||||
err("unable to locate ifile inode");
|
||||
errx(1, "unable to locate ifile inode");
|
||||
|
||||
(void)printf("\nIFILE inode\n");
|
||||
dump_dinode(dip);
|
||||
|
@ -213,7 +215,7 @@ dump_ifile(fd, lfsp, do_ientries)
|
|||
|
||||
/* Get the direct block */
|
||||
if ((ipage = malloc(psize)) == NULL)
|
||||
err("%s", strerror(errno));
|
||||
err(1, "malloc");
|
||||
for (inum = 0, addrp = dip->di_db, i = 0; i < block_limit;
|
||||
i++, addrp++) {
|
||||
get(fd, *addrp << daddr_shift, ipage, psize);
|
||||
|
@ -241,7 +243,7 @@ dump_ifile(fd, lfsp, do_ientries)
|
|||
|
||||
/* Dump out blocks off of single indirect block */
|
||||
if (!(indir = malloc(psize)))
|
||||
err("%s", strerror(errno));
|
||||
err(1, "malloc");
|
||||
get(fd, dip->di_ib[0] << daddr_shift, indir, psize);
|
||||
block_limit = MIN(i + lfsp->lfs_nindir, nblocks);
|
||||
for (addrp = indir; i < block_limit; i++, addrp++) {
|
||||
|
@ -271,7 +273,7 @@ dump_ifile(fd, lfsp, do_ientries)
|
|||
|
||||
/* Get the double indirect block */
|
||||
if (!(dindir = malloc(psize)))
|
||||
err("%s", strerror(errno));
|
||||
err(1, "malloc");
|
||||
get(fd, dip->di_ib[1] << daddr_shift, dindir, psize);
|
||||
for (iaddrp = dindir, j = 0; j < lfsp->lfs_nindir; j++, iaddrp++) {
|
||||
if (*iaddrp == LFS_UNUSED_DADDR)
|
||||
|
@ -586,7 +588,7 @@ addseg(arg)
|
|||
SEGLIST *p;
|
||||
|
||||
if ((p = malloc(sizeof(SEGLIST))) == NULL)
|
||||
err("%s", strerror(errno));
|
||||
err(1, "malloc");
|
||||
p->next = seglist;
|
||||
p->num = atoi(arg);
|
||||
seglist = p;
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)extern.h 8.1 (Berkeley) 6/5/93
|
||||
* from: @(#)extern.h 8.1 (Berkeley) 6/5/93
|
||||
* $Id: extern.h,v 1.2 1994/09/23 02:18:40 mycroft Exp $
|
||||
*/
|
||||
|
||||
void err __P((const char *, ...));
|
||||
void get __P((int, off_t, void *, size_t));
|
||||
|
||||
extern char *special;
|
||||
|
|
|
@ -32,15 +32,18 @@
|
|||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)misc.c 8.1 (Berkeley) 6/5/93";
|
||||
/*static char sccsid[] = "from: @(#)misc.c 8.1 (Berkeley) 6/5/93";*/
|
||||
static char *rcsid = "$Id: misc.c,v 1.2 1994/09/23 02:18:42 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "extern.h"
|
||||
|
||||
void
|
||||
|
@ -53,38 +56,9 @@ get(fd, off, p, len)
|
|||
int rbytes;
|
||||
|
||||
if (lseek(fd, off, SEEK_SET) < 0)
|
||||
err("%s: %s", special, strerror(errno));
|
||||
err(1, "%s", special);
|
||||
if ((rbytes = read(fd, p, len)) < 0)
|
||||
err("%s: %s", special, strerror(errno));
|
||||
err(1, "%s", special);
|
||||
if (rbytes != len)
|
||||
err("%s: short read (%d, not %d)", special, rbytes, len);
|
||||
}
|
||||
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
err(const char *fmt, ...)
|
||||
#else
|
||||
err(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
(void)fprintf(stderr, "dumplfs: ");
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
exit(1);
|
||||
/* NOTREACHED */
|
||||
errx(1, "%s: short read (%d, not %d)", special, rbytes, len);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue