wok-current annotate genromfs/stuff/genromfs.u @ rev 22886

web-applications: update png files
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Feb 22 16:58:29 2020 +0100 (2020-02-22)
parents
children
rev   line source
pascal@17253 1 --- genromfs.c
pascal@17253 2 +++ genromfs.c
pascal@17253 3 @@ -164,6 +164,7 @@
pascal@17253 4 uid_t nuid;
pascal@17253 5 gid_t ngid;
pascal@17253 6 time_t ntime;
pascal@17253 7 + nlink_t nlink;
pascal@17253 8 unsigned int offset;
pascal@17253 9 unsigned int realsize;
pascal@17253 10 unsigned int prepad;
pascal@17253 11 @@ -178,6 +179,8 @@
pascal@17253 12 int extlen;
pascal@17253 13 };
pascal@17253 14
pascal@17253 15 +static int oldromfs = 1;
pascal@17253 16 +
pascal@17253 17 #define EXTTYPE_UNKNOWN 0
pascal@17253 18 #define EXTTYPE_ALIGNMENT 1
pascal@17253 19 #define EXTTYPE_EXCLUDE 2
pascal@17253 20 @@ -361,7 +364,9 @@
pascal@17253 21 }
pascal@17253 22 len+=16;
pascal@17253 23 ri=(struct romfh *)bigbuf;
pascal@17253 24 - if (n->offset)
pascal@17253 25 + if (!oldromfs)
pascal@17253 26 + ri->checksum = ntohl(n->ntime);
pascal@17253 27 + else if (n->offset)
pascal@17253 28 fixsum(ri, len);
pascal@17253 29 dumpdata(bigbuf, len, f);
pascal@17253 30 #if 0
pascal@17253 31 @@ -373,6 +378,9 @@
pascal@17253 32 #endif
pascal@17253 33 }
pascal@17253 34
pascal@17253 35 +#define SIGNED_OVERFLOW(x,m) (((x) & (m)) != 0 && (((x) & (m)) | ~(m)) != ~0)
pascal@17253 36 +#define SIGNED_EXTENTION(x,m) (((x) & (((m)+1)>>1)) ? (x) | ~(m) : (x) & (m))
pascal@17253 37 +
pascal@17253 38 void dumpnode(struct filenode *node, FILE *f)
pascal@17253 39 {
pascal@17253 40 struct romfh ri;
pascal@17253 41 @@ -386,13 +394,33 @@
pascal@17253 42
pascal@17253 43 ri.nextfh = 0;
pascal@17253 44 ri.spec = 0;
pascal@17253 45 + if (!oldromfs) {
pascal@17253 46 + ri.spec = node->modes & (0x0FFF ^ S_IXUSR);
pascal@17253 47 + ri.spec ^= S_IRUSR |S_IWUSR;
pascal@17253 48 + ri.spec |= node->nuid << 20;
pascal@17253 49 + ri.spec |= (node->ngid & 0xFF) << 12;
pascal@17253 50 + if (node->ngid & 0x100)
pascal@17253 51 + ri.spec |= S_IXUSR;
pascal@17253 52 + if (SIGNED_OVERFLOW(node->nuid,0xF000)) {
pascal@17253 53 + printf("%-50s : uid=%04X -> %04X \n",
pascal@17253 54 + node->realname, node->nuid,
pascal@17253 55 + (uid_t) SIGNED_EXTENTION(node->nuid,0x0FFF));
pascal@17253 56 + }
pascal@17253 57 + if (SIGNED_OVERFLOW(node->ngid,0xFE00)) {
pascal@17253 58 + printf("%-50s : gid=%04X -> %04X \n",
pascal@17253 59 + node->realname, node->ngid,
pascal@17253 60 + (gid_t) SIGNED_EXTENTION(node->ngid,0x01FF));
pascal@17253 61 + }
pascal@17253 62 + }
pascal@17253 63 + ri.spec = htonl(ri.spec);
pascal@17253 64 ri.size = htonl(node->realsize);
pascal@17253 65 ri.checksum = htonl(0x55555555);
pascal@17253 66
pascal@17253 67 if (node->next && node->next->next)
pascal@17253 68 ri.nextfh = htonl(node->next->offset);
pascal@17253 69 if ((node->modes & 0111) &&
pascal@17253 70 - (S_ISDIR(node->modes) || S_ISREG(node->modes)))
pascal@17253 71 + (S_ISDIR(node->modes) || S_ISREG(node->modes) ||
pascal@17253 72 + (!oldromfs && (S_ISCHR(node->modes) || S_ISBLK(node->modes)))))
pascal@17253 73 ri.nextfh |= htonl(ROMFH_EXEC);
pascal@17253 74
pascal@17253 75 if (node->orig_link) {
pascal@17253 76 @@ -403,11 +431,17 @@
pascal@17253 77 dumpri(&ri, node, f);
pascal@17253 78 } else if (S_ISDIR(node->modes)) {
pascal@17253 79 ri.nextfh |= htonl(ROMFH_DIR);
pascal@17253 80 + if (!oldromfs)
pascal@17253 81 + ri.size = ri.spec;
pascal@17253 82 if (listisempty(&node->dirlist)) {
pascal@17253 83 ri.spec = htonl(node->offset);
pascal@17253 84 } else {
pascal@17253 85 ri.spec = htonl(node->dirlist.head->offset);
pascal@17253 86 }
pascal@17253 87 + if (node->nlink > 0xf)
pascal@17253 88 + node->nlink = 0xf;
pascal@17253 89 + if (!oldromfs)
pascal@17253 90 + ri.spec |= htonl(node->nlink);
pascal@17253 91 dumpri(&ri, node, f);
pascal@17253 92 } else if (S_ISLNK(node->modes)) {
pascal@17253 93 ri.nextfh |= htonl(ROMFH_LNK);
pascal@17253 94 @@ -464,10 +498,14 @@
pascal@17253 95 }
pascal@17253 96 } else if (S_ISCHR(node->modes)) {
pascal@17253 97 ri.nextfh |= htonl(ROMFH_CHR);
pascal@17253 98 + if (!oldromfs)
pascal@17253 99 + ri.size = ri.spec;
pascal@17253 100 ri.spec = htonl(major(node->devnode)<<16|minor(node->devnode));
pascal@17253 101 dumpri(&ri, node, f);
pascal@17253 102 } else if (S_ISBLK(node->modes)) {
pascal@17253 103 ri.nextfh |= htonl(ROMFH_BLK);
pascal@17253 104 + if (!oldromfs)
pascal@17253 105 + ri.size = ri.spec;
pascal@17253 106 ri.spec = htonl(major(node->devnode)<<16|minor(node->devnode));
pascal@17253 107 dumpri(&ri, node, f);
pascal@17253 108 } else if (S_ISFIFO(node->modes)) {
pascal@17253 109 @@ -522,6 +560,7 @@
pascal@17253 110 n->nuid = sb->st_uid;
pascal@17253 111 n->ngid = sb->st_gid;
pascal@17253 112 n->ntime = sb->st_mtime;
pascal@17253 113 + n->nlink = sb->st_nlink;
pascal@17253 114 n->realsize = 0;
pascal@17253 115 /* only regular files and symlinks contain "data" in romfs */
pascal@17253 116 if (S_ISREG(n->modes) || S_ISLNK(n->modes)) {
pascal@17253 117 @@ -574,6 +613,9 @@
pascal@17253 118 node->ondev = -1;
pascal@17253 119 node->onino = -1;
pascal@17253 120 node->modes = -1;
pascal@17253 121 + node->realsize = 0;
pascal@17253 122 + node->devnode = 0;
pascal@17253 123 + node->orig_link = NULL;
pascal@17253 124 node->offset = curroffset;
pascal@17253 125 node->align = DEFALIGN;
pascal@17253 126
pascal@17253 127 @@ -935,6 +977,7 @@
pascal@17253 128 printf("\n");
pascal@17253 129 printf(" -f IMAGE Output the image into this file\n");
pascal@17253 130 printf(" -d DIRECTORY Use this directory as source\n");
pascal@17253 131 + printf(" -t Time, uid & gid support (backward compatible)\n");
pascal@17253 132 printf(" -v (Too) verbose operation\n");
pascal@17253 133 printf(" -V VOLUME Use the specified volume name\n");
pascal@17253 134 printf(" -a ALIGN Align regular file data to ALIGN bytes\n");
pascal@17253 135 @@ -971,6 +1014,9 @@
pascal@17253 136 break;
pascal@17253 137 case 'V':
pascal@17253 138 volname = optarg;
pascal@17253 139 + break;
pascal@17253 140 + case 't':
pascal@17253 141 + oldromfs = 0;
pascal@17253 142 break;
pascal@17253 143 case 'v':
pascal@17253 144 verbose = 1;