wok diff genromfs/stuff/genromfs.u @ rev 24924

Add as & asxxxx
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Apr 13 10:27:34 2022 +0000 (2022-04-13)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/genromfs/stuff/genromfs.u	Wed Apr 13 10:27:34 2022 +0000
     1.3 @@ -0,0 +1,144 @@
     1.4 +--- genromfs.c
     1.5 ++++ genromfs.c
     1.6 +@@ -164,6 +164,7 @@
     1.7 + 	uid_t nuid;
     1.8 + 	gid_t ngid;
     1.9 + 	time_t ntime;
    1.10 ++	nlink_t nlink;
    1.11 + 	unsigned int offset;
    1.12 + 	unsigned int realsize;
    1.13 + 	unsigned int prepad;
    1.14 +@@ -178,6 +179,8 @@
    1.15 + 	int extlen;
    1.16 + };
    1.17 + 
    1.18 ++static int oldromfs = 1;
    1.19 ++
    1.20 + #define EXTTYPE_UNKNOWN 0
    1.21 + #define EXTTYPE_ALIGNMENT 1
    1.22 + #define EXTTYPE_EXCLUDE 2
    1.23 +@@ -361,7 +364,9 @@
    1.24 + 	}
    1.25 + 	len+=16;
    1.26 + 	ri=(struct romfh *)bigbuf;
    1.27 +-	if (n->offset)
    1.28 ++	if (!oldromfs) 
    1.29 ++		ri->checksum = ntohl(n->ntime);
    1.30 ++	else if (n->offset)
    1.31 + 		fixsum(ri, len);
    1.32 + 	dumpdata(bigbuf, len, f);
    1.33 + #if 0
    1.34 +@@ -373,6 +378,9 @@
    1.35 + #endif
    1.36 + }
    1.37 + 
    1.38 ++#define SIGNED_OVERFLOW(x,m)  (((x) & (m)) != 0 && (((x) & (m)) | ~(m)) != ~0)
    1.39 ++#define SIGNED_EXTENTION(x,m) (((x) & (((m)+1)>>1)) ? (x) | ~(m) : (x) & (m))  
    1.40 ++
    1.41 + void dumpnode(struct filenode *node, FILE *f)
    1.42 + {
    1.43 + 	struct romfh ri;
    1.44 +@@ -386,13 +394,33 @@
    1.45 + 
    1.46 + 	ri.nextfh = 0;
    1.47 + 	ri.spec = 0;
    1.48 ++	if (!oldromfs) {
    1.49 ++		ri.spec = node->modes & (0x0FFF ^ S_IXUSR);
    1.50 ++		ri.spec ^= S_IRUSR |S_IWUSR;
    1.51 ++		ri.spec |= node->nuid << 20;
    1.52 ++		ri.spec |= (node->ngid & 0xFF) << 12;
    1.53 ++		if (node->ngid & 0x100)
    1.54 ++			ri.spec |= S_IXUSR;  
    1.55 ++		if (SIGNED_OVERFLOW(node->nuid,0xF000)) {
    1.56 ++			printf("%-50s : uid=%04X -> %04X \n",
    1.57 ++				node->realname, node->nuid,
    1.58 ++				(uid_t) SIGNED_EXTENTION(node->nuid,0x0FFF));
    1.59 ++		}
    1.60 ++		if (SIGNED_OVERFLOW(node->ngid,0xFE00)) {
    1.61 ++			printf("%-50s : gid=%04X -> %04X \n",
    1.62 ++				node->realname, node->ngid,
    1.63 ++				(gid_t) SIGNED_EXTENTION(node->ngid,0x01FF));
    1.64 ++		}
    1.65 ++	}
    1.66 ++	ri.spec = htonl(ri.spec);
    1.67 + 	ri.size = htonl(node->realsize);
    1.68 + 	ri.checksum = htonl(0x55555555);
    1.69 + 
    1.70 + 	if (node->next && node->next->next)
    1.71 + 		ri.nextfh = htonl(node->next->offset);
    1.72 + 	if ((node->modes & 0111) &&
    1.73 +-	    (S_ISDIR(node->modes) || S_ISREG(node->modes)))
    1.74 ++	    (S_ISDIR(node->modes) || S_ISREG(node->modes) ||
    1.75 ++	     (!oldromfs && (S_ISCHR(node->modes) || S_ISBLK(node->modes)))))
    1.76 + 		ri.nextfh |= htonl(ROMFH_EXEC);
    1.77 + 
    1.78 + 	if (node->orig_link) {
    1.79 +@@ -403,11 +431,17 @@
    1.80 + 		dumpri(&ri, node, f);
    1.81 + 	} else if (S_ISDIR(node->modes)) {
    1.82 + 		ri.nextfh |= htonl(ROMFH_DIR);
    1.83 ++ 		if (!oldromfs)
    1.84 ++			ri.size = ri.spec;
    1.85 + 		if (listisempty(&node->dirlist)) {
    1.86 + 			ri.spec = htonl(node->offset);
    1.87 + 		} else {
    1.88 + 			ri.spec = htonl(node->dirlist.head->offset);
    1.89 + 		}
    1.90 ++		if (node->nlink > 0xf)
    1.91 ++			node->nlink = 0xf;
    1.92 ++		if (!oldromfs)
    1.93 ++			ri.spec |= htonl(node->nlink);
    1.94 + 		dumpri(&ri, node, f);
    1.95 + 	} else if (S_ISLNK(node->modes)) {
    1.96 + 		ri.nextfh |= htonl(ROMFH_LNK);
    1.97 +@@ -464,10 +498,14 @@
    1.98 + 		}
    1.99 + 	} else if (S_ISCHR(node->modes)) {
   1.100 + 		ri.nextfh |= htonl(ROMFH_CHR);
   1.101 ++		if (!oldromfs)
   1.102 ++			ri.size = ri.spec;
   1.103 + 		ri.spec = htonl(major(node->devnode)<<16|minor(node->devnode));
   1.104 + 		dumpri(&ri, node, f);
   1.105 + 	} else if (S_ISBLK(node->modes)) {
   1.106 + 		ri.nextfh |= htonl(ROMFH_BLK);
   1.107 ++		if (!oldromfs)
   1.108 ++			ri.size = ri.spec;
   1.109 + 		ri.spec = htonl(major(node->devnode)<<16|minor(node->devnode));
   1.110 + 		dumpri(&ri, node, f);
   1.111 + 	} else if (S_ISFIFO(node->modes)) {
   1.112 +@@ -522,6 +560,7 @@
   1.113 + 	n->nuid = sb->st_uid;
   1.114 + 	n->ngid = sb->st_gid;
   1.115 + 	n->ntime = sb->st_mtime;
   1.116 ++	n->nlink = sb->st_nlink;
   1.117 + 	n->realsize = 0;
   1.118 + 	/* only regular files and symlinks contain "data" in romfs */
   1.119 + 	if (S_ISREG(n->modes) || S_ISLNK(n->modes)) {
   1.120 +@@ -574,6 +613,9 @@
   1.121 + 	node->ondev = -1;
   1.122 + 	node->onino = -1;
   1.123 + 	node->modes = -1;
   1.124 ++	node->realsize = 0;
   1.125 ++	node->devnode = 0;
   1.126 ++	node->orig_link = NULL;
   1.127 + 	node->offset = curroffset;
   1.128 + 	node->align = DEFALIGN;
   1.129 + 
   1.130 +@@ -935,6 +977,7 @@
   1.131 + 	printf("\n");
   1.132 + 	printf("  -f IMAGE               Output the image into this file\n");
   1.133 + 	printf("  -d DIRECTORY           Use this directory as source\n");
   1.134 ++	printf("  -t                     Time, uid & gid support (backward compatible)\n");
   1.135 + 	printf("  -v                     (Too) verbose operation\n");
   1.136 + 	printf("  -V VOLUME              Use the specified volume name\n");
   1.137 + 	printf("  -a ALIGN               Align regular file data to ALIGN bytes\n");
   1.138 +@@ -971,6 +1014,9 @@
   1.139 + 			break;
   1.140 + 		case 'V':
   1.141 + 			volname = optarg;
   1.142 ++			break;
   1.143 ++		case 't':
   1.144 ++		        oldromfs = 0;
   1.145 + 			break;
   1.146 + 		case 'v':
   1.147 + 			verbose = 1;