mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 18:56:38 +00:00
Rewrite function definitions with identifier lists.
A few functions snuck in with K&R style definitions. Also add some missing memory frees. MFC after: 1 week
This commit is contained in:
parent
b0f6acbaf8
commit
e5d0d1c5fb
|
@ -74,7 +74,8 @@ static long blocksthisvol; /* number of blocks on current output file */
|
|||
static char *nexttape;
|
||||
static FILE *popenfp = NULL;
|
||||
|
||||
static int atomic(ssize_t (*)(), int, char *, int);
|
||||
static int atomic_read(int, void *, int);
|
||||
static int atomic_write(int, const void *, int);
|
||||
static void worker(int, int);
|
||||
static void create_workers(void);
|
||||
static void flushtape(void);
|
||||
|
@ -236,7 +237,7 @@ flushtape(void)
|
|||
|
||||
wp->req[trecno].count = 0; /* Sentinel */
|
||||
|
||||
if (atomic(write, wp->fd, (char *)wp->req, siz) != siz)
|
||||
if (atomic_write(wp->fd, (const void *)wp->req, siz) != siz)
|
||||
quit("error writing command pipe: %s\n", strerror(errno));
|
||||
wp->sent = 1; /* we sent a request, read the response later */
|
||||
|
||||
|
@ -247,7 +248,7 @@ flushtape(void)
|
|||
|
||||
/* Read results back from next worker */
|
||||
if (wp->sent) {
|
||||
if (atomic(read, wp->fd, (char *)&got, sizeof got)
|
||||
if (atomic_read(wp->fd, (void *)&got, sizeof got)
|
||||
!= sizeof got) {
|
||||
perror(" DUMP: error reading command pipe in master");
|
||||
dumpabort(0);
|
||||
|
@ -264,8 +265,8 @@ flushtape(void)
|
|||
*/
|
||||
for (i = 0; i < WORKERS; i++) {
|
||||
if (workers[i].sent) {
|
||||
if (atomic(read, workers[i].fd,
|
||||
(char *)&got, sizeof got)
|
||||
if (atomic_read(workers[i].fd,
|
||||
(void *)&got, sizeof got)
|
||||
!= sizeof got) {
|
||||
perror(" DUMP: error reading command pipe in master");
|
||||
dumpabort(0);
|
||||
|
@ -322,7 +323,7 @@ trewind(void)
|
|||
* fixme: punt for now.
|
||||
*/
|
||||
if (workers[f].sent) {
|
||||
if (atomic(read, workers[f].fd, (char *)&got, sizeof got)
|
||||
if (atomic_read(workers[f].fd, (void *)&got, sizeof got)
|
||||
!= sizeof got) {
|
||||
perror(" DUMP: error reading command pipe in master");
|
||||
dumpabort(0);
|
||||
|
@ -446,7 +447,7 @@ rollforward(void)
|
|||
lastspclrec = savedtapea - 1;
|
||||
}
|
||||
size = (char *)ntb - (char *)q;
|
||||
if (atomic(write, wp->fd, (char *)q, size) != size) {
|
||||
if (atomic_write(wp->fd, (const void *)q, size) != size) {
|
||||
perror(" DUMP: error writing command pipe");
|
||||
dumpabort(0);
|
||||
}
|
||||
|
@ -486,7 +487,7 @@ rollforward(void)
|
|||
* worked ok, otherwise the tape is much too short!
|
||||
*/
|
||||
if (wp->sent) {
|
||||
if (atomic(read, wp->fd, (char *)&got, sizeof got)
|
||||
if (atomic_read(wp->fd, (void *)&got, sizeof got)
|
||||
!= sizeof got) {
|
||||
perror(" DUMP: error reading command pipe in master");
|
||||
dumpabort(0);
|
||||
|
@ -676,8 +677,7 @@ dumpabort(int signo __unused)
|
|||
}
|
||||
|
||||
void
|
||||
Exit(status)
|
||||
int status;
|
||||
Exit(int status)
|
||||
{
|
||||
|
||||
#ifdef TDEBUG
|
||||
|
@ -735,8 +735,8 @@ create_workers(void)
|
|||
}
|
||||
|
||||
for (i = 0; i < WORKERS; i++)
|
||||
(void) atomic(write, workers[i].fd,
|
||||
(char *) &workers[(i + 1) % WORKERS].pid,
|
||||
(void) atomic_write(workers[i].fd,
|
||||
(const void *) &workers[(i + 1) % WORKERS].pid,
|
||||
sizeof workers[0].pid);
|
||||
|
||||
master = 0;
|
||||
|
@ -777,7 +777,7 @@ worker(int cmd, int worker_number)
|
|||
/*
|
||||
* Need the pid of the next worker in the loop...
|
||||
*/
|
||||
if ((nread = atomic(read, cmd, (char *)&nextworker, sizeof nextworker))
|
||||
if ((nread = atomic_read(cmd, (void *)&nextworker, sizeof nextworker))
|
||||
!= sizeof nextworker) {
|
||||
quit("master/worker protocol botched - didn't get pid of next worker.\n");
|
||||
}
|
||||
|
@ -785,7 +785,7 @@ worker(int cmd, int worker_number)
|
|||
/*
|
||||
* Get list of blocks to dump, read the blocks into tape buffer
|
||||
*/
|
||||
while ((nread = atomic(read, cmd, (char *)wp->req, reqsiz)) == reqsiz) {
|
||||
while ((nread = atomic_read(cmd, (void *)wp->req, reqsiz)) == reqsiz) {
|
||||
struct req *p = wp->req;
|
||||
|
||||
for (trecno = 0; trecno < ntrec;
|
||||
|
@ -794,8 +794,8 @@ worker(int cmd, int worker_number)
|
|||
blkread(p->dblk, wp->tblock[trecno],
|
||||
p->count * TP_BSIZE);
|
||||
} else {
|
||||
if (p->count != 1 || atomic(read, cmd,
|
||||
(char *)wp->tblock[trecno],
|
||||
if (p->count != 1 || atomic_read(cmd,
|
||||
(void *)wp->tblock[trecno],
|
||||
TP_BSIZE) != TP_BSIZE)
|
||||
quit("master/worker protocol botched.\n");
|
||||
}
|
||||
|
@ -858,7 +858,8 @@ worker(int cmd, int worker_number)
|
|||
* pass size of write back to master
|
||||
* (for EOT handling)
|
||||
*/
|
||||
(void) atomic(write, cmd, (char *)&size, sizeof size);
|
||||
(void)atomic_write(cmd, (const void *)&size,
|
||||
sizeof size);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -873,15 +874,28 @@ worker(int cmd, int worker_number)
|
|||
|
||||
/*
|
||||
* Since a read from a pipe may not return all we asked for,
|
||||
* or a write may not write all we ask if we get a signal,
|
||||
* loop until the count is satisfied (or error).
|
||||
*/
|
||||
static int
|
||||
atomic(ssize_t (*func)(), int fd, char *buf, int count)
|
||||
atomic_read(int fd, void *buf, int count)
|
||||
{
|
||||
int got, need = count;
|
||||
|
||||
while ((got = (*func)(fd, buf, need)) > 0 && (need -= got) > 0)
|
||||
while ((got = read(fd, buf, need)) > 0 && (need -= got) > 0)
|
||||
buf += got;
|
||||
return (got < 0 ? got : count - need);
|
||||
}
|
||||
|
||||
/*
|
||||
* Since a write to a pipe may not write all we ask if we get a signal,
|
||||
* loop until the count is satisfied (or error).
|
||||
*/
|
||||
static int
|
||||
atomic_write(int fd, const void *buf, int count)
|
||||
{
|
||||
int got, need = count;
|
||||
|
||||
while ((got = write(fd, buf, need)) > 0 && (need -= got) > 0)
|
||||
buf += got;
|
||||
return (got < 0 ? got : count - need);
|
||||
}
|
||||
|
|
|
@ -525,6 +525,7 @@ linkup(ino_t orphan, ino_t parentdir, char *name)
|
|||
}
|
||||
}
|
||||
irelse(&ip);
|
||||
free(idesc.id_name);
|
||||
if (lfdir == 0) {
|
||||
pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY");
|
||||
printf("\n\n");
|
||||
|
@ -621,6 +622,7 @@ changeino(ino_t dir, const char *name, ino_t newnum)
|
|||
idesc.id_parent = newnum; /* new value for name */
|
||||
ginode(dir, &ip);
|
||||
error = ckinode(ip.i_dp, &idesc);
|
||||
free(idesc.id_name);
|
||||
irelse(&ip);
|
||||
return (error);
|
||||
}
|
||||
|
@ -655,15 +657,18 @@ makeentry(ino_t parent, ino_t ino, const char *name)
|
|||
}
|
||||
if ((ckinode(dp, &idesc) & ALTERED) != 0) {
|
||||
irelse(&ip);
|
||||
free(idesc.id_name);
|
||||
return (1);
|
||||
}
|
||||
getpathname(pathbuf, parent, parent);
|
||||
if (expanddir(&ip, pathbuf) == 0) {
|
||||
irelse(&ip);
|
||||
free(idesc.id_name);
|
||||
return (0);
|
||||
}
|
||||
retval = ckinode(dp, &idesc) & ALTERED;
|
||||
irelse(&ip);
|
||||
free(idesc.id_name);
|
||||
return (retval);
|
||||
}
|
||||
|
||||
|
|
|
@ -1163,9 +1163,7 @@ allocblk(long startcg, long frags,
|
|||
}
|
||||
|
||||
ufs2_daddr_t
|
||||
std_checkblkavail(blkno, frags)
|
||||
ufs2_daddr_t blkno;
|
||||
long frags;
|
||||
std_checkblkavail(ufs2_daddr_t blkno, long frags)
|
||||
{
|
||||
struct bufarea *cgbp;
|
||||
struct cg *cgp;
|
||||
|
@ -1279,9 +1277,11 @@ getpathname(char *namebuf, ino_t curdir, ino_t ino)
|
|||
ginode(ino, &ip);
|
||||
if ((ckinode(ip.i_dp, &idesc) & FOUND) == 0) {
|
||||
irelse(&ip);
|
||||
free(idesc.id_name);
|
||||
break;
|
||||
}
|
||||
irelse(&ip);
|
||||
free(idesc.id_name);
|
||||
namelookup:
|
||||
idesc.id_number = idesc.id_parent;
|
||||
idesc.id_parent = ino;
|
||||
|
|
|
@ -798,12 +798,8 @@ snapclean(struct inodesc *idesc)
|
|||
* must always have been allocated from a BLK_NOCOPY location.
|
||||
*/
|
||||
int
|
||||
snapblkfree(fs, bno, size, inum, checkblkavail)
|
||||
struct fs *fs;
|
||||
ufs2_daddr_t bno;
|
||||
long size;
|
||||
ino_t inum;
|
||||
ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags);
|
||||
snapblkfree(struct fs *fs, ufs2_daddr_t bno, long size, ino_t inum,
|
||||
ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags))
|
||||
{
|
||||
union dinode *dp;
|
||||
struct inode ip;
|
||||
|
@ -930,10 +926,8 @@ snapblkfree(fs, bno, size, inum, checkblkavail)
|
|||
* block. Here we need to check each block in the buffer.
|
||||
*/
|
||||
void
|
||||
copyonwrite(fs, bp, checkblkavail)
|
||||
struct fs *fs;
|
||||
struct bufarea *bp;
|
||||
ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags);
|
||||
copyonwrite(struct fs *fs, struct bufarea *bp,
|
||||
ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags))
|
||||
{
|
||||
ufs2_daddr_t copyblkno;
|
||||
long i, numblks;
|
||||
|
@ -953,10 +947,8 @@ copyonwrite(fs, bp, checkblkavail)
|
|||
}
|
||||
|
||||
static void
|
||||
chkcopyonwrite(fs, copyblkno, checkblkavail)
|
||||
struct fs *fs;
|
||||
ufs2_daddr_t copyblkno;
|
||||
ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags);
|
||||
chkcopyonwrite(struct fs *fs, ufs2_daddr_t copyblkno,
|
||||
ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags))
|
||||
{
|
||||
struct inode ip;
|
||||
union dinode *dp;
|
||||
|
|
|
@ -602,6 +602,7 @@ fix_extraneous(struct inoinfo *inp, struct inodesc *idesc)
|
|||
if ((ckinode(ip.i_dp, &dotdesc) & FOUND))
|
||||
inp->i_dotdot = dotdesc.id_parent;
|
||||
irelse(&ip);
|
||||
free(dotdesc.id_name);
|
||||
}
|
||||
/*
|
||||
* We have the previously found old name (inp->i_parent) and the
|
||||
|
|
|
@ -384,9 +384,7 @@ blk_isindir(ufs2_daddr_t blk, ino_t ino, ufs_lbn_t lbn)
|
|||
* they will only have usable blocks in them.
|
||||
*/
|
||||
ufs2_daddr_t
|
||||
suj_checkblkavail(blkno, frags)
|
||||
ufs2_daddr_t blkno;
|
||||
long frags;
|
||||
suj_checkblkavail(ufs2_daddr_t blkno, long frags)
|
||||
{
|
||||
struct bufarea *cgbp;
|
||||
struct cg *cgp;
|
||||
|
|
|
@ -44,9 +44,7 @@ void prtblknos(struct fs *fs, union dinode *dp);
|
|||
struct uufsd disk;
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
union dinodep dp;
|
||||
struct fs *fs;
|
||||
|
|
|
@ -53,9 +53,7 @@ static void indirprt(struct fs *, int, ufs_lbn_t, ufs_lbn_t, ufs2_daddr_t,
|
|||
ufs_lbn_t);
|
||||
|
||||
void
|
||||
prtblknos(fs, dp)
|
||||
struct fs *fs;
|
||||
union dinode *dp;
|
||||
prtblknos(struct fs *fs, union dinode *dp)
|
||||
{
|
||||
int i, mode, frags;
|
||||
ufs_lbn_t lbn, lastlbn, len, blksperindir;
|
||||
|
@ -154,13 +152,8 @@ prtblknos(fs, dp)
|
|||
}
|
||||
|
||||
static void
|
||||
indirprt(fs, level, blksperindir, lbn, blkno, lastlbn)
|
||||
struct fs *fs;
|
||||
int level;
|
||||
ufs_lbn_t blksperindir;
|
||||
ufs_lbn_t lbn;
|
||||
ufs2_daddr_t blkno;
|
||||
ufs_lbn_t lastlbn;
|
||||
indirprt(struct fs *fs, int level, ufs_lbn_t blksperindir, ufs_lbn_t lbn,
|
||||
ufs2_daddr_t blkno, ufs_lbn_t lastlbn)
|
||||
{
|
||||
char indir[MAXBSIZE];
|
||||
ufs_lbn_t i, last;
|
||||
|
@ -209,10 +202,7 @@ indirprt(fs, level, blksperindir, lbn, blkno, lastlbn)
|
|||
}
|
||||
|
||||
static const char *
|
||||
distance(fs, lastblk, firstblk)
|
||||
struct fs *fs;
|
||||
ufs2_daddr_t lastblk;
|
||||
ufs2_daddr_t firstblk;
|
||||
distance(struct fs *fs, ufs2_daddr_t lastblk, ufs2_daddr_t firstblk)
|
||||
{
|
||||
ufs2_daddr_t delta;
|
||||
int firstcg, lastcg;
|
||||
|
@ -237,12 +227,8 @@ distance(fs, lastblk, firstblk)
|
|||
static const char *indirname[UFS_NIADDR] = { "First", "Second", "Third" };
|
||||
|
||||
static void
|
||||
printblk(fs, lbn, blkno, numfrags, lastlbn)
|
||||
struct fs *fs;
|
||||
ufs_lbn_t lbn;
|
||||
ufs2_daddr_t blkno;
|
||||
int numfrags;
|
||||
ufs_lbn_t lastlbn;
|
||||
printblk(struct fs *fs, ufs_lbn_t lbn, ufs2_daddr_t blkno, int numfrags,
|
||||
ufs_lbn_t lastlbn)
|
||||
{
|
||||
static int seq;
|
||||
static ufs2_daddr_t totfrags, lastindirblk, lastblk, firstblk;
|
||||
|
|
Loading…
Reference in a new issue