-diff -urN genext2fs-1.3.orig/.gdbinit genext2fs-1.3/.gdbinit
---- genext2fs-1.3.orig/.gdbinit 1969-12-31 17:00:00.000000000 -0700
-+++ genext2fs-1.3/.gdbinit 2003-01-06 08:22:30.000000000 -0700
-@@ -0,0 +1,3 @@
-+set args -d /home/andersen/CVS/buildroot/build/root -D /home/andersen/CVS/buildroot/sources/device_table.txt /home/andersen/CVS/buildroot/root_fs -i 1915 -b 30000
-+b interpret_table_entry
-+r
-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-01-06 08:22:30.000000000 -0700
+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
@@ -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.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-01-06 08:22:30.000000000 -0700
+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
@@ -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.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-01-06 08:22:30.000000000 -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
@@ -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.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-01-06 08:22:30.000000000 -0700
+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
@@ -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.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-01-06 08:22:30.000000000 -0700
+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
@@ -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.orig/dev.txt genext2fs-1.3/dev.txt
---- genext2fs-1.3.orig/dev.txt 2000-09-28 09:03:19.000000000 -0600
+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
+++ 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.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-01-06 08:22:30.000000000 -0700
+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
@@ -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.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-01-06 08:22:30.000000000 -0700
+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
@@ -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.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-01-06 08:22:30.000000000 -0700
+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
@@ -1,3 +1,4 @@
+/* vi: set sw=8 ts=8: */
// genext2fs.c
} filesystem;
#else
#error UNHANDLED BLOCKSIZE
-@@ -389,25 +462,84 @@
+@@ -389,25 +462,105 @@
#undef udecl32
#undef utdecl32
+ return fp;
+}
+
-+extern char *xstrdup(const char *s)
++static char *xstrdup(const char *s)
+{
+ char *t;
+
+ if (t == NULL)
+ error_msg_and_die(memory_exhausted);
+ return t;
++}
++
++static char *xreadlink(const char *path)
++{
++ static const int GROWBY = 80; /* how large we will grow strings by */
++
++ char *buf = NULL;
++ int bufsize = 0, readsize = 0;
++
++ do {
++ buf = xrealloc(buf, bufsize += GROWBY);
++ readsize = readlink(path, buf, bufsize); /* 1st try */
++ if (readsize == -1) {
++ perror_msg_and_die("%s:%s", progname, path);
++ }
++ }
++ while (bufsize < readsize + 1);
++
++ buf[readsize] = '\0';
++
++ return buf;
}
// printf helper macro
-@@ -423,7 +555,7 @@
+@@ -423,7 +576,7 @@
{
}
uint32 rndup(uint32 qty, uint32 siz)
{
return (qty + (siz - 1)) & ~(siz - 1);
-@@ -444,7 +576,13 @@
+@@ -444,7 +597,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 +617,57 @@
+@@ -479,29 +638,57 @@
}
// allocate a block
}
// print a bitmap allocation
-@@ -546,14 +712,14 @@
+@@ -546,14 +733,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 +728,11 @@
+@@ -562,11 +749,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 +741,7 @@
+@@ -575,7 +762,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 +751,14 @@
+@@ -585,14 +772,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 +768,7 @@
+@@ -602,7 +789,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 +778,100 @@
+@@ -612,20 +799,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 +909,40 @@
+@@ -663,23 +930,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 +954,16 @@
+@@ -691,9 +975,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 +975,16 @@
+@@ -705,9 +996,16 @@
d = (directory*) (((int8*)d) + d->d_rec_len);
d->d_rec_len = reclen;
d->d_inode = nod;
return;
}
}
-@@ -716,10 +993,17 @@
+@@ -716,10 +1014,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 +1031,7 @@
+@@ -747,7 +1052,7 @@
// find the inode of a full path
uint32 find_path(filesystem *fs, uint32 nod, const char * name)
{
n = n2;
while(*n == '/')
{
-@@ -770,27 +1054,32 @@
+@@ -770,27 +1075,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 +1090,15 @@
+@@ -801,15 +1111,15 @@
}
// make a file from a FILE*
memset(b, 0,rndup(size, BLOCKSIZE));
if(f)
fread(b, size, 1, f);
-@@ -824,6 +1113,15 @@
+@@ -824,6 +1134,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)
-@@ -831,32 +1129,19 @@
- if(st->st_mode & S_IXUSR)
- mode |= FM_IXUSR | FM_IXGRP | FM_IXOTH;
+@@ -833,30 +1152,17 @@
return mode;
--}
--
+ }
+
-// retrieves a mode info from a string
-uint32 get_modestr(const char *p)
-{
- if(p[2] == 'x' || p[2] == 's')
- mode |= FM_IXUSR | FM_IXGRP | FM_IXOTH;
- return mode;
- }
-
+-}
+-
// basename of a path - free me
char * basename(const char * fullpath)
{
if((p = strrchr(n, '/')))
*(p+1) = 0;
else
-@@ -864,66 +1150,6 @@
+@@ -864,66 +1170,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 +1160,7 @@
+@@ -934,7 +1180,7 @@
struct stat st;
uint8 *b;
if(!(dh = opendir(".")))
while((dent = readdir(dh)))
{
if((!strcmp(dent->d_name, ".")) || (!strcmp(dent->d_name, "..")))
-@@ -948,31 +1174,30 @@
+@@ -948,31 +1194,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);
+ add2dir(fs, this_nod, nod, dent->d_name, st.st_mode, st.st_uid, st.st_gid, st.st_ctime);
break;
case S_IFLNK:
- if(!(b = (uint8*)malloc(rndup(st.st_size, BLOCKSIZE))))
+- if(!(b = (uint8*)malloc(rndup(st.st_size, BLOCKSIZE))))
- errexit("out of memory");
-+ error_msg_and_die("out of memory");
- if(readlink(dent->d_name, (char*)b, st.st_size) < 0)
+- if(readlink(dent->d_name, (char*)b, st.st_size) < 0)
- pexit(dent->d_name);
- mklink_fs(fs, this_nod, dent->d_name, st.st_size, b);
-+ perror_msg_and_die(dent->d_name);
++ b = xreadlink(dent->d_name);
+ mklink_fs(fs, this_nod, dent->d_name, st.st_size, b, st.st_uid, st.st_gid, st.st_ctime);
free(b);
break;
}
}
closedir(dh);
-@@ -981,9 +1206,11 @@
+@@ -981,9 +1223,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 +1218,55 @@
+@@ -991,20 +1235,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 +1274,34 @@
+@@ -1012,13 +1291,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 +1328,8 @@
+@@ -1045,7 +1345,8 @@
swap_goodblocks(fs, nod);
swap_nod(nod);
}
swap_sb(&fs->sb);
}
-@@ -1053,7 +1337,8 @@
+@@ -1053,7 +1354,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 +1369,118 @@
+@@ -1084,53 +1386,118 @@
directory *d;
uint8 * b;
uint32 nod;
b = get_workblk();
d = (directory*)b;
d->d_inode = EXT2_ROOT_INO;
-@@ -1147,9 +1497,14 @@
+@@ -1147,9 +1514,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 +1525,24 @@
+@@ -1170,24 +1542,24 @@
// loads a filesystem from disk
filesystem * load_fs(FILE * fh, int swapit)
{
return fs;
}
-@@ -1230,9 +1585,9 @@
+@@ -1230,9 +1602,9 @@
while((bk = walk_bw(fs, nod, &bw, 0, 0)) != WALK_END)
{
if(fsize <= 0)
fsize -= BLOCKSIZE;
}
}
-@@ -1250,7 +1605,7 @@
+@@ -1250,7 +1622,7 @@
{
int i, j;
if(fsize <= 0)
b = get_blk(fs, bk);
for(i = 0; i < 64; i++)
{
-@@ -1406,7 +1761,7 @@
+@@ -1406,7 +1778,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 +1795,46 @@
+@@ -1440,24 +1812,46 @@
default:
list_blocks(fs, nod);
}
}
void dump_fs(filesystem *fs, FILE * fh, int swapit)
-@@ -1467,31 +1844,234 @@
+@@ -1467,31 +1861,234 @@
if(swapit)
swap_goodfs(fs);
if(fwrite(fs, BLOCKSIZE, nbblocks, fh) < nbblocks)
}
#define MAX_DOPT 128
-@@ -1520,22 +2100,18 @@
- int bigendian = !*(char*)&endian;
+@@ -1521,21 +2118,17 @@
filesystem *fs;
int i;
-- int c;
-+ int c;
+ int c;
+ struct stat sb;
+ FILE *devtable = NULL;
dopt[didx++] = optarg;
break;
case 'b':
-@@ -1556,6 +2132,24 @@
+@@ -1556,6 +2149,24 @@
case 'z':
holes = 1;
break;
case 'v':
verbose = 1;
break;
-@@ -1566,16 +2160,14 @@
+@@ -1566,16 +2177,14 @@
exit(1);
}
if(optind < (argc - 1))
fs = load_fs(fh, bigendian);
fclose(fh);
}
-@@ -1585,7 +2177,7 @@
+@@ -1585,7 +2194,7 @@
else
{
if(nbblocks == -1)
if(nbinodes == -1)
nbinodes = nbblocks * BLOCKSIZE / rndup(BYTES_PER_INODE, BLOCKSIZE);
if(nbresrvd == -1)
-@@ -1595,35 +2187,30 @@
+@@ -1595,35 +2204,30 @@
for(i = 0; i < didx; i++)
{
struct stat st;
if(verbose)
print_fs(fs);
for(i = 0; i < gidx; i++)
-@@ -1633,21 +2220,18 @@
+@@ -1633,21 +2237,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.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-01-06 08:22:30.000000000 -0700
+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
@@ -0,0 +1,96 @@
+#!/bin/sh
+set -e
+ftest dev.txt 4096
+
+exit 0
-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-01-06 08:22:30.000000000 -0700
+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
@@ -0,0 +1,53 @@
+#!/bin/sh
+set -e