-diff -urN genext2fs-1.3~/Makefile genext2fs-1.3/Makefile
---- genext2fs-1.3~/Makefile 1969-12-31 17:00:00.000000000 -0700
-+++ genext2fs-1.3/Makefile 2003-04-14 17:38:53.000000000 -0600
+diff -urN genext2fs-1.3.orig/Makefile genext2fs-1.3/Makefile
+--- genext2fs-1.3.orig/Makefile 1969-12-31 17:00:00.000000000 -0700
++++ genext2fs-1.3/Makefile 2003-04-21 01:41:42.000000000 -0600
@@ -0,0 +1,46 @@
+CC=gcc
+CFLAGS=-Wall -O0 -g
+# test genext2fs by actually mounting the created image.
+test-mount: all
+ sudo sh ./test-mount.sh
-diff -urN genext2fs-1.3~/debian/changelog genext2fs-1.3/debian/changelog
---- genext2fs-1.3~/debian/changelog 1969-12-31 17:00:00.000000000 -0700
-+++ genext2fs-1.3/debian/changelog 2003-04-14 17:38:53.000000000 -0600
+diff -urN genext2fs-1.3.orig/debian/changelog genext2fs-1.3/debian/changelog
+--- genext2fs-1.3.orig/debian/changelog 1969-12-31 17:00:00.000000000 -0700
++++ genext2fs-1.3/debian/changelog 2003-04-21 01:41:42.000000000 -0600
@@ -0,0 +1,17 @@
+genext2fs (1.3-2) unstable; urgency=low
+
+
+ -- David Kimdon <dwhedon@debian.org> Sat, 14 Jul 2001 13:24:49 -0700
+
-diff -urN genext2fs-1.3~/debian/control genext2fs-1.3/debian/control
---- genext2fs-1.3~/debian/control 1969-12-31 17:00:00.000000000 -0700
-+++ genext2fs-1.3/debian/control 2003-04-14 17:38:53.000000000 -0600
+diff -urN genext2fs-1.3.orig/debian/control genext2fs-1.3/debian/control
+--- genext2fs-1.3.orig/debian/control 1969-12-31 17:00:00.000000000 -0700
++++ genext2fs-1.3/debian/control 2003-04-21 01:41:42.000000000 -0600
@@ -0,0 +1,19 @@
+Source: genext2fs
+Section: admin
+ Warning ! `genext2fs' has been designed for embedded
+ systems. As such, it will generate a filesystem for single-user
+ usage: all files/directories/etc... will belong to UID/GID 0
-diff -urN genext2fs-1.3~/debian/copyright genext2fs-1.3/debian/copyright
---- genext2fs-1.3~/debian/copyright 1969-12-31 17:00:00.000000000 -0700
-+++ genext2fs-1.3/debian/copyright 2003-04-14 17:38:53.000000000 -0600
+diff -urN genext2fs-1.3.orig/debian/copyright genext2fs-1.3/debian/copyright
+--- genext2fs-1.3.orig/debian/copyright 1969-12-31 17:00:00.000000000 -0700
++++ genext2fs-1.3/debian/copyright 2003-04-21 01:41:42.000000000 -0600
@@ -0,0 +1,15 @@
+This package was debianized by David Kimdon <dwhedon@debian.org> on
+Sat, 14 Jul 2001 13:24:49 -0700.
+
+On Debian systems, the complete text of the GNU General Public
+License can be found in /usr/share/common-licenses/GPL file.
-diff -urN genext2fs-1.3~/debian/rules genext2fs-1.3/debian/rules
---- genext2fs-1.3~/debian/rules 1969-12-31 17:00:00.000000000 -0700
-+++ genext2fs-1.3/debian/rules 2003-04-14 17:38:53.000000000 -0600
+diff -urN genext2fs-1.3.orig/debian/rules genext2fs-1.3/debian/rules
+--- genext2fs-1.3.orig/debian/rules 1969-12-31 17:00:00.000000000 -0700
++++ genext2fs-1.3/debian/rules 2003-04-21 01:41:42.000000000 -0600
@@ -0,0 +1,70 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
-diff -urN genext2fs-1.3~/dev.txt genext2fs-1.3/dev.txt
---- genext2fs-1.3~/dev.txt 2000-09-28 09:03:19.000000000 -0600
+diff -urN genext2fs-1.3.orig/dev.txt genext2fs-1.3/dev.txt
+--- genext2fs-1.3.orig/dev.txt 2000-09-28 09:03:19.000000000 -0600
+++ genext2fs-1.3/dev.txt 1969-12-31 17:00:00.000000000 -0700
@@ -1,94 +0,0 @@
-drwx /dev
-crw- 5,67 /dev/cua3
-crw- 5,68 /dev/cua4
-crw- 5,69 /dev/cua5
-diff -urN genext2fs-1.3~/device_table.txt genext2fs-1.3/device_table.txt
---- genext2fs-1.3~/device_table.txt 1969-12-31 17:00:00.000000000 -0700
-+++ genext2fs-1.3/device_table.txt 2003-04-14 17:38:53.000000000 -0600
+diff -urN genext2fs-1.3.orig/device_table.txt genext2fs-1.3/device_table.txt
+--- genext2fs-1.3.orig/device_table.txt 1969-12-31 17:00:00.000000000 -0700
++++ genext2fs-1.3/device_table.txt 2003-04-21 01:41:42.000000000 -0600
@@ -0,0 +1,129 @@
+# When building a target filesystem, it is desirable to not have to
+# become root and then run 'mknod' a thousand times. Using a device
+#/dev/mcd b 640 0 0 23 0 0 0 -
+#/dev/optcd b 640 0 0 17 0 0 0 -
+
-diff -urN genext2fs-1.3~/genext2fs.8 genext2fs-1.3/genext2fs.8
---- genext2fs-1.3~/genext2fs.8 1969-12-31 17:00:00.000000000 -0700
-+++ genext2fs-1.3/genext2fs.8 2003-04-14 17:38:53.000000000 -0600
+diff -urN genext2fs-1.3.orig/genext2fs.8 genext2fs-1.3/genext2fs.8
+--- genext2fs-1.3.orig/genext2fs.8 1969-12-31 17:00:00.000000000 -0700
++++ genext2fs-1.3/genext2fs.8 2003-04-21 01:41:42.000000000 -0600
@@ -0,0 +1,125 @@
+.\" Hey, EMACS: -*- nroff -*-
+.\" First parameter, NAME, should be all caps
+.SH AUTHOR
+This manual page was written by David Kimdon <dwhedon@debian.org>,
+for the Debian GNU/Linux system (but may be used by others).
-diff -urN genext2fs-1.3~/genext2fs.c genext2fs-1.3/genext2fs.c
---- genext2fs-1.3~/genext2fs.c 2001-06-18 02:11:32.000000000 -0600
-+++ genext2fs-1.3/genext2fs.c 2003-04-14 17:44:45.000000000 -0600
+diff -urN genext2fs-1.3.orig/genext2fs.c genext2fs-1.3/genext2fs.c
+--- genext2fs-1.3.orig/genext2fs.c 2001-06-18 02:11:32.000000000 -0600
++++ genext2fs-1.3/genext2fs.c 2003-04-21 01:48:35.000000000 -0600
@@ -1,3 +1,4 @@
+/* vi: set sw=8 ts=8: */
// genext2fs.c
} filesystem;
#else
#error UNHANDLED BLOCKSIZE
-@@ -389,25 +462,105 @@
+@@ -389,25 +462,113 @@
#undef udecl32
#undef utdecl32
+ if (*s)
+ s = ": ";
+ fprintf(stderr, "%s%s\n", s, strerror(err));
- }
-
--inline void pexit(const char * fname)
++}
++
+#if 0
+static void perror_msg(const char *s, ...)
+{
+}
+#endif
+static void perror_msg_and_die(const char *s, ...)
- {
-- fprintf(stderr, "%s: ", argv0);
-- perror(fname);
-- exit(1);
++{
+ va_list p;
+ va_start(p, s);
+ vperror_msg(s, p);
+ va_end(p);
+ exit(EXIT_FAILURE);
-+}
-+
+ }
+
+-inline void pexit(const char * fname)
+static FILE *xfopen(const char *path, const char *mode)
-+{
+ {
+- fprintf(stderr, "%s: ", argv0);
+- perror(fname);
+- exit(1);
+ FILE *fp;
+ if ((fp = fopen(path, mode)) == NULL)
+ perror_msg_and_die("%s", path);
+ return t;
+}
+
++extern void *xrealloc(void *ptr, size_t size)
++{
++ ptr = realloc(ptr, size);
++ if (ptr == NULL && size != 0)
++ error_msg_and_die(memory_exhausted);
++ return ptr;
++}
++
+static char *xreadlink(const char *path)
+{
+ static const int GROWBY = 80; /* how large we will grow strings by */
+ buf = xrealloc(buf, bufsize += GROWBY);
+ readsize = readlink(path, buf, bufsize); /* 1st try */
+ if (readsize == -1) {
-+ perror_msg_and_die("%s:%s", progname, path);
++ perror_msg_and_die("%s:%s", app_name, path);
+ }
+ }
+ while (bufsize < readsize + 1);
}
// printf helper macro
-@@ -423,7 +576,7 @@
+@@ -423,7 +584,7 @@
{
}
uint32 rndup(uint32 qty, uint32 siz)
{
return (qty + (siz - 1)) & ~(siz - 1);
-@@ -444,7 +597,13 @@
+@@ -444,7 +605,13 @@
// return a given inode from a filesystem
inline inode * get_nod(filesystem *fs, uint32 nod)
{
}
// allocate a given block/inode in the bitmap
-@@ -479,29 +638,57 @@
+@@ -479,29 +646,57 @@
}
// allocate a block
}
// print a bitmap allocation
-@@ -546,14 +733,14 @@
+@@ -546,14 +741,14 @@
{
bkref = &get_nod(fs, nod)->i_block[bw->bpdir = 0];
if(extend) // allocate first block
}
// first block in indirect block
else if(bw->bpdir == EXT2_NDIR_BLOCKS)
-@@ -562,11 +749,11 @@
+@@ -562,11 +757,11 @@
bw->bpdir = EXT2_IND_BLOCK;
bw->bpind = 0;
if(extend) // allocate indirect block
}
// block in indirect block
else if((bw->bpdir == EXT2_IND_BLOCK) && (bw->bpind < BLOCKSIZE/4 - 1))
-@@ -575,7 +762,7 @@
+@@ -575,7 +770,7 @@
b = (uint32*)get_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]);
bkref = &b[bw->bpind];
if(extend) // allocate block
}
// first block in first indirect block in first double indirect block
else if(bw->bpdir == EXT2_IND_BLOCK)
-@@ -585,14 +772,14 @@
+@@ -585,14 +780,14 @@
bw->bpind = 0;
bw->bpdind = 0;
if(extend) // allocate double indirect block
}
// block in indirect block in double indirect block
else if((bw->bpdir == EXT2_DIND_BLOCK) && (bw->bpdind < BLOCKSIZE/4 - 1))
-@@ -602,7 +789,7 @@
+@@ -602,7 +797,7 @@
b = (uint32*)get_blk(fs, b[bw->bpind]);
bkref = &b[bw->bpdind];
if(extend) // allocate block
}
// first block in indirect block in double indirect block
else if((bw->bpdir == EXT2_DIND_BLOCK) && (bw->bpind < BLOCKSIZE/4 - 1))
-@@ -612,20 +799,100 @@
+@@ -612,20 +807,100 @@
bw->bpind++;
b = (uint32*)get_blk(fs, get_nod(fs, nod)->i_block[bw->bpdir]);
if(extend) // allocate indirect block
}
if(extend)
get_nod(fs, nod)->i_blocks = bw->bnum * INOBLK;
-@@ -663,23 +930,40 @@
+@@ -663,23 +938,40 @@
}
// link an entry (inode #) to a directory
init_bw(fs, dnod, &bw);
while((bk = walk_bw(fs, dnod, &bw, 0, 0)) != WALK_END) // for all blocks in dir
{
-@@ -691,9 +975,16 @@
+@@ -691,9 +983,16 @@
if((!d->d_inode) && (d->d_rec_len >= reclen))
{
d->d_inode = nod;
return;
}
// if entry with enough room (last one?), shrink it & use it
-@@ -705,9 +996,16 @@
+@@ -705,9 +1004,16 @@
d = (directory*) (((int8*)d) + d->d_rec_len);
d->d_rec_len = reclen;
d->d_inode = nod;
return;
}
}
-@@ -716,10 +1014,17 @@
+@@ -716,10 +1022,17 @@
b = get_workblk();
d = (directory*)b;
d->d_inode = nod;
extend_blk(fs, dnod, b, 1);
get_nod(fs, dnod)->i_size += BLOCKSIZE;
free_workblk(b);
-@@ -747,7 +1052,7 @@
+@@ -747,7 +1060,7 @@
// find the inode of a full path
uint32 find_path(filesystem *fs, uint32 nod, const char * name)
{
n = n2;
while(*n == '/')
{
-@@ -770,27 +1075,32 @@
+@@ -770,27 +1083,32 @@
}
// make a full-fledged directory (i.e. with "." & "..")
if(size <= 4 * (EXT2_TIND_BLOCK+1))
{
strncpy((char*)get_nod(fs, nod)->i_block, (char*)b, size);
-@@ -801,15 +1111,15 @@
+@@ -801,15 +1119,15 @@
}
// make a file from a FILE*
memset(b, 0,rndup(size, BLOCKSIZE));
if(f)
fread(b, size, 1, f);
-@@ -824,6 +1134,15 @@
+@@ -824,6 +1142,15 @@
uint32 get_mode(struct stat *st)
{
uint32 mode = 0;
if(st->st_mode & S_IRUSR)
mode |= FM_IRUSR | FM_IRGRP | FM_IROTH;
if(st->st_mode & S_IWUSR)
-@@ -833,30 +1152,17 @@
+@@ -833,30 +1160,17 @@
return mode;
}
if((p = strrchr(n, '/')))
*(p+1) = 0;
else
-@@ -864,66 +1170,6 @@
+@@ -864,66 +1178,6 @@
return n;
}
// adds a tree of entries to the filesystem from current dir
void add2fs_from_dir(filesystem *fs, uint32 this_nod)
{
-@@ -934,7 +1180,7 @@
+@@ -934,7 +1188,7 @@
struct stat st;
uint8 *b;
if(!(dh = opendir(".")))
while((dent = readdir(dh)))
{
if((!strcmp(dent->d_name, ".")) || (!strcmp(dent->d_name, "..")))
-@@ -948,31 +1194,27 @@
+@@ -948,31 +1202,27 @@
get_nod(fs, nod)->i_mode = (((st.st_mode & S_IFMT) == S_IFCHR) ? FM_IFCHR : FM_IFBLK) | get_mode(&st);
((uint8*)get_nod(fs, nod)->i_block)[0] = (st.st_rdev & 0xff);
((uint8*)get_nod(fs, nod)->i_block)[1] = (st.st_rdev >> 8);
}
}
closedir(dh);
-@@ -981,9 +1223,11 @@
+@@ -981,9 +1231,11 @@
// endianness swap of x-indirect blocks
void swap_goodblocks(filesystem *fs, inode *nod)
{
for(i = 0; i <= EXT2_TIND_BLOCK; i++)
nod->i_block[i] = swab32(nod->i_block[i]);
if(nblk <= EXT2_IND_BLOCK)
-@@ -991,20 +1235,55 @@
+@@ -991,20 +1243,55 @@
swap_block(get_blk(fs, nod->i_block[EXT2_IND_BLOCK]));
if(nblk <= EXT2_IND_BLOCK + BLOCKSIZE/4)
return;
for(i = 0; i <= EXT2_TIND_BLOCK; i++)
nod->i_block[i] = swab32(nod->i_block[i]);
if(nblk <= EXT2_IND_BLOCK)
-@@ -1012,13 +1291,34 @@
+@@ -1012,13 +1299,34 @@
swap_block(get_blk(fs, nod->i_block[EXT2_IND_BLOCK]));
if(nblk <= EXT2_IND_BLOCK + BLOCKSIZE/4)
return;
}
// endianness swap of the whole filesystem
-@@ -1045,7 +1345,8 @@
+@@ -1045,7 +1353,8 @@
swap_goodblocks(fs, nod);
swap_nod(nod);
}
swap_sb(&fs->sb);
}
-@@ -1053,7 +1354,8 @@
+@@ -1053,7 +1362,8 @@
{
int i;
swap_sb(&fs->sb);
for(i = 1; i < fs->sb.s_inodes_count; i++)
{
inode *nod = get_nod(fs, i);
-@@ -1084,53 +1386,118 @@
+@@ -1084,53 +1394,118 @@
directory *d;
uint8 * b;
uint32 nod;
b = get_workblk();
d = (directory*)b;
d->d_inode = EXT2_ROOT_INO;
-@@ -1147,9 +1514,14 @@
+@@ -1147,9 +1522,14 @@
// make lost+found directory and reserve blocks
if(fs->sb.s_r_blocks_count)
{
for(i = 1; i < fs->sb.s_r_blocks_count; i++)
extend_blk(fs, nod, b, 1);
get_nod(fs, nod)->i_size = fs->sb.s_r_blocks_count * BLOCKSIZE;
-@@ -1170,24 +1542,24 @@
+@@ -1170,24 +1550,24 @@
// loads a filesystem from disk
filesystem * load_fs(FILE * fh, int swapit)
{
return fs;
}
-@@ -1230,9 +1602,9 @@
+@@ -1230,9 +1610,9 @@
while((bk = walk_bw(fs, nod, &bw, 0, 0)) != WALK_END)
{
if(fsize <= 0)
fsize -= BLOCKSIZE;
}
}
-@@ -1250,7 +1622,7 @@
+@@ -1250,7 +1630,7 @@
{
int i, j;
if(fsize <= 0)
b = get_blk(fs, bk);
for(i = 0; i < 64; i++)
{
-@@ -1406,7 +1778,7 @@
+@@ -1406,7 +1786,7 @@
s = (nod >= EXT2_FIRST_INO) ? "normal" : "unknown reserved";
}
printf("inode %d (%s, %d links): ", nod, s, get_nod(fs, nod)->i_links_count);
{
printf("unallocated\n");
return;
-@@ -1440,24 +1812,46 @@
+@@ -1440,24 +1820,46 @@
default:
list_blocks(fs, nod);
}
}
void dump_fs(filesystem *fs, FILE * fh, int swapit)
-@@ -1467,31 +1861,234 @@
+@@ -1467,31 +1869,234 @@
if(swapit)
swap_goodfs(fs);
if(fwrite(fs, BLOCKSIZE, nbblocks, fh) < nbblocks)
}
#define MAX_DOPT 128
-@@ -1521,21 +2118,17 @@
+@@ -1521,21 +2126,17 @@
filesystem *fs;
int i;
int c;
dopt[didx++] = optarg;
break;
case 'b':
-@@ -1556,6 +2149,24 @@
+@@ -1556,6 +2157,24 @@
case 'z':
holes = 1;
break;
case 'v':
verbose = 1;
break;
-@@ -1566,16 +2177,14 @@
+@@ -1566,16 +2185,14 @@
exit(1);
}
if(optind < (argc - 1))
fs = load_fs(fh, bigendian);
fclose(fh);
}
-@@ -1585,7 +2194,7 @@
+@@ -1585,7 +2202,7 @@
else
{
if(nbblocks == -1)
if(nbinodes == -1)
nbinodes = nbblocks * BLOCKSIZE / rndup(BYTES_PER_INODE, BLOCKSIZE);
if(nbresrvd == -1)
-@@ -1595,35 +2204,30 @@
+@@ -1595,35 +2212,30 @@
for(i = 0; i < didx; i++)
{
struct stat st;
if(verbose)
print_fs(fs);
for(i = 0; i < gidx; i++)
-@@ -1633,21 +2237,18 @@
+@@ -1633,21 +2245,18 @@
char *p;
FILE *fh;
if(!(nod = find_path(fs, EXT2_ROOT_INO, gopt[i])))
dump_fs(fs, fh, bigendian);
fclose(fh);
}
-diff -urN genext2fs-1.3~/test-mount.sh genext2fs-1.3/test-mount.sh
---- genext2fs-1.3~/test-mount.sh 1969-12-31 17:00:00.000000000 -0700
-+++ genext2fs-1.3/test-mount.sh 2003-04-14 17:38:53.000000000 -0600
+diff -urN genext2fs-1.3.orig/test-mount.sh genext2fs-1.3/test-mount.sh
+--- genext2fs-1.3.orig/test-mount.sh 1969-12-31 17:00:00.000000000 -0700
++++ genext2fs-1.3/test-mount.sh 2003-04-21 01:41:42.000000000 -0600
@@ -0,0 +1,96 @@
+#!/bin/sh
+set -e
+ftest dev.txt 4096
+
+exit 0
-diff -urN genext2fs-1.3~/test.sh genext2fs-1.3/test.sh
---- genext2fs-1.3~/test.sh 1969-12-31 17:00:00.000000000 -0700
-+++ genext2fs-1.3/test.sh 2003-04-14 17:38:53.000000000 -0600
+diff -urN genext2fs-1.3.orig/test.sh genext2fs-1.3/test.sh
+--- genext2fs-1.3.orig/test.sh 1969-12-31 17:00:00.000000000 -0700
++++ genext2fs-1.3/test.sh 2003-04-21 01:41:42.000000000 -0600
@@ -0,0 +1,53 @@
+#!/bin/sh
+set -e