svn commit: r237497 - stable/9/sbin/growfs
Edward Tomasz Napierala
trasz at FreeBSD.org
Sat Jun 23 18:58:02 UTC 2012
Author: trasz
Date: Sat Jun 23 18:58:02 2012
New Revision: 237497
URL: http://svn.freebsd.org/changeset/base/237497
Log:
MFC r232548:
Make growfs(8) mostly style compliant. No functional changes,
verified with MD5.
MFC r232858:
After r232548, clang complains about the apparent '=-' operator (a
left-over from ancient C times, and a frequent typo) in growfs.c:
sbin/growfs/growfs.c:1550:8: error: use of unary operator that may be intended as compound assignment (-=) [-Werror]
blkno =- 1;
^~
Use 'blkno = -1' instead, to silence the error.
Modified:
stable/9/sbin/growfs/debug.c
stable/9/sbin/growfs/growfs.c
Directory Properties:
stable/9/sbin/growfs/ (props changed)
Modified: stable/9/sbin/growfs/debug.c
==============================================================================
--- stable/9/sbin/growfs/debug.c Sat Jun 23 18:54:24 2012 (r237496)
+++ stable/9/sbin/growfs/debug.c Sat Jun 23 18:58:02 2012 (r237497)
@@ -44,7 +44,6 @@ static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
-/* ********************************************************** INCLUDES ***** */
#include <sys/param.h>
#include <limits.h>
@@ -57,15 +56,13 @@ static const char rcsid[] =
#ifdef FS_DEBUG
-/* *********************************************************** GLOBALS ***** */
-static FILE *dbg_log=NULL;
-static unsigned int indent=0;
+static FILE *dbg_log = NULL;
+static unsigned int indent = 0;
/*
* prototypes not done here, as they come with debug.h
*/
-/* ********************************************************** dbg_open ***** */
/*
* Open the filehandle where all debug output has to go.
*/
@@ -74,14 +71,13 @@ dbg_open(const char *fn)
{
if (strcmp(fn, "-") == 0)
- dbg_log=fopen("/dev/stdout", "a");
+ dbg_log = fopen("/dev/stdout", "a");
else
- dbg_log=fopen(fn, "a");
+ dbg_log = fopen(fn, "a");
return;
}
-/* ********************************************************* dbg_close ***** */
/*
* Close the filehandle where all debug output went to.
*/
@@ -89,15 +85,14 @@ void
dbg_close(void)
{
- if(dbg_log) {
+ if (dbg_log) {
fclose(dbg_log);
- dbg_log=NULL;
+ dbg_log = NULL;
}
return;
}
-/* ****************************************************** dbg_dump_hex ***** */
/*
* Dump out a full file system block in hex.
*/
@@ -106,17 +101,16 @@ dbg_dump_hex(struct fs *sb, const char *
{
int i, j, k;
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
+
fprintf(dbg_log, "===== START HEXDUMP =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)mem, comment);
indent++;
- for (i=0; i<sb->fs_bsize; i+=24) {
- for (j=0; j<3; j++) {
- for (k=0; k<8; k++) {
+ for (i = 0; i < sb->fs_bsize; i += 24) {
+ for (j = 0; j < 3; j++) {
+ for (k = 0; k < 8; k++)
fprintf(dbg_log, "%02x ", *mem++);
- }
fprintf(dbg_log, " ");
}
fprintf(dbg_log, "\n");
@@ -127,7 +121,6 @@ dbg_dump_hex(struct fs *sb, const char *
return;
}
-/* ******************************************************* dbg_dump_fs ***** */
/*
* Dump the superblock.
*/
@@ -135,12 +128,11 @@ void
dbg_dump_fs(struct fs *sb, const char *comment)
{
#ifdef FSMAXSNAP
- int j;
+ int j;
#endif /* FSMAXSNAP */
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log, "===== START SUPERBLOCK =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)sb, comment);
@@ -308,10 +300,10 @@ dbg_dump_fs(struct fs *sb, const char *c
sb->fs_pendinginodes);
#ifdef FSMAXSNAP
- for(j=0; j<FSMAXSNAP; j++) {
+ for (j = 0; j < FSMAXSNAP; j++) {
fprintf(dbg_log, "snapinum int32_t[%2d] 0x%08x\n",
j, sb->fs_snapinum[j]);
- if(!sb->fs_snapinum[j]) { /* list is dense */
+ if (!sb->fs_snapinum[j]) { /* list is dense */
break;
}
}
@@ -356,7 +348,6 @@ dbg_dump_fs(struct fs *sb, const char *c
return;
}
-/* ******************************************************* dbg_dump_cg ***** */
/*
* Dump a cylinder group.
*/
@@ -365,9 +356,8 @@ dbg_dump_cg(const char *comment, struct
{
int j;
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log, "===== START CYLINDER GROUP =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
@@ -383,7 +373,7 @@ dbg_dump_cg(const char *comment, struct
fprintf(dbg_log, "rotor int32_t 0x%08x\n", cgr->cg_rotor);
fprintf(dbg_log, "frotor int32_t 0x%08x\n", cgr->cg_frotor);
fprintf(dbg_log, "irotor int32_t 0x%08x\n", cgr->cg_irotor);
- for(j=0; j<MAXFRAG; j++) {
+ for (j = 0; j < MAXFRAG; j++) {
fprintf(dbg_log, "frsum int32_t[%d] 0x%08x\n", j,
cgr->cg_frsum[j]);
}
@@ -411,7 +401,6 @@ dbg_dump_cg(const char *comment, struct
return;
}
-/* ***************************************************** dbg_dump_csum ***** */
/*
* Dump a cylinder summary.
*/
@@ -419,9 +408,8 @@ void
dbg_dump_csum(const char *comment, struct csum *cs)
{
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log, "===== START CYLINDER SUMMARY =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment);
@@ -438,7 +426,6 @@ dbg_dump_csum(const char *comment, struc
return;
}
-/* ************************************************ dbg_dump_csum_total ***** */
/*
* Dump a cylinder summary.
*/
@@ -446,9 +433,8 @@ void
dbg_dump_csum_total(const char *comment, struct csum_total *cs)
{
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log, "===== START CYLINDER SUMMARY TOTAL =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cs, comment);
@@ -475,7 +461,6 @@ dbg_dump_csum_total(const char *comment,
return;
}
-/* **************************************************** dbg_dump_inmap ***** */
/*
* Dump the inode allocation map in one cylinder group.
*/
@@ -485,30 +470,29 @@ dbg_dump_inmap(struct fs *sb, const char
int j,k,l,e;
unsigned char *cp;
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log, "===== START INODE ALLOCATION MAP =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
indent++;
- cp=(unsigned char *)cg_inosused(cgr);
- e=sb->fs_ipg/8;
- for(j=0; j<e; j+=32) {
+ cp = (unsigned char *)cg_inosused(cgr);
+ e = sb->fs_ipg / 8;
+ for (j = 0; j < e; j += 32) {
fprintf(dbg_log, "%08x: ", j);
- for(k=0; k<32; k+=8) {
- if(j+k+8<e) {
+ for (k = 0; k < 32; k += 8) {
+ if (j + k + 8 < e) {
fprintf(dbg_log,
"%02x%02x%02x%02x%02x%02x%02x%02x ",
cp[0], cp[1], cp[2], cp[3],
cp[4], cp[5], cp[6], cp[7]);
} else {
- for(l=0; (l<8)&&(j+k+l<e); l++) {
+ for (l = 0; (l < 8) && (j + k + l < e); l++) {
fprintf(dbg_log, "%02x", cp[l]);
}
}
- cp+=8;
+ cp += 8;
}
fprintf(dbg_log, "\n");
}
@@ -520,7 +504,6 @@ dbg_dump_inmap(struct fs *sb, const char
}
-/* **************************************************** dbg_dump_frmap ***** */
/*
* Dump the fragment allocation map in one cylinder group.
*/
@@ -530,33 +513,32 @@ dbg_dump_frmap(struct fs *sb, const char
int j,k,l,e;
unsigned char *cp;
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log, "===== START FRAGMENT ALLOCATION MAP =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
indent++;
- cp=(unsigned char *)cg_blksfree(cgr);
+ cp = (unsigned char *)cg_blksfree(cgr);
if (sb->fs_old_nspf)
- e=howmany((sb->fs_old_cpg * sb->fs_old_spc / sb->fs_old_nspf), CHAR_BIT);
+ e = howmany((sb->fs_old_cpg * sb->fs_old_spc / sb->fs_old_nspf), CHAR_BIT);
else
e = 0;
- for(j=0; j<e; j+=32) {
+ for (j = 0; j < e; j += 32) {
fprintf(dbg_log, "%08x: ", j);
- for(k=0; k<32; k+=8) {
- if(j+k+8<e) {
+ for (k = 0; k < 32; k += 8) {
+ if (j + k + 8 <e) {
fprintf(dbg_log,
"%02x%02x%02x%02x%02x%02x%02x%02x ",
cp[0], cp[1], cp[2], cp[3],
cp[4], cp[5], cp[6], cp[7]);
} else {
- for(l=0; (l<8)&&(j+k+l<e); l++) {
+ for (l = 0; (l < 8) && (j + k + l < e); l++) {
fprintf(dbg_log, "%02x", cp[l]);
}
}
- cp+=8;
+ cp += 8;
}
fprintf(dbg_log, "\n");
}
@@ -567,7 +549,6 @@ dbg_dump_frmap(struct fs *sb, const char
return;
}
-/* **************************************************** dbg_dump_clmap ***** */
/*
* Dump the cluster allocation map in one cylinder group.
*/
@@ -577,33 +558,32 @@ dbg_dump_clmap(struct fs *sb, const char
int j,k,l,e;
unsigned char *cp;
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log, "===== START CLUSTER ALLOCATION MAP =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
indent++;
- cp=(unsigned char *)cg_clustersfree(cgr);
+ cp = (unsigned char *)cg_clustersfree(cgr);
if (sb->fs_old_nspf)
- e=howmany(sb->fs_old_cpg * sb->fs_old_spc / (sb->fs_old_nspf << sb->fs_fragshift), CHAR_BIT);
+ e = howmany(sb->fs_old_cpg * sb->fs_old_spc / (sb->fs_old_nspf << sb->fs_fragshift), CHAR_BIT);
else
e = 0;
- for(j=0; j<e; j+=32) {
+ for (j = 0; j < e; j += 32) {
fprintf(dbg_log, "%08x: ", j);
- for(k=0; k<32; k+=8) {
- if(j+k+8<e) {
+ for (k = 0; k < 32; k += 8) {
+ if (j + k + 8 < e) {
fprintf(dbg_log,
"%02x%02x%02x%02x%02x%02x%02x%02x ",
cp[0], cp[1], cp[2], cp[3],
cp[4], cp[5], cp[6], cp[7]);
} else {
- for(l=0; (l<8)&&(j+k+l<e); l++) {
+ for (l = 0; (l < 8) && (j + k + l <e); l++) {
fprintf(dbg_log, "%02x", cp[l]);
}
}
- cp+=8;
+ cp += 8;
}
fprintf(dbg_log, "\n");
}
@@ -614,7 +594,6 @@ dbg_dump_clmap(struct fs *sb, const char
return;
}
-/* **************************************************** dbg_dump_clsum ***** */
/*
* Dump the cluster availability summary of one cylinder group.
*/
@@ -624,16 +603,15 @@ dbg_dump_clsum(struct fs *sb, const char
int j;
int *ip;
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log, "===== START CLUSTER SUMMARY =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
indent++;
- ip=(int *)cg_clustersum(cgr);
- for(j=0; j<=sb->fs_contigsumsize; j++) {
+ ip = (int *)cg_clustersum(cgr);
+ for (j = 0; j <= sb->fs_contigsumsize; j++) {
fprintf(dbg_log, "%02d: %8d\n", j, *ip++);
}
@@ -651,7 +629,6 @@ dbg_dump_clsum(struct fs *sb, const char
* will leave it disabled for now; it should probably be re-enabled
* specifically for UFS1.
*/
-/* **************************************************** dbg_dump_sptbl ***** */
/*
* Dump the block summary, and the rotational layout table.
*/
@@ -661,23 +638,21 @@ dbg_dump_sptbl(struct fs *sb, const char
int j,k;
int *ip;
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log,
"===== START BLOCK SUMMARY AND POSITION TABLE =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)cgr, comment);
indent++;
- ip=(int *)cg_blktot(cgr);
- for(j=0; j<sb->fs_old_cpg; j++) {
+ ip = (int *)cg_blktot(cgr);
+ for (j = 0; j < sb->fs_old_cpg; j++) {
fprintf(dbg_log, "%2d: %5d = ", j, *ip++);
- for(k=0; k<sb->fs_old_nrpos; k++) {
+ for (k = 0; k < sb->fs_old_nrpos; k++) {
fprintf(dbg_log, "%4d", cg_blks(sb, cgr, j)[k]);
- if(k<sb->fs_old_nrpos-1) {
+ if (k < sb->fs_old_nrpos - 1)
fprintf(dbg_log, " + ");
- }
}
fprintf(dbg_log, "\n");
}
@@ -689,7 +664,6 @@ dbg_dump_sptbl(struct fs *sb, const char
}
#endif
-/* ************************************************** dbg_dump_ufs1_ino ***** */
/*
* Dump a UFS1 inode structure.
*/
@@ -699,9 +673,8 @@ dbg_dump_ufs1_ino(struct fs *sb, const c
int ictr;
int remaining_blocks;
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log, "===== START UFS1 INODE DUMP =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment);
@@ -723,25 +696,25 @@ dbg_dump_ufs1_ino(struct fs *sb, const c
fprintf(dbg_log, "ctimensec int32_t 0x%08x\n",
ino->di_ctimensec);
- remaining_blocks=howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */
- for(ictr=0; ictr < MIN(NDADDR, remaining_blocks); ictr++) {
+ remaining_blocks = howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */
+ for (ictr = 0; ictr < MIN(NDADDR, remaining_blocks); ictr++) {
fprintf(dbg_log, "db ufs_daddr_t[%x] 0x%08x\n", ictr,
ino->di_db[ictr]);
}
- remaining_blocks-=NDADDR;
- if(remaining_blocks>0) {
+ remaining_blocks -= NDADDR;
+ if (remaining_blocks > 0) {
fprintf(dbg_log, "ib ufs_daddr_t[0] 0x%08x\n",
ino->di_ib[0]);
}
- remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs1_daddr_t));
- if(remaining_blocks>0) {
+ remaining_blocks -= howmany(sb->fs_bsize, sizeof(ufs1_daddr_t));
+ if (remaining_blocks > 0) {
fprintf(dbg_log, "ib ufs_daddr_t[1] 0x%08x\n",
ino->di_ib[1]);
}
-#define SQUARE(a) ((a)*(a))
- remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs1_daddr_t)));
+#define SQUARE(a) ((a) * (a))
+ remaining_blocks -= SQUARE(howmany(sb->fs_bsize, sizeof(ufs1_daddr_t)));
#undef SQUARE
- if(remaining_blocks>0) {
+ if (remaining_blocks > 0) {
fprintf(dbg_log, "ib ufs_daddr_t[2] 0x%08x\n",
ino->di_ib[2]);
}
@@ -758,7 +731,6 @@ dbg_dump_ufs1_ino(struct fs *sb, const c
return;
}
-/* ************************************************** dbg_dump_ufs2_ino ***** */
/*
* Dump a UFS2 inode structure.
*/
@@ -768,9 +740,8 @@ dbg_dump_ufs2_ino(struct fs *sb, const c
int ictr;
int remaining_blocks;
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log, "===== START UFS2 INODE DUMP =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)ino, comment);
@@ -785,8 +756,8 @@ dbg_dump_ufs2_ino(struct fs *sb, const c
((unsigned int *)&(ino->di_size))[1],
((unsigned int *)&(ino->di_size))[0]);
fprintf(dbg_log, "blocks u_int64_t 0x%08x%08x\n",
- ((unsigned int *)&(ino->di_blocks))[1],
- ((unsigned int *)&(ino->di_blocks))[0]);
+ ((unsigned int *)&(ino->di_blocks))[1],
+ ((unsigned int *)&(ino->di_blocks))[0]);
fprintf(dbg_log, "atime ufs_time_t %10jd\n", ino->di_atime);
fprintf(dbg_log, "mtime ufs_time_t %10jd\n", ino->di_mtime);
fprintf(dbg_log, "ctime ufs_time_t %10jd\n", ino->di_ctime);
@@ -802,25 +773,25 @@ dbg_dump_ufs2_ino(struct fs *sb, const c
/* XXX: What do we do with di_extb[NXADDR]? */
- remaining_blocks=howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */
- for(ictr=0; ictr < MIN(NDADDR, remaining_blocks); ictr++) {
+ remaining_blocks = howmany(ino->di_size, sb->fs_bsize); /* XXX ts - +1? */
+ for (ictr = 0; ictr < MIN(NDADDR, remaining_blocks); ictr++) {
fprintf(dbg_log, "db ufs2_daddr_t[%x] 0x%16jx\n", ictr,
ino->di_db[ictr]);
}
- remaining_blocks-=NDADDR;
- if(remaining_blocks>0) {
+ remaining_blocks -= NDADDR;
+ if (remaining_blocks > 0) {
fprintf(dbg_log, "ib ufs2_daddr_t[0] 0x%16jx\n",
ino->di_ib[0]);
}
- remaining_blocks-=howmany(sb->fs_bsize, sizeof(ufs2_daddr_t));
- if(remaining_blocks>0) {
+ remaining_blocks -= howmany(sb->fs_bsize, sizeof(ufs2_daddr_t));
+ if (remaining_blocks > 0) {
fprintf(dbg_log, "ib ufs2_daddr_t[1] 0x%16jx\n",
ino->di_ib[1]);
}
-#define SQUARE(a) ((a)*(a))
- remaining_blocks-=SQUARE(howmany(sb->fs_bsize, sizeof(ufs2_daddr_t)));
+#define SQUARE(a) ((a) * (a))
+ remaining_blocks -= SQUARE(howmany(sb->fs_bsize, sizeof(ufs2_daddr_t)));
#undef SQUARE
- if(remaining_blocks>0) {
+ if (remaining_blocks > 0) {
fprintf(dbg_log, "ib ufs2_daddr_t[2] 0x%16jx\n",
ino->di_ib[2]);
}
@@ -831,7 +802,6 @@ dbg_dump_ufs2_ino(struct fs *sb, const c
return;
}
-/* ***************************************************** dbg_dump_iblk ***** */
/*
* Dump an indirect block. The iteration to dump a full file has to be
* written around.
@@ -841,9 +811,8 @@ dbg_dump_iblk(struct fs *sb, const char
{
unsigned int *mem, i, j, size;
- if(!dbg_log) {
+ if (!dbg_log)
return;
- }
fprintf(dbg_log, "===== START INDIRECT BLOCK DUMP =====\n");
fprintf(dbg_log, "# %d@%lx: %s\n", indent, (unsigned long)block,
@@ -855,14 +824,13 @@ dbg_dump_iblk(struct fs *sb, const char
else
size = sizeof(ufs2_daddr_t);
- mem=(unsigned int *)block;
- for (i=0; (size_t)i<MIN(howmany(sb->fs_bsize, size),
- length); i+=8) {
+ mem = (unsigned int *)block;
+ for (i = 0; (size_t)i < MIN(howmany(sb->fs_bsize, size), length);
+ i += 8) {
fprintf(dbg_log, "%04x: ", i);
- for (j=0; j<8; j++) {
- if((size_t)(i+j)<length) {
+ for (j = 0; j < 8; j++) {
+ if ((size_t)(i + j) < length)
fprintf(dbg_log, "%08X ", *mem++);
- }
}
fprintf(dbg_log, "\n");
}
Modified: stable/9/sbin/growfs/growfs.c
==============================================================================
--- stable/9/sbin/growfs/growfs.c Sat Jun 23 18:54:24 2012 (r237496)
+++ stable/9/sbin/growfs/growfs.c Sat Jun 23 18:58:02 2012 (r237497)
@@ -49,7 +49,6 @@ All rights reserved.\n";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-/* ********************************************************** INCLUDES ***** */
#include <sys/param.h>
#include <sys/disklabel.h>
#include <sys/ioctl.h>
@@ -72,7 +71,6 @@ __FBSDID("$FreeBSD$");
#include "debug.h"
-/* *************************************************** GLOBALS & TYPES ***** */
#ifdef FS_DEBUG
int _dbg_lvl_ = (DL_INFO); /* DL_TRC */
#endif /* FS_DEBUG */
@@ -117,7 +115,7 @@ union dinode {
static ufs2_daddr_t inoblk; /* inode block address */
static char inobuf[MAXBSIZE]; /* inode block */
static ino_t maxino; /* last valid inode */
-static int unlabeled; /* unlabeled partition, e.g. vinum volume etc. */
+static int unlabeled; /* unlabeled partition, e.g. vinum volume */
/*
* An array of elements of type struct gfs_bpp describes all blocks to
@@ -130,10 +128,9 @@ struct gfs_bpp {
#define GFS_FL_FIRST 1
#define GFS_FL_LAST 2
unsigned int flags; /* special handling required */
- int found; /* how many references were updated */
+ int found; /* how many references were updated */
};
-/* ******************************************************** PROTOTYPES ***** */
static void growfs(int, int, unsigned int);
static void rdfs(ufs2_daddr_t, size_t, void *, int);
static void wtfs(ufs2_daddr_t, size_t, void *, int, unsigned int);
@@ -158,7 +155,6 @@ static void indirchk(ufs_lbn_t, ufs_lbn_
struct gfs_bpp *, int, int, unsigned int);
static void get_dev_size(int, int *);
-/* ************************************************************ growfs ***** */
/*
* Here we actually start growing the file system. We basically read the
* cylinder summary from the first cylinder group as we want to update
@@ -174,12 +170,12 @@ static void
growfs(int fsi, int fso, unsigned int Nflag)
{
DBG_FUNC("growfs")
- time_t modtime;
- uint cylno;
- int i, j, width;
- char tmpbuf[100];
+ time_t modtime;
+ uint cylno;
+ int i, j, width;
+ char tmpbuf[100];
#ifdef FSIRAND
- static int randinit=0;
+ static int randinit=0;
DBG_ENTER;
@@ -198,37 +194,35 @@ growfs(int fsi, int fso, unsigned int Nf
* Get the cylinder summary into the memory.
*/
fscs = (struct csum *)calloc((size_t)1, (size_t)sblock.fs_cssize);
- if(fscs == NULL) {
+ if (fscs == NULL)
errx(1, "calloc failed");
- }
for (i = 0; i < osblock.fs_cssize; i += osblock.fs_bsize) {
rdfs(fsbtodb(&osblock, osblock.fs_csaddr +
numfrags(&osblock, i)), (size_t)MIN(osblock.fs_cssize - i,
- osblock.fs_bsize), (void *)(((char *)fscs)+i), fsi);
+ osblock.fs_bsize), (void *)(((char *)fscs) + i), fsi);
}
#ifdef FS_DEBUG
-{
- struct csum *dbg_csp;
- int dbg_csc;
- char dbg_line[80];
-
- dbg_csp=fscs;
- for(dbg_csc=0; dbg_csc<osblock.fs_ncg; dbg_csc++) {
- snprintf(dbg_line, sizeof(dbg_line),
- "%d. old csum in old location", dbg_csc);
- DBG_DUMP_CSUM(&osblock,
- dbg_line,
- dbg_csp++);
+ {
+ struct csum *dbg_csp;
+ int dbg_csc;
+ char dbg_line[80];
+
+ dbg_csp = fscs;
+
+ for (dbg_csc = 0; dbg_csc < osblock.fs_ncg; dbg_csc++) {
+ snprintf(dbg_line, sizeof(dbg_line),
+ "%d. old csum in old location", dbg_csc);
+ DBG_DUMP_CSUM(&osblock, dbg_line, dbg_csp++);
+ }
}
-}
#endif /* FS_DEBUG */
DBG_PRINT0("fscs read\n");
/*
* Do all needed changes in the former last cylinder group.
*/
- updjcg(osblock.fs_ncg-1, modtime, fsi, fso, Nflag);
+ updjcg(osblock.fs_ncg - 1, modtime, fsi, fso, Nflag);
/*
* Dump out summary information about file system.
@@ -260,7 +254,7 @@ growfs(int fsi, int fso, unsigned int Nf
initcg(cylno, modtime, fso, Nflag);
j = sprintf(tmpbuf, " %jd%s",
(intmax_t)fsbtodb(&sblock, cgsblock(&sblock, cylno)),
- cylno < (sblock.fs_ncg-1) ? "," : "" );
+ cylno < (sblock.fs_ncg - 1) ? "," : "" );
if (i + j >= width) {
printf("\n");
i = 0;
@@ -288,20 +282,18 @@ growfs(int fsi, int fso, unsigned int Nf
DBG_PRINT0("fscs written\n");
#ifdef FS_DEBUG
-{
- struct csum *dbg_csp;
- int dbg_csc;
- char dbg_line[80];
-
- dbg_csp=fscs;
- for(dbg_csc=0; dbg_csc<sblock.fs_ncg; dbg_csc++) {
- snprintf(dbg_line, sizeof(dbg_line),
- "%d. new csum in new location", dbg_csc);
- DBG_DUMP_CSUM(&sblock,
- dbg_line,
- dbg_csp++);
+ {
+ struct csum *dbg_csp;
+ int dbg_csc;
+ char dbg_line[80];
+
+ dbg_csp = fscs;
+ for (dbg_csc = 0; dbg_csc < sblock.fs_ncg; dbg_csc++) {
+ snprintf(dbg_line, sizeof(dbg_line),
+ "%d. new csum in new location", dbg_csc);
+ DBG_DUMP_CSUM(&sblock, dbg_line, dbg_csp++);
+ }
}
-}
#endif /* FS_DEBUG */
/*
@@ -310,8 +302,7 @@ growfs(int fsi, int fso, unsigned int Nf
sblock.fs_time = modtime;
wtfs(sblockloc, (size_t)SBLOCKSIZE, (void *)&sblock, fso, Nflag);
DBG_PRINT0("sblock written\n");
- DBG_DUMP_FS(&sblock,
- "new initial sblock");
+ DBG_DUMP_FS(&sblock, "new initial sblock");
/*
* Clean up the dynamic fields in our superblock copies.
@@ -353,14 +344,12 @@ growfs(int fsi, int fso, unsigned int Nf
(size_t)SBLOCKSIZE, (void *)&sblock, fso, Nflag);
}
DBG_PRINT0("sblock copies written\n");
- DBG_DUMP_FS(&sblock,
- "new other sblocks");
+ DBG_DUMP_FS(&sblock, "new other sblocks");
DBG_LEAVE;
return;
}
-/* ************************************************************ initcg ***** */
/*
* This creates a new cylinder group structure, for more details please see
* the source of newfs(8), as this function is taken over almost unchanged.
@@ -453,7 +442,7 @@ initcg(int cylno, time_t modtime, int fs
if (sblock.fs_magic == FS_UFS1_MAGIC) {
bzero(iobuf, sblock.fs_bsize);
for (i = 0; i < sblock.fs_ipg / INOPF(&sblock);
- i += sblock.fs_frag) {
+ i += sblock.fs_frag) {
#ifdef FSIRAND
dp1 = (struct ufs1_dinode *)(void *)iobuf;
for (j = 0; j < INOPB(&sblock); j++) {
@@ -488,7 +477,7 @@ initcg(int cylno, time_t modtime, int fs
}
}
for (d = dupper; d + sblock.fs_frag <= acg.cg_ndblk;
- d += sblock.fs_frag) {
+ d += sblock.fs_frag) {
blkno = d / sblock.fs_frag;
setblock(&sblock, cg_blksfree(&acg), blkno);
if (sblock.fs_contigsumsize > 0)
@@ -549,7 +538,6 @@ initcg(int cylno, time_t modtime, int fs
return;
}
-/* ******************************************************* frag_adjust ***** */
/*
* Here we add or subtract (sign +1/-1) the available fragments in a given
* block to or from the fragment statistics. By subtracting before and adding
@@ -570,45 +558,38 @@ frag_adjust(ufs2_daddr_t frag, int sign)
* Here frag only needs to point to any fragment in the block we want
* to examine.
*/
- for(f=rounddown(frag, sblock.fs_frag);
- f<roundup(frag+1, sblock.fs_frag);
- f++) {
+ for (f = rounddown(frag, sblock.fs_frag);
+ f < roundup(frag + 1, sblock.fs_frag); f++) {
/*
* Count contiguous free fragments.
*/
- if(isset(cg_blksfree(&acg), f)) {
+ if (isset(cg_blksfree(&acg), f)) {
fragsize++;
} else {
- if(fragsize && fragsize<sblock.fs_frag) {
+ if (fragsize && fragsize < sblock.fs_frag) {
/*
* We found something in between.
*/
acg.cg_frsum[fragsize]+=sign;
DBG_PRINT2("frag_adjust [%d]+=%d\n",
- fragsize,
- sign);
+ fragsize, sign);
}
- fragsize=0;
+ fragsize = 0;
}
}
- if(fragsize && fragsize<sblock.fs_frag) {
+ if (fragsize && fragsize < sblock.fs_frag) {
/*
* We found something.
*/
- acg.cg_frsum[fragsize]+=sign;
- DBG_PRINT2("frag_adjust [%d]+=%d\n",
- fragsize,
- sign);
- }
- DBG_PRINT2("frag_adjust [[%d]]+=%d\n",
- fragsize,
- sign);
+ acg.cg_frsum[fragsize] += sign;
+ DBG_PRINT2("frag_adjust [%d]+=%d\n", fragsize, sign);
+ }
+ DBG_PRINT2("frag_adjust [[%d]]+=%d\n", fragsize, sign);
DBG_LEAVE;
return;
}
-/* ******************************************************* cond_bl_upd ***** */
/*
* Here we conditionally update a pointer to a fragment. We check for all
* relocated blocks if any of its fragments is referenced by the current
@@ -641,9 +622,7 @@ cond_bl_upd(ufs2_daddr_t *block, struct
*block = dst + fragnum;
f->found++;
DBG_PRINT3("scg (%jd->%jd)[%d] reference updated\n",
- (intmax_t)f->old,
- (intmax_t)f->new,
- fragnum);
+ (intmax_t)f->old, (intmax_t)f->new, fragnum);
/*
* Copy the block back immediately.
@@ -669,7 +648,6 @@ cond_bl_upd(ufs2_daddr_t *block, struct
return (0);
}
-/* ************************************************************ updjcg ***** */
/*
* Here we do all needed work for the former last cylinder group. It has to be
* changed in any case, even if the file system ended exactly on the end of
@@ -685,10 +663,10 @@ static void
updjcg(int cylno, time_t modtime, int fsi, int fso, unsigned int Nflag)
{
DBG_FUNC("updjcg")
- ufs2_daddr_t cbase, dmax, dupper;
- struct csum *cs;
- int i,k;
- int j=0;
+ ufs2_daddr_t cbase, dmax, dupper;
+ struct csum *cs;
+ int i, k;
+ int j = 0;
DBG_ENTER;
@@ -699,9 +677,7 @@ updjcg(int cylno, time_t modtime, int fs
rdfs(fsbtodb(&osblock, cgtod(&osblock, cylno)),
(size_t)osblock.fs_cgsize, (void *)&aocg, fsi);
DBG_PRINT0("jcg read\n");
- DBG_DUMP_CG(&sblock,
- "old joining cg",
- &aocg);
+ DBG_DUMP_CG(&sblock, "old joining cg", &aocg);
memcpy((void *)&cgun1, (void *)&cgun2, sizeof(cgun2));
@@ -713,16 +689,14 @@ updjcg(int cylno, time_t modtime, int fs
* cylinder group we have to change that value now to fs_cpg.
*/
- if(cgbase(&osblock, cylno+1) == osblock.fs_size) {
+ if (cgbase(&osblock, cylno + 1) == osblock.fs_size) {
if (sblock.fs_magic == FS_UFS1_MAGIC)
acg.cg_old_ncyl=sblock.fs_old_cpg;
wtfs(fsbtodb(&sblock, cgtod(&sblock, cylno)),
(size_t)sblock.fs_cgsize, (void *)&acg, fso, Nflag);
DBG_PRINT0("jcg written\n");
- DBG_DUMP_CG(&sblock,
- "new joining cg",
- &acg);
+ DBG_DUMP_CG(&sblock, "new joining cg", &acg);
DBG_LEAVE;
return;
@@ -736,9 +710,8 @@ updjcg(int cylno, time_t modtime, int fs
if (dmax > sblock.fs_size)
dmax = sblock.fs_size;
dupper = cgdmin(&sblock, cylno) - cbase;
- if (cylno == 0) { /* XXX fscs may be relocated */
+ if (cylno == 0) /* XXX fscs may be relocated */
dupper += howmany(sblock.fs_cssize, sblock.fs_fsize);
- }
/*
* Set pointer to the cylinder summary for our cylinder group.
@@ -760,21 +733,16 @@ updjcg(int cylno, time_t modtime, int fs
} else {
acg.cg_old_ncyl = sblock.fs_old_cpg;
}
- DBG_PRINT2("jcg dbg: %d %u",
- cylno,
- sblock.fs_ncg);
+ DBG_PRINT2("jcg dbg: %d %u", cylno, sblock.fs_ncg);
#ifdef FS_DEBUG
if (sblock.fs_magic == FS_UFS1_MAGIC)
- DBG_PRINT2("%d %u",
- acg.cg_old_ncyl,
- sblock.fs_old_cpg);
+ DBG_PRINT2("%d %u", acg.cg_old_ncyl, sblock.fs_old_cpg);
#endif
DBG_PRINT0("\n");
acg.cg_ndblk = dmax - cbase;
- sblock.fs_dsize += acg.cg_ndblk-aocg.cg_ndblk;
- if (sblock.fs_contigsumsize > 0) {
+ sblock.fs_dsize += acg.cg_ndblk - aocg.cg_ndblk;
+ if (sblock.fs_contigsumsize > 0)
acg.cg_nclusterblks = acg.cg_ndblk / sblock.fs_frag;
- }
/*
* Now we have to update the free fragment bitmap for our new free
@@ -788,15 +756,16 @@ updjcg(int cylno, time_t modtime, int fs
* Handle the first new block here if it was partially available
* before.
*/
- if(osblock.fs_size % sblock.fs_frag) {
- if(roundup(osblock.fs_size, sblock.fs_frag)<=sblock.fs_size) {
+ if (osblock.fs_size % sblock.fs_frag) {
+ if (roundup(osblock.fs_size, sblock.fs_frag) <=
+ sblock.fs_size) {
/*
* The new space is enough to fill at least this
* block
*/
- j=0;
- for(i=roundup(osblock.fs_size-cbase, sblock.fs_frag)-1;
- i>=osblock.fs_size-cbase;
+ j = 0;
+ for (i = roundup(osblock.fs_size - cbase,
+ sblock.fs_frag) - 1; i >= osblock.fs_size - cbase;
i--) {
setbit(cg_blksfree(&acg), i);
acg.cg_cs.cs_nffree++;
@@ -808,44 +777,43 @@ updjcg(int cylno, time_t modtime, int fs
* already existing fragment at the former end of the
* file system.
*/
- if(isblock(&sblock, cg_blksfree(&acg),
- ((osblock.fs_size - cgbase(&sblock, cylno))/
- sblock.fs_frag))) {
+ if (isblock(&sblock, cg_blksfree(&acg),
+ ((osblock.fs_size - cgbase(&sblock, cylno)) /
+ sblock.fs_frag))) {
/*
* The block is now completely available.
*/
DBG_PRINT0("block was\n");
- acg.cg_frsum[osblock.fs_size%sblock.fs_frag]--;
+ acg.cg_frsum[osblock.fs_size % sblock.fs_frag]--;
acg.cg_cs.cs_nbfree++;
- acg.cg_cs.cs_nffree-=sblock.fs_frag;
- k=rounddown(osblock.fs_size-cbase,
+ acg.cg_cs.cs_nffree -= sblock.fs_frag;
+ k = rounddown(osblock.fs_size - cbase,
+ sblock.fs_frag);
+ updclst((osblock.fs_size - cbase) /
sblock.fs_frag);
- updclst((osblock.fs_size-cbase)/sblock.fs_frag);
} else {
/*
* Lets rejoin a possible partially growed
* fragment.
*/
- k=0;
- while(isset(cg_blksfree(&acg), i) &&
- (i>=rounddown(osblock.fs_size-cbase,
+ k = 0;
+ while (isset(cg_blksfree(&acg), i) &&
+ (i >= rounddown(osblock.fs_size - cbase,
sblock.fs_frag))) {
i--;
k++;
}
- if(k) {
+ if (k)
acg.cg_frsum[k]--;
- }
- acg.cg_frsum[k+j]++;
+ acg.cg_frsum[k + j]++;
}
} else {
/*
* We only grow by some fragments within this last
* block.
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-stable-9
mailing list