ansi knf
This commit is contained in:
parent
dacdbbf6ac
commit
f97f509658
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fsck.c,v 1.24 2001/06/18 02:22:33 lukem Exp $ */
|
||||
/* $NetBSD: fsck.c,v 1.25 2001/06/18 02:31:09 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: fsck.c,v 1.24 2001/06/18 02:22:33 lukem Exp $");
|
||||
__RCSID("$NetBSD: fsck.c,v 1.25 2001/06/18 02:31:09 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -80,25 +80,22 @@ static int maxrun = 0;
|
||||
static char *options = NULL;
|
||||
static int flags = 0;
|
||||
|
||||
int main __P((int, char *[]));
|
||||
int main(int, char *[]);
|
||||
|
||||
static int checkfs __P((const char *, const char *, const char *, void *,
|
||||
pid_t *));
|
||||
static int selected __P((const char *));
|
||||
static void addoption __P((char *));
|
||||
static const char *getoptions __P((const char *));
|
||||
static void addentry __P((struct fstypelist *, const char *, const char *));
|
||||
static void maketypelist __P((char *));
|
||||
static void catopt __P((char **, const char *));
|
||||
static void mangle __P((char *, int *, const char ***, int *));
|
||||
static const char *getfslab __P((const char *));
|
||||
static void usage __P((void));
|
||||
static void *isok __P((struct fstab *));
|
||||
static int checkfs(const char *, const char *, const char *, void *, pid_t *);
|
||||
static int selected(const char *);
|
||||
static void addoption(char *);
|
||||
static const char *getoptions(const char *);
|
||||
static void addentry(struct fstypelist *, const char *, const char *);
|
||||
static void maketypelist(char *);
|
||||
static void catopt(char **, const char *);
|
||||
static void mangle(char *, int *, const char ***, int *);
|
||||
static const char *getfslab(const char *);
|
||||
static void usage(void);
|
||||
static void *isok(struct fstab *);
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
struct fstab *fs;
|
||||
int i, rval = 0;
|
||||
@ -198,9 +195,9 @@ main(argc, argv)
|
||||
|
||||
|
||||
static void *
|
||||
isok(fs)
|
||||
struct fstab *fs;
|
||||
isok(struct fstab *fs)
|
||||
{
|
||||
|
||||
if (fs->fs_passno == 0)
|
||||
return NULL;
|
||||
|
||||
@ -215,10 +212,8 @@ isok(fs)
|
||||
|
||||
|
||||
static int
|
||||
checkfs(vfstype, spec, mntpt, auxarg, pidp)
|
||||
const char *vfstype, *spec, *mntpt;
|
||||
void *auxarg;
|
||||
pid_t *pidp;
|
||||
checkfs(const char *vfstype, const char *spec, const char *mntpt, void *auxarg,
|
||||
pid_t *pidp)
|
||||
{
|
||||
/* List of directories containing fsck_xxx subcommands. */
|
||||
static const char *edirs[] = {
|
||||
@ -330,8 +325,7 @@ checkfs(vfstype, spec, mntpt, auxarg, pidp)
|
||||
|
||||
|
||||
static int
|
||||
selected(type)
|
||||
const char *type;
|
||||
selected(const char *type)
|
||||
{
|
||||
struct entry *e;
|
||||
|
||||
@ -345,8 +339,7 @@ selected(type)
|
||||
|
||||
|
||||
static const char *
|
||||
getoptions(type)
|
||||
const char *type;
|
||||
getoptions(const char *type)
|
||||
{
|
||||
struct entry *e;
|
||||
|
||||
@ -358,8 +351,7 @@ getoptions(type)
|
||||
|
||||
|
||||
static void
|
||||
addoption(optstr)
|
||||
char *optstr;
|
||||
addoption(char *optstr)
|
||||
{
|
||||
char *newoptions;
|
||||
struct entry *e;
|
||||
@ -379,10 +371,7 @@ addoption(optstr)
|
||||
|
||||
|
||||
static void
|
||||
addentry(list, type, opts)
|
||||
struct fstypelist *list;
|
||||
const char *type;
|
||||
const char *opts;
|
||||
addentry(struct fstypelist *list, const char *type, const char *opts)
|
||||
{
|
||||
struct entry *e;
|
||||
|
||||
@ -394,8 +383,7 @@ addentry(list, type, opts)
|
||||
|
||||
|
||||
static void
|
||||
maketypelist(fslist)
|
||||
char *fslist;
|
||||
maketypelist(char *fslist)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
@ -416,9 +404,7 @@ maketypelist(fslist)
|
||||
|
||||
|
||||
static void
|
||||
catopt(sp, o)
|
||||
char **sp;
|
||||
const char *o;
|
||||
catopt(char **sp, const char *o)
|
||||
{
|
||||
char *s;
|
||||
size_t i, j;
|
||||
@ -436,10 +422,7 @@ catopt(sp, o)
|
||||
|
||||
|
||||
static void
|
||||
mangle(options, argcp, argvp, maxargcp)
|
||||
char *options;
|
||||
int *argcp, *maxargcp;
|
||||
const char ***argvp;
|
||||
mangle(char *options, int *argcp, const char ***argvp, int *maxargcp)
|
||||
{
|
||||
char *p, *s;
|
||||
int argc, maxargc;
|
||||
@ -477,8 +460,7 @@ mangle(options, argcp, argvp, maxargcp)
|
||||
|
||||
|
||||
const static char *
|
||||
getfslab(str)
|
||||
const char *str;
|
||||
getfslab(const char *str)
|
||||
{
|
||||
struct disklabel dl;
|
||||
int fd;
|
||||
@ -513,7 +495,7 @@ getfslab(str)
|
||||
|
||||
|
||||
static void
|
||||
usage()
|
||||
usage(void)
|
||||
{
|
||||
static const char common[] =
|
||||
"[-dpvlyn] [-T fstype:fsoptions] [-t fstype]";
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fsutil.c,v 1.9 2001/02/19 22:56:19 cgd Exp $ */
|
||||
/* $NetBSD: fsutil.c,v 1.10 2001/06/18 02:31:09 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990, 1993
|
||||
@ -35,17 +35,13 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: fsutil.c,v 1.9 2001/02/19 22:56:19 cgd Exp $");
|
||||
__RCSID("$NetBSD: fsutil.c,v 1.10 2001/06/18 02:31:09 lukem Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#if __STDC__
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
#include <varargs.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <fstab.h>
|
||||
#include <err.h>
|
||||
@ -59,60 +55,47 @@ static const char *dev = NULL;
|
||||
static int hot = 0;
|
||||
static int preen = 0;
|
||||
|
||||
static void vmsg __P((int, const char *, va_list))
|
||||
static void vmsg(int, const char *, va_list)
|
||||
__attribute((__format__(__printf__,2,0)));
|
||||
|
||||
void
|
||||
setcdevname(cd, pr)
|
||||
const char *cd;
|
||||
int pr;
|
||||
setcdevname(const char *cd, int pr)
|
||||
{
|
||||
|
||||
dev = cd;
|
||||
preen = pr;
|
||||
}
|
||||
|
||||
const char *
|
||||
cdevname()
|
||||
cdevname(void)
|
||||
{
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
int
|
||||
hotroot()
|
||||
hotroot(void)
|
||||
{
|
||||
|
||||
return hot;
|
||||
}
|
||||
|
||||
/*VARARGS*/
|
||||
void
|
||||
#if __STDC__
|
||||
errexit(const char *fmt, ...)
|
||||
#else
|
||||
errexit(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
fmt = va_arg(ap, const char *);
|
||||
#endif
|
||||
(void) vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
exit(8);
|
||||
}
|
||||
|
||||
static void
|
||||
vmsg(fatal, fmt, ap)
|
||||
int fatal;
|
||||
const char *fmt;
|
||||
va_list ap;
|
||||
vmsg(int fatal, const char *fmt, va_list ap)
|
||||
{
|
||||
|
||||
if (!fatal && preen)
|
||||
(void) printf("%s: ", dev);
|
||||
|
||||
@ -131,82 +114,46 @@ vmsg(fatal, fmt, ap)
|
||||
|
||||
/*VARARGS*/
|
||||
void
|
||||
#if __STDC__
|
||||
pfatal(const char *fmt, ...)
|
||||
#else
|
||||
pfatal(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
fmt = va_arg(ap, const char *);
|
||||
#endif
|
||||
vmsg(1, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
/*VARARGS*/
|
||||
void
|
||||
#if __STDC__
|
||||
pwarn(const char *fmt, ...)
|
||||
#else
|
||||
pwarn(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
fmt = va_arg(ap, const char *);
|
||||
#endif
|
||||
va_start(ap, fmt);
|
||||
vmsg(0, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void
|
||||
perror(s)
|
||||
const char *s;
|
||||
perror(const char *s)
|
||||
{
|
||||
|
||||
pfatal("%s (%s)", s, strerror(errno));
|
||||
}
|
||||
|
||||
void
|
||||
#if __STDC__
|
||||
panic(const char *fmt, ...)
|
||||
#else
|
||||
panic(va_alist)
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
#if __STDC__
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
const char *fmt;
|
||||
|
||||
va_start(ap);
|
||||
fmt = va_arg(ap, const char *);
|
||||
#endif
|
||||
vmsg(1, fmt, ap);
|
||||
va_end(ap);
|
||||
exit(8);
|
||||
}
|
||||
|
||||
const char *
|
||||
unrawname(name)
|
||||
const char *name;
|
||||
unrawname(const char *name)
|
||||
{
|
||||
static char unrawbuf[32];
|
||||
const char *dp;
|
||||
@ -225,8 +172,7 @@ unrawname(name)
|
||||
}
|
||||
|
||||
const char *
|
||||
rawname(name)
|
||||
const char *name;
|
||||
rawname(const char *name)
|
||||
{
|
||||
static char rawbuf[32];
|
||||
const char *dp;
|
||||
@ -238,8 +184,7 @@ rawname(name)
|
||||
}
|
||||
|
||||
const char *
|
||||
blockcheck(origname)
|
||||
const char *origname;
|
||||
blockcheck(const char *origname)
|
||||
{
|
||||
struct stat stslash, stblock, stchar;
|
||||
const char *newname, *raw;
|
||||
@ -292,8 +237,7 @@ retry:
|
||||
|
||||
|
||||
void *
|
||||
emalloc(s)
|
||||
size_t s;
|
||||
emalloc(size_t s)
|
||||
{
|
||||
void *p;
|
||||
|
||||
@ -305,9 +249,7 @@ emalloc(s)
|
||||
|
||||
|
||||
void *
|
||||
erealloc(p, s)
|
||||
void *p;
|
||||
size_t s;
|
||||
erealloc(void *p, size_t s)
|
||||
{
|
||||
void *q;
|
||||
|
||||
@ -319,8 +261,7 @@ erealloc(p, s)
|
||||
|
||||
|
||||
char *
|
||||
estrdup(s)
|
||||
const char *s;
|
||||
estrdup(const char *s)
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fsutil.h,v 1.5 2001/02/04 19:59:37 christos Exp $ */
|
||||
/* $NetBSD: fsutil.h,v 1.6 2001/06/18 02:31:09 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
|
||||
@ -29,28 +29,28 @@
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
void errexit __P((const char *, ...))
|
||||
void errexit(const char *, ...)
|
||||
__attribute__((__noreturn__,__format__(__printf__,1,2)));
|
||||
void pfatal __P((const char *, ...))
|
||||
void pfatal(const char *, ...)
|
||||
__attribute__((__format__(__printf__,1,2)));
|
||||
void pwarn __P((const char *, ...))
|
||||
void pwarn(const char *, ...)
|
||||
__attribute__((__format__(__printf__,1,2)));
|
||||
void panic __P((const char *, ...))
|
||||
void panic(const char *, ...)
|
||||
__attribute__((__noreturn__,__format__(__printf__,1,2)));
|
||||
const char *rawname __P((const char *));
|
||||
const char *unrawname __P((const char *));
|
||||
const char *blockcheck __P((const char *));
|
||||
const char *cdevname __P((void));
|
||||
void setcdevname __P((const char *, int));
|
||||
int hotroot __P((void));
|
||||
void *emalloc __P((size_t));
|
||||
void *erealloc __P((void *, size_t));
|
||||
char *estrdup __P((const char *));
|
||||
const char *rawname(const char *);
|
||||
const char *unrawname(const char *);
|
||||
const char *blockcheck(const char *);
|
||||
const char *cdevname(void);
|
||||
void setcdevname(const char *, int);
|
||||
int hotroot(void);
|
||||
void *emalloc(size_t);
|
||||
void *erealloc(void *, size_t);
|
||||
char *estrdup(const char *);
|
||||
|
||||
#define CHECK_PREEN 1
|
||||
#define CHECK_VERBOSE 2
|
||||
#define CHECK_DEBUG 4
|
||||
|
||||
struct fstab;
|
||||
int checkfstab __P((int, int, void *(*)(struct fstab *),
|
||||
int (*) (const char *, const char *, const char *, void *, pid_t *)));
|
||||
int checkfstab(int, int, void *(*)(struct fstab *),
|
||||
int (*) (const char *, const char *, const char *, void *, pid_t *));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: preen.c,v 1.19 2001/06/18 02:22:33 lukem Exp $ */
|
||||
/* $NetBSD: preen.c,v 1.20 2001/06/18 02:31:09 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990, 1993
|
||||
@ -38,7 +38,7 @@
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)preen.c 8.5 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: preen.c,v 1.19 2001/06/18 02:22:33 lukem Exp $");
|
||||
__RCSID("$NetBSD: preen.c,v 1.20 2001/06/18 02:31:09 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -69,7 +69,7 @@ TAILQ_HEAD(part, partentry) badh;
|
||||
|
||||
struct diskentry {
|
||||
TAILQ_ENTRY(diskentry) d_entries;
|
||||
char *d_name; /* disk base name */
|
||||
char *d_name; /* disk base name */
|
||||
TAILQ_HEAD(prt, partentry) d_part; /* list of partitions on disk */
|
||||
int d_pid; /* 0 or pid of fsck proc */
|
||||
};
|
||||
@ -78,18 +78,15 @@ TAILQ_HEAD(disk, diskentry) diskh;
|
||||
|
||||
static int nrun = 0, ndisks = 0;
|
||||
|
||||
static struct diskentry *finddisk __P((const char *));
|
||||
static void addpart __P((const char *, const char *, const char *, void *));
|
||||
static int startdisk __P((struct diskentry *,
|
||||
int (*)(const char *, const char *, const char *, void *, pid_t *)));
|
||||
static void printpart __P((void));
|
||||
static struct diskentry *finddisk(const char *);
|
||||
static void addpart(const char *, const char *, const char *, void *);
|
||||
static int startdisk(struct diskentry *,
|
||||
int (*)(const char *, const char *, const char *, void *, pid_t *));
|
||||
static void printpart(void);
|
||||
|
||||
int
|
||||
checkfstab(flags, maxrun, docheck, checkit)
|
||||
int flags, maxrun;
|
||||
void *(*docheck) __P((struct fstab *));
|
||||
int (*checkit) __P((const char *, const char *, const char *, void *,
|
||||
pid_t *));
|
||||
checkfstab(int flags, int maxrun, void *(*docheck)(struct fstab *),
|
||||
int (*checkit)(const char *, const char *, const char *, void *, pid_t *))
|
||||
{
|
||||
struct fstab *fs;
|
||||
struct diskentry *d, *nextdisk;
|
||||
@ -249,8 +246,7 @@ checkfstab(flags, maxrun, docheck, checkit)
|
||||
|
||||
|
||||
static struct diskentry *
|
||||
finddisk(name)
|
||||
const char *name;
|
||||
finddisk(const char *name)
|
||||
{
|
||||
const char *p;
|
||||
size_t len = 0;
|
||||
@ -282,7 +278,7 @@ finddisk(name)
|
||||
|
||||
|
||||
static void
|
||||
printpart()
|
||||
printpart(void)
|
||||
{
|
||||
struct diskentry *d;
|
||||
struct partentry *p;
|
||||
@ -297,9 +293,7 @@ printpart()
|
||||
|
||||
|
||||
static void
|
||||
addpart(type, devname, mntpt, auxarg)
|
||||
const char *type, *devname, *mntpt;
|
||||
void *auxarg;
|
||||
addpart(const char *type, const char *devname, const char *mntpt, void *auxarg)
|
||||
{
|
||||
struct diskentry *d = finddisk(devname);
|
||||
struct partentry *p;
|
||||
@ -321,10 +315,8 @@ addpart(type, devname, mntpt, auxarg)
|
||||
|
||||
|
||||
static int
|
||||
startdisk(d, checkit)
|
||||
struct diskentry *d;
|
||||
int (*checkit) __P((const char *, const char *, const char *, void *,
|
||||
pid_t *));
|
||||
startdisk(struct diskentry *d,
|
||||
int (*checkit)(const char *, const char *, const char *, void *, pid_t *))
|
||||
{
|
||||
struct partentry *p = TAILQ_FIRST(&d->d_part);
|
||||
int rv;
|
||||
|
Loading…
x
Reference in New Issue
Block a user