1 /* $MirOS: contrib/hosted/fwcf/ft_dump.c,v 1.5 2006/09/23 23:21:04 tg Exp $ */
5 * Thorsten Glaser <tg@mirbsd.de>
7 * Licensee is hereby permitted to deal in this work without restric-
8 * tion, including unlimited rights to use, publicly perform, modify,
9 * merge, distribute, sell, give away or sublicence, provided all co-
10 * pyright notices above, these terms and the disclaimer are retained
11 * in all redistributions or reproduced in accompanying documentation
12 * or other materials provided with binary redistributions.
14 * Licensor offers the work "AS IS" and WITHOUT WARRANTY of any kind,
15 * express, or implied, to the maximum extent permitted by applicable
16 * law, without malicious intent or gross negligence; in no event may
17 * licensor, an author or contributor be held liable for any indirect
18 * or other damage, or direct damage except proven a consequence of a
19 * direct error of said person and intended use of this work, loss or
20 * other issues arising in any way out of its use, even if advised of
21 * the possibility of such damage or existence of a defect.
24 #include <sys/param.h>
34 __RCSID("$MirOS: contrib/hosted/fwcf/ft_dump.c,v 1.5 2006/09/23 23:21:04 tg Exp $");
36 static int ft_dumpfile(char *);
42 buf
+= ft_dumpfile(buf
);
46 ft_dumpfile(char *buf
)
49 int i
, type
= 0, size
= 0;
54 printf("\nNAME=%s\n", buf
);
55 p
= (uint8_t *)buf
+ i
;
63 printf("CHARACTER\n");
75 printf("DIRECTORY\n");
82 printf("MTIME=%d -> %s", (int)y
, ctime(&y
));
89 x
= (c
& 0x20) ? *p
: LOADD(p
);
90 p
+= (c
& 0x20) ? 1 : 4;
91 printf("%cID=%d\n", c
& ~0x20, x
);
95 x
= (c
== 'i') ? *p
: LOADW(p
);
96 p
+= (c
== 'i') ? 1 : 2;
97 printf("INODE=%d\n", x
);
101 x
= (c
== 'm') ? LOADW(p
) : LOADD(p
);
102 p
+= (c
== 'm') ? 2 : 4;
103 printf("MODE=0%o\n", x
);
107 x
= (c
== 's') ? *p
: LOADT(p
);
108 p
+= (c
== 's') ? 1 : 3;
109 printf("SIZE=%d\n", size
= x
);
112 errx(1, "unknown attribute %02Xh", c
);
118 if ((target
= malloc(size
+ 1)) == NULL
)
120 memcpy(target
, p
, size
);
122 printf("LINK_TARGET=%s\n", target
);
124 } else if (type
== 1) {
126 printf("WARN: size not allowed, ignoring\n");
129 printf("BEGIN DATA\n");
131 write(STDOUT_FILENO
, p
, size
);
132 printf("\nEND DATA\n");
134 return ((p
- (uint8_t *)buf
) + size
);