commit genromfs for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package genromfs for openSUSE:Factory checked in at 2022-08-30 14:50:38 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/genromfs (Old) and /work/SRC/openSUSE:Factory/.genromfs.new.2083 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "genromfs" Tue Aug 30 14:50:38 2022 rev:20 rq:1000180 version:0.5.7 Changes: -------- --- /work/SRC/openSUSE:Factory/genromfs/genromfs.changes 2022-05-14 22:58:52.127493839 +0200 +++ /work/SRC/openSUSE:Factory/.genromfs.new.2083/genromfs.changes 2022-08-30 14:51:23.448412963 +0200 @@ -1,0 +2,10 @@ +Sat Aug 27 11:52:39 UTC 2022 - Jan Engelhardt <jengelh@inai.de> + +- Update to release 0.5.7 + * Make extension options really able to copy the current data. + * Detect unparseable numbers in the extended options. + * Tags were stored in an incorrect order, making any value of + uids, gids and timestamps larger than 4095 ending up with a + wrong value. + +------------------------------------------------------------------- Old: ---- genromfs-0.5.2.tar.gz New: ---- 0.5.7.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ genromfs.spec ++++++ --- /var/tmp/diff_new_pack.rkXEa6/_old 2022-08-30 14:51:23.832413943 +0200 +++ /var/tmp/diff_new_pack.rkXEa6/_new 2022-08-30 14:51:23.836413953 +0200 @@ -17,14 +17,13 @@ Name: genromfs -Version: 0.5.2 +Version: 0.5.7 Release: 0 Summary: Utility for Creating romfs File Systems License: GPL-2.0-or-later Group: System/Boot URL: http://romfs.sourceforge.net -Source: https://downloads.sf.net/romfs/%{name}-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: https://github.com/chexum/genromfs/archive/refs/tags/%version.tar.gz %description Genromfs is a tool for creating romfs file systems, which are @@ -33,17 +32,17 @@ used during installation. %prep -%setup -q +%autosetup %build -make %{?_smp_mflags} CC="gcc" CFLAGS="%{optflags} -DVERSION=\\\"%{version}\\\"" LDFLAGS= +%make_build CC="gcc" CFLAGS="%{optflags} -DVERSION=\\\"%{version}\\\"" LDFLAGS= %install -make PREFIX=%{buildroot} mandir=%{_mandir} install +%make_install PREFIX="%{buildroot}" mandir="%{_mandir}" %files -%defattr(-,root,root) -%doc COPYING NEWS ChangeLog genromfs.lsm romfs.txt +%license COPYING +%doc NEWS ChangeLog genromfs.lsm romfs.txt %doc %{_mandir}/man8/genromfs.8.gz %{_bindir}/genromfs ++++++ genromfs-0.5.2.tar.gz -> 0.5.7.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/.gitignore new/genromfs-0.5.7/.gitignore --- old/genromfs-0.5.2/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/.gitignore 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,4 @@ +selftest/*.out +selftest/*.bin +genromfs +genromfs.o diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/ChangeLog new/genromfs-0.5.7/ChangeLog --- old/genromfs-0.5.2/ChangeLog 2007-06-26 19:08:47.000000000 +0200 +++ new/genromfs-0.5.7/ChangeLog 2009-02-15 11:48:15.000000000 +0100 @@ -1,3 +1,8 @@ +2009-02-15 11:43 Janos Farkas <chexum@shadow.banki.hu> + + * Many changes, the main feature is to support + unixy file metadata on request. Test release 0.5.7. + 2007-06-26 19:04 Janos Farkas <chexum+dev () gmail.com> * NEWS, genromfs.8, genromfs.lsm: releasing 0.5.2. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/Makefile new/genromfs-0.5.7/Makefile --- old/genromfs-0.5.2/Makefile 2007-06-26 19:08:47.000000000 +0200 +++ new/genromfs-0.5.7/Makefile 2009-02-15 11:48:15.000000000 +0100 @@ -4,7 +4,7 @@ all: genromfs PACKAGE = genromfs -VERSION = 0.5.2 +VERSION = 0.5.7 CC = gcc CFLAGS = -O2 -Wall -DVERSION=\"$(VERSION)\"#-g# LDFLAGS = -s#-g @@ -14,7 +14,8 @@ FILES = COPYING NEWS ChangeLog Makefile \ genromfs.8 genromfs.c genromfs.lsm \ readme-kernel-patch genrommkdev romfs.txt \ - checkdist + checkdist \ + .gitignore selftest prefix = /usr bindir = $(prefix)/bin @@ -37,11 +38,14 @@ rm -rf $(DISTDIR).tar.gz $(DISTDIR) mkdir $(DISTDIR); for i in $(FILES); do \ - cp $$i $(DISTDIR)/; \ + cp -r $$i $(DISTDIR)/; \ done; \ tar --owner=root --group=root -zcf $(DISTDIR).tar.gz $(DISTDIR); rm -rf $(DISTDIR) +check: all selftest + $(MAKE) -C selftest dotest + install: all install-bin install-man install-bin: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/NEWS new/genromfs-0.5.7/NEWS --- old/genromfs-0.5.2/NEWS 2007-06-26 19:08:47.000000000 +0200 +++ new/genromfs-0.5.7/NEWS 2009-02-15 11:48:15.000000000 +0100 @@ -1,3 +1,15 @@ +Changes in (pre)release 0.5.7: + +* A test suite is now included (but may not work correctly in all + circumstances). +* Implemented including files by pattern, and combining this with excludes +* It is now possible to override alignment with a smaller value: + genromfs -A2048,*.boot -A1024,m68k.boot -A512,m68k.boot +* Unix permissions, including mode bits, user and group id, and even + mtime may be saved for individual files. This needs a format change, + which is backward compatible, but older kernels will not recognise + any of these features. + Changes in release 0.5.2: * faked device names may contain the special characters "-" "_" and "+" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/genromfs.8 new/genromfs-0.5.7/genromfs.8 --- old/genromfs-0.5.2/genromfs.8 2007-06-26 19:08:47.000000000 +0200 +++ new/genromfs-0.5.7/genromfs.8 2009-02-15 11:48:15.000000000 +0100 @@ -1,4 +1,4 @@ -.TH GENROMFS 8 "Jun 2007" "Version 0.5.2" +.TH GENROMFS 8 "Feb 2009" "Version 0.5.7" .SH NAME genromfs \- create a romfs image .SH SYNOPSIS @@ -83,16 +83,99 @@ directories, or start with a leading slash, in which case they are matched against absolute paths inside of the romfs filesystem (that is, as if you chrooted into the rom filesystem). + .TP .BI -x \ pattern Allow to exclude files that match a pattern. It's useful to exclude CVS directories and backup files (ending in a '~'). .TP +.BI -i \ pattern +Include files that match a pattern. You can mix and match +.B +-i +and +.B +-x +options, they will be processed in the order specified. You can exclude +files matching +.I +*.bin +but include +.I +boot*.bin +later. +.TP .BI -v Verbose operation, .B genromfs will print each file which is included in the image, along with its offset. + +.SH EXTENSION OPTIONS +Except for the alignment options, these are not supported in current +in-kernel +.B +romfs +implementations as of early 2009. + +.TP +.BI -ealign:N,PATTERN +Same as the +.B -AN,PATTERN +option. + +.TP +.BI -ealign:N +Same as the +.B -aN +option. + +.TP +.BI -eperm:N[,PATTERN] +Will try to store the numeric (octal) permission for the files matching the pattern. Examples are +.B +600 +for files accessible to their owners only, or +.B +4711 +for +.I +setuid +files. +The +.I +PATTERN +is optional, if missing, it will apply to all files (which is not generally useful). + +.TP +.BI -eperm[,PATTERN] +Similar to the above option, except that the permission to store will be retrieved from the +actual file. + +.TP +.BI -euid:N[,PATTERN] + +.TP +.BI -euid[,PATTERN] + +.TP +.BI -egid:N[,PATTERN] + +.TP +.BI -egid[,PATTERN] +Similarly to the +.I +-eperm +option, these options allow to store the file user-id and group-id information. + +.TP +.BI -etime:N[,PATTERN] + +.TP +.BI -etime[,PATTERN] +Similarly, these options allow to store the file modification timestamp. The number is the +Unix time, the seconds since January 1, 1970, 00:00:00 UTC. + .SH EXAMPLES .EX diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/genromfs.c new/genromfs-0.5.7/genromfs.c --- old/genromfs-0.5.2/genromfs.c 2007-06-26 19:08:47.000000000 +0200 +++ new/genromfs-0.5.7/genromfs.c 2009-02-15 11:48:15.000000000 +0100 @@ -75,7 +75,15 @@ #include <sys/sysmacros.h> #endif +#ifdef O_BINARY +#define O_RDBIN (O_RDONLY|O_BINARY) +#else +#define O_RDBIN O_RDONLY +#endif + +/* physical on-disk layout */ +/* 16 byte romfs header */ struct romfh { int32_t nextfh; int32_t spec; @@ -94,6 +102,39 @@ #define ROMFH_FIF 7 #define ROMFH_EXEC 8 +#define ROMEXT_MAGIC3 "xyz" + +/* + * extension tag, starting backwards from the fileheader: + * .... + * TtTt TtTt TtTt TtTt + * TtTt TtTt xyzN CHKS + * NEXT SPEC SIZE CHKS <- the usual fileheader + * Tt: 16 bits of romext tags, the first few being 0 + * xyzN: 16 bits of ID, N being the (binary) number of 16 byte "rows" + * CHKS: checksum spanning the whole + */ + +#define ROMET_TYPE 0xf000 /* type of the tag */ +#define ROMET_VAL 0x0fff /* value of the tag */ + +/* reserved for extended attributes */ +#define ROMET_MORE 0x0000 /* 6+6 bits of further extensions */ + +#define ROMET_MORETYPE 0x0fc0 /* 6 bits - additional extension type */ +#define ROMETMT_END 0x0000 /* end of extension tags */ +#define ROMET_MOREVAL 0x003f /* 6 bits - number of int16s */ + +#define ROMET_PERM 0x1000 /* 12 bits of permissions AND end of tags */ +#define ROMET_UGID 0x2000 /* 6+6 bits of uid/gid */ +#define ROMET_UID 0x3000 /* 12 additional bits of uid (ROLed in) */ +#define ROMET_GID 0x4000 /* 12 additional bits of gid (ROLed in) */ +#define ROMET_TIME 0x5000 /* 12 additional bits of timestamp (ROLed in) */ +#define ROMET_MARKER 0x7000 /* ignored -- header only */ +/* 0x6000/0x8000-0xf000 is reserved */ + +/* genromfs internal data types */ + struct filenode; struct filehdr { @@ -115,23 +156,39 @@ struct filenode *orig_link; char *name; char *realname; + int isrootdot; dev_t ondev; dev_t devnode; ino_t onino; mode_t modes; + uid_t nuid; + gid_t ngid; + time_t ntime; unsigned int offset; - unsigned int size; - unsigned int pad; + unsigned int realsize; + unsigned int prepad; + unsigned int postpad; + int exclude; + unsigned int align; + int extperm; + int extuid; + int extgid; + int exttime; + char extdata[32]; + int extlen; }; -struct aligns { - struct aligns *next; - int align; - char pattern[0]; -}; - -struct excludes { - struct excludes *next; +#define EXTTYPE_UNKNOWN 0 +#define EXTTYPE_ALIGNMENT 1 +#define EXTTYPE_EXCLUDE 2 +#define EXTTYPE_EXTPERM 3 +#define EXTTYPE_EXTUID 4 +#define EXTTYPE_EXTGID 5 +#define EXTTYPE_EXTTIME 6 +struct extmatches { + struct extmatches *next; + unsigned int exttype; + unsigned int num; char pattern[0]; }; @@ -162,7 +219,7 @@ struct filenode *p; fprintf(f, "%-4d %-20s [0x%-8x, 0x%-8x] %07o, sz %5u, at 0x%-6x", level, node->name, - (int)node->ondev, (int)node->onino, node->modes, node->size, + (int)node->ondev, (int)node->onino, node->modes, node->realsize, node->offset); if (node->orig_link) @@ -181,37 +238,43 @@ static char bigbuf[4096]; static char fixbuf[512]; static int atoffs = 0; -static int align = 16; -struct aligns *alignlist = NULL; -struct excludes *excludelist = NULL; -int realbase; +static struct extmatches *patterns = NULL; +static int realbase; +static int extlevel = 0; + +#define DEFALIGN 16 /* helper function to match an exclusion or align pattern */ int nodematch(char *pattern, struct filenode *node) { char *start = node->name; + + /* empty means all */ + if (pattern[0] == 0) return 0; + /* XXX: ugly realbase is global */ if (pattern[0] == '/') start = node->realname + realbase; return fnmatch(pattern,start,FNM_PATHNAME|FNM_PERIOD); } -int findalign(struct filenode *node) +void addpattern(int type,int num,char *s) { - struct aligns *pa; - int i; - - if (S_ISREG(node->modes)) i = align; - else i = 16; - - for (pa = alignlist; pa; pa = pa->next) { - if (pa->align > i) { - if (!nodematch(pa->pattern,node)) i = pa->align; + struct extmatches *pa, *pa2; + pa = (struct extmatches *)malloc(sizeof(*pa) + strlen(s) + 1); + pa->exttype = type; + pa->num = num; + pa->next = NULL; + strcpy (pa->pattern,s); + + if (!patterns) { patterns = pa; } + else { + for (pa2 = patterns; pa2->next; pa2 = pa2->next) { + ; } + pa2->next = pa; } - return i; } - int romfs_checksum(void *data, int size) { int32_t sum, word, *ptr; @@ -291,6 +354,11 @@ memset(bigbuf+16+len, 0, 16-(len&15)); len += 16-(len&15); } + /* special marker for present extensions */ + if (n->isrootdot == 1 && extlevel) { + memcpy(bigbuf+16+8, ROMEXT_MAGIC3, 3); + fixsum((struct romfh *)(bigbuf + 16), 16); + } len+=16; ri=(struct romfh *)bigbuf; if (n->offset) @@ -310,12 +378,17 @@ struct romfh ri; struct filenode *p; + if (node->prepad) + dumpzero(node->prepad, f); + if (node->extlen) { + dumpdataa(node->extdata+sizeof(node->extdata)-node->extlen, node->extlen, f); + } + ri.nextfh = 0; ri.spec = 0; - ri.size = htonl(node->size); + ri.size = htonl(node->realsize); ri.checksum = htonl(0x55555555); - if (node->pad) - dumpzero(node->pad, f); + if (node->next && node->next->next) ri.nextfh = htonl(node->next->offset); if ((node->modes & 0111) && @@ -340,21 +413,19 @@ ri.nextfh |= htonl(ROMFH_LNK); dumpri(&ri, node, f); memset(bigbuf, 0, sizeof(bigbuf)); - readlink(node->realname, bigbuf, node->size); - dumpdataa(bigbuf, node->size, f); + readlink(node->realname, bigbuf, node->realsize); + dumpdataa(bigbuf, node->realsize, f); } else if (S_ISREG(node->modes)) { int offset, len, fd, max, avail; ri.nextfh |= htonl(ROMFH_REG); dumpri(&ri, node, f); offset = 0; - max = node->size; - /* XXX warn about size mismatch */ - fd = open(node->realname, O_RDONLY -#ifdef O_BINARY -| O_BINARY -#endif -); + max = node->realsize; + fd = open(node->realname, O_RDBIN); if (fd) { + /* we cannot handle 64 bit file sizes */ + unsigned int realsize=0; + struct stat s; while(offset < max) { avail = max-offset < sizeof(bigbuf) ? max-offset : sizeof(bigbuf); len = read(fd, bigbuf, avail); @@ -363,7 +434,26 @@ dumpdata(bigbuf, len, f); offset+=len; } + if (offset != max) { + fprintf(stderr,"file %s changed size while reading?\n",node->realname); + exit(1); + } + if (!fstat(fd,&s)) { + realsize = s.st_size; + } + if (realsize != max) { + fprintf(stderr,"file %s changed size while reading?\n",node->realname); + exit(1); + } + realsize = lseek(fd,0,SEEK_CUR); + if (realsize != max) { + fprintf(stderr,"file %s changed size while reading?\n",node->realname); + exit(1); + } close(fd); + } else { + fprintf(stderr,"file %s cannot be opened?\n",node->realname); + exit(1); } max = (max+15)&~15; while (offset < max) { @@ -387,6 +477,8 @@ ri.nextfh |= htonl(ROMFH_SCK); dumpri(&ri, node, f); } + if (node->postpad) + dumpzero(node->postpad, f); p = node->dirlist.head; while (p->next) { @@ -422,11 +514,19 @@ /* Rare, not yet */ } -void setnode(struct filenode *n, dev_t dev, ino_t ino, mode_t um) +void setnode(struct filenode *n, struct stat *sb) { - n->ondev = dev; - n->onino = ino; - n->modes = um; + n->ondev = sb->st_dev; + n->onino = sb->st_ino; + n->modes = sb->st_mode; + n->nuid = sb->st_uid; + n->ngid = sb->st_gid; + n->ntime = sb->st_mtime; + n->realsize = 0; + /* only regular files and symlinks contain "data" in romfs */ + if (S_ISREG(n->modes) || S_ISLNK(n->modes)) { + n->realsize = sb->st_size; + } } struct filenode *newnode(const char *base, const char *name, int curroffset) @@ -440,6 +540,7 @@ fprintf(stderr,"out of memory\n"); exit(1); } + memset(node,0,sizeof(*node)); len = strlen(name); str = malloc(len+1); @@ -468,18 +569,21 @@ } node->realname = str; - node->next = node->prev = NULL; - node->parent = NULL; initlist(&node->dirlist, node); node->ondev = -1; node->onino = -1; node->modes = -1; - node->size = 0; - node->devnode = 0; - node->orig_link = NULL; node->offset = curroffset; - node->pad = 0; + node->align = DEFALIGN; + + /* -2: specified without value */ + /* -1: specified as blank (to copy original) */ + /* N: specified */ + node->extperm = -2; + node->extuid = -2; + node->extgid = -2; + node->exttime = -2; return node; } @@ -503,23 +607,153 @@ #define ALIGNUP16(x) (((x)+15)&~15) -int spaceneeded(struct filenode *node) +int spaceneeded(struct filenode *node, unsigned int sz) { - return 16 + ALIGNUP16(strlen(node->name)+1) + ALIGNUP16(node->size); + return 16 + ALIGNUP16(strlen(node->name)+1) + ALIGNUP16(sz); } int alignnode(struct filenode *node, int curroffset, int extraspace) { - int align = findalign(node), d; - + int d; + unsigned int align = DEFALIGN; + unsigned int checkpos; + int fd; + + if (S_ISREG(node->modes)) align = node->align; + + /* Just a safeguard to make sure file contents won't be mistaken for extension tags */ + if ((checkpos = node->realsize) && + (((checkpos+8) & 15) <= 8)) { + if ((((checkpos+8)&15) == 8)) checkpos -= 16; + checkpos &= ~15; + + if (S_ISREG(node->modes)) { + if ((fd = open(node->realname, O_RDBIN)) >= 0) { + memset(bigbuf, 0, 16); + read(fd, bigbuf, 16); + checkpos = 0; + } + } else if (S_ISLNK(node->modes)) { + memset(bigbuf, 0, sizeof(bigbuf)); + readlink(node->realname, bigbuf, sizeof(bigbuf)-1); + } else { + fprintf(stderr,"internal error, %s has size?\n", node->realname); + exit(1); + } + if(!memcmp(bigbuf+checkpos+8, ROMEXT_MAGIC3, 3)) { + node->postpad += 16; + } + } + + curroffset += node->extlen; + node->offset += node->extlen; + d = ((curroffset + extraspace) & (align - 1)); if (d) { align -= d; curroffset += align; node->offset += align; - node->pad = align; + node->prepad = align; } - return curroffset; + + return curroffset+node->postpad; +} + +/* Build romfs extension header */ +/* NOTE: The format change is not complete */ +/* XXX: root permissions must be stored in /.. */ + +int buildromext(struct filenode *node) +{ + unsigned int tag; + unsigned int extidx,extend; + char *romext=node->extdata; + unsigned int myuid,mygid; + unsigned int mytime; + + /* root dir cannot be extended */ + if (node->isrootdot == 1) return 0; + + extend = extidx = sizeof(node->extdata); + memset(romext, 0, extidx); + + extidx-=8; + memcpy(romext+extidx,ROMEXT_MAGIC3,3); + + /* override permissions if any given */ + if (node->extperm != (unsigned int)-1 && node->extperm != (unsigned int)-2) { + node->modes = (node->modes&~07777)|node->extperm; + } + if (node->extuid != (unsigned int)-1 && node->extuid != (unsigned int)-2) { + node->nuid = node->extuid; + } + if (node->extgid != (unsigned int)-1 && node->extgid != (unsigned int)-2) { + node->ngid = node->extgid; + } + if (node->exttime != (unsigned int)-1 && node->exttime != (unsigned int)-2) { + node->ntime = node->exttime; + } else { + node->ntime = 0; + } + + /* build romext */ + if (node->extperm != (unsigned int)-2) { + tag=ROMET_PERM|(node->modes&07777); + romext[--extidx]=tag; + romext[--extidx]=tag>>8; + } + myuid = node->nuid; + mygid = node->ngid; + if (node->extuid == (unsigned int)-2) { myuid = 0; } + if (node->extgid == (unsigned int)-2) { mygid = 0; } + if ((myuid && mygid) && + ( (myuid <= 077 && mygid <= 077)) ) { + tag=ROMET_UGID|((myuid&077)<<6|(mygid&077)); + romext[--extidx]=tag; + romext[--extidx]=tag>>8; + myuid >>= 6; + mygid >>= 6; + } + while (myuid) { + tag=ROMET_UID|(myuid&0xfff); + romext[--extidx]=tag; + romext[--extidx]=tag>>8; + myuid >>= 12; + } + while (mygid) { + tag=ROMET_GID|(mygid&0xfff); + romext[--extidx]=tag; + romext[--extidx]=tag>>8; + mygid >>= 12; + } + mytime = node->ntime; + while (mytime) { + tag=ROMET_TIME|(mytime&0xfff); + romext[--extidx]=tag; + romext[--extidx]=tag>>8; + mytime >>= 12; + } + + + if (extidx == (extend-8)) { + return 0; + } + + /* compute the aligned start */ + extidx &= ~15; + node->extlen = extend-extidx; + tag = htonl(-romfs_checksum(node->extdata+extidx, node->extlen)); + /* the number of 16 byte lines in the extension header */ + node->extdata[extend-5] = node->extlen>>4; + + /* store checksum */ + romext = node->extdata + extend; + *--romext=tag; + *--romext=tag>>8; + *--romext=tag>>16; + *--romext=tag>>24; + + return node->extlen; } int processdir(int level, const char *base, const char *dirname, struct stat *sb, @@ -528,31 +762,34 @@ DIR *dirfd; struct dirent *dp; struct filenode *n, *link; - struct excludes *pe; + struct extmatches *pa; + /* To make sure . and .. are handled correctly in the + * root directory, we add them first. Note also that we + * alloc them first to get to know the real name + */ if (level <= 1) { - /* Ok, to make sure . and .. are handled correctly - * we add them first. Note also that we alloc them - * first to get to know the real name - */ link = newnode(base, ".", curroffset); + link->isrootdot = 1; if (!lstat(link->realname, sb)) { - setnode(link, sb->st_dev, sb->st_ino, sb->st_mode); + setnode(link, sb); append(&dir->dirlist, link); - /* special case for root node - '..'s in subdirs should link to - * '.' of root node, not root node itself. + /* special case for root node - '..'s in + * subdirs should link to '.' of root + * node, not root node itself. */ dir->dirlist.owner = link; - curroffset = alignnode(link, curroffset, 0) + spaceneeded(link); + curroffset = alignnode(link, curroffset, 0) + spaceneeded(link,0); n = newnode(base, "..", curroffset); + n->isrootdot = 2; if (!lstat(n->realname, sb)) { - setnode(n, sb->st_dev, sb->st_ino, sb->st_mode); + setnode(n, sb); append(&dir->dirlist, n); n->orig_link = link; - curroffset = alignnode(n, curroffset, 0) + spaceneeded(n); + curroffset = alignnode(n, curroffset, 0) + spaceneeded(n,0); } } } @@ -569,11 +806,18 @@ continue; n = newnode(base, dp->d_name, curroffset); - /* Process exclude list. */ - for (pe = excludelist; pe; pe = pe->next) { - if (!nodematch(pe->pattern, n)) { freenode(n); break; } + /* Process exclude/align list. */ + for (pa = patterns; pa; pa = pa->next) { + if (!nodematch(pa->pattern, n)) { + if (pa->exttype == EXTTYPE_EXCLUDE) { n->exclude = pa->num; } + if (pa->exttype == EXTTYPE_ALIGNMENT) { n->align = pa->num; } + if (pa->exttype == EXTTYPE_EXTPERM) { extlevel |= 1; n->extperm = pa->num; } + if (pa->exttype == EXTTYPE_EXTUID) { extlevel |= 1; n->extuid = pa->num; } + if (pa->exttype == EXTTYPE_EXTGID) { extlevel |= 1; n->extgid = pa->num; } + if (pa->exttype == EXTTYPE_EXTTIME) { extlevel |= 1; n->exttime = pa->num; } + } } - if (pe) continue; + if (n->exclude) { freenode(n); continue; } if (lstat(n->realname, sb)) { fprintf(stderr, "ignoring '%s' (lstat failed)\n", n->realname); @@ -602,7 +846,7 @@ char type; int major; int minor; - + if (sscanf(n->name, "@%[a-zA-Z0-9_+-],%c,%d,%d", devname, &type, &major, &minor) == 4 ) { strcpy(n->name, devname); @@ -629,7 +873,7 @@ } } - setnode(n, sb->st_dev, sb->st_ino, sb->st_mode); + setnode(n, sb); /* Skip unreadable files/dirs */ if (!S_ISLNK(n->modes) && access(n->realname, R_OK)) { fprintf(stderr, "ignoring '%s' (access failed)\n", n->realname); @@ -649,23 +893,26 @@ } if (link) { + n->realsize = 0; n->orig_link = link; - curroffset = alignnode(n, curroffset, 0) + spaceneeded(n); + curroffset = alignnode(n, curroffset, 0) + spaceneeded(n,0); continue; } - if (S_ISREG(sb->st_mode)) { - curroffset = alignnode(n, curroffset, spaceneeded(n)); - n->size = sb->st_size; - } else - curroffset = alignnode(n, curroffset, 0); - if (S_ISLNK(sb->st_mode)) { - n->size = sb->st_size; - } - curroffset += spaceneeded(n); + if (S_ISCHR(sb->st_mode) || S_ISBLK(sb->st_mode)) { n->devnode = sb->st_rdev; } + buildromext(n); + + if (S_ISREG(sb->st_mode)) { + curroffset = alignnode(n, curroffset, spaceneeded(n,0)); + } else { + curroffset = alignnode(n, curroffset, 0); + } + + curroffset += spaceneeded(n,n->realsize); + if (S_ISDIR(sb->st_mode)) { if (!strcmp(n->name, "..")) { curroffset = processdir(level+1, dir->realname, dp->d_name, @@ -693,9 +940,10 @@ printf(" -a ALIGN Align regular file data to ALIGN bytes\n"); printf(" -A ALIGN,PATTERN Align all objects matching pattern to at least ALIGN bytes\n"); printf(" -x PATTERN Exclude all objects matching pattern\n"); + printf(" -i PATTERN Include all objects matching pattern\n"); printf(" -h Show this help\n"); printf("\n"); - printf("Report bugs to chexum@shadow.banki.hu\n"); + printf("To report bugs check http://romfs.sf.net/\n"); } int main(int argc, char *argv[]) @@ -709,13 +957,11 @@ struct filenode *root; struct stat sb; int lastoff; - int i; - char *p; - struct aligns *pa, *pa2; - struct excludes *pe, *pe2; + unsigned int i; + char *p,*optn,*optpat; FILE *f; - while ((c = getopt(argc, argv, "V:vd:f:ha:A:x:")) != EOF) { + while ((c = getopt(argc, argv, "V:vd:f:ha:A:x:i:e:")) != EOF) { switch(c) { case 'd': dir = optarg; @@ -733,45 +979,81 @@ showhelp(argv[0]); exit(0); case 'a': - align = strtoul(optarg, NULL, 0); - if (align < 16 || (align & (align - 1))) { - fprintf(stderr, "Align has to be at least 16 bytes and a power of two\n"); - exit(1); - } - break; case 'A': i = strtoul(optarg, &p, 0); if (i < 16 || (i & (i - 1))) { - fprintf(stderr, "Align has to be at least 16 bytes and a power of two\n"); + fprintf(stderr, "Alignment has to be at least 16 bytes and a power of two\n"); exit(1); } - if (*p != ',' || !p[1]) { + if (c == 'a') { + if (p[0] != 0) { + fprintf(stderr, "-a must only be given a number\n"); + exit(1); + } + p=","; + } + if (*p != ',') { fprintf(stderr, "-A takes N,PATTERN format of argument, where N is a number\n"); exit(1); } - /* strlen(p+1) + 1 eq strlen(p) */ - pa = (struct aligns *)malloc(sizeof(*pa) + strlen(p)); - pa->align = i; - pa->next = NULL; - strcpy(pa->pattern, p + 1); - if (!alignlist) - alignlist = pa; - else { - for (pa2 = alignlist; pa2->next; pa2 = pa2->next) - ; - pa2->next = pa; - } + addpattern(EXTTYPE_ALIGNMENT,i,p+1); break; + case 'i': case 'x': - pe = (struct excludes *)malloc(sizeof(*pe) + strlen(optarg) + 1); - pe->next = NULL; - strcpy(pe->pattern, optarg); - if (!excludelist) - excludelist = pe; - else { - for (pe2 = excludelist; pe2->next; pe2 = pe2->next) - ; - pe2->next = pe; + addpattern(EXTTYPE_EXCLUDE,c=='x',optarg); + break; + /* -e EXT[:VAL][,PATTERN] */ + case 'e': + i = (unsigned int)-1; + optpat = strchr(optarg,','); + if (optpat) { *optpat++ = 0; } + else { optpat=""; } + optn = strchr(optarg,':'); + if (optn) { + *optn++ = 0; + i = strtoul(optn,&p,0); + if (*p != 0) { + fprintf(stderr,"-e%s:N,PATTERN must be numeric\n",optarg); + exit(1); + } + } + /* -ealign:N,PATTERN */ + if (!strcmp(optarg,"align")) { + if (i == (unsigned int)-1) { + fprintf(stderr,"-e%s:N,PATTERN needs value\n",optarg); + exit(1); + } + if (i < 16 || (i & (i - 1))) { + fprintf(stderr, "Alignment has to be at least 16 bytes and a power of two\n"); + exit(1); + } + addpattern(EXTTYPE_ALIGNMENT,i,optpat); + /* -eperm:N[,PATTERN] - set permissions for pattern */ + /* -eperm[,PATTERN] - save permissions for pattern */ + } else if (!strcmp(optarg,"perm")) { + /* reparse it in octal */ + if (optn) { + i = strtoul(optn,&p,8); + if (*p != 0 || (i != (unsigned int)-1 && i&~07777)) { + fprintf(stderr,"-e%s:N must be octal and less than 07777\n",optarg); + exit(1); + } + } + addpattern(EXTTYPE_EXTPERM,i,optpat); + /* -euid:N[,PATTERN] - set uid for pattern */ + /* -euid[,PATTERN] - save uid for pattern */ + } else if (!strcmp(optarg,"uid")) { + addpattern(EXTTYPE_EXTUID,i,optpat); + /* -egid:N[,PATTERN] - set uid for pattern */ + /* -egid[,PATTERN] - save uid for pattern */ + } else if (!strcmp(optarg,"gid")) { + addpattern(EXTTYPE_EXTGID,i,optpat); + /* -etime:N[,PATTERN] - set timestamp for pattern */ + /* -etime[,PATTERN] - save timestamp for pattern */ + } else if (!strcmp(optarg,"time")) { + addpattern(EXTTYPE_EXTTIME,i,optpat); + } else { + fprintf(stderr,"-e%s not recognised\n",optarg); } break; default: @@ -797,11 +1079,11 @@ perror(outf); exit(1); } - + realbase = strlen(dir); root = newnode(dir, volname, 0); root->parent = root; - lastoff = processdir (1, dir, dir, &sb, root, root, spaceneeded(root)); + lastoff = processdir (1, dir, dir, &sb, root, root, spaceneeded(root,0)); if (verbose) shownode(0, root, stderr); dumpall(root, lastoff, f); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/genromfs.lsm new/genromfs-0.5.7/genromfs.lsm --- old/genromfs-0.5.2/genromfs.lsm 2007-06-26 19:08:47.000000000 +0200 +++ new/genromfs-0.5.7/genromfs.lsm 2009-02-15 11:48:15.000000000 +0100 @@ -1,7 +1,7 @@ Begin3 Title: genromfs -Version: 0.5.2 -Entered-date: 26 Jan 2007 +Version: 0.5.7 +Entered-date: 15 Feb 2009 Description: This is the mkfs equivalent for romfs filesystem. You need it to build such a filesystem. romfs is a small, read-only filesystem intended for installation/rescue @@ -11,7 +11,7 @@ Author: chexum+dev () gmail.com (Janos Farkas) Maintained-by: chexum+dev () gmail.com (Janos Farkas) Primary-site: sunsite.unc.edu /pub/Linux/system/recovery/ - 24kB genromfs-0.5.2.tar.gz + 28kB genromfs-0.5.7.tar.gz Platforms: Linux 2.0 or later, gcc Copying-policy: GPL End diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/romfs.txt new/genromfs-0.5.7/romfs.txt --- old/genromfs-0.5.2/romfs.txt 2007-06-26 19:08:47.000000000 +0200 +++ new/genromfs-0.5.7/romfs.txt 2009-02-15 11:48:15.000000000 +0100 @@ -28,10 +28,10 @@ which has only this filesystem linked in, and then can load any module later, with the current module utilities. It can also be used to run some program to decide if you need SCSI devices, and even IDE or -floppy drives can be loaded later if you use the "initrd"--initial -RAM disk--feature of the kernel. This would not be really news -flash, but with romfs, you can even spare off your ext2 or minix or -maybe even affs filesystem until you really know that you need it. +floppy drives can be loaded later if you use the "initrd"--initial RAM +disk--feature of the kernel. This would not be really news flash, but +with romfs, you can even spare off your ext2 or minix or maybe even +affs filesystem until you really know that you need it. For example, a distribution boot disk can contain only the cd disk drivers (and possibly the SCSI drivers), and the ISO 9660 filesystem @@ -44,13 +44,13 @@ purpose, just because it won't fit into ext2. romfs operates on block devices as you can expect, and the underlying -structure is very simple. Every accessible structure begins on 16 -byte boundaries for fast access. The minimum space a file will take -is 32 bytes (this is an empty file, with a less than 16 character -name). The maximum overhead for any non-empty file is the header, and -the 16 byte padding for the name and the contents, also 16+14+15 = 45 -bytes. This is quite rare however, since most file names are longer -than 3 bytes, and shorter than 15 bytes. +structure is very simple. Every accessible structure begins on a 16 +byte boundary for fast access. The minimum space a file will take is +32 bytes (this is an empty file, with a name shorter than 16 +characters). The maximum overhead for any non-empty file is the +header, and the 16 byte padding for the name and the contents, thus +16+14+15 = 45 bytes. This is quite rare however, since most file +names are longer than 3 bytes, and shorter than 15 bytes. The layout of the filesystem is the following: @@ -127,13 +127,14 @@ Note that hard links are specifically marked in this filesystem, but they will behave as you can expect (i.e. share the inode number). -Note also that it is your responsibility to not create hard link -loops, and creating all the . and .. links for directories. This is -normally done correctly by the genromfs program. Please refrain from -using the executable bits for special purposes on the socket and fifo -special files, they may have other uses in the future. Additionally, -please remember that only regular files, and symlinks are supposed to -have a nonzero size field; they contain the number of bytes available +Note also that as the filesystem is readonly, the program creating it +must not create hard link loops, and must create all the . and .. +links for directories the way UNIX programs expect. This is normally +done correctly by the genromfs program. Please refrain from using the +executable bits for special purposes on the socket and fifo special +files, they may have other uses in the future. Additionally, please +remember that only regular files, and symlinks are supposed to have a +nonzero size field; they contain the number of bytes available directly after the (padded) file name. Another thing to note is that romfs works on file headers and data @@ -143,18 +144,10 @@ padded to an 1024 byte boundary. If you have any problems or suggestions concerning this file system, -please contact me. However, think twice before wanting me to add -features and code, because the primary and most important advantage of -this file system is the small code. On the other hand, don't be -alarmed, I'm not getting that much romfs related mail. Now I can -understand why Avery wrote poems in the ARCnet docs to get some more -feedback. :) - -romfs has also a mailing list, and to date, it hasn't received any -traffic, so you are welcome to join it to discuss your ideas. :) - -It's run by ezmlm, so you can subscribe to it by sending a message -to romfs-subscribe@shadow.banki.hu, the content is irrelevant. +please contact me. I'd appreciate if you could bear in mind the +primary goals of the filesystem, that is being as small as possible +while having only the most essential features to have a running Linux +system on it. There is a web page about romfs at: @@ -174,17 +167,9 @@ - Since the files are only required to have alignment on a 16 byte boundary, it is currently possibly suboptimal to read or execute files -from the filesystem. It might be resolved by reordering file data to -have most of it (i.e. except the start and the end) laying at "natural" -boundaries, thus it would be possible to directly map a big portion of -the file contents to the mm subsystem. +from the filesystem. It is possible to reorder the file data to have +it at "natural" sector alignment, but to efficiently use it, there +might be need for other supporting code. - Compression might be an useful feature, but memory is quite a limiting factor in my eyes. - -- Where it is used? - -- Does it work on other architectures than intel and motorola? - -Have fun, -Janos Farkas <chexum@shadow.banki.hu> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/1.ok new/genromfs-0.5.7/selftest/1.ok --- old/genromfs-0.5.2/selftest/1.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/1.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,9 @@ +0000000: 2d72 6f6d 3166 732d 0000 0060 02d9 ccb2 -rom1fs-...`.... +0000010: 454d 5054 5900 0000 0000 0000 0000 0000 EMPTY........... +0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +0000040: 0000 0000 0000 0020 0000 0000 d1d1 ffe0 ....... ........ +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/10.ok new/genromfs-0.5.7/selftest/10.ok --- old/genromfs-0.5.2/selftest/10.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/10.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,12 @@ +0000000: 2d72 6f6d 3166 732d 0000 0090 25cf 1bc3 -rom1fs-....%... +0000010: 494e 434c 5544 4553 0000 0000 0000 0000 INCLUDES........ +0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +0000040: 0000 0060 0000 0020 0000 0000 d1d1 ff80 ...`... ........ +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 0002 0000 0000 0000 0007 6a1c 181f ............j... +0000070: 676f 6f64 2e74 7874 0000 0000 0000 0000 good.txt........ +0000080: 7761 6e74 6564 0a00 0000 0000 0000 0000 wanted.......... +0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/11.ok new/genromfs-0.5.7/selftest/11.ok --- old/genromfs-0.5.2/selftest/11.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/11.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,17 @@ +0000000: 2d72 6f6d 3166 732d 0000 0110 dd55 543d -rom1fs-.....UT= +0000010: 414c 4947 4e4e 4557 0000 0000 0000 0000 ALIGNNEW........ +0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +0000040: 0000 0060 0000 0020 0000 0000 d1d1 ff80 ...`... ........ +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 00e2 0000 0000 0000 0004 d5d1 8bb2 ................ +0000070: 2a2e 7368 0000 0000 0000 0000 0000 0000 *.sh............ +0000080: 6465 6c0a 0000 0000 0000 0000 0000 0000 del............. +0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00000e0: 0000 0002 0000 0000 0000 0008 b25d 1618 .............].. +00000f0: 7374 7566 662e 7478 7400 0000 0000 0000 stuff.txt....... +0000100: 616c 6967 6e65 640a 0000 0000 0000 0000 aligned......... +0000110: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/12.ok new/genromfs-0.5.7/selftest/12.ok --- old/genromfs-0.5.2/selftest/12.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/12.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,33 @@ +0000000: 2d72 6f6d 3166 732d 0000 01e0 f1f7 c9d6 -rom1fs-........ +0000010: 5045 524d 4953 5349 4f4e 5300 0000 0000 PERMISSIONS..... +0000020: 0000 0049 0000 0020 0000 0000 ffff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 7879 7a00 5986 8600 ........xyz.Y... +0000040: 0000 0070 0000 0020 0000 0000 d1d1 ff70 ...p... .......p +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 0000 0000 403e 7879 7a01 c245 8687 ......@>xyz..E.. +0000070: 0000 00b2 0000 0000 0000 0005 2451 591b ............$QY. +0000080: 6736 322e 7478 7400 0000 0000 0000 0000 g62.txt......... +0000090: 7878 7878 0a00 0000 0000 0000 0000 0000 xxxx............ +00000a0: 0000 0000 0000 1949 7879 7a01 b76c 8687 .......Ixyz..l.. +00000b0: 0000 00fa 0000 0000 0000 0005 5e16 555c ............^.U\ +00000c0: 7375 3131 2e74 7874 0000 0000 0000 0000 su11.txt........ +00000d0: 7a7a 7a7a 0a00 0000 0000 0000 0000 0000 zzzz............ +00000e0: 0000 0000 2ffe 1949 7879 7a01 b76c 8857 ..../..Ixyz..l.W +00000f0: 0000 013a 0000 0000 0000 0005 2ba0 e8e4 ...:........+... +0000100: 7375 6736 3275 3633 2e74 7874 0000 0000 sug62u63.txt.... +0000110: 7a7a 7a7a 0a00 0000 0000 0000 0000 0000 zzzz............ +0000120: 0000 0000 4080 307f 7879 7a01 8155 0647 ....@.0.xyz..U.G +0000130: 0000 0172 0000 0000 0000 0005 f529 21a6 ...r.........)!. +0000140: 7531 3237 6731 3238 2e74 7874 0000 0000 u127g128.txt.... +0000150: 7171 7171 0a00 0000 0000 0000 0000 0000 qqqq............ +0000160: 0000 0000 0000 303f 7879 7a01 c155 8687 ......0?xyz..U.. +0000170: 0000 01b2 0000 0000 0000 0005 1651 571b .............QW. +0000180: 7536 332e 7478 7400 0000 0000 0000 0000 u63.txt......... +0000190: 7878 7878 0a00 0000 0000 0000 0000 0000 xxxx............ +00001a0: 0000 0000 0000 2ffe 7879 7a01 0256 8687 ....../.xyz..V.. +00001b0: 0000 0002 0000 0000 0000 0005 dc23 9e1e .............#.. +00001c0: 7536 3367 3632 2e74 7874 0000 0000 0000 u63g62.txt...... +00001d0: 7979 7979 0a00 0000 0000 0000 0000 0000 yyyy............ +00001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/13.ok new/genromfs-0.5.7/selftest/13.ok --- old/genromfs-0.5.2/selftest/13.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/13.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,27 @@ +0000000: 2d72 6f6d 3166 732d 0000 0180 afe5 1bf6 -rom1fs-........ +0000010: 4445 5649 4345 5300 0000 0000 0000 0000 DEVICES......... +0000020: 0000 0049 0000 0020 0000 0000 ffff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 7879 7a00 5986 8600 ........xyz.Y... +0000040: 0000 0070 0000 0020 0000 0000 d1d1 ff70 ...p... .......p +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 0000 0000 11c9 7879 7a01 3774 8687 ........xyz.7t.. +0000070: 0000 0159 0000 0090 0000 0000 9b9a 8817 ...Y............ +0000080: 6465 7600 0000 0000 0000 0000 0000 0000 dev............. +0000090: 0000 00b0 0000 0070 0000 0000 d1ff fee0 .......p........ +00000a0: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +00000b0: 0000 00e0 0000 0020 0000 0000 d1d1 ff00 ....... ........ +00000c0: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +00000d0: 0000 0000 0000 11b6 7879 7a01 4a74 8687 ........xyz.Jt.. +00000e0: 0000 0115 0001 0003 0000 0000 9189 927c ...............| +00000f0: 6e75 6c6c 0000 0000 0000 0000 0000 0000 null............ +0000100: 0000 0000 0000 11b6 7879 7a01 4a74 8687 ........xyz.Jt.. +0000110: 0000 0005 0001 0005 0000 0000 8599 8d87 ................ +0000120: 7a65 726f 0000 0000 0000 0000 0000 0000 zero............ +0000130: 0000 0000 0000 0000 0000 0000 0000 5049 ..............PI +0000140: 5960 52d2 40c8 3064 7879 7a02 81b2 5ded Y`R.@.0dxyz...]. +0000150: 0000 0002 0000 0000 0000 000b f16c 294a .............l)J +0000160: 6665 6231 342e 7478 7400 0000 0000 0000 feb14.txt....... +0000170: 3132 3334 3536 3738 3930 0a00 0000 0000 1234567890...... +0000180: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/2.ok new/genromfs-0.5.7/selftest/2.ok --- old/genromfs-0.5.2/selftest/2.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/2.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,12 @@ +0000000: 2d72 6f6d 3166 732d 0000 0090 d7d4 1ad9 -rom1fs-........ +0000010: 5349 4e47 4c45 4649 4c45 0000 0000 0000 SINGLEFILE...... +0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +0000040: 0000 0060 0000 0020 0000 0000 d1d1 ff80 ...`... ........ +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 0002 0000 0000 0000 0006 228a 928b ............"... +0000070: 6475 6d6d 7900 0000 0000 0000 0000 0000 dummy........... +0000080: 6475 6d6d 790a 0000 0000 0000 0000 0000 dummy........... +0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/3.ok new/genromfs-0.5.7/selftest/3.ok --- old/genromfs-0.5.2/selftest/3.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/3.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,14 @@ +0000000: 2d72 6f6d 3166 732d 0000 00b0 2f1d 0eba -rom1fs-..../... +0000010: 4841 5244 4c49 4e4b 0000 0000 0000 0000 HARDLINK........ +0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +0000040: 0000 0060 0000 0020 0000 0000 d1d1 ff80 ...`... ........ +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 0092 0000 0000 0000 0006 228a 91fb ............"... +0000070: 6475 6d6d 7900 0000 0000 0000 0000 0000 dummy........... +0000080: 6475 6d6d 790a 0000 0000 0000 0000 0000 dummy........... +0000090: 0000 0000 0000 0060 0000 0000 2b35 1ed1 .......`....+5.. +00000a0: 6861 7264 6c69 6e6b 0000 0000 0000 0000 hardlink........ +00000b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/4.ok new/genromfs-0.5.7/selftest/4.ok --- old/genromfs-0.5.2/selftest/4.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/4.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,21 @@ +0000000: 2d72 6f6d 3166 732d 0000 0250 3b02 526e -rom1fs-...P;.Rn +0000010: 414c 4947 4e45 4400 0000 0000 0000 0000 ALIGNED......... +0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +0000040: 0000 0060 0000 0020 0000 0000 d1d1 ff80 ...`... ........ +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 01e2 0000 0000 0000 0007 1255 cc9f .............U.. +0000070: 7430 3178 797a 0000 0000 0000 0000 0000 t01xyz.......... +0000080: 7430 3161 6263 0a00 0000 0000 0000 0000 t01abc.......... +0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00001e0: 0000 0222 0000 0000 0000 001d 1558 cb4c ...".........X.L +00001f0: 7430 3275 7677 0000 0000 0000 0000 0000 t02uvw.......... +0000200: 2835 3132 616c 6967 6e65 6430 3132 3334 (512aligned01234 +0000210: 3536 3738 3961 6263 6465 6629 0a00 0000 56789abcdef).... +0000220: 0000 0002 0000 0000 0000 0007 185b cc85 .............[.. +0000230: 7430 3372 7374 0000 0000 0000 0000 0000 t03rst.......... +0000240: 7430 3367 6869 0a00 0000 0000 0000 0000 t03ghi.......... +0000250: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/5.ok new/genromfs-0.5.7/selftest/5.ok --- old/genromfs-0.5.2/selftest/5.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/5.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,21 @@ +0000000: 2d72 6f6d 3166 732d 0000 0120 17fb d72b -rom1fs-... ...+ +0000010: 4142 5341 4c49 474e 4544 0000 0000 0000 ABSALIGNED...... +0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +0000040: 0000 0060 0000 0020 0000 0000 d1d1 ff80 ...`... ........ +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 0092 0000 0000 0000 0007 1255 cdef .............U.. +0000070: 7430 3178 797a 0000 0000 0000 0000 0000 t01xyz.......... +0000080: 7430 3161 6263 0a00 0000 0000 0000 0000 t01abc.......... +0000090: 0000 00e2 0000 0000 0000 0007 1558 cca2 .............X.. +00000a0: 7430 3275 7677 0000 0000 0000 0000 0000 t02uvw.......... +00000b0: 7430 3264 6566 0a00 0000 0000 0000 0000 t02def.......... +00000c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +00000d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +00000e0: 0000 0002 0000 0000 0000 001d 88d0 31b3 ..............1. +00000f0: 7430 335f 3132 3361 6c69 676e 6564 0000 t03_123aligned.. +0000100: 2831 3238 616c 6967 6e65 6430 3132 3334 (128aligned01234 +0000110: 3536 3738 3961 6263 6465 6629 0a00 0000 56789abcdef).... +0000120: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/6.ok new/genromfs-0.5.7/selftest/6.ok --- old/genromfs-0.5.2/selftest/6.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/6.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,23 @@ +0000000: 2d72 6f6d 3166 732d 0000 0140 e9ea aa30 -rom1fs-...@...0 +0000010: 4558 5444 4154 4100 0000 0000 0000 0000 EXTDATA......... +0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +0000040: 0000 0060 0000 0020 0000 0000 d1d1 ff80 ...`... ........ +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 0092 0000 0000 0000 0010 b862 1db5 .............b.. +0000070: 726f 6d31 612e 7478 7400 0000 0000 0000 rom1a.txt....... +0000080: 3031 3233 3031 3233 7575 7531 3031 320a 01230123uuu1012. +0000090: 0000 00d2 0000 0000 0000 0010 b762 1d75 .............b.u +00000a0: 726f 6d31 622e 7478 7400 0000 0000 0000 rom1b.txt....... +00000b0: 3031 3233 3031 3233 7879 7a61 3031 320a 01230123xyza012. +00000c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +00000d0: 0000 0113 0000 0000 0000 000c b662 2d4f .............b-O +00000e0: 726f 6d31 632e 6461 7400 0000 0000 0000 rom1c.dat....... +00000f0: 3031 3233 3031 3233 7879 7a31 0000 0000 01230123xyz1.... +0000100: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +0000110: 0000 0003 0000 0000 0000 0009 b562 1e4b .............b.K +0000120: 726f 6d31 642e 7478 7400 0000 0000 0000 rom1d.txt....... +0000130: 726f 6d31 622e 7478 7400 0000 0000 0000 rom1b.txt....... +0000140: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/7.ok new/genromfs-0.5.7/selftest/7.ok --- old/genromfs-0.5.2/selftest/7.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/7.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,17 @@ +0000000: 2d72 6f6d 3166 732d 0000 0110 52ee 265d -rom1fs-....R.&] +0000010: 4445 4641 4c49 474e 4544 0000 0000 0000 DEFALIGNED...... +0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +0000040: 0000 0060 0000 0020 0000 0000 d1d1 ff80 ...`... ........ +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 00e2 0000 0000 0000 0005 2a25 27eb ............*%'. +0000070: 6162 632e 7478 7400 0000 0000 0000 0000 abc.txt......... +0000080: 3031 3233 0a00 0000 0000 0000 0000 0000 0123............ +0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00000e0: 0000 0002 0000 0000 0000 0005 2722 25cb ............'"%. +00000f0: 6465 662e 7478 7400 0000 0000 0000 0000 def.txt......... +0000100: 3435 3637 0a00 0000 0000 0000 0000 0000 4567............ +0000110: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/8.ok new/genromfs-0.5.7/selftest/8.ok --- old/genromfs-0.5.2/selftest/8.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/8.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,19 @@ +0000000: 2d72 6f6d 3166 732d 0000 0810 c342 3775 -rom1fs-.....B7u +0000010: 4d55 4c54 4941 4c49 474e 4544 0000 0000 MULTIALIGNED.... +0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +0000040: 0000 01e0 0000 0020 0000 0000 d1d1 fe00 ....... ........ +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00001e0: 0000 07e2 0000 0000 0000 0008 f067 503c .............gP< +00001f0: 6d36 386b 2e62 6f6f 7400 0000 0000 0000 m68k.boot....... +0000200: 626f 6f74 3531 320a 0000 0000 0000 0000 boot512......... +0000210: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00007e0: 0000 0002 0000 0000 0000 0009 b9ed 3c14 ..............<. +00007f0: 7370 6172 632e 626f 6f74 0000 0000 0000 sparc.boot...... +0000800: 626f 6f74 3230 3438 0a00 0000 0000 0000 boot2048........ +0000810: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +0000bf0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/9.ok new/genromfs-0.5.7/selftest/9.ok --- old/genromfs-0.5.2/selftest/9.ok 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/9.ok 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,12 @@ +0000000: 2d72 6f6d 3166 732d 0000 0090 32c1 24d3 -rom1fs-....2.$. +0000010: 4558 434c 5544 4553 0000 0000 0000 0000 EXCLUDES........ +0000020: 0000 0049 0000 0020 0000 0000 d1ff ff97 ...I... ........ +0000030: 2e00 0000 0000 0000 0000 0000 0000 0000 ................ +0000040: 0000 0060 0000 0020 0000 0000 d1d1 ff80 ...`... ........ +0000050: 2e2e 0000 0000 0000 0000 0000 0000 0000 ................ +0000060: 0000 0002 0000 0000 0000 0007 9d9a 8b96 ................ +0000070: 6265 7461 0000 0000 0000 0000 0000 0000 beta............ +0000080: 6e65 6564 6564 0a00 0000 0000 0000 0000 needed.......... +0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................ +* +00003f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/Makefile new/genromfs-0.5.7/selftest/Makefile --- old/genromfs-0.5.2/selftest/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/Makefile 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,5 @@ +all check: + $(MAKE) -C .. $@ + +dotest test: + bash ./test.sh diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/genromfs-0.5.2/selftest/test.sh new/genromfs-0.5.7/selftest/test.sh --- old/genromfs-0.5.2/selftest/test.sh 1970-01-01 01:00:00.000000000 +0100 +++ new/genromfs-0.5.7/selftest/test.sh 2009-02-15 11:48:15.000000000 +0100 @@ -0,0 +1,128 @@ +#!/bin/sh + +# requires: GNU md5sum and bash, xxd from vim +# known bug: file ordering is not actually specified + +NTESTS=13 +FAIL=0 +I=0 +V= +tdir=`pwd` +CMD=$tdir/../genromfs +mkdir testimg +cd testimg + +function testlabel () { + I=`expr $I + 1` + echo "$I/$NTESTS" "$@" + rm -f * + rm -f $tdir/img.bin +} + +function testsummary () { + xxd -a <$tdir/img.bin >$tdir/$I.out + if ! diff -u $tdir/$I.ok $tdir/$I.out; then + echo FAILED - Check differences above + FAIL=`expr $FAIL + 1` + else + echo OK + rm -f $tdir/$I.out + fi +} + +testlabel Test image with no files +eval $CMD $V -V EMPTY -f $tdir/img.bin +testsummary + +testlabel Test image with a single file +echo dummy >dummy +eval $CMD $V -V SINGLEFILE -f $tdir/img.bin +testsummary + +testlabel Test image with a hard links +echo dummy >dummy +ln dummy hardlink +eval $CMD $V -V HARDLINK -f $tdir/img.bin +testsummary + +testlabel Test image with alignment +echo t01abc >t01xyz +echo '(512aligned0123456789abcdef)' >t02uvw +echo t03ghi >t03rst +eval $CMD $V -V ALIGNED -A '512,t02*' -f $tdir/img.bin +testsummary + +testlabel Test image with alignment with absolute path +echo t01abc >t01xyz +echo t02def >t02uvw +echo '(128aligned0123456789abcdef)' >t03_123aligned +eval $CMD $V -V ABSALIGNED -A '128,/t03*' -f $tdir/img.bin +testsummary + +testlabel Test image with file data +echo 01230123uuu1012 >rom1a.txt +echo 01230123xyza012 >rom1b.txt +ln -s 01230123xyz1 rom1c.dat +ln -s rom1b.txt rom1d.txt +eval $CMD $V -V EXTDATA -f $tdir/img.bin +testsummary + +testlabel Test default alignment +echo 0123 >abc.txt +echo 4567 >def.txt +eval $CMD $V -V DEFALIGNED -a128 -f $tdir/img.bin +testsummary + +testlabel Test multiple alignment +echo boot512 >m68k.boot +echo boot2048 >sparc.boot +eval $CMD $V -V MULTIALIGNED -A2048,*.boot -A1024,m68k.boot -A512,m68k.boot -f $tdir/img.bin +testsummary + +testlabel Test excludes +echo unwanted >alpha +echo needed >beta +echo unwanted >gamma +eval $CMD $V -V EXCLUDES -x '"*a*a"' -f $tdir/img.bin +testsummary + +testlabel Test exclude/includes +echo wanted >good.txt +echo not >stuff.txt +echo del >erase.txt +eval $CMD $V -V INCLUDES -x '"*"' '"-i*good*"' -f $tdir/img.bin +testsummary + +testlabel Test new style alignment option +echo aligned >stuff.txt +echo del >*.sh +eval $CMD $V -V ALIGNNEW -ealign:256,*.txt -f $tdir/img.bin +testsummary + +testlabel Test permissions +echo xxxx >u63.txt +echo xxxx >g62.txt +echo yyyy >u63g62.txt +echo qqqq >u127g128.txt +echo zzzz >su11.txt +echo zzzz >sug62u63.txt +eval $CMD $V -V PERMISSIONS -euid:63,*u63* -egid:62,*g62* -euid:127,*127* -egid:128,*128* -eperm:4511,su* -f $tdir/img.bin +testsummary + +testlabel Test devices/permissions +mkdir dev +touch dev/@null,c,1,3 +touch dev/@zero,c,1,5 +echo 1234567890 >feb14.txt +eval $CMD $V -V DEVICES -eperm:711,/dev -eperm:666,/dev/* -etime:1234567890,feb14* -euid:100,feb* -egid:200,feb* -f $tdir/img.bin +testsummary +rm -rf dev + +# remove stray files +rm -f * + +# end +echo $FAIL failures found +cd $tdir +rm -f img.bin +rmdir testimg
participants (1)
-
Source-Sync