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