summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/makefs/cd9660.c5
-rw-r--r--usr.sbin/makefs/ffs.c189
-rw-r--r--usr.sbin/makefs/ffs/buf.c24
-rw-r--r--usr.sbin/makefs/ffs/ffs_alloc.c3
-rw-r--r--usr.sbin/makefs/makefs.c17
-rw-r--r--usr.sbin/makefs/makefs.h45
-rw-r--r--usr.sbin/makefs/msdos.c21
-rw-r--r--usr.sbin/makefs/msdos/msdosfs_fat.c27
-rw-r--r--usr.sbin/makefs/walk.c24
9 files changed, 15 insertions, 340 deletions
diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index 28d3e4d053f..9ce68699b17 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660.c,v 1.7 2016/10/17 08:22:38 natano Exp $ */
+/* $OpenBSD: cd9660.c,v 1.8 2016/10/22 18:17:14 natano Exp $ */
/* $NetBSD: cd9660.c,v 1.52 2015/12/24 15:52:37 christos Exp $ */
/*
@@ -358,9 +358,6 @@ cd9660_parse_opts(const char *option, fsinfo_t *fsopts)
assert(option != NULL);
- if (debug & DEBUG_FS_PARSE_OPTS)
- printf("%s: got `%s'\n", __func__, option);
-
i = set_option(cd9660_options, option, buf, sizeof(buf));
if (i == -1)
return 0;
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c
index 3c1d8bdf5af..a0f3e9cc297 100644
--- a/usr.sbin/makefs/ffs.c
+++ b/usr.sbin/makefs/ffs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs.c,v 1.13 2016/10/22 17:15:28 natano Exp $ */
+/* $OpenBSD: ffs.c,v 1.14 2016/10/22 18:17:14 natano Exp $ */
/* $NetBSD: ffs.c,v 1.66 2015/12/21 00:58:08 christos Exp $ */
/*
@@ -118,8 +118,6 @@ typedef struct {
static int ffs_create_image(const char *, fsinfo_t *);
-static void ffs_dump_fsinfo(fsinfo_t *);
-static void ffs_dump_dirbuf(dirbuf_t *, const char *);
static void ffs_make_dirbuf(dirbuf_t *, const char *, fsnode *);
static int ffs_populate_dir(const char *, fsnode *, fsinfo_t *);
static void ffs_size_dir(fsnode *, fsinfo_t *);
@@ -203,9 +201,6 @@ ffs_parse_opts(const char *option, fsinfo_t *fsopts)
assert(fsopts != NULL);
assert(ffs_opts != NULL);
- if (debug & DEBUG_FS_PARSE_OPTS)
- printf("ffs_parse_opts: got `%s'\n", option);
-
rv = set_option(ffs_options, option, buf, sizeof(buf));
if (rv == -1)
return 0;
@@ -235,46 +230,30 @@ void
ffs_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts)
{
struct fs *superblock;
- struct timeval start;
assert(image != NULL);
assert(dir != NULL);
assert(root != NULL);
assert(fsopts != NULL);
- if (debug & DEBUG_FS_MAKEFS)
- printf("ffs_makefs: image %s directory %s root %p\n",
- image, dir, root);
-
/* validate tree and options */
- TIMER_START(start);
ffs_validate(dir, root, fsopts);
- TIMER_RESULTS(start, "ffs_validate");
printf("Calculated size of `%s': %lld bytes, %lld inodes\n",
image, (long long)fsopts->size, (long long)fsopts->inodes);
/* create image */
- TIMER_START(start);
if (ffs_create_image(image, fsopts) == -1)
errx(1, "Image file `%s' not created.", image);
- TIMER_RESULTS(start, "ffs_create_image");
fsopts->curinode = ROOTINO;
- if (debug & DEBUG_FS_MAKEFS)
- putchar('\n');
-
/* populate image */
printf("Populating `%s'\n", image);
- TIMER_START(start);
if (! ffs_populate_dir(dir, root, fsopts))
errx(1, "Image file `%s' not populated.", image);
- TIMER_RESULTS(start, "ffs_populate_dir");
- /* ensure no outstanding buffers remain */
- if (debug & DEBUG_FS_MAKEFS)
- bcleanup();
+ bcleanup();
/* update various superblock parameters */
superblock = fsopts->superblock;
@@ -299,9 +278,6 @@ static void
ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts)
{
int32_t ncg = 1;
-#if notyet
- int32_t spc, nspf, ncyl, fssize;
-#endif
ffs_opt_t *ffs_opts = fsopts->fs_specific;
assert(dir != NULL);
@@ -309,11 +285,6 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts)
assert(fsopts != NULL);
assert(ffs_opts != NULL);
- if (debug & DEBUG_FS_VALIDATE) {
- printf("ffs_validate: before defaults set:\n");
- ffs_dump_fsinfo(fsopts);
- }
-
/* set FFS defaults */
if (fsopts->sectorsize == -1)
fsopts->sectorsize = DFL_SECSIZE;
@@ -347,10 +318,6 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts)
ffs_size_dir(root, fsopts);
fsopts->inodes += ROOTINO; /* include first two inodes */
- if (debug & DEBUG_FS_VALIDATE)
- printf("ffs_validate: size of tree: %lld bytes, %lld inodes\n",
- (long long)fsopts->size, (long long)fsopts->inodes);
-
/* add requested slop */
fsopts->size += fsopts->freeblocks;
fsopts->inodes += fsopts->freefiles;
@@ -396,12 +363,6 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts)
if (ffs_opts->density == -1)
ffs_opts->density = fsopts->size / fsopts->inodes + 1;
- if (debug & DEBUG_FS_VALIDATE) {
- printf("ffs_validate: after defaults set:\n");
- ffs_dump_fsinfo(fsopts);
- printf("ffs_validate: dir %s; %lld bytes, %lld inodes\n",
- dir, (long long)fsopts->size, (long long)fsopts->inodes);
- }
/* now check calculated sizes vs requested sizes */
if (fsopts->maxsize > 0 && fsopts->size > fsopts->maxsize) {
errx(1, "`%s' size of %lld is larger than the maxsize of %lld.",
@@ -410,36 +371,6 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts)
}
-static void
-ffs_dump_fsinfo(fsinfo_t *f)
-{
-
- ffs_opt_t *fs = f->fs_specific;
-
- printf("fsopts at %p\n", f);
-
- printf("\tsize %lld, inodes %lld, curinode %u\n",
- (long long)f->size, (long long)f->inodes, f->curinode);
-
- printf("\tminsize %lld, maxsize %lld\n",
- (long long)f->minsize, (long long)f->maxsize);
- printf("\tfree files %lld, freefile %% %d\n",
- (long long)f->freefiles, f->freefilepc);
- printf("\tfree blocks %lld, freeblock %% %d\n",
- (long long)f->freeblocks, f->freeblockpc);
- printf("\tsectorsize %d\n", f->sectorsize);
-
- printf("\tbsize %d, fsize %d, cpg %d, density %d\n",
- fs->bsize, fs->fsize, fs->cpg, fs->density);
- printf("\tnsectors %d, rpm %d, minfree %d\n",
- fs->nsectors, fs->rpm, fs->minfree);
- printf("\tmaxcontig %d, maxbpg %d\n",
- fs->maxcontig, fs->maxbpg);
- printf("\toptimization %s\n",
- fs->optimization == FS_OPTSPACE ? "space" : "time");
-}
-
-
static int
ffs_create_image(const char *image, fsinfo_t *fsopts)
{
@@ -471,10 +402,6 @@ ffs_create_image(const char *image, fsinfo_t *fsopts)
return -1;
}
- if ((debug & DEBUG_FS_CREATE_IMAGE))
- printf(
- "zero-ing image `%s', %lld sectors, using %d byte chunks\n",
- image, (long long)bufrem, bufsize);
if (bufrem > 0)
buf = ecalloc(1, bufsize);
while (bufrem > 0) {
@@ -491,31 +418,14 @@ ffs_create_image(const char *image, fsinfo_t *fsopts)
free(buf);
/* make the file system */
- if (debug & DEBUG_FS_CREATE_IMAGE)
- printf("calling mkfs(\"%s\", ...)\n", image);
-
if (stampst.st_ino == 1) {
tstamp = stampst.st_ctime;
srandom_deterministic(tstamp);
- } else {
+ } else
tstamp = start_time.tv_sec;
- srandom(tstamp);
- }
fs = ffs_mkfs(image, fsopts, tstamp);
fsopts->superblock = (void *)fs;
- if (debug & DEBUG_FS_CREATE_IMAGE) {
- time_t t;
-
- t = (time_t)((struct fs *)fsopts->superblock)->fs_time;
- printf("mkfs returned %p; fs_time %s",
- fsopts->superblock, ctime(&t));
- printf("fs totals: nbfree %lld, nffree %lld, nifree %lld, ndir %lld\n",
- (long long)fs->fs_cstotal.cs_nbfree,
- (long long)fs->fs_cstotal.cs_nffree,
- (long long)fs->fs_cstotal.cs_nifree,
- (long long)fs->fs_cstotal.cs_ndir);
- }
if ((off_t)(fs->fs_cstotal.cs_nifree + ROOTINO) < fsopts->inodes) {
warnx(
@@ -541,22 +451,12 @@ ffs_size_dir(fsnode *root, fsinfo_t *fsopts)
assert(fsopts != NULL);
assert(ffs_opts != NULL);
- if (debug & DEBUG_FS_SIZE_DIR)
- printf("ffs_size_dir: entry: bytes %lld inodes %lld\n",
- (long long)fsopts->size, (long long)fsopts->inodes);
-
#define ADDDIRENT(e) do { \
tmpdir.d_namlen = strlen((e)); \
this = DIRSIZ(NEWDIRFMT, &tmpdir); \
- if (debug & DEBUG_FS_SIZE_DIR_ADD_DIRENT) \
- printf("ADDDIRENT: was: %s (%d) this %d cur %d\n", \
- e, tmpdir.d_namlen, this, curdirsize); \
if (this + curdirsize > roundup(curdirsize, DIRBLKSIZ)) \
curdirsize = roundup(curdirsize, DIRBLKSIZ); \
curdirsize += this; \
- if (debug & DEBUG_FS_SIZE_DIR_ADD_DIRENT) \
- printf("ADDDIRENT: now: %s (%d) this %d cur %d\n", \
- e, tmpdir.d_namlen, this, curdirsize); \
} while (0);
/*
@@ -576,10 +476,6 @@ ffs_size_dir(fsnode *root, fsinfo_t *fsopts)
} else if ((node->inode->flags & FI_SIZED) == 0) {
/* don't count duplicate names */
node->inode->flags |= FI_SIZED;
- if (debug & DEBUG_FS_SIZE_DIR_NODE)
- printf("ffs_size_dir: `%s' size %lld\n",
- node->name,
- (long long)node->inode->st.st_size);
fsopts->inodes++;
if (node->type == S_IFREG)
ADDSIZE(node->inode->st.st_size);
@@ -597,10 +493,6 @@ ffs_size_dir(fsnode *root, fsinfo_t *fsopts)
ffs_size_dir(node->child, fsopts);
}
ADDSIZE(curdirsize);
-
- if (debug & DEBUG_FS_SIZE_DIR)
- printf("ffs_size_dir: exit: size %lld inodes %lld\n",
- (long long)fsopts->size, (long long)fsopts->inodes);
}
static void *
@@ -708,9 +600,6 @@ ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts)
(void)memset(&dirbuf, 0, sizeof(dirbuf));
- if (debug & DEBUG_FS_POPULATE)
- printf("ffs_populate_dir: PASS 1 dir %s node %p\n", dir, root);
-
/*
* pass 1: allocate inode numbers, build directory `file'
*/
@@ -739,14 +628,10 @@ ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts)
* cares about ordering? :-)
*/
}
- if (debug & DEBUG_FS_POPULATE_DIRBUF)
- ffs_dump_dirbuf(&dirbuf, dir);
/*
* pass 2: write out dirbuf, then non-directories at this level
*/
- if (debug & DEBUG_FS_POPULATE)
- printf("ffs_populate_dir: PASS 2 dir %s\n", dir);
for (cur = root; cur != NULL; cur = cur->next) {
if (cur->inode->flags & FI_WRITTEN)
continue; /* skip hard-linked entries */
@@ -767,14 +652,6 @@ ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts)
membuf = ffs_build_dinode2(&din.ffs2_din, &dirbuf, cur,
root, fsopts);
- if (debug & DEBUG_FS_POPULATE_NODE) {
- printf("ffs_populate_dir: writing ino %d, %s",
- cur->inode->ino, inode_type(cur->type));
- if (cur->inode->nlink > 1)
- printf(", nlink %d", cur->inode->nlink);
- putchar('\n');
- }
-
if (membuf != NULL) {
ffs_write_file(&din, cur->inode->ino, membuf, fsopts);
} else if (S_ISREG(cur->type)) {
@@ -788,8 +665,6 @@ ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts)
/*
* pass 3: write out sub-directories
*/
- if (debug & DEBUG_FS_POPULATE)
- printf("ffs_populate_dir: PASS 3 dir %s\n", dir);
for (cur = root; cur != NULL; cur = cur->next) {
if (cur->child == NULL)
continue;
@@ -800,9 +675,6 @@ ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts)
return (0);
}
- if (debug & DEBUG_FS_POPULATE)
- printf("ffs_populate_dir: DONE dir %s\n", dir);
-
/* cleanup */
if (dirbuf.buf != NULL)
free(dirbuf.buf);
@@ -835,17 +707,6 @@ ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts)
in.i_fs = (struct fs *)fsopts->superblock;
in.i_devvp = &vp;
- if (debug & DEBUG_FS_WRITE_FILE) {
- printf(
- "ffs_write_file: ino %u, din %p, isfile %d, %s, size %lld",
- ino, din, isfile, inode_type(DIP(din, mode) & S_IFMT),
- (long long)DIP(din, size));
- if (isfile)
- printf(", file '%s'\n", (char *)buf);
- else
- printf(", buffer %p\n", buf);
- }
-
in.i_number = ino;
in.i_size = DIP(din, size);
if (ffs_opts->version == 1)
@@ -885,11 +746,6 @@ ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts)
else
p = fbuf;
offset = DIP(din, size) - bufleft;
- if (debug & DEBUG_FS_WRITE_FILE_BLOCK)
- printf(
- "ffs_write_file: write %p offset %lld size %lld left %lld\n",
- p, (long long)offset,
- (long long)chunk, (long long)bufleft);
/*
* XXX if holey support is desired, do the check here
*
@@ -925,31 +781,6 @@ ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts)
static void
-ffs_dump_dirbuf(dirbuf_t *dbuf, const char *dir)
-{
- doff_t i;
- struct direct *de;
- uint16_t reclen;
-
- assert (dbuf != NULL);
- assert (dir != NULL);
- printf("ffs_dump_dirbuf: dir %s size %d cur %d\n",
- dir, dbuf->size, dbuf->cur);
-
- for (i = 0; i < dbuf->size; ) {
- de = (struct direct *)(dbuf->buf + i);
- reclen = ufs_rw16(de->d_reclen, 0);
- printf(
- " inode %4d %7s offset %4d reclen %3d namlen %3d name %s\n",
- ufs_rw32(de->d_ino, 0),
- inode_type(DTTOIF(de->d_type)), i, reclen,
- de->d_namlen, de->d_name);
- i += reclen;
- assert(reclen > 0);
- }
-}
-
-static void
ffs_make_dirbuf(dirbuf_t *dbuf, const char *name, fsnode *node)
{
struct direct de, *dp;
@@ -973,18 +804,7 @@ ffs_make_dirbuf(dirbuf_t *dbuf, const char *name, fsnode *node)
if (dp != NULL)
llen = DIRSIZ(NEWDIRFMT, dp);
- if (debug & DEBUG_FS_MAKE_DIRBUF)
- printf(
- "ffs_make_dirbuf: dbuf siz %d cur %d lastlen %d\n"
- " ino %d type %d reclen %d namlen %d name %.30s\n",
- dbuf->size, dbuf->cur, llen,
- ufs_rw32(de.d_ino, 0), de.d_type, reclen,
- de.d_namlen, de.d_name);
-
if (reclen + dbuf->cur + llen > roundup(dbuf->size, DIRBLKSIZ)) {
- if (debug & DEBUG_FS_MAKE_DIRBUF)
- printf("ffs_make_dirbuf: growing buf to %d\n",
- dbuf->size + DIRBLKSIZ);
newbuf = erealloc(dbuf->buf, dbuf->size + DIRBLKSIZ);
dbuf->buf = newbuf;
dbuf->size += DIRBLKSIZ;
@@ -1024,9 +844,6 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts)
fs = (struct fs *)fsopts->superblock;
cg = ino_to_cg(fs, ino);
cgino = ino % fs->fs_ipg;
- if (debug & DEBUG_FS_WRITE_INODE)
- printf("ffs_write_inode: din %p ino %u cg %d cgino %d\n",
- dp, ino, cg, cgino);
ffs_rdfs(fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, &sbbuf,
fsopts);
diff --git a/usr.sbin/makefs/ffs/buf.c b/usr.sbin/makefs/ffs/buf.c
index 68ba5eee585..8f0a224cfbe 100644
--- a/usr.sbin/makefs/ffs/buf.c
+++ b/usr.sbin/makefs/ffs/buf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.c,v 1.3 2016/10/17 01:16:22 tedu Exp $ */
+/* $OpenBSD: buf.c,v 1.4 2016/10/22 18:17:14 natano Exp $ */
/* $NetBSD: buf.c,v 1.24 2016/06/24 19:24:11 christos Exp $ */
/*
@@ -61,21 +61,12 @@ bread(struct mkfsvnode *vp, daddr_t blkno, int size, int u2 __unused,
assert (bpp != NULL);
- if (debug & DEBUG_BUF_BREAD)
- printf("bread: blkno %lld size %d\n", (long long)blkno, size);
*bpp = getblk(vp, blkno, size, 0, 0);
offset = (*bpp)->b_blkno * fs->sectorsize + fs->offset;
- if (debug & DEBUG_BUF_BREAD)
- printf("bread: blkno %lld offset %lld bcount %ld\n",
- (long long)(*bpp)->b_blkno, (long long) offset,
- (*bpp)->b_bcount);
if (lseek((*bpp)->b_fs->fd, offset, SEEK_SET) == -1)
err(EXIT_FAILURE, "%s: lseek %lld (%lld)", __func__,
(long long)(*bpp)->b_blkno, (long long)offset);
rv = read((*bpp)->b_fs->fd, (*bpp)->b_data, (size_t)(*bpp)->b_bcount);
- if (debug & DEBUG_BUF_BREAD)
- printf("bread: read %ld (%lld) returned %zd\n",
- (*bpp)->b_bcount, (long long)offset, rv);
if (rv == -1) /* read error */
err(EXIT_FAILURE, "%s: read %ld (%lld) returned %zd", __func__,
(*bpp)->b_bcount, (long long)offset, rv);
@@ -127,15 +118,9 @@ bwrite(struct mkfsbuf *bp)
assert (bp != NULL);
offset = bp->b_blkno * fs->sectorsize + fs->offset;
bytes = (size_t)bp->b_bcount;
- if (debug & DEBUG_BUF_BWRITE)
- printf("bwrite: blkno %lld offset %lld bcount %zu\n",
- (long long)bp->b_blkno, (long long) offset, bytes);
if (lseek(bp->b_fs->fd, offset, SEEK_SET) == -1)
return (errno);
rv = write(bp->b_fs->fd, bp->b_data, bytes);
- if (debug & DEBUG_BUF_BWRITE)
- printf("bwrite: write %ld (offset %lld) returned %lld\n",
- bp->b_bcount, (long long)offset, (long long)rv);
brelse(bp, 0);
if (rv == (ssize_t)bytes)
return (0);
@@ -148,6 +133,7 @@ bwrite(struct mkfsbuf *bp)
void
bcleanup(void)
{
+#if DEBUG_BUFFERS
struct mkfsbuf *bp;
/*
@@ -166,6 +152,7 @@ bcleanup(void)
bp->b_bcount, bp->b_bufsize);
}
printf("bcleanup: done\n");
+#endif
}
struct mkfsbuf *
@@ -176,13 +163,8 @@ getblk(struct mkfsvnode *vp, daddr_t blkno, int size, int u1 __unused,
struct mkfsbuf *bp;
void *n;
- if (debug & DEBUG_BUF_GETBLK)
- printf("getblk: blkno %lld size %d\n", (long long)blkno, size);
-
bp = NULL;
if (!buftailinitted) {
- if (debug & DEBUG_BUF_GETBLK)
- printf("getblk: initialising tailq\n");
TAILQ_INIT(&buftail);
buftailinitted = 1;
} else {
diff --git a/usr.sbin/makefs/ffs/ffs_alloc.c b/usr.sbin/makefs/ffs/ffs_alloc.c
index a6aa425d87d..dbe74879b47 100644
--- a/usr.sbin/makefs/ffs/ffs_alloc.c
+++ b/usr.sbin/makefs/ffs/ffs_alloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_alloc.c,v 1.9 2016/10/22 16:51:52 natano Exp $ */
+/* $OpenBSD: ffs_alloc.c,v 1.10 2016/10/22 18:17:14 natano Exp $ */
/* $NetBSD: ffs_alloc.c,v 1.29 2016/06/24 19:24:11 christos Exp $ */
/* From: NetBSD: ffs_alloc.c,v 1.50 2001/09/06 02:16:01 lukem Exp */
@@ -456,7 +456,6 @@ ffs_mapsearch(struct fs *fs, struct cg *cgp, daddr_t bpref, int allocsiz)
"len %d offset %d %ld", __func__, ostart, olen,
ufs_rw32(cgp->cg_freeoff, 0),
(long)cg_blksfree(cgp) - (long)cgp);
- /* NOTREACHED */
}
}
bno = (start + len - loc) * NBBY;
diff --git a/usr.sbin/makefs/makefs.c b/usr.sbin/makefs/makefs.c
index 97de938c920..295c67dc506 100644
--- a/usr.sbin/makefs/makefs.c
+++ b/usr.sbin/makefs/makefs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: makefs.c,v 1.11 2016/10/18 18:34:45 natano Exp $ */
+/* $OpenBSD: makefs.c,v 1.12 2016/10/22 18:17:14 natano Exp $ */
/* $NetBSD: makefs.c,v 1.53 2015/11/27 15:10:32 joerg Exp $ */
/*
@@ -71,7 +71,6 @@ static fstype_t fstypes[] = {
{ .type = NULL },
};
-u_int debug;
struct timespec start_time;
struct stat stampst;
@@ -83,13 +82,11 @@ static void usage(fstype_t *, fsinfo_t *) __dead;
int
main(int argc, char *argv[])
{
- struct timeval start;
fstype_t *fstype;
fsinfo_t fsoptions;
fsnode *root;
int ch, len;
- debug = 0;
if ((fstype = get_fstype(DEFAULT_FSTYPE)) == NULL)
errx(1, "Unknown default fs type `%s'.", DEFAULT_FSTYPE);
@@ -194,7 +191,6 @@ main(int argc, char *argv[])
case '?':
default:
usage(fstype, &fsoptions);
- /* NOTREACHED */
}
}
argc -= optind;
@@ -204,25 +200,14 @@ main(int argc, char *argv[])
usage(fstype, &fsoptions);
/* walk the tree */
- TIMER_START(start);
root = walk_dir(argv[1], ".", NULL, NULL);
- TIMER_RESULTS(start, "walk_dir");
-
- if (debug & DEBUG_DUMP_FSNODES) {
- printf("\nparent: %s\n", argv[1]);
- dump_fsnodes(root);
- putchar('\n');
- }
/* build the file system */
- TIMER_START(start);
fstype->make_fs(argv[0], argv[1], root, &fsoptions);
- TIMER_RESULTS(start, "make_fs");
free_fsnodes(root);
exit(0);
- /* NOTREACHED */
}
int
diff --git a/usr.sbin/makefs/makefs.h b/usr.sbin/makefs/makefs.h
index 3dcf137af52..1f82c2ccaa3 100644
--- a/usr.sbin/makefs/makefs.h
+++ b/usr.sbin/makefs/makefs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: makefs.h,v 1.6 2016/10/17 07:54:17 natano Exp $ */
+/* $OpenBSD: makefs.h,v 1.7 2016/10/22 18:17:14 natano Exp $ */
/* $NetBSD: makefs.h,v 1.36 2015/11/25 00:48:49 christos Exp $ */
/*
@@ -182,49 +182,6 @@ extern u_int debug;
extern struct timespec start_time;
extern struct stat stampst;
-#define DEBUG_TIME 0x00000001
- /* debug bits 1..3 unused at this time */
-#define DEBUG_WALK_DIR 0x00000010
-#define DEBUG_WALK_DIR_NODE 0x00000020
-#define DEBUG_WALK_DIR_LINKCHECK 0x00000040
-#define DEBUG_DUMP_FSNODES 0x00000080
-#define DEBUG_DUMP_FSNODES_VERBOSE 0x00000100
-#define DEBUG_FS_PARSE_OPTS 0x00000200
-#define DEBUG_FS_MAKEFS 0x00000400
-#define DEBUG_FS_VALIDATE 0x00000800
-#define DEBUG_FS_CREATE_IMAGE 0x00001000
-#define DEBUG_FS_SIZE_DIR 0x00002000
-#define DEBUG_FS_SIZE_DIR_NODE 0x00004000
-#define DEBUG_FS_SIZE_DIR_ADD_DIRENT 0x00008000
-#define DEBUG_FS_POPULATE 0x00010000
-#define DEBUG_FS_POPULATE_DIRBUF 0x00020000
-#define DEBUG_FS_POPULATE_NODE 0x00040000
-#define DEBUG_FS_WRITE_FILE 0x00080000
-#define DEBUG_FS_WRITE_FILE_BLOCK 0x00100000
-#define DEBUG_FS_MAKE_DIRBUF 0x00200000
-#define DEBUG_FS_WRITE_INODE 0x00400000
-#define DEBUG_BUF_BREAD 0x00800000
-#define DEBUG_BUF_BWRITE 0x01000000
-#define DEBUG_BUF_GETBLK 0x02000000
-#define DEBUG_APPLY_SPECFILE 0x04000000
-#define DEBUG_APPLY_SPECENTRY 0x08000000
-#define DEBUG_APPLY_SPECONLY 0x10000000
-
-
-#define TIMER_START(x) \
- if (debug & DEBUG_TIME) \
- gettimeofday(&(x), NULL)
-
-#define TIMER_RESULTS(x,d) \
- if (debug & DEBUG_TIME) { \
- struct timeval end, td; \
- gettimeofday(&end, NULL); \
- timersub(&end, &(x), &td); \
- printf("%s took %lld.%06ld seconds\n", \
- (d), (long long)td.tv_sec, \
- (long)td.tv_usec); \
- }
-
#ifndef DEFAULT_FSTYPE
#define DEFAULT_FSTYPE "ffs"
diff --git a/usr.sbin/makefs/msdos.c b/usr.sbin/makefs/msdos.c
index 6daed37f5f3..dafaced4765 100644
--- a/usr.sbin/makefs/msdos.c
+++ b/usr.sbin/makefs/msdos.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdos.c,v 1.6 2016/10/18 17:05:30 natano Exp $ */
+/* $OpenBSD: msdos.c,v 1.7 2016/10/22 18:17:14 natano Exp $ */
/* $NetBSD: msdos.c,v 1.16 2016/01/30 09:59:27 mlelstv Exp $ */
/*-
@@ -95,9 +95,6 @@ msdos_parse_opts(const char *option, fsinfo_t *fsopts)
assert(fsopts != NULL);
assert(msdos_opt != NULL);
- if (debug & DEBUG_FS_PARSE_OPTS)
- printf("msdos_parse_opts: got `%s'\n", option);
-
rv = set_option(msdos_options, option, NULL, 0);
if (rv == -1)
return rv;
@@ -117,7 +114,6 @@ msdos_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts)
{
struct msdos_options *msdos_opt = fsopts->fs_specific;
struct mkfsvnode vp, rootvp;
- struct timeval start;
struct msdosfsmount *pmp;
assert(image != NULL);
@@ -146,10 +142,8 @@ msdos_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts)
/* create image */
printf("Creating `%s'\n", image);
- TIMER_START(start);
if (mkfs_msdos(image, NULL, msdos_opt) == -1)
return;
- TIMER_RESULTS(start, "mkfs_msdos");
fsopts->fd = open(image, O_RDWR);
vp.fs = fsopts;
@@ -160,23 +154,12 @@ msdos_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts)
if (msdosfs_root(pmp, &rootvp) != 0)
err(1, "msdosfs_root");
- if (debug & DEBUG_FS_MAKEFS)
- printf("msdos_makefs: image %s directory %s root %p\n",
- image, dir, root);
-
/* populate image */
printf("Populating `%s'\n", image);
- TIMER_START(start);
if (msdos_populate_dir(dir, VTODE(&rootvp), root, root, fsopts) == -1)
errx(1, "Image file `%s' not created.", image);
- TIMER_RESULTS(start, "msdos_populate_dir");
-
- if (debug & DEBUG_FS_MAKEFS)
- putchar('\n');
- /* ensure no outstanding buffers remain */
- if (debug & DEBUG_FS_MAKEFS)
- bcleanup();
+ bcleanup();
printf("Image `%s' complete\n", image);
}
diff --git a/usr.sbin/makefs/msdos/msdosfs_fat.c b/usr.sbin/makefs/msdos/msdosfs_fat.c
index 86e25a5b7c7..e498c4d600a 100644
--- a/usr.sbin/makefs/msdos/msdosfs_fat.c
+++ b/usr.sbin/makefs/msdos/msdosfs_fat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: msdosfs_fat.c,v 1.1 2016/10/18 17:05:30 natano Exp $ */
+/* $OpenBSD: msdosfs_fat.c,v 1.2 2016/10/22 18:17:14 natano Exp $ */
/* $NetBSD: msdosfs_fat.c,v 1.31 2016/05/07 16:43:02 mlelstv Exp $ */
/*-
@@ -85,31 +85,6 @@ int pm_fatblocksize;
#else
#define DPRINTF(a)
#endif
-#ifdef MSDOSFS_DEBUG
-void print_fat_stats(void);
-
-void
-print_fat_stats(void)
-{
- int i;
-
- printf("fc_fileextends=%d fc_lfcempty=%d fc_bmapcalls=%d "
- "fc_largedistance=%d [%d->%d=%d] fc_lastclust=%d pm_fatblocksize=%d\n",
- fc_fileextends, fc_lfcempty, fc_bmapcalls, fc_largedistance,
- fc_wherefrom, fc_whereto, fc_whereto-fc_wherefrom,
- fc_lastclust, pm_fatblocksize);
-
- fc_fileextends = fc_lfcempty = fc_bmapcalls = 0;
- fc_wherefrom = fc_whereto = fc_lastclust = 0;
-
- for (i = 0; i < LMMAX; i++) {
- printf("%d:%d ", i, fc_lmdistance[i]);
- fc_lmdistance[i] = 0;
- }
-
- printf("\n");
-}
-#endif
static void fatblock(struct msdosfsmount *, u_long, u_long *, u_long *,
u_long *);
diff --git a/usr.sbin/makefs/walk.c b/usr.sbin/makefs/walk.c
index fd1dc11c82d..5bc57e59abd 100644
--- a/usr.sbin/makefs/walk.c
+++ b/usr.sbin/makefs/walk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: walk.c,v 1.5 2016/10/17 07:54:17 natano Exp $ */
+/* $OpenBSD: walk.c,v 1.6 2016/10/22 18:17:14 natano Exp $ */
/* $NetBSD: walk.c,v 1.29 2015/11/25 00:48:49 christos Exp $ */
/*
@@ -78,8 +78,6 @@ walk_dir(const char *root, const char *dir, fsnode *parent, fsnode *join)
len = snprintf(path, sizeof(path), "%s/%s", root, dir);
if (len >= (int)sizeof(path))
errx(1, "Pathname too long.");
- if (debug & DEBUG_WALK_DIR)
- printf("walk_dir: %s %p\n", path, parent);
if ((dirp = opendir(path)) == NULL)
err(1, "Can't opendir `%s'", path);
rp = path + strlen(root) + 1;
@@ -107,20 +105,13 @@ walk_dir(const char *root, const char *dir, fsnode *parent, fsnode *join)
default:
dot = 0;
}
- if (debug & DEBUG_WALK_DIR_NODE)
- printf("scanning %s/%s/%s\n", root, dir, name);
if (snprintf(path + len, sizeof(path) - len, "/%s", name) >=
(int)sizeof(path) - len)
errx(1, "Pathname too long.");
if (lstat(path, &stbuf) == -1)
err(1, "Can't lstat `%s'", path);
-#ifdef S_ISSOCK
- if (S_ISSOCK(stbuf.st_mode & S_IFMT)) {
- if (debug & DEBUG_WALK_DIR_NODE)
- printf(" skipping socket %s\n", path);
+ if (S_ISSOCK(stbuf.st_mode & S_IFMT))
continue;
- }
-#endif
if (join != NULL) {
cur = join->next;
@@ -136,9 +127,6 @@ walk_dir(const char *root, const char *dir, fsnode *parent, fsnode *join)
if (cur != NULL) {
if (S_ISDIR(cur->type) &&
S_ISDIR(stbuf.st_mode)) {
- if (debug & DEBUG_WALK_DIR_NODE)
- printf("merging %s with %p\n",
- path, cur->child);
cur->child = walk_dir(root, rp, cur,
cur->child);
continue;
@@ -179,10 +167,6 @@ walk_dir(const char *root, const char *dir, fsnode *parent, fsnode *join)
free(cur->inode);
cur->inode = curino;
cur->inode->nlink++;
- if (debug & DEBUG_WALK_DIR_LINKCHECK)
- printf("link_check: found [%llu, %llu]\n",
- (unsigned long long)curino->st.st_dev,
- (unsigned long long)curino->st.st_ino);
}
}
if (S_ISLNK(cur->type)) {
@@ -295,9 +279,6 @@ dump_fsnodes(fsnode *root)
cur->name) >= (int)sizeof(path))
errx(1, "Pathname too long.");
- if (debug & DEBUG_DUMP_FSNODES_VERBOSE)
- printf("cur=%8p parent=%8p first=%8p ",
- cur, cur->parent, cur->first);
printf("%7s: %s", inode_type(cur->type), path);
if (S_ISLNK(cur->type)) {
assert(cur->symlink != NULL);
@@ -344,7 +325,6 @@ inode_type(mode_t mode)
default:
return ("unknown");
}
- /* NOTREACHED */
}